Skip to content

Commit

Permalink
Merge pull request #1713 from wazuh/1695-error-dynamic-link
Browse files Browse the repository at this point in the history
Fix error when upgrading using symlinks
  • Loading branch information
alberpilot committed Jul 4, 2022
2 parents 200154b + 165beab commit 3fe8d18
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 53 deletions.
8 changes: 4 additions & 4 deletions aix/SPECS/wazuh-agent-aix.spec
Expand Up @@ -178,17 +178,17 @@ chmod 0660 %{_localstatedir}/etc/ossec.conf
# Remove old ossec user and group if exists and change ownwership of files

if grep "^ossec:" /etc/group > /dev/null 2>&1; then
find %{_localstatedir} -group ossec -user root -exec chown root:wazuh {} \; > /dev/null 2>&1 || true
find %{_localstatedir}/ -group ossec -user root -exec chown root:wazuh {} \; > /dev/null 2>&1 || true
if grep "^ossec" /etc/passwd > /dev/null 2>&1; then
find %{_localstatedir} -group ossec -user ossec -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
find %{_localstatedir}/ -group ossec -user ossec -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
userdel ossec
fi
if grep "^ossecm" /etc/passwd > /dev/null 2>&1; then
find %{_localstatedir} -group ossec -user ossecm -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
find %{_localstatedir}/ -group ossec -user ossecm -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
userdel ossecm
fi
if grep "^ossecr" /etc/passwd > /dev/null 2>&1; then
find %{_localstatedir} -group ossec -user ossecr -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
find %{_localstatedir}/ -group ossec -user ossecr -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
userdel ossecr
fi
rmgroup ossec
Expand Down
8 changes: 4 additions & 4 deletions debs/SPECS/wazuh-agent/debian/postinst
Expand Up @@ -139,17 +139,17 @@ case "$1" in
# Remove old ossec user and group if exists and change ownwership of files

if getent group ossec > /dev/null 2>&1; then
find ${DIR} -group ossec -user root -exec chown root:wazuh {} \; > /dev/null 2>&1 || true
find ${DIR}/ -group ossec -user root -exec chown root:wazuh {} \; > /dev/null 2>&1 || true
if getent passwd ossec > /dev/null 2>&1; then
find ${DIR} -group ossec -user ossec -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
find ${DIR}/ -group ossec -user ossec -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
deluser ossec > /dev/null 2>&1
fi
if getent passwd ossecm > /dev/null 2>&1; then
find ${DIR} -group ossec -user ossecm -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
find ${DIR}/ -group ossec -user ossecm -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
deluser ossecm > /dev/null 2>&1
fi
if getent passwd ossecr > /dev/null 2>&1; then
find ${DIR} -group ossec -user ossecr -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
find ${DIR}/ -group ossec -user ossecr -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
deluser ossecr > /dev/null 2>&1
fi
if getent group ossec > /dev/null 2>&1; then
Expand Down
8 changes: 4 additions & 4 deletions debs/SPECS/wazuh-manager/debian/postinst
Expand Up @@ -232,17 +232,17 @@ case "$1" in
# Remove old ossec user and group if exists and change ownwership of files

if getent group ossec > /dev/null 2>&1; then
find ${DIR} -group ossec -user root -exec chown root:wazuh {} \; > /dev/null 2>&1 || true
find ${DIR}/ -group ossec -user root -exec chown root:wazuh {} \; > /dev/null 2>&1 || true
if getent passwd ossec > /dev/null 2>&1; then
find ${DIR} -group ossec -user ossec -exec chown ${USER}:${GROUP} {} \; > /dev/null 2>&1 || true
find ${DIR}/ -group ossec -user ossec -exec chown ${USER}:${GROUP} {} \; > /dev/null 2>&1 || true
deluser ossec > /dev/null 2>&1
fi
if getent passwd ossecm > /dev/null 2>&1; then
find ${DIR} -group ossec -user ossecm -exec chown ${USER}:${GROUP} {} \; > /dev/null 2>&1 || true
find ${DIR}/ -group ossec -user ossecm -exec chown ${USER}:${GROUP} {} \; > /dev/null 2>&1 || true
deluser ossecm > /dev/null 2>&1
fi
if getent passwd ossecr > /dev/null 2>&1; then
find ${DIR} -group ossec -user ossecr -exec chown ${USER}:${GROUP} {} \; > /dev/null 2>&1 || true
find ${DIR}/ -group ossec -user ossecr -exec chown ${USER}:${GROUP} {} \; > /dev/null 2>&1 || true
deluser ossecr > /dev/null 2>&1
fi
if getent group ossec > /dev/null 2>&1; then
Expand Down
8 changes: 4 additions & 4 deletions macos/package_files/postinstall.sh
Expand Up @@ -119,17 +119,17 @@ rm -rf ${DIR}/packages_files
# Remove old ossec user and group if exists and change ownwership of files

