LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 08-22-2011, 06:23 AM   #1
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: SLED, openSUSE
Posts: 1,022

Rep: Reputation: 172Reputation: 172
pam_exec run script as user that's logging in


I've got pam_exec calling a script from the session part of the pam stack. The script runs as root. Does anyone know how to make the script run as the user that's logging in?

I can make a script that runs as root run a script as $PAM_USER using su
Code:
su - ${PAM_USER} -c /path/to/a/script
but that seems inelegant.

What I'm specifically trying to achieve at the moment is to access the DESKTOP_SESSION environment variable of the user that's logging in so I can see what desktop environment they're using.

Edit @ Mon Aug 22 14:10:30 BST 2011
Accessing DESKTOP_SESSION via su isn't possible because it's not set it's not set in the session that's created by su! Doh. Original question on how to run the script as the user that's logging in stands...

Last edited by arizonagroovejet; 08-22-2011 at 08:12 AM.
 
Old 08-22-2011, 08:39 PM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,261

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
I don't think that's set until after login ie after PAM.
How about checking during /etc/profile ?
 
Old 08-23-2011, 02:59 AM   #3
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: SLED, openSUSE
Posts: 1,022

Original Poster
Rep: Reputation: 172Reputation: 172
Quote:
Originally Posted by chrism01 View Post
How about checking during /etc/profile ?
Yeah that's doable. Forget finding DESKTOP_SESSION though, I can get to that via means other than a pam_session script.

I still want to know if it's possible to make pam_exec run the script with the permissions of the user that's logging in. pam_script appears to be able to do it but I'd rather use pam_exec since it's supplied as part of pam.
 
  


Reply

Tags
pam, pam_exec


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run a script as any user Hi_This_is_Dev Linux - General 5 09-26-2010 08:57 AM
Logging out a user account within a script kaplan71 Linux - Software 2 03-14-2009 12:07 AM
how do I make sure that the user that is going to run the script is a root user??? nikold01 Linux - General 3 09-10-2004 07:54 AM
Allow user to run their own cgi script samwong Linux - Newbie 5 05-25-2004 10:22 PM
Run a script as a different user dtheorem Programming 5 11-05-2003 05:57 PM


All times are GMT -5. The time now is 12:05 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration