summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-06-11 23:51:21 +0000
committerZac Medico <zmedico@gentoo.org>2006-06-11 23:51:21 +0000
commit495b89a457686440e2619d6e7ad977c14f939a4a (patch)
treec4e1eb767182a479a8f9ffbcbf9896884bfc37b2
parent81e496207ea5bd809fb64443dc00fd0062a14e08 (diff)
downloadportage-495b89a457686440e2619d6e7ad977c14f939a4a.tar.gz
portage-495b89a457686440e2619d6e7ad977c14f939a4a.tar.bz2
portage-495b89a457686440e2619d6e7ad977c14f939a4a.zip
Wrap more exceptions when applying permissions. Thanks to marienz for reporting.
svn path=/main/trunk/; revision=3493
-rw-r--r--pym/portage_util.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/pym/portage_util.py b/pym/portage_util.py
index 8adc483e5..e9e84e72d 100644
--- a/pym/portage_util.py
+++ b/pym/portage_util.py
@@ -476,8 +476,11 @@ def apply_permissions(filename, uid=-1, gid=-1, mode=-1, mask=-1,
try:
stat_cached = os.stat(filename)
except OSError, oe:
+ func_call = "stat('%s')" % filename
if oe.errno == errno.EPERM:
- raise OperationNotPermitted("stat('%s')" % filename)
+ raise OperationNotPermitted(func_call)
+ elif oe.errno == errno.EACCES:
+ raise PermissionDenied(func_call)
elif oe.errno == errno.ENOENT:
raise FileNotFound(filename)
else:
@@ -489,8 +492,13 @@ def apply_permissions(filename, uid=-1, gid=-1, mode=-1, mask=-1,
os.chown(filename, uid, gid)
modified = True
except OSError, oe:
+ func_call = "chown('%s', %i, %i)" % (filename, uid, gid)
if oe.errno == errno.EPERM:
- raise OperationNotPermitted("chown('%s', %i, %i)" % (filename, uid, gid))
+ raise OperationNotPermitted(func_call)
+ elif oe.errno == errno.EACCES:
+ raise PermissionDenied(func_call)
+ elif oe.errno == errno.EROFS:
+ raise ReadOnlyFileSystem(func_call)
elif oe.errno == errno.ENOENT:
raise FileNotFound(filename)
else:
@@ -520,6 +528,8 @@ def apply_permissions(filename, uid=-1, gid=-1, mode=-1, mask=-1,
func_call = "chmod('%s', %s)" % (filename, oct(new_mode))
if oe.errno == errno.EPERM:
raise OperationNotPermitted(func_call)
+ elif oe.errno == errno.EACCES:
+ raise PermissionDenied(func_call)
elif oe.errno == errno.EROFS:
raise ReadOnlyFileSystem(func_call)
elif oe.errno == errno.ENOENT:
@@ -589,8 +599,11 @@ def apply_secpass_permissions(filename, uid=-1, gid=-1, mode=-1, mask=-1,
try:
stat_cached = os.stat(filename)
except OSError, oe:
+ func_call = "stat('%s')" % filename
if oe.errno == errno.EPERM:
- raise OperationNotPermitted("stat('%s')" % filename)
+ raise OperationNotPermitted(func_call)
+ elif oe.errno == errno.EACCES:
+ raise PermissionDenied(func_call)
elif oe.errno == errno.ENOENT:
raise FileNotFound(filename)
else: