Bug 711358

Summary: Traceback when you are running 'yum install' from directory which does not exist
Product: Red Hat Enterprise Linux 6 Reporter: Petr Sklenar <psklenar>
Component: yumAssignee: James Antill <james.antill>
Status: CLOSED ERRATA QA Contact: Red Hat Satellite QA List <satqe-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1CC: dapospis, ksrot, zpavlas
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: yum-3.2.29-29.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 819534 (view as bug list) Environment:
Last Closed: 2012-06-20 13:51:09 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Petr Sklenar 2011-06-07 09:54:56 UTC
Description of problem:
Traceback when you are running yum from directory which does not exist

Version-Release number of selected component (if applicable):
yum-3.2.29-17.el6.noarch

How reproducible:
deterministic

Steps to Reproduce:
1. be in situation when your working dir is missing, (deleted from another place)
.???.[root@x86-64-6cn-v1 tps]# pwd
/mnt/qa/scratch/xxxxxx/yyyyyy/tps
find: failed to save initial working directory: Stale NFS file handle

  
Actual results:

(118/123): ruby-libs-1.8.7.299-7.el6.i686.rpm                                                          | 1.6 MB     00:01     
(119/123): soprano-2.3.1-1.2.el6.i686.rpm                                                              | 550 kB     00:00     
(120/123): sqlite-3.6.20-1.el6.i686.rpm                                                                | 307 kB     00:00     
(121/123): strigi-libs-0.7.0-2.el6.i686.rpm                                                            | 413 kB     00:00     
(122/123): xz-libs-4.999.9-0.3.beta.20091007git.el6.i686.rpm                                           |  94 kB     00:00     
(123/123): zlib-1.2.3-25.el6.i686.rpm                                                                  |  72 kB     00:00     
------------------------------------------------------------------------------------------------------------------------------
Total                                                                                         460 kB/s |  68 MB     02:32     
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
Traceback (most recent call last):
  File "/usr/share/createrepo/genpkgmetadata.py", line 249, in <module>
    main(sys.argv[1:])
  File "/usr/share/createrepo/genpkgmetadata.py", line 201, in main
    conf = createrepo.MetaDataConfig()
  File "/usr/lib/python2.6/site-packages/createrepo/__init__.py", line 66, in __init__
    self.basedir = os.getcwd()
OSError: [Errno 2] No such file or directory
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.

### then it installs all the package

Expected results:
no traceback

Additional info:

Comment 1 James Antill 2011-06-08 14:16:56 UTC
Do you have the "local" plugin installed?

Comment 2 Petr Sklenar 2011-06-09 06:56:14 UTC
Comment 0 was without local plugin and actually I cannot reproduce it now (maybe more package were updated , ... will try later)

And with yum-plugin-local-1.1.30-6.el6.noarch there is longer traceback and mainly yum stops to continue. Its reproducible with each new package installed and in working nfs directory which is deleted.

mkdir /mnt/xxx/scratch/psklenar/test1
cd /mnt/xx/scratch/psklenar/test1
rm -rf /mnt/xxx/scratch/psklenar/test1
.???.[root@xxxx test1]# yum clean all;yum install zsh-html -y
Loaded plugins: aliases, changelog, downloadonly, kabi, local, presto, refresh-packagekit, rhnplugin, security, tmprepo,
              : verify, versionlock
Loading support for Red Hat kernel ABI
Cleaning repos: rhel-x86_64-client-6 rhel-x86_64-client-6-debuginfo rhel-x86_64-client-fastrack-6
              : rhel-x86_64-client-fastrack-6-debuginfo rhel-x86_64-client-optional-6 rhel-x86_64-client-optional-6-debuginfo
              : rhel-x86_64-client-optional-fastrack-6 rhel-x86_64-client-optional-fastrack-6-debuginfo
              : rhel-x86_64-client-supplementary-6 rhel-x86_64-client-supplementary-6-debuginfo
              : rhn-tools-rhel-x86_64-client-6 rhn-tools-rhel-x86_64-client-6-debuginfo
