简体   繁体   English

Unix:将目录限制为用户

[英]Unix : Restricting a directory to an user

I have a root user who has set of input files in a directory 我有一个root用户,该用户在目录中具有一组输入文件

/home/root/inputs/input1.txt . /home/root/inputs/input1.txt

I created another dummy user /home/dummy who cannot view the input files under /home/root/inputs . 我创建了另一个虚拟用户/home/dummy ,该用户无法查看/ home / root / inputs下的输入文件。 But this dummy user will be creating ac program and executing it. 但是这个虚拟用户将创建一个交流程序并执行它。 And this program should use the inputs under 这个程序应该使用下面的输入

 /home/root/inputs/input1.txt.

How can i achieve this ? 我怎样才能做到这一点? I Do not want the dummy user to view the input file from his code (by using system( ls , cat )) but i want the dummy user to call the binary and use this input. 我不希望虚拟用户从他的代码中查看输入文件(通过使用system( lscat )),但我希望虚拟用户调用二进制文件并使用此输入。

sudo -u dummy ./a.out < /home/root/inputs/input1.txt 

is giving me permission denied. 给我拒绝的权限。

Am creating this script for my class. 正在为我的课程创建此脚本。

You can't do that because a.ou t is not reading the file when you use < . 你不能这样做,因为a.ou T没有读取文件,当您使用< The shell is. 外壳是。 You need to change a.out so it takes an argument, then you'll be able to run sudo -u dummy ./a.out /home/root/inputs/input1.txt and it will work. 您需要更改a.out以便它接受一个参数,然后就可以运行sudo -u dummy ./a.out /home/root/inputs/input1.txt ,它将起作用。

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

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