[tpop3d-discuss] A few patches
Yann GROSSEL
olrick at rainbow.winterbird.net
Mon, 14 Jul 2003 23:23:05 +0200
This is a multi-part message in MIME format.
--Multipart_Mon__14_Jul_2003_23:23:05_+0200_08277a98
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Hello
Here are a few small patches I've done this week-end. They are against the
current CVS repository. Please tell me what you think of them.
configure.in.diff:
- makes the configure script abort with an error message if no
authentication driver is enabled
- always detects if libcrypt is needed no matter what authentication
drivers are selected (password.c uses the crypt() function in
check_password() and it is always compiled in)
main.c.diff:
'configfile' was missing in one of the log_print() calls
tpop3d.conf.5.diff:
fixes a few typos
auth_flatfile.c.diff:
this one fixes a bug that made read_user_passwd() return the pwhash
of the last line of the flat file if the localpart supplied was not
found in the file. This allowed someone knowning the last password
in the file to log in with any (non existent) username
password.c.diff:
this one fixes two bugs in the check_password() function :
- the default scheme was used to check the hash even if a different
scheme was specified in the hash (for example it prevented the use
of {md5} hashes in flat files, because {crypt} was always checked
first and of course the check always failed)
- the check against md5 hash was inversed, allowing users to log in
with any password but the right one
connection.c.diff:
tpop3d crashed when the user issued a 'TOP' command on a empty
mailbox or message (OK, empty mailboxes or messages should never
happen, but if we can make tpop3d harder to crash even in unexpected
situations...)
warnings.diff:
removes a few warnings (mainly "missing braces around initializer")
(one warning remains at listener.c:59 - I think the alloc_struct
macro should be fixed but I don't know the right fix to apply)
--
Olrick
--Multipart_Mon__14_Jul_2003_23:23:05_+0200_08277a98
Content-Type: text/plain;
name="configure.in.diff"
Content-Disposition: attachment;
filename="configure.in.diff"
Content-Transfer-Encoding: 7bit
diff -ruN tpop3d-cvs/configure.in tpop3d/configure.in
--- tpop3d-cvs/configure.in 2003-01-10 00:20:23.000000000 +0100
+++ tpop3d/configure.in 2003-07-13 13:39:10.000000000 +0200
@@ -337,6 +337,18 @@
AC_DEFINE(AUTH_PERL,1,[Use an embedded perl interpreter for authentication.])
fi
+if test x"$enable_auth_pam" != x"yes" \
+&& test x"$enable_auth_passwd" != x"yes" \
+&& test x"$enable_shadow" != x"yes" \
+&& test x"$enable_auth_mysql" != x"yes" \
+&& test x"$enable_auth_ldap" != x"yes" \
+&& test x"$enable_auth_flatfile" != x"yes" \
+&& test x"$enable_auth_other" != x"yes" \
+&& test x"$enable_auth_perl" != x"yes"
+then
+ AC_MSG_ERROR([No authentication driver is enabled. At least one is required.])
+fi
+
dnl Mailbox drivers
if test x"$enable_mbox_bsd" = x"yes"
then
@@ -478,10 +490,7 @@
fi
# Some machines have crypt(3) in libcrypt; test for this.
-if test x"$enable_auth_passwd" = x"yes" || test x"$enable_shadow" = x"yes" || test x"$enable_auth_mysql" = x"yes" || test x"$enable_auth_flatfile" = x"yes"
-then
- AC_CHECK_LIB(crypt, crypt, , )
-fi
+AC_CHECK_LIB(crypt, crypt, , )
# Some machines have dlopen etc. in libdl, and these are needed for PAM.
if test x"$enable_auth_pam" = x"yes"
--Multipart_Mon__14_Jul_2003_23:23:05_+0200_08277a98
Content-Type: text/plain;
name="main.c.diff"
Content-Disposition: attachment;
filename="main.c.diff"
Content-Transfer-Encoding: 7bit
diff -ruN tpop3d-cvs/main.c tpop3d/main.c
--- tpop3d-cvs/main.c 2002-12-28 16:39:20.000000000 +0100
+++ tpop3d/main.c 2003-07-12 15:08:21.000000000 +0200
@@ -500,7 +500,7 @@
strip_domain = 1;
if (append_domain && strip_domain)
- log_print(LOG_WARNING, _("%s: specifying append-domain and strip-domain does not make much sense"));
+ log_print(LOG_WARNING, _("%s: specifying append-domain and strip-domain does not make much sense"), configfile);
/* Should we disconnect any client which sends a USER command? */
if (config_get_bool("apop-only"))
--Multipart_Mon__14_Jul_2003_23:23:05_+0200_08277a98
Content-Type: text/plain;
name="tpop3d.conf.5.diff"
Content-Disposition: attachment;
filename="tpop3d.conf.5.diff"
Content-Transfer-Encoding: 7bit
diff -ruN tpop3d-cvs/tpop3d.conf.5 tpop3d/tpop3d.conf.5
--- tpop3d-cvs/tpop3d.conf.5 2003-02-18 00:18:32.000000000 +0100
+++ tpop3d/tpop3d.conf.5 2003-07-12 15:11:26.000000000 +0200
@@ -539,9 +539,9 @@
\fBauth-flatfile-passwd-file\fP: \fIsubstitution string\fP
Specify the file in which \fBtpop3d\fP will search for a user's password.
.TP
-\fBauth-ldap-mail-user\fP: (\fIuser-name\fP | \fIuid\fP)
+\fBauth-flatfile-mail-user\fP: (\fIuser-name\fP | \fIuid\fP)
.TP
-\fBauth-ldap-mail-group\fP: (\fIgroup-name\fP | \fIgid\fP)
+\fBauth-flatfile-mail-group\fP: (\fIgroup-name\fP | \fIgid\fP)
User and group under which access to the mailbox will take place.
.SS A note on flat file authentication
--Multipart_Mon__14_Jul_2003_23:23:05_+0200_08277a98
Content-Type: text/plain;
name="auth_flatfile.c.diff"
Content-Disposition: attachment;
filename="auth_flatfile.c.diff"
Content-Transfer-Encoding: 7bit
diff -ruN tpop3d-cvs/auth_flatfile.c tpop3d/auth_flatfile.c
--- tpop3d-cvs/auth_flatfile.c 2003-02-18 00:18:32.000000000 +0100
+++ tpop3d/auth_flatfile.c 2003-07-13 15:05:57.000000000 +0200
@@ -88,7 +88,7 @@
FILE *fp = NULL;
char *filename = NULL;
struct sverr err;
- static char *buf, *pwhash;
+ static char *buf, *pwhash = NULL;
static size_t buflen;
size_t i, linenum;
int c;
@@ -109,7 +109,7 @@
linenum = 0;
while (1) {
- char *user, *end;
+ char *user, *hash, *end;
i = 0;
while ((c = getc(fp)) != EOF) {
@@ -134,21 +134,22 @@
/* OK, have a line. */
user = buf;
- pwhash = strchr(buf, ':');
- if (!pwhash) {
+ hash = strchr(buf, ':');
+ if (!hash) {
log_print(LOG_WARNING, _("read_user_passwd: flat file %s: line %u: bad format (missing :)"), filename, (unsigned)linenum);
continue;
}
- *pwhash++ = 0;
+ *hash++ = 0;
/* Check username. */
if (strcmp(user, local_part) != 0)
continue;
- if ((end = strchr(pwhash, ':')))
+ if ((end = strchr(hash, ':')))
*end = 0;
+ pwhash = hash;
break;
}
--Multipart_Mon__14_Jul_2003_23:23:05_+0200_08277a98
Content-Type: text/plain;
name="password.c.diff"
Content-Disposition: attachment;
filename="password.c.diff"
Content-Transfer-Encoding: 7bit
diff -ruN tpop3d-cvs/password.c tpop3d/password.c
--- tpop3d-cvs/password.c 2003-04-03 19:41:57.000000000 +0200
+++ tpop3d/password.c 2003-07-13 14:50:41.000000000 +0200
@@ -240,7 +240,7 @@
/* Helper macro to detect schemes. */
# define IS_SCHEME(hash, scheme, def) \
((*hash == '{' && strncmp(hash, scheme, strlen(scheme)) == 0) \
- || strcmp(scheme, def) == 0)
+ || (*hash != '{' && strcmp(scheme, def) == 0))
if (IS_SCHEME(pwhash, "{crypt}", default_crypt_scheme)) {
/* Password hashed by system crypt function. */
@@ -274,7 +274,7 @@
* encoding. */
if (strlen(realhash) == 32) {
/* Hex. */
- return strcasecmp(realhash, md5_digest_str(pass, strlen(pass), 0));
+ return strcasecmp(realhash, md5_digest_str(pass, strlen(pass), 0)) == 0;
} else if (strlen(pwhash) == 24) {
/* Base 64. */
return strcmp(realhash, md5_digest_str(pass, strlen(pass), 1)) == 0;
--Multipart_Mon__14_Jul_2003_23:23:05_+0200_08277a98
Content-Type: text/plain;
name="connection.c.diff"
Content-Disposition: attachment;
filename="connection.c.diff"
Content-Transfer-Encoding: 7bit
diff -ruN tpop3d-cvs/connection.c tpop3d/connection.c
--- tpop3d-cvs/connection.c 2003-01-23 20:51:55.000000000 +0100
+++ tpop3d/connection.c 2003-07-13 16:03:14.000000000 +0200
@@ -438,7 +438,7 @@
p += skip;
/* Send the message headers */
- do {
+ while (p < r && *p != '\n') {
q = memchr(p, '\n', r - p);
if (!q) q = r;
errno = 0;
@@ -454,7 +454,7 @@
nwritten += q - p + 2;
p = q + 1;
- } while (p < r && *p != '\n');
+ }
++p;
--Multipart_Mon__14_Jul_2003_23:23:05_+0200_08277a98
Content-Type: text/plain;
name="warnings.diff"
Content-Disposition: attachment;
filename="warnings.diff"
Content-Transfer-Encoding: 7bit
diff -ruN tpop3d-cvs/maildir.c tpop3d/maildir.c
--- tpop3d-cvs/maildir.c 2003-01-24 12:31:24.000000000 +0100
+++ tpop3d/maildir.c 2003-07-13 15:42:33.000000000 +0200
@@ -25,6 +25,7 @@
#include <syslog.h>
#include <unistd.h>
#include <utime.h>
+#include <time.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
diff -ruN tpop3d-cvs/netloop.c tpop3d/netloop.c
--- tpop3d-cvs/netloop.c 2003-01-10 00:20:23.000000000 +0100
+++ tpop3d/netloop.c 2003-07-13 13:22:08.000000000 +0200
@@ -21,6 +21,7 @@
#include <string.h>
#include <syslog.h>
#include <unistd.h>
+#include <time.h>
#ifdef USE_TCP_WRAPPERS
# include <tcpd.h>
diff -ruN tpop3d-cvs/signals.c tpop3d/signals.c
--- tpop3d-cvs/signals.c 2003-01-10 00:20:23.000000000 +0100
+++ tpop3d/signals.c 2003-07-12 21:12:21.000000000 +0200
@@ -67,7 +67,7 @@
int restart_signals[] = {SIGHUP, 0};
int die_signals[] = {SIGQUIT, SIGABRT, SIGSEGV, SIGBUS, SIGILL, 0};
int *i;
- struct sigaction sa = {0};
+ struct sigaction sa = {{0}};
for (i = ignore_signals; *i; ++i)
xsignal(*i, SIG_IGN);
@@ -108,7 +108,7 @@
extern int post_fork; /* in main.c */
void die_signal_handler(const int i) {
- struct sigaction sa = {0};
+ struct sigaction sa = {{0}};
/* log_print(LOG_ERR, "quit: %s", sys_siglist[i]); */
log_print(LOG_ERR, _("quit: signal %d post_fork = %d"), i, post_fork); /* Some systems do not have sys_siglist. */
#ifdef APPALLING_BACKTRACE_HACK
diff -ruN tpop3d-cvs/util.c tpop3d/util.c
--- tpop3d-cvs/util.c 2002-11-14 00:31:43.000000000 +0100
+++ tpop3d/util.c 2003-07-12 21:14:24.000000000 +0200
@@ -112,7 +112,7 @@
/* xsignal NUMBER HANDLER
* Set a signal with a similar interface to signal(2) using sigaction(2). */
void (*xsignal(int signum, void(*handler)(int)))(int) {
- struct sigaction sa = {0}, sa_old;
+ struct sigaction sa = {{0}}, sa_old;
sa.sa_handler = handler;
sa.sa_flags = SA_RESTART;
if (sigaction(signum, &sa, &sa_old) == -1)
--Multipart_Mon__14_Jul_2003_23:23:05_+0200_08277a98--