variáveis de ambiente sudo desapareceram

0

Sintoma:

user1@ubuntu:~$ printenv PATH
/system/company/root/bin:/usr/lib/icecc/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/system/company/scripts:/opt/puppetlabs/bin
user1@ubuntu:~$ sudo su - user2
[sudo] password for user1: 
user2@ubuntu:~$ printenv PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/opt/puppetlabs/bin

arquivo / etc / environment:

PATH="/system/company/root/bin:/usr/lib/icecc/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/system/company/scripts"
COMPANY_ROOT="/system/company/root"
COMPANY_SCRIPTS_ROOT="/system/company/scripts"

visudo:

Defaults        env_reset
Defaults        env_keep += "PATH"
Defaults        env_keep += "COMPANY_ROOT"
Defaults        env_keep += "COMPANY_SCRIPTS_ROOT"
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

~ / .profile:

if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

Verificação adicional:

user1@ubuntu:~$ echo $COMPANY_ROOT
/system/COMPANY/root
user1@ubuntu:~$ sudo bash -c 'echo $COMPANY_ROOT'
[sudo] password for user1: 
/system/COMPANY/root

Por que as variáveis de ambiente desaparecem logo após o sudo? Eu já defini env_keep em visudo e / etc / environment arquivo ainda não vai.

    
por Thomas G. Lau 20.04.2017 / 05:19

0 respostas