From owner-freebsd-hackers Fri Aug 7 00:59:11 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id AAA21482 for freebsd-hackers-outgoing; Fri, 7 Aug 1998 00:59:11 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from caladan.tdx.co.uk (caladan.tdx.co.uk [195.188.177.4]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id AAA21430 for ; Fri, 7 Aug 1998 00:58:45 -0700 (PDT) (envelope-from kpielorz@tdx.co.uk) Received: from tdx.co.uk (lorca-tx.tdx.co.uk [195.188.177.242]) by caladan.tdx.co.uk (8.9.1/8.9.1) with ESMTP id IAA24405 for ; Fri, 7 Aug 1998 08:58:28 +0100 (BST) Message-ID: <35CAB3C7.4A6B776D@tdx.co.uk> Date: Fri, 07 Aug 1998 08:59:03 +0100 From: Karl Pielorz Organization: TDX X-Mailer: Mozilla 4.5b1 [en] (WinNT; I) X-Accept-Language: en MIME-Version: 1.0 To: hackers@FreeBSD.ORG Subject: getpwuid - after chroot? Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi, Is there a workaround for using getpwuid() after you've chroot'd at all? - e.g. with the code below? I think the reason it _doesn't_ work is because once you've chroot'd the system can't get back to the '/etc/pwd.db' file etc.? - Is there any way round this? Apparently the following code does actually work on other systems... Someone mentioned Linux, but I don't have access to any Linux boxes to test it ;-) Regards, Karl Pielorz ---- #include #include #include #include int main() { setpassent(1); getpwent(); chroot("/usr"); chdir("/"); if(!getpwuid(0)) { printf("setpassent doesn't appear to work\n"); } else { if(!getpwuid(0)) printf("second getpwuid(0) didn't work\n"); else printf("setpassent works\n"); } return 0; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message