PDA

View Full Version : [ubuntu] have sudo keep enviromental variables (.bashrc)



pspsampsp
April 24th, 2009, 03:40 AM
my question is in the title , i think i know how but i just want to check:

if this is my sudo file below



# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root ALL=(ALL) ALL

# Uncomment to allow members of group sudo to not need a password


would i remove: Defaults env_reset ?

Hospadar
April 24th, 2009, 03:48 AM
Well, just for peace of mind, I would comment it out with a #
But yeah, I think you can remove it and sudo should work fine, if not, livecd and change it back.

That said, there might I suppose be some security concern if a program run as sudo sets an environment variable thinking that it is private since it's running as root, and then that value getting out into non-root land (or the other way around)

If you just have a couple specific environment variables you need to have set (or aliases, or whatever), you can put those into /root/.bashrc and that should work fine.

pspsampsp
April 24th, 2009, 03:53 AM
ive put them in /root/.bashrc but they only work when using su not sudo any one else got ideas?

duanedesign
April 24th, 2009, 03:59 AM
One of sudo’s security features makes sure your parent environment is cleaned before dropping down to root. Generally you want this! But if you do not.

You can instruct sudo to keep specific environmental variables (in /etc/sudoers):

Defaults env_keep=”variables”

Defaults env_reset

pspsampsp
April 24th, 2009, 04:52 AM
quick question just to be sure , would i add multiple variables like :
Defaults env_keep=”variable1”
Defaults env_keep=”variable2”
Defaults env_reset

if not how?

duanedesign
April 24th, 2009, 04:56 AM
If I were passing Var_1 and Var_2


Defaults env_keep=”Var_1 Var_2”
Defaults env_reset


Good Luck

pspsampsp
April 24th, 2009, 04:59 AM
ok thanks

ULeeC
September 14th, 2011, 09:09 PM
One of sudo’s security features makes sure your parent environment is cleaned before dropping down to root. Generally you want this! But if you do not.

You can instruct sudo to keep specific environmental variables (in /etc/sudoers):

Defaults env_keep=”variables”

Defaults env_reset

Thanks a lot. that's what i'm looking for :)

oldos2er
September 15th, 2011, 01:38 AM
Back to sleep, poor tired thread. Closed.