From owner-freebsd-emulation@FreeBSD.ORG Mon Mar 1 08:07:11 2004 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 25F8916A4CE for ; Mon, 1 Mar 2004 08:07:11 -0800 (PST) Received: from heechee.tobez.org (heechee.tobez.org [217.157.39.226]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1979643D2F for ; Mon, 1 Mar 2004 08:07:09 -0800 (PST) (envelope-from tobez@tobez.org) Received: by heechee.tobez.org (Postfix, from userid 1001) id 5CA39175D2; Mon, 1 Mar 2004 17:07:03 +0100 (CET) Date: Mon, 1 Mar 2004 17:07:03 +0100 From: Anton Berezin To: freebsd-emulation@freebsd.org Message-ID: <20040301160702.GA31836@heechee.tobez.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.6i Subject: [PATCH] any objections to the following patch? X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Mar 2004 16:07:11 -0000 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