User switching without carrying over LC_CTYPE env variable

I am using Solaris8, userA's shell '/usr/ace/prog/sdshell', AppuserB's shell '/bin/ksh'.

serverT:/home/userA>LC_CTYPE=iso_8859_1; export LC_CTYPE; vtemp='userA variable'; export vtemp   
 
serverT:/home/userA>echo "LC_CTYPE=$LC_CTYPE, vtemp=$vtemp";
LC_CTYPE=iso_8859_1, vtemp=userA variable
 
serverT:/home/userA>sudo /usr/bin/su - AppuserB
Password:
 
serverT:/export/apps/AppuserB> echo "LC_CTYPE=$LC_CTYPE, vtemp=$vtemp"
LC_CTYPE=iso_8859_1, vtemp=

I am switching from userA's account to AppuserB's using 'sudo /usr/bin/su - AppuserB'. This is not bringing any of 'userA' environment variables except 'LC_CTYPE' over to 'AppuserB' account. What tells sudo to bring this variable over? How can I prevent this? Is there a way to make sure none of userA's env variables get carried over to userB's including these system variables !!?

I have no Solaris expertise, but perhaps the env variable could be set by /etc/ksh.kshrc or $HOME/.kshrc.

Regards,
Alister

My problem is not how to set 'LC_CTYPE' env variable. I have say 10 different applications running on 10 different Unix app.Accounts. I want operations members to be able to sudo to these Unix accounts without bringing un-wanted env settings along when they switch to application accounts using 'sudo'. 'sudo /usr/bin/su - <user>' does that, except for 'LC_CTYPE', I want to know why and prevent that.

I checked in AppuserB's .kshrc, .profile and all his local .* files I could not find anything setting LC_CTYPE.
Checked all files under /etc/ folder if something is telling 'LC_CTYPE' to get forwarded when doing sudo, so far I did not find anything.

I understood. Perhaps I should have said "perhaps the env variable could be being set by".

Did you check sudoers for env_keep?

If you also thought of that and other possibilities, please list what you've considered in detail to save everyone time.

Regards,
Alister

1 Like

I asked our root to check /usr/local/etc/sudoers file and env_keep variable.. he could not find anything related to LC_CTYPE or 'env_keep'.