bugfix bad ssh command parsing
add more logging
This commit is contained in:
parent
9a6ec1a6b3
commit
d09c0c82ea
1 changed files with 14 additions and 7 deletions
|
|
@ -249,35 +249,42 @@ class AutoSSHTunnelMonitor(list):
|
||||||
# ssh cmd line, got from /proc
|
# ssh cmd line, got from /proc
|
||||||
f = open( '/proc/' + str(sshpid) + '/cmdline' )
|
f = open( '/proc/' + str(sshpid) + '/cmdline' )
|
||||||
cmd = f.readlines()[0]
|
cmd = f.readlines()[0]
|
||||||
|
f.close()
|
||||||
logging.debug("SSH command: %s" % cmd)
|
logging.debug("SSH command: %s" % cmd)
|
||||||
|
|
||||||
# if not an ssh tunnel command
|
# if not an ssh tunnel command
|
||||||
if ('-L' not in cmd) and (':' not in cmd):
|
if ('-L' not in cmd) or (':' not in cmd):
|
||||||
# do not list it
|
# do not list it
|
||||||
logging.debug("Not a tunnel command")
|
logging.debug("Not a tunnel command")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
f.close()
|
|
||||||
logging.debug("Is a tunnel command")
|
logging.debug("Is a tunnel command")
|
||||||
|
|
||||||
# autossh parent process
|
# autossh parent process
|
||||||
f = open( '/proc/' + str(sshpid) + '/status' )
|
ppidf = '/proc/' + str(sshpid) + '/status'
|
||||||
|
logging.debug("Parse %s" % ppidf)
|
||||||
|
f = open( ppidf )
|
||||||
|
|
||||||
# filter the parent pid
|
# filter the parent pid
|
||||||
lpid = [i for i in f.readlines() if 'PPid' in i]
|
lpid = [i for i in f.readlines() if 'PPid' in i]
|
||||||
|
|
||||||
f.close()
|
f.close()
|
||||||
|
logging.debug("PPid: %s" % lpid)
|
||||||
|
|
||||||
# parsing
|
# parsing
|
||||||
ppid = int(lpid[0].split(':')[1].strip())
|
ppid = int(lpid[0].split(':')[1].strip())
|
||||||
|
logging.debug("Parsed PPid: %s" % ppid)
|
||||||
|
|
||||||
# command line of the parent process
|
# command line of the parent process
|
||||||
f = open( '/proc/' + str(ppid) + '/cmdline' )
|
pcmdf = '/proc/' + str(ppid) + '/cmdline'
|
||||||
|
logging.debug("Parse %s" % pcmdf)
|
||||||
|
f = open( pcmdf )
|
||||||
|
|
||||||
# exclude the port
|
# exclude the port
|
||||||
autohost = f.readlines()[0].split(':')[1]
|
content = f.readlines()
|
||||||
|
logging.debug("Cmd: %s" % content[0])
|
||||||
|
autohost = content[0].split(':')[1]
|
||||||
f.close()
|
f.close()
|
||||||
|
logging.debug("Parsed cmd without port: %s" % autohost)
|
||||||
|
|
||||||
# instanciation
|
# instanciation
|
||||||
tunnels.append( SSHTunnel( local_addr, local_port, foreign_addr, foreign_port, autohost, status, sshpid, ppid ) )
|
tunnels.append( SSHTunnel( local_addr, local_port, foreign_addr, foreign_port, autohost, status, sshpid, ppid ) )
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue