1 /*
2    config.c - routines for getting configuration information
3 
4    Copyright (C) 2012, 2013 Arthur de Jong
5 
6    This library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
10 
11    This library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
15 
16    You should have received a copy of the GNU Lesser General Public
17    License along with this library; if not, write to the Free Software
18    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19    02110-1301 USA
20 */
21 
22 #include "config.h"
23 
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #ifdef HAVE_STDINT_H
28 #include <stdint.h>
29 #endif /* HAVE_STDINT_H */
30 #include <unistd.h>
31 
32 #include "common.h"
33 #include "log.h"
34 #include "cfg.h"
35 
nslcd_config_get(TFILE * fp,MYLDAP_SESSION UNUSED (* session))36 int nslcd_config_get(TFILE *fp, MYLDAP_SESSION UNUSED(*session))
37 {
38   int32_t tmpint32;
39   int32_t cfgopt;
40   /* read request parameters */
41   READ_INT32(fp, cfgopt);
42   /* log call */
43   log_setrequest("config=%d", (int)cfgopt);
44   log_log(LOG_DEBUG, "nslcd_config_get(%d)", (int)cfgopt);
45   /* write the response header */
46   WRITE_INT32(fp, NSLCD_VERSION);
47   WRITE_INT32(fp, NSLCD_ACTION_CONFIG_GET);
48   WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
49   /* validate request */
50   switch (cfgopt)
51   {
52     case NSLCD_CONFIG_PAM_PASSWORD_PROHIBIT_MESSAGE:
53       WRITE_STRING(fp, nslcd_cfg->pam_password_prohibit_message);
54       break;
55     default:
56       /* all other config options are ignored */
57       break;
58   }
59   WRITE_INT32(fp, NSLCD_RESULT_END);
60   return 0;
61 }
62