Bug 83391 - [devlabel] mkinitrd does not allow symlinks pointing to your root fs
Summary: [devlabel] mkinitrd does not allow symlinks pointing to your root fs
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: mkinitrd
Version: 9
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Peter Jones
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-02-03 19:46 UTC by Gary Lerhaupt
Modified: 2008-01-17 17:49 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2006-08-04 20:19:11 UTC
Embargoed:


Attachments (Terms of Use)

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
 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 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.


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