User switching without carrying over LC_CTYPE env variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting User switching without carrying over LC_CTYPE env variable
# 1  
Old 04-24-2013
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'.

Code:
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 !!?

Last edited by kchinnam; 04-24-2013 at 04:39 PM.. Reason: correction to example
# 2  
Old 04-24-2013
I have no Solaris expertise, but perhaps the env variable could be set by /etc/ksh.kshrc or $HOME/.kshrc.

Regards,
Alister
# 3  
Old 04-24-2013
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.

Last edited by kchinnam; 04-24-2013 at 04:45 PM.. Reason: corrected explanation
# 4  
Old 04-24-2013
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
This User Gave Thanks to alister For This Post:
# 5  
Old 04-24-2013
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'.

Last edited by kchinnam; 04-24-2013 at 05:22 PM.. Reason: status update.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Switching to user to stop db

Hi all, I have a script that I will need to run occasionally to stop my db2 instance- stopDB2.sh su -l -c "db2 force application all" su -l -c "db2 terminate" su -l -c "db2 stop" su -l -c "db2licd -end" This works when I su to the instance owner (archive), and run each line. I need to... (5 Replies)
Discussion started by: jeffs42885
5 Replies

2. UNIX for Dummies Questions & Answers

Switching from root to normal user takes me to user's home dir

Whenever i switch from root to another user, by doing su - user, it takes me to home directory of user. This is very annoying as i want to be in same dir to run different commands as root sometimes and sometimes as normal user. How to fix this? (1 Reply)
Discussion started by: syncmaster
1 Replies

3. Web Development

Deny from env=env-variable Does not work

(Above from Apache docs). On my system, using: SetEnvIf User-Agent Mozilla IsBad=1 Order allow,deny Allow from all Deny from env=IsBad ...I see that environment variable is set (using phpinfo()) but the page is still served. No errors in the Apache logs. (1 Reply)
Discussion started by: gnurob
1 Replies

4. UNIX for Dummies Questions & Answers

Switching user

I need to do a switch user in an automated mode and do a ftp using that switched id. Scenario: initial login xx. switch to user-yy without manually entering the password. ftp some files from user yy to another user zz - automated mode. Can any unix experts can help me for my above query? (9 Replies)
Discussion started by: mjdarm
9 Replies

5. UNIX for Advanced & Expert Users

Switching user in AIX 5

I need to do a switch user in an automated mode and do a ftp using that switched id. Scenario: initial login xx. switch to user-yy without manually entering the password. ftp some files from user yy to another user zz - automated mode. Can any unix experts can help me for my above query? (1 Reply)
Discussion started by: mjdarm
1 Replies

6. Shell Programming and Scripting

su (switching to other user)

Hi, what is the use of the double quotes and !! in the following code segment: su - user1 << ""!! > /dev/null 2>&1 echo "welcome user1" EOF !! also what is the difference between below: su - user1 << ""!! > /dev/null 2>&1 and su - $USER << ""!!!> /dev/null 2>&1. Note: $USER =... (2 Replies)
Discussion started by: bjagadeesh
2 Replies

7. Shell Programming and Scripting

su (switching to other user)

Hi, what is the use of the double quotes and !! in the following code segment: su - user1 << ""!! > /dev/null 2>&1 echo "welcome user1" EOF !! also what is the difference between below: su - user1 << ""!! > /dev/null 2>&1 and su - $USER << ""!!!> /dev/null 2>&1. Note: $USER =... (1 Reply)
Discussion started by: bjagadeesh
1 Replies

8. Shell Programming and Scripting

switching user from root to ordinary user

Good day Guys!!! I am currently making a script in AIX, the script runs a SAS job, the owner of the script is the root, but the SAS jobs cannot be run by the root, as it should be run by a user 'sasia'. But inside the script, root creates a logfile, so what I need is just to su to sasia for the... (3 Replies)
Discussion started by: sasia
3 Replies

9. Shell Programming and Scripting

switching between root and a normal user

I am writing a script that has some tasks that must be run as root, then set of tasks to be run as normal user, then again as root. is there a way to switch between users in a script? any other alternatives? thx (3 Replies)
Discussion started by: melanie_pfefer
3 Replies

10. UNIX for Dummies Questions & Answers

Switching to single-user mode

Hello everyone, I need to make a OS full backup. I am using the vdump command but first, I must to switch to the single-user mode. I am working on a Compaq Tru64 Unix V4.0G. Please, could somebody tell me which is/are the commands to do it? I appreciate your help Gastón (1 Reply)
Discussion started by: gmoyano
1 Replies
Login or Register to Ask a Question