Visit The New, Modern Unix Linux Community

Setuid Program with (-rwsr-sr-x 1 root other ) UID/EUID issue

Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Setuid Program with (-rwsr-sr-x 1 root other ) UID/EUID issue
# 1  
Setuid Program with (-rwsr-sr-x 1 root other ) UID/EUID issue


I have a program with the following suid setup
-rwsr-sr-x 1 root other 653 Aug 16 17:00 restart_server

It basically starts up a service that has to be started by root. I just want the normal users to be able to restart the service using the script above.

But when the servers are restarted, when i do a ps -ef , they show the username of the user who runs the script and not as root, in the first column.

How can I solve this issue. as the server will only work as expected if it runs as root and the above setuid setup ps -ef | greps to username and not root.

Please advise


Last edited by 0ktalmagik; 08-16-2006 at 10:21 PM..
# 2  
Are you actually calling the setuid() system call inside that code? If you are not and are only setting the setuid bit on the file, then only the euid is set to root. The difference is seen here:
int main() {          
   fprintf(stdout,"euid: %d",geteuid());
   fprintf(stdout,"uid: %d",getuid());

int main() {          
   fprintf(stdout,"euid: %d",geteuid());
   fprintf(stdout,"uid: %d",getuid());

Complie both the codes, set the suid flag and run them. The id and the whoami commands should show you the difference.

It is most likely that the code that you are using has not used the setuid call.
# 3  

Its a shell script. rws by root, r_s by group named "other" and r_x by all others.

How can i set the uid from inside a setuid program. please let me know.

Also I dont have a c compiler on the system.
# 4  
OK, what system are you using? Quite a few systems do not honour the setuid bit on the shell script, as they (setuid scripts) are considered a security hazard.
# 5  

Im running Solaris 9 32 bit on a sparc-64 bit system.

# 6  
Then it wont work... Solaris does not honour the setuid bit on shell scripts so your program will not run as root.
# 7  
any workarounds??

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #727
Difficulty: Medium
Radia Perlman Invented the Spanning Tree Protocol (STP).
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

What keeps me from abusing setuid(0) and programs with setuid bit set?

Just learning about the privilege escalation method provided by setuid. Correct me if I am wrong but what it does is change the uid of the current process to whatever uid I set. Right ? So what stops me from writing my own C program and calling setuid(0) within it and gaining root privileges ? ... (2 Replies)
Discussion started by: sreyan32
2 Replies

2. UNIX for Dummies Questions & Answers

Can you gain root privileges if the suid program does not belong to root?

I had a question in my test which asked where suppose user B has a program with 's' bit set. Can user A run this program and gain root privileges in any way? I suppose not as the suid program run with privileges of owner and this program will run with B's privileges and not root. (1 Reply)
Discussion started by: syncmaster
1 Replies

3. Shell Programming and Scripting

Find users with root UID or GID or root home

I need to list users in /etc/passwd with root's GID or UID or /root as home directory If we have these entries in /etc/passwd root:x:0:0:root:/root:/bin/bash rootgooduser1:x:100:100::/home/gooduser1:/bin/bash baduser1:x:0:300::/home/baduser1:/bin/bash... (6 Replies)
Discussion started by: anil510
6 Replies

4. AIX

Equivalent uid to root

Hi all I have a strange problem on one my my AIX machines. We have created a user called testroot with the same UID as root (uid=0) by changing the uid of that user in the /etc/passwd file. I know that this is a security breach but this is a test system. Now the strange thing that happens is that... (3 Replies)
Discussion started by: abohmeed
3 Replies

5. Solaris

New root account with Different UID number

Hi Unix Gurus . I have requirement where in which - I would like create duplicate root equivalent account with all the privileges equal to root. Is it possible to create this duplicate account with different UID. ? this id i would like give it to my teams - who does multiple activities using... (2 Replies)
Discussion started by: johnavery50
2 Replies

6. Solaris

rbac and execution attributes (uid and euid)

Hi all, I have a question to see if I understand the euid and uid attributes correctly for rbac (/etc/security/exec_attr): All: * Audit Control: /etc/init.d/audit euid=0, egid=3 /etc/security/bsmconv uid=0 /etc/security/bsmunconv uid=0 /usr/sbin/audit euid=0 /usr/sbin/auditconfig... (6 Replies)
Discussion started by: deadeyes
6 Replies

7. AIX

sudo must be setuid root.

Guy's I'm trying to add some lines in sudo by useing this command visudo # User privilege specification root ALL=(ALL) ALL # Uncomment to allow people in group wheel to run all commands # %wheel ALL=(ALL) ALL # Same thing without a password # %wheel ALL=(ALL) NOPASSWD: ALL #... (5 Replies)
Discussion started by: ITHelper
5 Replies

8. Solaris

EUID set for all non-root users

We have a Solaris box. I noticed that whenever any non-root user logins into the box and issues the command id the output is (for example) uid=42568(sam) gid=1245(sam) euid=0(root) egid=2(bin). I have not given any privileges to anyone explicitly. When I issued ls -l in the /usr/bin directory I... (1 Reply)
Discussion started by: chrisanto_2000
1 Replies

9. UNIX for Dummies Questions & Answers

To:blowtorch - Setuid uid/euid issue

Hi, Its a shell script. rws by root, r_s by group named "other" and r_x by all others. How can i set the uid from inside a setuid program. please let me know. Also I dont have a c compiler on the system. Thanks Reply With Quote (0 Replies)
Discussion started by: 0ktalmagik
0 Replies

10. UNIX for Dummies Questions & Answers

Setuid root and chown

I am trying to run chown and chmod from a script owned by root. The permissions are set to 4755 so that users can execute the script as root. However, when I run the script as a user other than root, I get "Operation not permitted" for both chown and chmod. Any ideas as to why this is? (6 Replies)
Discussion started by: johnmsucpe
6 Replies

Featured Tech Videos