What should I do with the password? - homebrew

I tried to install the homebrew and I tried to put my computer password for the 'password' command. But I don't know why I even can't type one word or one number in terminal.
I tried to type my password but it didn't work.
Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod u+rwx /usr/local/bin /usr/local/include /usr/local/lib /usr/local/share /usr/local/lib/pkgconfig /usr/local/share/info /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5
Password:
Sorry, try again.
Password:

Related

Build HDFView 3.1 on ubuntu-20.04

I have downloaded the deb file from the https://support.hdfgroup.org/ftp/HDF5/releases/HDF-JAVA/hdfview-3.1.2/bin/ link and install it via
sudo dpkg -i hdfview_3.1.2-1_amd64.deb
I didn't see any error during installation.
But hdfview didn't open.
I am using java-1.11.0-openjdk and hdf5-1.10.
How to solve this problem?
I found a way to solve this. The program gets installed in /opt/hdfview. However, starting it causes the error
$ ./bin/HDFView
Error: dl failure on line 534
Error: failed /opt/hdfview/lib/runtime/lib/server/libjvm.so, because /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /opt/hdfview/lib/runtime/lib/server/libjvm.so)
Failed to launch JVM
We can fix this by patching the libjvm.so file:
Install java-15 if it is not present already:
sudo apt install openjdk-15-jre
Find the libjvm.so file:
cd /usr/lib
find . -name libjvm.so
In my case, the correct version is located in /usr/lib/jvm/java-15-openjdk-amd64/lib/server/libjvm.so
Replace the libjvm.so in hdfview with a symlink to this libjvm.so
cd /opt/hdfview/lib/runtime/lib/server
sudo mv libjvm.so libjvm.so.bak
sudo ln -s /usr/lib/jvm/java-15-openjdk-amd64/lib/server/libjvm.so libjvm.so
(optional) link the hdfview binary, so that it is found in the terminal
sudo ln -s /opt/hdfview/bin/HDFView /usr/local/bin/hdfview
Afterwards, you should be able to start hdfview both from the terminal and the icon.

how to fix never ending password request with homebrew

