Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2012-12-15 12:13:35 +0100
committerArthur de Jong <arthur@arthurdejong.org>2012-12-15 12:13:35 +0100
commit99933fd3561df12ed81304eaf444c1d7d1060f38 (patch)
tree6ea4c358358901c27f828437d12b92e2f20fae5f
parent5d7483715aceb4f1f50d0b2dfbca5510b598191a (diff)
merge config.py into constants.py and generate it from configure
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1863 ef36b2f9-881f-0410-afb5-c4e39611909c
-rw-r--r--.gitignore1
-rw-r--r--configure.ac10
-rw-r--r--pynslcd/Makefile.am10
-rw-r--r--pynslcd/constants.py.in (renamed from pynslcd/config.py.in)6
-rwxr-xr-xpynslcd/pynslcd.py29
-rw-r--r--pynslcd/tio.py6
6 files changed, 31 insertions, 31 deletions
diff --git a/.gitignore b/.gitignore
index ee4e358..0f5c6ec 100644
--- a/.gitignore
+++ b/.gitignore
@@ -50,7 +50,6 @@ stamp-*
/nslcd/nslcd
# /pynslcd/
-/pynslcd/config.py
/pynslcd/constants.py
# /tests/
diff --git a/configure.ac b/configure.ac
index 8feb376..63ff521 100644
--- a/configure.ac
+++ b/configure.ac
@@ -767,6 +767,14 @@ AM_CONDITIONAL([NSS_FLAVOUR_FREEBSD], [test "x${with_nss_flavour}" = xfreebsd])
# generate files
AC_CONFIG_FILES([Makefile compat/Makefile common/Makefile nss/Makefile
- pam/Makefile nslcd/Makefile pynslcd/Makefile pynslcd/config.py
+ pam/Makefile nslcd/Makefile pynslcd/Makefile
man/Makefile tests/Makefile])
+AC_CONFIG_FILES([pynslcd/constants.py], [[
+(
+ echo ''
+ echo '# The following is automatically generated from nslcd.h.'
+ echo '# See that file for details.'
+ echo ''
+ sed -n 's| */\*.*\*/ *||;s/^.define *\(NSLCD_[A-Z_]*\) */\1 = /p' "$srcdir"/nslcd.h
+) >> pynslcd/constants.py]])
AC_OUTPUT
diff --git a/pynslcd/Makefile.am b/pynslcd/Makefile.am
index 87c0a8d..3d18684 100644
--- a/pynslcd/Makefile.am
+++ b/pynslcd/Makefile.am
@@ -23,7 +23,7 @@ pynslcd_PYTHON = pynslcd.py attmap.py cache.py cfg.py common.py expr.py \
mypidfile.py tio.py \
alias.py ether.py group.py host.py netgroup.py network.py \
pam.py passwd.py protocol.py rpc.py service.py shadow.py
-nodist_pynslcd_PYTHON = constants.py config.py
+nodist_pynslcd_PYTHON = constants.py
CLEANFILES = $(nodist_pynslcd_PYTHON)
all-local: $(nodist_pynslcd_PYTHON)
@@ -37,11 +37,3 @@ install-data-hook:
chmod a+rx $(DESTDIR)$(pynslcddir)/pynslcd.py
$(MKDIR_P) $(DESTDIR)$(sbindir)
[ -L $(DESTDIR)$(sbindir)/pynslcd ] || $(LN_S) $(pynslcddir)/pynslcd.py $(DESTDIR)$(sbindir)/pynslcd
-
-# generate constants module
-constants.py: $(top_srcdir)/nslcd.h Makefile
- ( echo "# This file is automatically generated from nslcd.h." ; \
- echo "# See that file for details." ; \
- echo "" ; \
- sed -n 's| */\*.*\*/ *||;s/^.define *\(NSLCD_[A-Z_]*\) */\1 = /p' \
- $(top_srcdir)/nslcd.h ) > $@
diff --git a/pynslcd/config.py.in b/pynslcd/constants.py.in
index fada9b0..4f57e34 100644
--- a/pynslcd/config.py.in
+++ b/pynslcd/constants.py.in
@@ -1,6 +1,8 @@
-# config.py.in - configured information, this file is processed by the
-# configure script to produce config.py
+# constants.py - configured information and constants, this file is processed
+# and extended by the configure script
+#
+# Copyright (C) 2012 Arthur de Jong
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
diff --git a/pynslcd/pynslcd.py b/pynslcd/pynslcd.py
index f28440e..f06ac11 100755
--- a/pynslcd/pynslcd.py
+++ b/pynslcd/pynslcd.py
@@ -31,10 +31,9 @@ import threading
import ldap
from tio import TIOStream
-import cfg # from nslcd.conf
+import cfg
import common
-import config # from configure
-import constants # from nslcd.h
+import constants
import mypidfile
@@ -95,7 +94,7 @@ def display_version(fp):
'Copyright (C) 2010-2012 Arthur de Jong\n'
'This is free software; see the source for copying conditions. There is NO\n'
'warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n'
- % {'PACKAGE_STRING': config.PACKAGE_STRING, })
+ % {'PACKAGE_STRING': constants.PACKAGE_STRING, })
def display_usage(fp):
@@ -108,7 +107,7 @@ def display_usage(fp):
"\n"
"Report bugs to <%(PACKAGE_BUGREPORT)s>.\n"
% {'program_name': program_name,
- 'PACKAGE_BUGREPORT': config.PACKAGE_BUGREPORT, })
+ 'PACKAGE_BUGREPORT': constants.PACKAGE_BUGREPORT, })
def parse_cmdline():
@@ -149,15 +148,15 @@ def create_socket():
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
# remove existing named socket
try:
- os.unlink(config.NSLCD_SOCKET)
+ os.unlink(constants.NSLCD_SOCKET)
except OSError:
pass # ignore any problems
# bind to named socket
- sock.bind(config.NSLCD_SOCKET)
+ sock.bind(constants.NSLCD_SOCKET)
# close the file descriptor on exit
fcntl.fcntl(sock, fcntl.F_SETFD, fcntl.FD_CLOEXEC)
# set permissions of socket so anybody can do requests
- os.chmod(config.NSLCD_SOCKET, 0666)
+ os.chmod(constants.NSLCD_SOCKET, 0666)
# start listening for connections
sock.listen(socket.SOMAXCONN)
return sock
@@ -230,7 +229,7 @@ def acceptconnection(session):
def disable_nss_ldap():
"""Disable the nss_ldap module to avoid lookup loops."""
import ctypes
- lib = ctypes.CDLL(config.NSS_LDAP_SONAME)
+ lib = ctypes.CDLL(constants.NSS_LDAP_SONAME)
ctypes.c_int.in_dll(lib, '_nss_ldap_enablelookups').value = 0
@@ -284,7 +283,7 @@ if __name__ == '__main__':
#if myldap_set_debuglevel(cfg.debug) != LDAP_SUCCESS:
# sys.exit(1)
# read configuration file
- cfg.read(config.NSLCD_CONF_PATH)
+ cfg.read(constants.NSLCD_CONF_PATH)
# set process title
try:
import setproctitle
@@ -294,19 +293,19 @@ if __name__ == '__main__':
# set a default umask for the pidfile and socket
os.umask(0022)
# see if someone already locked the pidfile
- pidfile = mypidfile.MyPIDLockFile(config.NSLCD_PIDFILE)
+ pidfile = mypidfile.MyPIDLockFile(constants.NSLCD_PIDFILE)
# see if --check option was given
if checkonly:
if pidfile.is_locked():
- logging.debug('pidfile (%s) is locked', config.NSLCD_PIDFILE)
+ logging.debug('pidfile (%s) is locked', constants.NSLCD_PIDFILE)
sys.exit(0)
else:
- logging.debug('pidfile (%s) is not locked', config.NSLCD_PIDFILE)
+ logging.debug('pidfile (%s) is not locked', constants.NSLCD_PIDFILE)
sys.exit(1)
# normal check for pidfile locked
if pidfile.is_locked():
logging.error('daemon may already be active, cannot acquire lock (%s)',
- config.NSLCD_PIDFILE)
+ constants.NSLCD_PIDFILE)
sys.exit(1)
# daemonize
if debugging:
@@ -324,7 +323,7 @@ if __name__ == '__main__':
# start normal logging to syslog
if not debugging:
logging.getLogger().addHandler(sysloghandler)
- logging.info('version %s starting', config.VERSION)
+ logging.info('version %s starting', constants.VERSION)
try:
# create socket
nslcd_serversocket = create_socket()
diff --git a/pynslcd/tio.py b/pynslcd/tio.py
index 9c43ac2..6394acf 100644
--- a/pynslcd/tio.py
+++ b/pynslcd/tio.py
@@ -26,13 +26,13 @@ import socket
# definition for reading and writing INT32 values
_int32 = struct.Struct('i')
-# FIXME: use something from config.py to determine the correct size
+# FIXME: use something from constants.py to determine the correct size
_uid_t = struct.Struct('i')
-# FIXME: use something from config.py to determine the correct size
+# FIXME: use something from constants.py to determine the correct size
_gid_t = struct.Struct('i')
-# FIXME: use something from config.py to determine the correct size
+# FIXME: use something from constants.py to determine the correct size
_struct_timeval = struct.Struct('ll')