"Permission denied" while importing _imaging

Bug #1028396 reported by Łukasz Langa
22
This bug affects 5 people
Affects Status Importance Assigned to Milestone
python-imaging (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

STEPS TO REPRODUCE:

1. Install python-imaging

$ sudo apt-get install python-imaging

2. launch a Python shell and import _imaging

$ python
Python 2.7.3 (default, Apr 20 2012, 22:39:59)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import _imaging

EXPECTED OUTPUT:

None, it's only an import.

ACTUAL OUTPUT:

Error opening file for reading: Permission denied

ADDITIONAL INFO:

The _imaging library is actually /usr/lib/python2.7/dist-packages/PIL/_imaging.so and the error is probably not thrown by this file but by some of its dependencies. The library itself works fine besides that strange error message. Rudimentary stracing didn't give any results:

$ strace python -c "import _imaging" 2>&1 | grep Permission

(returned no output)

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: python-imaging 1.1.7-4
ProcVersionSignature: Ubuntu 3.2.0-23.36-generic 3.2.14
Uname: Linux 3.2.0-23-generic x86_64
ApportVersion: 2.0.1-0ubuntu5
Architecture: amd64
Date: Wed Jul 18 22:47:07 2012
InstallationMedia: Ubuntu-Server 12.04 LTS "Precise Pangolin" - Release amd64 (20120424.1)
ProcEnviron: Error: [Errno 13] Permission denied: '/proc/20269/environ'
SourcePackage: python-imaging
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Łukasz Langa (lukasz-langa) wrote :
Revision history for this message
Xinkai Chen (yeled-nova) wrote :

I have this issue too. It seems that this bug effects not only PIL but every C library in python. In my case, I tried django.contrib.gis.gdal and django.contrib.gis.geos, in addition to PIL.

This bug only appears when certain conditions are met, but I don't know what they are. I tried importing these C libraries with a fresh KUbuntu 12.04, and it worked without any permission complains. However after installing some softwares and several python packages, this bug emerges.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in python-imaging (Ubuntu):
status: New → Confirmed
Revision history for this message
Xinkai Chen (yeled-nova) wrote :

I have found that my using setcap on python interpreter to grant python permission to bind ports under 1024 is causing the problem. Using 'setcap cap_net_bind_service=+ep /usr/bin/python2.7' prevents python to import C extensions correctly.

Revision history for this message
Łukasz Langa (lukasz-langa) wrote :

I found that this is caused not by PIL but by libjpeg-turbo: https://bugs.launchpad.net/libjpeg-turbo/+bug/1020872
This happens if your Python executable is setcapp'ed or otherwise creates /proc/self/* files with owner UID=0.

See my bug hunt here: http://lukasz.langa.pl/5/error-opening-file-for-reading-permission-denied/

Summing up, this should be declared a duplicate of 1020872. If you're affected, vote on that other bug instead.

Revision history for this message
Xinkai Chen (yeled-nova) wrote :

Thank you for the blog. Voted on that bug.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.