I'm trying to run brew upgrade, and when trying to uninstall a jdk package, it keeps asking for my password, taking it, and then asking for it again and again and never making progress. I am just wondering what's going on here and how to fix it?
(base) user#computer: ~ $
> brew upgrade
==> Casks with `auto_updates` or `version :latest` will not be upgraded
==> Upgrading 1 outdated package:
adoptopenjdk8 8,242:b08 -> 8,272:b10
==> Upgrading adoptopenjdk8
==> Downloading https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u272-b10/OpenJDK8U-jdk_x64_mac_hotspot_8u272b10.pkg
Already downloaded: /Users/me/Library/Caches/Homebrew/downloads/91154181533f41bf699ae50474345f17a588dd0524ba21698eed51461b2fdcdb--OpenJDK8U-jdk_x64_mac_hotspot_8u272b10.pkg
==> Verifying SHA-256 checksum for Cask 'adoptopenjdk8'.
==> Uninstalling packages:
net.adoptopenjdk.8.jdk
Password: # <- I entered my password here
Password: # <- and here
Password: # <- I tried entering it 10 times, WTF?
DEBUG OUTPUT
after adding the debug options, it looks like a new sudo command is being run at each password request... how many there are I wonder
> HOMEBREW_DEBUG=1 HOMEBREW_VERBOSE=1 brew upgrade
...
# many preamble lines left out, before ending with this:
==> Casks with `auto_updates` or `version :latest` will not be upgraded
==> Upgrading 1 outdated package:
adoptopenjdk8 8,242:b08 -> 8,275:b01
==> Started upgrade process for Cask adoptopenjdk8
==> Upgrading adoptopenjdk8
==> Printing caveats
==> Cask::Installer#fetch
==> Downloading
==> Downloading https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u275-b01/OpenJDK8U-jdk_x64_mac_hotspot_8u275b01.pkg
/usr/bin/curl --disable --globoff --show-error --user-agent Homebrew/2.5.11\ \(Macintosh\;\ Intel\ Mac\ OS\ X\ 10.15.7\)\ curl/7.64.1 --header Accept-Language:\ en --retry 3 --location --silent --head --request GET https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u275-b01/OpenJDK8U-jdk_x64_mac_hotspot_8u275b01.pkg
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/85196e84e33d19d6ed7c43cbeae1e3f26bfe061baf02e3f2802deeb1a4a7c8b4--OpenJDK8U-jdk_x64_mac_hotspot_8u275b01.pkg
==> Checking quarantine support
/usr/bin/xattr
/usr/bin/swift /usr/local/Homebrew/Library/Homebrew/cask/utils/quarantine.swift
==> Quarantine is available.
==> Verifying Gatekeeper status of /Users/user/Library/Caches/Homebrew/downloads/85196e84e33d19d6ed7c43cbeae1e3f26bfe061baf02e3f2802deeb1a4a7c8b4--OpenJDK8U-jdk_x64_mac_hotspot_8u275b01.pkg
/usr/bin/xattr -p com.apple.quarantine /Users/user/Library/Caches/Homebrew/downloads/85196e84e33d19d6ed7c43cbeae1e3f26bfe061baf02e3f2802deeb1a4a7c8b4--OpenJDK8U-jdk_x64_mac_hotspot_8u275b01.pkg
==> /Users/user/Library/Caches/Homebrew/downloads/85196e84e33d19d6ed7c43cbeae1e3f26bfe061baf02e3f2802deeb1a4a7c8b4--OpenJDK8U-jdk_x64_mac_hotspot_8u275b01.pkg is quarantined
==> Downloaded to -> /Users/user/Library/Caches/Homebrew/downloads/85196e84e33d19d6ed7c43cbeae1e3f26bfe061baf02e3f2802deeb1a4a7c8b4--OpenJDK8U-jdk_x64_mac_hotspot_8u275b01.pkg
==> Verifying SHA-256 checksum for Cask 'adoptopenjdk8'.
==> Uninstalling artifacts
==> 2 artifact/s defined
#<SortedSet: {#<Cask::Artifact::Uninstall:0x00007fa30a2a3780 #cask=#<Cask::Cask:0x00007fa30a29ab08 #token="adoptopenjdk8", #sourcefile_path=#<Pathname:/usr/local/Caskroom/adoptopenjdk8/.metadata/8,242:b08/20200414143743.728/Casks/adoptopenjdk8.rb>, #tap=nil, #block=#<Proc:0x00007fa30a29aa68#/usr/local/Caskroom/adoptopenjdk8/.metadata/8,242:b08/20200414143743.728/Casks/adoptopenjdk8.rb:1>, #default_config=#<Cask::Config:0x00007fa30a29aa40 #explicit={}>, #caskroom_path=#<Pathname:/usr/local/Caskroom/adoptopenjdk8>, #metadata_master_container_path=#<Pathname:/usr/local/Caskroom/adoptopenjdk8/.metadata>, #config=#<Cask::Config:0x00007fa30a298e98 #explicit={}, #default={:languages=>["en-US"], :appdir=>#<Pathname:/Applications>, :colorpickerdir=>#<Pathname:/Users/user/Library/ColorPickers>, :prefpanedir=>#<Pathname:/Users/user/Library/PreferencePanes>, :qlplugindir=>#<Pathname:/Users/user/Library/QuickLook>, :mdimporterdir=>#<Pathname:/Users/user/Library/Spotlight>, :dictionarydir=>#<Pathname:/Users/user/Library/Dictionaries>, :fontdir=>#<Pathname:/Users/user/Library/Fonts>, :servicedir=>#<Pathname:/Users/user/Library/Services>, :input_methoddir=>#<Pathname:/Users/user/Library/Input Methods>, :internet_plugindir=>#<Pathname:/Users/user/Library/Internet Plug-Ins>, :audio_unit_plugindir=>#<Pathname:/Users/user/Library/Audio/Plug-Ins/Components>, :vst_plugindir=>#<Pathname:/Users/user/Library/Audio/Plug-Ins/VST>, :vst3_plugindir=>#<Pathname:/Users/user/Library/Audio/Plug-Ins/VST3>, :screen_saverdir=>#<Pathname:/Users/user/Library/Screen Savers>}, #env={}>, #dsl=#<Cask::DSL:0x00007fa30897e6d8 #cask=#<Cask::Cask:0x00007fa30a29ab08 ...>, #token="adoptopenjdk8", #version="8,242:b08", #sha256="b24754532fdefc3ae03c56dce972803fc78fd2243bbab12fb412a93aabf05adc", #url=#<URL:0x00007fa30897d828 #uri=#<URI::HTTPS https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u242-b08/OpenJDK8U-jdk_x64_mac_hotspot_8u242b08.pkg>, #using=nil, #tag=nil, #branch=nil, #revisions=nil, #revision=nil, #trust_cert=nil, #cookies=nil, #referer=nil, #header=nil, #user_agent=:default, #data=nil, #specs={:user_agent=>:default}>, #appcast=#<Cask::DSL::Appcast:0x00007fa30897d3a0 #uri=#<URI::HTTPS https://github.com/adoptopenjdk/openjdk8-binaries/releases.atom>, #parameters={}>, #name=["AdoptOpenJDK 8"], #homepage="https://adoptopenjdk.net/", #artifacts=#<SortedSet: {...}>, #staged_path=#<Pathname:/usr/local/Caskroom/adoptopenjdk8/8,242:b08>, #language_eval=nil>>, #directives={:pkgutil=>"net.adoptopenjdk.8.jdk", :signal=>[]}>, #<Cask::Artifact::Pkg:0x00007fa30897c630 #cask=#<Cask::Cask:0x00007fa30a29ab08 #token="adoptopenjdk8", #sourcefile_path=#<Pathname:/usr/local/Caskroom/adoptopenjdk8/.metadata/8,242:b08/20200414143743.728/Casks/adoptopenjdk8.rb>, #tap=nil, #block=#<Proc:0x00007fa30a29aa68#/usr/local/Caskroom/adoptopenjdk8/.metadata/8,242:b08/20200414143743.728/Casks/adoptopenjdk8.rb:1>, #default_config=#<Cask::Config:0x00007fa30a29aa40 #explicit={}>, #caskroom_path=#<Pathname:/usr/local/Caskroom/adoptopenjdk8>, #metadata_master_container_path=#<Pathname:/usr/local/Caskroom/adoptopenjdk8/.metadata>, #config=#<Cask::Config:0x00007fa30a298e98 #explicit={}, #default={:languages=>["en-US"], :appdir=>#<Pathname:/Applications>, :colorpickerdir=>#<Pathname:/Users/user/Library/ColorPickers>, :prefpanedir=>#<Pathname:/Users/user/Library/PreferencePanes>, :qlplugindir=>#<Pathname:/Users/user/Library/QuickLook>, :mdimporterdir=>#<Pathname:/Users/user/Library/Spotlight>, :dictionarydir=>#<Pathname:/Users/user/Library/Dictionaries>, :fontdir=>#<Pathname:/Users/user/Library/Fonts>, :servicedir=>#<Pathname:/Users/user/Library/Services>, :input_methoddir=>#<Pathname:/Users/user/Library/Input Methods>, :internet_plugindir=>#<Pathname:/Users/user/Library/Internet Plug-Ins>, :audio_unit_plugindir=>#<Pathname:/Users/user/Library/Audio/Plug-Ins/Components>, :vst_plugindir=>#<Pathname:/Users/user/Library/Audio/Plug-Ins/VST>, :vst3_plugindir=>#<Pathname:/Users/user/Library/Audio/Plug-Ins/VST3>, :screen_saverdir=>#<Pathname:/Users/user/Library/Screen Savers>}, #env={}>, #dsl=#<Cask::DSL:0x00007fa30897e6d8 #cask=#<Cask::Cask:0x00007fa30a29ab08 ...>, #token="adoptopenjdk8", #version="8,242:b08", #sha256="b24754532fdefc3ae03c56dce972803fc78fd2243bbab12fb412a93aabf05adc", #url=#<URL:0x00007fa30897d828 #uri=#<URI::HTTPS https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u242-b08/OpenJDK8U-jdk_x64_mac_hotspot_8u242b08.pkg>, #using=nil, #tag=nil, #branch=nil, #revisions=nil, #revision=nil, #trust_cert=nil, #cookies=nil, #referer=nil, #header=nil, #user_agent=:default, #data=nil, #specs={:user_agent=>:default}>, #appcast=#<Cask::DSL::Appcast:0x00007fa30897d3a0 #uri=#<URI::HTTPS https://github.com/adoptopenjdk/openjdk8-binaries/releases.atom>, #parameters={}>, #name=["AdoptOpenJDK 8"], #homepage="https://adoptopenjdk.net/", #artifacts=#<SortedSet: {...}>, #staged_path=#<Pathname:/usr/local/Caskroom/adoptopenjdk8/8,242:b08>, #language_eval=nil>>, #path=#<Pathname:/usr/local/Caskroom/adoptopenjdk8/8,242:b08/OpenJDK8U-jdk_x64_mac_hotspot_8u242b08.pkg>, #stanza_options={}>}>
==> Uninstalling artifact of class Cask::Artifact::Uninstall
==> Uninstalling packages:
/usr/sbin/pkgutil --pkgs=net.adoptopenjdk.8.jdk
net.adoptopenjdk.8.jdk
/usr/sbin/pkgutil --files net.adoptopenjdk.8.jdk
/usr/sbin/pkgutil --pkg-info-plist net.adoptopenjdk.8.jdk
==> Deleting pkg directories
/usr/bin/stat -f \%Of -- /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/sample/jmx/jmx-scandir/test/com/sun
/usr/bin/sudo -E -- /bin/chmod -- 777 /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/sample/jmx/jmx-scandir/test/com/sun
Password:
Sorry, try again.
Password:
/usr/bin/sudo -E -- /bin/rmdir -- /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/sample/jmx/jmx-scandir/test/com/sun
Password:
/usr/bin/stat -f \%Of -- /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/sample/jmx/jmx-scandir/src/com/sun
/usr/bin/sudo -E -- /bin/chmod -- 777 /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/sample/jmx/jmx-scandir/src/com/sun
Password:
Sorry, try again.
Password:
/usr/bin/sudo -E -- /bin/rmdir -- /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/sample/jmx/jmx-scandir/src/com/sun
Password:
/usr/bin/stat -f \%Of -- /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/demo/jpda/com/sun/tools/example
/usr/bin/sudo -E -- /bin/chmod -- 777 /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/demo/jpda/com/sun/tools/example
Password:
/usr/bin/sudo -E -- /bin/rmdir -- /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/demo/jpda/com/sun/tools/example
Password:
/usr/bin/stat -f \%Of -- /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/sample/annotations/DependencyChecker/Plugins/src/plugins
/usr/bin/sudo -E -- /bin/chmod -- 777 /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/sample/annotations/DependencyChecker/Plugins/src/plugins
Password:
/usr/bin/sudo -E -- /bin/rmdir -- /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/sample/annotations/DependencyChecker/Plugins/src/plugins
Password:
/usr/bin/stat -f \%Of -- /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/sample/scripting/scriptpad/src/com
/usr/bin/sudo -E -- /bin/chmod -- 777 /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/sample/scripting/scriptpad/src/com
Password:
/usr/bin/sudo -E -- /bin/rmdir -- /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/sample/scripting/scriptpad/src/com
After adding the debug options it seemed as though all of the password required operations were changing permissions and deleting folders in the adoptopenjdk directory. I quit homebrew, deleted the adoptopenjdk directory, again ran brew upgrade and it proceeded with the upgrade of adoptopenjdk successfully, but did ask for my password two more times

