[Dovecot] another Dovecot problem

Timo Sirainen tss at iki.fi
Fri Oct 3 18:02:11 EEST 2003


On Thu, 2003-10-02 at 20:57, Tim Miller wrote:
> First, thanks to Timo for solving my last issue. I got dovecot up and
> running on one of my machines, and it does exactly what I want. Now I'm
> trying to install dovecot on an older box (glibc 2.0.7 Linux kernel
> 2.0.36), and encountering some problems:
> 
> -- firstly autoconf/automake does not seem to correctly deal with the
> madvise function on this system. It detects that we don't have madvise,
> yet it's prototyped in /usr/include/sys/mman.h. This causes the
> compilation to fail when dovecot tries to redefine this function.
> 
> -- I attempted to solve this problem by renaming the function dovecot
> prototypes to dc_madvise and then changed all the calls in the code (and
> the implementation) from madvise to dc_madvise. This allows the code to
> compile correctly.

Well, I fixed it in a bit easier way :)

diff -u -r1.4 -r1.5
--- mmap-util.h 28 Oct 2002 09:00:25 -0000      1.4
+++ mmap-util.h 3 Oct 2003 14:50:48 -0000       1.5
@@ -15,7 +15,8 @@
 #endif
 
 #ifndef HAVE_MADVISE
-int madvise(void *start, size_t length, int advice);
+#  define madvise my_madvise
+int my_madvise(void *start, size_t length, int advice);
 #  ifndef MADV_NORMAL
 #    define MADV_NORMAL 0
 #    define MADV_RANDOM 0


> -- However, once the server is installed, it does not appear to work
> correctly. I can login, but when I try to list my folders or select any
> folder (one that exists or one that doesn't exist) the connection times
> out and the following entry is written to the log file:
> 
> dovecot: Oct 03 05:38:56 Error: login: received another "not listening"
> notification (if you can't login at all, see src/lib/fdpass.c)
> 
> I tracked this message down in the source, but didn't see any obvious way
> to trace back the problem.

Linux 2.0.x kernels requires changes in the source to work. I didn't
think anyone would really bother trying Dovecot with 2.0 kernels anymore
so there was only a comment about it there. Apply the included patch and
compile with -DLINUX20 and it should work.

-------------- next part --------------
? src/lib/file-lock-remote.c
? src/lib/file-lock-remote.h
? src/lib/istream-copy.c
? src/lib/istream-data.c2
? src/lib/istream-filter.c
? src/lib/istream-filter.h
? src/lib/m
Index: src/lib/fdpass.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/fdpass.c,v
retrieving revision 1.26
diff -u -r1.26 fdpass.c
--- src/lib/fdpass.c	26 Aug 2003 21:06:44 -0000	1.26
+++ src/lib/fdpass.c	3 Oct 2003 15:01:33 -0000
@@ -78,6 +78,22 @@
 	return sendmsg(handle, &msg, 0);
 }
 
+#ifdef __osf__
+#  define CHECK_MSG(msg) TRUE /* Tru64 */
+#else
+#  define CHECK_MSG(msg) (msg).msg_controllen >= CMSG_SPACE(sizeof(int))
+#endif
+
+#ifdef LINUX20
+/* Linux 2.0.x doesn't set any cmsg fields. Note that this might make some
+   attacks possible so don't do it unless you really have to. */
+#  define CHECK_CMSG(cmsg) ((cmsg) != NULL)
+#else
+#  define CHECK_CMSG(cmsg) \
+	((cmsg) != NULL && (cmsg)->cmsg_len >= CMSG_LEN(sizeof(int)) && \
+	 (cmsg)->cmsg_level == SOL_SOCKET && (cmsg)->cmsg_type == SCM_RIGHTS)
+#endif
+
 ssize_t fd_read(int handle, void *data, size_t size, int *fd)
 {
 	struct msghdr msg;
@@ -109,17 +125,10 @@
 	/* at least one byte transferred - we should have the fd now.
 	   do extra checks to make sure it really is an fd that is being
 	   transferred to avoid potential DoS conditions. some systems don't
-	   set all these values correctly however:
-
-	   Linux 2.0.x - cmsg_len, cmsg_level, cmsg_type are not set
-	   Tru64 - msg_controllen isn't set */
+	   set all these values correctly however so CHECK_MSG() and
+	   CHECK_CMSG() are somewhat system dependent */
 	cmsg = CMSG_FIRSTHDR(&msg);
-	if (
-#ifndef __osf__ /* Tru64 */
-	    msg.msg_controllen < CMSG_SPACE(sizeof(int)) ||
-#endif
-	    cmsg == NULL || cmsg->cmsg_len < CMSG_LEN(sizeof(int)) ||
-	    cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS)
+	if (!CHECK_MSG(msg) || !CHECK_CMSG(cmsg))
 		*fd = -1;
 	else
 		*fd = *((int *) CMSG_DATA(cmsg));


More information about the dovecot mailing list