作者:_cristal_500 | 来源:互联网 | 2023-09-10 04:33
在myVagrantinstance:vagrant@archlinux:~$sudopip2installvcardDownloadingunpackingvcardDownlo
在my Vagrant instance:
vagrant@archlinux:~$sudo pip2 install vcard
Downloading/unpacking vcard
Downloading vcard-0.9.tar.gz
Running setup.py (path:/tmp/pip_build_root/vcard/setup.py) egg_info for package vcard
Requirement already satisfied (use --upgrade to upgrade): isodate in /usr/lib/python2.7/site-packages (from vcard)
Installing collected packages: vcard
Running setup.py install for vcard
Installing vcard script to /usr/bin
Successfully installed vcard
Cleaning up...
vagrant@archlinux:~$ls -l $(which vcard)
which: no vcard in (/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl)
total 0
vagrant@archlinux:~$ls -l /usr/bin/vcard
-rwxr-x--- 1 root root 286 Nov 9 10:42 /usr/bin/vcard
/usr/bin/vcard只能由root身份执行.是什么赋予了?
在我最新的Arch Linux machine上它按预期工作:
$sudo pip2 install vcard
Downloading/unpacking vcard
Downloading vcard-0.9.tar.gz
Running setup.py (path:/tmp/pip_build_root/vcard/setup.py) egg_info for package vcard
Requirement already satisfied (use --upgrade to upgrade): isodate in /usr/lib/python2.7/site-packages (from vcard)
Installing collected packages: vcard
Running setup.py install for vcard
Installing vcard script to /usr/bin
Successfully installed vcard
Cleaning up...
$ls -l $(which vcard)
-rwxr-xr-x 1 root root 286 Nov 9 10:40 /usr/bin/vcard
/usr/bin/vcard可由大家执行.
这似乎是由限制性umask引起的:
vagrant@archlinux:~$sudo bash -c umask
0027
原来它设置在vagrant和root用户的.profile中,为unknown reasons:
vagrant@archlinux:~$sudo grep ^umask /root/.profile
umask 027
vagrant@archlinux:~$grep ^umask ~/.profile
umask 027
解决方法:
vcard不仅可以由root用户执行,还可以由组root的任何成员执行.这是由umask为007引起的,或者在pip2启动时更具限制性.只需使用umask 002更改或以:
python -c "import os; os.umask(2); os.system('pip2 install vcard')"