Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dracut.sh): do not add device if find_block_device returns an error #307

Merged

Conversation

aafeijoo-suse
Copy link
Collaborator

If find_block_device returns an error, the device must not be added to the list of host devices. E.g., a MicroOS system with /etc mounted as overlay is pushing the empty string '' as host device, leading to incorrect results from functions called later which are expecting block devices (i.e. get_persistent_dev and get_maj_min).

//usr/bin/dracut@1658(): readlink -f /etc
/usr/bin/dracut@1658(): mp=/etc
/usr/bin/dracut@1659(): mountpoint /etc
//usr/bin/dracut@1660(): find_block_device /etc
//usr/lib/dracut/dracut-functions.sh@366(find_block_device): local _dev _majmin _find_mpt
//usr/lib/dracut/dracut-functions.sh@367(find_block_device): _find_mpt=/etc
//usr/lib/dracut/dracut-functions.sh@369(find_block_device): [[ '' != yes ]]
//usr/lib/dracut/dracut-functions.sh@370(find_block_device): [[ -d /etc/. ]]
//usr/lib/dracut/dracut-functions.sh@371(find_block_device): findmnt -e -v -n -o MAJ:MIN,SOURCE --target /etc
//usr/lib/dracut/dracut-functions.sh@372(find_block_device): read -r _majmin _dev
//usr/lib/dracut/dracut-functions.sh@373(find_block_device): [[ -b overlay ]]
//usr/lib/dracut/dracut-functions.sh@384(find_block_device): [[ overlay == *:* ]]
//usr/lib/dracut/dracut-functions.sh@372(find_block_device): read -r _majmin _dev
//usr/lib/dracut/dracut-functions.sh@372(find_block_device): '[' -n '' ']'
//usr/lib/dracut/dracut-functions.sh@389(find_block_device): return 1
//usr/lib/dracut/dracut-functions.sh@393(find_block_device): [[ ! -f /etc/fstab ]]
//usr/lib/dracut/dracut-functions.sh@395(find_block_device): findmnt -e --fstab -v -n -o MAJ:MIN,SOURCE --target /etc
//usr/lib/dracut/dracut-functions.sh@396(find_block_device): read -r _majmin _dev
//usr/lib/dracut/dracut-functions.sh@397(find_block_device): [[ -n '' ]]
//usr/lib/dracut/dracut-functions.sh@398(find_block_device): _dev=overlay
//usr/lib/dracut/dracut-functions.sh@399(find_block_device): unset _majmin
//usr/lib/dracut/dracut-functions.sh@401(find_block_device): [[ -b overlay ]]
//usr/lib/dracut/dracut-functions.sh@410(find_block_device): [[ overlay == *:* ]]
//usr/lib/dracut/dracut-functions.sh@396(find_block_device): read -r _majmin _dev
//usr/lib/dracut/dracut-functions.sh@396(find_block_device): '[' -n '' ']'
//usr/lib/dracut/dracut-functions.sh@415(find_block_device): return 1
//usr/lib/dracut/dracut-functions.sh@418(find_block_device): return 1
/usr/bin/dracut@1660(): _dev=
//usr/bin/dracut@1661(): readlink -f /dev/block/
/usr/bin/dracut@1661(): _bdev=/dev/block
/usr/bin/dracut@1662(): [[ -b /dev/block ]]
/usr/bin/dracut@1663(): [[ /etc == \/ ]]
/usr/bin/dracut@1664(): push_host_devs ''

…rror

If `find_block_device` returns an error, the device must not be added to the
list of host devices. E.g., a system with /etc mounted as overlay is pushing
the empty string '' as host device.

```
//usr/bin/dracut@1658(): readlink -f /etc
/usr/bin/dracut@1658(): mp=/etc
/usr/bin/dracut@1659(): mountpoint /etc
//usr/bin/dracut@1660(): find_block_device /etc
//usr/lib/dracut/dracut-functions.sh@366(find_block_device): local _dev _majmin _find_mpt
//usr/lib/dracut/dracut-functions.sh@367(find_block_device): _find_mpt=/etc
//usr/lib/dracut/dracut-functions.sh@369(find_block_device): [[ '' != yes ]]
//usr/lib/dracut/dracut-functions.sh@370(find_block_device): [[ -d /etc/. ]]
//usr/lib/dracut/dracut-functions.sh@371(find_block_device): findmnt -e -v -n -o MAJ:MIN,SOURCE --target /etc
//usr/lib/dracut/dracut-functions.sh@372(find_block_device): read -r _majmin _dev
//usr/lib/dracut/dracut-functions.sh@373(find_block_device): [[ -b overlay ]]
//usr/lib/dracut/dracut-functions.sh@384(find_block_device): [[ overlay == *:* ]]
//usr/lib/dracut/dracut-functions.sh@372(find_block_device): read -r _majmin _dev
//usr/lib/dracut/dracut-functions.sh@372(find_block_device): '[' -n '' ']'
//usr/lib/dracut/dracut-functions.sh@389(find_block_device): return 1
//usr/lib/dracut/dracut-functions.sh@393(find_block_device): [[ ! -f /etc/fstab ]]
//usr/lib/dracut/dracut-functions.sh@395(find_block_device): findmnt -e --fstab -v -n -o MAJ:MIN,SOURCE --target /etc
//usr/lib/dracut/dracut-functions.sh@396(find_block_device): read -r _majmin _dev
//usr/lib/dracut/dracut-functions.sh@397(find_block_device): [[ -n '' ]]
//usr/lib/dracut/dracut-functions.sh@398(find_block_device): _dev=overlay
//usr/lib/dracut/dracut-functions.sh@399(find_block_device): unset _majmin
//usr/lib/dracut/dracut-functions.sh@401(find_block_device): [[ -b overlay ]]
//usr/lib/dracut/dracut-functions.sh@410(find_block_device): [[ overlay == *:* ]]
//usr/lib/dracut/dracut-functions.sh@396(find_block_device): read -r _majmin _dev
//usr/lib/dracut/dracut-functions.sh@396(find_block_device): '[' -n '' ']'
//usr/lib/dracut/dracut-functions.sh@415(find_block_device): return 1
//usr/lib/dracut/dracut-functions.sh@418(find_block_device): return 1
/usr/bin/dracut@1660(): _dev=
//usr/bin/dracut@1661(): readlink -f /dev/block/
/usr/bin/dracut@1661(): _bdev=/dev/block
/usr/bin/dracut@1662(): [[ -b /dev/block ]]
/usr/bin/dracut@1663(): [[ /etc == \/ ]]
/usr/bin/dracut@1664(): push_host_devs ''
```
Check at least that the arguments are not an empty string.
Copy link
Collaborator

@tblume tblume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aafeijoo-suse aafeijoo-suse changed the title A couple of fixes for transactional servers fix(dracut.sh): do not add device if find_block_device returns an error Dec 21, 2023
@aafeijoo-suse aafeijoo-suse merged commit 5a7cf9f into openSUSE:SUSE/059 Dec 21, 2023
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants