简体   繁体   English

如何只允许在指定路径上使用sudo?

[英]how to only allow sudo on specify path?

in Linux: 在Linux中:

I want to limited user only can do sudo on specify path. 我想限制用户只能在指定路径上执行sudo。

sudo chmod works on /home/Krome/revA sudo chmod适用于/ home / Krome / revA

but sudo chmod failed on /home/Krome 但是sudo chmod在/ home / Krome上失败

Thanks! 谢谢!

可以使用chroot将用户或进程限制为某个路径-这里的问题是,在chroot之后, $PATH和动态加载的对象中的命令将不再可访问,因此您需要一个静态链接的shell来执行chroot以及用户应能够发出的内置命令。

I don't think it possible, and am pretty sure it's not reasonable. 我认为这是不可能的,并且非常确定这是不合理的。

chmod would work inside /home/Krome if it's the user's home folder. 如果是用户的home文件夹,则chmod可以在/home/Krome内部运行。

I think you need a regular user (without sudo ), and everything else can be managed by adding that user to groups and sharing some folders to those groups. 我认为您需要一个普通用户(没有sudo ),并且可以通过将该用户添加到组中并在这些组中共享一些文件夹来管理其他所有内容。

Add to /etc/sudoers something like the following line: 将类似以下行的内容添加到/etc/sudoers

%users ALL = NOPASSWD: /bin/chmod [ugoa][-+=][rwxXst] /home/Krome/*

It basically says that all group users members can invoke sudo chmod in symbolic mode on anything under /home/Krome/ path. 它基本上说所有组users成员都可以在/home/Krome/路径下的任何内容上以符号模式调用sudo chmod

See man sudo for more details. 有关更多详细信息,请参见man sudo

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM