From owner-freebsd-bugs@FreeBSD.ORG Tue Jan 3 07:58:47 2006 Return-Path: X-Original-To: freebsd-bugs@freebsd.org Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EA97816A41F for ; Tue, 3 Jan 2006 07:58:47 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from rosebud.otenet.gr (rosebud.otenet.gr [195.170.0.94]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3DAFB43D49 for ; Tue, 3 Jan 2006 07:58:46 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from flame.pc (aris.bedc.ondsl.gr [62.103.39.226]) by rosebud.otenet.gr (8.13.4/8.13.4/Debian-8) with SMTP id k037wiQ7024049; Tue, 3 Jan 2006 09:58:44 +0200 Received: by flame.pc (Postfix, from userid 1001) id 1B3441171C; Tue, 3 Jan 2006 09:57:29 +0200 (EET) Date: Tue, 3 Jan 2006 09:57:28 +0200 From: Giorgos Keramidas To: Tzachi Tager Message-ID: <20060103075728.GA81689@flame.pc> References: <20051228032332.GA30303@flame.pc> <20051228091604.48873.qmail@web30805.mail.mud.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20051228091604.48873.qmail@web30805.mail.mud.yahoo.com> Cc: freebsd-bugs@freebsd.org Subject: Re: using /dev/null in chrooted enviroment X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jan 2006 07:58:48 -0000 On 2005-12-28 01:16, Tzachi Tager wrote: > Hi, > > Giorgos Keramidas wrote: On 2005-12-27 06:49, Tzachi Tager wrote: > > Hi, > > I'm trying to create chrooted enviroment, i did the folllowing > > in the chrooted enviroment: > > > > mknode c null 0 24 > > mknode c zero 0 25 > > > > And then i did chroot and those files are under /dev, but when > > i wrote a short program in C that tries to open /dev/null > > (within the chrooted env.) i got: > > > > "/dev/null-operation is not supported" > > > You forgot to mention what version of FreeBSD you are using. It > > may also help to see the contents of the chrooted /dev directory. > > We are using: > > FreeBSD freebsd6.0 6.0-RELEASE FreeBSD 6.0-RELEASE #0: > Thu Nov 3 09:36:13 UTC 2005 > root@x64.samsco.home:/usr/obj/usr/src/sys/GENERIC i386 > > We tried: > > 1) To create only /dev/null and /dev/zero (that configuration worked in FreeBSD 5.4) > 2) To create the same /dev contents via: tar -cf - /dev | tar -xf - > > The original system has /dev mounted as: devfs on /dev (devfs, local) That's not the correct way to populate a /dev directory in a chroot anymore. None of the above will work as expected, AFAIK. The best way to create a second devfs mount-point that only contains /dev/zero and /dev/null is to remount devfs and 'hide' all teh rest of the device nodes: > PS: It seems like if we mount devfs to the chrooted env - everything > works. The problem is that chroot directory can be placed everywhere, > but mount doesn't accept very long path: > > # mount -t devfs none dev > mount_devfs: File name too long > > # pwd > /tmp/build.debugger-php-4.0.6.5269/debugger-php-4.0.6-DEBUG_SERVER_5_1_0_RC3_20051215 This is where you hit an internal limit of the kernel. The limit is defined as 88 bytes at /usr/src/sys/sys/mount.h: # root@flame:/usr/src/sys/sys# grep MNAMELEN mount* # #define MNAMELEN 88 /* size of on/from name bufs */ # char f_mntfromname[MNAMELEN]; /* mounted filesystem */ # char f_mntonname[MNAMELEN]; /* directory on which mounted */ I'm not sure if this is easy to bump. The best person to answer is someone with more experience with the kernel internals. A workaround that you can use in the mean time is to use shorter names for the chroot directories, i.e.: # mkdir -p /tmp/chroot/100/dev # mount -t devfs devfs /tmp/chroot/100/dev Regards, Giorgos