Welcome! Log In Create A New Profile


getpwnam issue

January 04, 2011 03:43PM
Hello all,

I am testing a chroot'ed nginx setup on Debian Lenny and am receiving the error: `getpwnam("www-data") failed` when I try to start nginx. My search to find a possible solution have so far been fruitless but I am hoping someone smarter than I could offer some advice.

I've setup the "jail" in /chroot/nginx, created the relevant directory structure (/dev/, /etc, /usr, /var, etc.). Then I copied files that "ldd `which nginx`" showed as linked to the relevant directories, and also copied what I believe are the necessary /etc/* files to /chroot/nginx/etc/. So my directory structure is basically as follows:

/chroot/nginx (base chroot directory)
passwd, shadow, group, hosts, nsswitch.conf, resolv.conf
/sites-{available, enabled}
*(some shared library files here)
libnss_dns* files, libnss_compat* files, libnss_files*, and some other shared library files here

(that's a non-exhaustive overview, but is hopefullly enough to diagnose the problem)

I know that it's not a getpwnam() issue, as I found a forum discussion which involves troubleshooting the getpwnam() function with a simple C program to ensure that getpwnam() is indeed working properly. I've tested this and it works as expected in a non-chroot setting (discussion is here, it's in Russian, so you may need to use Google Translate: http://forum.nginx.org/read.php?21,128545,129156#msg-129156).

I am using the start-stop-daemon to manage nginx with a script similar to this: http://snippets.aktagon.com/snippets/155-nginx-startup-script-for-Debian. So to start nginx I run:

# start-stop-daemon --start --pidfile /var/run/nginx/nginx.pid --exec /usr/sbin/nginx --chroot /chroot/nginx

And this is what throws the error. I think that it's really an issue of having my paths or permissions wrong such that getpwnam() cannot read/find the passwd file, but my attempts to change permissions, owners, and paths have not been successful. Any advice or suggestions would be appreciated!


Subject Author Posted

getpwnam issue

chadmiko January 04, 2011 03:43PM

Re: getpwnam issue

chadmiko January 04, 2011 05:52PM

Re: getpwnam issue

doublerebel January 12, 2011 04:09PM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 72
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready