OCI: Sudo Command Returns "sorry, you are not allowed to preserve the environment" error
Applies To:
Oracle Cloud Infrastructure
Oracle Linux
Symptoms
Running sudo
command with "-E" option reports the following error.
$ export MY_NAME=abcd $ sudo -E bash -c 'echo $MY_NAME' sudo: sorry, you are not allowed to preserve the environment
The following sudo rule exists for the user in /etc/sudoers
file.
oracle ALL=(ALL) NOPASSWD: /usr/bin/bash
Cause
The sudo rule has not defined to present the environment variables of the user.
Solution
Add SETENV
tag to the user sudo rule entry to fix the issue.
#visudo oracle ALL=(ALL) NOPASSWD:SETENV: /usr/bin/bash *
Tagged:
0