diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2018-12-13 17:05:28 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-13 17:05:28 -0800 |
commit | eaffc7b17140e163b096fda87169c27501290d94 (patch) | |
tree | 83c867743265a2edbb002a0ee826fb0de9b7cbc2 | |
parent | 87e0d8ae8babd9c38b5b3c440cb774fd3b558e38 (diff) | |
parent | cfa45b928007e5b9b90a31ad79cd5cbf2b03c9f4 (diff) | |
download | chef-eaffc7b17140e163b096fda87169c27501290d94.tar.gz |
Merge pull request #8046 from chef/lcg/fix-omnibus-rm-rf
fix EBUSY errors in preinst script
-rwxr-xr-x | omnibus/package-scripts/angrychef/preinst | 11 | ||||
-rwxr-xr-x | omnibus/package-scripts/chef-fips/preinst | 11 | ||||
-rwxr-xr-x | omnibus/package-scripts/chef/preinst | 11 |
3 files changed, 30 insertions, 3 deletions
diff --git a/omnibus/package-scripts/angrychef/preinst b/omnibus/package-scripts/angrychef/preinst index b3038a10c6..870bd5fc37 100755 --- a/omnibus/package-scripts/angrychef/preinst +++ b/omnibus/package-scripts/angrychef/preinst @@ -9,4 +9,13 @@ INSTALLER_DIR=/opt/angrychef echo "removing $INSTALLER_DIR..." -rm -rf $INSTALLER_DIR + +# have to do this dance of moving /opt/chef to a tmp dir since files may be in use +tmp_dir="/opt/.chef.$$" +# if we can't create the tmp_dir then fail hard to prevent any possible security hole +(umask 077 && mkdir $tmp_dir) || exit 1 +# now we can clean up the tmp_dir we created safely +mv $INSTALLER_DIR $tmp_dir +# ignore errors which must be EBUSY issues, this may crate some litter, which may +# be unavoidable +rm -rf $tmp_dir || true diff --git a/omnibus/package-scripts/chef-fips/preinst b/omnibus/package-scripts/chef-fips/preinst index 834c29544b..69909262c9 100755 --- a/omnibus/package-scripts/chef-fips/preinst +++ b/omnibus/package-scripts/chef-fips/preinst @@ -9,4 +9,13 @@ INSTALLER_DIR=/opt/chef-fips echo "removing $INSTALLER_DIR..." -rm -rf $INSTALLER_DIR + +# have to do this dance of moving /opt/chef to a tmp dir since files may be in use +tmp_dir="/opt/.chef.$$" +# if we can't create the tmp_dir then fail hard to prevent any possible security hole +(umask 077 && mkdir $tmp_dir) || exit 1 +# now we can clean up the tmp_dir we created safely +mv $INSTALLER_DIR $tmp_dir +# ignore errors which must be EBUSY issues, this may crate some litter, which may +# be unavoidable +rm -rf $tmp_dir || true diff --git a/omnibus/package-scripts/chef/preinst b/omnibus/package-scripts/chef/preinst index 1880275e99..b3f48258c7 100755 --- a/omnibus/package-scripts/chef/preinst +++ b/omnibus/package-scripts/chef/preinst @@ -9,4 +9,13 @@ INSTALLER_DIR=/opt/chef echo "removing $INSTALLER_DIR..." -rm -rf $INSTALLER_DIR + +# have to do this dance of moving /opt/chef to a tmp dir since files may be in use +tmp_dir="/opt/.chef.$$" +# if we can't create the tmp_dir then fail hard to prevent any possible security hole +(umask 077 && mkdir $tmp_dir) || exit 1 +# now we can clean up the tmp_dir we created safely +mv $INSTALLER_DIR $tmp_dir +# ignore errors which must be EBUSY issues, this may crate some litter, which may +# be unavoidable +rm -rf $tmp_dir || true |