if [[ $(dscl . -read /Groups/ossec) ]]; then
find %{_localstatedir} -group ossec -user root -exec chown root:wazuh {} \ > /dev/null 2>&1 || true
find ${DIR}/ -group ossec -user root -exec chown root:wazuh {} \ > /dev/null 2>&1 || true
if [ $(dscl . -read /Users/ossec) ]]; then
find %{_localstatedir} -group ossec -user ossec -exec chown wazuh:wazuh {} \ > /dev/null 2>&1 || true
find ${DIR}/ -group ossec -user ossec -exec chown wazuh:wazuh {} \ > /dev/null 2>&1 || true
sudo /usr/bin/dscl . -delete "/Users/ossec"
fi
if [ $(dscl . -read /Users/ossecm) ]]; then
find %{_localstatedir} -group ossec -user ossecm -exec chown wazuh:wazuh {} \ > /dev/null 2>&1 || true
find ${DIR}/ -group ossec -user ossecm -exec chown wazuh:wazuh {} \ > /dev/null 2>&1 || true
sudo /usr/bin/dscl . -delete "/Users/ossecm"
fi
if [ $(dscl . -read /Users/ossecr) ]]; then
find %{_localstatedir} -group ossec -user ossecr -exec chown wazuh:wazuh {} \ > /dev/null 2>&1 || true
find ${DIR}/ -group ossec -user ossecr -exec chown wazuh:wazuh {} \ > /dev/null 2>&1 || true
sudo /usr/bin/dscl . -delete "/Users/ossecr"
fi
sudo /usr/bin/dscl . -delete "/Groups/ossec"
Expand Down
24 changes: 12 additions & 12 deletions rpms/SPECS/wazuh-agent.spec
Expand Up @@ -177,11 +177,11 @@ exit 0
# Create the wazuh group if it doesn't exists
if command -v getent > /dev/null 2>&1 && ! getent group wazuh > /dev/null 2>&1; then
groupadd -r wazuh
elif ! id -g wazuh > /dev/null 2>&1; then
elif ! getent group wazuh > /dev/null 2>&1; then
groupadd -r wazuh
fi
# Create the wazuh user if it doesn't exists
if ! id -u wazuh > /dev/null 2>&1; then
if ! getent passwd wazuh > /dev/null 2>&1; then
useradd -g wazuh -G wazuh -d %{_localstatedir} -r -s /sbin/nologin wazuh
fi

Expand Down Expand Up @@ -364,18 +364,18 @@ chmod 0660 %{_localstatedir}/etc/ossec.conf

# Remove old ossec user and group if exists and change ownwership of files

if id -g ossec > /dev/null 2>&1; then
find %{_localstatedir} -group ossec -user root -exec chown root:wazuh {} \; > /dev/null 2>&1 || true
if id -u ossec > /dev/null 2>&1; then
find %{_localstatedir} -group ossec -user ossec -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
if getent group ossec > /dev/null 2>&1; then
find %{_localstatedir}/ -group ossec -user root -exec chown root:wazuh {} \; > /dev/null 2>&1 || true
if getent passwd ossec > /dev/null 2>&1; then
find %{_localstatedir}/ -group ossec -user ossec -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
userdel ossec > /dev/null 2>&1
fi
if id -u ossecm > /dev/null 2>&1; then
find %{_localstatedir} -group ossec -user ossecm -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
if getent passwd ossecm > /dev/null 2>&1; then
find %{_localstatedir}/ -group ossec -user ossecm -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
userdel ossecm > /dev/null 2>&1
fi
if id -u ossecr > /dev/null 2>&1; then
find %{_localstatedir} -group ossec -user ossecr -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
if getent passwd ossecr > /dev/null 2>&1; then
find %{_localstatedir}/ -group ossec -user ossecr -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
userdel ossecr > /dev/null 2>&1
fi
if grep -q ossec /etc/group; then
Expand Down Expand Up @@ -430,13 +430,13 @@ fi
# If the package is been uninstalled
if [ $1 = 0 ];then
# Remove the wazuh user if it exists
if id -u wazuh > /dev/null 2>&1; then
if getent passwd wazuh > /dev/null 2>&1; then
userdel wazuh >/dev/null 2>&1
fi
# Remove the wazuh group if it exists
if command -v getent > /dev/null 2>&1 && getent group wazuh > /dev/null 2>&1; then
groupdel wazuh >/dev/null 2>&1
elif id -g wazuh > /dev/null 2>&1; then
elif getent group wazuh > /dev/null 2>&1; then
groupdel wazuh >/dev/null 2>&1
fi

