Date: Fri, 07 Aug 1998 08:59:03 +0100 From: Karl Pielorz <kpielorz@tdx.co.uk> To: hackers@FreeBSD.ORG Subject: getpwuid - after chroot? Message-ID: <35CAB3C7.4A6B776D@tdx.co.uk>
next in thread | raw e-mail | index | archive | help
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 <stdlib.h> #include <stdio.h> #include <unistd.h> #include <pwd.h> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?35CAB3C7.4A6B776D>