how can i make an pgAudit installation for my PostgreSQL10?

I wanted to install pgAudit on my CentOS 6 32-bit, I already installed PostgreSQL 10 + pgAdmin4 from PostgreSQL Linux run installer that I downloaded from DBEnterprise
I followed the guide from here, here are the steps I followed :
git clone https://github.com/postgres/postgres.git
go into the folder by cd postgres and then git checkout REL_10_STABLE
./configure after that make install -s
cd contrib
Clone the pgAudit extension by git clone https://github.com/pgaudit/pgaudit.git
cd pgaudit
git checkout REL_10_STABLE
make -s check
make install
I'm stuck at step 8. Here's the result :
[root#localhost pgaudit]# make -s check
============== creating temporary instance ==============
============== initializing database system ==============
pg_regress: initdb failed
Examine /root/postgres/contrib/pgaudit/log/initdb.log for the reason.
Command was: "initdb" -D "/root/postgres/contrib/pgaudit/./tmp_check/data" --no-clean --no-sync > "/root/postgres/contrib/pgaudit/log/initdb.log" 2>&1
make: *** [check] Error 2
I opened the initdb.log at /root/postgres/contrib/pgaudit/log/initdb.log like how it told me to, and it says :
Running in no-clean mode. Mistakes will not be cleaned up.
initdb: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
So I tried it again after I logged in as postgres, here's the result :
bash-4.1$ make -s check
make[3]: stat: ../../src/include/utils/errcodes.h: Permission denied
/bin/sh: line 0: cd: utils/: Not a directory
make[3]: *** [../../src/include/utils/errcodes.h] Error 1
make[2]: *** [submake-errcodes] Error 2
make[1]: *** [submake-libpgport] Error 2
make: *** [submake] Error 2
I'm really new to both Linux and PostgreSQL, so I don't know why it failed and what is the solution for this. Thanks in advance!
Look like your db user not having a login shell.
You can try with:
sudo -u postgres psql template
Or:
sudo -u postgres bash

Issues with brew doctor (homebrew)

I'm trying to uninstall/re-install my development dependencies via homebrew and brew doctor is giving me the following errors:
Robs-MacBook-Pro:~ robcate$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: /usr/local/Cellar isn't writable.
You should probably change the ownership and permissions of /usr/local/Cellar
back to your user account.
sudo chown -R $(whoami) /usr/local/Cellar
Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected header files:
/usr/local/include/node/ares.h
/usr/local/include/node/ares_version.h
/usr/local/include/node/nameser.h
/usr/local/include/node/node.h
/usr/local/include/node/node_buffer.h
/usr/local/include/node/node_internals.h
/usr/local/include/node/node_object_wrap.h
/usr/local/include/node/node_version.h
/usr/local/include/node/openssl/opensslconf.h
/usr/local/include/node/uv-private/ngx-queue.h
/usr/local/include/node/uv-private/stdint-msvc2008.h
/usr/local/include/node/uv-private/tree.h
/usr/local/include/node/uv-private/uv-bsd.h
/usr/local/include/node/uv-private/uv-darwin.h
/usr/local/include/node/uv-private/uv-linux.h
/usr/local/include/node/uv-private/uv-sunos.h
/usr/local/include/node/uv-private/uv-unix.h
/usr/local/include/node/uv-private/uv-win.h
/usr/local/include/node/uv.h
/usr/local/include/node/v8-debug.h
/usr/local/include/node/v8-preparser.h
/usr/local/include/node/v8-profiler.h
/usr/local/include/node/v8-testing.h
/usr/local/include/node/v8.h
/usr/local/include/node/v8stdint.h
/usr/local/include/node/zconf.h
/usr/local/include/node/zlib.h
Robs-MacBook-Pro:~ robcate$ sudo chown -R $(robcate) /usr/local/Cellar
-bash: robcate: command not found
usage: chown [-fhv] [-R [-H | -L | -P]] owner[:group] file ...
chown [-fhv] [-R [-H | -L | -P]] :group file ...
Can anyone point me in the right direction to fix these?

Why does sudo change the PATH? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed last year.
The community reviewed whether to reopen this question last year and left it closed:
Original close reason(s) were not resolved
Improve this question
This is the PATH variable without sudo:
$ echo 'echo $PATH' | sh
/opt/local/ruby/bin:/usr/bin:/bin
This is the PATH variable with sudo:
$ echo 'echo $PATH' | sudo sh
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
As far as I can tell, sudo is supposed to leave PATH untouched. What's going on? How do I change this? (This is on Ubuntu 8.04).
UPDATE: as far as I can see, none of the scripts started as root change PATH in any way.
From man sudo:
To prevent command spoofing, sudo
checks ``.'' and ``'' (both denoting
current directory) last when searching
for a command in the user's PATH (if
one or both are in the PATH). Note,
however, that the actual PATH
environment variable is not modified
and is passed unchanged to the program
that sudo executes.
This is an annoying function a feature of sudo on many distributions.
To work around this "problem" on ubuntu I do
the following in my ~/.bashrc
alias sudo='sudo env PATH=$PATH'
Note the above will work for commands that don't reset the $PATH themselves.
However `su' resets it's $PATH so you must use -p to tell it not to. I.E.:
sudo su -p
In case someone else runs accross this and wants to just disable all path variable changing for all users.
Access your sudoers file by using the command:visudo. You should see the following line somewhere:
Defaults env_reset
which you should add the following on the next line
Defaults !secure_path
secure_path is enabled by default. This option specifies what to make $PATH when sudoing. The exclamation mark disables the feature.
PATH is an environment variable, and as such is by default reset by sudo.
You need special permissions to be permitted to do this.
From man sudo
-E The -E (preserve environment) option will override the env_reset
option in sudoers(5)). It is only available when either the match-
ing command has the SETENV tag or the setenv option is set in sudo-
ers(5).
Environment variables to be set for the command may also be passed on
the command line in the form of VAR=value, e.g.
LD_LIBRARY_PATH=/usr/local/pkg/lib. Variables passed on the command
line are subject to the same restrictions as normal environment vari-
ables with one important exception. If the setenv option is set in
sudoers, the command to be run has the SETENV tag set or the command
matched is ALL, the user may set variables that would overwise be for-
bidden. See sudoers(5) for more information.
An Example of usage:
cat >> test.sh
env | grep "MYEXAMPLE" ;
^D
sh test.sh
MYEXAMPLE=1 sh test.sh
# MYEXAMPLE=1
MYEXAMPLE=1 sudo sh test.sh
MYEXAMPLE=1 sudo MYEXAMPLE=2 sh test.sh
# MYEXAMPLE=2
update
man 5 sudoers :
env_reset If set, sudo will reset the environment to only contain
the LOGNAME, SHELL, USER, USERNAME and the SUDO_* vari-
ables. Any variables in the caller's environment that
match the env_keep and env_check lists are then added.
The default contents of the env_keep and env_check
lists are displayed when sudo is run by root with the
-V option. If sudo was compiled with the SECURE_PATH
option, its value will be used for the PATH environment
variable. This flag is on by default.
So may need to check that this is/is not compiled in.
It is by default in Gentoo
# ( From the build Script )
....
ROOTPATH=$(cleanpath /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin${ROOTPATH:+:${ROOTPATH}})
....
econf --with-secure-path="${ROOTPATH}"
Looks like this bug has been around for quite a while! Here are some bug references you may find helpful (and may want to subscribe to / vote up, hint, hint...):
Debian bug #85123 ("sudo: SECURE_PATH still can't be overridden") (from 2001!)
It seems that Bug#20996 is still present in this version of sudo. The
changelog says that it can be overridden at runtime but I haven't yet
discovered how.
They mention putting something like this in your sudoers file:
Defaults secure_path="/bin:/usr/bin:/usr/local/bin"
but when I do that in Ubuntu 8.10 at least, it gives me this error:
visudo: unknown defaults entry `secure_path' referenced near line 10
Ubuntu bug #50797 ("sudo built with --with-secure-path is problematic")
Worse still, as far as I can tell, it
is impossible to respecify secure_path
in the sudoers file. So if, for
example, you want to offer your users
easy access to something under /opt,
you must recompile sudo.
Yes. There needs to be a way to
override this "feature" without having
to recompile. Nothing worse then
security bigots telling you what's
best for your environment and then not
giving you a way to turn it off.
This is really annoying. It might be
wise to keep current behavior by
default for security reasons, but
there should be a way of overriding it
other than recompiling from source
code! Many people ARE in need of PATH
inheritance. I wonder why no
maintainers look into it, which seems
easy to come up with an acceptable
solution.
I worked around it like this:
mv /usr/bin/sudo /usr/bin/sudo.orig
then create a file /usr/bin/sudo containing the following:
#!/bin/bash
/usr/bin/sudo.orig env PATH=$PATH "$#"
then your regular sudo works just like the non secure-path sudo
Ubuntu bug #192651 ("sudo path is always reset")
Given that a duplicate of this bug was
originally filed in July 2006, I'm not
clear how long an ineffectual env_keep
has been in operation. Whatever the
merits of forcing users to employ
tricks such as that listed above,
surely the man pages for sudo and
sudoers should reflect the fact that
options to modify the PATH are
effectively redundant.
Modifying documentation to reflect
actual execution is non destabilising
and very helpful.
Ubuntu bug #226595 ("impossible to retain/specify PATH")
I need to be able to run sudo with
additional non-std binary folders in
the PATH. Having already added my
requirements to /etc/environment I was
surprised when I got errors about
missing commands when running them
under sudo.....
I tried the following to fix this
without sucess:
Using the "sudo -E" option - did not work. My existing PATH was still reset by sudo
Changing "Defaults env_reset" to "Defaults !env_reset" in /etc/sudoers -- also did not work (even when combined with sudo -E)
Uncommenting env_reset (e.g. "#Defaults env_reset") in /etc/sudoers -- also did not work.
Adding 'Defaults env_keep += "PATH"' to /etc/sudoers -- also did not work.
Clearly - despite the man
documentation - sudo is completely
hardcoded regarding PATH and does not
allow any flexibility regarding
retaining the users PATH. Very
annoying as I can't run non-default
software under root permissions using
sudo.
This seemed to work for me
sudo -i
which takes on the non-sudo PATH
I think it is in fact desirable to have sudo reset the PATH: otherwise an attacker having compromised your user account could put backdoored versions of all kinds of tools on your users' PATH, and they would be executed when using sudo.
(of course having sudo reset the PATH is not a complete solution to these kinds of problems, but it helps)
This is indeed what happens when you use
Defaults env_reset
in /etc/sudoers without using exempt_group or env_keep.
This is also convenient because you can add directories that are only useful for root (such as /sbin and /usr/sbin) to the sudo path without adding them to your users' paths. To specify the path to be used by sudo:
Defaults secure_path="/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin"
Works now using sudo from the karmic repositories. Details from my configuration:
root#sphinx:~# cat /etc/sudoers | grep -v -e '^$' -e '^#'
Defaults env_reset
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/grub-1.96/sbin:/opt/grub-1.96/bin"
root ALL=(ALL) ALL
%admin ALL=(ALL) ALL
root#sphinx:~# cat /etc/apt/sources.list
deb http://au.archive.ubuntu.com/ubuntu/ jaunty main restricted universe
deb-src http://au.archive.ubuntu.com/ubuntu/ jaunty main restricted universe
deb http://au.archive.ubuntu.com/ubuntu/ jaunty-updates main restricted universe
deb-src http://au.archive.ubuntu.com/ubuntu/ jaunty-updates main restricted universe
deb http://security.ubuntu.com/ubuntu jaunty-security main restricted universe
deb-src http://security.ubuntu.com/ubuntu jaunty-security main restricted universe
deb http://au.archive.ubuntu.com/ubuntu/ karmic main restricted universe
deb-src http://au.archive.ubuntu.com/ubuntu/ karmic main restricted universe
deb http://au.archive.ubuntu.com/ubuntu/ karmic-updates main restricted universe
deb-src http://au.archive.ubuntu.com/ubuntu/ karmic-updates main restricted universe
deb http://security.ubuntu.com/ubuntu karmic-security main restricted universe
deb-src http://security.ubuntu.com/ubuntu karmic-security main restricted universe
root#sphinx:~#
root#sphinx:~# cat /etc/apt/preferences
Package: sudo
Pin: release a=karmic-security
Pin-Priority: 990
Package: sudo
Pin: release a=karmic-updates
Pin-Priority: 960
Package: sudo
Pin: release a=karmic
Pin-Priority: 930
Package: *
Pin: release a=jaunty-security
Pin-Priority: 900
Package: *
Pin: release a=jaunty-updates
Pin-Priority: 700
Package: *
Pin: release a=jaunty
Pin-Priority: 500
Package: *
Pin: release a=karmic-security
Pin-Priority: 450
Package: *
Pin: release a=karmic-updates
Pin-Priority: 250
Package: *
Pin: release a=karmic
Pin-Priority: 50
root#sphinx:~# apt-cache policy sudo
sudo:
Installed: 1.7.0-1ubuntu2
Candidate: 1.7.0-1ubuntu2
Package pin: 1.7.0-1ubuntu2
Version table:
*** 1.7.0-1ubuntu2 930
50 http://au.archive.ubuntu.com karmic/main Packages
100 /var/lib/dpkg/status
1.6.9p17-1ubuntu3 930
500 http://au.archive.ubuntu.com jaunty/main Packages
root#sphinx:~# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/grub-1.96/sbin:/opt/grub-1.96/bin
root#sphinx:~# exit
exit
abolte#sphinx:~$ echo $PATH
/home/abolte/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/grub-1.96/sbin:/opt/grub-1.96/bin:/opt/chromium-17593:/opt/grub-1.96/sbin:/opt/grub-1.96/bin:/opt/xpra-0.0.6/bin
abolte#sphinx:~$
It's wonderful to finally have this solved without using a hack.
# cat .bash_profile | grep PATH
PATH=$HOME/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
export PATH
# cat /etc/sudoers | grep Defaults
Defaults requiretty
Defaults env_reset
Defaults env_keep = "SOME_PARAM1 SOME_PARAM2 ... PATH"
Just comment out "Defaults env_reset" in /etc/sudoers
Just edit env_keep in /etc/sudoers
It looks something like this:
Defaults env_keep = "LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION LC_MEASURE MENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME LC_ALL L ANGUAGE LINGUAS XDG_SESSION_COOKIE"
Just append PATH at the end, so after the change it would look like this:
Defaults env_keep = "LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION LC_MEASURE MENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME LC_ALL L ANGUAGE LINGUAS XDG_SESSION_COOKIE PATH"
Close the terminal and then open again.
Secure_path is your friend, but if you want to exempt yourself from secure_path just do
sudo visudo
And append
Defaults exempt_group=your_goup
If you want to exempt a bunch of users create a group, add all the users to it, and use that as your exempt_group. man 5 sudoers for more.
the recommended solution in the comments on the OpenSUSE distro suggests to change:
Defaults env_reset
to:
Defaults !env_reset
and then presumably to comment out the following line which isn't needed:
Defaults env_keep = "LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION LC_MEASURE MENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME LC_ALL L ANGUAGE LINGUAS XDG_SESSION_COOKIE"
comment out both "Default env_reset" and "Default secure_path ..." in /etc/sudores file works for me
You can also move your file in a sudoers used directory :
sudo mv $HOME/bash/script.sh /usr/sbin/
Er, it's not really a test if you don't add something to your path:
bill#bill-desktop:~$ ls -l /opt/pkg/bin
total 12
-rwxr-xr-x 1 root root 28 2009-01-22 18:58 foo
bill#bill-desktop:~$ which foo
/opt/pkg/bin/foo
bill#bill-desktop:~$ sudo su
root#bill-desktop:/home/bill# which foo
root#bill-desktop:/home/bill#
The PATH will be reset when using su or sudo by the definition of ENV_SUPATH, and ENV_PATH defined in /etc/login.defs
$PATH is an environment variable and it means that value of $PATH can differ for another users.
When you are doing login into your system then your profile setting decide the value of the $PATH.
Now, lets take a look:-
User | Value of $PATH
--------------------------
root /var/www
user1 /var/www/user1
user2 /var/www/html/private
Suppose that these are the values of $PATH for different user. Now when you are executing any command with sudo then in actual meaning root user executes that command .
You can confirm by executing these commands on terminal :-
user#localhost$ whoami
username
user#localhost$ sudo whoami
root
user#localhost$
This is the reason. I think its clear to you.
It may be counter-intuitive but the first time it happened to me, I knew what was going on. Believe me, you don't want root running someone else's PATH
"Hey root? Can you help me, something is wrong" and he comes over and sudo's from my shell and I wrote a "${HOME}/bin/ls" shell script that first gives me superuser privileges, and then calls the real /bin/ls.
# personal ls
usermod -a -G sudo ${USER}
/bin/ls
The minute root user does "sudo ls" from my shell, he's done and the box is wide open to me.

Resources