* [gentoo-user] zsh and sudo
@ 2010-02-19 1:33 daid kahl
2010-02-19 13:07 ` Helmut Jarausch
2010-02-20 22:00 ` Etaoin Shrdlu
0 siblings, 2 replies; 4+ messages in thread
From: daid kahl @ 2010-02-19 1:33 UTC (permalink / raw
To: gentoo-user
Hello,
I just installed zsh recently and was working on making the switch
over from bash for my daily user, provided I can get a few things
worked out.
The biggest problem that I can't find useful results googling is zsh
interaction with sudo.
I'm noticing some strange behavior with the PATH and also the
interpretation of '='.
daid@flux log % sudo which useradd
which: no useradd in
(/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.4.3:/opt/sun-jdk-1.4.2.17/bin:/opt/sun-jdk-1.4.2.17/jre/bin:/opt/sun-jdk-1.4.2.17/jre/javaws:/usr/kde/3.5/bin:/usr/qt/3/bin:/usr/games/bin)
daid@flux log % sudo echo $PATH
/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.4.3:/opt/sun-jdk-1.4.2.17/bin:/opt/sun-jdk-1.4.2.17/jre/bin:/opt/sun-jdk-1.4.2.17/jre/javaws:/usr/kde/3.5/bin:/usr/qt/3/bin:/usr/games/bin:/home/daid/scripts:/sbin:/home/daid/.gentoo/java-config-2/current-user-vm/bin:/usr/sbin:/usr/local/warlock2:/usr/local/sbin:/home/daid/physics/transport_for_crib/transport1.6/bin
daid@flux log % which useradd
/usr/sbin/useradd
So sudo has the PATH set correctly, but it doesn't actually use the
correct path. Fishy!
It gets more confusing. Any new zsh opened within a first instance of
zsh things work as expected:
daid@flux log % zsh
daid@flux log % sudo which useradd
/usr/sbin/useradd
This happens in X and at console login. One can assume that either
ghosts are haunting my machine, there was a solar flare flipping bits
on my hdd, or I've done something silly. If I make root set my user's
path, then sudo is fine. So basically the problem is that it's
defaulting to checking root's path and not the user path, which is not
the documented behavior on Gentoo (nor consistent with sudo in other
shells.
As for interpretation of '=' I really don't understand what's
happening. It seems indiscriminate of the case in terms of mucking
about, but the exact result it not always the same. Consider the
monstrous output in the following simple case of making a new
environment variable:
daid@flux log % sudo TEST="testing"
LESSOPEN=|lesspipe.sh %s
XDG_DATA_DIRS=/usr/local/share:/usr/kde/3.5/share:/usr/share:/usr/share
GLADE_CATALOG_PATH=:
GTK_PATH=:/usr/lib/gtk-2.0
PATH=/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.4.3:/opt/sun-jdk-1.4.2.17/bin:/opt/sun-jdk-1.4.2.17/jre/bin:/opt/sun-jdk-1.4.2.17/jre/javaws:/usr/kde/3.5/bin:/usr/qt/3/bin:/usr/games/bin
GDK_USE_XFT=1
SSH_AUTH_SOCK=/tmp/ssh-mCuWxp2532/agent.2532
USER=root
QTDIR=/usr/qt/3
PRELINK_PATH_MASK=/usr/lib/klibc
SHELL=/bin/zsh
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-HBS914aGoB,guid=109c64af5b65dda3804f8d4d4b7de295
LESS=-R -M --shift 5
JAVACC_HOME=/usr/share/javacc/
GCC_SPECS=
CONFIG_PROTECT_MASK=/etc/gentoo-release /etc/sandbox.d
/etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/terminfo
/etc/ca-certificates.conf /etc/texmf/web2c /etc/texmf/language.dat.d
/etc/texmf/language.def.d /etc/texmf/updmap.d /etc/revdep-rebuild
/etc/splash
LIBGLADE_MODULE_PATH=:/usr/lib/libglade/2.0
OPENGL_PROFILE=xorg-x11
GENERATION=2
MAIL=/var/mail/daid
JAVAC=/home/daid/.gentoo/java-config-2/current-user-vm/bin/javac
ANT_HOME=/usr/share/ant
XAUTHORITY=/home/daid/.Xauthority
PAGER=/usr/bin/less
SHLVL=2
_=/usr/bin/sudo
QMAKESPEC=linux-g++
WINDOWID=25165872
GLADE_MODULE_PATH=:
TERM=xterm
PWD=/home/daid/log
COLORTERM=Terminal
CONFIG_PROTECT=/usr/share/X11/xkb /var/lib/hsqldb
/usr/kde/3.5/share/config /usr/kde/3.5/env /usr/kde/3.5/shutdown
/usr/share/config
CVS_RSH=ssh
GLADE_PIXMAP_PATH=:
JDK_HOME=/home/daid/.gentoo/java-config-2/current-user-vm
VMHANDLE=sun-jdk-1.4
INFOPATH=/usr/share/info:/usr/share/binutils-data/i686-pc-linux-gnu/2.20/info:/usr/share/gcc-data/i686-pc-linux-gnu/4.4.3/info
SESSION_MANAGER=local/flux:@/tmp/.ICE-unix/2541,unix/flux:/tmp/.ICE-unix/2541
DISPLAY=:0.0
LOGNAME=root
JAVA_HOME=/home/daid/.gentoo/java-config-2/current-user-vm
SSH_AGENT_PID=2533
MANPATH=/home/daid/.gentoo/java-config-2/current-user-vm/man:/usr/local/share/man:/usr/share/man:/usr/share/binutils-data/i686-pc-linux-gnu/2.20/man:/usr/share/gcc-data/i686-pc-linux-gnu/4.4.3/man:/opt/sun-jdk-1.4.2.17/man:/etc/java-config/system-vm/man/:/usr/kde/3.5/share/man:/usr/qt/3/doc/man
XDG_CONFIG_DIRS=/etc/xdg
SGML_CATALOG_FILES=/etc/sgml/sgml-ent.cat:/etc/sgml/openjade-1.3.2.cat:/etc/sgml/sgml-docbook.cat:/etc/sgml/sgml-docbook-3.1.cat:/etc/sgml/dsssl-docbook-stylesheets.cat:/etc/sgml/sgml-lite.cat:/etc/sgml/xml-docbook-4.4.cat:/etc/sgml/xml-docbook-4.1.2.cat
HOME=/home/daid
EDITOR=/usr/bin/vi
OLDPWD=/home/daid/log
MOCADI_DIR=/home/daid/physics/rib_model/mocadi
MOCADI_DATA=/home/daid/physics/rib_model/mocadi/data
MOCADI_SPLINES_GZ=/home/daid/physics/rib_model/mocadi/splines_gz
ROOTSYS=/usr
ROOT_LIBRARIES=/usr/lib/root
MYSQL=/usr/include/mysql:/usr/lib/mysql
MYSQL_TCP_PORT=3306
JAVADIR=/usr/lib/jvm/sun-jdk-1.6
USERNAME=root
SUDO_COMMAND=/bin/env
PATH=/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.4.3:/opt/sun-jdk-1.4.2.17/bin:/opt/sun-jdk-1.4.2.17/jre/bin:/opt/sun-jdk-1.4.2.17/jre/javaws:/usr/kde/3.5/bin:/usr/qt/3/bin:/usr/games/bin
TEST=testing
SUDO_USER=daid
SUDO_UID=1000
SUDO_GID=1009
TEST=testing
Or if I want to emerge a specific package, instead I get:
daid@flux log % sudo emerge =sudo-1.7.2_p2-r2
zsh: sudo-1.7.2_p2-r2 not found
Unlike the PATH problems, the equal problems do not go away with a new
instance of zsh overtop of the first one.
I'm experiencing some other problems with zsh as well, but being able
to use sudo is reasonably more pressing, and basic googling on the
other errors (problems sourcing /etc/profile and getting a bash
prompt, trying to set zsh as my slim login shell fails to login).
As always, I'm suspicious that I've done something stupid, but I don't
see anything obvious. I can use tcsh and bash both just fine. This
occurred for both x86 builds on an x86 arch and ~x86 builds on an ~x86
arch with the most recent versions of sudo and zsh for those
respective arch settings (recent ~x86 upgrade). revdep-rebuild still
has a couple things to take care of that need babysitting and/or bug
reports, but I would be extremely surprised if those packages are at
all related here (things for tex and also libjpeg).
I'll happily take any advice, even if it's "go back to bash" (although
some tips on auto-completion and command correction would be welcome,
since I didn't get any reasonable results for these features with
bash).
If it's useful I'll post my working .zshrc and such, but honestly I
can't see much reason to do so now since I don't see it as relevant to
the problems I see.
Toodles,
daid
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-user] zsh and sudo
2010-02-19 1:33 [gentoo-user] zsh and sudo daid kahl
@ 2010-02-19 13:07 ` Helmut Jarausch
2010-02-20 22:00 ` Etaoin Shrdlu
1 sibling, 0 replies; 4+ messages in thread
From: Helmut Jarausch @ 2010-02-19 13:07 UTC (permalink / raw
To: gentoo-user
On 19 Feb, daid kahl wrote:
> Hello,
>
> I just installed zsh recently and was working on making the switch
> over from bash for my daily user, provided I can get a few things
> worked out.
>
> The biggest problem that I can't find useful results googling is zsh
> interaction with sudo.
>
> I'm noticing some strange behavior with the PATH and also the
> interpretation of '='.
>
> daid@flux log % sudo which useradd
> which: no useradd in
> (/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.4.3:/opt/sun-jdk-1.4.2.17/bin:/opt/sun-jdk-1.4.2.17/jre/bin:/opt/sun-jdk-1.4.2.17/jre/javaws:/usr/kde/3.5/bin:/usr/qt/3/bin:/usr/games/bin)
> daid@flux log % sudo echo $PATH
> /usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.4.3:/opt/sun-jdk-1.4.2.17/bin:/opt/sun-jdk-1.4.2.17/jre/bin:/opt/sun-jdk-1.4.2.17/jre/javaws:/usr/kde/3.5/bin:/usr/qt/3/bin:/usr/games/bin:/home/daid/scripts:/sbin:/home/daid/.gentoo/java-config-2/current-user-vm/bin:/usr/sbin:/usr/local/warlock2:/usr/local/sbin:/home/daid/physics/transport_for_crib/transport1.6/bin
> daid@flux log % which useradd
> /usr/sbin/useradd
>
> So sudo has the PATH set correctly, but it doesn't actually use the
> correct path. Fishy!
SNIP
AFAIK, sudo invokes the shell specified in the environment.
What is echo $SHELL saying?
Here, is says /bin/zsh
and your examples works just fine.
Helmut.
--
Helmut Jarausch
Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-user] zsh and sudo
2010-02-19 1:33 [gentoo-user] zsh and sudo daid kahl
2010-02-19 13:07 ` Helmut Jarausch
@ 2010-02-20 22:00 ` Etaoin Shrdlu
2010-02-21 16:33 ` daid kahl
1 sibling, 1 reply; 4+ messages in thread
From: Etaoin Shrdlu @ 2010-02-20 22:00 UTC (permalink / raw
To: gentoo-user
On Friday 19 February 2010, daid kahl wrote:
> Hello,
>
> I just installed zsh recently and was working on making the switch
> over from bash for my daily user, provided I can get a few things
> worked out.
>
> The biggest problem that I can't find useful results googling is zsh
> interaction with sudo.
>
> I'm noticing some strange behavior with the PATH and also the
> interpretation of '='.
>
> daid@flux log % sudo which useradd
> which: no useradd in
> (/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.4.3
> :/opt/sun-jdk-1.4.2.17/bin:/opt/sun-jdk-1.4.2.17/jre/bin:/opt/sun-jdk-1.4.2
> .17/jre/javaws:/usr/kde/3.5/bin:/usr/qt/3/bin:/usr/games/bin) daid@flux log
> % sudo echo $PATH
> /usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.4.3:
> /opt/sun-jdk-1.4.2.17/bin:/opt/sun-jdk-1.4.2.17/jre/bin:/opt/sun-jdk-1.4.2.
> 17/jre/javaws:/usr/kde/3.5/bin:/usr/qt/3/bin:/usr/games/bin:/home/daid/scri
> pts:/sbin:/home/daid/.gentoo/java-config-2/current-user-vm/bin:/usr/sbin:/u
> sr/local/warlock2:/usr/local/sbin:/home/daid/physics/transport_for_crib/tra
> nsport1.6/bin daid@flux log % which useradd
> /usr/sbin/useradd
>
> So sudo has the PATH set correctly, but it doesn't actually use the
> correct path. Fishy!
Nope. If you do
sudo echo $PATH
$PATH is replaced by the calling shell before sudo even sees it, so no wonder
you see the right one (btw, this should also answer your other question on why
doing the same on a second instance of the shell seems to "work").
To test what path is seen when sudoing, do
sudo zsh -c 'echo $PATH'
that should be more accurate. But you already had an indication of what $PATH
is in your first command above.
This might be a good read about where to define PATH:
http://zsh.sourceforge.net/FAQ/zshfaq03.html#l19
> As for interpretation of '=' I really don't understand what's
> happening. It seems indiscriminate of the case in terms of mucking
> about, but the exact result it not always the same. Consider the
> monstrous output in the following simple case of making a new
> environment variable:
>
> daid@flux log % sudo TEST="testing"
> LESSOPEN=|lesspipe.sh %s
> XDG_DATA_DIRS=/usr/local/share:/usr/kde/3.5/share:/usr/share:/usr/share
> GLADE_CATALOG_PATH=:
> GTK_PATH=:/usr/lib/gtk-2.0
> PATH=/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4
> .4.3:/opt/sun-jdk-1.4.2.17/bin:/opt/sun-jdk-1.4.2.17/jre/bin:/opt/sun-jdk-1
> .4.2.17/jre/javaws:/usr/kde/3.5/bin:/usr/qt/3/bin:/usr/games/bin
> GDK_USE_XFT=1
> SSH_AUTH_SOCK=/tmp/ssh-mCuWxp2532/agent.2532
> USER=root
>[snip]
> SUDO_COMMAND=/bin/env
>[snip]
> TEST=testing
This looks strange, and would indeed require more investigation. For some
reason, sudo is running /bin/env instead of erroring out (as no command to run
has been specified). However, I doubt that has anything to do with zsh.
> Or if I want to emerge a specific package, instead I get:
>
> daid@flux log % sudo emerge =sudo-1.7.2_p2-r2
> zsh: sudo-1.7.2_p2-r2 not found
This is expected. See
http://zsh.sourceforge.net/Doc/Release/Expansion.html#SEC78
"unsetopt EQUALS"
should cure it. Unless, of course, you DO want to take advantage of zsh's
special handling of "=", in which case read the documentation.
Zsh is a wonderfull shell, but it does have a steep learning curve, due to its
many features. Yes, you will bang your head on the wall many and many times if
you don't read the documentation and continue to think in bash terms.
Reading the manual (or the "user friendly" documentation) is a must. Zsh is an
example of an open source project with a massive and excellent documentation,
so no excuses for not reading it! :)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-user] zsh and sudo
2010-02-20 22:00 ` Etaoin Shrdlu
@ 2010-02-21 16:33 ` daid kahl
0 siblings, 0 replies; 4+ messages in thread
From: daid kahl @ 2010-02-21 16:33 UTC (permalink / raw
To: gentoo-user
>> I just installed zsh recently and was working on making the switch
>> over from bash for my daily user, provided I can get a few things
>> worked out.
>>
>> The biggest problem that I can't find useful results googling is zsh
>> interaction with sudo.
>>
>> I'm noticing some strange behavior with the PATH and also the
>> interpretation of '='.
>>
[snip]
>> So sudo has the PATH set correctly, but it doesn't actually use the
>> correct path. Fishy!
>
> Nope. If you do
>
> sudo echo $PATH
>
> $PATH is replaced by the calling shell before sudo even sees it, so no wonder
> you see the right one (btw, this should also answer your other question on why
> doing the same on a second instance of the shell seems to "work").
> To test what path is seen when sudoing, do
>
> sudo zsh -c 'echo $PATH'
>
> that should be more accurate. But you already had an indication of what $PATH
> is in your first command above.
Yes, that's true!
>
> This might be a good read about where to define PATH:
>
> http://zsh.sourceforge.net/FAQ/zshfaq03.html#l19
>
>> As for interpretation of '=' I really don't understand what's
>> happening. It seems indiscriminate of the case in terms of mucking
>> about, but the exact result it not always the same. Consider the
>> monstrous output in the following simple case of making a new
>> environment variable:
[snip]
> This looks strange, and would indeed require more investigation. For some
> reason, sudo is running /bin/env instead of erroring out (as no command to run
> has been specified). However, I doubt that has anything to do with zsh.
>
>> Or if I want to emerge a specific package, instead I get:
>>
>> daid@flux log % sudo emerge =sudo-1.7.2_p2-r2
>> zsh: sudo-1.7.2_p2-r2 not found
>
> This is expected. See
>
> http://zsh.sourceforge.net/Doc/Release/Expansion.html#SEC78
>
> "unsetopt EQUALS"
>
> should cure it. Unless, of course, you DO want to take advantage of zsh's
> special handling of "=", in which case read the documentation.
Excellent!
> Zsh is a wonderfull shell, but it does have a steep learning curve, due to its
> many features. Yes, you will bang your head on the wall many and many times if
> you don't read the documentation and continue to think in bash terms.
> Reading the manual (or the "user friendly" documentation) is a must. Zsh is an
> example of an open source project with a massive and excellent documentation,
> so no excuses for not reading it! :)
Etaoin -- your response gave me probably all the tools and conviction
I need. I should read documentation before hitting user lists, but I
like the gentoo user list for good reasons. The notes about zsh are
greatly appreciated, but as long as I command the ability to take the
time to learn well documented things, then if nothing else, it's a
great learning experience. Using gentoo for me is largely motivated
by this personal philosophy, and I changed from bash not because I
dislike it but because I wanted to try something new. For example,
just reading your response I've learned more about how the path works
that I didn't know.
I'm over my head right now for other work that's more pressing, but it
seems like I should be able to get zsh running properly by next week.
Regarding Helmut's comment:
> What is echo $SHELL saying?
> Here, is says /bin/zsh
> and your examples works just fine.
This is a useful suggestion, but I had tried this and confirmed the
same output you report. So the problem is buried deeper in my lack of
knowledge about the operation of shells. Thanks!
~daid
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-02-21 17:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-19 1:33 [gentoo-user] zsh and sudo daid kahl
2010-02-19 13:07 ` Helmut Jarausch
2010-02-20 22:00 ` Etaoin Shrdlu
2010-02-21 16:33 ` daid kahl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox