Linux C programming execute as user
问题 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