setuid

Linux C programming execute as user

孤人 提交于 2021-02-06 08:51:14
问题 I have an program which I run as root. I would like the program to execute another application as a normal user. I tried setgid() and it works, but I can't then go back to root or another user. The program for the time being is very simple; #include <stdio.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char *argv[] ) { if ( argc != 2) { printf("usage: %s command\n",argv[0]); exit(1); } setgid(100); setuid(1000); putenv("HOME=/home/caroline"); putenv("DISPLAY=:0"); system(argv[1

Linux C programming execute as user

℡╲_俬逩灬. 提交于 2021-02-06 08:50:23
问题 I have an program which I run as root. I would like the program to execute another application as a normal user. I tried setgid() and it works, but I can't then go back to root or another user. The program for the time being is very simple; #include <stdio.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char *argv[] ) { if ( argc != 2) { printf("usage: %s command\n",argv[0]); exit(1); } setgid(100); setuid(1000); putenv("HOME=/home/caroline"); putenv("DISPLAY=:0"); system(argv[1

Linux C programming execute as user

我们两清 提交于 2021-02-06 08:50:20
问题 I have an program which I run as root. I would like the program to execute another application as a normal user. I tried setgid() and it works, but I can't then go back to root or another user. The program for the time being is very simple; #include <stdio.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char *argv[] ) { if ( argc != 2) { printf("usage: %s command\n",argv[0]); exit(1); } setgid(100); setuid(1000); putenv("HOME=/home/caroline"); putenv("DISPLAY=:0"); system(argv[1

Linux C programming execute as user

走远了吗. 提交于 2021-02-06 08:50:17
问题 I have an program which I run as root. I would like the program to execute another application as a normal user. I tried setgid() and it works, but I can't then go back to root or another user. The program for the time being is very simple; #include <stdio.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char *argv[] ) { if ( argc != 2) { printf("usage: %s command\n",argv[0]); exit(1); } setgid(100); setuid(1000); putenv("HOME=/home/caroline"); putenv("DISPLAY=:0"); system(argv[1

setuid on an executable doesn't seem to work

扶醉桌前 提交于 2020-05-27 04:01:58
问题 I wrote a small C utility called killSPR to kill the following processes on my RHEL box. The idea is for anyone who logs into this linux box to be able to use this utility to kill the below mentioned processes (which doesn't work - explained below). cadmn@rhel /tmp > ps -eaf | grep -v grep | grep " SPR " cadmn 5822 5821 99 17:19 ? 00:33:13 SPR 4 cadmn cadmn 10466 10465 99 17:25 ? 00:26:34 SPR 4 cadmn cadmn 13431 13430 99 17:32 ? 00:19:55 SPR 4 cadmn cadmn 17320 17319 99 17:39 ? 00:13:04 SPR 4

setuid on an executable doesn't seem to work

≯℡__Kan透↙ 提交于 2020-05-27 04:00:06
问题 I wrote a small C utility called killSPR to kill the following processes on my RHEL box. The idea is for anyone who logs into this linux box to be able to use this utility to kill the below mentioned processes (which doesn't work - explained below). cadmn@rhel /tmp > ps -eaf | grep -v grep | grep " SPR " cadmn 5822 5821 99 17:19 ? 00:33:13 SPR 4 cadmn cadmn 10466 10465 99 17:25 ? 00:26:34 SPR 4 cadmn cadmn 13431 13430 99 17:32 ? 00:19:55 SPR 4 cadmn cadmn 17320 17319 99 17:39 ? 00:13:04 SPR 4

setuid vs seteuid function

ぃ、小莉子 提交于 2020-01-03 11:45:24
问题 What is the difference between setuid and seteuid function. In man page both of the function have similar description. setuid: DESCRIPTION setuid() sets the effective user ID of the calling process. If the effective UID of the caller is root, the real UID and saved set-user-ID are also set. seteuid: DESCRIPTION seteuid() sets the effective user ID of the calling process. Unprivileged user processes may only set the effective user ID to the real user ID, the effective user ID or the saved set

How to set the setuid bit in a program of a non-root user?

天大地大妈咪最大 提交于 2020-01-03 04:55:31
问题 I am trying to make a python script executable with the setuid bit set. The program, belonging to user 'bgmc', must create some files in the directory '/home/bgmc', but is called by another user, 'client'. Indeed, I don't want user 'client' to change the files created by the program. I used a c-wrapper to call the program (see setuid on shell scripts): #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h> int main() { setuid(0); system("/home/bgmc/myprogram.sh");

correct way to run setuid programs in C

老子叫甜甜 提交于 2020-01-01 09:47:50
问题 I have a process with permissions 4750. Two users exist in my Linux system. The root user and the appz user. The process inherits the permissions of a process manager that runs as "appz" user. I have two basic routines: void do_root (void) { int status; status = seteuid (euid); if (status < 0) { exit (status); } } /* undo root permissions */ void undo_root (void) { int status; status = seteuid (ruid); if (status < 0) { exit (status); } status = setuid(ruid); if (status < 0) { exit (status); }

correct way to run setuid programs in C

谁都会走 提交于 2020-01-01 09:47:25
问题 I have a process with permissions 4750. Two users exist in my Linux system. The root user and the appz user. The process inherits the permissions of a process manager that runs as "appz" user. I have two basic routines: void do_root (void) { int status; status = seteuid (euid); if (status < 0) { exit (status); } } /* undo root permissions */ void undo_root (void) { int status; status = seteuid (ruid); if (status < 0) { exit (status); } status = setuid(ruid); if (status < 0) { exit (status); }