Exit if the eval_password command returns a non-zero status code
This commit is contained in:
parent
99d5e25f9b
commit
fce4daf4a1
1 changed files with 8 additions and 2 deletions
|
@ -15,6 +15,7 @@ log = logging.getLogger(__name__)
|
||||||
|
|
||||||
import getpass
|
import getpass
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
import slixmpp
|
import slixmpp
|
||||||
from slixmpp.plugins.xep_0184 import XEP_0184
|
from slixmpp.plugins.xep_0184 import XEP_0184
|
||||||
|
@ -49,10 +50,15 @@ class Connection(slixmpp.ClientXMPP):
|
||||||
if not password and not eval_password and not (keyfile and certfile):
|
if not password and not eval_password and not (keyfile and certfile):
|
||||||
password = getpass.getpass()
|
password = getpass.getpass()
|
||||||
elif not password and not (keyfile and certfile):
|
elif not password and not (keyfile and certfile):
|
||||||
print("No password or certificates provided, using the eval_password command.")
|
sys.stderr.write("No password or certificates provided, using the eval_password command.\n")
|
||||||
process = subprocess.Popen(['sh', '-c', eval_password], stdin=subprocess.PIPE,
|
process = subprocess.Popen(['sh', '-c', eval_password], stdin=subprocess.PIPE,
|
||||||
stdout=subprocess.PIPE, close_fds=True)
|
stdout=subprocess.PIPE, close_fds=True)
|
||||||
process.wait()
|
code = process.wait()
|
||||||
|
if code != 0:
|
||||||
|
sys.stderr.write('The eval_password command (%s) returned a '
|
||||||
|
'nonzero status code: %s.\n' % (eval_password, code))
|
||||||
|
sys.stderr.write('Poezio will now exit\n')
|
||||||
|
sys.exit(code)
|
||||||
password = process.stdout.readline().decode('utf-8').strip('\n')
|
password = process.stdout.readline().decode('utf-8').strip('\n')
|
||||||
else: # anonymous auth
|
else: # anonymous auth
|
||||||
self.anon = True
|
self.anon = True
|
||||||
|
|
Loading…
Reference in a new issue