Bug 118251

Summary: prelink mishandles temp files if /usr mounted read-only
Product: [Fedora] Fedora Reporter: Robert Nichols <rnichols42>
Component: prelinkAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact:
Severity: high Docs Contact:
Priority: medium    
Version: 1   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: 0.3.1-2 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-03-17 12:49:53 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 Robert Nichols 2004-03-14 15:46:29 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1)
Gecko/20031114

Description of problem:
The scheduled daily prelink job blows up when it attempts to process
binaries on a read-only file system.  When the attempt to create a
temporary file in the current directory fails, the temp file is
created in /tmp.  This is pointless if /tmp is on a different file
system because a subsequent rename will fail due to an invalid
cross-device link.  The big problem is that prelink then fails to
remove the temp file it created.  If there have been major updates, it
is likely that the file system for /tmp will run out of space.  After
this, the full file system causes failures in various other tasks on
the system.

Version-Release number of selected component (if applicable):
prelink-0.3.0-13

How reproducible:
Always

Steps to Reproduce:
1. Run "/usr/sbin/prelink -fav -mR" on a system with /usr mounted
read-only.


Actual Results:  A large number of messages of the form:
  /usr/sbin/prelink: Could not rename temporary to
/usr/X11R6/lib/libX11.so.6.2: Invalid cross-device link

A large number of temporary files are left in /tmp.

The file system containing /tmp runs out of space if it is not large
enough to contain a copy of all of the binaries in /usr.

Expected Results:  Prelink should gracefully fail when it cannot
create a temporary file on the same filesystem as the binary it is
processing.

Additional info:

Comment 1 Jakub Jelinek 2004-03-15 14:31:30 UTC
--- prelink/src/dso.c~  2004-03-15 15:34:13.034559500 +0100
+++ prelink/src/dso.c   2004-03-15 15:34:13.034559500 +0100
@@ -1735,10 +1735,14 @@ update_dso (DSO *dso)
       utime (name2, &u);

       if (set_security_context (dso, name2, name1))
-       return 1;
+        {
+         unlink (name2);
+         return 1;
+       }

       if (rename (name2, name1))
        {
+         unlink (name2);
          error (0, errno, "Could not rename temporary to %s", name1);
          return 1;
        }

should fix this.  I'll include it in 0.3.1-2.

Comment 2 Jay Turner 2004-09-02 05:19:46 UTC
An errata has been issued which should help the problem 
described in this bug report. This report is therefore being 
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files, 
please follow the link below. You may reopen this bug report 
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2004-386.html