Date: Mon, 1 Mar 2004 17:07:03 +0100 From: Anton Berezin <tobez@freebsd.org> To: freebsd-emulation@freebsd.org Subject: [PATCH] any objections to the following patch? Message-ID: <20040301160702.GA31836@heechee.tobez.org>
next in thread | raw e-mail | index | archive | help
This fixes the hostname determination from linux applications inside a
jail. The patch is against RELENG_4, since this problem is already
fixed in -CURRENT.
Index: linux_misc.c
===================================================================
RCS file: /home/ncvs/src/sys/compat/linux/linux_misc.c,v
retrieving revision 1.85.2.10
diff -u -r1.85.2.10 linux_misc.c
--- linux_misc.c 22 Oct 2003 13:51:46 -0000 1.85.2.10
+++ linux_misc.c 1 Mar 2004 16:05:30 -0000
@@ -686,6 +686,8 @@
{
struct l_new_utsname utsname;
char *osrelease, *osname;
+ int name[2];
+ int error, plen, olen;
#ifdef DEBUG
if (ldebug(newuname))
@@ -697,7 +699,14 @@
bzero(&utsname, sizeof(utsname));
strncpy(utsname.sysname, osname, LINUX_MAX_UTSNAME-1);
- strncpy(utsname.nodename, hostname, LINUX_MAX_UTSNAME-1);
+
+ name[0] = CTL_KERN;
+ name[1] = KERN_HOSTNAME;
+ olen = LINUX_MAX_UTSNAME-1;
+ error = kernel_sysctl(p, name, 2, utsname.nodename, &olen, NULL, 0, &plen);
+ if (error)
+ strncpy(utsname.nodename, hostname, LINUX_MAX_UTSNAME-1);
+
strncpy(utsname.release, osrelease, LINUX_MAX_UTSNAME-1);
strncpy(utsname.version, version, LINUX_MAX_UTSNAME-1);
strncpy(utsname.machine, machine, LINUX_MAX_UTSNAME-1);
Cheers,
\Anton.
--
Civilization is a fractal patchwork of old and new and dangerously new.
-- Vernor Vinge
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040301160702.GA31836>
