add permission propertys

This commit is contained in:
chrys 2018-09-07 21:55:40 +02:00
parent 6b8c24831c
commit ef091a427d
8 changed files with 28 additions and 10 deletions

View File

@ -204,7 +204,7 @@ allowSettings=barrier#enabled
# allow commands to be executed
enableCommandRemote=True
# permitted commands
allowCommands=Say,defineWindow,resetSettings,resetWindow,toggleHighlight
allowCommands=say,interrupt,window,resetwindow
[barrier]
enabled=True

View File

@ -214,7 +214,7 @@ allowSettings=barrier#enabled
# allow commands to be executed
enableCommandRemote=True
# permitted commands
allowCommands=Say,defineWindow,resetSettings,resetWindow,toggleHighlight
allowCommands=say,interrupt,window,resetwindow
[barrier]
enabled=True

View File

@ -215,7 +215,7 @@ allowSettings=barrier#enabled
# allow commands to be executed
enableCommandRemote=True
# permitted commands
allowCommands=Say,defineWindow,resetSettings,resetWindow,toggleHighlight
allowCommands=say,interrupt,window,resetwindow
[barrier]
enabled=True

View File

@ -160,7 +160,7 @@ allowSettings=barrier#enabled
# allow commands to be executed
enableCommandRemote=True
# permitted commands
allowCommands=Say,defineWindow,resetSettings,resetWindow,toggleHighlight
allowCommands=say,interrupt,window,resetwindow
[barrier]
enabled=True

View File

@ -214,7 +214,7 @@ allowSettings=barrier#enabled
# allow commands to be executed
enableCommandRemote=True
# permitted commands
allowCommands=Say,defineWindow,resetSettings,resetWindow,toggleHighlight
allowCommands=say,interrupt,window,resetwindow
[barrier]
enabled=True

View File

@ -48,9 +48,9 @@ class remoteManager():
self.env = environment
if self.env['runtime']['settingsManager'].getSettingAsBool('remote', 'enabled'):
if self.env['runtime']['settingsManager'].getSetting('remote', 'method') == 'unix':
if self.env['runtime']['settingsManager'].getSetting('remote', 'method').upper() == 'UNIX':
self.env['runtime']['processManager'].addCustomEventThread(self.unixSocketWatchDog, multiprocess=True)
elif self.env['runtime']['settingsManager'].getSetting('remote', 'method') == 'tcp':
elif self.env['runtime']['settingsManager'].getSetting('remote', 'method').upper() == 'TCP':
self.env['runtime']['processManager'].addCustomEventThread(self.tcpWatchDog, multiprocess=True)
def shutdown(self):
if self.sock:
@ -126,6 +126,7 @@ class remoteManager():
def handleSettingsChange(self, settingsText):
if not self.env['runtime']['settingsManager'].getSettingAsBool('remote', 'enableSettingsRemote'):
return
upperSettingsText = settingsText.upper()
# set setting
if upperSettingsText.startswith(self.setSettingConst):
@ -137,7 +138,14 @@ class remoteManager():
def handleCommandExecution(self, commandText):
if not self.env['runtime']['settingsManager'].getSettingAsBool('remote', 'enableCommandRemote'):
return
allowCommands = self.env['runtime']['settingsManager'].getSetting('remote', 'allowCommands').upper().split(',')
upperCommandText = commandText.upper()
allowed = False
for a in allowCommands:
if upperCommandText.startswith(a):
allowed = True
if not allowed:
return
# say
if upperCommandText.startswith(self.sayConst):
parameterText = commandText[len(self.sayConst):]
@ -176,7 +184,9 @@ class remoteManager():
def resetSettings(self):
self.env['runtime']['settingsManager'].resetSettingArgDict()
def setSettings(self, settingsArgs):
self.env['runtime']['settingsManager'].parseSettingArgs(settingsArgs)
allowSettings = self.env['runtime']['settingsManager'].getSetting('remote', 'allowSettings').upper().split(',')
self.env['runtime']['settingsManager'].parseSettingArgs(settingsArgs, allowSettings)
def handleRemoteIncomming(self, eventData):
if not eventData:
return

View File

@ -89,7 +89,7 @@ settingsData = {
'enableSettingsRemote': True,
'allowSettings': 'barrier#enabled',
'enableCommandRemote': True,
'allowCommands': 'Say,defineWindow,resetSettings,resetWindow,toggleHighlight',
'allowCommands': 'say,interrupt,window,resetwindow',
},
'barrier':{
'enabled': True,

View File

@ -186,12 +186,20 @@ class settingsManager():
self.settingArgDict[section] = {}
self.settingArgDict[section][option] = str(value)
def parseSettingArgs(self, settingArgs):
def parseSettingArgs(self, settingArgs, allowSettings):
for optionElem in settingArgs.split(';'):
if len(optionElem.split('#',1)) != 2:
continue
if len(optionElem.split('#',1)[1].split('=',1)) != 2:
continue
allowed = False
if allowSettings:
for a in allowSettings:
if a in optionElem:
allowed = True
if not allowed:
continue
section = str(optionElem.split('#',1)[0]).lower()
option = str(optionElem.split('#',1)[1].split('=',1)[0]).lower()
value = optionElem.split('#',1)[1].split('=',1)[1]