Bug 723729

Summary: "was suposed to be installed but is not" for read-only $CWD
Product: [Fedora] Fedora Reporter: Frank Ch. Eigler <fche>
Component: rpmAssignee: Panu Matilainen <pmatilai>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: ffesti, james.antill, jnovy, maxamillion, pmatilai, tim.lauridsen, zpavlas
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-07-21 13:29:57 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:
Attachments:
Description Flags
yum run from read-only /home
none
yum run from read-write /tmp none

Description Frank Ch. Eigler 2011-07-20 22:27:21 UTC
Starting yum from a read-only-mounted home directory thusly fails:

% touch foo
touch: cannot touch `foo': Read-only file system
% sudo yum install gnuchess
[...]
Total download size: 2.4 M
Installed size: 2.4 M
Is this ok [y/N]: y
Downloading Packages:
Setting up and reading Presto delta metadata
Processing delta metadata
Package(s) data still to download: 2.4 M
gnuchess-5.08-1.fc16.x86_64.rpm                                                        | 2.4 MB     00:01     
Running Transaction Check
Running Transaction Test
Transaction Test Succeeded
Running Transaction
gnuchess-5.08-1.fc16.x86_64 was supposed to be installed but is not!

Installed:
  gnuchess.x86_64 0:5.08-1.fc16                                                                               
Complete!


except that the RPM is not actually installed.
If one cd's to another local, read-write directory first, things go:

% cd /tmp
% sudo yum ...
[all is well, unicorns are dancing in the clouds, pink ponies for every birthday]

Comment 1 Zdeněk Pavlas 2011-07-21 07:33:27 UTC
Hi,

I'm having problems reproducing it.  Tried FC14 and the current git HEAD, not rawhide though.  Are you sure that only the CWD was ro?

$ dd if=/dev/zero of=bla bs=1M count=50 && mkfs -f bla
$ mkdir p && mount -o loop bla p -o ro && cd p
$ sudo touch P
touch: cannot touch `P': Read-only file system
$ sudo yum install gnuchess
[unicorns dance]

Comment 2 Frank Ch. Eigler 2011-07-21 11:02:14 UTC
I have an strace -f yum .... log for the working & non-working cases, but
I could find the smoking gun, perhaps because of dbus or whatnot other parties,
but I'll attach them.

It may matter that it was /home that was itself read-only.

Comment 3 Frank Ch. Eigler 2011-07-21 11:04:44 UTC
Created attachment 514183 [details]
yum run from read-only /home

Comment 4 Frank Ch. Eigler 2011-07-21 11:11:39 UTC
Created attachment 514186 [details]
yum run from read-write /tmp

Comment 5 Zdeněk Pavlas 2011-07-21 12:26:52 UTC
$ grep ' open(\".\"' strace*
strace-ro:5277  open(".", O_RDONLY)               = -1 EACCES (Permission denied)
strace-ro:5277  open(".", O_RDONLY)               = -1 EACCES (Permission denied)
strace-rw:5309  open(".", O_RDONLY)               = 15
strace-rw:5309  open(".", O_RDONLY)               = 8

It's the RPM chroot() thing... lib/rpmchroot.c open()s ".", to fchdir() into it later.  This open() surprisingly fails on RO filesystems.  It's a RPM bug, and seems mine version (4.8.1) is not affected.

I think It's quite easy to fix - just strdup() paths instead of FDs, however I'm not a RPM developer.

Comment 6 Zdeněk Pavlas 2011-07-21 12:59:03 UTC
Well, I just gave a try- and it works, so it's probably OK to open directories RDONLY on a RO filesystem..

$ touch x
touch: cannot touch `x': Read-only file system
$ python -c 'import os; print os.open(".", os.O_RDONLY)'
3

Can you try this on your /home?  What kind of filesystem is there?

Comment 7 Frank Ch. Eigler 2011-07-21 13:12:31 UTC
That works the same way here.  It's an NFS filesystem mounted ro.
selinux is disabled on this machine (VM).

Comment 8 James Antill 2011-07-21 13:14:07 UTC
Are we sure this isn't a dup of bug 698795 ?

Comment 9 Zdeněk Pavlas 2011-07-21 13:25:55 UTC
> That works the same way here.

Err, sorry.. Forgot to tell you to try it as root.

Comment 10 Frank Ch. Eigler 2011-07-21 13:29:57 UTC
sudo python -c 'import os; print os.open(".", os.O_RDONLY)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
OSError: [Errno 13] Permission denied: '.'

*** This bug has been marked as a duplicate of bug 698795 ***