Cleaning up Everything
0 delta-package files removed, by presto
Loaded plugins: local, rhnplugin
rhel-x86_64-client-6                                                                                  | 1.8 kB     00:00     
rhel-x86_64-client-6/primary                                                                          | 3.7 MB     00:01     
rhel-x86_64-client-6                                                                                               4469/4469
rhel-x86_64-client-6-debuginfo                                                                        | 1.6 kB     00:00     
rhel-x86_64-client-6-debuginfo/primary                                                                | 336 kB     00:00     
rhel-x86_64-client-6-debuginfo                                                                                     1951/1951
rhel-x86_64-client-fastrack-6                                                                         | 1.6 kB     00:00     
rhel-x86_64-client-fastrack-6/primary                                                                 |  16 kB     00:00     
rhel-x86_64-client-fastrack-6                                                                                          49/49
rhel-x86_64-client-fastrack-6-debuginfo                                                               | 1.6 kB     00:00     
rhel-x86_64-client-fastrack-6-debuginfo/primary                                                       | 4.0 kB     00:00     
rhel-x86_64-client-fastrack-6-debuginfo                                                                                20/20
rhel-x86_64-client-optional-6                                                                         | 1.6 kB     00:00     
rhel-x86_64-client-optional-6/primary                                                                 | 1.1 MB     00:00     
rhel-x86_64-client-optional-6                                                                                      4004/4004
rhel-x86_64-client-optional-6-debuginfo                                                               | 1.6 kB     00:00     
rhel-x86_64-client-optional-6-debuginfo/primary                                                       | 266 kB     00:00     
rhel-x86_64-client-optional-6-debuginfo                                                                            1562/1562
rhel-x86_64-client-optional-fastrack-6                                                                | 1.6 kB     00:00     
rhel-x86_64-client-optional-fastrack-6/primary                                                        | 8.0 kB     00:00     
rhel-x86_64-client-optional-fastrack-6                                                                                 29/29
rhel-x86_64-client-optional-fastrack-6-debuginfo                                                      | 1.6 kB     00:00     
rhel-x86_64-client-optional-fastrack-6-debuginfo/primary                                              | 3.0 kB     00:00     
rhel-x86_64-client-optional-fastrack-6-debuginfo                                                                       14/14
rhel-x86_64-client-supplementary-6                                                                    | 1.6 kB     00:00     
rhel-x86_64-client-supplementary-6/primary                                                            |  40 kB     00:00     
rhel-x86_64-client-supplementary-6                                                                                   102/102
rhel-x86_64-client-supplementary-6-debuginfo                                                          | 1.2 kB     00:00     
rhel-x86_64-client-supplementary-6-debuginfo/primary                                                  |  129 B     00:00     
rhn-tools-rhel-x86_64-client-6                                                                        | 1.6 kB     00:00     
rhn-tools-rhel-x86_64-client-6/primary                                                                | 9.2 kB     00:00     
rhn-tools-rhel-x86_64-client-6                                                                                         45/45
rhn-tools-rhel-x86_64-client-6-debuginfo                                                              | 1.2 kB     00:00     
rhn-tools-rhel-x86_64-client-6-debuginfo/primary                                                      |  129 B     00:00     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package zsh-html.x86_64 0:4.3.10-4.1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================
 Package                Arch                 Version                       Repository                                   Size
=============================================================================================================================
Installing:
 zsh-html               x86_64               4.3.10-4.1.el6                rhel-x86_64-client-optional-6               454 k

Transaction Summary
=============================================================================================================================
Install       1 Package(s)

Total download size: 454 k
Installed size: 0  
Downloading Packages:
zsh-html-4.3.10-4.1.el6.x86_64.rpm                                                                    | 454 kB     00:00     
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
Traceback (most recent call last):
  File "/usr/share/createrepo/genpkgmetadata.py", line 249, in <module>
    main(sys.argv[1:])
  File "/usr/share/createrepo/genpkgmetadata.py", line 201, in main
    conf = createrepo.MetaDataConfig()
  File "/usr/lib/python2.6/site-packages/createrepo/__init__.py", line 66, in __init__
    self.basedir = os.getcwd()
OSError: [Errno 2] No such file or directory
Traceback (most recent call last):
  File "/usr/bin/yum", line 29, in <module>
    yummain.user_main(sys.argv[1:], exit_code=True)
  File "/usr/share/yum-cli/yummain.py", line 274, in user_main
    errcode = main(args)
  File "/usr/share/yum-cli/yummain.py", line 211, in main
    return_code = base.doTransaction()
  File "/usr/share/yum-cli/cli.py", line 496, in doTransaction
    problems = self.downloadPkgs(downloadpkgs, callback_total=self.download_callback_total_cb) 
  File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 2000, in downloadPkgs
    self.plugins.run('postdownload', pkglist=pkglist, errors=errors)
  File "/usr/lib/python2.6/site-packages/yum/plugins.py", line 184, in run
    func(conduitcls(self, self.base, conf, **kwargs))
  File "/usr/lib/yum-plugins/local.py", line 79, in postdownload_hook
    _rebuild(conduit, done)
  File "/usr/lib/yum-plugins/local.py", line 125, in _rebuild
    os.utime("%s/repodata/repomd.xml" % local_repo_dir, None)
