|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
# config.py - routines for getting configuration information
|
|
Packit |
6bd9ab |
#
|
|
Packit |
6bd9ab |
# Copyright (C) 2013 Arthur de Jong
|
|
Packit |
6bd9ab |
#
|
|
Packit |
6bd9ab |
# This library is free software; you can redistribute it and/or
|
|
Packit |
6bd9ab |
# modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6bd9ab |
# License as published by the Free Software Foundation; either
|
|
Packit |
6bd9ab |
# version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6bd9ab |
#
|
|
Packit |
6bd9ab |
# This library is distributed in the hope that it will be useful,
|
|
Packit |
6bd9ab |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6bd9ab |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6bd9ab |
# Lesser General Public License for more details.
|
|
Packit |
6bd9ab |
#
|
|
Packit |
6bd9ab |
# You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6bd9ab |
# License along with this library; if not, write to the Free Software
|
|
Packit |
6bd9ab |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit |
6bd9ab |
# 02110-1301 USA
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
import cfg
|
|
Packit |
6bd9ab |
import common
|
|
Packit |
6bd9ab |
import constants
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
class ConfigGetRequest(common.Request):
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
action = constants.NSLCD_ACTION_CONFIG_GET
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
def read_parameters(self, fp):
|
|
Packit |
6bd9ab |
return dict(cfgopt=fp.read_int32())
|
|
Packit |
6bd9ab |
# TODO: log call with parameters
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
def write(self, value):
|
|
Packit |
6bd9ab |
self.fp.write_int32(constants.NSLCD_RESULT_BEGIN)
|
|
Packit |
6bd9ab |
self.fp.write_string(value)
|
|
Packit |
6bd9ab |
self.fp.write_int32(constants.NSLCD_RESULT_END)
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
def handle_request(self, parameters):
|
|
Packit |
6bd9ab |
cfgopt = parameters['cfgopt']
|
|
Packit |
6bd9ab |
if cfgopt == constants.NSLCD_CONFIG_PAM_PASSWORD_PROHIBIT_MESSAGE:
|
|
Packit |
6bd9ab |
self.write(cfg.pam_password_prohibit_message or '')
|
|
Packit |
6bd9ab |
else:
|
|
Packit |
6bd9ab |
# return empty response
|
|
Packit |
6bd9ab |
self.fp.write_int32(constants.NSLCD_RESULT_END)
|