mirror of
https://github.com/os-mnemo/pan-globalprotect-okta
synced 2026-07-31 07:44:38 +02:00
Escape backslash in username and other fields, i.e., use single quote.
Add work-around for additional username input.
This commit is contained in:
@@ -46,4 +46,9 @@ override `password` option in configuration file.
|
||||
|
||||
If `openconnect` returns with `ioctl` error, then this version has a bug, which
|
||||
requires to prefix stdin input with a newline. Set `bug.nl=1` in configuration
|
||||
file to work-around this issue.
|
||||
file to work-around this issue.
|
||||
|
||||
If `openconnect` returns with `fgets (stdin): Resource temporarily unavailable`
|
||||
error, then this version has a bug, which requires to prefix stdin input with a
|
||||
username. Set `bug.username=1` in configuration file to work-around this issue.
|
||||
|
||||
|
||||
@@ -10,3 +10,4 @@ gateway = Manual ny1-gw.example.com
|
||||
openconnect_args = # optional arguments to openconnect
|
||||
execute = 0 # execute openconnect command
|
||||
bug.nl = 0 # newline work-around for openconnect
|
||||
bug.username = 0 # username work-around for openconnect
|
||||
|
||||
+11
-6
@@ -345,17 +345,22 @@ def main():
|
||||
userauthcookie = paloalto_getconfig(conf, s, saml_username, prelogin_cookie)
|
||||
log('portal-userauthcookie: {0}'.format(userauthcookie))
|
||||
|
||||
username = saml_username
|
||||
cmd = conf.get('openconnect_cmd') or 'openconnect'
|
||||
cmd += ' --protocol=gp -u "{0}"'
|
||||
cmd += ' --protocol=gp -u \'{0}\''
|
||||
cmd += ' --usergroup portal:portal-userauthcookie'
|
||||
cmd += ' --passwd-on-stdin ' + conf.get('openconnect_args', '') + ' "{1}"'
|
||||
cmd = cmd.format(saml_username, conf.get('vpn_url'))
|
||||
cmd += ' --passwd-on-stdin ' + conf.get('openconnect_args', '') + ' \'{1}\''
|
||||
cmd = cmd.format(username, conf.get('vpn_url'))
|
||||
gw = (conf.get('gateway') or '').strip()
|
||||
nlbug = '\\n' if conf.get('bug.nl', '').lower() in ['1', 'true'] else ''
|
||||
bugs = ''
|
||||
if conf.get('bug.nl', '').lower() in ['1', 'true']:
|
||||
bugs += '\\n'
|
||||
if conf.get('bug.username', '').lower() in ['1', 'true']:
|
||||
bugs += '{0}\\n'.format(username.replace('\\', '\\\\'))
|
||||
if len(gw) > 0:
|
||||
pcmd = 'printf "' + nlbug + '{0}\\n{1}"'.format(userauthcookie, gw)
|
||||
pcmd = 'printf \'' + bugs + '{0}\\n{1}\''.format(userauthcookie, gw)
|
||||
else:
|
||||
pcmd = 'printf "' + nlbug + '{0}"'.format(userauthcookie)
|
||||
pcmd = 'printf \'' + bugs + '{0}\''.format(userauthcookie)
|
||||
print()
|
||||
if conf.get('execute', '').lower() in ['1', 'true']:
|
||||
cmd = shlex.split(cmd)
|
||||
|
||||
Reference in New Issue
Block a user