LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-25-2009, 03:28 AM   #1
logforlinux
LQ Newbie
 
Registered: Feb 2009
Posts: 14

Rep: Reputation: 0
Question 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?
 
Old 06-26-2009, 12:03 PM   #2
Fantasio
Member
 
Registered: Nov 2007
Location: Vinsobres - Drome - France
Distribution: SuSE Linux 11.3
Posts: 152

Rep: Reputation: 19
First of all, why you process runs under root ? It should use it's own user or the connected user.
 
Old 06-29-2009, 12:45 AM   #3
logforlinux
LQ Newbie
 
Registered: Feb 2009
Posts: 14

Original Poster
Rep: Reputation: 0
The process must run under root as it needs some root privileges.
 
Old 06-29-2009, 01:40 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
What about the 'who' cmd ?
 
Old 06-30-2009, 12:52 AM   #5
logforlinux
LQ Newbie
 
Registered: Feb 2009
Posts: 14

Original Poster
Rep: Reputation: 0
Got it...

I am using 'w -ih'/'who'
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Gnome: Auto mounting external devices as first user logged in, not current user yitzle Linux - Software 4 04-01-2008 10:43 AM
How can I get the context info for a thread/process running in user mode? LostInLinux4ever Programming 1 05-23-2007 05:00 PM
Multi-user and 3D sharing, 3D only works for the first logged in user foxy123 SUSE / openSUSE 0 02-20-2005 05:31 AM
Launching apps under Root User Name MDBlueIce Linux - Software 2 08-20-2004 06:15 AM
mozilla works fine when logged in as a user but crashes when logged in as root jimi Linux - General 6 04-02-2003 09:34 PM


All times are GMT -5. The time now is 09:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration