Gentoo Archives: gentoo-user

From: daid kahl <daidxor@×××××.com>
To: gentoo-user@l.g.o
Subject: [gentoo-user] zsh and sudo
Date: Fri, 19 Feb 2010 01:34:27
Message-Id: 3ac129341002181733m4af5bea0j53e67fcd09100470@mail.gmail.com
1 Hello,
2
3 I just installed zsh recently and was working on making the switch
4 over from bash for my daily user, provided I can get a few things
5 worked out.
6
7 The biggest problem that I can't find useful results googling is zsh
8 interaction with sudo.
9
10 I'm noticing some strange behavior with the PATH and also the
11 interpretation of '='.
12
13 daid@flux log % sudo which useradd
14 which: no useradd in
15 (/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)
16 daid@flux log % sudo echo $PATH
17 /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
18 daid@flux log % which useradd
19 /usr/sbin/useradd
20
21 So sudo has the PATH set correctly, but it doesn't actually use the
22 correct path. Fishy!
23
24 It gets more confusing. Any new zsh opened within a first instance of
25 zsh things work as expected:
26
27 daid@flux log % zsh
28 daid@flux log % sudo which useradd
29 /usr/sbin/useradd
30
31 This happens in X and at console login. One can assume that either
32 ghosts are haunting my machine, there was a solar flare flipping bits
33 on my hdd, or I've done something silly. If I make root set my user's
34 path, then sudo is fine. So basically the problem is that it's
35 defaulting to checking root's path and not the user path, which is not
36 the documented behavior on Gentoo (nor consistent with sudo in other
37 shells.
38
39 As for interpretation of '=' I really don't understand what's
40 happening. It seems indiscriminate of the case in terms of mucking
41 about, but the exact result it not always the same. Consider the
42 monstrous output in the following simple case of making a new
43 environment variable:
44
45 daid@flux log % sudo TEST="testing"
46 LESSOPEN=|lesspipe.sh %s
47 XDG_DATA_DIRS=/usr/local/share:/usr/kde/3.5/share:/usr/share:/usr/share
48 GLADE_CATALOG_PATH=:
49 GTK_PATH=:/usr/lib/gtk-2.0
50 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
51 GDK_USE_XFT=1
52 SSH_AUTH_SOCK=/tmp/ssh-mCuWxp2532/agent.2532
53 USER=root
54 QTDIR=/usr/qt/3
55 PRELINK_PATH_MASK=/usr/lib/klibc
56 SHELL=/bin/zsh
57 DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-HBS914aGoB,guid=109c64af5b65dda3804f8d4d4b7de295
58 LESS=-R -M --shift 5
59 JAVACC_HOME=/usr/share/javacc/
60 GCC_SPECS=
61 CONFIG_PROTECT_MASK=/etc/gentoo-release /etc/sandbox.d
62 /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/terminfo
63 /etc/ca-certificates.conf /etc/texmf/web2c /etc/texmf/language.dat.d
64 /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/revdep-rebuild
65 /etc/splash
66 LIBGLADE_MODULE_PATH=:/usr/lib/libglade/2.0
67 OPENGL_PROFILE=xorg-x11
68 GENERATION=2
69 MAIL=/var/mail/daid
70 JAVAC=/home/daid/.gentoo/java-config-2/current-user-vm/bin/javac
71 ANT_HOME=/usr/share/ant
72 XAUTHORITY=/home/daid/.Xauthority
73 PAGER=/usr/bin/less
74 SHLVL=2
75 _=/usr/bin/sudo
76 QMAKESPEC=linux-g++
77 WINDOWID=25165872
78 GLADE_MODULE_PATH=:
79 TERM=xterm
80 PWD=/home/daid/log
81 COLORTERM=Terminal
82 CONFIG_PROTECT=/usr/share/X11/xkb /var/lib/hsqldb
83 /usr/kde/3.5/share/config /usr/kde/3.5/env /usr/kde/3.5/shutdown
84 /usr/share/config
85 CVS_RSH=ssh
86 GLADE_PIXMAP_PATH=:
87 JDK_HOME=/home/daid/.gentoo/java-config-2/current-user-vm
88 VMHANDLE=sun-jdk-1.4
89 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
90 SESSION_MANAGER=local/flux:@/tmp/.ICE-unix/2541,unix/flux:/tmp/.ICE-unix/2541
91 DISPLAY=:0.0
92 LOGNAME=root
93 JAVA_HOME=/home/daid/.gentoo/java-config-2/current-user-vm
94 SSH_AGENT_PID=2533
95 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
96 XDG_CONFIG_DIRS=/etc/xdg
97 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
98 HOME=/home/daid
99 EDITOR=/usr/bin/vi
100 OLDPWD=/home/daid/log
101 MOCADI_DIR=/home/daid/physics/rib_model/mocadi
102 MOCADI_DATA=/home/daid/physics/rib_model/mocadi/data
103 MOCADI_SPLINES_GZ=/home/daid/physics/rib_model/mocadi/splines_gz
104 ROOTSYS=/usr
105 ROOT_LIBRARIES=/usr/lib/root
106 MYSQL=/usr/include/mysql:/usr/lib/mysql
107 MYSQL_TCP_PORT=3306
108 JAVADIR=/usr/lib/jvm/sun-jdk-1.6
109 USERNAME=root
110 SUDO_COMMAND=/bin/env
111 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
112 TEST=testing
113 SUDO_USER=daid
114 SUDO_UID=1000
115 SUDO_GID=1009
116 TEST=testing
117
118 Or if I want to emerge a specific package, instead I get:
119
120 daid@flux log % sudo emerge =sudo-1.7.2_p2-r2
121 zsh: sudo-1.7.2_p2-r2 not found
122
123 Unlike the PATH problems, the equal problems do not go away with a new
124 instance of zsh overtop of the first one.
125
126 I'm experiencing some other problems with zsh as well, but being able
127 to use sudo is reasonably more pressing, and basic googling on the
128 other errors (problems sourcing /etc/profile and getting a bash
129 prompt, trying to set zsh as my slim login shell fails to login).
130
131 As always, I'm suspicious that I've done something stupid, but I don't
132 see anything obvious. I can use tcsh and bash both just fine. This
133 occurred for both x86 builds on an x86 arch and ~x86 builds on an ~x86
134 arch with the most recent versions of sudo and zsh for those
135 respective arch settings (recent ~x86 upgrade). revdep-rebuild still
136 has a couple things to take care of that need babysitting and/or bug
137 reports, but I would be extremely surprised if those packages are at
138 all related here (things for tex and also libjpeg).
139
140 I'll happily take any advice, even if it's "go back to bash" (although
141 some tips on auto-completion and command correction would be welcome,
142 since I didn't get any reasonable results for these features with
143 bash).
144
145 If it's useful I'll post my working .zshrc and such, but honestly I
146 can't see much reason to do so now since I don't see it as relevant to
147 the problems I see.
148
149 Toodles,
150 daid

Replies

Subject Author
Re: [gentoo-user] zsh and sudo Helmut Jarausch <jarausch@××××××××××××××××.de>
Re: [gentoo-user] zsh and sudo Etaoin Shrdlu <shrdlu@×××××××××××××.org>