[Yum-devel] [PATCH] Ignore EACCES on yumdb stat calls, users can't access yumdb :(. BZ 719467

James Antill james at fedoraproject.org
Fri Jul 8 19:00:30 UTC 2011


On Thu, 2011-07-07 at 11:05 -0400, seth vidal wrote:
> 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.

 Yeh, I think I've fixed it ... assuming that it's just people playing
games with umask when the makedirs() happens.
 I've also been thinking about just ignoring all errors from this stat
call ... as it's almost never awesome to traceback here. Not sure.

> Maybe make the check note the error?

 I don't know what we'd do with the error ... we can't print it here.



More information about the Yum-devel mailing list