You are not logged in.

#1 2011-03-05 14:44:41

nTia89
Banned
From: varese, italy
Registered: 2008-12-22
Posts: 1,230

[solved] export problem

hi to all

i put in my .bashrc some exported variables, like:

export EDITOR='nano'

but if i run

sudo visudo

, exported editor is ignored  !!!

why ?, how can i solve this ?

thanks

Last edited by nTia89 (2011-03-05 18:03:17)


+pc: custom | AMD Opteron 175 | nForce4 Ultra | 2GB ram DDR400 | nVidia 9800GT 1GB | ArchLinux x86_64 w/ openbox
+laptop: Apple | MacBook (2,1) | 2GB ram | Mac OS X 10.4 -> DIED
+ultrabook: Dell | XPS 13 (9343) | 8GB ram | 256GB ssd | FullHD display | Windows 8.1 64bit ArchLinux x86_64 w/ Gnome

Offline

#2 2011-03-05 14:52:00

loafer
Member
From: the pub
Registered: 2009-04-14
Posts: 1,772

Re: [solved] export problem

Shouldn't it be:

 export EDITOR=nano

All men have stood for freedom...
For freedom is the man that will turn the world upside down.
Gerrard Winstanley.

Offline

#3 2011-03-05 15:00:41

nTia89
Banned
From: varese, italy
Registered: 2008-12-22
Posts: 1,230

Re: [solved] export problem

yes, yes .... a mistake in the post, not in my .bashrc

edited the first post

Last edited by nTia89 (2011-03-05 15:02:07)


+pc: custom | AMD Opteron 175 | nForce4 Ultra | 2GB ram DDR400 | nVidia 9800GT 1GB | ArchLinux x86_64 w/ openbox
+laptop: Apple | MacBook (2,1) | 2GB ram | Mac OS X 10.4 -> DIED
+ultrabook: Dell | XPS 13 (9343) | 8GB ram | 256GB ssd | FullHD display | Windows 8.1 64bit ArchLinux x86_64 w/ Gnome

Offline

#4 2011-03-05 16:24:12

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved] export problem

man visudo wrote:

       There is a hard-coded list of one or more editors that visudo will use set at compile-time that may be
       overridden via the editor sudoers Default variable.  This list defaults to "/usr/bin/vi".  Normally, visudo
       does not honor the VISUAL or EDITOR environment variables unless they contain an editor in the aforementioned
       editors list.  However, if visudo is configured with the --with-env-editor option or the env_editor Default
       variable is set in sudoers, visudo will use any the editor defines by VISUAL or EDITOR.  Note that this can
       be a security hole since it allows the user to execute any program they wish simply by setting VISUAL or
       EDITOR.

Offline

#5 2011-03-05 17:17:42

nTia89
Banned
From: varese, italy
Registered: 2008-12-22
Posts: 1,230

Re: [solved] export problem

yes but if i explitly run

sudo EDITOR=nano visudo

it works ......


+pc: custom | AMD Opteron 175 | nForce4 Ultra | 2GB ram DDR400 | nVidia 9800GT 1GB | ArchLinux x86_64 w/ openbox
+laptop: Apple | MacBook (2,1) | 2GB ram | Mac OS X 10.4 -> DIED
+ultrabook: Dell | XPS 13 (9343) | 8GB ram | 256GB ssd | FullHD display | Windows 8.1 64bit ArchLinux x86_64 w/ Gnome

Offline

#6 2011-03-05 17:23:46

loafer
Member
From: the pub
Registered: 2009-04-14
Posts: 1,772

Re: [solved] export problem

Maybe create an alias:

alias visudo="sudo EDITOR=nano visudo"

All men have stood for freedom...
For freedom is the man that will turn the world upside down.
Gerrard Winstanley.

Offline

#7 2011-03-05 17:28:29

rwd
Member
Registered: 2009-02-08
Posts: 664

Re: [solved] export problem

For security reasons environment variables that you define as non-root user are ignored when you sudo. If you want to keep certain environment variables when sudo-ing  you need to name them in /etc/sudoers on the line with  'env_keep'. See man sudo.

Last edited by rwd (2011-03-05 17:41:29)

Offline

#8 2011-03-05 17:28:55

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved] export problem

loafer wrote:

Maybe create an alias:

alias visudo="sudo EDITOR=nano visudo"

+1


Edit: See rwd's post.

Last edited by karol (2011-03-05 17:29:31)

Offline

#9 2011-03-05 18:02:57

nTia89
Banned
From: varese, italy
Registered: 2008-12-22
Posts: 1,230

Re: [solved] export problem

rwd wrote:

For security reasons environment variables that you define as non-root user are ignored when you sudo. If you want to keep certain environment variables when sudo-ing  you need to name them in /etc/sudoers on the line with  'env_keep'. See man sudo.

thanks, this is the answer


+pc: custom | AMD Opteron 175 | nForce4 Ultra | 2GB ram DDR400 | nVidia 9800GT 1GB | ArchLinux x86_64 w/ openbox
+laptop: Apple | MacBook (2,1) | 2GB ram | Mac OS X 10.4 -> DIED
+ultrabook: Dell | XPS 13 (9343) | 8GB ram | 256GB ssd | FullHD display | Windows 8.1 64bit ArchLinux x86_64 w/ Gnome

Offline

Board footer

Powered by FluxBB