Skip to content

Commit

Permalink
Update rc.initdiskless, fix error handling of remount_optional
Browse files Browse the repository at this point in the history
chkerr() ignores the exit code of a preceding mount command in case a file ```remount_optional``` exists.
The check is performed and a subshell is launched to log the informational message and return.
The return is executed in the context of the subshell, not the context of the chkerr() function, hence is a NOP.
The remount_optional check is hence ineffective.

Change the code to if/then/fi, so the return is evaluated in the context of the  chkerr function, to make the check effective.
  • Loading branch information
kevemueller committed Dec 13, 2024
1 parent 9899985 commit f6ec9d9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libexec/rc/rc.initdiskless
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ log() {
chkerr() {
lastitem () ( n=$(($# - 1)) ; shift $n ; echo $1 )
mountpoint="$(lastitem $2)"
[ -r $mountpoint/remount_optional ] && ( echo "$2 failed: ignoring due to remount_optional" ; return )
if [ -r $mountpoint/remount_optional ]; then
echo "$2 failed: ignoring due to remount_optional"
return
fi
case $1 in
0)
;;
Expand Down

0 comments on commit f6ec9d9

Please sign in to comment.