我会先试着解释我的情况。 我目前在ESXi主机上运行6个虚拟化的Debian服务器。 安装有Debian Linux 6(Lenny)的虚拟服务器。
最近我把服务器更新到debian Wheezy
root@ares> lsb_release -a /home/vincent No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 7.1 (wheezy) Release: 7.1 Codename: wheezy
它已经引起我的注意,因为这个升级“sudo”命令显示奇怪的行为。 其实,这似乎没有任何作用。 我检查了/ etc / visudo文件,一切似乎都没问题。 Sudo也要求我的密码,但似乎并没有以root身份运行。 一个例子是'ifconfig'命令:
user@ares> ifconfig zsh: command not found: ifconfig [127] user@ares> sudo ifconfig sudo: ifconfig: command not found [1] user@ares> sudo su root@ares>ifconfig output shows
任何人可以帮助我在这里?
您的普通用户和root用户的PATH可能有所不同,可能会丢失诸如/sbin和/或/usr/sbin这样的pipe理实用程序(如ifconfig正常运行的目录。
迈克尔的回答是正确的,但我想添加一个评论:
只要在LDAP服务器的/etc/sudoersconfiguration了secure_path指令,就不需要将pipe理命令的path( /sbin , /usr/sbin , /usr/local/sbin )添加到非特权用户,如果您使用LDAP后端:
$ ip as -rbash: ip: command not found $ sudo ip as 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UNKNOWN qlen 1000 link/ether 00:0c:29:57:80:d9 brd ff:ff:ff:ff:ff:ff inet 172.22.197.38/24 brd 172.22.197.255 scope global eth0 $ echo $PATH /home/dawud/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin $ sudo -l | awk '$0~/secure_path/ {print $1}' secure_path=/bin\:/usr/bin\:/sbin\:/usr/sbin\:/usr/local/bin\:/usr/local/sbin
检查man 5 sudoers以获取有关secure_path进一步参考信息(同样感兴趣的是exempt_group和env_reset )。
secure_path Path used for every command run from sudo. If you don't trust the people running sudo to have a sane PATH environment variable you may want to use this. Another use is if you want to have the “root path” be separate from the “user path”. Users in the group specified by the exempt_group option are not affected by secure_path. This option is not set by default.