summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-06-20 00:01:49 +0000
committerZac Medico <zmedico@gentoo.org>2007-06-20 00:01:49 +0000
commit13ecf921b8e21c1ce98c6da8a5852ba13acfb280 (patch)
treef0d1666f8f386127bb745ecab6c497806fa5d460
parentf1b6fede42435d2c53db5af3d10cdbc1f2853fb1 (diff)
downloadportage-13ecf921b8e21c1ce98c6da8a5852ba13acfb280.tar.gz
portage-13ecf921b8e21c1ce98c6da8a5852ba13acfb280.tar.bz2
portage-13ecf921b8e21c1ce98c6da8a5852ba13acfb280.zip
For bug #180165, make portageq print a "Permission denied" error when appropriate. A PermissionDenied exception is raised from portage.listdir() enven when EmptyOnError is True since errno.EACCES is very likely to indicate a condition that should be reported in any case.
svn path=/main/trunk/; revision=6881
-rwxr-xr-xbin/emerge8
-rwxr-xr-xbin/portageq3
-rw-r--r--pym/portage/__init__.py11
-rw-r--r--pym/portage/exception.py1
4 files changed, 19 insertions, 4 deletions
diff --git a/bin/emerge b/bin/emerge
index 48f327170..0e12b173e 100755
--- a/bin/emerge
+++ b/bin/emerge
@@ -13,4 +13,10 @@ except ImportError:
if __name__ == "__main__":
import sys
- sys.exit(emerge_main())
+ from portage.exception import PermissionDenied
+ try:
+ retval = emerge_main()
+ except PermissionDenied, e:
+ sys.stderr.write("Permission denied: '%s'\n" % str(e))
+ sys.exit(e.errno)
+ sys.exit(retval)
diff --git a/bin/portageq b/bin/portageq
index 968cc129a..b9260fed5 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -383,6 +383,9 @@ def main():
except KeyError:
usage(sys.argv)
sys.exit(os.EX_USAGE)
+ except portage.exception.PermissionDenied, e:
+ sys.stderr.write("Permission denied: '%s'\n" % str(e))
+ sys.exit(e.errno)
main()
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 31f2f091c..f5a4893c1 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -185,7 +185,14 @@ def cacheddir(my_original_path, ignorecvs, ignorelist, EmptyOnError, followSymli
mtime = pathstat[stat.ST_MTIME]
else:
raise portage.exception.DirectoryNotFound(mypath)
- except (IOError,OSError,portage.exception.PortageException):
+ except EnvironmentError, e:
+ if e.errno == portage.exception.PermissionDenied.errno:
+ raise portage.exception.PermissionDenied(mypath)
+ del e
+ if EmptyOnError:
+ return [], []
+ return None, None
+ except portage.exception.PortageException:
if EmptyOnError:
return [], []
return None, None
@@ -199,8 +206,6 @@ def cacheddir(my_original_path, ignorecvs, ignorelist, EmptyOnError, followSymli
if e.errno != errno.EACCES:
raise
del e
- if EmptyOnError:
- return [], []
raise portage.exception.PermissionDenied(mypath)
ftype = []
for x in list:
diff --git a/pym/portage/exception.py b/pym/portage/exception.py
index 4be72cf96..3d590a563 100644
--- a/pym/portage/exception.py
+++ b/pym/portage/exception.py
@@ -53,6 +53,7 @@ class OperationNotPermitted(PortageException):
"""An operation was not permitted operating system"""
class PermissionDenied(PortageException):
+ from errno import EACCES as errno
"""Permission denied"""
class ReadOnlyFileSystem(PortageException):