aboutsummaryrefslogtreecommitdiff
path: root/modules/ldap/ldap.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/ldap/ldap.c')
-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
@@ -108,7 +108,7 @@ argz_copy(char ***dst, char **a)
108 for (n = 0; a[n]; n++) 108 for (n = 0; a[n]; n++)
109 ; 109 ;
110 110
111 b = calloc(i + 1, sizeof(b[0])); 111 b = calloc(n + 1, sizeof(b[0]));
112 if (!b) 112 if (!b)
113 return -1; 113 return -1;
114 for (i = 0; i < n; i++) { 114 for (i = 0; i < n; i++) {
@@ -200,7 +200,7 @@ parse_ldap_conf(const char *name, struct smap_option const *opt)
200 } 200 }
201 201
202 line = 0; 202 line = 0;
203 while (p = fgets(buf, sizeof(buf), fp)) { 203 while ((p = fgets(buf, sizeof(buf), fp))) {
204 size_t len; 204 size_t len;
205 char *errmsg; 205 char *errmsg;
206 206
@@ -254,6 +254,7 @@ parse_ldap_conf(const char *name, struct smap_option const *opt)
254 return rc; 254 return rc;
255} 255}
256 256
257#if 0
257static int 258static int
258readconf(struct smap_option const *opt, const char *val, char **errmsg) 259readconf(struct smap_option const *opt, const char *val, char **errmsg)
259{ 260{
@@ -262,6 +263,7 @@ readconf(struct smap_option const *opt, const char *val, char **errmsg)
262 *errmsg = "parse error"; 263 *errmsg = "parse error";
263 return rc; 264 return rc;
264} 265}
266#endif
265 267
266#define MKOPT_DEFAULT 0 268#define MKOPT_DEFAULT 0
267#define MKOPT_REUSE 0x01 269#define MKOPT_REUSE 0x01
@@ -502,8 +504,6 @@ ldap_connect(struct ldap_conf *conf)
502 int rc; 504 int rc;
503 char *ldapuri = NULL; 505 char *ldapuri = NULL;
504 LDAP *ld = NULL; 506 LDAP *ld = NULL;
505 char *val;
506 unsigned long lval;
507 507
508 if (ldap_debug_level) { 508 if (ldap_debug_level) {
509 if (ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, 509 if (ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL,
@@ -605,22 +605,20 @@ full_read(int fd, char *file, char *buf, size_t size)
605static int 605static int
606get_passwd(struct ldap_conf *conf, struct berval *pwd, char **palloc) 606get_passwd(struct ldap_conf *conf, struct berval *pwd, char **palloc)
607{ 607{
608 char *file;
609
610 if (conf->bindpwfile) { 608 if (conf->bindpwfile) {
611 struct stat st; 609 struct stat st;
612 int fd, rc; 610 int fd, rc;
613 char *mem, *p; 611 char *mem, *p;
614 612
615 fd = open(file, O_RDONLY); 613 fd = open(conf->bindpwfile, O_RDONLY);
616 if (fd == -1) { 614 if (fd == -1) {
617 smap_error("can't open password file %s: %s", 615 smap_error("can't open password file %s: %s",
618 file, strerror(errno)); 616 conf->bindpwfile, strerror(errno));
619 return -1; 617 return -1;
620 } 618 }
621 if (fstat(fd, &st)) { 619 if (fstat(fd, &st)) {
622 smap_error("can't stat password file %s: %s", 620 smap_error("can't stat password file %s: %s",
623 file, strerror(errno)); 621 conf->bindpwfile, strerror(errno));
624 close(fd); 622 close(fd);
625 return -1; 623 return -1;
626 } 624 }
@@ -631,7 +629,7 @@ get_passwd(struct ldap_conf *conf, struct berval *pwd, char **palloc)
631 close(fd); 629 close(fd);
632 return -1; 630 return -1;
633 } 631 }
634 rc = full_read(fd, file, mem, st.st_size); 632 rc = full_read(fd, conf->bindpwfile, mem, st.st_size);
635 close(fd); 633 close(fd);
636 if (rc) 634 if (rc)
637 return rc; 635 return rc;
@@ -731,7 +729,6 @@ ldap_bind(LDAP *ld, struct ldap_conf *conf)
731static smap_database_t 729static smap_database_t
732mod_ldap_init_db(const char *dbid, int argc, char **argv) 730mod_ldap_init_db(const char *dbid, int argc, char **argv)
733{ 731{
734 LDAP *ldap;
735 struct ldap_db *db; 732 struct ldap_db *db;
736 struct ldap_conf conf; 733 struct ldap_conf conf;
737 size_t i, j; 734 size_t i, j;
@@ -880,7 +877,6 @@ getvar(const char *var, size_t len, void *data)
880 } 877 }
881 878
882 if (gd->ld) { 879 if (gd->ld) {
883 struct berval bv;
884 char *p; 880 char *p;
885 struct berval **values; 881 struct berval **values;
886 char *attr = malloc(len+1); 882 char *attr = malloc(len+1);
@@ -989,12 +985,9 @@ mod_ldap_query(smap_database_t dbp,
989{ 985{
990 struct ldap_db *db = (struct ldap_db *) dbp; 986 struct ldap_db *db = (struct ldap_db *) dbp;
991 char const *inenv[5]; 987 char const *inenv[5];
992 char **env;
993 char **attrs;
994 struct wordsplit ws; 988 struct wordsplit ws;
995 ber_int_t msgid; 989 ber_int_t msgid;
996 int rc; 990 int rc;
997 char *reply = NULL;
998 LDAPMessage *res, *msg; 991 LDAPMessage *res, *msg;
999 992
1000# define __smap_s_cat2__(a,b) a ## b 993# define __smap_s_cat2__(a,b) a ## b

Return to:

Send suggestions and report system problems to the System administrator.