简体   繁体   中英

Unix : Restricting a directory to an user

I have a root user who has set of input files in a directory

/home/root/inputs/input1.txt .

I created another dummy user /home/dummy who cannot view the input files under /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.

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 < . 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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