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
Created attachment 152994 [details] Fix fastestmirror plugin to work with nonroot user
Luke, please check the attached patch, before i submit it.
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.
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.
Created attachment 160442 [details] Patch Luke, what do you think about this patch?
Applied, thanks!
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.
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.