As below I found in Ubuntu 12.04, I found that I get the segfault, even though I follow the right procedure. The same code seem to work on RedHat distrubution:
- Establish a chroot-jail using debootstrap
- In the C program do a chroot into the jail created by dbootstrap.
- Then to drop privileges, within the chroot jail, in the forked process, call setgid(existinguser).
Then one gets segfault as below. This doesn't happen, if the chroot is to "/". I wonder whether the chroot environment created by debootstrap is a problem. The output is below:
======== start here ======== ubuntu12-04 kernel: [ 8595.902026] ae[9695]: segfault at 3ea ip b752ee29 sp bf986c70 error 4 in libc-2.15.so[b74ea000+1a3000] ================================
setguid(), which isn't a syscall, but your description mentionssetgid(), which will set the group ID, not the user ID. Do you mean to callsetuid()instead, to actually drop user privileges? – Jeremy Kerr Nov 13 '12 at 5:18