Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix netdata-uninstaller; blindly deletes NETDATA_PREFIX env var #16167

Merged
merged 2 commits into from Oct 11, 2023

Conversation

tkatsoulas
Copy link
Contributor

@tkatsoulas tkatsoulas commented Oct 11, 2023

Summary

We noticed that there might be cases in which the NETDATA_PREFIX (during installation) might point to a system wide folder. We need to avoid causes like this by checking the suffix of the path (to be a netdata folder)

This issue affects all "from source" installations that use --install-no-prefix.

Test Plan

Cases: Build-only (you need to instruct local kickstart to point to a local tarball), build from source, static builds

What to check
Install and uninstall; check the folder the uninstaller will remove, they must be just netdata folder

@github-actions github-actions bot added the area/packaging Packaging and operating systems support label Oct 11, 2023
@ilyam8
Copy link
Member

ilyam8 commented Oct 11, 2023

We need to:

  • remove the whole dir only if NETDATA_PREFIX is set, it exists (dir) and ends with /netdata
  • delete specific files/dirs (else branch) otherwise and use the prefix (set to "" if doesn't exist or dir) for all files/dirs except /tmp.

Signed-off-by: Tasos Katsoulas <tasos@netdata.cloud>
@@ -733,20 +733,20 @@ rm_file /etc/cron.daily/netdata-updater
rm_file /etc/cron.d/netdata-updater


if [ -n "${NETDATA_PREFIX}" ] && [ -d "${NETDATA_PREFIX}" ]; then
if [ -n "${NETDATA_PREFIX}" ] && [ -d "${NETDATA_PREFIX}" ] && [ "netdata" = "$(basename "$NETDATA_PREFIX")" ] ; then
rm_dir "${NETDATA_PREFIX}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

covers cases like static installs and macos

rm_dir "${NETDATA_PREFIX}"
else
rm_file "/usr/sbin/netdata"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this block
Linux build from source + FreeBSD

@tkatsoulas tkatsoulas changed the title Update netdata-uninstaller.sh Fix netdata-uninstaller; blindly deletes NETDATA_PREFIX env var Oct 11, 2023
@tkatsoulas tkatsoulas marked this pull request as ready for review October 11, 2023 15:56
@tkatsoulas tkatsoulas merged commit 756046a into master Oct 11, 2023
139 checks passed
@ilyam8 ilyam8 deleted the patch branch October 11, 2023 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/packaging Packaging and operating systems support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants