diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2013-07-29 23:07:36 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2013-07-29 23:07:36 +0200 |
commit | fa97bcc376777f87ee661852ad0a8ed60d002466 (patch) | |
tree | 42b30bf308eb5a6c4f523a92924e0a965bf2bf52 /pynslcd | |
parent | a3acbecc071b4138a36fa2a155f7fab2eb94209b (diff) |
Implement config request handling in pynslcd
This allows the PAM module to request the pam_password_prohibit_message
option for denying password change.
Diffstat (limited to 'pynslcd')
-rw-r--r-- | pynslcd/Makefile.am | 6 | ||||
-rw-r--r-- | pynslcd/config.py | 45 | ||||
-rwxr-xr-x | pynslcd/pynslcd.py | 1 |
3 files changed, 49 insertions, 3 deletions
diff --git a/pynslcd/Makefile.am b/pynslcd/Makefile.am index f96654b..a61ff65 100644 --- a/pynslcd/Makefile.am +++ b/pynslcd/Makefile.am @@ -21,9 +21,9 @@ pynslcddir = $(datadir)/pynslcd pynslcd_PYTHON = pynslcd.py attmap.py cache.py cfg.py common.py expr.py \ mypidfile.py invalidator.py search.py tio.py \ - alias.py ether.py group.py host.py netgroup.py network.py \ - passwd.py protocol.py rpc.py service.py shadow.py pam.py \ - usermod.py + config.py alias.py ether.py group.py host.py netgroup.py \ + network.py passwd.py protocol.py rpc.py service.py \ + shadow.py pam.py usermod.py nodist_pynslcd_PYTHON = constants.py CLEANFILES = $(nodist_pynslcd_PYTHON) diff --git a/pynslcd/config.py b/pynslcd/config.py new file mode 100644 index 0000000..ee57db3 --- /dev/null +++ b/pynslcd/config.py @@ -0,0 +1,45 @@ + +# config.py - routines for getting configuration information +# +# Copyright (C) 2013 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 +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 USA + +import cfg +import common +import constants + + +class ConfigGetRequest(common.Request): + + action = constants.NSLCD_ACTION_CONFIG_GET + + def read_parameters(self, fp): + return dict(cfgopt=fp.read_int32()) + # TODO: log call with parameters + + def write(self, value): + self.fp.write_int32(constants.NSLCD_RESULT_BEGIN) + self.fp.write_string(value) + self.fp.write_int32(constants.NSLCD_RESULT_END) + + def handle_request(self, parameters): + cfgopt = parameters['cfgopt'] + if cfgopt == constants.NSLCD_CONFIG_PAM_PASSWORD_PROHIBIT_MESSAGE: + self.write(cfg.pam_password_prohibit_message or '') + else: + # return empty response + self.fp.write_int32(constants.NSLCD_RESULT_END) diff --git a/pynslcd/pynslcd.py b/pynslcd/pynslcd.py index e0add71..cd3a171 100755 --- a/pynslcd/pynslcd.py +++ b/pynslcd/pynslcd.py @@ -178,6 +178,7 @@ def getpeercred(fd): handlers = {} +handlers.update(common.get_handlers('config')) handlers.update(common.get_handlers('alias')) handlers.update(common.get_handlers('ether')) handlers.update(common.get_handlers('group')) |