From: Zac Medico Date: Sun, 11 Jun 2006 23:51:21 +0000 (-0000) Subject: Wrap more exceptions when applying permissions. Thanks to marienz for reporting. X-Git-Tag: v2.1.1~501 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=495b89a457686440e2619d6e7ad977c14f939a4a;p=portage.git Wrap more exceptions when applying permissions. Thanks to marienz for reporting. svn path=/main/trunk/; revision=3493 --- 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: