Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

A script that requires root privileges needs to be executed when a non-root privileged user signs in/out. How do I handle this?

share|improve this question

2 Answers

Use the PAM session hooks module.

share|improve this answer
Thats useful. Now, some of operations in which I want to apply should be done before the memory is allocated for user account. And, the operations need to be done after the user account memory is fully deallocated. When does PAM actually trigger the scripts in concern with user account memory allocation/deallocation? One operation I intend to run is sdmem, which cleans the available ram. I need users who sign out to be cleaned up this way. – bambuntu Feb 7 '12 at 1:18
Linux doesn't allocate memory "for a user account" or at login time. Memory is allocated as new processes start. If you run this script from pam hooks, it will start before the user is able to run any programs. – poolie Feb 7 '12 at 1:59

PAM looked a bit intimidating. I actually stumbled upon a way to solve this while trying to solve another problem. Upstart scripts. I was able to write a simple script that ran as root for non-root users when they logged in.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.