Bug ID 1228847
Summary dracut: syntax error in convertfs module
Classification openSUSE
Product openSUSE Tumbleweed
Version Current
Hardware Other
OS Other
Status NEW
Severity Normal
Priority P5 - None
Component Basesystem
Assignee dracut-maintainers@suse.de
Reporter antonio.feijoo@suse.com
QA Contact qa-bugs@suse.de
Target Milestone ---
Found By ---
Blocker ---

Code from `/usr/bin/convertfs`:

> #mount /sysroot/var if it is a separate mount
> VARDEV=$(sed -n -e 's/^\#.*//' -e '/ \/var /s/\([[:graph:]]* \).*/\1/p' /sysroot/etc/fstab)
> VARFS=$(sed -n -e 's/^\#.*//' -e '/ \/var /s/[[:graph:]]* * [[:graph:]]* *\([[:graph:]]* \).*/\1/p' /sysroot/etc/fstab)
> 
> if [ -n $VARDEV ] && [ -n $VARFS ]; then
>     #mount btrfs subvolume var
>     if [ $VARFS == btrfs ]; then
>         SUBVOLIDVAR=$(btrfs subvolume list $ROOT | sed -n '/var$/s/ID \([[:digit:]]*\) .*/\1/p')
> ...
> [ -n $SUBVOLIDVAR ] && umount $ROOT/var

With POSIX conditionals using single brackets, `-n` followed by a variable
without quotes is always true. So, if /etc/fstab does not define a separate
/var, `[ -n $VARDEV ] && [ -n $VARFS ]` evaluates to true:

> linux-rrky:/home/dev # VARDEV=$(sed -n -e 's/^\#.*//' -e '/ \/var /s/\([[:graph:]]* \).*/\1/p' "$ROOT"/etc/fstab)
> linux-rrky:/home/dev # VARFS=$(sed -n -e 's/^\#.*//' -e '/ \/var /s/[[:graph:]]* * [[:graph:]]* *\([[:graph:]]* \).*/\1/p' "$ROOT"/etc/fstab)
> linux-rrky:/home/dev # if [ -n $VARDEV ] && [ -n $VARFS ]; then echo "VARDEV=$VARDEV VARFS=$VARFS"; fi
> VARDEV= VARFS=
> linux-rrky:/home/dev # if [[ -n $VARDEV ]] && [[ -n $VARFS ]]; then echo "VARDEV=$VARDEV VARFS=$VARFS"; fi
> linux-rrky:/home/dev # if [ $VARFS == btrfs ]; then echo "YES"; else echo "NO"; fi; 
> bash: [: ==: unary operator expected
> NO

Backport fix: https://github.com/openSUSE/dracut/pull/354


You are receiving this mail because: