Bugzilla – Bug 272
servername disappears after sudo -s
Last modified: 2008-03-06 16:18:47 MST
Hi, I am running 1.6.8 on all my Solaris servers (8, 9 and 10). When I use sudo to become root the <username>@<servername> <pwd> prompt appears as normal. I have installed on a test server release 1.6.9p8 (downloaded from Sunfreeware). When you become root using sudo -s and as prompt of your own user you have <username>@<servername> <pwd> the <servername> disappears. Instead of weger@server /home > you get after sudo -s: root@ /home >. If I run my .profile after the sudo command the prompt is <username>@<servername> <pwd>. I have tested this on a solaris 5.8 and a solaris 5.10 system. My guess is that in my case this also works for solaris 5.9 Is this already known to you? Regards, Ernst de Weger Unix System Administrator Orange Netherlands NV
Chances are that the environment variable used in your prompt is not being preserved when you run sudo. Starting with sudo 1.6.9, commands run by sudo inherit a minimal environment instead of a copy of the caller's environment. Sudo will preserve the HOSTNAME environment variable by default but your prompt may be using something else. If you look in your .profile you can probably figure out what that is. Then you can add a line like the following to the top of your sudoers file. Default env_keep += HOST replacing HOST with whatever the environment variable you need to preserve really is. Another alternative is to use "sudo -i" instead of "sudo -s". Unlike -s, -i will run a login shell which will source the .profile of the target user.
This is almost certainly an environment variable issue.