We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [setuid]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
188
votes
8answers
143k views

Allow setuid on shell scripts

The setuid permission bit tells Linux to run a program with the effective user id of the owner instead of the executor: > cat setuid-test.c #include <stdio.h> #include <unistd.h> int ...
45
votes
2answers
49k views

Using the setuid bit properly

I have a process that needs root privileges when run by a normal user. Apparently I can use the "setuid bit" to accomplish this. What is the proper way of doing this on a POSIX system? Also, how ...
14
votes
2answers
17k views

Setuid bit seems to have no effect on bash

I was experimenting a bit and noticed something strange: setting the setuid bit on a copy of bash located at /usr/bin/bash-test seemed to have no effect. When I ran an instance of bash-test, my home ...
12
votes
5answers
13k views

How do I drop root privileges in shell scripts?

The "--up" option in OpenVPN is normally used for routing etc. And so it is processed before OpenVPN drops root privileges to run as nobody. However, I am invoking shell scripts that need to run as an ...
15
votes
1answer
20k 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:...
13
votes
1answer
4k views

root owned program with setuid bit on

Ping is a a program owned by root with the user id bit set. $ ls -l `which ping` -rwsr-xr-x 1 root root 35752 Nov 4 2011 /bin/ping As I understand it, if a user runs the ping process, then the ...
5
votes
2answers
4k views

setuid and setgid confusion

