nss-pam-ldapd commit: r1580 - nss-pam-ldapd/pynslcd
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
nss-pam-ldapd commit: r1580 - nss-pam-ldapd/pynslcd
- From: Commits of the nss-pam-ldapd project <nss-pam-ldapd-commits [at] lists.arthurdejong.org>
- To: nss-pam-ldapd-commits [at] lists.arthurdejong.org
- Reply-to: nss-pam-ldapd-users [at] lists.arthurdejong.org
- Subject: nss-pam-ldapd commit: r1580 - nss-pam-ldapd/pynslcd
- Date: Wed, 28 Dec 2011 23:44:35 +0100 (CET)
Author: arthur
Date: Wed Dec 28 23:44:33 2011
New Revision: 1580
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?revision=1580&view=revision
Log:
move the state variables (from command line) from the configuration to the main
module
Modified:
nss-pam-ldapd/pynslcd/cfg.py
nss-pam-ldapd/pynslcd/pynslcd.py
Modified: nss-pam-ldapd/pynslcd/cfg.py
==============================================================================
--- nss-pam-ldapd/pynslcd/cfg.py Wed Dec 28 23:29:49 2011 (r1579)
+++ nss-pam-ldapd/pynslcd/cfg.py Wed Dec 28 23:44:33 2011 (r1580)
@@ -20,17 +20,9 @@
import ldap
-# these values are defined here
-# the name of the program
-program_name = 'pynslcd'
-# the debugging level
-debug = 0
-# whether the --check option was passed
-check = False
# the number of threads to start
threads = 5
-
# the user id nslcd should be run as
uid = None
# the group id nslcd should be run as
Modified: nss-pam-ldapd/pynslcd/pynslcd.py
==============================================================================
--- nss-pam-ldapd/pynslcd/pynslcd.py Wed Dec 28 23:29:49 2011 (r1579)
+++ nss-pam-ldapd/pynslcd/pynslcd.py Wed Dec 28 23:44:33 2011 (r1580)
@@ -37,6 +37,16 @@
from tio import TIOStream
+# the name of the program
+program_name = 'pynslcd'
+
+# flag to indicate whether we are in debugging mode
+debugging = 0
+
+# flag to indicate user requested the --check option
+checkonly = False
+
+
# configure logging
class MyFormatter(logging.Formatter):
def format(self, record):
@@ -81,22 +91,25 @@
" --version output version information and exit\n"
"\n"
"Report bugs to <%(PACKAGE_BUGREPORT)s>.\n"
- % {'program_name': cfg.program_name,
+ % {'program_name': program_name,
'PACKAGE_BUGREPORT': config.PACKAGE_BUGREPORT, })
def parse_cmdline():
"""Parse command-line arguments."""
import getopt
- cfg.program_name = sys.argv[0] or 'pynslcd'
+ global program_name
+ program_name = sys.argv[0] or program_name
try:
optlist, args = getopt.gnu_getopt(sys.argv[1:],
'cdhV', ('check', 'debug', 'help', 'version', ))
for flag, arg in optlist:
if flag in ('-c', '--check'):
- cfg.check = True
+ global checkonly
+ checkonly = True
elif flag in ('-d', '--debug'):
- cfg.debug += 1
+ global debugging
+ debugging += 1
elif flag in ('-h', '--help'):
display_usage(sys.stdout)
sys.exit(0)
@@ -108,7 +121,7 @@
except getopt.GetoptError, reason:
sys.stderr.write("%(program_name)s: %(reason)s\n"
"Try '%(program_name)s --help' for more
information.\n"
- % {'program_name': cfg.program_name,
+ % {'program_name': program_name,
'reason': reason, })
sys.exit(1)
@@ -222,7 +235,7 @@
# disable ldap lookups of host names to avoid lookup loop
disable_nss_ldap()
# set log level
- if cfg.debug:
+ if debugging:
logging.getLogger().setLevel(logging.DEBUG)
# FIXME: implement
#if myldap_set_debuglevel(cfg.debug) != LDAP_SUCCESS:
@@ -234,7 +247,7 @@
# see if someone already locked the pidfile
pidfile = mypidfile.MyPIDLockFile(config.NSLCD_PIDFILE)
# see if --check option was given
- if cfg.check:
+ if checkonly:
if pidfile.is_locked():
logging.debug('pidfile (%s) is locked', config.NSLCD_PIDFILE)
sys.exit(0)
@@ -246,7 +259,7 @@
logging.error('daemon may already be active, cannot acquire lock
(%s)', config.NSLCD_PIDFILE)
sys.exit(1)
# daemonize
- if cfg.debug:
+ if debugging:
daemon = pidfile
else:
daemon = daemon.DaemonContext(
@@ -259,7 +272,7 @@
# start daemon
with daemon:
# start normal logging
- if not cfg.debug:
+ if not debugging:
log_startlogging()
logging.info('version %s starting', config.VERSION)
# create socket
--
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits/
- nss-pam-ldapd commit: r1580 - nss-pam-ldapd/pynslcd,
Commits of the nss-pam-ldapd project