summaryrefslogtreecommitdiffabout
path: root/modules/ldap/ldap.c
Side-by-side diff
Diffstat (limited to 'modules/ldap/ldap.c') (more/less context) (ignore whitespace changes)
-rw-r--r--modules/ldap/ldap.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/modules/ldap/ldap.c b/modules/ldap/ldap.c
index d686f6b..b34c560 100644
--- a/modules/ldap/ldap.c
+++ b/modules/ldap/ldap.c
@@ -105,13 +105,13 @@ argz_copy(char ***dst, char **a)
return 0;
}
for (n = 0; a[n]; n++)
;
- b = calloc(i + 1, sizeof(b[0]));
+ b = calloc(n + 1, sizeof(b[0]));
if (!b)
return -1;
for (i = 0; i < n; i++) {
b[i] = strdup(a[i]);
if (!b[i])
return -1;
@@ -197,13 +197,13 @@ parse_ldap_conf(const char *name, struct smap_option const *opt)
smap_error("can't open LDAP config file %s: %s",
name, strerror(errno));
return -1;
}
line = 0;
- while (p = fgets(buf, sizeof(buf), fp)) {
+ while ((p = fgets(buf, sizeof(buf), fp))) {
size_t len;
char *errmsg;
++line;
while (*p && isspace(*p))
@@ -251,20 +251,22 @@ parse_ldap_conf(const char *name, struct smap_option const *opt)
}
fclose(fp);
return rc;
}
+#if 0
static int
readconf(struct smap_option const *opt, const char *val, char **errmsg)
{
int rc = parse_ldap_conf(val, opt);
if (rc)
*errmsg = "parse error";
return rc;
}
+#endif
#define MKOPT_DEFAULT 0
#define MKOPT_REUSE 0x01
#define MKOPT_RESET 0x02
static int
@@ -499,14 +501,12 @@ parse_ldap_uri(const char *uri)
static LDAP *
ldap_connect(struct ldap_conf *conf)
{
int rc;
char *ldapuri = NULL;
LDAP *ld = NULL;
- char *val;
- unsigned long lval;
if (ldap_debug_level) {
if (ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL,
&ldap_debug_level)
!= LBER_OPT_SUCCESS )
smap_error("cannot set LBER_OPT_DEBUG_LEVEL %d",
@@ -602,39 +602,37 @@ full_read(int fd, char *file, char *buf, size_t size)
return 0;
}
static int
get_passwd(struct ldap_conf *conf, struct berval *pwd, char **palloc)
{
- char *file;
-
if (conf->bindpwfile) {
struct stat st;
int fd, rc;
char *mem, *p;
- fd = open(file, O_RDONLY);
+ fd = open(conf->bindpwfile, O_RDONLY);
if (fd == -1) {
smap_error("can't open password file %s: %s",
- file, strerror(errno));
+ conf->bindpwfile, strerror(errno));
return -1;
}
if (fstat(fd, &st)) {
smap_error("can't stat password file %s: %s",
- file, strerror(errno));
+ conf->bindpwfile, strerror(errno));
close(fd);
return -1;
}
mem = malloc(st.st_size + 1);
if (!mem) {
smap_error("can't allocate memory (%lu bytes)",
(unsigned long) st.st_size+1);
close(fd);
return -1;
}
- rc = full_read(fd, file, mem, st.st_size);
+ rc = full_read(fd, conf->bindpwfile, mem, st.st_size);
close(fd);
if (rc)
return rc;
mem[st.st_size] = 0;
p = strchr(mem, '\n');
if (p)
@@ -728,13 +726,12 @@ ldap_bind(LDAP *ld, struct ldap_conf *conf)
}
static smap_database_t
mod_ldap_init_db(const char *dbid, int argc, char **argv)
{
- LDAP *ldap;
struct ldap_db *db;
struct ldap_conf conf;
size_t i, j;
struct smap_option *opt;
if (!ldap_conf_cpy(&conf, &dfl_conf))
@@ -877,13 +874,12 @@ getvar(const char *var, size_t len, void *data)
if (strlen(gd->env[i]) == len
&& memcmp(var, gd->env[i], len) == 0)
return strdup(gd->env[i+1]);
}
if (gd->ld) {
- struct berval bv;
char *p;
struct berval **values;
char *attr = malloc(len+1);
if (!attr)
return NULL;
@@ -986,18 +982,15 @@ mod_ldap_query(smap_database_t dbp,
smap_stream_t ostr,
const char *map, const char *key,
struct smap_conninfo const *conninfo)
{
struct ldap_db *db = (struct ldap_db *) dbp;
char const *inenv[5];
- char **env;
- char **attrs;
struct wordsplit ws;
ber_int_t msgid;
int rc;
- char *reply = NULL;
LDAPMessage *res, *msg;
# define __smap_s_cat2__(a,b) a ## b
# define REPLY(d,s) \
((d)->conf.__smap_s_cat2__(s,_reply) \
? (d)->conf.__smap_s_cat2__(s,_reply) \

Return to:

Send suggestions and report system problems to the System administrator.