News for hackers. Stuff that matters.
Re:Privilege drop, separation, and restricted-service operat... by commandersaki on Sunday February 19, 2023 @08:07PM (#34863743)
> We first get a user with getpwnam(3) to drop to. The user has /var/empty configured as its home directory so we can use that in chroot(2). Next we chdir(2) to the new file-system root to have a valid current working directory. This prevents us accidentally marking a file-system as busy depending on from where the daemon was started, preventing unmounting file-systems while the daemon is running.

I think another reason for chdir(2) is to avoid a vulnerability where you can repeatedly chain chdir("..") in the process and then chroot(".") to escape chroot.

There are no comments on this comment yet.