Example #1
0
def run_viewer(app, message):
    print("[main.py] running viewer to approve")
    run_command(get_command_openvt(sudo_user(normal_user, "./" + viewer_exe)))
    time.sleep(2)
    print("[main.py] going to connect to sock")
    viewer = UnixSocketClient(viewer_sock_path)
    viewer.write_line("view %s %s %s" % (app.executable, app.exec_hash, message ))
    read = viewer.read_line()
    viewer.write_line("end")
    if read is "1":
        return True
    return False
Example #2
0
def init_loop():
    run_command(get_command_openvt(sudo_user(normal_user, "./" + getpass_exe)))
    run_command("./" + checkpass_exe)

    time.sleep(2)

    getpass_sock = UnixSocketClient(getpass_sock_path)
    checkpass_sock = UnixSocketClient(checkpass_sock_path)

    success = False
    master_password = ""

    while True:
        getpass_read = getpass_sock.read_line()

        if getpass_read[0] in ['0', '1']:
            checkpass_sock.write_line("end")

            if getpass_read[0] is '1':
                success = True
                master_password = getpass_read.split()[1]
            break

        checkpass_sock.write_line(getpass_read)
        getpass_sock.write_line(checkpass_sock.read_line())

    return success, master_password
Example #3
0
# parser.add_argument("-u")
# args = parser.parse_args()

username = "******"

if "-u" in sys.argv:
    i = sys.argv[1:].index("-u")
    username = sys.argv[i+1]

if "--user" in sys.argv:
    i = sys.argv[1:].index("--user")
    username = sys.argv[i+1]

try:
    saved_id = d[username]
    client.write_line("get %s" % saved_id)
    _ , saved_id, username, password = client.read_line().split()
except KeyError:
    password = getpass.getpass()
    client.write_line("save %s %s" % (username, password))
    id = client.read_line().split()[1]
    d[username] = id

client.write_line("end")
client.disconnect()
d.close()

nosudo_command = " ".join(sys.argv[1:])
command = ("sudo -S %s" % (nosudo_command)).split()

p = Popen(['sudo', '-S'] + command, stdin=PIPE,