This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 237034 - yum-fastestmirror should operate without write access to timedhosts.txt
yum-fastestmirror should operate without write access to timedhosts.txt
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: yum-utils (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Luke Macken
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2007-04-18 19:30 EDT by Christopher Aillon
Modified: 2016-09-19 22:37 EDT (History)
3 users (show)

See Also:
Fixed In Version: 1.1.7-1.fc7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-09-17 23:21:19 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Fix fastestmirror plugin to work with nonroot user (710 bytes, patch)
2007-04-19 08:45 EDT, Tim Lauridsen
no flags Details | Diff
Patch (1.21 KB, patch)
2007-08-01 14:02 EDT, Christopher Aillon
no flags Details | Diff

  None (edit)
Description Christopher Aillon 2007-04-18 19:30:43 EDT
Some yum operations, such as yum search traditionally do not require root
access.  But after the mirror cache is set up with root privs, yum commands will
fail if the plugin cannot write to the cache file which is owned by root.  It
should use the values it obtains but simply not write out in this case.

% rpm -qf /usr/lib/yum-plugins/fastestmirror.py
yum-fastestmirror-1.1.1-1.fc7
% whoami 
caillon
% yum --noplugins search firefox-devel
firefox-devel.i386                       2.0.0.3-4.fc7          development     
Matched from:
firefox-devel
Development files for Firefox.  This package exists temporarily.
When xulrunner has reached version 1.0, firefox-devel will be
removed in favor of xulrunner-devel.
% yum search firefox-devel 
Loading "fastestmirror" plugin
Loading "installonlyn" plugin
Determining fastest mirrors
Traceback (most recent call last):
  File "/usr/bin/yum", line 29, in <module>
    yummain.main(sys.argv[1:])
  File "/usr/share/yum-cli/yummain.py", line 82, in main
    base.getOptionsConfig(args)
  File "/usr/share/yum-cli/cli.py", line 156, in getOptionsConfig
    (opts, self.cmds) = self.optparser.setupYumConfig()
  File "/usr/share/yum-cli/cli.py", line 1149, in setupYumConfig
    self.base.setupProgessCallbacks()
  File "/usr/share/yum-cli/output.py", line 322, in setupProgessCallbacks
    self.repos.setProgressBar(TextMeter(fo=sys.stdout))
  File "/usr/lib/python2.5/site-packages/yum/__init__.py", line 493, in <lambda>
    repos = property(fget=lambda self: self._getRepos(),
  File "/usr/lib/python2.5/site-packages/yum/__init__.py", line 342, in _getRepos
    self.plugins.run('postreposetup')
  File "/usr/lib/python2.5/site-packages/yum/plugins.py", line 162, in run
    func(conduitcls(self, self.base, conf, **kwargs))
  File "/usr/lib/yum-plugins/fastestmirror.py", line 88, in postreposetup_hook
    write_timedhosts()
  File "/usr/lib/yum-plugins/fastestmirror.py", line 103, in write_timedhosts
    hostfile = file(hostfilepath, 'w')
IOError: [Errno 13] Permission denied: '/var/cache/yum/timedhosts.txt'
zsh: exit 1     yum search firefox-devel
% ls -hl /var/cache/yum/timedhosts.txt 
-rw-r--r-- 1 root root 578 2007-04-18 16:22 /var/cache/yum/timedhosts.txt
Comment 1 Tim Lauridsen 2007-04-19 08:45:05 EDT
Created attachment 152994 [details]
Fix fastestmirror plugin to work with nonroot user
Comment 2 Tim Lauridsen 2007-04-19 08:46:56 EDT
Luke, 
please check the attached patch, before i submit it.

Comment 3 Christopher Aillon 2007-04-19 12:51:22 EDT
Comment on attachment 152994 [details]
Fix fastestmirror plugin to work with nonroot user

> def postreposetup_hook(conduit):
>     global loadcache
>-    if loadcache:
>+    conf = conduit.getConf()
>+    if loadcache or conf.uid > 0:
>         conduit.info(2, "Loading mirror speeds from cached hostfile")
>         read_timedhosts()
>     else:


Will this handle the case where someone first runs the fastestmirror plugin as
a non-root superuser and then run it from a different non-root user (this might
actually be a different bug here).  I think it might be better to see if the
user has write access to the file.
Comment 4 Luke Macken 2007-04-19 22:50:42 EDT
Tim, it looks like that patch only checks the uid when reading the hostfile,
where as caillon's traceback occurred when fastestmirror writes the hostfile.
Comment 5 Christopher Aillon 2007-08-01 14:02:37 EDT
Created attachment 160442 [details]
Patch

Luke, what do you think about this patch?
Comment 6 Luke Macken 2007-08-08 17:55:15 EDT
Applied, thanks!
Comment 7 Fedora Update System 2007-09-10 12:51:49 EDT
yum-utils-1.1.7-1.fc7 has been pushed to the Fedora 7 testing repository.  If problems still persist, please make note of it in this bug report.
Comment 8 Fedora Update System 2007-09-17 23:21:12 EDT
yum-utils-1.1.7-1.fc7 has been pushed to the Fedora 7 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.