コード例 #1
0
ファイル: main.py プロジェクト: razeghi71/pypassman
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
コード例 #2
0
ファイル: main.py プロジェクト: razeghi71/pypassman
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
コード例 #3
0
ファイル: ssudo.py プロジェクト: razeghi71/pypassman
from common.connection import UnixSocketClient
from optparse import OptionParser
from common.sudo import run_command
from exceptions import KeyError
from subprocess import Popen, PIPE
import getpass
import argparse
import sys
import shelve


d = shelve.open("id.shelve")

api_path = "/tmp/passman_api"

client = UnixSocketClient(api_path)

# parser = argparse.ArgumentParser()
# 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]