Operating System - HP-UX
1829005 Members
2665 Online
109986 Solutions
New Discussion

Change PATH based on group membership

 
SOLVED
Go to solution

Change PATH based on group membership

Is there a generally accepted way to change a user's PATH based upon his group memberships? I could add lines to each user's .profile, or do something like this in /etc/profile:

[ grep -q "^GRP:[:,]USRNAME[,$] /etc/groups ] && PATH=$PATH:/blah/blah/blah

Both of these seem kludgy to me.

Any better ideas floating around out there?

Thanks!

Dave (SOL in Lawrence)
Listen to their words, but watch their feet.
4 REPLIES 4
harry d brown jr
Honored Contributor

Re: Change PATH based on group membership


You could execute different profiles but your method is easier to maintain.

live free or die
harry
Live Free or Die
Jordan Bean
Honored Contributor
Solution

Re: Change PATH based on group membership


I'm concidering using something like this in /etc/profile:

PATH=$(cat /etc/PATH)
# append paths per group membership
for g in $(id -Gn)
do
case $g in
(emc) PATH=${PATH}:/usr/symcli/bin; MANPATH=${MANPATH}:/usr/symcli/man;;
(oracle) PATH=${PATH}:/usr/oracle/bin;;
(lawson) PATH=${PATH}:/usr/lawson/bin;;
esac
done

Wodisch
Honored Contributor

Re: Change PATH based on group membership

Hi Dave,

not really elegant, but simple:

Different directories containing soft-links to the codefiles permitted for each group.
Then give read/execute permission on that directory only to that group.
Finally put all these directories into $PATH (but only these).

FWIW,
Wodisch

Re: Change PATH based on group membership

I will go with Jordan's method, with one addition: Since this will fail in single user mode (/usr/bin/id wont be available), I'll put the code inside an if [-x /usr/bin/id] statement.

Thanks to all for your help.
Listen to their words, but watch their feet.