|
Subject: qmail vs errno (patch included) Newsgroups: gmane.mail.qmail.general, gmane.spam.detected Date: 2002-12-26 06:16:59 GMT (5 years, 36 weeks, 5 days, 6 hours and 49 minutes ago)
Recent versions of the GNU C library (glibc), as well as other C libraries,
will not work with qmail. Here's an explanation and a patch.
The explanation is simple: 'errno' is not required nor guaranteed to
be an int, only a modfifiable lvalue. Many modern *nixes define it to
be an expression involving a function call in order to be threadsafe.
The <errno.h> header will do it all for you.
Most *nixes also have some kind of backwards compatibility for the annoying
historical practice of writing "extern int errno;" rather than including
the header. The most recent version of glibc removed that compatability.
(C was standardized in 1989, you'd think 14 years would be enough time to
catch up.)
Anyhow, qmail includes errno.h only in some of the .c files. Not the .h
which defines ENOENT and others if they aren't already defined. Oops.
Thus, when 'errno' is not actually an int, none of the qmail code -- or,
for that matter, tcpserver and others -- has a correct value in errno when
doing things like
if (errno == error_noent) return; // from qmail-send.c
So, for example, nonexistent qmail control files cause a hard error instead
of falling back on defaults, when running qmail with an upgraded libc.
Recompiling qmail after upgrading such a library also fails, because
of the "extern int errno;" declaration. (At link time, since no such
symbol exists.)
Additional reports and notes:
http://bugs.debian.org/174040 (scroll down)
http://www.ornl.gov/cts/archives/mailing-lists/qmail/2002/12/msg00638.html
The patch is equally simple: let the system set up errno the way it wants
to, rather than assuming an int. I note that two source files do include
the correct header file, but then additionally declare errno as an int.
(I realize that was correct historical practice. Those OSes are dead now.
The seven installations of crappy *nix remaining in the world can use qmail
1.03. Please, let's get 1.04 to work correctly on relevent OSes. *grin*)
% diff -u3 error.h.orig error.h
--- error.h.orig 1998-06-15 06:53:16.000000000 -0400
+++ error.h 2002-12-24 20:28:40.000000000 -0500
@@ -1,7 +1,7 @@
#ifndef ERROR_H
#define ERROR_H
-extern int errno;
+#include <errno.h>
extern int error_intr;
extern int error_nomem;
% diff -u3 dns.c.orig dns.c
--- dns.c.orig 2002-08-09 19:20:48.000000000 -0400
+++ dns.c 2002-12-24 20:42:46.000000000 -0500
@@ -7,8 +7,6 @@
#include <errno.h>
extern int res_query();
extern int res_search();
-extern int errno;
-extern int h_errno;
#include "ip.h"
#include "ipalloc.h"
#include "fmt.h"
% diff -u3 cdb_seek.c.orig cdb_seek.c
--- cdb_seek.c.orig 1998-06-15 06:53:16.000000000 -0400
+++ cdb_seek.c 2002-12-24 20:42:52.000000000 -0500
@@ -1,6 +1,5 @@
#include <sys/types.h>
#include <errno.h>
-extern int errno;
#include "cdb.h"
#ifndef SEEK_SET
|
|
|