You are not logged in.

#1 2011-12-08 21:05:30

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,965
Website

[solved] hook to run commands when user logs in? (before bash profile)

Is there any way to run commands when a user logs in but before the bash profile is sourced?

For example, I have a user account with a home directory on /tmp. When the user logs in, the home directory might not exist so there will be no .bash_profile to source. I want to run a script to create the directory if necessary and copy some files into it. How can that be done?

I thought of putting something in /etc/profile or /etc/profile.d/, but I would like to run something before the user's shell and environment become active.

I can use /etc/rc.local to do what I want, but I would prefer a hook to ensure that everything is set right when the user logs in.

Any ideas?


*edit*
Solution
In my case, I found that I could write my own shell script and set it as a login shell. In the script, I can configure everything I need before launching the interactive shell, then clean up anything after it exits.

Last edited by Xyne (2011-12-10 19:34:07)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#2 2011-12-08 23:24:03

dammannj
Member
Registered: 2009-01-28
Posts: 44

Re: [solved] hook to run commands when user logs in? (before bash profile)

Take a look at 'man pam_exec'.
Maybe that is what you are looking for.

Offline

#3 2011-12-10 19:36:02

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,965
Website

Re: [solved] hook to run commands when user logs in? (before bash profile)

Thanks, dammannj. PAM could probably do what I need but I think I have found a simpler solution (see original post).


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

Board footer

Powered by FluxBB