diff -ur nwebmail-0.1.77/Makefile nwebmail-sgp/Makefile --- nwebmail-0.1.77/Makefile Fri Nov 24 22:03:30 2000 +++ nwebmail-sgp/Makefile Fri Apr 6 16:01:48 2001 @@ -17,7 +17,7 @@ login_validate: login_validate.cpp $(CC) $(CFLAGS) -o login_validate login_validate.cpp -lcrypt -nwebmail: main.o environment.o headers.o parse_form.o \ +nwebmail: kandrgetline.o main.o environment.o headers.o parse_form.o \ login_authenticate.o session.o \ login_page.o inbox_page.o logout_page.o err_page.o \ parse_mail_headers.o view_message.o mail_process.o \ @@ -27,7 +27,7 @@ random.o custom_string.o addr.o import_addr_page.o \ do_import_addr.o conv_csv.o conv_ldif.o export_addr.o \ edit_pref_page.o action.o - $(CC) $(CFLAGS) -o nwebmail main.o environment.o headers.o \ + $(CC) $(CFLAGS) -o nwebmail kandrgetline.o main.o environment.o headers.o \ parse_form.o login_authenticate.o session.o \ login_page.o inbox_page.o logout_page.o err_page.o \ parse_mail_headers.o view_message.o mail_process.o \ @@ -37,6 +37,9 @@ random.o custom_string.o addr.o import_addr_page.o \ do_import_addr.o conv_csv.o conv_ldif.o export_addr.o \ edit_pref_page.o action.o + +kandrgetline.o: kandrgetline.c + $(CC) $(CFLAGS) -c kandrgetline.c main.o: main.cpp $(CC) $(CFLAGS) -c main.cpp Only in nwebmail-sgp: cgi.sh diff -ur nwebmail-0.1.77/compose_message_page.cpp nwebmail-sgp/compose_message_page.cpp --- nwebmail-0.1.77/compose_message_page.cpp Fri Nov 24 21:56:03 2000 +++ nwebmail-sgp/compose_message_page.cpp Fri Apr 6 15:56:25 2001 @@ -22,6 +22,7 @@ #include "encoding_conv.h" #include "config.h" #include "preferences.h" +#include "header.h" int compose_message_header(void); int compose_message_form(mail_header*, FILE*); diff -ur nwebmail-0.1.77/config.h nwebmail-sgp/config.h --- nwebmail-0.1.77/config.h Fri Nov 24 21:55:22 2000 +++ nwebmail-sgp/config.h Fri Apr 6 16:15:53 2001 @@ -40,8 +40,8 @@ -#define SENDMAIL "/usr/sbin/sendmail" -#define MAILSPOOLDIR "/var/spool/mail" +#define SENDMAIL "/usr/lib/sendmail" +#define MAILSPOOLDIR "/var/mail" #define LOCALSTATEDIR "/var/nwebmail" diff -ur nwebmail-0.1.77/conv_csv.cpp nwebmail-sgp/conv_csv.cpp --- nwebmail-0.1.77/conv_csv.cpp Mon Sep 4 17:09:19 2000 +++ nwebmail-sgp/conv_csv.cpp Fri Apr 6 15:56:32 2001 @@ -12,6 +12,7 @@ #include "custom_string.h" #include "addr.h" +#include "header.h" int parse_csv_header(FILE*, int*, int*, int*, int*); diff -ur nwebmail-0.1.77/conv_ldif.cpp nwebmail-sgp/conv_ldif.cpp --- nwebmail-0.1.77/conv_ldif.cpp Mon Sep 4 00:53:34 2000 +++ nwebmail-sgp/conv_ldif.cpp Fri Apr 6 15:56:35 2001 @@ -12,6 +12,7 @@ #include "addr.h" #include "custom_string.h" +#include "header.h" int get_ldif_entry(FILE*, char**, char**); diff -ur nwebmail-0.1.77/edit_pref_page.cpp nwebmail-sgp/edit_pref_page.cpp --- nwebmail-0.1.77/edit_pref_page.cpp Mon Nov 13 05:37:40 2000 +++ nwebmail-sgp/edit_pref_page.cpp Fri Apr 6 10:34:59 2001 @@ -206,7 +206,6 @@ return(-1); } - name=eliminate_lwsp(name); email=eliminate_lwsp(email); @@ -217,11 +216,12 @@ return(1); } - - if(name != NULL) - asprintf(address,"\"%s\" <%s>",name,email); +*address=(char*)malloc(100); + if(name != NULL) { + sprintf(*address, "\"%s\" <%s>", name, email); + } else - asprintf(address,"\"\" <%s>",email); + sprintf(*address,"\"\" <%s>",email); if(name != NULL) { Only in nwebmail-sgp: header.h diff -ur nwebmail-0.1.77/install.sh nwebmail-sgp/install.sh --- nwebmail-0.1.77/install.sh Fri Nov 24 22:00:59 2000 +++ nwebmail-sgp/install.sh Fri Apr 6 17:33:00 2001 @@ -1,37 +1,35 @@ -#!/bin/bash +#!/bin/sh # # This is the install script. # # If you are looking for a place to configure the installation directories, # check 'config.h' - -LOCALSTATEDIR=$(grep LOCALSTATEDIR config.h | awk -F \" '{ print $2 }') -PREFDIR=$(grep PREFDIR config.h | awk -F \" '{ print $2 }') -LOCKDIR=$(grep LOCKDIR config.h | awk -F \" '{ print $2 }') -TMPDIR=$(grep TMPDIR config.h | awk -F \" '{ print $2 }') - -SBINDIR=$(grep SBINDIR config.h | awk -F \" '{ print $2 }') -HTTPROOT=$(grep HTTPROOT config.h | awk -F \" '{ print $2 }') -CGIBIN=$(grep CGIBIN config.h | awk -F \" '{ print $2 }') -NWMHTTP=${HTTPROOT}$(grep NWMHTTP config.h | awk -F \" '{ print $2 }') +LOCALSTATEDIR=`grep LOCALSTATEDIR config.h|tail -1|cut -d\" -f2` +PREFDIR=`grep PREFDIR config.h|tail -1|cut -d\" -f2` +LOCKDIR=`grep LOCKDIR config.h|tail -1|cut -d\" -f2` +TMPDIR=`grep TMPDIR config.h|tail -1|cut -d\" -f2` +SBINDIR=`grep SBINDIR config.h|tail -1|cut -d\" -f2` +HTTPROOT=`grep HTTPROOT config.h|tail -1|cut -d\" -f2` +CGIBIN=`grep CGIBIN config.h|tail -1|cut -d\" -f2` +NWMHTTP=${HTTPROOT}`grep NWMHTTP config.h|tail -1|cut -d\" -f2` #create directories if [ ! -d $LOCALSTATEDIR ]; then - install -d -o mail -g mail -m 500 $LOCALSTATEDIR + install -d -u mail -g mail -m 500 $LOCALSTATEDIR fi if [ ! -d $PREFDIR ]; then - install -d -o mail -g mail -m 700 $PREFDIR + install -d -u mail -g mail -m 700 $PREFDIR fi if [ ! -d $LOCKDIR ]; then - install -d -o mail -g mail -m 700 $LOCKDIR + install -d -u mail -g mail -m 700 $LOCKDIR fi if [ ! -d $TMPDIR ]; then - install -d -o mail -g mail -m 700 $TMPDIR + install -d -u mail -g mail -m 700 $TMPDIR fi @@ -44,7 +42,7 @@ if [ ! -d $NWMHTTP ]; then install -d -o nobody -g nobody -m 555 $NWMHTTP - cp -a images/* $NWMHTTP + cp -R images/* $NWMHTTP fi @@ -54,15 +52,20 @@ fi #install nwebmail binary -install -o mail -g mail -s -m 6555 nwebmail $CGIBIN +#install -o mail -g mail -s -m 6555 nwebmail $CGIBIN +cp nwebmail ${CGIBIN} +chown apache:mail ${CGIBIN}/nwebmail +chmod 6555 ${CGIBIN}/nwebmail #install login_validate binary -install -o root -g root -m 4555 login_validate $SBINDIR +#install -o root -g root -m 4555 login_validate $SBINDIR +cp login_validate ${SBINDIR} +chown root:root ${SBINDIR}/login_validate +chmod 4555 ${SBINDIR}/login_validate if [ ! -f $PREFDIR/default ]; then echo "hostname=$(hostname)" > $PREFDIR/default - chown mail.mail $PREFDIR/default + chown apache:mail $PREFDIR/default chmod 600 $PREFDIR/default fi - Only in nwebmail-sgp: kandrgetline.c diff -ur nwebmail-0.1.77/login_authenticate.cpp nwebmail-sgp/login_authenticate.cpp --- nwebmail-0.1.77/login_authenticate.cpp Mon Nov 13 02:55:28 2000 +++ nwebmail-sgp/login_authenticate.cpp Fri Apr 6 16:03:42 2001 @@ -74,7 +74,6 @@ syslog(LOG_MAIL | LOG_ERR,"invalid CGI header during initial login"); return(-1); } - return(create_session(password)); } diff -ur nwebmail-0.1.77/login_validate.cpp nwebmail-sgp/login_validate.cpp --- nwebmail-0.1.77/login_validate.cpp Mon Sep 4 23:49:58 2000 +++ nwebmail-sgp/login_validate.cpp Fri Apr 6 16:04:17 2001 @@ -11,6 +11,8 @@ #include #include #include +#include + int destroy_str(char*); int get_stdin(char*); @@ -54,7 +56,7 @@ return(-1); } - crypto=crypt(password,login_info->sp_pwdp); + crypto=(char*)crypt(password,login_info->sp_pwdp); destroy_str(password); diff -ur nwebmail-0.1.77/mail_process.cpp nwebmail-sgp/mail_process.cpp --- nwebmail-0.1.77/mail_process.cpp Tue Oct 31 04:51:03 2000 +++ nwebmail-sgp/mail_process.cpp Fri Apr 6 16:04:51 2001 @@ -21,6 +21,7 @@ #include "main.h" #include "config.h" #include "custom_string.h" +#include "header.h" int buffer_allocate(size_t, size_t, size_t*, void**); int free_buffers(void**); diff -ur nwebmail-0.1.77/main.cpp nwebmail-sgp/main.cpp --- nwebmail-0.1.77/main.cpp Fri Nov 24 22:07:21 2000 +++ nwebmail-sgp/main.cpp Fri Apr 6 10:35:06 2001 @@ -135,6 +135,7 @@ err=login_authenticate(); + if(err != 0) { if(err == 1) @@ -150,7 +151,6 @@ return(EXIT_FAILURE); } - get_user_pref(); parse_action(mail_action); diff -ur nwebmail-0.1.77/parse_form.cpp nwebmail-sgp/parse_form.cpp --- nwebmail-0.1.77/parse_form.cpp Sat Nov 18 15:27:16 2000 +++ nwebmail-sgp/parse_form.cpp Fri Apr 6 16:05:12 2001 @@ -17,6 +17,7 @@ #include "environment.h" #include "custom_string.h" #include "config.h" +#include "header.h" int acquire_post_data(cgi_t*); @@ -34,6 +35,66 @@ cgi_t* cgi_ptr=NULL; int cgi_ptr_size=0; int cgi_next_read=0; + + + +/* Read up to (and including) a TERMINATOR from STREAM into *LINEPTR + (and null-terminate it). *LINEPTR is a pointer returned from malloc (or + NULL), pointing to *N characters of space. It is realloc'd as + necessary. Returns the number of characters read (not including the + null delimiter), or -1 on error or EOF. */ +ssize_t getdelim(char **linebuf, size_t *linebufsz, int delimiter, FILE *file) +{ + static const int GROWBY = 80; /* how large we will grow strings by */ + + int ch; + int idx = 0; + + if ((file == NULL || linebuf==NULL || *linebuf == NULL || *linebufsz == 0) + && !(*linebuf == NULL && *linebufsz ==0 )) { + errno=EINVAL; + return -1; + } + + if (*linebuf == NULL && *linebufsz == 0){ + (char**)*linebuf = malloc(GROWBY); + if (!*linebuf) { + errno=ENOMEM; + return -1; + } + *linebufsz += GROWBY; + } + + while (1) { + ch = fgetc(file); + if (ch == EOF) + break; + /* grow the line buffer as necessary */ + while (idx > *linebufsz-2) { + (char**)*linebuf = realloc(*linebuf, *linebufsz += GROWBY); + if (!*linebuf) { + errno=ENOMEM; + return -1; + } + } + (*linebuf)[idx++] = (char)ch; + if ((char)ch == delimiter) + break; + } + + if (idx != 0) + (*linebuf)[idx] = 0; + else if ( ch == EOF ) + return -1; + return idx; +} + + +int getline(char **s, unsigned int *lim, FILE *stream) +{ + return getdelim(s, lim, '\n', stream); +} + //////////////////////////////////////////////////////////////////////////// // This will sort out the cgi name/value pairs. They are saved in an array diff -ur nwebmail-0.1.77/parse_mail_headers.cpp nwebmail-sgp/parse_mail_headers.cpp --- nwebmail-0.1.77/parse_mail_headers.cpp Tue Oct 31 05:08:43 2000 +++ nwebmail-sgp/parse_mail_headers.cpp Fri Apr 6 15:57:05 2001 @@ -21,6 +21,7 @@ #include "view_message.h" #include "encoding_conv.h" #include "custom_string.h" +#include "header.h" char* get_head_data(FILE*, char**, size_t*); time_t compute_time(char*); diff -ur nwebmail-0.1.77/preferences.cpp nwebmail-sgp/preferences.cpp --- nwebmail-0.1.77/preferences.cpp Tue Oct 31 05:20:44 2000 +++ nwebmail-sgp/preferences.cpp Fri Apr 6 16:10:40 2001 @@ -18,6 +18,7 @@ #include "addr.h" #include "custom_string.h" #include "session.h" +#include "header.h" pref_t user_pref; diff -ur nwebmail-0.1.77/send_message.cpp nwebmail-sgp/send_message.cpp --- nwebmail-0.1.77/send_message.cpp Fri Nov 24 22:06:24 2000 +++ nwebmail-sgp/send_message.cpp Fri Apr 6 16:11:41 2001 @@ -30,6 +30,7 @@ #include "view_message.h" #include "preferences.h" #include "headers.h" +#include "header.h" struct send_info { char* from; @@ -120,8 +121,11 @@ sendmail_fork_child_process(fdes); exit(-1); } - else if(pid > 0) + else if(pid > 0) { err=sendmail_fork_parent_process(fdes,pid,&info); + if (err!=0) + syslog(LOG_MAIL|LOG_ERR, "forking sendmail failed."); + } else { syslog(LOG_MAIL | LOG_ERR,"fork failed (%s)",strerror(errno)); @@ -134,8 +138,10 @@ if(err == 0) inbox_action(); - else + else { + syslog(LOG_MAIL|LOG_ERR, "some other send mail error occurred."); err_string_page("Send message failed."); + } return(0); } @@ -156,11 +162,11 @@ if(info->att != NULL && info->new_boundary == NULL) { - info->new_boundary=get_rand_string(20); + info->new_boundary=(char*)malloc(20); if(info->new_boundary == NULL) { - syslog(LOG_MAIL | LOG_ERR,"Out of memory."); + syslog(LOG_MAIL | LOG_ERR,"Forking sendmail: Out of memory."); kill(child_pid,SIGKILL); return(-1); } @@ -883,7 +889,7 @@ } else { - info->new_boundary=get_rand_string(20); + info->new_boundary=(char*)malloc(20); if(info->new_boundary == NULL) return(-1); diff -ur nwebmail-0.1.77/session.cpp nwebmail-sgp/session.cpp --- nwebmail-0.1.77/session.cpp Tue Oct 31 06:07:50 2000 +++ nwebmail-sgp/session.cpp Fri Apr 6 16:13:43 2001 @@ -27,6 +27,7 @@ #include "environment.h" #include "config.h" #include "mail_process.h" +#include "header.h" session_t user_ses; @@ -330,11 +331,10 @@ syslog(LOG_MAIL | LOG_ERR,"Out of memory (%s)",strerror(errno)); return(-1); } - //Fill in user_ses.sessionid - +user_ses.sessionid=(char*)malloc(10); srand(time(NULL)); - asprintf(&(user_ses.sessionid),"%d",rand()); + sprintf(user_ses.sessionid, "%d", rand()); if(user_ses.sessionid == NULL) { @@ -446,7 +446,7 @@ int err=0; char* old_cwd=NULL; - if( (old_cwd=getcwd(NULL,0)) == NULL) + if( (old_cwd=getcwd(NULL,64)) == NULL) { syslog(LOG_MAIL | LOG_ERR,"error during getcwd"); return(-1); diff -ur nwebmail-0.1.77/view_attachment.cpp nwebmail-sgp/view_attachment.cpp --- nwebmail-0.1.77/view_attachment.cpp Mon Nov 13 00:59:29 2000 +++ nwebmail-sgp/view_attachment.cpp Fri Apr 6 15:57:32 2001 @@ -19,6 +19,7 @@ #include "view_attachment.h" #include "view_message.h" #include "encoding_conv.h" +#include "header.h" //////////////////////////////////////////////////////////////////// diff -ur nwebmail-0.1.77/view_message.cpp nwebmail-sgp/view_message.cpp --- nwebmail-0.1.77/view_message.cpp Fri Nov 24 21:57:33 2000 +++ nwebmail-sgp/view_message.cpp Fri Apr 6 15:57:36 2001 @@ -20,6 +20,7 @@ #include "view_message.h" #include "encoding_conv.h" #include "config.h" +#include "header.h" void view_message_header(struct mail_header*); status_type view_message_body(FILE*, struct mail_header*,int,int*,char*);