I'm trying to fully grasp the concept of setuid and setgid, and I'm not quite sure in what way permissions are actually elevated. Let me provide an example: Users userA (groups: userA groupA) userB (...
3
votes
1answer
793 views

SUID has no effect on directories with Linux

Why does the SUID bit have no effect when applied to directories in Linux? I clearly see that I can set it with 'chmod u+s'. But why does it not have "any" effect. What is the reason for implementing ...
35
votes
6answers
3k views

What is the safest way for programmatically writing to a file with root privileges?

A huge application needs, at one specific time, to perform a small number of writes to a file which requires root permissions. It is not really a file but a hardware interface which is exposed to ...
12
votes
4answers
14k views

How do real and effective user IDs work?

When a normal user wants to make change to the passwd file, the user will by setuid be given the effective user access. User becomes root temporarily and can edit passwd. However you can only edit ...
9
votes
2answers
8k views

Why setuid does not work on executable?

I know that enabling setuid on scripts has security issues and so is inactive by default, but expect that it works for executables. I created and executable which shows uid as an output following ...
9
votes
4answers
4k views

Which user's password does `sudo` asks for?

$ ls -l /usr/bin/sudo -rwsr-xr-x 1 root root 136808 Jul 4 2017 /usr/bin/sudo so sudo is runnable by any user, and any user who runs sudo will have root as the effective user ID of the process ...
26
votes
1answer
1k views

What would be the best way to work around this glibc problem?

I administer a Gentoo Hardened box that uses file capabilities to eliminate most of the need for setuid-root binaries (e.g. /bin/ping has CAP_NET_RAW, etc). Infact, the only binary I have left is ...
16
votes
2answers
16k views

Can gdb debug suid root programs?

I wrote a program that calls setuid(0) and execve("/bin/bash",NULL,NULL). Then I did chown root:root a.out && chmod +s a.out When I execute ./a.out I get a root shell. However when I do gdb ...
3
votes
1answer
3k views

Setuid, SUID bit not providing root privileges

I've written and compiled a short program to allow any user to change the contents of my /sys/class/backlight/intel_backlight/brightness file, but I fail to escalate their permissions. What could I be ...
0
votes
2answers
356 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 ...
24
votes
1answer
30k views

Difference between owner/root and RUID/EUID

I am relatively new to the concepts mentioned in the question and reading about them from different sources only makes them more confusing. So this is what I understood so far: When we are given ...
57
votes
2answers
139k views

What does the 's' attribute in file permissions mean? [duplicate]

Please compare the following two lines: -rws---r-x 1 root root 21872 2009-10-13 21:06 prg1 -rwx---r-x 1 root root 21872 2009-10-13 21:06 prg2 Does the setuid bit on prg1, along with the read and ...
11
votes
3answers
22k views

How does the set-user-ID mechanism work in Unix?

Can someone please explain the set-user-ID mechanism in Unix ? What was the rationale behind this design decision? How is it different from effective user id mechanism ?
8
votes
3answers
5k views

SetUID bit not working in Ubuntu?

I suppose an executable file with SetUID bit set should be running as its owner but I cannot really reproduce it. I tried the following. $ cat prepare.sh cp /bin/bash . chown root.root bash chmod ...
6
votes
1answer
643 views

How do I run a process that wants to become root from a systemd service which is a regular user?

I have a service that I start using systemd. The service user and group are changed to a non-privileged user. [Service] ... User=regular_user Group=regular_user ... At some point the service needs ...
6
votes
1answer
570 views

Why doesn't Ubuntu use capabilities on ping?

After running, $ ls -l /bin/ping -rwsr-xr-x 1 root root 34740 Nov 5 2012 /bin/ping I wonder, why doesn't Ubuntu use capabilities (i.e. raw sockets) rather than setuid?
6
votes
1answer
856 views

How does having /dev/fd make running shell scripts under sudo safe?

At the end of the man page for sudo, there's the following remark: Running shell scripts via sudo can expose the same kernel bugs that make setuid shell scripts unsafe on some operating systems ...
4
votes
2answers
803 views

linux setuid does not work

I am learning linux suid,so I have written a small c program with the following content to test it #include<stdio.h> int main(){ system("echo 100 >> test.txt"); return 0; } -rwsr-xr-x 1 ...
4
votes
1answer
3k views

Environment settings on setuid executables

I am observing a curious behavior when running a program with setuid bit enabled. Program foo is owned by user bar with setuid bit set. User execbar runs foo foo reports that one of the dynamic ...
3
votes
2answers
237 views

How to get users to set ACLs on directories they don't own?

I have a set of storage directories on Linux machines, all 770/root:root (perms/owner:group), for which I use ACLs to manage users access. (I am unable to use unix groups as the directories are shared ...
2
votes
3answers
9k views

What is required by a process to set its uid to 0 (root)?

I am completely new to *NIX based OSes. One of the things that baffles me is that a process or program may execute setuid(0) and then perform privileged operations and revert back to its normal uid. ...
8
votes
1answer
4k views

Why does ping need setuid permission? [duplicate]

I'm looking at a handful of files on my system with setuid permission on my system, by running: sudo find / -perm -4000 I noticed that /bin/ping shows up on the list. Can anyone explain why ping ...
6
votes
3answers
4k views

Changing the UID of files in /proc

In a follow up to this question about changing the UID of a user, it is recommended to change the ownership of all files on the system (this answer) find / -uid 1000 -exec chown 5000 '{}' \+ where ...
2
votes
1answer
2k views

How to suid iwconfig on Debian wheezy?

I have a script running under my own user account that takes care of all sorts of wireless interfaces. It (more or less) intelligently switches wireless LAN off and on and so forth. However, it does ...
2
votes
3answers
285 views

Why does FreeBSD require terminal programs to be started as root?

On FreeBSD all graphical terminal programs (e.g. xterm, rxvt) seem to be installed setuid root, or with setuid root wrappers. On Linux, this is not the case on any distribution I have ever used. Why ...
1
vote
1answer
3k views

Using find -perm to find setuid files

I want to find list of all suid binaries. I use the command find / -perm 4000 However this does not give me any output. I understand that the SUID file may be in 4xxx permission mode. But if I issue ...
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 " $(...
1
vote
1answer
657 views

How does android implement run-as without setuid

Earlier versions of Android have at run-as executable with the setuid flag set so it runs as root, but more recent versions do away with that. What changed? How can the shell user effect a user change?...
0
votes
1answer
492 views

Why can't unprivileged users nest FUSE mounts, but they can mount FUSE inside NFS with root_squash?

$ mkdir mnt $ bindfs /tmp mnt fusermount: option allow_other only allowed if 'user_allow_other' is set in /etc/fuse.conf $ bindfs --no-allow-other /tmp mnt $ mkdir /tmp/mnt2 $ bindfs --no-allow-...