Bug 83391

Summary: [devlabel] mkinitrd does not allow symlinks pointing to your root fs
Product: [Retired] Red Hat Linux Reporter: Gary Lerhaupt <gary_lerhaupt>
Component: mkinitrdAssignee: Peter Jones <pjones>
Status: CLOSED NEXTRELEASE QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: 9CC: tao
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-08-04 20:19:11 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Gary Lerhaupt 2003-02-03 19:46:12 UTC
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

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

How reproducible:

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 19:48:21 UTC
This is issue tracker 15136

Comment 2 Gary Lerhaupt 2003-02-03 19:51:00 UTC
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 17:08:40 UTC
Fixed in CVS, though by adding a readlink command to nash and using that

Comment 4 Bill Nottingham 2006-08-04 20:19:11 UTC
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.