From owner-freebsd-bugs Wed Feb 12 11:50:11 2003 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3116737B401 for ; Wed, 12 Feb 2003 11:50:08 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 341C243FCB for ; Wed, 12 Feb 2003 11:50:07 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id h1CJo7NS024187 for ; Wed, 12 Feb 2003 11:50:07 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id h1CJo7UP024186; Wed, 12 Feb 2003 11:50:07 -0800 (PST) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E5B0D37B406 for ; Wed, 12 Feb 2003 11:40:32 -0800 (PST) Received: from ptserver.progtech.net (p50803BA9.dip.t-dialin.net [80.128.59.169]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6B05343F93 for ; Wed, 12 Feb 2003 11:40:30 -0800 (PST) (envelope-from grossman@progtech.net) Received: from ptserver.progtech.intern (localhost [127.0.0.1]) by ptserver.progtech.net (8.12.6/8.12.3) with ESMTP id h1CJfJXL023269 for ; Wed, 12 Feb 2003 20:41:20 +0100 (CET) (envelope-from grossman@ptserver.progtech.intern) Received: (from grossman@localhost) by ptserver.progtech.intern (8.12.6/8.12.3/Submit) id h1CJfINn023268; Wed, 12 Feb 2003 20:41:18 +0100 (CET) Message-Id: <200302121941.h1CJfINn023268@ptserver.progtech.intern> Date: Wed, 12 Feb 2003 20:41:18 +0100 (CET) From: Rolf Grossmann To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/48216: Linux uname returns wrong hostname inside jail Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >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