setuid

RealUID, Saved UID, Effective UID. What's going on?

元气小坏坏 提交于 2019-11-27 09:11:23
问题 This is a set-root-uid program $ls -l -rwsr-sr-x 1 root root 7406 2011-12-13 22:37 ./x* The source code: int main(void) { printf( " UID GID \n" "Real %d Real %d \n" "Effective %d Effective %d \n", getuid (), getgid (), geteuid(), getegid() ); seteuid(600); printf( " UID GID \n" "Real %d Real %d \n" "Effective %d Effective %d \n", getuid (), getgid (), geteuid(), getegid() ); setuid(1000); printf( " UID GID \n" "Real %d Real %d \n" "Effective %d Effective %d \n", getuid (), getgid (), geteuid(

Setuid bit on python script : Linux vs Solaris

我与影子孤独终老i 提交于 2019-11-27 04:37:23
问题 I am running this small python script on both linux and Solaris as a not privileged user : #!/usr/bin/python import os print 'uid,euid =',os.getuid(),os.geteuid() Before running, the setuid bit is set on the script (not on python interpreter) : chown root:myusergrp getuid.py chmod 4750 getuid.py On Solaris, the effective uid is set because of the setuid bit : uid,euid = 10002 0 But not on Linux : uid,euid = 10002 10002 Note the python version is 2.6 for both Solaris and Linux Is it possibe to

Calling a script from a setuid root C program - script does not run as root

大憨熊 提交于 2019-11-27 00:46:08
I need to run a bash script as root (passwordless sudo or su not viable) and since you cannot setuid a script in Linux, I thought about calling it from an executable and making it setuid: $ cat wrapper.c int main(void) { system("/bin/bash ./should_run_as_root.sh"); } $ gcc -o wrapper wrapper.c $ sudo chown root wrapper $ sudo chmod ug+s wrapper $ ll wrapper -rwsr-sr-x 1 root users 6667 2009-02-17 11:11 wrapper $ This works - as in runs the script correctly - but the script runs as the user who executes "./wrapper". Why? And how to correctly implement this? Thanks! Since the suid bit on

Calling a script from a setuid root C program - script does not run as root

不羁岁月 提交于 2019-11-26 09:27:23
问题 I need to run a bash script as root (passwordless sudo or su not viable) and since you cannot setuid a script in Linux, I thought about calling it from an executable and making it setuid: $ cat wrapper.c int main(void) { system(\"/bin/bash ./should_run_as_root.sh\"); } $ gcc -o wrapper wrapper.c $ sudo chown root wrapper $ sudo chmod ug+s wrapper $ ll wrapper -rwsr-sr-x 1 root users 6667 2009-02-17 11:11 wrapper $ This works - as in runs the script correctly - but the script runs as the user

Run child processes as different user from a long running Python process

怎甘沉沦 提交于 2019-11-26 06:05:37
问题 I\'ve got a long running, daemonized Python process that uses subprocess to spawn new child processes when certain events occur. The long running process is started by a user with super user privileges. I need the child processes it spawns to run as a different user (e.g., \"nobody\") while retaining the super user privileges for the parent process. I\'m currently using su -m nobody -c <program to execute as a child> but this seems heavyweight and doesn\'t die very cleanly. Is there a way to