[Sunhelp] Scripts - checking user

Walter Trush wtrush at uswest.com
Wed Jun 7 14:37:00 CDT 2000


Jeff,

chown user1 filename.

The only difference with su user1 & su - user1 is the - means
execute the user's .profile, environment, etc.

Try putting in your script;    cd ~user1 ; ./.profile

This will force user1 environment to be taken into the *sh.

Don't use $LOGNAME, use the id command and cut out the uid.
LOGNAME is only a variable which can be changed.

To be even more secure, try;

chmod 450 script             Make executable by group member 
chown root script            Only writable by root
chgrp (user1 group) script   Only that group can run script

Then within script do the id command and cut out the uid.
Then do an if [ $UID = $GOOD_UID ]  then continue...
in your script

Wally



"Kalusniak, Jeff" wrote:
> 
> Can anyone tell me the easiest way to verify the user running a script?
> In other words, I have a script that I want to always be run by user1.
> However,
> if user2 has su'd to user1 (su user1  instead of   su - user1), the LOGNAME,
> 
> etc are still held by user2.
> 
> I need the script to only be run as user1.
> 
> Thanks
> 
> Jeff Kalusniak
> Goliath Falls Inc.
> 
> _______________________________________________
> SunHELP maillist  -  SunHELP at sunhelp.org
> http://www.sunhelp.org/mailman/listinfo/sunhelp





More information about the SunHELP mailing list