OSError: [Errno 2] No such file or directory: '/var/lib/yum/plugins/local/repodata/repomd.xml'
find: failed to save initial working directory: Stale NFS file handle

Comment 4 James Antill 2011-12-20 19:36:21 UTC
Not 100% a yum bug, but it seems easiest to work around it in yum with the open(".") fix.

Comment 6 Zdeněk Pavlas 2012-02-14 14:58:44 UTC
Merged the upstream fix, resolves Bug 698795 as well.

Comment 8 Karel Srot 2012-04-05 11:47:08 UTC
This fix has a side-effect which let's me install package from / directory when running localinstall from removed directory.


[root@auto-i386-001 ~]# mkdir p
[root@auto-i386-001 ~]# cd p
[root@auto-i386-001 p]# yumdownloader aide
Loaded plugins: local, product-id, refresh-packagekit, rhnplugin
_local                                                                                 | 3.0 kB     00:00 ... 
_local/primary_db                                                                      | 3.6 kB     00:00 ... 
aide-0.14-3.el6.i686.rpm                                                               | 122 kB     00:00     
[root@auto-i386-001 p]# mv aide-0.14-3.el6.i686.rpm /
[root@auto-i386-001 p]# rmdir ~/p
[root@auto-i386-001 p]# pwd
/root/p
[root@auto-i386-001 p]# yum localinstall aide-0.14-3.el6.i686.rpm
Loaded plugins: downloadonly, local, product-id, refresh-packagekit, rhnplugin, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
No getcwd() access in current directory, moving to /
Setting up Local Package Process
Examining aide-0.14-3.el6.i686.rpm: aide-0.14-3.el6.i686
Marking aide-0.14-3.el6.i686.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package aide.i686 0:0.14-3.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================
 Package             Arch                Version                   Repository                            Size
==============================================================================================================
Installing:
 aide                i686                0.14-3.el6                /aide-0.14-3.el6.i686                295 k

Transaction Summary
==============================================================================================================
Install       1 Package(s)

Total size: 295 k
Installed size: 295 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : aide-0.14-3.el6.i686                                                                       1/1 
Installed products updated.
  Verifying  : aide-0.14-3.el6.i686                                                                       1/1 

Installed:
  aide.i686 0:0.14-3.el6                                                                                      

Complete!

Comment 9 Karel Srot 2012-04-05 12:10:17 UTC
I though I could use that to redirect yum to use /etc/yum.conf instead of differen etc/yum.conf passed using relative address... 

But yum crashes in that case:

# rpm -q yum
yum-3.2.29-28.el6.noarch
# mkdir p
# cd p
# rm -rf ~/p
# yum -c etc/yum.conf install zsh
Traceback (most recent call last):
  File "/usr/bin/yum", line 29, in <module>
    yummain.user_main(sys.argv[1:], exit_code=True)
  File "/usr/share/yum-cli/yummain.py", line 285, in user_main
    errcode = main(args)
  File "/usr/share/yum-cli/yummain.py", line 88, in main
    base.getOptionsConfig(args)
  File "/usr/share/yum-cli/cli.py", line 228, in getOptionsConfig
    self.conf
  File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 901, in <lambda>
    conf = property(fget=lambda self: self._getConfig(),
  File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 295, in _getConfig
    startupconf = config.readStartupConfig(fn, root)
  File "/usr/lib/python2.6/site-packages/yum/config.py", line 866, in readStartupConfig
    confpp_obj = ConfigPreProcessor(configfile)
  File "/usr/lib/python2.6/site-packages/yum/parser.py", line 76, in __init__
    configfile = os.getcwd() + '/' + configfile
OSError: [Errno 2] No such file or directory

Comment 10 James Antill 2012-04-09 18:17:55 UTC
> This fix has a side-effect which let's me install package from / directory when
> running localinstall from removed directory.

Yeh, I would just ignore that as a known issue ... along with other things like using --downloadonly and --downloaddir ... I can't see how you could attack a sysadmin this way that wouldn't mean you could attack them just as easily another way.

Comment 13 errata-xmlrpc 2012-06-20 13:51:09 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0857.html