remote-file: add --remote-root option for security

This commit is contained in:
jean-emmanuel 2019-04-04 22:31:17 +02:00
parent 09d41cae5b
commit 2ab2614853
4 changed files with 9 additions and 1 deletions

View file

@ -70,7 +70,10 @@ $(document).ready(()=>{
browse.click(function(e){
e.preventDefault()
dialog.showOpenDialog({filters:[{name:option.file.name,extensions:option.file.extensions}]},function(file){
dialog.showOpenDialog({
filters:[{name:option.file.name,extensions:option.file.extensions}],
properties: option.file.folder ? ['openDirectory'] : ['openFile']
},function(file){
input.val(file).change()
})
})

View file

@ -380,6 +380,9 @@ module.exports = {
if (data.path) p = path.resolve(...data.path)
var root = settings.read('remoteRoot')
if (root && !p.includes(root)) p = root
fs.readdir(p, (err, files)=>{
if (err) {
ipc.send('notify', {class: 'error', message: err.message}, clientId)

View file

@ -82,6 +82,7 @@ module.exports = {
return msg
}
},
'remote-root':{type:'string', describe:'set remote file browsing root folder', file:{folder: true}},
'instance-name':{type:'string',describe:'used to differenciate multiple instances in a zeroconf network'},
'fullscreen':{type:'boolean', describe:'launch in fullscreen mode (only affects the default gui, F11 to exit)'},
'inspect':{type:'boolean', describe:'enable node/electron inspector', launcher: false}

View file

@ -76,6 +76,7 @@ var makeDefaultConfig = function(argv){
noGpu: argv['disable-gpu'] || false,
readOnly: argv['read-only'] || false,
remoteSaving: argv['remote-saving'] ? RegExp(argv['remote-saving']) : false,
remoteRoot: argv['remote-root'] || false,
midi: argv['midi'],
stateFile: (function(){
if (!argv['state']) return false