Bug#150976: Debian bug #150976: now fixed in upstream source.
On Mon, Jul 28, 2003 at 03:06:00PM +1000, Darren Tucker wrote:
> Colin Watson wrote:
> > Unfortunately the patch won't work for our purposes as-is, because we
> > ship a single compiled binary for all kernels, and generally compile on
> > 2.2 or 2.4. Would it be possible to detect this at run-time instead?
>
> Maybe. I tried making a test [1] to run in configure but it broke when
> compiler optimization was turned on. I don't think a run-time test would
> be popular upstream, though.
I think tests that distinguish between such details of otherwise
binary-compatible platforms should always be made at run-time. I'm not
sure if that's a popular view, but certainly it's the only feasible way
to do things in a distribution.
Anyway, in case it's useful, here follows the patch I've now applied to
our CVS repository. If need be, of course, I can keep it there forever,
but it would be good to keep our forking to a minimum. :)
Index: monitor_fdpass.c
===================================================================
RCS file: /home/cjwatson/cvs/openssh/openssh/monitor_fdpass.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -p -u -r1.1.1.2 -r1.2
--- monitor_fdpass.c 1 Sep 2003 01:46:56 -0000 1.1.1.2
+++ monitor_fdpass.c 1 Sep 2003 19:22:38 -0000 1.2
@@ -27,10 +27,34 @@
RCSID("$OpenBSD: monitor_fdpass.c,v 1.4 2002/06/26 14:50:04 deraadt Exp $");
#include <sys/uio.h>
+#include <sys/utsname.h>
#include "log.h"
#include "monitor_fdpass.h"
+static int
+cmsg_type_is_broken(void)
+{
+ static int broken_cmsg_type = -1;
+
+ if (broken_cmsg_type != -1)
+ return broken_cmsg_type;
+ else {
+ struct utsname uts;
+ /* If uname() fails, play safe and assume that cmsg_type
+ * isn't broken.
+ */
+ if (!uname(&uts) &&
+ strcmp(uts.sysname, "Linux") == 0 &&
+ strncmp(uts.release, "2.0.", 4) == 0)
+ broken_cmsg_type = 1;
+ else
+ broken_cmsg_type = 0;
+ }
+
+ return broken_cmsg_type;
+}
+
void
mm_send_fd(int socket, int fd)
{
@@ -113,7 +137,7 @@ mm_receive_fd(int socket)
fatal("%s: no fd", __func__);
#else
cmsg = CMSG_FIRSTHDR(&msg);
- if (cmsg->cmsg_type != SCM_RIGHTS)
+ if (!cmsg_type_is_broken() && cmsg->cmsg_type != SCM_RIGHTS)
fatal("%s: expected type %d got %d", __func__,
SCM_RIGHTS, cmsg->cmsg_type);
fd = (*(int *)CMSG_DATA(cmsg));
> BTW, I posted a bug report [2] to linux-kernel but got no response.
I suspect there's very little in the way of 2.0 maintenance happening
nowadays, even to verify bugs.
Thanks,
--
Colin Watson [cjwatson@flatline.org.uk]
Reply to: