Launching UI in logged in user context
Hi,
I am running Red Hat Linux 4. I have a program that gets started everytime when system gets up. The program runs with root privileges. In this program, I want to find who is currently logged in. What I want to do is to start the User interface process in logged in user mode. e.g. int main(int c, char *[]){ char *loggedUser = getenv("USER"); //Based on loggedUser value; execute further return 0; } Consider the following scenario; 1. Start the system, 2. Program will get loaded with root privilege, 3. logged in to the system with 'test' user (i.e. non -root), 4. command getenv("USER"), returns 'null' value, How come? 5. if root logs in, then getenv("USER") returns 'root' Is there any why to find who is currently logged within a process which is started by root? |
First of all, why you process runs under root ? It should use it's own user or the connected user.
|
The process must run under root as it needs some root privileges.
|
What about the 'who' cmd ?
|
Got it...
I am using 'w -ih'/'who' |
All times are GMT -5. The time now is 04:30 AM. |