radius: on se débarasse du fils ssh
Et on a presque un truc qui marche. Bon le trigger_generate, on va vite le virer parce que c'est mauche tout de même.
This commit is contained in:
parent
b372b52c76
commit
d5bd1ec23e
3 changed files with 57 additions and 17 deletions
|
@ -3,16 +3,22 @@
|
|||
|
||||
import subprocess
|
||||
|
||||
def trigger_generate(host, background=False):
|
||||
_options = ['PasswordAuthentication=no', 'ConnectTimeout=1', 'VerifyHostKeyDNS=yes',
|
||||
'BatchMode=yes', 'ServerAliveInterval=5', 'ServerAliveCountMax=1']
|
||||
_args = ["ssh", "-4", "-i", "/etc/crans/secrets/trigger-generate" ]
|
||||
|
||||
def build_args(host):
|
||||
if not 'adm.crans.org' in host:
|
||||
host=host + '.adm.crans.org'
|
||||
options = ['PasswordAuthentication=no', 'ConnectTimeout=1', 'VerifyHostKeyDNS=yes',
|
||||
'BatchMode=yes', 'ServerAliveInterval=5', 'ServerAliveCountMax=1']
|
||||
args = ["ssh", "-4", "-i", "/etc/crans/secrets/trigger-generate" ]
|
||||
for opt in options:
|
||||
args = list(_args)
|
||||
for opt in _options:
|
||||
args.append('-o')
|
||||
args.append(opt)
|
||||
args.extend(["rpcssh@%s" % host, "generate"])
|
||||
return args
|
||||
|
||||
def trigger_generate(host, background=False):
|
||||
args = build_args(host)
|
||||
if background:
|
||||
subprocess.Popen(args)
|
||||
else:
|
||||
|
@ -22,3 +28,10 @@ def trigger_generate(host, background=False):
|
|||
raise Exception(err)
|
||||
return out
|
||||
|
||||
def trigger_generate_cochon(host):
|
||||
"""Ceci est une fonction crade qui permet de se débarraser du process enfant
|
||||
que l'on aurait laissé en arrière plan"""
|
||||
args = build_args(host)
|
||||
p = subprocess.Popen(['/bin/bash'],
|
||||
stdin=subprocess.PIPE, )
|
||||
p.communicate(' '.join(args) + ' &> /dev/null &')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue