Date: Wed, 12 Feb 2003 20:41:18 +0100 (CET) From: Rolf Grossmann <grossman@progtech.net> To: FreeBSD-gnats-submit@FreeBSD.org Subject: kern/48216: Linux uname returns wrong hostname inside jail Message-ID: <200302121941.h1CJfINn023268@ptserver.progtech.intern>
next in thread | raw e-mail | index | archive | help
>Number: 48216 >Category: kern >Synopsis: Linux uname returns wrong hostname inside jail >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Feb 12 11:50:06 PST 2003 >Closed-Date: >Last-Modified: >Originator: Rolf Grossmann >Release: FreeBSD 4.7-STABLE i386 >Organization: PROGTECH GmbH >Environment: System: FreeBSD ptserver 4.7-STABLE FreeBSD 4.7-STABLE #2: Thu Nov 14 19:43:00 CET 2002 grossman@ptserver:/export/home/grossman/tmp/sys/compile/PTSERVER i386 >Description: In a jail-ed environment, the linux uname system call still returns the machine's main hostname (not the one given in the jail command). >How-To-Repeat: Try this (adjust hostname and ip addresses to your system): # uname -n ptserver # jail / ptserver.progtech.intern 10.25.0.1 /bin/tcsh # uname -n ptserver.progtech.intern # /compat/linux/bin/uname -n ptserver >Fix: This patch fixes the problem for me on a recent -STABLE. I would guess that it might work aswell on -CURRENT, but I haven't checked. (FWIW linux_misc.c is the same, so the bug is in -CURRENT, too.) RCS file: /home/freebsd/cvs/cvs/src/sys/compat/linux/linux_misc.c,v retrieving revision 1.85.2.9 diff -u -r1.85.2.9 linux_misc.c --- linux_misc.c 24 Sep 2002 08:11:41 -0000 1.85.2.9 +++ linux_misc.c 12 Feb 2003 19:15:32 -0000 @@ -686,6 +686,8 @@ { struct l_new_utsname utsname; char *osrelease, *osname; + int name[2], rtval; + size_t len; #ifdef DEBUG if (ldebug(newuname)) @@ -697,7 +699,11 @@ 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; + len = LINUX_MAX_UTSNAME-1; + rtval = kernel_sysctl(p, name, 2, utsname.nodename, &len, 0, 0, 0); + if (rtval) return rtval; strncpy(utsname.release, osrelease, LINUX_MAX_UTSNAME-1); strncpy(utsname.version, version, LINUX_MAX_UTSNAME-1); strncpy(utsname.machine, machine, LINUX_MAX_UTSNAME-1); >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200302121941.h1CJfINn023268>