当我尝试将 chroot 与“.”一起使用时或作为参数的完整路径名,perror 告诉我“不允许操作”。
如果我的问题的答案是肯定的,是否有另一种更改根目录的方法? (没有使用 strcmp()/strncmp() 的野蛮方法)
最佳答案
chroot
只能由 root
他/她/自己使用。不,在不损害安全性的情况下不会有任何其他方式。
来自维基百科
Only the root user can perform a chroot. This is intended to prevent users from putting a setuid program inside a specially crafted chroot jail (for example, with a fake /etc/passwd and /etc/shadow file) that would fool it into a privilege escalation.
参见 here对于文章。
关于c - chroot() 需要 root 权限吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15985290/