Linked Questions

15
votes
1answer
22k views

Why does setuid not work? [duplicate]

I want to ensure that my program can only be run by user xyz using root privilege. To do this, I set the setuid bit with: chmod u+s program1.sh ls -l program1.sh rwsr-x--- 1 root house 1299 May 15 23:...
4
votes
1answer
2k views

How to let a user execute a script owned by root? Setuid doesn't seem to work anymore [duplicate]

I have some bash scripts that I use with the user 'root' to manage iptable rules. The problem is that I want these things at the same time: The script must be owned by root Permissions must be 700 I ...
1
vote
1answer
4k views

How to run privileged bash script as non-root? [duplicate]

I created a simple bash script which contains the command ifconfig. In general I want to execute such a privileged script to run as non-root user. I have tried hown root:users ./path/to/script.sh ...
1
vote
1answer
1k views

suid script not working correctly [duplicate]

My os is Fedora 24 and I tried to test the suid bit functionality. I wrote below bash as Setuid.bash: #!/bin/bash if [ $USER = 'root' ] then echo "Like Root Run" echo "Root User Add in " $(...
0
votes
2answers
463 views

Why is the suid bit having no effect on a shell or perl script? [duplicate]

As an experiment in playing with the suid bit, I tried writing a script to run apt-get update from a bash script, and then set the suid bit on it, so I could just run ~/update or something. apt-get ...
0
votes
0answers
356 views

Effective and real user id matching? [duplicate]

I have the following script: $ ls -al setprog.sh -rwsrwxr-x 1 root root 52 Αυγ 2 10:23 setprog.sh $ cat setprog.sh #!/bin/bash while [ True ] do echo $(whoami) done When running it $ ./...
1
vote
1answer
250 views

Why won't this example of setUID work? [duplicate]

I am learning about setuid and setgid where the user executing the script will inherit the owner's permission while running the script. To test this, I created a bash as user fiverr in /home/fiverr/...
0
votes
1answer
166 views

Is a php file with SGID bit and read-only & execute a security problem? [duplicate]

I find php files with SGID bit and read-only & execute. The group is root. Is this a problem? Because a user will need to run the php interpreter with their our account, could it led to privilege ...
1
vote
1answer
72 views

How to implement setuid bit? [duplicate]

I created a small script as the root user... #!/bin/bash cat /etc/shadow and set the setuid bit and placed it within the guest folder. When I ran the script as guest, it showed permission denied. ...
0
votes
0answers
74 views

Always run script as root [duplicate]

I want to run a command automatically. The problem is that it may only be run after I logged in and that it requires superuser privileges. I've heard of suid before, so I thought I'd use it for this. ...
2
votes
0answers
29 views

Cannot execute file with root priviledges using SUID [duplicate]

So from what I understand, SUID makes so that when you execute a file, you're basically executing it under root, right? Now I made this file, and whenever I try to run it, I get a permission denied ...
3
votes
0answers
22 views

How to create a directory behalf on root user? [duplicate]

I have a script: [postgres@LaHarch ~]$ cat mkrundir.sh #!/bin/bash mkdir /run/postresql With attributes: [postgres@LaHarch ~]$ ll mkrundir.sh -rwsr-sr-x 1 root root 74 Aug 26 18:53 mkrundir.sh ...
175
votes
14answers
372k views

How to run a specific program as root without a password prompt?

I need to run something as sudo without a password, so I used visudo and added this to my sudoers file: MYUSERNAME ALL = NOPASSWD: /path/to/my/program Then I tried it out: $ sudo /path/to/my/...
69
votes
9answers
60k views

Can a script be executable but not readable?

Is it possible to execute a script if there is no permission to read it? In root mode, I made a script and I want the other user to execute this script but not read it. I did chmod to forbid read and ...
86
votes
2answers
267k views

su options - running command as another user

I was wondering how to run a command as another user from a script. I have the script's owner set as root. I also have the following command being run within the script to run the command as the ...

15 30 50 per page