summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjkar8572 <jkar8572>2007-05-29 13:30:09 +0000
committerjkar8572 <jkar8572>2007-05-29 13:30:09 +0000
commit10ecc037ccbe0b234dc88d7bec8adfbb45fd2406 (patch)
tree2b9869a61c0d39ba4265d170495e0e273ee362cb
parent77a79ea8a3669f6c51f9079d8cd350c8743f2ee5 (diff)
downloadlinuxquota-10ecc037ccbe0b234dc88d7bec8adfbb45fd2406.tar.gz
Changed warnquota to allow use of URI, updated configure to detect whether ldap_initialize() is available (Jan Kara)
-rw-r--r--Changelog1
-rw-r--r--configure.in16
-rw-r--r--warnquota.c29
-rw-r--r--warnquota.conf3
4 files changed, 41 insertions, 8 deletions
diff --git a/Changelog b/Changelog
index e960732..00b7bab 100644
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,5 @@
Changes in quota-tools from 3.14 to 3.15
+* modified configure scripts and warnquota to check for new LDAP library and allow use of URI (Jan Kara)
* fix LDAP scripts to set VISUAL instead of EDITOR (Michael Meskes)
* added ext4 filesystem to the list of supported filesystems (Jan Kara)
* pot.o is now compiled with CFLAGS (Ladislav Michnovic)
diff --git a/configure.in b/configure.in
index 5d60e4c..b4d4838 100644
--- a/configure.in
+++ b/configure.in
@@ -26,8 +26,20 @@ AC_ARG_ENABLE(ldapmail, [ --enable-ldapmail=[yes/no/try] Enable ldap mail
,
enable_ldapmail="no")
if test "x$enable_ldapmail" != "xno"; then
- LDAPLIBS="-L/usr/lib -lldap -llber -lssl -lresolv"
- CFLAGS="$CFLAGS -DUSE_LDAP_MAIL_LOOKUP"
+ have_new_ldap="no"
+ have_old_ldap="no"
+ AC_CHECK_LIB(ldap, ldap_initialize, have_new_ldap="yes", AC_CHECK_LIB(ldap, ldap_init, have_old_ldap="yes"))
+ if test "x$have_new_ldap" = "xno" -a "x$have_old_ldap" = "xno"; then
+ LDAPLIBS="-L/usr/lib -lldap -llber -lssl -lresolv"
+ CFLAGS="$CFLAGS -DUSE_LDAP_MAIL_LOOKUP"
+ if test "x$have_new_ldap" = "xyes"; then
+ CFLAGS="$CFLAGS -DHAVE_LDAP_INITIALIZE"
+ fi
+ else
+ if test "x$enable_ldapmail" = "xyes"; then
+ AC_MSG_ERROR([LDAP support required but library not found.]);
+ fi
+ fi
fi
AC_SUBST(LDAPLIBS)
diff --git a/warnquota.c b/warnquota.c
index 74e1483..aa5875b 100644
--- a/warnquota.c
+++ b/warnquota.c
@@ -10,7 +10,7 @@
*
* Author: Marco van Wieringen <mvw@planets.elm.net>
*
- * Version: $Id: warnquota.c,v 1.26 2006/05/13 01:05:24 jkar8572 Exp $
+ * Version: $Id: warnquota.c,v 1.27 2007/05/29 13:30:10 jkar8572 Exp $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -112,6 +112,7 @@ struct configparams {
int ldap_is_setup; /* 0 */
char ldap_host[CNF_BUFFER];
int ldap_port;
+ char ldap_uri[CNF_BUFFER];
char ldap_binddn[CNF_BUFFER];
char ldap_bindpw[CNF_BUFFER];
char ldap_basedn[CNF_BUFFER];
@@ -171,18 +172,22 @@ static int setup_ldap(struct configparams *config)
{
int ret;
- ldapconn = ldap_init(config->ldap_host, config->ldap_port);
+ if (config->ldap_host[0])
+ ldapconn = ldap_init(config->ldap_host, config->ldap_port);
+ else
+ ldap_initialize(&ldapconn, config->ldap_uri);
+
if(ldapconn == NULL) {
ldap_perror(ldapconn, "ldap_init");
- return(-1);
+ return -1;
}
ret = ldap_bind_s(ldapconn, config->ldap_binddn, config->ldap_bindpw, LDAP_AUTH_SIMPLE);
if(ret < 0) {
ldap_perror(ldapconn, "ldap_bind");
- return(-1);
+ return -1;
}
- return(0);
+ return 0;
}
#endif
@@ -681,6 +686,8 @@ static int readconfigfile(const char *filename, struct configparams *config)
#ifdef USE_LDAP_MAIL_LOOKUP
config->ldap_port = config->ldap_is_setup = 0;
+ config->ldap_host[0] = 0;
+ config->ldap_uri[0] = 0;
#endif
if (!(fp = fopen(filename, "r"))) {
@@ -774,7 +781,7 @@ static int readconfigfile(const char *filename, struct configparams *config)
goto cc_parse_err;
if (str2timeunits(num, unit, &config->cc_before) < 0) {
cc_parse_err:
- errstr(_("Cannot parse time at CC_BEFORE variable (line %d).\n"), line);
+ die(1, _("Cannot parse time at CC_BEFORE variable (line %d).\n"), line);
}
}
#ifdef USE_LDAP_MAIL_LOOKUP
@@ -782,6 +789,8 @@ cc_parse_err:
sstrncpy(config->ldap_host, value, CNF_BUFFER);
else if (!strcmp(var, "LDAP_PORT"))
config->ldap_port = (int)strtol(value, NULL, 10);
+ else if (!strcmp(var, "LDAP_URI"))
+ sstrncpy(config->ldap_uri, value, CNF_BUFFER);
else if(!strcmp(var, "LDAP_BINDDN"))
sstrncpy(config->ldap_binddn, value, CNF_BUFFER);
else if(!strcmp(var, "LDAP_BINDPW"))
@@ -803,6 +812,14 @@ cc_parse_err:
}
if (bufpos)
errstr(_("Unterminated last line, ignoring\n"));
+#ifdef USE_LDAP_MAIL_LOOKUP
+ if (config->ldap_uri[0] && (config->ldap_host[0] || config->ldap_port))
+ die(_("Cannot specify both LDAP_URI and LDAP_HOST:LDAP_PORT.\n"));
+#ifndef HAVE_LDAP_INITIALIZE
+ if (config->ldap_uri[0])
+ die(_("LDAP library does not support ldap_initialize() but URI is specified."));
+#endif
+#endif
fclose(fp);
return 0;
diff --git a/warnquota.conf b/warnquota.conf
index d80f7ae..2347e80 100644
--- a/warnquota.conf
+++ b/warnquota.conf
@@ -51,6 +51,9 @@ GROUP_SIGNATURE = See you!| Your admin|
# if binddn and bindpw are blank or left out, an anonymous bind is used
#
# LDAP_MAIL = false # or false if you don't want to use it
+# If you have at least LDAP 2.3 installed, you can use LDAP_URI
+# LDAP_URI = ldaps://my.server:389
+# Otherwise you can specify LDAP_HOST and LDAP_PORT
# LDAP_HOST = ldap
# LDAP_PORT = 389
# LDAP_BINDDN = uid=ReadOnlyUser,o=YourOrg