Skip to content

Commit

Permalink
Merge pull request #4 from mfyuce/development
Browse files Browse the repository at this point in the history
GUI `sudo` ile baslatildigindan,  `su - root` komutu sifre sormayabiliyor…
  • Loading branch information
ciari authored Sep 2, 2019
2 parents 87679ff + 9f0de87 commit 654e6f8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions ahtapot-gdys-gui/var/opt/gdysgui/fwsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from dmrlogger import Filelogger
import pexpect

MAX_WAIT_TIME_FOR_PAM_TO_EXIT=10

try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
Expand Down Expand Up @@ -545,9 +547,15 @@ def get_file_list(self):
def pam_login(self,username, password):
try:
child = pexpect.spawn('/bin/su - %s'%(username))
child.expect('Password:')
child.sendline(password)
result=child.expect(['su: Authentication failure',username])
# wait until it request input or finishes,
# 10 sec seem to be log enough?
child.waitnoecho(MAX_WAIT_TIME_FOR_PAM_TO_EXIT)
if child.isalive():
child.sendline(password)
result=child.expect(['su: Authentication failure',username])
else:
result = 1 # user was asked no pwd
# TODO: check exit code
child.close()
except Exception as exc_err:
child.close()
Expand Down

0 comments on commit 654e6f8

Please sign in to comment.