Bug 83391 - [devlabel] mkinitrd does not allow symlinks pointing to your root fs
[devlabel] mkinitrd does not allow symlinks pointing to your root fs
Status: CLOSED NEXTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: mkinitrd (Show other bugs)
9
All Linux
medium Severity medium
: ---
: ---
Assigned To: Peter Jones
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-02-03 14:46 EST by Gary Lerhaupt
Modified: 2008-01-17 12:49 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-08-04 16:19:11 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Gary Lerhaupt 2003-02-03 14:46:12 EST
Description of problem:
With devlabel, one could possibly create a symlink to the root fs partition 
and then reference this symlink in /etc/fstab.  If this is done, however, 
mkinitrd craps out as it is not coded to handle symlinks which point to your 
root fs.  This can easily be fixed with the attached patch:

--- /sbin/mkinitrd.orig	2003-02-03 13:17:21.000000000 -0600
+++ /sbin/mkinitrd	2003-02-03 13:20:53.000000000 -0600
@@ -438,6 +438,11 @@ if echo $rootdev | cut -d/ -f3 | grep -q
     basicmodules="$basicmodules -${loopFs}"
 # check if the root fs is on a logical volume
 elif ! echo $rootdev | cut -c1-6 |grep -q "LABEL=" ; then
+    # check if a symlink is used to point to the root device	
+    if [ `ls -l "$rootdev" | grep -c "^l"` -eq 1 ]; then
+	realrootdev=`ls -l "$rootdev" | sed -e "s/.*-> \+//"`
+	rootdev="$realrootdev"
+    fi
     major=`ls -l "$rootdev" | sed -e "s/.* \\([0-9]\+\\), *[0-9]\+.*/\\1/"`
     [ "$major" -ne 58 ] || root_lvm=1
 fi

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


How reproducible:
Always

Steps to Reproduce:
1. Create a symlink to your root fs partition using devlabel
2. Edit /etc/fstab and replace LABEL=/ with the symlink name from step 1
3. Attempt to use mkinitrd
    
Actual results:
mkinitrd fails

Expected results:
mkinitrd success

Additional info:
Comment 1 Gary Lerhaupt 2003-02-03 14:48:21 EST
This is issue tracker 15136
Comment 2 Gary Lerhaupt 2003-02-03 14:51:00 EST
Matt Domsch points out that

+    if [ `ls -l "$rootdev" | grep -c "^l"` -eq 1 ]; then

looks prettier as such:

+    if [ -L "$rootdev" ]; then
Comment 3 Jeremy Katz 2003-02-11 12:08:40 EST
Fixed in CVS, though by adding a readlink command to nash and using that
Comment 4 Bill Nottingham 2006-08-04 16:19:11 EDT
Red Hat Linux and Red Hat Powertools are currently no longer supported by Red
Hat, Inc. In an effort to clean up bugzilla, we are closing all bugs in MODIFIED
state for these products.

However, we do want to make sure that nothing important slips through the
cracks. If, in fact, these issues are not resolved in a current Fedora Core
Release (such as Fedora Core 5), please open a new issues stating so. Thanks.

Note You need to log in before you can comment on or make changes to this bug.