From a023916f23847c90905e8d37617a7a8200d11d00 Mon Sep 17 00:00:00 2001 From: dfolcha Date: Thu, 19 Aug 2021 15:08:28 +0200 Subject: [PATCH 1/2] Remove symlink --- rpms/SPECS/4.3.0/wazuh-agent-4.3.0.spec | 3 ++- rpms/SPECS/4.3.0/wazuh-manager-4.3.0.spec | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/rpms/SPECS/4.3.0/wazuh-agent-4.3.0.spec b/rpms/SPECS/4.3.0/wazuh-agent-4.3.0.spec index d1f5042df0..133987bafd 100644 --- a/rpms/SPECS/4.3.0/wazuh-agent-4.3.0.spec +++ b/rpms/SPECS/4.3.0/wazuh-agent-4.3.0.spec @@ -480,7 +480,8 @@ if [ -d %{_localstatedir}/queue/ossec ]; then fi if [ -f %{_sysconfdir}/ossec-init.conf ]; then - rm -rf %{_sysconfdir}/ossec-init.conf + rm -f %{_sysconfdir}/ossec-init.conf + rm -f %{_localstatedir}/etc/ossec-init.conf fi %clean diff --git a/rpms/SPECS/4.3.0/wazuh-manager-4.3.0.spec b/rpms/SPECS/4.3.0/wazuh-manager-4.3.0.spec index 9bf625effd..a18af3a54b 100644 --- a/rpms/SPECS/4.3.0/wazuh-manager-4.3.0.spec +++ b/rpms/SPECS/4.3.0/wazuh-manager-4.3.0.spec @@ -553,7 +553,8 @@ if [ -d %{_localstatedir}/queue/ossec ]; then fi if [ -f %{_sysconfdir}/ossec-init.conf ]; then - rm -rf %{_sysconfdir}/ossec-init.conf + rm -f %{_sysconfdir}/ossec-init.conf + rm -f %{_localstatedir}/etc/ossec-init.conf fi %triggerin -- glibc From 6491d413b604857c06794ff3036458013b8b3bc8 Mon Sep 17 00:00:00 2001 From: dfolcha Date: Thu, 19 Aug 2021 15:12:30 +0200 Subject: [PATCH 2/2] Update AIX SPEC --- aix/SPECS/4.3.0/wazuh-agent-4.3.0-aix.spec | 55 ++++++++++------------ 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/aix/SPECS/4.3.0/wazuh-agent-4.3.0-aix.spec b/aix/SPECS/4.3.0/wazuh-agent-4.3.0-aix.spec index 482e1a8b7f..edbbcc6f17 100644 --- a/aix/SPECS/4.3.0/wazuh-agent-4.3.0-aix.spec +++ b/aix/SPECS/4.3.0/wazuh-agent-4.3.0-aix.spec @@ -101,23 +101,38 @@ if [ $1 = 1 ]; then fi if [ $1 = 2 ]; then - if %{_localstatedir}/bin/wazuh-control status 2>/dev/null | grep "is running" > /dev/null 2>&1; then + if /etc/rc.d/init.d/wazuh-agent status 2>/dev/null | grep "is running" > /dev/null 2>&1; then /etc/rc.d/init.d/wazuh-agent stop > /dev/null 2>&1 || : touch %{_localstatedir}/tmp/wazuh.restart fi %{_localstatedir}/bin/ossec-control stop > /dev/null 2>&1 || %{_localstatedir}/bin/wazuh-control stop > /dev/null 2>&1 fi -%post if [ $1 = 2 ]; then if [ -d %{_localstatedir}/logs/ossec ]; then - rm -rf %{_localstatedir}/logs/wazuh - cp -rp %{_localstatedir}/logs/ossec %{_localstatedir}/logs/wazuh + cp -rp %{_localstatedir}/logs/ossec %{_localstatedir}/tmp/logs/wazuh > /dev/null 2>&1 + rm -rf %{_localstatedir}/logs/ossec/* + rm -rf %{_localstatedir}/logs/ossec/.??* fi if [ -d %{_localstatedir}/queue/ossec ]; then + cp -rp %{_localstatedir}/queue/ossec %{_localstatedir}/tmp/queue/sockets > /dev/null 2>&1 + rm -rf %{_localstatedir}/queue/ossec/* + rm -rf %{_localstatedir}/queue/ossec/.??* + fi +fi + +%post + +if [ $1 = 2 ]; then + if [ -d %{_localstatedir}/tmp/logs/wazuh ]; then + rm -rf %{_localstatedir}/logs/wazuh + mv %{_localstatedir}/tmp/logs/ossec %{_localstatedir}/logs/wazuh> /dev/null 2>&1 + fi + + if [ -d %{_localstatedir}/tmp/queue/sockets ]; then rm -rf %{_localstatedir}/queue/sockets - cp -rp %{_localstatedir}/queue/ossec %{_localstatedir}/queue/sockets + mv %{_localstatedir}/tmp/queue/ossec %{_localstatedir}/queue/sockets > /dev/null 2>&1 fi fi @@ -160,17 +175,6 @@ rm -f %{_localstatedir}/tmp/add_localfiles.sh chmod 0660 %{_localstatedir}/etc/ossec.conf -# Restart wazuh-agent when manager settings are in place -if grep '.*' %{_localstatedir}/etc/ossec.conf | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$' > /dev/null 2>&1; then - /etc/rc.d/init.d/wazuh-agent restart > /dev/null 2>&1 || : -fi -if grep '.*' %{_localstatedir}/etc/ossec.conf > /dev/null 2>&1; then - /etc/rc.d/init.d/wazuh-agent restart > /dev/null 2>&1 || : -fi -if grep '
.*
' %{_localstatedir}/etc/ossec.conf | grep -v 'MANAGER_IP' > /dev/null 2>&1; then - /etc/rc.d/init.d/wazuh-agent restart > /dev/null 2>&1 || : -fi - # Remove old ossec user and group if exists and change ownwership of files if grep "^ossec:" /etc/group > /dev/null 2>&1; then @@ -190,6 +194,11 @@ if grep "^ossec:" /etc/group > /dev/null 2>&1; then rmgroup ossec fi +if [ -f %{_localstatedir}/tmp/wazuh.restart ]; then + rm -f %{_localstatedir}/tmp/wazuh.restart + /etc/rc.d/init.d/wazuh-agent restart > /dev/null 2>&1 || : +fi + %preun if [ $1 = 0 ]; then @@ -219,20 +228,6 @@ if [ $1 = 0 ];then rm -rf %{_localstatedir}/ruleset fi -%posttrans -if [ -f %{_localstatedir}/tmp/wazuh.restart ]; then - rm -f %{_localstatedir}/tmp/wazuh.restart - /etc/rc.d/init.d/wazuh-agent restart > /dev/null 2>&1 || : -fi - -if [ -d %{_localstatedir}/logs/ossec ]; then - rm -rf %{_localstatedir}/logs/ossec/ -fi - -if [ -d %{_localstatedir}/queue/ossec ]; then - rm -rf %{_localstatedir}/queue/ossec/ -fi - %clean rm -fr %{buildroot}