File: pseudo.py

package info (click to toggle)
cockpit 337-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 36,232 kB
  • sloc: javascript: 47,090; python: 38,766; ansic: 35,470; xml: 6,048; sh: 3,413; makefile: 614
file content (18 lines) | stat: -rw-r--r-- 513 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import os
import sys

from cockpit._vendor.ferny import interaction_client

pw = os.environ.get('PSEUDO_PASSWORD')
if pw:
    reader, writer = os.pipe()
    # '-' is the (ignored) argv[0], and 'can haz pw' is the message in argv[1]
    interaction_client.askpass(2, writer, ['-', 'can haz pw?'], {})
    os.close(writer)

    response = os.read(reader, 1024).decode().strip()
    if response != pw:
        sys.stderr.write('pseudo says: Bad password\n')
        sys.exit(1)

os.execvp(sys.argv[1], sys.argv[1:])