From owner-freebsd-hackers Thu May 29 17:39:23 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id RAA18467 for hackers-outgoing; Thu, 29 May 1997 17:39:23 -0700 (PDT) Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.50]) by hub.freebsd.org (8.8.5/8.8.5) with SMTP id RAA18461 for ; Thu, 29 May 1997 17:39:13 -0700 (PDT) Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id RAA05616; Thu, 29 May 1997 17:36:05 -0700 From: Terry Lambert Message-Id: <199705300036.RAA05616@phaeton.artisoft.com> Subject: Re: Correct way to chroot for shell account users? To: julian@whistle.com (Julian Elischer) Date: Thu, 29 May 1997 17:36:05 -0700 (MST) Cc: imp@village.org, terry@lambert.org, dec@phoenix.its.rpi.edu, peter@grendel.IAEhv.nl, mrcpu@cdsnet.net, hackers@FreeBSD.ORG In-Reply-To: <338E1C3B.2781E494@whistle.com> from "Julian Elischer" at May 29, 97 05:15:55 pm X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk It won't work for arbitrary depth without modification... main() { dev_t d_last; ino_t i_last; struct stat sb; mkdir( "xxx"); chroot("xxx"); chdir(".."); stat( ".", &sb); do { d_last = sb.st_dev; i_last = sb.st_ino; if (chdir("..")) break; stat( ".", &sb); } while( sb.st_dev != d_last || sb.st_ino != i_last); chroot("."); } Now *there's* a reliable hack... 8-). Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.