[debian-edu-commits] debian-edu/upstream/ 27/71: Lot to syslog, not to stdout.
Petter Reinholdtsen
pere at moszumanska.debian.org
Mon Jun 9 18:25:37 UTC 2014
This is an automated email from the git hooks/post-receive script.
pere pushed a commit to branch master
in repository libpam-mklocaluser.
commit 43a13a5f3a25c38dd25ef3d5db7dc133e306c950
Author: Petter Reinholdtsen <pere at hungry.com>
Date: Tue May 4 18:03:21 2010 +0000
Lot to syslog, not to stdout.
---
debian/pam-python.py | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/debian/pam-python.py b/debian/pam-python.py
index ed4a521..709f9c9 100755
--- a/debian/pam-python.py
+++ b/debian/pam-python.py
@@ -13,6 +13,7 @@ import subprocess
import shutil
import math
import time
+import syslog
def runcmd(pamh, cmd):
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,)
@@ -54,12 +55,12 @@ def check_and_create_localuser(pamh, user):
return pamh.PAM_SUCCESS
if None == homedir:
- print "Home directory is not set for user %s" % user
+ syslog.syslog("Home directory is not set for user %s" % user)
return pamh.PAM_USER_UNKNOWN
newhomedir = os.path.join(topdir, user)
if not os.path.isdir(newhomedir):
-# print "Creating local passwd entry uid=%d (%s) gid=%d(%s) gecos='%s' home=%s" % (uid, user, gid, groupname, gecos, newhomedir)
+ syslog.syslog("Creating local passwd entry uid=%d(%s) gid=%d(%s) gecos='%s' home=%s" % (uid, user, gid, groupname, gecos, newhomedir))
try:
# Add user entry with overridden home directory in /etc/passwd.
# XXX Should only add entry if is is missing in /etc/passwd
@@ -78,6 +79,7 @@ def check_and_create_localuser(pamh, user):
% (user, pwlastchange, pwminage, pwmaxage, pwwarn)
runcmd(pamh, cmd)
+ syslog.syslog("Creating local home directory for user '%s'" % user)
# Copy content of /etc/skel
shutil.copytree("/etc/skel/.", newhomedir, True)
@@ -102,7 +104,7 @@ def check_and_create_localuser(pamh, user):
# and need to be restarted.
return pamh.PAM_TRY_AGAIN
except Exception, e:
- print e
+ syslog.syslog(e)
pass
return pamh.PAM_SUCCESS
@@ -117,18 +119,19 @@ def pam_sm_acct_mgmt(pamh, flags, argv):
return pamh.PAM_SUCCESS
def pam_sm_open_session(pamh, flags, argv):
+ syslog.openlog("pam_localoffline", syslog.LOG_PID, syslog.LOG_AUTH)
try:
user = pamh.get_user(None)
except pamh.exception, e:
return e.pam_result
if user == None:
- print "No user, ignoring pam-python for localoffline"
+ syslog.syslog("No user, ignoring pam-python for localoffline")
return pamh.PAM_USER_UNKNOWN
# Only create local users for console logins
try:
if pamh.rhost != None and 0 != len(pamh.rhost):
- print "Remote login, ignoring pam-python for localoffline"
+ syslog.syslog("Remote login, ignoring pam-python for localoffline")
return pamh.PAM_SUCCESS
except pamh.exception, e:
return e.pam_result
@@ -136,10 +139,10 @@ def pam_sm_open_session(pamh, flags, argv):
try:
return check_and_create_localuser(pamh, user)
except KeyError, e:
- print "Unknown username, should never happen: %s" % e
+ syslog.syslog("Unknown username, should never happen: %s" % e)
return pamh.PAM_USER_UNKNOWN
except Exception, e:
- print "Unexpected exception, should never happen: %s" % e
+ syslog.syslog("Unexpected exception, should never happen: %s" % e)
return pamh.PAM_SYSTEM_ERR
def pam_sm_close_session(pamh, flags, argv):
@@ -150,6 +153,7 @@ def pam_sm_chauthtok(pamh, flags, argv):
# Test if the code work. Argument is username to simulate login for.
if __name__ == '__main__':
+ syslog.openlog("pam_localoffline", syslog.LOG_PID, syslog.LOG_AUTH)
class pam_handler:
PAM_SUCCESS = 1
PAM_USER_UNKNOWN = 2
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-edu/upstream/libpam-mklocaluser.git
More information about the debian-edu-commits
mailing list