-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add filter to default unintaller for pkgs to only remove .app folders (…
…#22585) #22571 - [X] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [X] Added/updated tests - [X] Manual QA for all new/changed functionality
- Loading branch information
1 parent
a230eea
commit c15934f
Showing
6 changed files
with
50 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Fixed software uninstaller script for `pkg`s to only remove '.app' directories installed by the package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
#!/bin/sh | ||
|
||
# Fleet extracts and saves package IDs. | ||
pkg_ids=$PACKAGE_ID | ||
package_app_name="$PACKAGE_ID" | ||
|
||
# Get all files associated with package and remove them | ||
for pkg_id in "${pkg_ids[@]}" | ||
do | ||
# Get volume and location of package | ||
volume=$(pkgutil --pkg-info "$pkg_id" | grep -i "volume" | awk '{for (i=2; i<NF; i++) printf $i " "; print $NF}') | ||
location=$(pkgutil --pkg-info "$pkg_id" | grep -i "location" | awk '{for (i=2; i<NF; i++) printf $i " "; print $NF}') | ||
# Check if this package id corresponds to a valid/installed package | ||
if [[ ! -z "$volume" && ! -z "$location" ]]; then | ||
# Remove individual files/directories belonging to package | ||
pkgutil --files "$pkg_id" | sed -e 's@^@'"$volume""$location"'/@' | tr '\n' '\0' | xargs -n 1 -0 rm -rf | ||
# Remove receipts | ||
pkgutil --forget "$pkg_id" | ||
else | ||
echo "WARNING: volume or location are empty for package ID $pkg_id" | ||
fi | ||
done | ||
# Make sure PACKAGE_ID is not empty. | ||
if [[ -z "$package_app_name" ]]; then | ||
echo "Empty PACKAGE_ID variable." | ||
exit 1 | ||
fi | ||
|
||
# Make sure the PACKAGE_ID doesn't have "../" or is "." | ||
if [[ "$package_app_name" == *".."* || "$package_app_name" == "." ]]; then | ||
echo "Invalid PACKAGE_ID value." | ||
exit 1 | ||
fi | ||
|
||
echo "Removing \"/Applications/$package_app_name\"..." | ||
rm -rf "/Applications/$package_app_name" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
#!/bin/sh | ||
|
||
# Fleet extracts and saves package IDs. | ||
pkg_ids=$PACKAGE_ID | ||
package_app_name="$PACKAGE_ID" | ||
|
||
# Get all files associated with package and remove them | ||
for pkg_id in "${pkg_ids[@]}" | ||
do | ||
# Get volume and location of package | ||
volume=$(pkgutil --pkg-info "$pkg_id" | grep -i "volume" | awk '{for (i=2; i<NF; i++) printf $i " "; print $NF}') | ||
location=$(pkgutil --pkg-info "$pkg_id" | grep -i "location" | awk '{for (i=2; i<NF; i++) printf $i " "; print $NF}') | ||
# Check if this package id corresponds to a valid/installed package | ||
if [[ ! -z "$volume" && ! -z "$location" ]]; then | ||
# Remove individual files/directories belonging to package | ||
pkgutil --files "$pkg_id" | sed -e 's@^@'"$volume""$location"'/@' | tr '\n' '\0' | xargs -n 1 -0 rm -rf | ||
# Remove receipts | ||
pkgutil --forget "$pkg_id" | ||
else | ||
echo "WARNING: volume or location are empty for package ID $pkg_id" | ||
fi | ||
done | ||
# Make sure PACKAGE_ID is not empty. | ||
if [[ -z "$package_app_name" ]]; then | ||
echo "Empty PACKAGE_ID variable." | ||
exit 1 | ||
fi | ||
|
||
# Make sure the PACKAGE_ID doesn't have "../" or is "." | ||
if [[ "$package_app_name" == *".."* || "$package_app_name" == "." ]]; then | ||
echo "Invalid PACKAGE_ID value." | ||
exit 1 | ||
fi | ||
|
||
echo "Removing \"/Applications/$package_app_name\"..." | ||
rm -rf "/Applications/$package_app_name" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters