Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2420318
  • 博文数量: 384
  • 博客积分: 10193
  • 博客等级: 上将
  • 技术积分: 3785
  • 用 户 组: 普通用户
  • 注册时间: 2005-06-09 18:02
文章分类

全部博文(384)

文章存档

2011年(10)

2010年(29)

2009年(39)

2008年(36)

2007年(43)

2006年(198)

2005年(29)

分类: LINUX

2010-07-22 22:33:51

今天在执行一个命令时报如下错误:

liang@guoliangc:~$ sudo DIST=lucid pbuilder upgrade
sudo: sorry, you are not allowed to set the following environment variables: DIST

pbuilder是一个编译环境, 需要使用root身份执行, DIST=lucid是指在pbuilder执行时设置DIST环境变量为lucid, 也就是ubuntu 10.4.

出现这个错误是由于sudo不允许传递环境变量给要执行的程序, 解决办法是运行visudo, 添加如下行:

Defaults env_keep+="DIST"

以root方式运行sudo -V可以看到会被保留的, 以及会被舍弃的环境变量等, 在debian sid中, 运行结果如下:

guoliangc:~# sudo -V
Sudo version 1.7.2p7

Sudoers path: /etc/sudoers
Authentication methods: 'pam'
Syslog facility if syslog is being used for logging: authpriv
Syslog priority to use when user authenticates successfully: notice
Syslog priority to use when user authenticates unsuccessfully: alert
Send mail if the user is not in sudoers
Lecture user the first time they run sudo
Require users to authenticate by default
Root may run sudo
Allow some information gathering to give useful error messages
Require fully-qualified hostnames in the sudoers file
Visudo will honor the EDITOR environment variable
Set the LOGNAME and USER environment variables
Length at which to wrap log file lines (0 for no wrap): 80
Authentication timestamp timeout: 15 minutes
Password prompt timeout: 0 minutes
Number of tries to enter a password: 3
Umask to use or 0777 to use user's: 022
Path to mail program: /usr/sbin/sendmail
Flags for mail program: -t
Address to send mail to: root
Subject line for mail messages: *** SECURITY information for %h ***
Incorrect password message: Sorry, try again.
Path to authentication timestamp dir: /var/lib/sudo
Default password prompt: [sudo] password for %p:
Default user to run commands as: root
Value to override user's $PATH with: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
Path to the editor for use by visudo: /usr/bin/editor
When to require a password for 'list' pseudocommand: any
When to require a password for 'verify' pseudocommand: all
File containing dummy exec functions: /usr/lib/sudo/sudo_noexec.so
File descriptors >= 3 will be closed before executing a command
Reset the environment to a default set of variables
Environment variables to check for sanity:
        TERM
        LINGUAS
        LC_*
        LANGUAGE
        LANG
        COLORTERM
Environment variables to remove:
        RUBYOPT
        RUBYLIB
        PYTHONINSPECT
        PYTHONPATH
        PYTHONHOME
        TMPPREFIX
        ZDOTDIR
        READNULLCMD
        NULLCMD
        FPATH
        PERL5DB
        PERL5OPT
        PERL5LIB
        PERLLIB
        PERLIO_DEBUG
        JAVA_TOOL_OPTIONS
        SHELLOPTS
        GLOBIGNORE
        PS4
        BASH_ENV
        ENV
        TERMCAP
        TERMPATH
        TERMINFO_DIRS
        TERMINFO
        _RLD*
        LD_*
        PATH_LOCALE
        NLSPATH
        HOSTALIASES
        RES_OPTIONS
        LOCALDOMAIN
        PS4
        SHELLOPTS
        CDPATH
        IFS
Environment variables to preserve:
        XAUTHORIZATION
        XAUTHORITY
        TZ
        PS2
        PS1
        PATH
        MAIL
        LS_COLORS
        KRB5CCNAME
        HOSTNAME
        HOME
        DISPLAY
        COLORS
Locale to use while parsing sudoers: C
Local IP address and netmask pairs:
        192.168.0.100 / 255.255.255.0
        10.10.0.1 / 255.255.255.0
        10.10.2.1 / 255.255.255.0
        10.10.1.1 / 255.255.255.0
        10.10.3.1 / 255.255.255.0
        fe80::21a:73ff:fe81:ccec / ffff:ffff:ffff:ffff::
        fe80::ec62:e4ff:fedc:fefb / ffff:ffff:ffff:ffff::
        fe80::21a:4bff:fe61:11c9 / ffff:ffff:ffff:ffff::
        fe80::e47d:62ff:fe20:3c64 / ffff:ffff:ffff:ffff::
        fe80::d4ea:d0ff:fe2a:a89b / ffff:ffff:ffff:ffff::
        fe80::f0e7:1eff:fe90:158b / ffff:ffff:ffff:ffff::


阅读(4791) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~