aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2014-09-01 08:26:59 +0300
committerSergey Poznyakoff <gray@gnu.org>2014-09-01 08:31:57 +0300
commit59ea25e3fe207aaf0e8134b44601a763780109cb (patch)
tree499b320aec38a9621200a616a45e31d10c14b0ac
parentf4894990bd98521e09d418f703111dd393de9b05 (diff)
downloadsmap-59ea25e3fe207aaf0e8134b44601a763780109cb.tar.gz
smap-59ea25e3fe207aaf0e8134b44601a763780109cb.tar.bz2
Bugfixes.
* configure.ac: Fix copy-paste error * lib/wordsplit.c (wordsplit_varnames): Initialize count * modules/ldap/ldap.c (ldap_conf)<protocol>: Change type to long (parse_ldap_conf,mod_ldap_init_db): Fix arguments to smap_error (make_options): Handle ldap_version (parse_ldap_uri): Use wordsplit_ instead of mu_wordsplit_ (ldap_connect): Handle ldap_version setting. Use ldap_unbind_ext instead of the deprecated ldap_unbind. (mod_ldap_free_db,mod_ldap_close): Add missing return statements. (mod_ldap_query): Additional debug output. * src/cmdline.opt: Update copyright years. * src/smapccmd.opt: Likewise.
-rw-r--r--configure.ac2
-rw-r--r--lib/wordsplit.c2
-rw-r--r--modules/ldap/ldap.c37
-rw-r--r--src/cmdline.opt2
-rw-r--r--src/smapccmd.opt2
5 files changed, 27 insertions, 18 deletions
diff --git a/configure.ac b/configure.ac
index 66c9a92..b39e917 100644
--- a/configure.ac
+++ b/configure.ac
@@ -175,7 +175,7 @@ if test $status_ldap != no; then
status_ldap=no
fi])
fi
-AM_CONDITIONAL([LDAP_COND],[test $status_postgres = yes])
+AM_CONDITIONAL([LDAP_COND],[test $status_ldap = yes])
# Readline
AC_ARG_WITH([readline],
diff --git a/lib/wordsplit.c b/lib/wordsplit.c
index 3788c08..c4abc30 100644
--- a/lib/wordsplit.c
+++ b/lib/wordsplit.c
@@ -1392,7 +1392,7 @@ int
wordsplit_varnames(const char *input, char ***ret_names, int af)
{
const char *p;
- size_t count;
+ size_t count = 0;
char **names;
size_t i = 0;
diff --git a/modules/ldap/ldap.c b/modules/ldap/ldap.c
index 7935236..2cbde6f 100644
--- a/modules/ldap/ldap.c
+++ b/modules/ldap/ldap.c
@@ -20,7 +20,9 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
+#include <unistd.h>
#include <ldap.h>
+#include <ctype.h>
#include <smap/stream.h>
#include <smap/diag.h>
#include <smap/module.h>
@@ -53,7 +55,7 @@ struct ldap_conf {
char *config_file;
char *uri;
char *base;
- int protocol;
+ long protocol;
char *cacert;
char *filter;
char **attrs;
@@ -209,7 +211,7 @@ parse_ldap_conf(const char *name, struct smap_option const *opt)
if (p[len-1] == '\n')
p[--len] = 0;
else if (!feof(fp)) {
- smap_error("%s:%u: line too long, skipping");
+ smap_error("%s:%u: line too long, skipping", name, line);
while (!feof(fp) && fgetc(fp) != '\n')
;
++line;
@@ -286,6 +288,9 @@ make_options(struct ldap_conf *conf, int flags,
{ SMAP_OPTSTR(bindpwfile), smap_opt_string,
(void*)offsetof(struct ldap_conf, bindpwfile) },
+ { SMAP_OPTSTR(ldap_version), smap_opt_long,
+ (void*)offsetof(struct ldap_conf, protocol) },
+
{ SMAP_OPTSTR(positive-reply), smap_opt_string,
(void*)offsetof(struct ldap_conf, positive_reply) },
{ SMAP_OPTSTR(negative-reply), smap_opt_string,
@@ -404,10 +409,10 @@ parse_ldap_uri(const char *uri)
goto dnssrv_free;
}
- if (mu_wordsplit(hostlist, &ws, WRDSF_DEFFLAGS)) {
+ if (wordsplit(hostlist, &ws, WRDSF_DEFFLAGS)) {
smap_error("DNS SRV: could not parse hostlist=\"%s\": %s",
hostlist,
- mu_wordsplit_strerror(&ws));
+ wordsplit_strerror(&ws));
goto dnssrv_free;
}
@@ -442,7 +447,7 @@ parse_ldap_uri(const char *uri)
nurls += i;
dnssrv_free:
- mu_wordsplit_free (&ws);
+ wordsplit_free (&ws);
ber_memfree(hostlist);
ber_memfree(domain);
} else {
@@ -523,9 +528,10 @@ ldap_connect(struct ldap_conf *conf)
}
free(ldapuri);
- if (conf->protocol)
- ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION,
- &conf->protocol);
+ if (conf->protocol) {
+ int pn = (int) conf->protocol;
+ ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &pn);
+ }
if (conf->tls != tls_no) {
rc = ldap_start_tls_s(ld, NULL, NULL);
@@ -540,7 +546,7 @@ ldap_connect(struct ldap_conf *conf)
ldap_memfree(msg);
if (conf->tls == tls_only) {
- ldap_unbind(ld);
+ ldap_unbind_ext(ld, NULL, NULL);
return NULL;
}
/* try to continue anyway */
@@ -551,7 +557,7 @@ ldap_connect(struct ldap_conf *conf)
if (rc != LDAP_SUCCESS) {
smap_error("setting of LDAP_OPT_X_TLS_CACERTFILE failed");
if (conf->tls == tls_only) {
- ldap_unbind(ld);
+ ldap_unbind_ext(ld, NULL, NULL);
return NULL;
}
}
@@ -760,21 +766,21 @@ mod_ldap_init_db(const char *dbid, int argc, char **argv)
if (conf.positive_reply &&
wordsplit_varnames(conf.positive_reply, &conf.attrs, 0)) {
- smap_error("%s: can't get attribute names: %s",
+ smap_error("can't get attribute names: %s",
strerror(errno));
ldap_conf_free(&conf);
return NULL;
}
if (conf.negative_reply &&
wordsplit_varnames(conf.negative_reply, &conf.attrs, 1)) {
- smap_error("%s: can't get attribute names: %s",
+ smap_error("can't get attribute names: %s",
strerror(errno));
ldap_conf_free(&conf);
return NULL;
}
if (conf.onerror_reply &&
wordsplit_varnames(conf.onerror_reply, &conf.attrs, 1)) {
- smap_error("%s: can't get attribute names: %s",
+ smap_error("can't get attribute names: %s",
strerror(errno));
ldap_conf_free(&conf);
return NULL;
@@ -809,6 +815,7 @@ mod_ldap_free_db(smap_database_t dbp)
struct ldap_db *db = (struct ldap_db *) dbp;
ldap_conf_free(&db->conf);
free(db);
+ return 0;
}
static int
@@ -835,6 +842,7 @@ mod_ldap_close(smap_database_t dbp)
struct ldap_db *db = (struct ldap_db *) dbp;
ldap_unbind_ext(db->ldap, NULL, NULL);
db->ldap = NULL;
+ return 0;
}
struct getvar_data {
@@ -880,7 +888,7 @@ getvar(const char *var, size_t len, void *data)
return NULL;
memcpy(p, values[0]->bv_val, values[0]->bv_len);
p[values[0]->bv_len] = 0;
- smap_debug(dbgid, 1, ("attr %*.*s=%s", len, len, var, p));
+ smap_debug(dbgid, 1, ("attr %*.*s=%s", (int)len, (int)len, var, p));
ldap_value_free_len(values);
return p;
}
@@ -964,6 +972,7 @@ mod_ldap_query(smap_database_t dbp,
if (rc)
return 1;
+ smap_debug(dbgid, 2, ("using filter %s", ws.ws_wordv[0]));
rc = ldap_search_ext(db->ldap, db->conf.base, LDAP_SCOPE_SUBTREE,
ws.ws_wordv[0], db->conf.attrs, 0,
NULL, NULL, NULL, -1, &msgid);
diff --git a/src/cmdline.opt b/src/cmdline.opt
index 15dffdb..fc0b3ee 100644
--- a/src/cmdline.opt
+++ b/src/cmdline.opt
@@ -17,7 +17,7 @@
OPTIONS_BEGIN("smapd",
[<A socket map daemon.>],[<>],
[<gnu>],
- [<copyright_year=2009, 2010>],
+ [<copyright_year=2009, 2010, 2014>],
[<copyright_holder=Sergey Poznyakoff>])
GROUP([<Operation mode>])
diff --git a/src/smapccmd.opt b/src/smapccmd.opt
index ebab1ff..1649147 100644
--- a/src/smapccmd.opt
+++ b/src/smapccmd.opt
@@ -18,7 +18,7 @@ OPTIONS_BEGIN("smapc",
[<A socket map client.>],
[<[URL] [map [key]]]>],
[<gnu>],
- [<copyright_year=2009, 2010>],
+ [<copyright_year=2009, 2010, 2014>],
[<copyright_holder=Sergey Poznyakoff>])
OPTION(debug, d, LEVEL-SPEC,

Return to:

Send suggestions and report system problems to the System administrator.