[Yum-devel] [PATCH] Ignore EACCES on yumdb stat calls, users can't access yumdb :(. BZ 719467
seth vidal
skvidal at fedoraproject.org
Thu Jul 7 15:05:27 UTC 2011
On Thu, 2011-07-07 at 10:49 -0400, James Antill wrote:
> ---
> yum/misc.py | 10 ++++++----
> yum/rpmsack.py | 2 +-
> 2 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/yum/misc.py b/yum/misc.py
> index 2f6ddfe..37c572b 100644
> --- a/yum/misc.py
> +++ b/yum/misc.py
> @@ -940,14 +940,16 @@ def unlink_f(filename):
> if e.errno != errno.ENOENT:
> raise
>
> -def stat_f(filename):
> +def stat_f(filename, ignore_EACCES=False):
> """ Call os.stat(), but don't die if the file isn't there. Returns None. """
> try:
> return os.stat(filename)
> except OSError, e:
> - if e.errno not in (errno.ENOENT, errno.ENOTDIR):
> - raise
> - return None
> + if e.errno in (errno.ENOENT, errno.ENOTDIR):
> + return None
> + if ignore_EACCES and e.errno == errno.EACCES:
> + return None
> + raise
>
> def _getloginuid():
> """ Get the audit-uid/login-uid, if available. None is returned if there
> diff --git a/yum/rpmsack.py b/yum/rpmsack.py
> index e289a7a..ed9cabf 100644
> --- a/yum/rpmsack.py
> +++ b/yum/rpmsack.py
> @@ -1753,7 +1753,7 @@ class RPMDBAdditionalDataPackage(object):
> if attr.endswith('.tmp'):
> raise AttributeError, "%s has no attribute %s" % (self, attr)
>
> - info = misc.stat_f(fn)
> + info = misc.stat_f(fn, ignore_EACCES=True)
> if info is None:
> raise AttributeError, "%s has no attribute %s" % (self, attr)
>
the comment on this commit is misleading. Really this is just catching
the type of error where a user cannot access the yumdb. In general they
should be able to.
Maybe make the check note the error?
-sv
More information about the Yum-devel
mailing list