[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#634829: libpam-mklocaluser: login fails when used in conjunction with sssd



[Wolfgang Schulze-Zachau]
> Attached is a modified version of the python script which works for
> me.  Essentially I have added some poll() calls to ensure the shell
> commands are completed before communicating with the subprocesses.

Right.  Make sense.

> I have also added two lines in the runcmd subroutine to log any
> error messages to syslog. Hope that's OK with you.

Fine with me.  But what will happen if a command print more than one
line on stderr?

> I will now do further testing of this.

Great.

For the record, here is the relevant patch representing your change.

Index: debian/pam-python.py
===================================================================
--- debian/pam-python.py        (revision 69429)
+++ debian/pam-python.py        (working copy)
@@ -17,7 +17,11 @@

 def runcmd(pamh, cmd):
   proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,)
-  output = proc.communicate()[0]
+  while proc.poll() == None:
+    pass
+  result = proc.communicate(input=None)[0]
+  if result != 0:
+    syslog.syslog("Command %(command)s failed with %(msg)s" % ( cmd, proc.stderr.read()) )
 #  print "output: %s" % output

 def check_and_create_localuser(pamh, user):
@@ -53,8 +57,10 @@

   # Ignore users with existing entry in /etc/passwd
   cmd = "/bin/grep \"^%s:\" /etc/passwd >/dev/null" % user
-  proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,)
-  result = proc.communicate()
+  proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, )
+  while proc.poll() == None:
+    pass
+  result = proc.communicate(input=None)[0]
   if proc.returncode == 0:
     return pamh.PAM_SUCCESS


Happy hacking,
-- 
Petter Reinholdtsen



Reply to: