~ubuntu-branches/ubuntu/trusty/libpam-mklocaluser/trusty

« back to all changes in this revision

Viewing changes to debian/pam-python.py

  • Committer: Bazaar Package Importer
  • Author(s): Petter Reinholdtsen
  • Date: 2011-07-28 19:20:32 UTC
  • Revision ID: james.westby@ubuntu.com-20110728192032-guexxb63uno0t6x9
Tags: 0.7
* Rewrite how Popen() is used to ensure the script wait for the
  subprocesses to start before looking for their status (Closes:
  #634829).  Patch from Wolfgang Schulze-Zachau.
* Update standards-version from 3.9.1 to 3.9.2.  No changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
def runcmd(pamh, cmd):
19
19
  proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,)
20
 
  output = proc.communicate()[0]
 
20
  while proc.poll() == None:
 
21
    pass
 
22
  result = proc.communicate(input=None)[0]
 
23
  if result != 0:
 
24
    syslog.syslog("Command %(command)s failed with %(msg)s" % ( cmd, proc.stderr.read()) )
21
25
#  print "output: %s" % output
22
26
 
23
27
def check_and_create_localuser(pamh, user):
53
57
 
54
58
  # Ignore users with existing entry in /etc/passwd
55
59
  cmd = "/bin/grep \"^%s:\" /etc/passwd >/dev/null" % user
56
 
  proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,)
57
 
  result = proc.communicate()
 
60
  proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, )
 
61
  while proc.poll() == None:
 
62
    pass
 
63
  result = proc.communicate(input=None)[0]
58
64
  if proc.returncode == 0:
59
65
    return pamh.PAM_SUCCESS
60
66