Expand Down
26 changes: 13 additions & 13 deletions rpms/SPECS/wazuh-manager.spec
Expand Up @@ -173,12 +173,12 @@ exit 0
# Create the wazuh group if it doesn't exists
if command -v getent > /dev/null 2>&1 && ! getent group wazuh > /dev/null 2>&1; then
groupadd -r wazuh
elif ! id -g wazuh > /dev/null 2>&1; then
elif ! getent group wazuh > /dev/null 2>&1; then
groupadd -r wazuh
fi

# Create the wazuh user if it doesn't exists
if ! id -u wazuh > /dev/null 2>&1; then
if ! getent passwd wazuh > /dev/null 2>&1; then
useradd -g wazuh -G wazuh -d %{_localstatedir} -r -s /sbin/nologin wazuh
fi

Expand Down Expand Up @@ -442,21 +442,21 @@ rm -f %{_localstatedir}/etc/shared/default/*.rpmnew

# Remove old ossec user and group if exists and change ownwership of files

if id -g ossec > /dev/null 2>&1; then
find %{_localstatedir} -group ossec -user root -exec chown root:wazuh {} \; > /dev/null 2>&1 || true
if id -u ossec > /dev/null 2>&1; then
find %{_localstatedir} -group ossec -user ossec -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
if getent group ossec > /dev/null 2>&1; then
find %{_localstatedir}/ -group ossec -user root -exec chown root:wazuh {} \; > /dev/null 2>&1 || true
if getent passwd ossec > /dev/null 2>&1; then
find %{_localstatedir}/ -group ossec -user ossec -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
userdel ossec > /dev/null 2>&1
fi
if id -u ossecm > /dev/null 2>&1; then
find %{_localstatedir} -group ossec -user ossecm -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
if getent passwd ossecm > /dev/null 2>&1; then
find %{_localstatedir}/ -group ossec -user ossecm -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
userdel ossecm > /dev/null 2>&1
fi
if id -u ossecr > /dev/null 2>&1; then
find %{_localstatedir} -group ossec -user ossecr -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
if getent passwd ossecr > /dev/null 2>&1; then
find %{_localstatedir}/ -group ossec -user ossecr -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
userdel ossecr > /dev/null 2>&1
fi
if id -g ossec > /dev/null 2>&1; then
if getent group ossec > /dev/null 2>&1; then
groupdel ossec > /dev/null 2>&1
fi
fi
Expand Down Expand Up @@ -493,13 +493,13 @@ fi
# If the package is been uninstalled
if [ $1 = 0 ];then
# Remove the wazuh user if it exists
if id -u wazuh > /dev/null 2>&1; then
if getent passwd wazuh > /dev/null 2>&1; then
userdel wazuh >/dev/null 2>&1
fi
# Remove the wazuh group if it exists
if command -v getent > /dev/null 2>&1 && getent group wazuh > /dev/null 2>&1; then
groupdel wazuh >/dev/null 2>&1
elif id -g wazuh > /dev/null 2>&1; then
elif getent group wazuh > /dev/null 2>&1; then
groupdel wazuh >/dev/null 2>&1
fi

Expand Down
8 changes: 4 additions & 4 deletions solaris/solaris11/postinstall.sh
Expand Up @@ -26,17 +26,17 @@ fi

# Remove old ossec user and group if exists and change ownwership of files
if grep "^ossec:" /etc/group > /dev/null 2>&1; then
find ${install_path} -group ossec -user root -exec chown root:wazuh {} \; > /dev/null 2>&1 || true
find ${install_path}/ -group ossec -user root -exec chown root:wazuh {} \; > /dev/null 2>&1 || true
if grep "^ossec" /etc/passwd > /dev/null 2>&1; then
find ${install_path} -group ossec -user ossec -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
find ${install_path}/ -group ossec -user ossec -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
userdel ossec
fi
if grep "^ossecm" /etc/passwd > /dev/null 2>&1; then
find ${install_path} -group ossec -user ossecm -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
find ${install_path}/ -group ossec -user ossecm -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
userdel ossecm
fi
if grep "^ossecr" /etc/passwd > /dev/null 2>&1; then
find ${install_path} -group ossec -user ossecr -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
find ${install_path}/ -group ossec -user ossecr -exec chown wazuh:wazuh {} \; > /dev/null 2>&1 || true
userdel ossecr
fi
groupdel ossec
Expand Down
8 changes: 4 additions & 4 deletions stack/dashboard/rpm/wazuh-dashboard.spec
Expand Up @@ -111,11 +111,11 @@ find %{buildroot}%{INSTALL_DIR}/plugins/wazuh/ -type d -exec chmod 750 {} \;
if [ $1 = 1 ]; then
if command -v getent > /dev/null 2>&1 && ! getent group %{GROUP} > /dev/null 2>&1; then
groupadd -r %{GROUP}
elif ! id -g %{GROUP} > /dev/null 2>&1; then
elif ! getent group %{GROUP} > /dev/null 2>&1; then
groupadd -r %{GROUP}
fi
# Create the wazuh-dashboard user if it doesn't exists
if ! id -u %{USER} > /dev/null 2>&1; then
if ! getent passwd %{USER} > /dev/null 2>&1; then
useradd -g %{GROUP} -G %{USER} -d %{INSTALL_DIR}/ -r -s /sbin/nologin wazuh-dashboard
fi
fi
Expand Down Expand Up @@ -160,13 +160,13 @@ fi
if [ $1 = 0 ];then
# If the package is been uninstalled
# Remove the wazuh-dashboard user if it exists
if id -u %{USER} > /dev/null 2>&1; then
if getent passwd %{USER} > /dev/null 2>&1; then
userdel %{USER} >/dev/null 2>&1
fi
# Remove the wazuh-dashboard group if it exists
if command -v getent > /dev/null 2>&1 && getent group %{GROUP} > /dev/null 2>&1; then
groupdel %{GROUP} >/dev/null 2>&1
elif id -g %{GROUP} > /dev/null 2>&1; then
elif getent group %{GROUP} > /dev/null 2>&1; then
groupdel %{GROUP} >/dev/null 2>&1
fi

Expand Down
4 changes: 2 additions & 2 deletions stack/indexer/deb/debian/postrm
Expand Up @@ -89,14 +89,14 @@ fi

if [ "$REMOVE_USER_AND_GROUP" = "true" ]; then
# Remove the user if it exists
if id -u "${NAME}" > /dev/null 2>&1; then
if getent passwd "${NAME}" > /dev/null 2>&1; then
userdel "${NAME}" > /dev/null 2>&1
fi

# Remove the group if it exists
if command -v getent > /dev/null 2>&1 && getent group "${NAME}" > /dev/null 2>&1; then
groupdel "${NAME}" > /dev/null 2>&1
elif id -g "${NAME}" > /dev/null 2>&1; then
elif getent group "${NAME}" > /dev/null 2>&1; then
groupdel "${NAME}" > /dev/null 2>&1
fi
fi
Expand Down
4 changes: 2 additions & 2 deletions stack/indexer/rpm/wazuh-indexer.spec
Expand Up @@ -210,14 +210,14 @@ if [ $1 = 0 ];then
sed -i '/%{USER}/d' /etc/security/limits.conf

# Remove the user if it exists
if id -u %{USER} > /dev/null 2>&1; then
if getent passwd %{USER} > /dev/null 2>&1; then
userdel %{USER} >/dev/null 2>&1
fi

# Remove the group if it exists
if command -v getent > /dev/null 2>&1 && getent group %{GROUP} > /dev/null 2>&1; then
groupdel %{GROUP} >/dev/null 2>&1
elif id -g %{GROUP} > /dev/null 2>&1; then
elif getent group %{GROUP} > /dev/null 2>&1; then
groupdel %{GROUP} >/dev/null 2>&1
fi

Expand Down

0 comments on commit 3fe8d18

Please sign in to comment.