Skip to content

Commit

Permalink
fix(squash-lib): harden against empty $initdir
Browse files Browse the repository at this point in the history
The postinstall phase of 99squash-lib has the potential to delete the
whole rootfs if $initdir is empty. This should(tm) never happen.
Nevertheless as the consequences are so devastating it is better to
double check.

Signed-off-by: Philipp Rudo <[email protected]>
(cherry picked from commit 6b089c70761c81a7b82a1bfba5f2c1faef7e972f)

Resolves: RHEL-43460
  • Loading branch information
prudo1 authored and pvalena committed Oct 27, 2024
1 parent b2c9195 commit 69f46c1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions modules.d/99squash-lib/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ squash_install() {
squash_installpost() {
local _file _handler

# this shouldn't happen but...
# ...better safe than deleting your rootfs
if [[ -z $initdir ]]; then
#shellcheck disable=SC2016
dfatal '$initdir not set. Something went terribly wrong.'
exit 1
fi

_handler=$(squash_get_handler)
[[ -n $_handler ]] || return 1

Expand Down

0 comments on commit 69f46c1

Please sign in to comment.