Skip to content

Commit

Permalink
fixfiles: use grep -F when search in mounts
Browse files Browse the repository at this point in the history
systemd escapes luks uid so that mount points contain '\' and grep
should not consider this as regexp
Fixes:
    $ cat /proc/self/mounts | sort | uniq | awk '{print $2}'
    /run/credentials/systemd-cryptsetup@luks\134x2d6d1f41e6\134x2d5538\134x2d41a0\134x2db383\134x2cd41c2ddcacaa.service

    $ sudo fixfiles -B onboot
    grep: Invalid back reference
    grep: Invalid back reference
    System will relabel on next boot

Suggested-by: Christopher Tubbs <[email protected]>
Signed-off-by: Petr Lautrbach <[email protected]>
  • Loading branch information
bachradsusi committed Dec 12, 2024
1 parent 97ca3b1 commit 0f00c4e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions policycoreutils/scripts/fixfiles
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,24 @@ FS="`cat /proc/self/mounts | sort | uniq | awk '{print $2}'`"
for i in $FS; do
if [ `useseclabel` -ge 0 ]
then
grep " $i " /proc/self/mounts | awk '{print $4}' | grep -E --silent '(^|,)seclabel(,|$)' && echo $i
grep -F " $i " /proc/self/mounts | awk '{print $4}' | grep -E --silent '(^|,)seclabel(,|$)' && echo $i
else
grep " $i " /proc/self/mounts | grep -v "context=" | grep -E --silent '(ext[234]| ext4dev | gfs2 | xfs | jfs | btrfs )' && echo $i
grep -F " $i " /proc/self/mounts | grep -v "context=" | grep -E --silent '(ext[234]| ext4dev | gfs2 | xfs | jfs | btrfs )' && echo $i
fi
done
}

get_rw_labeled_mounts() {
FS=`get_all_labeled_mounts | sort | uniq`
for i in $FS; do
grep " $i " /proc/self/mounts | awk '{print $4}' | grep -E --silent '(^|,)rw(,|$)' && echo $i
grep -F " $i " /proc/self/mounts | awk '{print $4}' | grep -E --silent '(^|,)rw(,|$)' && echo $i
done
}

get_ro_labeled_mounts() {
FS=`get_all_labeled_mounts | sort | uniq`
for i in $FS; do
grep " $i " /proc/self/mounts | awk '{print $4}' | grep -E --silent '(^|,)ro(,|$)' && echo $i
grep -F " $i " /proc/self/mounts | awk '{print $4}' | grep -E --silent '(^|,)ro(,|$)' && echo $i
done
}

Expand Down

0 comments on commit 0f00c4e

Please sign in to comment.