1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/*
cfg.c - functions for configuration information
This file contains parts that were part of the nss-ldap
library which has been forked into the nss-ldapd library.
Copyright (C) 1997-2005 Luke Howard
Copyright (C) 2007 West Consulting
Copyright (C) 2007 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
*/
#include "config.h"
#include <string.h>
#include "ldap-nss.h"
#include "util.h"
#include "log.h"
#include "dnsconfig.h"
struct ldap_config *nslcd_cfg=NULL;
int _nss_ldap_test_config_flag (unsigned int flag)
{
return nslcd_cfg != NULL &&
(nslcd_cfg->ldc_flags&flag);
}
int _nss_ldap_test_initgroups_ignoreuser(const char *user)
{
char **p;
if (nslcd_cfg == NULL)
return 0;
if (nslcd_cfg->ldc_initgroups_ignoreusers == NULL)
return 0;
for (p = nslcd_cfg->ldc_initgroups_ignoreusers; *p != NULL; p++)
{
if (strcmp (*p, user) == 0)
return 1;
}
return 0;
}
int cfg_init(void)
{
static char configbuf[NSS_LDAP_CONFIG_BUFSIZ];
char *configbufp;
size_t configbuflen;
enum nss_status stat;
if (nslcd_cfg==NULL)
{
configbufp=configbuf;
configbuflen=sizeof(configbuf);
stat=_nss_ldap_readconfig(&nslcd_cfg,&configbufp,&configbuflen);
if (stat==NSS_STATUS_NOTFOUND)
{
/* config was read but no host information specified; try DNS */
stat=_nss_ldap_mergeconfigfromdns(nslcd_cfg,&configbufp,&configbuflen);
}
if (stat != NSS_STATUS_SUCCESS)
{
log_log(LOG_DEBUG,"cfg_init() failed to read config");
return -1;
}
}
return 0;
}
|