Bug 1528451 - dracut var dracut_cmd set incorrectly
Summary: dracut var dracut_cmd set incorrectly
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: dracut
Version: 27
Hardware: All
OS: Linux
unspecified
urgent
Target Milestone: ---
Assignee: dracut-maint-list
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-12-21 21:52 UTC by Stephen Champion
Modified: 2018-01-10 11:48 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-01-10 11:48:31 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Stephen Champion 2017-12-21 21:52:17 UTC
Description of problem:
The dracut internal variable dracut_cmd is set with 'readlink -f $0'.
If the argument to readlink -f is not a full path and does not exist in the current working directly, then readlink -f returns $PWD/$0.

If regenerate _all is set, then dracut calls $dracut_cmd.

Presumably this is as root, so I'm setting a high severity.

Version-Release: dracut-046-5.fc27.x86_64

How reproducible: 100%

Steps to Reproduce:
1. Run dracut --regenerate all
2.
3.

Actual results:
It runs $PWD/dracut.

Expected results:
It runs /usr/bin/dracut.

Additional info:
I haven't actually run with --regenerate-all.  I'm chasing another problem, this jumped out at me, and I thought I should flag it...

With a fix, you may want to leave a testing override - which is presumably why readlink was used.

Comment 1 Robert Scheck 2017-12-21 23:27:56 UTC
Oh dear, fancy "pagure over dist-git" stuff is still broken. I am definitely
not the default assignee for "dracut", re-assigning manually for now. Reported
the issue at https://pagure.io/fedora-infrastructure/issue/6587 already.

Comment 2 Harald Hoyer 2018-01-10 10:27:41 UTC
Hmm, I don't know how $0 could end up without a path.

With "--help printing $dracut_cmd"

 cat << EOF
Usage: $dracut_cmd [OPTION]... [<initramfs> [<kernel-version>]]


Test:

creating local dracut executable:

~ # cat dracut
#!/bin/sh

echo "FAIL"
~ # ./dracut 
FAIL

Testing /usr/bin/dracut:

~ # dracut --help | head -1
Usage: /usr/bin/dracut [OPTION]... [<initramfs> [<kernel-version>]]

Comment 3 Stephen Champion 2018-01-10 11:48:31 UTC
In a POSIX shell, $0 is not required to include the full path - only the path components that were used.

But bash is not a POSIX shell, and this is not a bug.


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