[PATCH] any objections to the following patch?

Anton Berezin tobez at freebsd.org
Mon Mar 1 08:07:11 PST 2004


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


More information about the freebsd-emulation mailing list