diff -uP gnu-pop3d-0.9.8/FAQ PATCH-1.0/FAQ --- gnu-pop3d-0.9.8/FAQ Wed Dec 31 16:00:00 1969 +++ PATCH-1.0/FAQ Mon Dec 4 11:46:31 2000 @@ -0,0 +1,15 @@ +GNU-pop3d Frequently Asked Questions +13/Nov/2000 +(Please send your clarifications or answers to jeremy@reedmedia.net.) + + +Why "connection refused" when I check emails? + +Make sure gnu-pop3d is running either as a daemon or via +tcpserver or inetd, for example. (If you get a "Connection +closed by foreign host" then your firewall may be stopping you.) + +Why do the logs say "logged in with mailbox '/dev/null'"? + +Make sure that the mailbox really exists. Make sure that it is running with +the correct UID so it has permissions to access the mailbox. diff -uP gnu-pop3d-0.9.8/INSTALL PATCH-1.0/INSTALL --- gnu-pop3d-0.9.8/INSTALL Wed Sep 22 18:02:44 1999 +++ PATCH-1.0/INSTALL Wed Nov 15 11:16:10 2000 @@ -5,13 +5,47 @@ 2) If you are using procmail or something similar to deliver mail to a nonstandard mailbox location (e.g. $HOME/Mail/inbox) edit the file - pop3d.h and define MAILSPOOLHOME appropriately. + config.h and define MAILSPOOLHOME appropriately. 3) Run `make` to build. If all goes well, you can run `make install` to - install. If you want to run in inetd mode, edit your inetd.conf file + install. + +4) If you want to run in inetd mode, edit your inetd.conf file to point to the program (usually /usr/local/sbin/gnu-pop3d unless you - specified something else with `./configure --prefix`), then restart - inetd with a SIGHUP. If you are running in standalone, you'll need - to create the appropriate symlinks in your /etc/rc.d hierarchy to start - and stop the service in appropriate runlevels. You may also still need - to edit inetd.conf to remove any lines that start other POP3 servers. + specified something else with `./configure --prefix`). Some examples: + + pop stream tcp nowait root /usr/libexec/tcpd /usr/local/sbin/gnu-pop3d + + pop-3 stream tcp nowait.50 root /usr/sbin/gnu-pop3d gnu-pop3d -i + + The "pop" or "pop-3" part is the service name as defined in your + /etc/services file. Be sure to read the inetd.conf manual page + for further information. Then restart inetd with a SIGHUP. + + If you are using xinetd, then maybe use a configuration like: + + service pop-3 + { + socket_type = stream + protocol = tcp + wait = no + user = root + instances = 25 + server = /usr/sbin/gnu-pop3d + server_args = -i + log_type = SYSLOG local4 info + log_on_success = PID HOST EXIT DURATION + log_on_failure = HOST ATTEMPT + } + +5) If you are running in standalone, you'll need to create the + appropriate symlinks in your /etc/rc.d hierarchy to start and + stop the service in appropriate runlevels. (You may also still need + to edit inetd.conf to remove any lines that start other POP3 servers.) + +6) If using PAM (Pluggable Authentication Modules) support, then you + may need to setup /etc/pam.conf or /etc/pam.d/gnu-pop3d with the + information from the included gnu-pop3d.pamd file. + +7) Be sure to read the gnu-pop3d manual page. + diff -uP gnu-pop3d-0.9.8/Makefile.in PATCH-1.0/Makefile.in --- gnu-pop3d-0.9.8/Makefile.in Wed Sep 22 18:02:44 1999 +++ PATCH-1.0/Makefile.in Thu May 18 22:53:58 2000 @@ -29,6 +29,7 @@ DEFS = @DEFS@ LIBS = @LIBS@ +## doesn't compile with followimg -ansi option under BSD/OS CFLAGS = -g -O3 -Wall -pedantic -ansi LDFLAGS = @@ -48,8 +49,8 @@ .SUFFIXES: .SUFFIXES: .c .o -SRCS = apop.c auth.c capa.c dele.c extra.c getopt.c getopt1.c gnu-pop3d.c list.c md5.c noop.c quit.c retr.c rset.c stat.c top.c uidl.c user.c -OBJS = apop.o auth.o capa.o dele.o extra.o getopt.o getopt1.o gnu-pop3d.o list.o md5.o noop.o quit.o retr.o rset.o stat.o top.o uidl.o user.o +SRCS = apop.c auth.c capa.c dele.c extra.c getopt.c getopt1.c gnu-pop3d.c list.c md5.c noop.c quit.c retr.c rset.c stat.c top.c uidl.c user.c virtual.c +OBJS = apop.o auth.o capa.o dele.o extra.o getopt.o getopt1.o gnu-pop3d.o list.o md5.o noop.o quit.o retr.o rset.o stat.o top.o uidl.o user.o virtual.o HDRS = gnu-pop3d.h md5.h getopt.h DISTFILES = $(SRCS) $(HDRS) COPYING Makefile.in README README.rfc README.rpm \ RFC????.txt TODO configure configure.in config.h.in gnu-pop3d.pamd \ diff -uP gnu-pop3d-0.9.8/README.virtual PATCH-1.0/README.virtual --- gnu-pop3d-0.9.8/README.virtual Wed Dec 31 16:00:00 1969 +++ PATCH-1.0/README.virtual Wed Dec 20 16:40:27 2000 @@ -0,0 +1,232 @@ +This is a patch for gnu-pop3d version 0.9.8 that allows use of +separate password files and spool directories for each +virtual domain. + +Information is at http://www.reedmedia.net/projects/virtualmail/. + +This is a freely-available open source solution for virtual +email hosting. (Commercial support is available.) + +This will allow you to have multiple users with the same name +on one system. Well... they aren't really users, just mailboxes. + +(I use the Exim MTA to deliver the mail in the correct spool +hierarchy. You can use whatever you want to put the mail in +the right place; just make sure it is readable and writable +by the user configured in the patch.) + +Then the end-user, enters his/her username AND domain name +as the username in the pop3 mail client separated by an +At sign "@" or a colon ":". (The colon is because Netscape +Messenger pre-parses the username before sending to the +pop3 server.) + +You can also define the config option "IP_BASED_VIRTUAL" which +will select the password file and mail spool directory by the +hostname that the user chooses to connect to. (Of course, with +this option, you will need separate IPs for each virtual domain +and the IP must resolve to the chosen host name.) + +If the user enters the domain name with his username, +it will override the IP-based option. + +To enable these features, simply use configure with these options: + --enable-virtual-domains + --enable-ip-based-virtual + +Some default settings that you may need to change in gnu-pop3d.h: + +- VIRTUAL_UID is the UID of the owner (real Unix account) of the + virtual mailboxes. +- VIRTUAL_MAILDIR is the path to the sub-directories containing + the mailboxes for each virtual domain (or realm). (By default, + this is /var/spool/virtual/.) +- PATH_TO_PASSWORDS is the path to the sub-directories containing + the passwd files for each virtual domain. (By default, this is + /etc/virtual/.) + +The password file is: + +username:ENCRYPTED_PASSWORD + +They are located like: + +/etc/virtual/domainname/passwd +/etc/virtual/poptest.reedmedia.net/passwd +/etc/virtual/foo.bar/passwd + +The mail spool looks like something like this: + +/var/spool/virtual/domainname/jeremy +/var/spool/virtual/domainname/somename +/var/spool/virtual/poptest.reedmedia.net/jeremy +/var/spool/virtual/poptest.reedmedia.net/somename +/var/spool/virtual/foo.bar/jeremy +/var/spool/virtual/foo.bar/somename + +CHANGES / HISTORY +20/Dec/2000 + Code Cleanup: Moved MAXHOSTNAMELEN definition to below + system includes to stop redefined warnings (gnu-pop3d.h). + + Feature: Log signal number before quiting on signal (extra.c). + + Code Cleanup: Renamed MAIL_UID to VIRTUAL_UID (to make this + more clear) and added comments and changed documentation. + Renamed mail_uid to virtual_uid (virtual.c). + + Code Cleanup: Renamed VIRTUALMAILSPOOL to VIRTUAL_MAILDIR + and added comments and changed documentation. + +15/Nov/2000 + Documentation: Added example of using xinetd to INSTALL + document. (Thanks to Sten Eriksson sten.eriksson @ udac.se.) + +13/Nov/2000 + Documentation: Started FAQ. + +3/Nov/2000 + Documentation: Cleaned up and expanded INSTALL document with + details and examples on using inetd. + +22/June/2000 + Bug Fix: Got rid of signal handler for SIGSTOP (gnu-pop3d.c). + According to sigaction(2), it will fail if an attempt is made + to supply a handler for SIGSTOP. It was returning: "EINVAL + (Invalid argument)". + +18/May/2000 + Bug Fix: Got rid of actual signal handler for SIGPIPE. Now + using SIG_IGN to ignore any write on a pipe with no reader. + (Note: The signal handler for SIGPIPE is not in the original + source. It was added to this patch on 21/Jan/2000.) + +21/Apr/2000 + Bug Fix: Fixed configure script to check for libraries after + headers, because it wouldn't check for libpam, because it tests + if pam headers are found first. (Note: This problem is from my + configure.in file -- not in original source distribution.) + + Feature: (Or should I call it a "Bug Fix"?) You can now compile + with PAM support. If using virtual support and a @domain part + exists, then it will bypass the PAM section. + + Documentation: Added note about PAM configuration to INSTALL file. + +6/Mar/2000 + Bug Fix: Fixed INSTALL documentation because MAILSPOOLHOME + is defined in config.h not pop3d.h (Thanks to Mike Klinkert + michael @ nomennescio.net). (Still needs a ./configure option.) + +21/Jan/2000 + Portability: Added signal handler for SIGPIPE (gnu-pop3d.c) + which may stop stale lock files when client drops connection + (Thanks to Ralf Winkel Ralf.Winkel @ tui.de). + +20/Jan/2000 + Code Cleanup: Set pw to NULL in pop3_user (user.c) to stop + "might be used uninitialized" warning. Use type casting for + pointer target passing in pop3_mainloop (gnu-pop3d.c) to + stop "differ in signedness" warning. Use type casting for + pointer target passing in pop3_daemon (gnu-pop3d.c) to + stop "differ in signedness" and "incompatible pointer + type" warnings. + +19/Jan/2000 + Release: version 0.7. + + Bug Fix: use temp_domain instead of virtualdomain + for preliminary inet_ntoa for IP_BASED_VIRTUAL. + + Code Cleanup: If has host name lookup problem for + IP_BASED_VIRTUAL then give error message and quit. + +18/Jan/2000 + Release: version 0.6. + + Bug Fix: not sure why it is a bug... but removed + virtualdomain++ in pop3_mainloop (gnu-pop3d.c); so + to start after the domain_delimiter, the temp_domain + is incremented. (Found this problem using gdb and mpr.) + +17/Jan/2000 + Code Cleanup: Added const char domain_delimiters + ";!:@". And loops through these. Uses strdup to allocate + virtualdomains, if needed. And free's it if created. + +12/Jan/2000 + Release: version 0.4. + + Code Cleanup: Ensure that ofile is non-null in pop3_abquit() + in extra.c so it does not attempt to write an error message + through the socket (Thanks to Jonathan Chin jonathan.chin @ + ox.compsoc.net). + + Bug Fix: Don't free virtualdomain in quit.c + (caused segmentation fault). Added #ifdef USE_VIRTUAL + before referencing virtualdomain in quit.c (didn't + compile when virtual support was not enabled -- but + not that this matters since it is commented out). + +9 Dec. 1999 + Release: version 0.3. + +30 Nov. 1999 + Feature: Added configure support --enable-virtual-domains + and --enable-ip-based-virtual (New configure.in and + configure). Added some debugging info. + + Bug Fix: Changed getsockname to use infile not sock. + Added check before freeing virtualdomain. + + Code cleanup: Remove line_no references from virtual.c. + + Portability: Changed how _PATH_MAILDIR and MAXNAMELEN is + configured (Thanks to Bill Sebok wls @ astro.umd.edu). + Now using chdir to go into virtual mail spool directory + (Thanks to Christian Roy roychri @ infiniweb.ca). + +24 Nov. 1999 + Feature: Added "IP_BASED_VIRTUAL" macro configuration. + Uses getsockname, inet_ntoa, gethostbyaddr. + + Portability: Changed type __uid_t to uid_t in virtual.c for + better BSD compatibility (Thanks to Ed Thomson + ethomson @ ravecomm.com). + + Code cleanup: Changed sprintf to snprintf in virtual.c. + +7 Oct. 1999 + Posted this first patch to gnu-pop3d-list. + +TO DO + +turn on APOP + +fix daemon child dieing problems + +add UIDL support + +socklen_t doesn t existe on solaris, it s size_t + +makefile: LIBS = -ldl -lpam -lsocket -lnsl, it s specific to solaris + +Seg faults when "fclose (lock)" if VIRTUAL_UID is wrong. But it still +deletes messages... who is gnu-pop3d really running as?? + +add "REALM" command like HTTP host command + +sending a SIGHUP (defaults to terminate process) to a +gnu-pop3d process kills it uncleanly (no logging and stale .lock file). +Does this matter? + +gcc -c -DHAVE_CONFIG_H -g -O3 -Wall -pedantic -ansi getopt.c +getopt.c: In function `_getopt_internal': +getopt.c:456: warning: implicit declaration of function `strncmp' + maybe in configure.in: +AC_CHECK_FUNC(getopt, [getopt=yes]) +if test x$getopt = "x"; then + CFLAGS="$CFLAGS -I./getopt" +fi + +if port already listening then let the admin know diff -uP gnu-pop3d-0.9.8/config.h.in PATCH-1.0/config.h.in --- gnu-pop3d-0.9.8/config.h.in Wed Sep 22 18:02:44 1999 +++ PATCH-1.0/config.h.in Thu May 18 22:53:58 2000 @@ -50,3 +50,10 @@ /* Define if you have the pam library (-lpam). */ #undef HAVE_LIBPAM + +/* Define if you want virtual domains support. */ +#undef USE_VIRTUAL + +/* Define if you want to use IP-based virtual domains support. */ +#undef IP_BASED_VIRTUAL + diff -uP gnu-pop3d-0.9.8/configure PATCH-1.0/configure --- gnu-pop3d-0.9.8/configure Wed Sep 22 18:02:44 1999 +++ PATCH-1.0/configure Thu May 18 22:53:59 2000 @@ -1,7 +1,7 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.12 +# Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation @@ -11,6 +11,10 @@ ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: +ac_help="$ac_help + --enable-virtual-domains enable virtual passwd files and spool directories." +ac_help="$ac_help + --enable-ip-based-virtual enable IP-based virtual passwd files and spool directories." # Initialize some variables set by options. # The variables have the same names as the options, with @@ -49,6 +53,7 @@ # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 @@ -332,7 +337,7 @@ verbose=yes ;; -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.12" + echo "configure generated by autoconf version 2.13" exit 0 ;; -with-* | --with-*) @@ -502,9 +507,11 @@ # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross +ac_exeext= +ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then @@ -519,19 +526,19 @@ - # 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:527: checking for $ac_word" >&5 +echo "configure:533: 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 if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="gcc" @@ -552,16 +559,17 @@ # 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:556: checking for $ac_word" >&5 +echo "configure:563: 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 if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no - for ac_dir in $PATH; do + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then @@ -596,25 +604,61 @@ echo "$ac_t""no" 1>&6 fi + if test -z "$CC"; then + case "`uname -s`" in + *win32* | *WIN32*) + # 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:614: 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 + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="cl" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + ;; + esac + fi test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:604: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:646: 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. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross -cat > conftest.$ac_ext < conftest.$ac_ext << EOF + +#line 657 "configure" #include "confdefs.h" + main(){return(0);} EOF -if { (eval echo configure:618: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:662: \"$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 @@ -628,18 +672,24 @@ ac_cv_prog_cc_works=no fi rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 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:638: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:688: 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:643: checking whether we are using GNU C" >&5 +echo "configure:693: 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 @@ -648,7 +698,7 @@ yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:652: \"$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:702: \"$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 @@ -659,11 +709,15 @@ if test $ac_cv_prog_gcc = yes; then GCC=yes - 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:667: checking whether ${CC-cc} accepts -g" >&5 +else + GCC= +fi + +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:721: 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 @@ -678,16 +732,20 @@ fi echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 - if test "$ac_test_CFLAGS" = set; then - CFLAGS="$ac_save_CFLAGS" - elif test $ac_cv_prog_cc_g = yes; then +if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then CFLAGS="-g -O2" else - CFLAGS="-O2" + CFLAGS="-g" fi else - GCC= - test "${CFLAGS+set}" = set || CFLAGS="-g" + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi fi ac_aux_dir= @@ -716,28 +774,30 @@ # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # 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:724: checking for a BSD compatible install" >&5 +echo "configure:783: 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 else - IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:" + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" for ac_dir in $PATH; do # Account for people who put trailing slashes in PATH elements. case "$ac_dir/" in /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. - for ac_prog in ginstall installbsd scoinst install; do + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. - # OSF/1 installbsd also uses dspmsg, but is usable. : else ac_cv_path_install="$ac_dir/$ac_prog -c" @@ -767,10 +827,12 @@ # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' + test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 -echo "configure:774: checking whether ln -s works" >&5 +echo "configure:836: checking whether ln -s works" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -792,7 +854,7 @@ echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:796: checking how to run the C preprocessor" >&5 +echo "configure:858: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -807,14 +869,14 @@ # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:817: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:879: \"$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 @@ -824,14 +886,31 @@ rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:896: \"$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 < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:834: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:913: \"$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 @@ -844,6 +923,8 @@ rm -f conftest* fi rm -f conftest* +fi +rm -f conftest* ac_cv_prog_CPP="$CPP" fi CPP="$ac_cv_prog_CPP" @@ -853,12 +934,12 @@ echo "$ac_t""$CPP" 1>&6 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:857: checking for ANSI C header files" >&5 +echo "configure:938: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -866,8 +947,8 @@ #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:870: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:951: \"$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* ac_cv_header_stdc=yes @@ -883,7 +964,7 @@ if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -901,7 +982,7 @@ if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -922,7 +1003,7 @@ : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -933,7 +1014,7 @@ exit (0); } EOF -if { (eval echo configure:937: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1018: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -957,12 +1038,12 @@ fi echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6 -echo "configure:961: checking for sys/wait.h that is POSIX.1 compatible" >&5 +echo "configure:1042: checking for sys/wait.h that is POSIX.1 compatible" >&5 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -978,7 +1059,7 @@ s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } EOF -if { (eval echo configure:982: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1063: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_sys_wait_h=yes else @@ -998,22 +1079,22 @@ fi -for ac_hdr in paths.h sys/file.h syslog.h unistd.h shadow.h security/pam_appl.h +for ac_hdr in fcntl.h limits.h paths.h sys/file.h sys/time.h syslog.h unistd.h shadow.h security/pam_appl.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1006: checking for $ac_hdr" >&5 +echo "configure:1087: 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 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1016: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:1097: \"$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" @@ -1039,28 +1120,23 @@ done -if test x"$ac_cv_header_security_pam_appl_h" = x"yes"; then - echo $ac_n "checking for pam_authenticate in -lpam""... $ac_c" 1>&6 -echo "configure:1045: checking for pam_authenticate in -lpam" >&5 -ac_lib_var=`echo pam'_'pam_authenticate | sed 'y%./+-%__p_%'` +echo $ac_n "checking for main in -lcrypt""... $ac_c" 1>&6 +echo "configure:1125: checking for main in -lcrypt" >&5 +ac_lib_var=`echo crypt'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" -LIBS="-lpam -ldl $LIBS" +LIBS="-lcrypt $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1140: \"$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 @@ -1075,92 +1151,41 @@ fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 - LIBS="$LIBS -ldl -lpam"; cat >> confdefs.h <<\EOF -#define HAVE_LIBPAM 1 + ac_tr_lib=HAVE_LIB`echo crypt | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 -fi - -else - for ac_func in crypt -do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1091: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -$ac_func(); -#endif - -; return 0; } -EOF -if { (eval echo configure:1119: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi + LIBS="-lcrypt $LIBS" -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <&6 fi -done - if test x"$ac_cv_func_crypt" = x"no"; then - echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6 -echo "configure:1145: checking for crypt in -lcrypt" >&5 -ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-%__p_%'` + +if test x"$ac_cv_header_security_pam_appl_h" = x"yes"; then + echo $ac_n "checking for pam_authenticate in -lpam""... $ac_c" 1>&6 +echo "configure:1170: checking for pam_authenticate in -lpam" >&5 +ac_lib_var=`echo pam'_'pam_authenticate | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" -LIBS="-lcrypt $LIBS" +LIBS="-lpam -ldl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1189: \"$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 @@ -1175,34 +1200,29 @@ fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 - ac_tr_lib=HAVE_LIB`echo crypt | sed -e 's/[^a-zA-Z0-9_]/_/g' \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` - cat >> confdefs.h <> confdefs.h <<\EOF +#define HAVE_LIBPAM 1 EOF - LIBS="-lcrypt $LIBS" - else echo "$ac_t""no" 1>&6 fi - fi fi echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:1195: checking for working const" >&5 +echo "configure:1215: 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 <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1269: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -1265,14 +1285,350 @@ fi +echo $ac_n "checking for size_t""... $ac_c" 1>&6 +echo "configure:1290: checking for size_t" >&5 +if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#if STDC_HEADERS +#include +#include +#endif +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_size_t=yes +else + rm -rf conftest* + ac_cv_type_size_t=no +fi +rm -f conftest* + +fi +echo "$ac_t""$ac_cv_type_size_t" 1>&6 +if test $ac_cv_type_size_t = no; then + cat >> confdefs.h <<\EOF +#define size_t unsigned +EOF + +fi + +echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 +echo "configure:1323: checking whether time.h and sys/time.h may both be included" >&5 +if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#include +int main() { +struct tm *tp; +; return 0; } +EOF +if { (eval echo configure:1337: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_header_time=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_time=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_header_time" 1>&6 +if test $ac_cv_header_time = yes; then + cat >> confdefs.h <<\EOF +#define TIME_WITH_SYS_TIME 1 +EOF + +fi + +echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6 +echo "configure:1358: checking for uid_t in sys/types.h" >&5 +if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "uid_t" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_uid_t=yes +else + rm -rf conftest* + ac_cv_type_uid_t=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_type_uid_t" 1>&6 +if test $ac_cv_type_uid_t = no; then + cat >> confdefs.h <<\EOF +#define uid_t int +EOF + + cat >> confdefs.h <<\EOF +#define gid_t int +EOF + +fi + + +# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works +# for constant arguments. Useless! +echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6 +echo "configure:1395: checking for working alloca.h" >&5 +if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +int main() { +void *p = alloca(2 * sizeof(int)); +; return 0; } +EOF +if { (eval echo configure:1407: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_header_alloca_h=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_alloca_h=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_header_alloca_h" 1>&6 +if test $ac_cv_header_alloca_h = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_ALLOCA_H 1 +EOF + +fi + +echo $ac_n "checking for alloca""... $ac_c" 1>&6 +echo "configure:1428: checking for alloca" >&5 +if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +# define alloca _alloca +# else +# if HAVE_ALLOCA_H +# include +# else +# ifdef _AIX + #pragma alloca +# else +# ifndef alloca /* predefined by HP cc +Olibcalls */ +char *alloca (); +# endif +# endif +# endif +# endif +#endif + +int main() { +char *p = (char *) alloca(1); +; return 0; } +EOF +if { (eval echo configure:1461: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_func_alloca_works=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_func_alloca_works=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_func_alloca_works" 1>&6 +if test $ac_cv_func_alloca_works = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_ALLOCA 1 +EOF + +fi + +if test $ac_cv_func_alloca_works = no; then + # The SVR3 libPW and SVR4 libucb both contain incompatible functions + # that cause trouble. Some versions do not even contain alloca or + # contain a buggy version. If you still want to use their alloca, + # use ar to extract alloca.o from them instead of compiling alloca.c. + ALLOCA=alloca.${ac_objext} + cat >> confdefs.h <<\EOF +#define C_ALLOCA 1 +EOF + + +echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 +echo "configure:1493: checking whether alloca needs Cray hooks" >&5 +if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <&5 | + egrep "webecray" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_os_cray=yes +else + rm -rf conftest* + ac_cv_os_cray=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_os_cray" 1>&6 +if test $ac_cv_os_cray = yes; then +for ac_func in _getb67 GETB67 getb67; do + echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1523: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1551: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <&6 +fi + +done +fi + +echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 +echo "configure:1578: checking stack direction for C alloca" >&5 +if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_c_stack_direction=0 +else + cat > conftest.$ac_ext < addr) ? 1 : -1; +} +main () +{ + exit (find_stack_direction() < 0); +} +EOF +if { (eval echo configure:1605: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_c_stack_direction=1 +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_c_stack_direction=-1 +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$ac_cv_c_stack_direction" 1>&6 +cat >> confdefs.h <&6 -echo "configure:1271: checking return type of signal handlers" >&5 +echo "configure:1627: checking return type of signal handlers" >&5 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1289,7 +1645,7 @@ int i; ; return 0; } EOF -if { (eval echo configure:1293: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1649: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_type_signal=void else @@ -1307,15 +1663,15 @@ EOF -for ac_func in socket +for ac_func in gethostname select socket strdup strerror strstr do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1314: checking for $ac_func" >&5 +echo "configure:1670: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1698: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1375,6 +1731,37 @@ #fi #fi +# Check whether --enable-virtual-domains or --disable-virtual-domains was given. +if test "${enable_virtual_domains+set}" = set; then + enableval="$enable_virtual_domains" + +echo "$ac_t""virtual domains enabled" 1>&6 +cat >> confdefs.h <<\EOF +#define USE_VIRTUAL 1 +EOF + + +fi + + +# Check whether --enable-ip-based-virtual or --disable-ip-based-virtual was given. +if test "${enable_ip_based_virtual+set}" = set; then + enableval="$enable_ip_based_virtual" + +echo "$ac_t""ip based virtual domains enabled" 1>&6 +cat >> confdefs.h <<\EOF +#define USE_VIRTUAL 1 +EOF + +cat >> confdefs.h <<\EOF +#define IP_BASED_VIRTUAL 1 +EOF + + +fi + + + trap '' 1 2 15 cat > confcache <<\EOF # This file is a shell script that caches the results of configure @@ -1398,7 +1785,7 @@ # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | - case `(ac_space=' '; set) 2>&1` in + case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). @@ -1465,7 +1852,7 @@ echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.12" + echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; @@ -1485,9 +1872,11 @@ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF $ac_vpsub $extrasub +s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g s%@LIBS@%$LIBS%g @@ -1508,9 +1897,11 @@ s%@mandir@%$mandir%g s%@CC@%$CC%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g s%@INSTALL_DATA@%$INSTALL_DATA%g s%@LN_S@%$LN_S%g s%@CPP@%$CPP%g +s%@ALLOCA@%$ALLOCA%g CEOF EOF diff -uP gnu-pop3d-0.9.8/configure.in PATCH-1.0/configure.in --- gnu-pop3d-0.9.8/configure.in Wed Sep 22 18:02:44 1999 +++ PATCH-1.0/configure.in Thu May 18 22:53:59 2000 @@ -1,6 +1,5 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(gnu-pop3d.c) -AC_CONFIG_HEADER(config.h) dnl Checks for programs. AC_PROG_CC @@ -10,24 +9,27 @@ dnl Checks for header files. AC_HEADER_STDC AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS(paths.h sys/file.h syslog.h unistd.h shadow.h security/pam_appl.h) +AC_CHECK_HEADERS(fcntl.h limits.h paths.h sys/file.h sys/time.h syslog.h unistd.h shadow.h security/pam_appl.h) + +dnl Checks for libraries. +dnl Replace `main' with a function in -lcrypt: +AC_CHECK_LIB(crypt, main) -dnl Checks for libraries if test x"$ac_cv_header_security_pam_appl_h" = x"yes"; then - AC_CHECK_LIB(pam, pam_authenticate, [LIBS="$LIBS -ldl -lpam"; AC_DEFINE(HAVE_LIBPAM)],, -ldl) -else - AC_CHECK_FUNCS(crypt) - if test x"$ac_cv_func_crypt" = x"no"; then - AC_CHECK_LIB(crypt, crypt) - fi + AC_CHECK_LIB(pam, pam_authenticate, + [LIBS="$LIBS -ldl -lpam"; AC_DEFINE(HAVE_LIBPAM)],, -ldl) fi dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST +AC_TYPE_SIZE_T +AC_HEADER_TIME +AC_TYPE_UID_T dnl Checks for library functions. +AC_FUNC_ALLOCA AC_TYPE_SIGNAL -AC_CHECK_FUNCS(socket) +AC_CHECK_FUNCS(gethostname select socket strdup strerror strstr) #dnl Checks for system services #AC_ARG_ENABLE(maildir, [ --disable-maildir disable home directory mail spools],,) @@ -41,4 +43,20 @@ #fi #fi +AC_ARG_ENABLE(virtual-domains, +[ --enable-virtual-domains enable virtual passwd files and spool directories.], +[ +AC_MSG_RESULT(virtual domains enabled) +AC_DEFINE(USE_VIRTUAL) +],) + +AC_ARG_ENABLE(ip-based-virtual, +[ --enable-ip-based-virtual enable IP-based virtual passwd files and spool directories.], +[ +AC_MSG_RESULT(ip based virtual domains enabled) +AC_DEFINE(USE_VIRTUAL) +AC_DEFINE(IP_BASED_VIRTUAL) +],) + +AC_CONFIG_HEADER(config.h) AC_OUTPUT(Makefile) Only in gnu-pop3d-0.9.8/: debian diff -uP gnu-pop3d-0.9.8/extra.c PATCH-1.0/extra.c --- gnu-pop3d-0.9.8/extra.c Wed Sep 22 18:02:43 1999 +++ PATCH-1.0/extra.c Wed Dec 20 14:36:26 2000 @@ -103,29 +103,45 @@ fclose (mbox); free (messages); +/* Jonathan Chin + Ensure that ofile is non-null so following routine will + not attempt to write an error message through the socket. +*/ + switch (reason) { case ERR_NO_MEM: - fprintf (ofile, "-ERR Out of memory, quitting\r\n"); + if (NULL != ofile ) + fprintf (ofile, "-ERR Out of memory, quitting\r\n"); syslog (LOG_ERR, "Out of memory"); break; case ERR_DEAD_SOCK: - fprintf (ofile, "-ERR Socket closed, quitting\r\n"); + if (NULL != ofile ) + fprintf (ofile, "-ERR Socket closed, quitting\r\n"); syslog (LOG_ERR, "Socket closed"); break; case ERR_SIGNAL: - fprintf (ofile, "-ERR Quitting on signal\r\n"); - syslog (LOG_ERR, "Quitting on signal"); + if (NULL != ofile ) + fprintf (ofile, "-ERR Quitting on signal\r\n"); break; case ERR_TIMEOUT: - fprintf (ofile, "-ERR Session timed out\r\n"); + if (NULL != ofile ) + fprintf (ofile, "-ERR Session timed out\r\n"); if (state == TRANSACTION) syslog (LOG_INFO, "Session timed out for user: %s", username); else syslog (LOG_INFO, "Session timed out for no user"); break; +#ifdef IP_BASED_VIRTUAL + case ERR_IP_BASED: + if (NULL != ofile ) + fprintf (ofile, "-ERR Quitting - host name not found\r\n"); + syslog (LOG_ERR, "Quitting - host name not found"); + break; +#endif /* IP_BASED_VIRTUAL */ default: - fprintf (ofile, "-ERR Quitting (reason unknown)\r\n"); + if (NULL != ofile ) + fprintf (ofile, "-ERR Quitting (reason unknown)\r\n"); syslog (LOG_ERR, "Unknown quit"); break; } @@ -270,8 +286,10 @@ while (waitpid (-1, &stat, WNOHANG) > 0); return; } - else + else { + syslog (LOG_ERR, "Quitting on signal: %d", signal); pop3_abquit (ERR_SIGNAL); + } } /* Gets a line of input from the client */ diff -uP gnu-pop3d-0.9.8/gnu-pop3d.c PATCH-1.0/gnu-pop3d.c --- gnu-pop3d-0.9.8/gnu-pop3d.c Wed Sep 22 18:02:43 1999 +++ PATCH-1.0/gnu-pop3d.c Thu Jun 22 11:47:03 2000 @@ -62,7 +62,10 @@ signal (SIGFPE, pop3_signal); signal (SIGSEGV, pop3_signal); signal (SIGTERM, pop3_signal); - signal (SIGSTOP, pop3_signal); + +/* Don't die when a process goes away unexpectedly. + Ignore write on a pipe with no reader. */ + signal (SIGPIPE, SIG_IGN); while ((c = getopt_long (argc, argv, "d::hip:t:v", long_options, &option_index)) && c != -1) { @@ -160,6 +163,16 @@ char *buf, *arg, *cmd; struct hostent *htbuf; char *local_hostname; +#ifdef USE_VIRTUAL + char *temp_domain; + const char domain_delimiters[] = ";!:@"; + int i; +#endif +#ifdef IP_BASED_VIRTUAL + struct sockaddr_in name; + int namelen = sizeof(name); + struct hostent *hostent_info; +#endif ifile = infile; ofile = fdopen (outfile, "w+"); @@ -195,6 +208,10 @@ fflush (ofile); fprintf (ofile, "+OK POP3 " WELCOME " %s\r\n", md5shared); +#ifdef USE_VIRTUAL + virtualdomain = NULL; +#endif + while (state != UPDATE) { fflush (ofile); @@ -203,12 +220,87 @@ cmd = pop3_cmd (buf); arg = pop3_args (buf); +/* syslog (LOG_ERR, "cmd: %s %s\n", cmd, arg); */ + if (strlen (arg) > POP_MAXCMDLEN || strlen (cmd) > POP_MAXCMDLEN) status = ERR_TOO_LONG; else if (strlen (cmd) > 4) status = ERR_BAD_CMD; else if (strncasecmp (cmd, "USER", 4) == 0) + { + +#ifdef USE_VIRTUAL + /* Some mail clients pre-parse out the username before sending */ + /* so allow colon or at-sign to separate username and domain name */ + + for (i = strlen(domain_delimiters) - 1; i >= 0; i--) + { + temp_domain = strchr(arg, domain_delimiters[i]); + if (temp_domain) + { + temp_domain++; +/* virtualdomain = malloc (MAXHOSTNAMELEN + 1); */ +/* strncpy (virtualdomain, (temp_domain + 1), MAXHOSTNAMELEN); */ + virtualdomain = strdup (temp_domain); +/* virtualdomain++; */ + arg = strtok(arg, domain_delimiters); + break; + } + } + +/* placing domain name in USER command overrides IP_BASED_VIRTUAL */ + +#ifdef IP_BASED_VIRTUAL + if (virtualdomain == NULL) + { +/* int getsockname __P((int, struct sockaddr *, socklen_t *)); +*/ + if (getsockname(infile, + (struct sockaddr *)&name, (socklen_t *)&namelen)<0) + { + pop3_abquit (ERR_IP_BASED); +/* syslog(LOG_ERR,"getsockname: %m"); */ + } + if (!(temp_domain = (char *) inet_ntoa(name.sin_addr))) + { + pop3_abquit (ERR_IP_BASED); +/* syslog(LOG_ERR,"inet_ntoa failed: %m"); */ + } + +/* syslog(LOG_INFO,"Connection to %s", temp_domain); */ + +/* jeremy reed: I read: + Attention: Do not use the gethostbyaddr subroutine + in a multithreaded environment. + what does this mean? */ + + if ((hostent_info = gethostbyaddr ((char *)&name.sin_addr,4,AF_INET)) + != NULL ) + { + virtualdomain = malloc (MAXHOSTNAMELEN + 1); + if (virtualdomain == NULL) + pop3_abquit (ERR_NO_MEM); + strcpy (virtualdomain, hostent_info -> h_name); +/* syslog (LOG_INFO, "hostname: %s", virtualdomain); */ + } + else + { + pop3_abquit (ERR_IP_BASED); +/* syslog(LOG_ERR, "gethostbyaddr failure %d for %s\n", + h_errno, temp_domain); */ + } + } +#endif /* IP_BASED_VIRTUAL */ + status = pop3_user (arg, virtualdomain); + if (virtualdomain) { + free (virtualdomain); + virtualdomain = NULL; + } +#else status = pop3_user (arg); +#endif /* USE_VIRTUAL */ + + } else if (strncasecmp (cmd, "QUIT", 4) == 0) status = pop3_quit (arg); else if (strncasecmp (cmd, "APOP", 4) == 0) @@ -300,7 +392,9 @@ { if (!fork ()) { - sock2 = accept (sock, &client, &socksize); +/* int accept __P((int, struct sockaddr *, socklen_t *)); */ + sock2 = accept (sock, (struct sockaddr *)&client, + (socklen_t *)&socksize); pop3_mainloop (sock2, sock2); close (sock2); exit (OK); diff -uP gnu-pop3d-0.9.8/gnu-pop3d.h PATCH-1.0/gnu-pop3d.h --- gnu-pop3d-0.9.8/gnu-pop3d.h Wed Sep 22 18:02:43 1999 +++ PATCH-1.0/gnu-pop3d.h Wed Dec 20 16:31:50 2000 @@ -20,7 +20,7 @@ #include "config.h" /* The version */ -#define VERSION "0.9.8" +#define VERSION "0.9.8 virtual 1.0" /* The implementation */ #define IMPL "GNU POP3" @@ -61,12 +61,25 @@ /* Size of the MD5 digest for APOP */ #define APOP_DIGEST 70 -/* Maximum length of a hostname (is this defined somewhere else?) */ -#define MAXHOSTNAMELEN 64 - /* Longest legal POP command */ #define POP_MAXCMDLEN 255 +#ifdef USE_VIRTUAL + +/* Define UID for using for manipulating mailboxes of virtual users. + The mailboxes for virtual domains do not have corresponding Unix + accounts; they do not have unique UIDs; so they could be owned + by one VIRTUAL_UID. */ +#define VIRTUAL_UID 8 + +/* path to virtual mailboxes which have a domain name or realm name + as a sub-directory */ +#define VIRTUAL_MAILDIR "/var/spool/virtual" + +#define PATH_TO_PASSWORDS "/etc/virtual" + +#endif /* USE_VIRTUAL */ + #define _GNU_SOURCE #include #include @@ -84,6 +97,7 @@ #include #include #include +#include #include #include #include @@ -92,16 +106,30 @@ #include "md5.h" #include "getopt.h" +/* Maximum length of a hostname (is this defined somewhere else?) */ +#ifndef MAXHOSTNAMELEN +#define MAXHOSTNAMELEN 64 +#endif + /* For Berkley DB2 APOP password file */ #ifdef BDB2 #include #endif /* The path to the mail spool files */ +/* first pull in paths.h if available */ #ifdef HAVE_PATHS_H #include -#else -#define _PATH_MAILDIR "/usr/spool/mail" +#endif + +/* then define _PATH_MAILDIR if not already defined */ +#ifndef _PATH_MAILDIR +/* (WLS) This is a quick hack which really should be done by autoconf */ +# ifdef __SVR4 +# define _PATH_MAILDIR "/var/mail" +# else +# define _PATH_MAILDIR "/usr/spool/mail" +# endif #endif #ifdef HAVE_SECURITY_PAM_APPL_H @@ -135,6 +163,10 @@ #define ERR_NO_OFILE 13 #define ERR_TIMEOUT 14 +#ifdef IP_BASED_VIRTUAL +#define ERR_IP_BASED 23 +#endif /* IP_BASED_VIRTUAL */ + typedef struct _pop3_message { unsigned int size; @@ -152,6 +184,9 @@ char *mailbox; char *lockfile; char *username; +#ifdef USE_VIRTUAL +char *virtualdomain; +#endif FILE *mbox; FILE *lock; int ifile; @@ -168,7 +203,12 @@ int pop3_stat (const char *arg); int pop3_top (const char *arg); int pop3_uidl (const char *arg); +#ifdef USE_VIRTUAL +struct passwd *getvirtualpwnam (const char *username, const char *domainname); +int pop3_user (const char *arg, const char *domainname); +#else int pop3_user (const char *arg); +#endif int pop3_apop (const char *arg); int pop3_auth (const char *arg); int pop3_capa (const char *arg); diff -uP gnu-pop3d-0.9.8/quit.c PATCH-1.0/quit.c --- gnu-pop3d-0.9.8/quit.c Wed Sep 22 18:02:43 1999 +++ PATCH-1.0/quit.c Thu May 18 22:53:59 2000 @@ -81,7 +81,6 @@ free (username); free (mailbox); free (md5shared); - fprintf (ofile, "+OK\r\n"); return OK; } diff -uP gnu-pop3d-0.9.8/user.c PATCH-1.0/user.c --- gnu-pop3d-0.9.8/user.c Wed Sep 22 18:02:43 1999 +++ PATCH-1.0/user.c Wed Dec 20 14:10:21 2000 @@ -75,15 +75,20 @@ the user name and password. Calls setuid() upon successful verification, otherwise it will (likely) return ERR_BAD_LOGIN */ +#ifdef USE_VIRTUAL +int +pop3_user (const char *arg, const char *domainname) +#else int pop3_user (const char *arg) +#endif { char *buf, pass[POP_MAXCMDLEN], *tmp, *cmd; #ifdef HAVE_SECURITY_PAM_APPL_H pam_handle_t *pamh; int pamerror; #endif /* !HAVE_SECURITY_PAM_APPL_H */ - struct passwd *pw; + struct passwd *pw = NULL; if (state != AUTHORIZATION) return ERR_WRONG_STATE; @@ -129,16 +134,36 @@ return ERR_BAD_LOGIN; } free (tmp); -#endif +#endif /* APOP support */ - pw = getpwnam (arg); -#ifndef HAVE_SECURITY_PAM_APPL_H - if (pw == NULL) - return ERR_BAD_LOGIN; - if (pw->pw_uid < 1) - return ERR_BAD_LOGIN; - if (strcmp (pw->pw_passwd, crypt (pass, pw->pw_passwd))) +#ifdef USE_VIRTUAL +/* uses regular crypt and not PAM for virtual domains authentication */ + +/* syslog (LOG_INFO, "user %s AT %s trying to log in", arg, domainname); */ + + if (domainname) + { + pw = getvirtualpwnam (arg, domainname); + + if (pw == NULL) + return ERR_BAD_LOGIN; + if (pw->pw_uid < 1) + return ERR_BAD_LOGIN; + if (strcmp (pw->pw_passwd, crypt (pass, pw->pw_passwd))) + return ERR_BAD_LOGIN; + } + else /* no domain part so revert to normal */ { +#endif /* USE_VIRTUAL */ + pw = getpwnam (arg); + +#ifndef HAVE_SECURITY_PAM_APPL_H + if (pw == NULL) + return ERR_BAD_LOGIN; + if (pw->pw_uid < 1) + return ERR_BAD_LOGIN; + if (strcmp (pw->pw_passwd, crypt (pass, pw->pw_passwd))) + { #ifdef HAVE_SHADOW_H struct spwd *spw; spw = getspnam (arg); @@ -148,7 +173,8 @@ #endif /* HAVE_SHADOW_H */ return ERR_BAD_LOGIN; } -#else /* HAVE_SECURITY_MAP_APPL_H */ + +#else /* HAVE_SECURITY_PAM_APPL_H */ _user = (char *) arg; _pwd = pass; /* libpam doesn't log to LOG_MAIL */ @@ -165,9 +191,15 @@ openlog ("gnu-pop3d", LOG_PID, LOG_MAIL); #endif /* HAVE_SECURITY_PAM_APPL_H */ +#ifdef USE_VIRTUAL + } /* has no domain part */ +#endif /* USE_VIRTUAL */ + if (pw != NULL && pw->pw_uid > 1) setuid (pw->pw_uid); +/* syslog (LOG_INFO, "uid %d", pw->pw_uid); */ + #ifdef MAILSPOOLHOME mailbox = malloc ((strlen (pw->pw_dir) + strlen (MAILSPOOLHOME) + 1) * sizeof (char)); @@ -175,13 +207,32 @@ pop3_abquit (ERR_NO_MEM); strcpy (mailbox, pw->pw_dir); strcat (mailbox, MAILSPOOLHOME); + mbox = fopen (mailbox, "r"); if (mbox == NULL) { free (mailbox); chdir (_PATH_MAILDIR); #endif /* MAILSPOOLHOME */ - mailbox = strdup (arg); + +#ifdef USE_VIRTUAL + if (domainname) + { + mailbox = malloc ((strlen (arg) + + strlen (VIRTUAL_MAILDIR) + strlen (domainname) + 2) + * sizeof (char)); + if (mailbox == NULL) + pop3_abquit (ERR_NO_MEM); + strcpy (mailbox, VIRTUAL_MAILDIR); + strcat (mailbox, "/"); + strcat (mailbox, domainname); + strcat (mailbox, "/"); + chdir (mailbox); + free (mailbox); + } +#endif + mailbox = strdup (arg); + if (mailbox == NULL) pop3_abquit (ERR_NO_MEM); mbox = fopen (mailbox, "r"); @@ -213,8 +264,17 @@ messages = NULL; pop3_getsizes (); fprintf (ofile, "+OK opened mailbox for %s\r\n", username); - syslog (LOG_INFO, "User '%s' logged in with mailbox '%s'", username, +#ifdef USE_VIRTUAL + if (domainname) + { + syslog (LOG_INFO, "User '%s' of '%s' logged in with mailbox '%s'", + username, domainname, mailbox); + } + else +#endif + syslog (LOG_INFO, "User '%s' logged in with mailbox '%s'", username, mailbox); + cursor = 0; return OK; } @@ -224,6 +284,7 @@ return pop3_quit (pass); } + free (pw); free (cmd); return ERR_BAD_LOGIN; } diff -uP gnu-pop3d-0.9.8/virtual.c PATCH-1.0/virtual.c --- gnu-pop3d-0.9.8/virtual.c Wed Dec 31 16:00:00 1969 +++ PATCH-1.0/virtual.c Wed Dec 20 15:10:25 2000 @@ -0,0 +1,66 @@ +/* read the README.virtual for more info on using the +* virtual patch for gnu-pop3d */ + +#include "gnu-pop3d.h" + +#ifdef USE_VIRTUAL + +#ifndef PATH_TO_PASSWORDS +#define PATH_TO_PASSWORDS "/etc/virtual" +#endif + +struct passwd * +getvirtualpwnam (const char *username, const char *domainname) + +{ + FILE *passwdfd; + char buffer[256]; + uid_t virtual_uid = VIRTUAL_UID; + struct passwd *pwdentry = NULL; + + if ( + ((pwdentry = (struct passwd *) malloc(sizeof (struct passwd))) == NULL) || + ((pwdentry->pw_name = (char *) malloc (256)) == NULL) || + ((pwdentry->pw_passwd = (char *) malloc (256)) == NULL) + ) + { + /* fprintf (stderr, "Couldn't allocate memory for password check\n"); */ + return (0); + } + + snprintf (buffer, 256, "%s/%s/passwd", PATH_TO_PASSWORDS, domainname ); + + if ((passwdfd = fopen (buffer, "r")) == (FILE *) NULL) + { + /* fprintf (stderr, "Couldn't open password file: %s\n", buffer); */ + return (0); + } + + while (fgets (buffer, sizeof (buffer), passwdfd) != (char *) NULL) + { + + /* skip comments, blank lines */ + if (*buffer == '#' || *buffer == '\n' || *buffer == '\0') + { + continue; + } + + if (sscanf (buffer, "%[^:]:%s", + pwdentry->pw_name, pwdentry->pw_passwd) != 2) + { + /* fprintf (stderr, "%s: Trouble parsing passwd file\n", buffer); */ + return (0); + } + + pwdentry->pw_uid = virtual_uid; + + if (strcmp (pwdentry->pw_name, username) == 0) + { + return pwdentry; + } + } + return (0); +} + +#endif /* USE_VIRTUAL */ +