mardi 10 mars 2015

How to get correct file permissions from Macports pip installs?


Macports sets up the ownership of its Python site-packages directory as root.wheel with world-readable permissions. Python packages instally via port install have the same



# ls -l -d /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
drwxr-xr-x 151 root wheel 5134 Mar 8 10:56 /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages


This of course prevents individual users from using pip install to add packages, which is just fine since that really ought to be done as root.


However, if one uses sudo or a root shell to pip install, the packages are installed by pip as readable only by root.wheel (740).



% sudo pip install BeautifulSoup
...
% ls -l -d /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/BeautifulSoup.py
-rw-r----- 1 root wheel 79567 Mar 8 11:09 /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/BeautifulSoup.py


This precludes my user account from actually importing or using the package (*).


How can I get pip to always put reasonable permissions on installed packages?


Update (edit)


I have reworded the question to emphasize that it is about pip installs only. I would also like to emphasize here that the problem is not about needing write permission to the modules. The problem is that the modules are being installed without read permissions.


(*) A hack to fix it is to chmod a+rX the proper permissions (744/755) onto the newly installed package files


Update 2 (solution)


As suggested by both Mark and Ian, and confirmed in a quick test, this has to do with the umask for root. Here is the documentation on how to change /etc/sudoers for OSX. Note that it is not necessarily a good idea to change the umask for all sudo instances!





Aucun commentaire:

Enregistrer un commentaire