Bug 237034 - yum-fastestmirror should operate without write access to timedhosts.txt
Summary: yum-fastestmirror should operate without write access to timedhosts.txt
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: yum-utils
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Luke Macken
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-04-18 23:30 UTC by Christopher Aillon
Modified: 2016-09-20 02:37 UTC (History)
3 users (show)

Fixed In Version: 1.1.7-1.fc7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2007-09-18 03:21:19 UTC
Type: ---
Embargoed:


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

Description Christopher Aillon 2007-04-18 23:30:43 UTC
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 12:45:05 UTC
Created attachment 152994 [details]
Fix fastestmirror plugin to work with nonroot user

Comment 2 Tim Lauridsen 2007-04-19 12:46:56 UTC
Luke, 
please check the attached patch, before i submit it.



Comment 3 Christopher Aillon 2007-04-19 16:51:22 UTC
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-20 02:50:42 UTC
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 18:02:37 UTC
Created attachment 160442 [details]
Patch

Luke, what do you think about this patch?

Comment 6 Luke Macken 2007-08-08 21:55:15 UTC
Applied, thanks!

Comment 7 Fedora Update System 2007-09-10 16:51:49 UTC
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-18 03:21:12 UTC
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.