mirror of
				https://github.com/Rudd-O/ansible-qubes.git
				synced 2025-11-04 05:28:54 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			49 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/env python
 | 
						|
 | 
						|
import pipes
 | 
						|
import os
 | 
						|
import subprocess
 | 
						|
import sys
 | 
						|
 | 
						|
argv = list(sys.argv[1:])
 | 
						|
if argv[0].startswith("--proxy="):
 | 
						|
    remotehost = argv[0][8:]
 | 
						|
    argv = argv[1:]
 | 
						|
else:
 | 
						|
    remotehost = None
 | 
						|
host, parms = argv[0], argv[1:]
 | 
						|
 | 
						|
path_to_bombshell = os.path.join(os.path.dirname(__file__), "bombshell-client")
 | 
						|
 | 
						|
if os.getenv("BOMBSHELL_DEBUG"):
 | 
						|
    cmd = [
 | 
						|
        path_to_bombshell,
 | 
						|
        "-d",
 | 
						|
        host,
 | 
						|
    ] + parms
 | 
						|
else:
 | 
						|
    cmd = [
 | 
						|
        path_to_bombshell,
 | 
						|
        host,
 | 
						|
    ] + parms
 | 
						|
 | 
						|
if remotehost:
 | 
						|
    args = " ".join(pipes.quote(x) for x in parms)
 | 
						|
    poop = file(path_to_bombshell, "rb").read().encode("hex_codec")
 | 
						|
    therest_template = ("test -x ./.bombshell-client || "
 | 
						|
                        "python -c 'import os; file(\"./.bombshell-client\", \"wb\").write(\"%s\".decode(\"hex_codec\")); os.chmod(\"./.bombshell-client\", 0700)' || "
 | 
						|
                        "exit 127 ;"
 | 
						|
                        "./.bombshell-client %s %s %s")
 | 
						|
    therest = therest_template % (poop,
 | 
						|
                                  "-d" if os.getenv("BOMBSHELL_DEBUG") else "",
 | 
						|
                                  pipes.quote(host),
 | 
						|
                                  args)
 | 
						|
    cmd = [
 | 
						|
        'ssh',
 | 
						|
        '-o', 'BatchMode yes',
 | 
						|
        remotehost,
 | 
						|
        therest,
 | 
						|
    ]
 | 
						|
 | 
						|
os.execvp(cmd[0], cmd)
 |