Mercurial > dovecot > original-hg > dovecot-1.2
changeset 1283:2d8af547a8b4 HEAD
Added PostgreSQL support, patch by Alex Howansky
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 07 Mar 2003 01:20:16 +0200 |
parents | e8894f2c776f |
children | 71f61b6a0f02 |
files | INSTALL configure.in doc/auth.txt doc/dovecot-ldap.conf dovecot-example.conf src/auth/Makefile.am src/auth/passdb.c src/auth/passdb.h src/auth/userdb.c src/auth/userdb.h |
diffstat | 10 files changed, 82 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/INSTALL Thu Mar 06 23:45:16 2003 +0200 +++ b/INSTALL Fri Mar 07 01:20:16 2003 +0200 @@ -88,6 +88,7 @@ --with-ldap Build with LDAP support --with-vpopmail Build with vpopmail support (default) --with-static-userdb Build with static userdb support (default) + --with-pgsql Build with PostgreSQL support Specify which authentication modules to use. Disabling them give you a few bytes smaller binary, but not much else. @@ -107,8 +108,13 @@ db-ldap.c userdb-ldap.c passdb-ldap.c -o ldap.so \ ../lib-settings/libsettings.a -lldap +gcc -shared -fPIC -DUSERDB_PGSQL -DPASSDB_PGSQL \ +-I../.. -I../lib -I../lib-settings -I/usr/include/postgresql \ +db-pgsql.c userdb-pgsql.c passdb-pgsql.c -o pgsql.so \ +../lib-settings/libsettings.a -L/usr/lib/postgresql -lpq + gcc -shared -fPIC -DUSERDB_VPOPMAIL -DPASSDB_VPOPMAIL -I../.. -I../lib \ userdb-vpopmail.c passdb-vpopmail.c -o vpopmail.so -lvpopmail -Including libsettings.a in ldap.so is kind of annoying, but it's not -currently needed elsewhere in dovecot-auth. +Including libsettings.a in ldap.so and pgsql.so is kind of annoying, but it's +not needed elsewhere in dovecot-auth.
--- a/configure.in Thu Mar 06 23:45:16 2003 +0200 +++ b/configure.in Fri Mar 07 01:20:16 2003 +0200 @@ -115,6 +115,15 @@ fi, want_static_userdb=yes) +AC_ARG_WITH(pgsql, +[ --with-pgsql Build with PostgreSQL support], + if test x$withval = xno; then + want_pgsql=no + else + want_pgsql=yes + fi, + want_pgsql=no) + AC_ARG_WITH(cyrus-sasl2, [ --with-cyrus-sasl2 Build with Cyrus SASL 2 library support], if test x$withval = xno; then @@ -769,6 +778,38 @@ ]) fi +if test $want_pgsql = yes; then + # based on code from PHP + for i in /usr /usr/local /usr/local/pgsql; do + for j in include include/pgsql include/postgres include/postgresql ""; do + if test -r "$i/$j/libpq-fe.h"; then + PGSQL_INC_BASE=$i + PGSQL_INCLUDE=$i/$j + fi + done + for j in lib lib/pgsql lib/postgres lib/postgresql ""; do + if test -f "$i/$j/libpq.so" || test -f "$i/$j/libpq.a"; then + PGSQL_LIBDIR=$i/$j + fi + done + done + + old_LIBS=$LIBS + LIBS="$LIBS -L$PGSQL_LIBDIR" + + AC_CHECK_LIB(pq, PQconnectdb, [ + AC_CHECK_HEADER($PGSQL_INCLUDE/libpq-fe.h, [ + AUTH_CFLAGS="$AUTH_CFLAGS -I$PGSQL_INCLUDE" + PASSDB_LIBS="$PASSDB_LIBS -L$PGSQL_LIBDIR -lpq" + AC_DEFINE(USERDB_PGSQL,, Build with PostgreSQL support) + AC_DEFINE(PASSDB_PGSQL,, Build with PostgreSQL support) + userdb="$userdb pgsql" + passdb="$passdb pgsql" + ]) + ]) + LIBS=$old_LIBS +fi + if test $want_vpopmail = yes; then vpopmail_home="`echo ~vpopmail`" vpop_libdeps="$vpopmail_home/etc/lib_deps" @@ -825,6 +866,7 @@ AM_CONDITIONAL(AUTH_MODULES, test "$auth_modules" = "yes") +AC_SUBST(AUTH_CFLAGS) AC_SUBST(PASSDB_LIBS) dnl **
--- a/doc/auth.txt Thu Mar 06 23:45:16 2003 +0200 +++ b/doc/auth.txt Fri Mar 07 01:20:16 2003 +0200 @@ -17,6 +17,7 @@ - passwd-file: /etc/passwd-like file in specified location - ldap: Lightweight Directory Access Protocol - vpopmail: External software used to handle virtual domains + - pgsql: A PostgreSQL database. Currently supported user databases: @@ -25,6 +26,7 @@ - ldap: Lightweight Directory Access Protocol - vpopmail: External software used to handle virtual domains - static: Static UID and GID, home directory from given template + - pgsql: A PostgreSQL database. Most password databases support only plaintext authentication. passwd-file and LDAP exceptions since they support multiple password schemes. @@ -126,6 +128,15 @@ %n and %d variables, see default_mail_env description in dovecot-example.conf. +PostgreSQL +---------- + +See dovecot-pgsql.conf for more information. Password and user databases may +use different configuration files to keep the information in separate +locations. If both refer to same file, they share the same PostgreSQL +connection. + + Generating passwords --------------------
--- a/doc/dovecot-ldap.conf Thu Mar 06 23:45:16 2003 +0200 +++ b/doc/dovecot-ldap.conf Fri Mar 07 01:20:16 2003 +0200 @@ -18,6 +18,9 @@ # Password for LDAP server #dnpass = +# LDAP protocol version to use. Likely 2 or 3. +#ldap_version = 2 + # LDAP base base = uid=someone, dc=foo, dc=bar, dc=org
--- a/dovecot-example.conf Thu Mar 06 23:45:16 2003 +0200 +++ b/dovecot-example.conf Fri Mar 07 01:20:16 2003 +0200 @@ -362,6 +362,7 @@ # static uid=<uid> gid=<gid> home=<dir template>: static settings # vpopmail: vpopmail library # ldap <config path>: LDAP, see doc/dovecot-ldap.conf +# pgsql <config path>: a PostgreSQL database, see doc/dovecot-pgsql.conf auth_userdb = passwd # Where password database is kept: @@ -371,6 +372,7 @@ # passwd-file <path>: passwd-like file with specified location # vpopmail: vpopmail authentication # ldap <config path>: LDAP, see doc/dovecot-ldap.conf +# pgsql <config path>: a PostgreSQL database, see doc/dovecot-pgsql.conf auth_passdb = pam # Executable location
--- a/src/auth/Makefile.am Thu Mar 06 23:45:16 2003 +0200 +++ b/src/auth/Makefile.am Fri Mar 07 01:20:16 2003 +0200 @@ -6,6 +6,7 @@ -I$(top_srcdir)/src/lib \ -I$(top_srcdir)/src/lib-settings \ -DAUTH_MODULE_DIR=\""$(libdir)/dovecot/auth"\" \ + $(AUTH_CFLAGS) \ $(VPOPMAIL_CFLAGS) dovecot_auth_LDADD = \ @@ -22,6 +23,7 @@ dovecot_auth_SOURCES = \ auth-module.c \ db-ldap.c \ + db-pgsql.c \ db-passwd-file.c \ login-connection.c \ main.c \ @@ -39,13 +41,15 @@ passdb-pam.c \ passdb-shadow.c \ passdb-vpopmail.c \ + passdb-pgsql.c \ password-scheme.c \ userdb.c \ userdb-ldap.c \ userdb-passwd.c \ userdb-passwd-file.c \ userdb-static.c \ - userdb-vpopmail.c + userdb-vpopmail.c \ + userdb-pgsql.c noinst_HEADERS = \ auth-login-interface.h \ @@ -53,6 +57,7 @@ auth-mech-desc.h \ auth-module.h \ db-ldap.h \ + db-pgsql.h \ db-passwd-file.h \ common.h \ login-connection.h \
--- a/src/auth/passdb.c Thu Mar 06 23:45:16 2003 +0200 +++ b/src/auth/passdb.c Fri Mar 07 01:20:16 2003 +0200 @@ -106,6 +106,10 @@ if (strcasecmp(name, "ldap") == 0) passdb = &passdb_ldap; #endif +#ifdef PASSDB_PGSQL + if (strcasecmp(name, "pgsql") == 0) + passdb = &passdb_pgsql; +#endif #ifdef AUTH_MODULES passdb_module = auth_module_open(name); if (passdb_module != NULL) {
--- a/src/auth/passdb.h Thu Mar 06 23:45:16 2003 +0200 +++ b/src/auth/passdb.h Fri Mar 07 01:20:16 2003 +0200 @@ -57,6 +57,7 @@ extern struct passdb_module passdb_pam; extern struct passdb_module passdb_vpopmail; extern struct passdb_module passdb_ldap; +extern struct passdb_module passdb_pgsql; void passdb_init(void); void passdb_deinit(void);
--- a/src/auth/userdb.c Thu Mar 06 23:45:16 2003 +0200 +++ b/src/auth/userdb.c Fri Mar 07 01:20:16 2003 +0200 @@ -45,6 +45,10 @@ if (strcasecmp(name, "ldap") == 0) userdb = &userdb_ldap; #endif +#ifdef USERDB_PGSQL + if (strcasecmp(name, "pgsql") == 0) + userdb = &userdb_pgsql; +#endif #ifdef AUTH_MODULES userdb_module = auth_module_open(name); if (userdb_module != NULL) {
--- a/src/auth/userdb.h Thu Mar 06 23:45:16 2003 +0200 +++ b/src/auth/userdb.h Fri Mar 07 01:20:16 2003 +0200 @@ -30,6 +30,7 @@ extern struct userdb_module userdb_passwd_file; extern struct userdb_module userdb_vpopmail; extern struct userdb_module userdb_ldap; +extern struct userdb_module userdb_pgsql; void userdb_init(void); void userdb_deinit(void);