diff options
-rw-r--r-- | INSTALL | 4 | ||||
-rw-r--r-- | Makefile.am | 4 | ||||
-rw-r--r-- | Makefile.concept | 28 | ||||
-rw-r--r-- | Makefile.in | 96 | ||||
-rw-r--r-- | Makefile.mysql | 22 | ||||
-rw-r--r-- | Makefile.pgsql | 24 | ||||
-rw-r--r-- | aclocal.m4 | 30 | ||||
-rw-r--r-- | auth.h | 4 | ||||
-rw-r--r-- | bounce.c | 7 | ||||
-rw-r--r-- | bounce.h | 8 | ||||
-rwxr-xr-x | build.sh | 18 | ||||
-rw-r--r-- | clientinfo.h | 6 | ||||
-rw-r--r-- | config.c | 4 | ||||
-rwxr-xr-x | configure | 376 | ||||
-rw-r--r-- | configure.in | 5 | ||||
-rw-r--r-- | db.h | 4 | ||||
-rw-r--r-- | dbmailtypes.h | 4 | ||||
-rw-r--r-- | dbmd5.c | 6 | ||||
-rw-r--r-- | dbmd5.h | 8 | ||||
-rw-r--r-- | dbmsgbuf.h | 4 | ||||
-rw-r--r-- | dbsearch.h | 4 | ||||
-rw-r--r-- | dbtest.c | 4 | ||||
-rw-r--r-- | debug.c | 4 | ||||
-rw-r--r-- | debug.h | 4 | ||||
-rw-r--r-- | forward.c | 6 | ||||
-rw-r--r-- | forward.h | 8 | ||||
-rw-r--r-- | imap4.c | 4 | ||||
-rw-r--r-- | imap4.h | 6 | ||||
-rw-r--r-- | imapcommands.c | 6 | ||||
-rw-r--r-- | imapcommands.h | 4 | ||||
-rw-r--r-- | imapd.c | 8 | ||||
-rw-r--r-- | imaputil.c | 3 | ||||
-rw-r--r-- | imaputil.h | 4 | ||||
-rw-r--r-- | injector.c | 4 | ||||
-rw-r--r-- | list.c | 4 | ||||
-rw-r--r-- | list.h | 4 | ||||
-rw-r--r-- | main.c | 6 | ||||
-rw-r--r-- | main.h | 4 | ||||
-rw-r--r-- | maintenance.c | 9 | ||||
-rw-r--r-- | maintenance.h | 4 | ||||
-rw-r--r-- | man/dbmail-adduser.1 | 16 | ||||
-rw-r--r-- | mbox2dbmail.c | 4 | ||||
-rw-r--r-- | md5.c | 7 | ||||
-rw-r--r-- | md5.h | 4 | ||||
-rw-r--r-- | memblock.c | 4 | ||||
-rw-r--r-- | memblock.h | 4 | ||||
-rw-r--r-- | mime.c | 4 | ||||
-rw-r--r-- | mime.h | 8 | ||||
-rw-r--r-- | mini-injector.c | 4 | ||||
-rw-r--r-- | misc.c | 11 | ||||
-rw-r--r-- | misc.h | 10 | ||||
-rw-r--r-- | mysql/Makefile.in | 3 | ||||
-rw-r--r-- | mysql/dbauthmysql.c | 60 | ||||
-rw-r--r-- | mysql/dbmsgbufmysql.c | 9 | ||||
-rw-r--r-- | mysql/dbmysql.c | 28 | ||||
-rw-r--r-- | mysql/dbsearchmysql.c | 11 | ||||
-rw-r--r-- | pgsql/Makefile.am | 5 | ||||
-rw-r--r-- | pgsql/Makefile.in | 7 | ||||
-rw-r--r-- | pgsql/dbauthpgsql.c | 56 | ||||
-rw-r--r-- | pgsql/dbmsgbufpgsql.c | 9 | ||||
-rw-r--r-- | pgsql/dbpgsql.c | 28 | ||||
-rw-r--r-- | pgsql/dbsearchpgsql.c | 11 | ||||
-rw-r--r-- | pipe.c | 21 | ||||
-rw-r--r-- | pipe.h | 8 | ||||
-rw-r--r-- | pop3.c | 4 | ||||
-rw-r--r-- | pop3.h | 6 | ||||
-rw-r--r-- | pop3d.c | 8 | ||||
-rw-r--r-- | proctitleutils.c | 4 | ||||
-rw-r--r-- | proctitleutils.h | 4 | ||||
-rw-r--r-- | quota.c | 4 | ||||
-rw-r--r-- | quota.h | 4 | ||||
-rw-r--r-- | raw-convert.c | 4 | ||||
-rw-r--r-- | rfcmsg.c | 4 | ||||
-rw-r--r-- | rfcmsg.h | 4 | ||||
-rw-r--r-- | server.c | 4 | ||||
-rw-r--r-- | server.h | 6 | ||||
-rw-r--r-- | serverchild.c | 4 | ||||
-rw-r--r-- | serverchild.h | 4 | ||||
-rw-r--r-- | settings.c | 7 | ||||
-rw-r--r-- | smtp-convert.c | 4 | ||||
-rw-r--r-- | sql/mysql/create_tables.mysql | 2 | ||||
-rw-r--r-- | sql/mysql/create_tables_innoDB.mysql | 2 | ||||
-rw-r--r-- | sql/postgresql/create_tables.pgsql | 2 | ||||
-rw-r--r-- | sql/postgresql/no-constraint-tables.pgsql | 2 | ||||
-rw-r--r-- | sstack.c | 4 | ||||
-rw-r--r-- | sstack.h | 4 | ||||
-rw-r--r-- | user.c | 150 | ||||
-rw-r--r-- | user.h | 4 | ||||
-rw-r--r-- | vut2dbmail.c | 4 |
89 files changed, 1076 insertions, 267 deletions
@@ -76,6 +76,10 @@ What do you need? 3. Run build.sh + If you want to use md5 hash passwords, you need to make sure the crypt() you link + in supports them. For most people this amounts to linking in GNU libc's libcrypt + via entering -lcrypt instead of -lcrypto. + 4. Create users in the dbmail system Next you will need to create some users into the dbmail mailing sytem. diff --git a/Makefile.am b/Makefile.am index 08978895..ec0259c1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,9 +1,9 @@ -SUBDIRS = mysql pgsql . +SUBDIRS = mysql pgsql bin_PROGRAMS = dbmail-smtp dbmail-pop3d dbmail-imapd dbmail-maintenance dbmail-adduser dbmail-readvut raw-convertor dbmail-mini-injector bin_SCRIPTS = install-dbmail.sh -dbmail_smtp_SOURCES = config.c list.c debug.c dbmd5.c md5.c mime.c main.c pipe.c bounce.c forward.c memblock.c +dbmail_smtp_SOURCES = config.c list.c debug.c dbmd5.c md5.c mime.c main.c pipe.c bounce.c forward.c memblock.c misc.c dbmail_smtp_LDADD = @SQLALIB@ dbmail_smtp_LDFLAGS = @SQLLIB@ diff --git a/Makefile.concept b/Makefile.concept index 089fdb55..0a43e97e 100644 --- a/Makefile.concept +++ b/Makefile.concept @@ -12,7 +12,7 @@ DBOBJECT = $(__DBTYPE__)/db$(__DBTYPE__).o DBSOURCE = $(__DBTYPE__)/db$(__DBTYPE__).c SMTP_OBJECTS = list.o debug.o pipe.o mime.o $(DBOBJECT) dbmd5.o md5.o bounce.o forward.o memblock.o \ -$(AUTHOBJECT) config.o +$(AUTHOBJECT) config.o misc.o INJECTOR_OBJECTS = list.o debug.o $(DBOBJECT) dbmd5.o md5.o $(AUTHOBJECT) mime.o config.o UNIONE_OBJECTS = list.o debug.o $(DBOBJECT) dbmd5.o md5.o $(AUTHOBJECT) mime.o config.o MINI_OBJECTS = debug.o $(DBOBJECT) list.o dbmd5.o md5.o $(AUTHOBJECT) mime.o config.o @@ -32,13 +32,13 @@ LIB = $(__LIBS__) # from compiler about vsyslog function # Added the -D_SVID_SOURCE option because ipc.h asked me to. -CFLAGS = -Wall -O2 -D_BSD_SOURCE -D_SVID_SOURCE +CFLAGS = -Wall -O2 -D_BSD_SOURCE -D_SVID_SOURCE $(__CFLAGS__) .PHONY: clean install all: smtp pop3d maintenance imapd user -smtp: config.h main.h $(SMTP_OBJECTS) main.c +smtp: dbmail.h main.h $(SMTP_OBJECTS) main.c $(CC) $(CFLAGS) main.c -o dbmail-smtp $(SMTP_OBJECTS) $(DIRS) $(LIB) pop3d: pop3.h $(POP_OBJECTS) pop3d.c @@ -76,27 +76,27 @@ mbox2dbmail: list.o: list.h debug.h debug.o: debug.h config.o: debug.h list.h -server.o: server.h debug.h list.h serverchild.h config.h -serverchild.o: serverchild.h debug.h config.h list.h -pipe.o: pipe.h config.h debug.h -forward.o: forward.h config.h debug.h -mime.o: mime.h config.h debug.h -misc.o:misc.h config.h debug.h -pop3.o:pop3.h config.h debug.h dbmailtypes.h +server.o: server.h debug.h list.h serverchild.h dbmail.h +serverchild.o: serverchild.h debug.h dbmail.h list.h +pipe.o: pipe.h dbmail.h debug.h misc.h dbmd5.h +forward.o: forward.h dbmail.h debug.h +mime.o: mime.h dbmail.h debug.h +misc.o:misc.h dbmail.h debug.h +pop3.o:pop3.h dbmail.h debug.h dbmailtypes.h dbmd5.o:dbmd5.h md5.h debug.h bounce.o:bounce.h list.h debug.h -imap4.o: imap4.h db.h debug.h imaputil.h imapcommands.h +imap4.o: dbmail.h imap4.h db.h debug.h imaputil.h imapcommands.h imaputil.o: imaputil.h db.h memblock.h debug.h dbmailtypes.h imapcommands.o: imapcommands.h imaputil.h imap4.h db.h memblock.h debug.h dbmailtypes.h quota.o: quota.h -maintenance.o: maintenance.h debug.h -settings.o: settings.h debug.h +maintenance.o: auth.h maintenance.h debug.h +settings.o: dbmail.h debug.h proctitleutils.o: proctitleutils.h user.o: user.h debug.h memblock.o: memblock.h debug.h rfcmsg.o: rfcmsg.h dbmailtypes.h vut2dbmail.o: db.h auth.h -$(DBOBJECT): db.h dbmd5.h config.h mime.h list.h memblock.h debug.h dbmailtypes.h auth.h +$(DBOBJECT): db.h dbmd5.h dbmail.h mime.h list.h memblock.h debug.h dbmailtypes.h auth.h $(CC) -o $(DBOBJECT) -c $(DBSOURCE) $(DIRS) $(MSGBUFOBJECT): dbmsgbuf.h db.h $(CC) -o $(MSGBUFOBJECT) -c $(MSGBUFSOURCE) $(DIRS) diff --git a/Makefile.in b/Makefile.in index 6e4a2b24..c9b3fc9e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,6 +1,6 @@ -# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am +# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am -# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -68,12 +68,12 @@ SQLALIB = @SQLALIB@ SQLLIB = @SQLLIB@ VERSION = @VERSION@ -SUBDIRS = mysql pgsql . +SUBDIRS = mysql pgsql bin_PROGRAMS = dbmail-smtp dbmail-pop3d dbmail-imapd dbmail-maintenance dbmail-adduser dbmail-readvut raw-convertor dbmail-mini-injector bin_SCRIPTS = install-dbmail.sh -dbmail_smtp_SOURCES = config.c list.c debug.c dbmd5.c md5.c mime.c main.c pipe.c bounce.c forward.c memblock.c +dbmail_smtp_SOURCES = config.c list.c debug.c dbmd5.c md5.c mime.c main.c pipe.c bounce.c forward.c memblock.c misc.c dbmail_smtp_LDADD = @SQLALIB@ dbmail_smtp_LDFLAGS = @SQLLIB@ @@ -119,16 +119,17 @@ dbmail_mini_injector_LDADD = @SQLALIB@ dbmail_mini_injector_LDFLAGS = @SQLLIB@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/buildtools/mkinstalldirs +CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = PROGRAMS = $(bin_PROGRAMS) -DEFS = @DEFS@ -I. -I$(srcdir) +DEFS = @DEFS@ -I. -I$(srcdir) -I. CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ dbmail_smtp_OBJECTS = config.o list.o debug.o dbmd5.o md5.o mime.o \ -main.o pipe.o bounce.o forward.o memblock.o +main.o pipe.o bounce.o forward.o memblock.o misc.o dbmail_smtp_DEPENDENCIES = dbmail_pop3d_OBJECTS = config.o server.o serverchild.o pop3.o list.o \ debug.o dbmd5.o md5.o mime.o misc.o memblock.o pop3d.o @@ -158,13 +159,14 @@ CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ -DIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \ -Makefile.in NEWS TODO aclocal.m4 configure configure.in +DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \ +Makefile.am Makefile.in NEWS TODO acconfig.h acinclude.m4 aclocal.m4 \ +config.in configure configure.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = gtar +TAR = tar GZIP_ENV = --best DEP_FILES = .deps/bounce.P .deps/config.P .deps/dbmd5.P .deps/debug.P \ .deps/forward.P .deps/imap4.P .deps/imapcommands.P .deps/imapd.P \ @@ -186,14 +188,42 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) cd $(top_builddir) \ && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ configure.in +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ configure.in acinclude.m4 cd $(srcdir) && $(ACLOCAL) -config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) +config.status: $(srcdir)/configure.in $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(srcdir)/configure: @MAINTAINER_MODE_TRUE@$(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) cd $(srcdir) && $(AUTOCONF) +config.h: stamp-h + @if test ! -f $@; then \ + rm -f stamp-h; \ + $(MAKE) stamp-h; \ + else :; fi +stamp-h: $(srcdir)/config.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES= CONFIG_HEADERS=config.h:config.in \ + $(SHELL) ./config.status + @echo timestamp > stamp-h 2> /dev/null +$(srcdir)/config.in: @MAINTAINER_MODE_TRUE@$(srcdir)/stamp-h.in + @if test ! -f $@; then \ + rm -f $(srcdir)/stamp-h.in; \ + $(MAKE) $(srcdir)/stamp-h.in; \ + else :; fi +$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) acconfig.h + cd $(top_srcdir) && $(AUTOHEADER) + @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null + +mostlyclean-hdr: + +clean-hdr: + +distclean-hdr: + -rm -f config.h + +maintainer-clean-hdr: + mostlyclean-binPROGRAMS: clean-binPROGRAMS: @@ -322,7 +352,7 @@ maintainer-clean-recursive: dot_seen=no; \ rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \ rev="$$subdir $$rev"; \ - test "$$subdir" != "." || dot_seen=yes; \ + test "$$subdir" = "." && dot_seen=yes; \ done; \ test "$$dot_seen" = "no" && rev=". $$rev"; \ target=`echo $@ | sed s/-recursive//`; \ @@ -351,7 +381,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) here=`pwd` && cd $(srcdir) \ && mkid -f$$here/ID $$unique $(LISP) -TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.in $(TAGS_DEPENDENCIES) $(LISP) tags=; \ here=`pwd`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ @@ -363,8 +393,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ - test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ - || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + test -z "$(ETAGS_ARGS)config.in$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.in $$unique $(LISP) -o $$here/TAGS) mostlyclean-tags: @@ -478,6 +508,9 @@ check-am: all-am check: check-recursive installcheck-am: installcheck: installcheck-recursive +all-recursive-am: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + install-exec-am: install-binPROGRAMS install-binSCRIPTS install-exec: install-exec-recursive @@ -489,8 +522,8 @@ install-am: all-am install: install-recursive uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS uninstall: uninstall-recursive -all-am: Makefile $(PROGRAMS) $(SCRIPTS) -all-redirect: all-recursive +all-am: Makefile $(PROGRAMS) $(SCRIPTS) config.h +all-redirect: all-recursive-am install-strip: $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: installdirs-recursive @@ -507,23 +540,25 @@ distclean-generic: -rm -f config.cache config.log stamp-h stamp-h[0-9]* maintainer-clean-generic: -mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \ - mostlyclean-tags mostlyclean-depend mostlyclean-generic +mostlyclean-am: mostlyclean-hdr mostlyclean-binPROGRAMS \ + mostlyclean-compile mostlyclean-tags mostlyclean-depend \ + mostlyclean-generic mostlyclean: mostlyclean-recursive -clean-am: clean-binPROGRAMS clean-compile clean-tags clean-depend \ - clean-generic mostlyclean-am +clean-am: clean-hdr clean-binPROGRAMS clean-compile clean-tags \ + clean-depend clean-generic mostlyclean-am clean: clean-recursive -distclean-am: distclean-binPROGRAMS distclean-compile distclean-tags \ - distclean-depend distclean-generic clean-am +distclean-am: distclean-hdr distclean-binPROGRAMS distclean-compile \ + distclean-tags distclean-depend distclean-generic \ + clean-am distclean: distclean-recursive -rm -f config.status -maintainer-clean-am: maintainer-clean-binPROGRAMS \ +maintainer-clean-am: maintainer-clean-hdr maintainer-clean-binPROGRAMS \ maintainer-clean-compile maintainer-clean-tags \ maintainer-clean-depend maintainer-clean-generic \ distclean-am @@ -533,7 +568,8 @@ maintainer-clean-am: maintainer-clean-binPROGRAMS \ maintainer-clean: maintainer-clean-recursive -rm -f config.status -.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \ +.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \ +mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \ maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ mostlyclean-compile distclean-compile clean-compile \ maintainer-clean-compile uninstall-binSCRIPTS install-binSCRIPTS \ @@ -545,11 +581,11 @@ maintainer-clean-recursive tags tags-recursive mostlyclean-tags \ distclean-tags clean-tags maintainer-clean-tags distdir \ mostlyclean-depend distclean-depend clean-depend \ maintainer-clean-depend info-am info dvi-am dvi check check-am \ -installcheck-am installcheck install-exec-am install-exec \ -install-data-am install-data install-am install uninstall-am uninstall \ -all-redirect all-am all installdirs-am installdirs mostlyclean-generic \ -distclean-generic clean-generic maintainer-clean-generic clean \ -mostlyclean distclean maintainer-clean +installcheck-am installcheck all-recursive-am install-exec-am \ +install-exec install-data-am install-data install-am install \ +uninstall-am uninstall all-redirect all-am all installdirs-am \ +installdirs mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean #mb2db_SOURCES = config.c debug.c list.c dbmd5.c md5.c mime.c mb2db.c diff --git a/Makefile.mysql b/Makefile.mysql index 62a9c8d1..66100585 100644 --- a/Makefile.mysql +++ b/Makefile.mysql @@ -12,7 +12,7 @@ SEARCHOBJECT = $(DBASETYPE)/dbsearch$(DBASETYPE).o DBOBJECT = $(DBASETYPE)/db$(DBASETYPE).o SMTP_OBJECTS = list.o debug.o pipe.o mime.o $(DBOBJECT) dbmd5.o md5.o bounce.o forward.o memblock.o \ -$(AUTHOBJECT) config.o +$(AUTHOBJECT) config.o misc.o INJECTOR_OBJECTS = list.o debug.o $(DBOBJECT) dbmd5.o md5.o $(AUTHOBJECT) mime.o config.o UNIONE_OBJECTS = list.o debug.o $(DBOBJECT) dbmd5.o md5.o $(AUTHOBJECT) mime.o config.o MINI_OBJECTS = debug.o $(DBOBJECT) list.o dbmd5.o md5.o $(AUTHOBJECT) mime.o config.o @@ -40,7 +40,7 @@ CFLAGS = -Wall -O2 -D_BSD_SOURCE -D_SVID_SOURCE all: smtp pop3d maintenance imapd user -smtp: config.h main.h $(SMTP_OBJECTS) main.c +smtp: dbmail.h main.h $(SMTP_OBJECTS) main.c $(CC) $(CFLAGS) main.c -o dbmail-smtp $(SMTP_OBJECTS) $(LIBS) $(LIB) pop3d: pop3.h $(POP_OBJECTS) pop3d.c @@ -78,25 +78,25 @@ mbox2dbmail: list.o: list.h debug.h debug.o: debug.h config.o: debug.h list.h -server.o: server.h debug.h list.h serverchild.h config.h -serverchild.o: serverchild.h debug.h config.h list.h -pipe.o: pipe.h config.h debug.h -forward.o: forward.h config.h debug.h -mime.o: mime.h config.h debug.h -misc.o:misc.h config.h debug.h -pop3.o:pop3.h config.h debug.h dbmailtypes.h +server.o: server.h debug.h list.h serverchild.h dbmail.h +serverchild.o: serverchild.h debug.h dbmail.h list.h +pipe.o: pipe.h dbmail.h debug.h misc.h dbmd5.h +forward.o: forward.h dbmail.h debug.h +mime.o: mime.h dbmail.h debug.h +misc.o:misc.h dbmail.h debug.h +pop3.o:pop3.h dbmail.h debug.h dbmailtypes.h dbmd5.o:dbmd5.h md5.h debug.h bounce.o:bounce.h list.h debug.h imap4.o: imap4.h db.h debug.h imaputil.h imapcommands.h imaputil.o: imaputil.h db.h memblock.h debug.h dbmailtypes.h imapcommands.o: imapcommands.h imaputil.h imap4.h db.h memblock.h debug.h dbmailtypes.h maintenance.o: maintenance.h debug.h -settings.o: settings.h debug.h +settings.o: dbmail.h debug.h user.o: user.h debug.h memblock.o: memblock.h debug.h rfcmsg.o: rfcmsg.h dbmailtypes.h vut2dbmail.o: db.h auth.h -$(DBOBJECT):db.h dbmd5.h config.h mime.h list.h memblock.h debug.h dbmailtypes.h auth.h +$(DBOBJECT):db.h dbmd5.h dbmail.h mime.h list.h memblock.h debug.h dbmailtypes.h auth.h $(MSGBUFOBJECT): dbmsgbuf.h db.h $(SEARCHOBJECT): dbsearch.h db.h $(AUTHOBJECT): auth.h db.h diff --git a/Makefile.pgsql b/Makefile.pgsql index 7c939acc..044f10d0 100644 --- a/Makefile.pgsql +++ b/Makefile.pgsql @@ -12,7 +12,7 @@ SEARCHOBJECT = $(DBASETYPE)/dbsearch$(DBASETYPE).o DBOBJECT = $(DBASETYPE)/db$(DBASETYPE).o SMTP_OBJECTS = list.o debug.o pipe.o mime.o $(DBOBJECT) dbmd5.o md5.o bounce.o forward.o memblock.o \ -$(AUTHOBJECT) config.o +$(AUTHOBJECT) config.o misc.o INJECTOR_OBJECTS = list.o debug.o $(DBOBJECT) dbmd5.o md5.o $(AUTHOBJECT) mime.o config.o UNIONE_OBJECTS = list.o debug.o $(DBOBJECT) dbmd5.o md5.o $(AUTHOBJECT) mime.o config.o MINI_OBJECTS = debug.o $(DBOBJECT) list.o dbmd5.o md5.o $(AUTHOBJECT) mime.o config.o @@ -41,7 +41,7 @@ CFLAGS = -Wall -O2 -D_BSD_SOURCE -D_SVID_SOURCE all: smtp pop3d maintenance imapd user -smtp: config.h main.h $(SMTP_OBJECTS) main.c +smtp: dbmail.h main.h $(SMTP_OBJECTS) main.c $(CC) $(CFLAGS) main.c -o dbmail-smtp $(SMTP_OBJECTS) $(LIBS) $(LIB) pop3d: pop3.h $(POP_OBJECTS) pop3d.c @@ -81,25 +81,25 @@ dbtest: $(DBTEST_OBJECTS) dbtest.c db.h list.o: list.h debug.h debug.o: debug.h -pipe.o: pipe.h config.h debug.h -forward.o: forward.h config.h debug.h -mime.o: mime.h config.h debug.h -misc.o:misc.h config.h debug.h -pop3.o:pop3.h config.h debug.h dbmailtypes.h +pipe.o: pipe.h dbmail.h debug.h misc.h dbmd5.h +forward.o: forward.h dbmail.h debug.h +mime.o: mime.h dbmail.h debug.h +misc.o:misc.h dbmail.h debug.h +pop3.o:pop3.h dbmail.h debug.h dbmailtypes.h dbmd5.o:dbmd5.h md5.h debug.h -bounce.o:bounce.h list.h debug.h config.h +bounce.o:bounce.h list.h debug.h dbmail.h imap4.o: imap4.h db.h debug.h imaputil.h imapcommands.h imaputil.o: imaputil.h db.h memblock.h debug.h dbmailtypes.h imapcommands.o: imapcommands.h imaputil.h imap4.h db.h memblock.h debug.h dbmailtypes.h -server.o: server.h debug.h list.h serverchild.h config.h -serverchild.o: serverchild.h debug.h config.h list.h +server.o: server.h debug.h list.h serverchild.h dbmail.h +serverchild.o: serverchild.h debug.h dbmail.h list.h maintenance.o: maintenance.h debug.h -settings.o: settings.h debug.h +settings.o: dbmail.h debug.h user.o: user.h debug.h memblock.o: memblock.h debug.h rfcmsg.o: rfcmsg.h dbmailtypes.h vut2dbmail.o: db.h auth.h -$(DBOBJECT):db.h dbmd5.h config.h mime.h list.h memblock.h debug.h dbmailtypes.h auth.h +$(DBOBJECT):db.h dbmd5.h dbmail.h mime.h list.h memblock.h debug.h dbmailtypes.h auth.h $(MSGBUFOBJECT): dbmsgbuf.h db.h $(SEARCHOBJECT): dbsearch.h db.h $(AUTHOBJECT): auth.h db.h @@ -1,6 +1,6 @@ -dnl aclocal.m4 generated automatically by aclocal 1.4-p5 +dnl aclocal.m4 generated automatically by aclocal 1.4-p4 -dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -23,7 +23,7 @@ AC_DEFUN([AM_INIT_AUTOMAKE], [AC_REQUIRE([AC_PROG_INSTALL]) PACKAGE=[$1] AC_SUBST(PACKAGE) -VERSION=["1.1"] +VERSION=[$2] AC_SUBST(VERSION) dnl test to see if srcdir already configured if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then @@ -309,3 +309,27 @@ else fi fi ]) + +# Like AC_CONFIG_HEADER, but automatically create stamp file. + +AC_DEFUN(AM_CONFIG_HEADER, +[AC_PREREQ([2.12]) +AC_CONFIG_HEADER([$1]) +dnl When config.status generates a header, we must update the stamp-h file. +dnl This file resides in the same directory as the config header +dnl that is generated. We must strip everything past the first ":", +dnl and everything past the last "/". +AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl +ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>, +<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>, +<<am_indx=1 +for am_file in <<$1>>; do + case " <<$>>CONFIG_HEADERS " in + *" <<$>>am_file "*<<)>> + echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx + ;; + esac + am_indx=`expr "<<$>>am_indx" + 1` +done<<>>dnl>>) +changequote([,]))]) + @@ -10,6 +10,10 @@ #ifndef _DBMAIL_AUTH_H #define _DBMAIL_AUTH_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "dbmailtypes.h" #define MAX_CHECKS_DEPTH 1000 @@ -4,13 +4,16 @@ * Bounce.c implements functions to bounce email back to a sender * with a message saying why the message was bounced */ - +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "dbmail.h" #include "bounce.h" #include "list.h" #include "mime.h" #include "db.h" #include "debug.h" -#include "config.h" #include <stdlib.h> #include <string.h> @@ -3,8 +3,12 @@ * * Headers for bounce.c */ -#ifndef BOUNCE_H_ -#define BOUNCE_H_ +#ifndef _BOUNCE_H +#define _BOUNCE_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include <stdio.h> #include <stdlib.h> @@ -22,7 +22,7 @@ else read database fi -if [ $database = p ]; then +if [ "$database" = p ]; then echo You have selected PostgreSQL as database libdir=$pglibdir incdir=$pgincdir @@ -60,6 +60,15 @@ if [ "$line" != "" ]; then libs=$line fi +# This is poor, but there's no easy way to check for a header file +# (that's what the autoconf system is for) +if [ -f /usr/include/endian.h ] || [-f "${incdir}/endian.h" ]; then + cflags="$cflags -DHAVE_ENDIAN_H" +fi +if [ -f /usr/include/crypt.h ] || [-f "${incdir}/crypt.h" ]; then + cflags="$cflags -DHAVE_CRYPT_H" +fi + echo "" echo Creating makefile.. @@ -73,7 +82,8 @@ cat >Makefile <<EOF __DBTYPE__=$db __LIBS__=$libs __LIBDIR__=$libdir -__INCDIR__=$incdir +__INCDIR__=$incdir -I. +__CFLAGS__=$cflags EOF @@ -84,7 +94,7 @@ echo Done. You can now make dbmail by running \'make clean all\'. echo Do you want this to be executed right now? read line -if [ $line = y ]; then +if [ "$line" = y ]; then make clean all if [ $? -eq 0 ]; then @@ -92,7 +102,7 @@ if [ $line = y ]; then echo Make succesfull. Do you want to install the binaries and man pages? read line - if [ $line = y ]; then + if [ "$line" = y ]; then echo Target binary directory is now $bindir. echo Enter new directory or press RETURN to keep this setting: read line diff --git a/clientinfo.h b/clientinfo.h index 57cb9615..89c94eee 100644 --- a/clientinfo.h +++ b/clientinfo.h @@ -7,8 +7,12 @@ #ifndef CLIENT_INFO_H #define CLIENT_INFO_H -#include <stdio.h> +#ifdef HAVE_CONFIG_H #include "config.h" +#endif + +#include <stdio.h> +#include "dbmail.h" #define IPNUM_LEN 32 @@ -4,7 +4,11 @@ * read a config file */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif + +#include "dbmail.h" #include <stdlib.h> #include <string.h> #include <stdio.h> @@ -547,6 +547,9 @@ ac_config_guess=$ac_aux_dir/config.guess ac_config_sub=$ac_aux_dir/config.sub ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. + + + echo "$ac_t"" This is dbmail's GNU configure script. It's going to run a bunch of strange tests to hopefully @@ -565,7 +568,7 @@ make your compile work without much twiddling. # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:569: checking for a BSD compatible install" >&5 +echo "configure:572: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -618,7 +621,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 -echo "configure:622: checking whether build environment is sane" >&5 +echo "configure:625: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile @@ -675,7 +678,7 @@ test "$program_suffix" != NONE && test "$program_transform_name" = "" && program_transform_name="s,x,x," echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:679: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:682: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -702,9 +705,9 @@ else fi -PACKAGE=dbmail-smtp +PACKAGE=dbmail -VERSION="1.1" +VERSION=1.1 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } @@ -721,7 +724,7 @@ EOF missing_dir=`cd $ac_aux_dir && pwd` echo $ac_n "checking for working aclocal""... $ac_c" 1>&6 -echo "configure:725: checking for working aclocal" >&5 +echo "configure:728: checking for working aclocal" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -734,7 +737,7 @@ else fi echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 -echo "configure:738: checking for working autoconf" >&5 +echo "configure:741: checking for working autoconf" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -747,7 +750,7 @@ else fi echo $ac_n "checking for working automake""... $ac_c" 1>&6 -echo "configure:751: checking for working automake" >&5 +echo "configure:754: checking for working automake" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -760,7 +763,7 @@ else fi echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 -echo "configure:764: checking for working autoheader" >&5 +echo "configure:767: checking for working autoheader" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -773,7 +776,7 @@ else fi echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 -echo "configure:777: checking for working makeinfo" >&5 +echo "configure:780: checking for working makeinfo" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -787,7 +790,7 @@ fi echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6 -echo "configure:791: checking whether to enable maintainer-specific portions of Makefiles" >&5 +echo "configure:794: checking whether to enable maintainer-specific portions of Makefiles" >&5 # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then enableval="$enable_maintainer_mode" @@ -813,7 +816,7 @@ fi # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:817: checking for $ac_word" >&5 +echo "configure:820: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -842,19 +845,24 @@ fi mysqllibpaths="/usr/lib /usr/local/lib /lib /usr/freeware/lib \ - /usr/freeware/lib32 $HOME/lib $HOME/tcl/lib $HOME" + /usr/freeware/lib32 $HOME/lib $HOME/mysql/lib \ + /usr/lib/mysql /usr/local/lib/mysql $HOME/lib/mysql $HOME" + mysqlheaderpaths="/usr/include/mysql /usr/include /usr/local/include/mysql \ /usr/local/include /usr/freeware/include/mysql \ /usr/freeware/include $HOME/include $HOME/mysql/include \ $HOME" pgsqllibpaths="/usr/lib /usr/local/lib /lib /usr/freeware/lib \ - /usr/freeware/lib32 $HOME/lib $HOME/tcl/lib $HOME" + /usr/freeware/lib32 $HOME/lib $HOME/pgsql/lib \ + /usr/lib/pgsql /usr/local/lib/pgsql /usr/lib/postgresql \ + /usr/local/lib/postgresql $HOME/lib/pgsql $HOME/lib/postgresql \ + $HOME/postgresql/lib $HOME" pgsqlheaderpaths="/usr/include/pgsql /usr/include /usr/local/include/pgsql \ /usr/local/include /usr/freeware/include/pgsql \ /usr/freeware/include $HOME/include $HOME/pgsql/include \ - /usr/local/pgsql/include $HOME" + /usr/local/pgsql/include /usr/include/postgresql $HOME" # Check whether --with-mysql or --without-mysql was given. if test "${with_mysql+set}" = set; then @@ -917,7 +925,7 @@ then if test "$withval" != "yes" then echo $ac_n "checking for mysql.h (user supplied)""... $ac_c" 1>&6 -echo "configure:921: checking for mysql.h (user supplied)" >&5 +echo "configure:929: checking for mysql.h (user supplied)" >&5 if test -r "$mysqlheadername/mysql.h" then # found @@ -935,7 +943,7 @@ echo "configure:921: checking for mysql.h (user supplied)" >&5 else # Lets look in our standard paths echo $ac_n "checking for mysql.h""... $ac_c" 1>&6 -echo "configure:939: checking for mysql.h" >&5 +echo "configure:947: checking for mysql.h" >&5 for mysqlpaths in $mysqlheaderpaths do if test -r "$mysqlpaths/mysql.h" @@ -962,7 +970,7 @@ then if test "$withval" != "yes" then echo $ac_n "checking for libpq-fe.h (user supplied)""... $ac_c" 1>&6 -echo "configure:966: checking for libpq-fe.h (user supplied)" >&5 +echo "configure:974: checking for libpq-fe.h (user supplied)" >&5 if test -r "$pgsqlheadername/libpq-fe.h" then # found @@ -980,7 +988,7 @@ echo "configure:966: checking for libpq-fe.h (user supplied)" >&5 else # Lets look in our standard paths echo $ac_n "checking for libpq-fe.h""... $ac_c" 1>&6 -echo "configure:984: checking for libpq-fe.h" >&5 +echo "configure:992: checking for libpq-fe.h" >&5 for pgsqlpaths in $pgsqlheaderpaths do if test -r "$pgsqlpaths/libpq-fe.h" @@ -1004,7 +1012,7 @@ fi if test ! "${mysqlheadername-x}" = "x" then echo $ac_n "checking for mysql_real_connect in -lmysqlclient""... $ac_c" 1>&6 -echo "configure:1008: checking for mysql_real_connect in -lmysqlclient" >&5 +echo "configure:1016: checking for mysql_real_connect in -lmysqlclient" >&5 ac_lib_var=`echo mysqlclient'_'mysql_real_connect | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1012,7 +1020,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lmysqlclient $LIBS" cat > conftest.$ac_ext <<EOF -#line 1016 "configure" +#line 1024 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -1023,7 +1031,7 @@ int main() { mysql_real_connect() ; return 0; } EOF -if { (eval echo configure:1027: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1035: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1055,7 +1063,7 @@ else if test ! "${pgsqlheadername-x}" = "x" then echo $ac_n "checking for PQconnectdb in -lpq""... $ac_c" 1>&6 -echo "configure:1059: checking for PQconnectdb in -lpq" >&5 +echo "configure:1067: checking for PQconnectdb in -lpq" >&5 ac_lib_var=`echo pq'_'PQconnectdb | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1063,7 +1071,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpq $LIBS" cat > conftest.$ac_ext <<EOF -#line 1067 "configure" +#line 1075 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -1074,7 +1082,7 @@ int main() { PQconnectdb() ; return 0; } EOF -if { (eval echo configure:1078: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1086: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1109,7 +1117,7 @@ fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1113: checking for $ac_word" >&5 +echo "configure:1121: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1139,7 +1147,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1143: checking for $ac_word" >&5 +echo "configure:1151: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1190,7 +1198,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1194: checking for $ac_word" >&5 +echo "configure:1202: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1222,7 +1230,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1226: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:1234: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1233,12 +1241,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 1237 "configure" +#line 1245 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:1242: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1250: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1264,12 +1272,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1268: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1276: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:1273: checking whether we are using GNU C" >&5 +echo "configure:1281: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1278,7 +1286,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1282: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1290: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -1297,7 +1305,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1301: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1309: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1329,12 +1337,12 @@ else fi echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:1333: checking for working const" >&5 +echo "configure:1341: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1338 "configure" +#line 1346 "configure" #include "confdefs.h" int main() { @@ -1383,7 +1391,7 @@ ccp = (char const *const *) p; ; return 0; } EOF -if { (eval echo configure:1387: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1395: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -1404,21 +1412,21 @@ EOF fi echo $ac_n "checking for inline""... $ac_c" 1>&6 -echo "configure:1408: checking for inline" >&5 +echo "configure:1416: checking for inline" >&5 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat > conftest.$ac_ext <<EOF -#line 1415 "configure" +#line 1423 "configure" #include "confdefs.h" int main() { } $ac_kw foo() { ; return 0; } EOF -if { (eval echo configure:1422: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1430: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_inline=$ac_kw; break else @@ -1462,6 +1470,166 @@ else PGSQL_TRUE='#' PGSQL_FALSE= fi +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:1475: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext <<EOF +#line 1490 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1496: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext <<EOF +#line 1507 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1513: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext <<EOF +#line 1524 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1530: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +for ac_hdr in endian.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1558: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1563 "configure" +#include "confdefs.h" +#include <$ac_hdr> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1568: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <<EOF +#define $ac_tr_hdr 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + +for ac_hdr in crypt.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1598: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1603 "configure" +#include "confdefs.h" +#include <$ac_hdr> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1608: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <<EOF +#define $ac_tr_hdr 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + @@ -1529,19 +1697,7 @@ fi trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 -# Transform confdefs.h into DEFS. -# Protect against shell expansion while executing Makefile rules. -# Protect against Makefile macro expansion. -cat > conftest.defs <<\EOF -s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g -s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g -s%\[%\\&%g -s%\]%\\&%g -s%\$%$$%g -EOF -DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` -rm -f conftest.defs - +DEFS=-DHAVE_CONFIG_H # Without the "./", some shells look in PATH for config.status. : ${CONFIG_STATUS=./config.status} @@ -1579,7 +1735,7 @@ done ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" -trap 'rm -fr `echo "Makefile mysql/Makefile pgsql/Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +trap 'rm -fr `echo "Makefile mysql/Makefile pgsql/Makefile config.h:config.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS <<EOF @@ -1631,6 +1787,7 @@ s%@MYSQL_TRUE@%$MYSQL_TRUE%g s%@MYSQL_FALSE@%$MYSQL_FALSE%g s%@PGSQL_TRUE@%$PGSQL_TRUE%g s%@PGSQL_FALSE@%$PGSQL_FALSE%g +s%@CPP@%$CPP%g s%@SQLLIB@%$SQLLIB%g s%@SQLALIB@%$SQLALIB%g s%@MYSQLINC@%$MYSQLINC%g @@ -1735,11 +1892,120 @@ s%@INSTALL@%$INSTALL%g fi; done rm -f conftest.s* +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' +ac_dC='\3' +ac_dD='%g' +# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". +ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='\([ ]\)%\1#\2define\3' +ac_uC=' ' +ac_uD='\4%g' +# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_eB='$%\1#\2define\3' +ac_eC=' ' +ac_eD='%g' + +if test "${CONFIG_HEADERS+set}" != set; then EOF cat >> $CONFIG_STATUS <<EOF + CONFIG_HEADERS="config.h:config.in" +EOF +cat >> $CONFIG_STATUS <<\EOF +fi +for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + echo creating $ac_file + + rm -f conftest.frag conftest.in conftest.out + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + cat $ac_file_inputs > conftest.in + +EOF + +# Transform confdefs.h into a sed script conftest.vals that substitutes +# the proper values into config.h.in to produce config.h. And first: +# Protect against being on the right side of a sed subst in config.status. +# Protect against being in an unquoted here document in config.status. +rm -f conftest.vals +cat > conftest.hdr <<\EOF +s/[\\&%]/\\&/g +s%[\\$`]%\\&%g +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp +s%ac_d%ac_u%gp +s%ac_u%ac_e%gp +EOF +sed -n -f conftest.hdr confdefs.h > conftest.vals +rm -f conftest.hdr + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >> conftest.vals <<\EOF +s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% +EOF + +# Break up conftest.vals because some shells have a limit on +# the size of here documents, and old seds have small limits too. + +rm -f conftest.tail +while : +do + ac_lines=`grep -c . conftest.vals` + # grep -c gives empty output for an empty file on some AIX systems. + if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi + # Write a limited-size here document to conftest.frag. + echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS + echo 'CEOF + sed -f conftest.frag conftest.in > conftest.out + rm -f conftest.in + mv conftest.out conftest.in +' >> $CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail + rm -f conftest.vals + mv conftest.tail conftest.vals +done +rm -f conftest.vals + +cat >> $CONFIG_STATUS <<\EOF + rm -f conftest.frag conftest.h + echo "/* $ac_file. Generated automatically by configure. */" > conftest.h + cat conftest.in >> conftest.h + rm -f conftest.in + if cmp -s $ac_file conftest.h 2>/dev/null; then + echo "$ac_file is unchanged" + rm -f conftest.h + else + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + fi + rm -f $ac_file + mv conftest.h $ac_file + fi +fi; done + +EOF +cat >> $CONFIG_STATUS <<EOF + EOF cat >> $CONFIG_STATUS <<\EOF +test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h exit 0 EOF diff --git a/configure.in b/configure.in index e05fd345..f80b5e86 100644 --- a/configure.in +++ b/configure.in @@ -1,7 +1,8 @@ AC_INIT(main.c) AC_CONFIG_AUX_DIR(buildtools) +AM_CONFIG_HEADER(config.h:config.in) DBMAIL_MSG_CONFIGURE_START -AM_INIT_AUTOMAKE(dbmail-smtp, 1.1) +AM_INIT_AUTOMAKE(dbmail, 1.1) AM_MAINTAINER_MODE AC_PROG_RANLIB @@ -35,6 +36,8 @@ AC_C_INLINE AM_CONDITIONAL(MYSQL, [test -n "$MYSQLINC"]) AM_CONDITIONAL(PGSQL, [test -n "$PGSQLINC"]) +AC_CHECK_HEADERS(endian.h) +AC_CHECK_HEADERS(crypt.h) AC_SUBST(SQLLIB) AC_SUBST(SQLALIB) AC_SUBST(MYSQLINC) @@ -8,6 +8,10 @@ #ifndef _DB_H #define _DB_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "debug.h" #include "dbmailtypes.h" #include "mime.h" diff --git a/dbmailtypes.h b/dbmailtypes.h index ffcbab00..faa53be3 100644 --- a/dbmailtypes.h +++ b/dbmailtypes.h @@ -8,6 +8,10 @@ #ifndef _DBMAILTYPES_H #define _DBMAILTYPES_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "memblock.h" #include "list.h" @@ -3,6 +3,10 @@ * * Functions to create md5 hash from buf */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -28,7 +32,5 @@ unsigned char *makemd5(char *buf) sprintf (&md5hash[i*2],"%02x", result[i]); } - printf ("hash found [%s]\n",md5hash); - return md5hash; } @@ -3,8 +3,12 @@ * * MD5 creation */ -#ifndef DBMD5_H_ -#define DBMD5_H_ +#ifndef _DBMD5_H +#define _DBMD5_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif unsigned char *makemd5(char *buf); @@ -10,6 +10,10 @@ #ifndef _DBMSGBUF_H #define _DBMSGBUF_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "dbmailtypes.h" #include "memblock.h" @@ -9,6 +9,10 @@ #ifndef _DBSEARCH_H #define _DBSEARCH_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "dbmailtypes.h" int db_search(int *rset, int setlen, const char *key, mailbox_t *mb); @@ -1,3 +1,7 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "db.h" #include <stdio.h> #include <stdlib.h> @@ -3,6 +3,10 @@ * * Debugging and memory checking functions */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdlib.h> #include "debug.h" #include <string.h> @@ -3,6 +3,10 @@ * * debug.h : headers for debug.c */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> #include <sys/syslog.h> #include <stdarg.h> @@ -3,6 +3,10 @@ * * takes care of forwarding mail to an external address */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> #include <time.h> #include "db.h" @@ -10,7 +14,7 @@ #include "list.h" #include "bounce.h" #include "forward.h" -#include "config.h" +#include "dbmail.h" #include <string.h> #include <stdlib.h> @@ -1,8 +1,12 @@ /* $Id$ * (c) 2000-2002 IC&S, The Netherlands */ -#ifndef FORWARD_H_ -#define FORWARD_H_ +#ifndef _FORWARD_H +#define _FORWARD_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #define FW_SENDMAIL SENDMAIL @@ -6,6 +6,10 @@ * implements an IMAP 4 rev 1 server. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -7,10 +7,14 @@ #ifndef _IMAP4_H #define _IMAP4_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "dbmailtypes.h" #include "clientinfo.h" -#define IMAP_SERVER_VERSION "1.1" +#define IMAP_SERVER_VERSION VERSION //#define IMAP_CAPABILITY_STRING "IMAP4 IMAP4rev1 AUTH=LOGIN QUOTA" #define IMAP_CAPABILITY_STRING "IMAP4 IMAP4rev1 AUTH=LOGIN" #define IMAP_TIMEOUT_MSG "* BYE dbmail IMAP4 server signing off due to timeout\r\n" diff --git a/imapcommands.c b/imapcommands.c index 2f159f64..d523fd62 100644 --- a/imapcommands.c +++ b/imapcommands.c @@ -6,6 +6,10 @@ * IMAP server command implementations */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "imapcommands.h" #include "imaputil.h" #include "db.h" @@ -21,7 +25,7 @@ #include <sys/types.h> #include <time.h> #include "debug.h" -#include "config.h" +#include "dbmail.h" #ifdef PROC_TITLES #include "proctitleutils.h" #endif diff --git a/imapcommands.h b/imapcommands.h index 301e9ab6..914b5daa 100644 --- a/imapcommands.h +++ b/imapcommands.h @@ -9,6 +9,10 @@ #ifndef _IMAP_COMMANDS_H #define _IMAP_COMMANDS_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "imap4.h" /* any-state commands */ @@ -6,6 +6,10 @@ * main prg for imap daemon */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -17,14 +21,14 @@ #include "server.h" #include "debug.h" #include "misc.h" -#include "config.h" +#include "dbmail.h" #ifdef PROC_TITLES #include "proctitleutils.h" #endif #define PNAME "dbmail/imap4d" -char *configFile = "/etc/dbmail.conf"; +char *configFile = DEFAULT_CONFIG_FILE; /* set up database login data */ extern field_t _db_host; @@ -6,6 +6,9 @@ * IMAP-server utility functions implementations */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include <stdio.h> #include <string.h> @@ -9,6 +9,10 @@ #ifndef _IMAPUTIL_H #define _IMAPUTIL_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "imap4.h" #include "db.h" #include "memblock.h" @@ -4,6 +4,10 @@ * Code for the SMTP injector program. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "auth.h" #include "db.h" #include "debug.h" @@ -3,6 +3,10 @@ * * functions to create lists and add/delete items */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -6,6 +6,10 @@ #ifndef _LIST_H #define _LIST_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <sys/types.h> /* @@ -3,7 +3,11 @@ * * main file for dbmail-smtp */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif + +#include "dbmail.h" #include "main.h" #include "pipe.h" #include "list.h" @@ -25,7 +29,7 @@ struct list users; /* list of email addresses in message */ struct list sysItems, smtpItems; /* config item lists */ -char *configFile = "/etc/dbmail.conf"; +char *configFile = DEFAULT_CONFIG_FILE; /* set up database login data */ extern field_t _db_host; @@ -4,6 +4,10 @@ #ifndef _MAIN_H #define _MAIN_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "debug.h" #include "list.h" #include "db.h" diff --git a/maintenance.c b/maintenance.c index 3116b66c..81f649a4 100644 --- a/maintenance.c +++ b/maintenance.c @@ -6,12 +6,17 @@ * deleted messages. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "maintenance.h" #include "db.h" #include "debug.h" -#include "config.h" +#include "dbmail.h" #include "list.h" #include "debug.h" +#include "auth.h" #include <unistd.h> #include <time.h> #include <stdio.h> @@ -19,7 +24,7 @@ #include <time.h> #include <string.h> -char *configFile = "/etc/dbmail.conf"; +char *configFile = DEFAULT_CONFIG_FILE; /* set up database login data */ extern field_t _db_host; diff --git a/maintenance.h b/maintenance.h index 72631071..02ce89f5 100644 --- a/maintenance.h +++ b/maintenance.h @@ -4,6 +4,10 @@ #ifndef _MAINTENANCE_H #define _MAINTENANCE_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #define LEN 30 #define PNAME "dbmail/maintenance" diff --git a/man/dbmail-adduser.1 b/man/dbmail-adduser.1 index 756456c1..83856184 100644 --- a/man/dbmail-adduser.1 +++ b/man/dbmail-adduser.1 @@ -13,7 +13,7 @@ Adds mailusers to the \fBDbmail\fR mailsystem \fBdbmail-adduser\fR [\fIquiet\fR] \fId\fR \fIusername\fR \fBdbmail-adduser\fR [\fIquiet\fR] \fIf\fR \fIalias\fR \fIdeliver-to\fR \fBdbmail-adduser\fR [\fIquiet\fR] \fIx\fR \fIalias\fR \fIdeliver-to\fR -\fBdbmail-adduser\fR [\fIquiet\fR] \fIc\fR \fIusername\fR [\fI-u username\fR] [\fI-p password\fR] [\fI+p password\fR] [\fIxp password\fR] [\fI-P[:filename]\fR] [\fI-c clientid\fR] [\fI-q maxmail\fR] [\fI+a alias\fR] [\fI-a alias\fR] +\fBdbmail-adduser\fR [\fIquiet\fR] \fIc\fR \fIusername\fR [\fI-u username\fR] [[\fI-p|+p|xp|-5|+5|d5|D5 password\fR] | [\fI-P[:filename]\fR]] [\fI-c clientid\fR] [\fI-q maxmail\fR] [\fI+a alias\fR] [\fI-a alias\fR] \fBdbmail-adduser\fR [\fIquiet\fR] \fIs\fR [\fIusername\fR] .SH DESCRIPTION @@ -37,7 +37,7 @@ Add a user. Arguments: The username of the user to be added. This username is used for access and authentication (through pop3 or imap4). .BI \fIpassword\fR -Cleartext password for user. If the password is preceeded by '{crypt:}' the (cleartext) password will be encrypted. If the password is preceeded by '{crypt}' the password on the command line is assumed to be already encrypted. +Cleartext password for user. If the password is preceeded by '{crypt:}' the (cleartext) password will be encrypted. If the password is preceeded by '{crypt}' the password on the command line is assumed to be already encrypted. If the password is preceeded by '{md5:}' the (cleartext) password will be saved as an md5 hash. If the password is preceeded by '{md5}' the password on the command line is assumed to be an md5 hash. If the password is preceeded by '{md5sum:}' the (cleartext) password will be saved as an md5 digest. If the password is preceeded by '{md5sum}' the password on the command line is assumed to be the md5 digest. .BI \fIclientid\fR This option enables users to be grouped. \fIclientid\fR specifies the owner of the user. @@ -85,6 +85,18 @@ The new (cleartext) password for this user which will be stored encrypted. .BI [\fIxp\ password\fR] The new crypt encryped password for this user. +.BI [\fI-5\ password\fR] +The md5 hash of the new password for this user. + +.BI [\fI+5\ password\fR] +The new (cleartext) password for this user which will be stored as an md5 hash. + +.BI [\fId5\ password\fR] +The md5 digest of the new password for this user. + +.BI [\fID5\ password\fR] +The new (cleartext) password for this user which will be stored as an md5 digest. + .BI [\fI-P[:filename]\fR] The new password for this user will be copied from '/etc/shadow' (default) or from \fIfilename\fR (if specified). These files are supposed to contain encrypted passwords, the passwords will be copied encrypted from the file. diff --git a/mbox2dbmail.c b/mbox2dbmail.c index 368c03a6..bc84dec4 100644 --- a/mbox2dbmail.c +++ b/mbox2dbmail.c @@ -7,6 +7,10 @@ * The file is read from stdin, the user is specified on the command line. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> #include <sys/types.h> #include <regex.h> @@ -19,12 +19,15 @@ * */ -#include <string.h> /* for memcpy() */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif -#ifdef __LINUX__ +#ifdef HAVE_ENDIAN_H #include <endian.h> #endif +#include <string.h> /* for memcpy() */ #include "md5.h" #if BYTE_ORDER == LITTLE_ENDIAN @@ -3,6 +3,10 @@ #ifndef GdmMD5_H #define GdmMD5_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #ifdef __alpha typedef unsigned int uint32; #else @@ -4,6 +4,10 @@ * implementations of functions declared in memblock.h */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "memblock.h" #include <unistd.h> #include <stdlib.h> @@ -9,6 +9,10 @@ #ifndef _MEMBLOCK_H #define _MEMBLOCK_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #define _MEMBLOCK_SIZE (512ul*1024ul) struct memblock @@ -4,6 +4,10 @@ * Functions for parsing a mime mailheader (actually just for scanning for email messages and parsing the messageID */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "mime.h" #include "debug.h" #include <ctype.h> @@ -1,8 +1,12 @@ /* $Id$ * (c) 2000-2002 IC&S, The Netherlands */ -#ifndef MIME_H_ -#define MIME_H_ +#ifndef _MIME_H +#define _MIME_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include "dbmailtypes.h" diff --git a/mini-injector.c b/mini-injector.c index 2fda47a0..67c4014f 100644 --- a/mini-injector.c +++ b/mini-injector.c @@ -10,6 +10,10 @@ * - user ID is not checked */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "db.h" #include "debug.h" #include "list.h" @@ -3,7 +3,11 @@ * * Miscelaneous functions */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif + +#include "dbmail.h" #include "misc.h" int drop_priviledges (char *newuser, char *newgroup) @@ -40,3 +44,10 @@ int drop_priviledges (char *newuser, char *newgroup) } return 0; } + +char *itoa(int i) +{ + char *s=(char *) malloc(42); /* Enough for a 128 bit integer */ + if (s) sprintf(s,"%d",i); + return s; +} @@ -1,8 +1,13 @@ /* $Id$ * (c) 2000-2002 IC&S, The Netherlands */ -#ifndef MISC_H_ -#define MISC_H_ +#ifndef _MISC_H +#define _MISC_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <grp.h> #include <sys/types.h> #include <unistd.h> @@ -12,5 +17,6 @@ #include "list.h" int drop_priviledges (char *newuser, char *newgroup); +char * itoa (int i); #endif diff --git a/mysql/Makefile.in b/mysql/Makefile.in index 396df446..114393b7 100644 --- a/mysql/Makefile.in +++ b/mysql/Makefile.in @@ -74,11 +74,12 @@ VERSION = @VERSION@ @MYSQL_TRUE@libmysqldbmail_a_SOURCES = dbauthmysql.c dbmysql.c dbmsgbufmysql.c dbsearchmysql.c mkinstalldirs = $(SHELL) $(top_srcdir)/buildtools/mkinstalldirs +CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = LIBRARIES = $(lib_LIBRARIES) -DEFS = @DEFS@ -I. -I$(srcdir) +DEFS = @DEFS@ -I. -I$(srcdir) -I.. CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ diff --git a/mysql/dbauthmysql.c b/mysql/dbauthmysql.c index bfe5fd0a..a7cd0bf2 100644 --- a/mysql/dbauthmysql.c +++ b/mysql/dbauthmysql.c @@ -5,23 +5,25 @@ * user management for mySQL dbases */ -#include "../auth.h" -//#include "/usr/include/mysql/mysql.h" +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "auth.h" #include "mysql.h" -#include "../list.h" -#include "../debug.h" +#include "list.h" +#include "debug.h" #include <stdlib.h> #include <stdio.h> #include <string.h> -#include "../db.h" -#include "../dbmd5.h" -#if defined(__FreeBSD__) +#include "db.h" +#include "dbmd5.h" +#include "dbmail.h" +#include <time.h> #include <unistd.h> -#else +#ifdef HAVE_CRYPT_H #include <crypt.h> #endif -#include "../config.h" -#include <time.h> #define AUTH_QUERY_SIZE 1024 @@ -635,13 +637,14 @@ u64_t auth_validate (char *user, char *password) char timestr[30]; time_t td; struct tm tm; + char salt[13]; + char cryptres[35]; time(&td); /* get time */ tm = *localtime(&td); /* get components */ strftime(timestr, sizeof(timestr), "%G-%m-%d %H:%M:%S", &tm); - snprintf(__auth_query_data, AUTH_QUERY_SIZE, "SELECT user_idnr, passwd, encryption_type FROM users " - "WHERE userid = '%s'", user); + snprintf(__auth_query_data, AUTH_QUERY_SIZE, "SELECT user_idnr, passwd, encryption_type FROM users WHERE userid = '%s'", user); if (__auth_query(__auth_query_data)==-1) { @@ -659,7 +662,7 @@ u64_t auth_validate (char *user, char *password) if (!__auth_row) { - /* user does not exist */ + trace (TRACE_DEBUG,"auth_validate(): userid '%s' not found", user); mysql_free_result(__auth_res); return 0; } @@ -672,8 +675,35 @@ u64_t auth_validate (char *user, char *password) else if ( strcasecmp(__auth_row[2], "crypt") == 0) { trace (TRACE_DEBUG,"auth_validate(): validating using crypt() encryption"); - is_validated = (strcmp( crypt(password, __auth_row[1]), __auth_row[1]) == 0) ? 1 : 0; + is_validated = (strcmp( (const char *) crypt(password, __auth_row[1]), __auth_row[1]) == 0) ? 1 : 0; + } + else if ( strcasecmp(__auth_row[2], "md5") == 0) + { + if ( strncmp(__auth_row[1], "$1$", 3) ) + { + trace (TRACE_DEBUG,"auth_validate(): validating using MD5 digest comparison"); + is_validated = (strncmp( makemd5(password), __auth_row[1], 32) == 0) ? 1 : 0; + } + else + { + trace (TRACE_DEBUG,"auth_validate(): validating using MD5 hash comparison"); + + strncpy (salt, __auth_row[1], 12); + strncpy(cryptres, (char *) crypt(password, salt), 34); + + trace (TRACE_DEBUG,"auth_validate(): salt : %s", salt); + trace (TRACE_DEBUG,"auth_validate(): hash : %s", __auth_row[1]); + trace (TRACE_DEBUG,"auth_validate(): crypt(): %s", cryptres); + + is_validated = (strncmp( __auth_row[1], cryptres, 34) == 0) ? 1 : 0; + } + } + else if ( strcasecmp(__auth_row[2], "md5sum") == 0) + { + trace (TRACE_DEBUG,"auth_validate(): validating using MD5 digest comparison"); + is_validated = (strncmp( makemd5(password), __auth_row[1], 32) == 0) ? 1 : 0; } + if (is_validated) { @@ -733,7 +763,7 @@ u64_t auth_md5_validate (char *username,unsigned char *md5_apop_he, char *apop_s __auth_row = mysql_fetch_row(__auth_res); - /* now authenticate using MD5 hash comparisation + /* now authenticate using MD5 hash comparison * __auth_row[0] contains the password */ trace (TRACE_DEBUG,"auth_md5_validate(): apop_stamp=[%s], userpw=[%s]",apop_stamp,__auth_row[0]); diff --git a/mysql/dbmsgbufmysql.c b/mysql/dbmsgbufmysql.c index 5f0f67a3..6c43e4a8 100644 --- a/mysql/dbmsgbufmysql.c +++ b/mysql/dbmsgbufmysql.c @@ -5,9 +5,12 @@ * using a mysql database */ -#include "../dbmsgbuf.h" -#include "../db.h" -//#include "/usr/include/mysql/mysql.h" +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "dbmsgbuf.h" +#include "db.h" #include "mysql.h" #include <stdlib.h> #include <string.h> diff --git a/mysql/dbmysql.c b/mysql/dbmysql.c index f62c67cf..ac4b9a14 100644 --- a/mysql/dbmysql.c +++ b/mysql/dbmysql.c @@ -4,21 +4,24 @@ * mysql driver file * Functions for connecting and talking to the Mysql database */ -#include "../db.h" -//#include "/usr/include/mysql/mysql.h" +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "db.h" #include "mysql.h" -#include "../config.h" -#include "../pop3.h" -#include "../list.h" -#include "../mime.h" -#include "../pipe.h" -#include "../memblock.h" +#include "dbmail.h" +#include "pop3.h" +#include "list.h" +#include "mime.h" +#include "pipe.h" +#include "memblock.h" #include <time.h> #include <ctype.h> #include <sys/types.h> #include <regex.h> -#include "../rfcmsg.h" -#include "../auth.h" +#include "rfcmsg.h" +#include "auth.h" MYSQL conn; @@ -1508,7 +1511,7 @@ int db_log_ip(const char *ip) if (id) { /* this IP is already in the table, update the 'since' field */ - snprintf(query, DEF_QUERYSIZE, "UPDATE pbsp SET since = '%s' WHERE idnr=%llu",timestr,id); + snprintf(query, DEF_QUERYSIZE, "UPDATE pbsp SET since = unix_timestamp() WHERE idnr=%llu",id); if (db_query(query) == -1) { @@ -1520,8 +1523,7 @@ int db_log_ip(const char *ip) else { /* IP not in table, insert row */ - snprintf(query, DEF_QUERYSIZE, "INSERT INTO pbsp (since, ipnumber) VALUES ('%s','%s')", - timestr, ip); + snprintf(query, DEF_QUERYSIZE, "INSERT INTO pbsp (since, ipnumber) VALUES (unix_timestamp(),'%s')", ip); if (db_query(query) == -1) { diff --git a/mysql/dbsearchmysql.c b/mysql/dbsearchmysql.c index f1d3a581..d69de31b 100644 --- a/mysql/dbsearchmysql.c +++ b/mysql/dbsearchmysql.c @@ -4,11 +4,14 @@ * function implementations for searching messages */ -#include "../dbsearch.h" -#include "../db.h" -//#include "/usr/include/mysql/mysql.h" +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "dbsearch.h" +#include "db.h" #include "mysql.h" -#include "../rfcmsg.h" +#include "rfcmsg.h" #include <stdlib.h> #include <stdio.h> #include <string.h> diff --git a/pgsql/Makefile.am b/pgsql/Makefile.am index e1417f71..34a83ee2 100644 --- a/pgsql/Makefile.am +++ b/pgsql/Makefile.am @@ -1,5 +1,8 @@ if PGSQL AM_CFLAGS = -I @PGSQLINC@ + lib_LIBRARIES = libpgsqldbmail.a -libpgsqldbmail_a_SOURCES = dbauthpgsql.c dbpgsql.c dbmsgbufpgsql.c dbsearchpgsql.c + +libpgsqldbmail_a_SOURCES = dbauthpgsql.c dbpgsql.c dbmsgbufpgsql.c \ + dbsearchpgsql.c endif diff --git a/pgsql/Makefile.in b/pgsql/Makefile.in index 79b1e20a..967e6e4d 100644 --- a/pgsql/Makefile.in +++ b/pgsql/Makefile.in @@ -69,14 +69,17 @@ SQLLIB = @SQLLIB@ VERSION = @VERSION@ @PGSQL_TRUE@AM_CFLAGS = -I @PGSQLINC@ + @PGSQL_TRUE@lib_LIBRARIES = libpgsqldbmail.a -@PGSQL_TRUE@libpgsqldbmail_a_SOURCES = dbauthpgsql.c dbpgsql.c dbmsgbufpgsql.c dbsearchpgsql.c + +@PGSQL_TRUE@libpgsqldbmail_a_SOURCES = dbauthpgsql.c dbpgsql.c dbmsgbufpgsql.c dbsearchpgsql.c mkinstalldirs = $(SHELL) $(top_srcdir)/buildtools/mkinstalldirs +CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = LIBRARIES = $(lib_LIBRARIES) -DEFS = @DEFS@ -I. -I$(srcdir) +DEFS = @DEFS@ -I. -I$(srcdir) -I.. CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ diff --git a/pgsql/dbauthpgsql.c b/pgsql/dbauthpgsql.c index bd178689..d17989bd 100644 --- a/pgsql/dbauthpgsql.c +++ b/pgsql/dbauthpgsql.c @@ -6,22 +6,24 @@ * (c) 2000-2002 IC&S, The Netherlands (http://www.ic-s.nl) */ -#include "../auth.h" -//#include "/usr/local/pgsql/include/libpq-fe.h" +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "auth.h" #include "libpq-fe.h" -#include "../list.h" -#include "../debug.h" +#include "list.h" +#include "debug.h" #include <stdlib.h> #include <stdio.h> #include <string.h> -#include "../dbmd5.h" -#if defined(__FreeBSD__) +#include "dbmd5.h" +#include "dbmail.h" +#include <time.h> #include <unistd.h> -#else +#ifdef HAVE_CRYPT_H #include <crypt.h> #endif -#include "../config.h" -#include <time.h> #define AUTH_QUERY_SIZE 1024 @@ -709,13 +711,14 @@ u64_t auth_validate (char *user, char *password) char timestr[30]; time_t td; struct tm tm; + char salt[13]; + char cryptres[35]; time(&td); /* get time */ tm = *localtime(&td); /* get components */ strftime(timestr, sizeof(timestr), "%G-%m-%d %H:%M:%S", &tm); - snprintf(__auth_query_data, AUTH_QUERY_SIZE, "SELECT user_idnr, passwd, encryption_type FROM users " - "WHERE userid = '%s'", user); + snprintf(__auth_query_data, AUTH_QUERY_SIZE, "SELECT user_idnr, passwd, encryption_type FROM users WHERE userid = '%s'", user); if (__auth_query(__auth_query_data)==-1) { @@ -741,7 +744,36 @@ u64_t auth_validate (char *user, char *password) { trace (TRACE_DEBUG,"auth_validate(): validating using crypt() encryption"); row = PQgetvalue(__auth_res, 0, 1); - is_validated = (strcmp( crypt(password, row), row) == 0) ? 1 : 0; + is_validated = (strcmp( (const char *) crypt(password, row), row) == 0) ? 1 : 0; + } + else if ( strcasecmp(row, "md5") == 0) + { + row = PQgetvalue(__auth_res, 0, 1); + if ( strncmp(row, "$1$", 3) ) + { + trace (TRACE_DEBUG,"auth_validate(): validating using MD5 digest comparison"); + row = PQgetvalue(__auth_res, 0, 1); + is_validated = (strncmp( makemd5(password), row, 32) == 0) ? 1 : 0; + } + else + { + trace (TRACE_DEBUG,"auth_validate(): validating using MD5 hash comparison"); + + strncpy (salt, row, 12); + strncpy(cryptres, (char *) crypt(password, salt), 34); + + trace (TRACE_DEBUG,"auth_validate(): salt : %s", salt); + trace (TRACE_DEBUG,"auth_validate(): hash : %s", row); + trace (TRACE_DEBUG,"auth_validate(): crypt(): %s", cryptres); + + is_validated = (strncmp( row, cryptres, 34) == 0) ? 1 : 0; + } + } + else if ( strcasecmp(row, "md5sum") == 0) + { + trace (TRACE_DEBUG,"auth_validate(): validating using MD5 digest comparison"); + row = PQgetvalue(__auth_res, 0, 1); + is_validated = (strncmp( makemd5(password), row, 32) == 0) ? 1 : 0; } if (is_validated) diff --git a/pgsql/dbmsgbufpgsql.c b/pgsql/dbmsgbufpgsql.c index aa54698f..964efb0c 100644 --- a/pgsql/dbmsgbufpgsql.c +++ b/pgsql/dbmsgbufpgsql.c @@ -7,9 +7,12 @@ * (c) 2000-2002 IC&S (http://www.ic-s.nl) */ -#include "../dbmsgbuf.h" -#include "../db.h" -//#include "/usr/local/pgsql/include/libpq-fe.h" +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "dbmsgbuf.h" +#include "db.h" #include "libpq-fe.h" #include <stdlib.h> #include <string.h> diff --git a/pgsql/dbpgsql.c b/pgsql/dbpgsql.c index 5c9bbb14..4f82ab58 100644 --- a/pgsql/dbpgsql.c +++ b/pgsql/dbpgsql.c @@ -4,16 +4,19 @@ * postgresql driver file * Functions for connecting and talking to the PostgreSQL database */ -#include "../db.h" -//#include "/usr/local/pgsql/include/libpq-fe.h" +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "db.h" #include "libpq-fe.h" -#include "../config.h" -#include "../list.h" -#include "../mime.h" -#include "../pipe.h" -#include "../memblock.h" -#include "../rfcmsg.h" -#include "../auth.h" +#include "dbmail.h" +#include "list.h" +#include "mime.h" +#include "pipe.h" +#include "memblock.h" +#include "rfcmsg.h" +#include "auth.h" #include <time.h> #include <ctype.h> #include <sys/types.h> @@ -1406,7 +1409,7 @@ int db_log_ip(const char *ip) return -1; } - if (PQntuples>0) + if (PQntuples(res) > 0) { row = PQgetvalue (res, 0, 0); id = row ? strtoull(row, NULL, 10) : 0; @@ -1419,7 +1422,7 @@ int db_log_ip(const char *ip) if (id) { /* this IP is already in the table, update the 'since' field */ - snprintf(query, DEF_QUERYSIZE, "UPDATE pbsp SET since = '%s' WHERE idnr=%llu::bigint",timestr,id); + snprintf(query, DEF_QUERYSIZE, "UPDATE pbsp SET since = current_timestamp WHERE idnr=%llu::bigint",id); if (db_query(query) == -1) { @@ -1431,8 +1434,7 @@ int db_log_ip(const char *ip) else { /* IP not in table, insert row */ - snprintf(query, DEF_QUERYSIZE, "INSERT INTO pbsp (since, ipnumber) VALUES ('%s','%s')", - timestr, ip); + snprintf(query, DEF_QUERYSIZE, "INSERT INTO pbsp (since, ipnumber) VALUES (current_timestamp,'%s')", ip); if (db_query(query) == -1) { diff --git a/pgsql/dbsearchpgsql.c b/pgsql/dbsearchpgsql.c index 211cf1d7..72c70675 100644 --- a/pgsql/dbsearchpgsql.c +++ b/pgsql/dbsearchpgsql.c @@ -5,11 +5,14 @@ * function implementations for searching messages */ -#include "../dbsearch.h" -#include "../db.h" -//#include "/usr/local/pgsql/include/libpq-fe.h" +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "dbsearch.h" +#include "db.h" #include "libpq-fe.h" -#include "../rfcmsg.h" +#include "rfcmsg.h" #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -4,6 +4,10 @@ * Functions for reading the pipe from the MTA */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <time.h> #include <ctype.h> #include "db.h" @@ -12,12 +16,16 @@ #include "list.h" #include "bounce.h" #include "forward.h" -#include "config.h" +#include "dbmail.h" #include "pipe.h" #include "debug.h" #include <errno.h> #include <string.h> #include <stdlib.h> +#include <sys/types.h> +#include <unistd.h> +#include "dbmd5.h" +#include "misc.h" #define HEADER_BLOCK_SIZE 1024 @@ -36,10 +44,9 @@ int send_reply(struct list *headerfields, const char *body); void create_unique_id(char *target, u64_t messageid) { - time_t now; - time(&now); - trace (TRACE_DEBUG,"create_unique_id(): createding id"); - snprintf (target,UID_SIZE,"%lluA%lu",messageid,now); + trace (TRACE_DEBUG,"create_unique_id(): creating id"); + srand((int) ((int) time(NULL) + (int) getpid()) ); + snprintf (target,UID_SIZE,"%s",makemd5( itoa((int) rand() * (int) messageid) )); trace (TRACE_DEBUG,"create_unique_id(): created: %s",target); } @@ -300,9 +307,11 @@ int insert_messages(char *header, u64_t headersize, struct list *users, /* make the id numeric */ userid = strtoull((char *)tmp->data, NULL, 10); + create_unique_id(unique_id,0); + /* create a message record */ temp_message_record_id = db_insert_message ((u64_t)userid, - deliver_to_mailbox, ""); + deliver_to_mailbox, unique_id); /* message id is an array of returned message id's * all messageblks are inserted for each message id @@ -1,8 +1,12 @@ /* $Id$ * (c) 2000-2002 IC&S, The Netherlands */ -#ifndef PIPE_H_ -#define PIPE_H_ +#ifndef _PIPE_H +#define _PIPE_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include "list.h" @@ -3,7 +3,11 @@ * * implementation for pop3 commands according to RFC 1081 */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif + +#include "dbmail.h" #include "pop3.h" #include "db.h" #include "debug.h" @@ -6,6 +6,10 @@ #ifndef _POP3_H #define _POP3_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> #include <unistd.h> #include <stdlib.h> @@ -26,7 +30,7 @@ #include "misc.h" #include "list.h" #include "debug.h" -#include "config.h" +#include "dbmail.h" #include "dbmailtypes.h" #include "clientinfo.h" @@ -6,6 +6,10 @@ * main prg for pop3 daemon */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -17,7 +21,7 @@ #include "server.h" #include "debug.h" #include "misc.h" -#include "config.h" +#include "dbmail.h" #include "clientinfo.h" #include "pop3.h" #ifdef PROC_TITLES @@ -30,7 +34,7 @@ /* server timeout error */ #define POP_TIMEOUT_MSG "-ERR I'm leaving, you're tooo slow" -char *configFile = "/etc/dbmail.conf"; +char *configFile = DEFAULT_CONFIG_FILE; /* set up database login data */ extern field_t _db_host; diff --git a/proctitleutils.c b/proctitleutils.c index 57bade04..03151b38 100644 --- a/proctitleutils.c +++ b/proctitleutils.c @@ -1,3 +1,7 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> #include <unistd.h> #include <string.h> diff --git a/proctitleutils.h b/proctitleutils.h index 5c458fce..77d363af 100644 --- a/proctitleutils.h +++ b/proctitleutils.h @@ -9,6 +9,10 @@ #ifndef PROC_TITLE_UTILS_H #define PROC_TITLE_UTILS_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + void set_proc_title(char *fmt,...); void init_set_proc_title(int argc, char *argv[], char *envp[], const char *name); @@ -1,3 +1,7 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdlib.h> #include <string.h> #include "db.h" @@ -1,6 +1,10 @@ #ifndef _DBMAIL_QUOTA_H #define _DBMAIL_QUOTA_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "dbmailtypes.h" diff --git a/raw-convert.c b/raw-convert.c index d5e25597..1eeeb65b 100644 --- a/raw-convert.c +++ b/raw-convert.c @@ -15,6 +15,10 @@ * be about 1GB in size..). */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -5,6 +5,10 @@ * compliant mail message */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "rfcmsg.h" #include "list.h" #include "debug.h" @@ -7,6 +7,10 @@ #ifndef _RFCMSG_H #define _RFCMSG_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "dbmailtypes.h" void db_free_msg(mime_message_t *msg); @@ -4,6 +4,10 @@ * code to implement a network server */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "debug.h" #include "server.h" #include "serverchild.h" @@ -7,11 +7,15 @@ #ifndef _SERVER_H #define _SERVER_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #define IPLEN 32 #define BACKLOG 16 #include <signal.h> -#include "config.h" +#include "dbmail.h" #include "clientinfo.h" typedef struct diff --git a/serverchild.c b/serverchild.c index 35bbd173..63115498 100644 --- a/serverchild.c +++ b/serverchild.c @@ -4,6 +4,10 @@ * function implementations of server children code (connection handling) */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "debug.h" #include "serverchild.h" #include "db.h" diff --git a/serverchild.h b/serverchild.h index 198bc285..820f6452 100644 --- a/serverchild.h +++ b/serverchild.h @@ -8,6 +8,10 @@ #ifndef SERVERCHILD_H #define SERVERCHILD_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <sys/types.h> #include <signal.h> #include "clientinfo.h" @@ -1,10 +1,13 @@ /* $Id$ * (c) 2000-2002 IC&S, The Netherlands */ -#include "settings.h" +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> #include <stdlib.h> -#include "config.h" +#include "dbmail.h" #include "list.h" #include "debug.h" #include "db.h" diff --git a/smtp-convert.c b/smtp-convert.c index e1a2d190..7c27cf93 100644 --- a/smtp-convert.c +++ b/smtp-convert.c @@ -3,6 +3,10 @@ * dbmail conversion on each file. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> #include <string.h> #include <stdlib.h> diff --git a/sql/mysql/create_tables.mysql b/sql/mysql/create_tables.mysql index 65188b6c..b61463c5 100644 --- a/sql/mysql/create_tables.mysql +++ b/sql/mysql/create_tables.mysql @@ -17,7 +17,7 @@ CREATE TABLE aliases ( CREATE TABLE users ( user_idnr bigint(21) DEFAULT '0' NOT NULL auto_increment, userid varchar(100) NOT NULL, - passwd varchar(32) NOT NULL, + passwd varchar(34) NOT NULL, client_idnr bigint(21) DEFAULT '0' NOT NULL, maxmail_size bigint(21) DEFAULT '0' NOT NULL, encryption_type varchar(20) DEFAULT '' NOT NULL, diff --git a/sql/mysql/create_tables_innoDB.mysql b/sql/mysql/create_tables_innoDB.mysql index 6ea02001..cc16e4a1 100644 --- a/sql/mysql/create_tables_innoDB.mysql +++ b/sql/mysql/create_tables_innoDB.mysql @@ -17,7 +17,7 @@ CREATE TABLE aliases ( CREATE TABLE users ( user_idnr bigint(21) DEFAULT '0' NOT NULL auto_increment, userid varchar(100) NOT NULL, - passwd varchar(32) NOT NULL, + passwd varchar(34) NOT NULL, client_idnr bigint(21) DEFAULT '0' NOT NULL, maxmail_size bigint(21) DEFAULT '0' NOT NULL, encryption_type varchar(20) DEFAULT '' NOT NULL, diff --git a/sql/postgresql/create_tables.pgsql b/sql/postgresql/create_tables.pgsql index b138a4b7..fe5930e2 100644 --- a/sql/postgresql/create_tables.pgsql +++ b/sql/postgresql/create_tables.pgsql @@ -19,7 +19,7 @@ CREATE SEQUENCE user_idnr_seq; CREATE TABLE users ( user_idnr INT8 DEFAULT nextval('user_idnr_seq'), userid VARCHAR(100) NOT NULL, - passwd VARCHAR(32) NOT NULL, + passwd VARCHAR(34) NOT NULL, client_idnr INT8 DEFAULT '0' NOT NULL, maxmail_size INT8 DEFAULT '0' NOT NULL, encryption_type VARCHAR(20) DEFAULT '' NOT NULL, diff --git a/sql/postgresql/no-constraint-tables.pgsql b/sql/postgresql/no-constraint-tables.pgsql index 9c9e4eb0..c44d99ba 100644 --- a/sql/postgresql/no-constraint-tables.pgsql +++ b/sql/postgresql/no-constraint-tables.pgsql @@ -16,7 +16,7 @@ CREATE SEQUENCE user_idnr_seq; CREATE TABLE users ( user_idnr INT8 DEFAULT nextval('user_idnr_seq') NOT NULL, userid VARCHAR(100) NOT NULL, - passwd VARCHAR(32) NOT NULL, + passwd VARCHAR(34) NOT NULL, client_idnr INT8 DEFAULT '0' NOT NULL, maxmail_size INT8 DEFAULT '0' NOT NULL, encryption_type VARCHAR(20) DEFAULT '' NOT NULL, @@ -6,6 +6,10 @@ * function implementations of sstack. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "sstack.h" #include <stdlib.h> @@ -10,6 +10,10 @@ #ifndef SSTACK_H #define SSTACK_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #ifndef NULL #define NULL 0 #endif @@ -3,26 +3,29 @@ * This is the dbmail-user program * It makes adding users easier */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "user.h" #include "auth.h" #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "config.h" +#include "dbmail.h" #include "list.h" #include "debug.h" #include "db.h" -#if defined(__FreeBSD__) -#include <unistd.h> -#else -#include <crypt.h> -#endif #include <time.h> #include <stdarg.h> #include <sys/types.h> #include <unistd.h> +#ifdef HAVE_CRYPT_H +#include <crypt.h> +#endif +#include "dbmd5.h" -char *configFile = "/etc/dbmail.conf"; +char *configFile = DEFAULT_CONFIG_FILE; #define SHADOWFILE "/etc/shadow" @@ -212,7 +215,7 @@ int do_add(int argc, char *argv[]) /* check if we need to encrypt this pwd */ if (strncasecmp(argv[1], "{crypt:}", strlen("{crypt:}")) == 0) { - /* encrypt using crypt() */ + /* encrypt using crypt() */ strcat(pw,crypt(&argv[1][strlen("{crypt:}")], cget_salt())); useridnr = auth_adduser(argv[0], pw, "crypt",argv[2],argv[3]); } @@ -221,6 +224,29 @@ int do_add(int argc, char *argv[]) /* assume passwd is encrypted on command line */ useridnr = auth_adduser(argv[0], &argv[1][strlen("{crypt}")], "crypt",argv[2],argv[3]); } + else if (strncasecmp(argv[1], "{md5:}", strlen("{md5:}")) == 0) + { + /* encrypt using md5 crypt() */ + sprintf(pw,"%s%s%s","$1$",cget_salt(),"$"); + strncpy(pw,crypt(&argv[1][strlen("{md5:}")], pw),49); + useridnr = auth_adduser(argv[0], pw, "md5",argv[2],argv[3]); + } + else if (strncasecmp(argv[1], "{md5}", strlen("{md5}")) == 0) + { + /* assume passwd is encrypted on command line */ + useridnr = auth_adduser(argv[0], &argv[1][strlen("{md5}")], "md5",argv[2],argv[3]); + } + else if (strncasecmp(argv[1], "{md5sum:}", strlen("{md5sum:}")) == 0) + { + /* encrypt using md5 digest */ + strcat(pw,makemd5(&argv[1][strlen("{md5sum:}")])); + useridnr = auth_adduser(argv[0], pw, "md5sum",argv[2],argv[3]); + } + else if (strncasecmp(argv[1], "{md5sum}", strlen("{md5sum}")) == 0) + { + /* assume passwd is encrypted on command line */ + useridnr = auth_adduser(argv[0], &argv[1][strlen("{md5sum}")], "md5sum",argv[2],argv[3]); + } else { useridnr = auth_adduser(argv[0],argv[1],"",argv[2],argv[3]); @@ -304,7 +330,8 @@ int do_change(int argc, char *argv[]) for (i=1; argv[i]; i++) { - if (argv[i][0] != '-' && argv[i][0] != '+' && argv[i][0] != 'x') + if (argv[i][0] != '-' && argv[i][0] != '+' && argv[i][0] != 'x' + && argv[i][0] != 'd' && argv[i][0] != 'D') { quiet_printf ("Failed: invalid option specified. Check the man page\n"); return -1; @@ -314,6 +341,11 @@ int do_change(int argc, char *argv[]) { case 'u': /* change the name */ + if (argv[i][0] != '-') + { + quiet_printf ("Failed: invalid option specified. Check the man page\n"); + return -1; + } if (!is_valid(argv[i+1])) { quiet_printf("\nWarning: username contains invalid characters. Username not updated. "); @@ -340,21 +372,69 @@ int do_change(int argc, char *argv[]) switch (argv[i][0]) { case '+': - /* +p will converse clear text into crypt hash value */ + /* +p will convert clear text into crypt hash value */ strcat(pw,crypt(argv[i+1], cget_salt())); result = auth_change_password(userid,pw,"crypt"); break; case '-': - strcpy(pw,argv[i+1]); + strncpy(pw,argv[i+1],49); result = auth_change_password(userid,pw,""); break; case 'x': /* 'xp' will copy passwd from command line assuming that the supplied passwd is crypt encrypted */ - strcpy(pw,argv[i+1]); + strncpy(pw,argv[i+1],49); result = auth_change_password(userid,pw,"crypt"); break; + default: + quiet_printf ("Failed: invalid option specified. Check the man page\n"); + return -1; + } + + if (result != 0) + { + quiet_printf("\nWarning: could not change password "); + retval = -1; + } + + i++; + break; + + case '5': + /* md5 passwords */ + if (!is_valid(argv[i+1])) + { + quiet_printf("\nWarning: password contains invalid characters. Password not updated. "); + retval = -1; + } + switch (argv[i][0]) + { + case '-': + /* -5 takes a md5 hash and saves it */ + strncpy(pw,argv[i+1],49); + result = auth_change_password(userid,pw,"md5"); + break; + case '+': + /* +5 takes a plaintext password and saves as a md5 hash */ + sprintf(pw,"%s%s%s","$1$",cget_salt(),"$"); + strncpy(pw,crypt(argv[i+1], pw),49); + result = auth_change_password(userid,pw,"md5"); + break; + case 'd': + /* d5 takes a md5 digest and saves it */ + strncpy(pw,argv[i+1],49); + result = auth_change_password(userid,pw,"md5sum"); + break; + case 'D': + /* D5 takes a plaintext password and saves as a md5 digest */ + strncat(pw,makemd5(argv[i+1]),49); + result = auth_change_password(userid,pw,"md5sum"); + break; + + default: + quiet_printf ("Failed: invalid option specified. Check the man page\n"); + return -1; } if (result != 0) @@ -369,6 +449,11 @@ int do_change(int argc, char *argv[]) case 'P': /* -P will copy password from SHADOWFILE */ /* -P:filename will copy password from filename */ + if (argv[i][0] != '-') + { + quiet_printf ("Failed: invalid option specified. Check the man page\n"); + return -1; + } if (argv[i][2] == ':') passwdfile = &argv[i][3]; else @@ -392,15 +477,32 @@ int do_change(int argc, char *argv[]) } else { - if (auth_change_password(userid,pw,"crypt") != 0) + if ( strncmp(pw, "$1$", 3) ) { - quiet_printf("\nWarning: could not change password"); - retval = -1; + if (auth_change_password(userid,pw,"crypt") != 0) + { + quiet_printf("\nWarning: could not change password"); + retval = -1; + } + } + else + { + if (auth_change_password(userid,pw,"md5") != 0) + { + quiet_printf("\nWarning: could not change password"); + retval = -1; + } } } break; case 'c': + if (argv[i][0] != '-') + { + quiet_printf ("Failed: invalid option specified. Check the man page\n"); + return -1; + } + newcid = strtoull(argv[i+1], 0, 10); if (auth_change_clientid(userid, newcid) != 0) @@ -413,6 +515,12 @@ int do_change(int argc, char *argv[]) break; case 'q': + if (argv[i][0] != '-') + { + quiet_printf ("Failed: invalid option specified. Check the man page\n"); + return -1; + } + newsize = strtoull(argv[i+1], &endptr, 10); switch (*endptr) { @@ -437,23 +545,27 @@ int do_change(int argc, char *argv[]) break; case 'a': - if (argv[i][0] == '-') + switch (argv[i][0]) { + case '-': /* remove alias */ if (db_removealias(userid, argv[i+1]) < 0) { quiet_printf("\nWarning: could not remove alias [%s] ",argv[i+1]); retval = -1; } - } - else - { + break; + case '+': /* add alias */ if (db_addalias(userid, argv[i+1], auth_getclientid(userid)) < 0) { quiet_printf("\nWarning: could not add alias [%s]",argv[i+1]); retval = -1; } + break; + default: + quiet_printf ("Failed: invalid option specified. Check the man page\n"); + return -1; } i++; break; @@ -1,5 +1,9 @@ /* $Id$ * (c) 2000-2002 IC&S, The Netherlands */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #define PNAME "dbmail/adduser" diff --git a/vut2dbmail.c b/vut2dbmail.c index 07877dd7..53997547 100644 --- a/vut2dbmail.c +++ b/vut2dbmail.c @@ -6,6 +6,10 @@ * the input is read from stdin */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> #include <string.h> #include <ctype.h> |