From 8a494a17cc6d0632aba6efecf6c0b398d70790ac Mon Sep 17 00:00:00 2001 From: sowmiyachelliah Date: Mon, 2 Mar 2026 09:43:24 +0000 Subject: [PATCH 01/24] cujo-agent agent.txt - add log rotation --- source/AdvSecuritySsp/Makefile.am | 2 +- source/AdvSecuritySsp/ssp_main.c | 116 ++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 1 deletion(-) diff --git a/source/AdvSecuritySsp/Makefile.am b/source/AdvSecuritySsp/Makefile.am index 89258ef..95f7a24 100644 --- a/source/AdvSecuritySsp/Makefile.am +++ b/source/AdvSecuritySsp/Makefile.am @@ -30,4 +30,4 @@ hardware_platform = i686-linux-gnu bin_PROGRAMS = CcspAdvSecuritySsp CcspAdvSecuritySsp_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/source/AdvSecurityDml -I$(top_srcdir)/source/AdvSecuritySsp $(CPPFLAGS) CcspAdvSecuritySsp_SOURCES = ssp_messagebus_interface.c ssp_main.c ssp_action.c ssp_messagebus_interface_priv.c dm_pack_datamodel.c -CcspAdvSecuritySsp_LDFLAGS = -lccsp_common -ldl -lsyscfg -rdynamic -lwebconfig_framework $(SSP_LDFLAGS) +CcspAdvSecuritySsp_LDFLAGS = -lccsp_common -ldl -lsyscfg -rdynamic -lwebconfig_framework -lpthread -lev $(SSP_LDFLAGS) diff --git a/source/AdvSecuritySsp/ssp_main.c b/source/AdvSecuritySsp/ssp_main.c index e23e68a..f1645ca 100644 --- a/source/AdvSecuritySsp/ssp_main.c +++ b/source/AdvSecuritySsp/ssp_main.c @@ -32,12 +32,18 @@ #include "webconfig_framework.h" #include "safec_lib_common.h" #include +#include +#include #define MAX_SUBSYSTEM_SIZE 32 #define ADVSEC_CCSP_INIT_FILE_BOOTUP "/tmp/advsec_ccsp_initialized_bootup" #define ADVSEC_CUJO_AGENT_ROOT_PRIV "/tmp/advsec_cujo_agent_root_priv" #define BLOCKLIST_FILE "/opt/secure/Blocklist_file.txt" #define ADVSEC_AGENT_PROC_NAME "cujo-agent" +#define ADVSEC_AGENT_LOG_FILE "/rdklogs/logs/agent.txt" +#define ADVSEC_AGENT_LOG_MAX_SIZE (4 * 1024 * 1024) /* 4MB */ +#define ADVSEC_AGENT_LOGROTATE_CONF "/tmp/advsec-agent-logrotate.conf" +#define LOGROTATE_BINARY "/usr/sbin/logrotate" #define NUM_SUBSYSTEM_TYPES (sizeof(gSubsystem_type_table)/sizeof(gSubsystem_type_table[0])) PDSLH_CPE_CONTROLLER_OBJECT pDslhCpeController = NULL; @@ -391,6 +397,105 @@ void drop_root(void) } } +/* Create logrotate configuration file for agent.txt */ +void create_logrotate_config(void) +{ + FILE *fp = fopen(ADVSEC_AGENT_LOGROTATE_CONF, "w"); + if (!fp) + { + CcspTraceError(("Failed to create logrotate config file: %s\n", ADVSEC_AGENT_LOGROTATE_CONF)); + return; + } + + fprintf(fp, "%s {\n", ADVSEC_AGENT_LOG_FILE); + fprintf(fp, " size 4M\n"); // logrotate decides threshold + fprintf(fp, " rotate 2\n"); + fprintf(fp, " start 0\n"); + fprintf(fp, " nodateext\n"); + fprintf(fp, " copytruncate\n"); + fprintf(fp, " missingok\n"); + fprintf(fp, " notifempty\n"); + fprintf(fp, " nocompress\n"); + fprintf(fp, "}\n"); + + fclose(fp); + + CcspTraceInfo(("Logrotate config file created: %s\n", + ADVSEC_AGENT_LOGROTATE_CONF)); +} + +/* Log rotation function for agent.txt using logrotate binary */ +void rotate_agent_log(void) +{ + char cmd[256]; + errno_t rc; + int result; + + CcspTraceInfo(("Triggering logrotate check for agent log...\n")); + + rc = sprintf_s(cmd, sizeof(cmd), "%s %s", LOGROTATE_BINARY, ADVSEC_AGENT_LOGROTATE_CONF); + + if (rc < EOK) + { + ERR_CHK(rc); + return; + } + + result = system(cmd); + + if (result == 0) + { + CcspTraceInfo(("Logrotate executed successfully\n")); + } + else + { + CcspTraceError(("Logrotate execution failed (exit code: %d)\n", result)); + } +} + +/* Callback function for libev stat watcher */ +void agent_log_stat_cb(EV_P_ ev_stat *w, int revents) +{ + (void)loop; + (void)revents; + + if (w->attr.st_nlink) + { + rotate_agent_log(); + } +} + +/* Thread function to run libev event loop for log monitoring */ +void* agent_log_monitor_thread(void* arg) +{ + (void)arg; + + struct ev_loop *loop = NULL; + static ev_stat stat_watcher; + + CcspTraceInfo(("Starting agent log monitor thread\n")); + + /* Create logrotate configuration file */ + create_logrotate_config(); + + /* Create dedicated event loop for this thread */ + loop = ev_loop_new(0); + if (!loop) + { + CcspTraceError(("Failed to create libev event loop\n")); + return NULL; + } + + ev_stat_init(&stat_watcher, agent_log_stat_cb, ADVSEC_AGENT_LOG_FILE, 5.0); + + ev_stat_start(loop, &stat_watcher); + + CcspTraceInfo(("Agent log monitoring started on %s\n", ADVSEC_AGENT_LOG_FILE)); + + ev_run(loop, 0); + ev_loop_destroy(loop); + return NULL; +} int main(int argc, char* argv[]) { ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; @@ -538,6 +643,17 @@ int main(int argc, char* argv[]) exit(0); } + /* Start the agent log monitor thread */ + pthread_t log_monitor_tid; + if (pthread_create(&log_monitor_tid, NULL, agent_log_monitor_thread, NULL) != 0) + { + CcspTraceError(("Failed to create agent log monitor thread\n")); + } + else + { + CcspTraceInfo(("Agent log monitor thread created successfully\n")); + } + if ( bRunAsDaemon ) { while(1) From 8e88ea3f8ccf5b47868e31c41253fdb94f79d2a0 Mon Sep 17 00:00:00 2001 From: sowmiyachelliah Date: Mon, 2 Mar 2026 10:46:55 +0000 Subject: [PATCH 02/24] Updating ssp_main.c --- source/AdvSecuritySsp/ssp_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/AdvSecuritySsp/ssp_main.c b/source/AdvSecuritySsp/ssp_main.c index f1645ca..57b9c2b 100644 --- a/source/AdvSecuritySsp/ssp_main.c +++ b/source/AdvSecuritySsp/ssp_main.c @@ -42,7 +42,7 @@ #define ADVSEC_AGENT_PROC_NAME "cujo-agent" #define ADVSEC_AGENT_LOG_FILE "/rdklogs/logs/agent.txt" #define ADVSEC_AGENT_LOG_MAX_SIZE (4 * 1024 * 1024) /* 4MB */ -#define ADVSEC_AGENT_LOGROTATE_CONF "/tmp/advsec-agent-logrotate.conf" +#define ADVSEC_AGENT_LOGROTATE_CONF "/etc/logrotate.d/advsec-agent" #define LOGROTATE_BINARY "/usr/sbin/logrotate" #define NUM_SUBSYSTEM_TYPES (sizeof(gSubsystem_type_table)/sizeof(gSubsystem_type_table[0])) From 9750e2412d7d8c88e9b8e1bd02a727d1f8c1739a Mon Sep 17 00:00:00 2001 From: sowmiyachelliah Date: Mon, 2 Mar 2026 11:02:00 +0000 Subject: [PATCH 03/24] Updating ssp_main.c --- source/AdvSecuritySsp/ssp_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/AdvSecuritySsp/ssp_main.c b/source/AdvSecuritySsp/ssp_main.c index 57b9c2b..781a62d 100644 --- a/source/AdvSecuritySsp/ssp_main.c +++ b/source/AdvSecuritySsp/ssp_main.c @@ -41,7 +41,7 @@ #define BLOCKLIST_FILE "/opt/secure/Blocklist_file.txt" #define ADVSEC_AGENT_PROC_NAME "cujo-agent" #define ADVSEC_AGENT_LOG_FILE "/rdklogs/logs/agent.txt" -#define ADVSEC_AGENT_LOG_MAX_SIZE (4 * 1024 * 1024) /* 4MB */ +#define ADVSEC_AGENT_LOG_MAX_SIZE (2 * 1024 * 1024) /* 4MB */ #define ADVSEC_AGENT_LOGROTATE_CONF "/etc/logrotate.d/advsec-agent" #define LOGROTATE_BINARY "/usr/sbin/logrotate" #define NUM_SUBSYSTEM_TYPES (sizeof(gSubsystem_type_table)/sizeof(gSubsystem_type_table[0])) From 0ffc62559d6553818f05660a7863220e88e9ae60 Mon Sep 17 00:00:00 2001 From: sowmiyachelliah Date: Tue, 3 Mar 2026 10:45:59 +0000 Subject: [PATCH 04/24] Updating ssp_main.c --- source/AdvSecuritySsp/ssp_main.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/source/AdvSecuritySsp/ssp_main.c b/source/AdvSecuritySsp/ssp_main.c index 781a62d..1c80a18 100644 --- a/source/AdvSecuritySsp/ssp_main.c +++ b/source/AdvSecuritySsp/ssp_main.c @@ -41,7 +41,7 @@ #define BLOCKLIST_FILE "/opt/secure/Blocklist_file.txt" #define ADVSEC_AGENT_PROC_NAME "cujo-agent" #define ADVSEC_AGENT_LOG_FILE "/rdklogs/logs/agent.txt" -#define ADVSEC_AGENT_LOG_MAX_SIZE (2 * 1024 * 1024) /* 4MB */ +#define ADVSEC_AGENT_LOG_MAX_SIZE (2 * 1024 * 1024) /* 2MB - for testing, change to 4MB for production */ #define ADVSEC_AGENT_LOGROTATE_CONF "/etc/logrotate.d/advsec-agent" #define LOGROTATE_BINARY "/usr/sbin/logrotate" #define NUM_SUBSYSTEM_TYPES (sizeof(gSubsystem_type_table)/sizeof(gSubsystem_type_table[0])) @@ -408,7 +408,7 @@ void create_logrotate_config(void) } fprintf(fp, "%s {\n", ADVSEC_AGENT_LOG_FILE); - fprintf(fp, " size 4M\n"); // logrotate decides threshold + fprintf(fp, " size 2M\n"); // Match C code threshold for testing fprintf(fp, " rotate 2\n"); fprintf(fp, " start 0\n"); fprintf(fp, " nodateext\n"); @@ -431,9 +431,9 @@ void rotate_agent_log(void) errno_t rc; int result; - CcspTraceInfo(("Triggering logrotate check for agent log...\n")); - - rc = sprintf_s(cmd, sizeof(cmd), "%s %s", LOGROTATE_BINARY, ADVSEC_AGENT_LOGROTATE_CONF); + /* Call logrotate - it will check size directive in config and only rotate if needed */ + rc = sprintf_s(cmd, sizeof(cmd), "%s -s /tmp/logrotate-advsec.status %s", + LOGROTATE_BINARY, ADVSEC_AGENT_LOGROTATE_CONF); if (rc < EOK) { @@ -443,11 +443,7 @@ void rotate_agent_log(void) result = system(cmd); - if (result == 0) - { - CcspTraceInfo(("Logrotate executed successfully\n")); - } - else + if (result != 0) { CcspTraceError(("Logrotate execution failed (exit code: %d)\n", result)); } From 008088434c095a51563c61f8f797ae7af1e0d121 Mon Sep 17 00:00:00 2001 From: sowmiyachelliah Date: Wed, 4 Mar 2026 08:48:38 +0000 Subject: [PATCH 05/24] Updating ssp_main.c --- source/AdvSecuritySsp/ssp_main.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/source/AdvSecuritySsp/ssp_main.c b/source/AdvSecuritySsp/ssp_main.c index 1c80a18..47b70b3 100644 --- a/source/AdvSecuritySsp/ssp_main.c +++ b/source/AdvSecuritySsp/ssp_main.c @@ -427,12 +427,27 @@ void create_logrotate_config(void) /* Log rotation function for agent.txt using logrotate binary */ void rotate_agent_log(void) { - char cmd[256]; + struct stat st; + char cmd[512]; errno_t rc; int result; - /* Call logrotate - it will check size directive in config and only rotate if needed */ - rc = sprintf_s(cmd, sizeof(cmd), "%s -s /tmp/logrotate-advsec.status %s", + /* Check if file exists and get its size */ + if (stat(ADVSEC_AGENT_LOG_FILE, &st) != 0) + { + return; /* File doesn't exist */ + } + + /* Only call logrotate if file is >= 2MB to avoid excessive calls */ + if (st.st_size < ADVSEC_AGENT_LOG_MAX_SIZE) + { + return; /* File too small, skip */ + } + + CcspTraceInfo(("Agent log reached %ld bytes, calling logrotate...\n", st.st_size)); + + /* Call logrotate with verbose flag to capture errors */ + rc = sprintf_s(cmd, sizeof(cmd), "%s -v -s /tmp/logrotate-advsec.status %s 2>&1 | logger -t ADVSEC_LOGROTATE", LOGROTATE_BINARY, ADVSEC_AGENT_LOGROTATE_CONF); if (rc < EOK) @@ -443,9 +458,13 @@ void rotate_agent_log(void) result = system(cmd); - if (result != 0) + if (result == 0) + { + CcspTraceInfo(("Logrotate completed successfully\n")); + } + else { - CcspTraceError(("Logrotate execution failed (exit code: %d)\n", result)); + CcspTraceError(("Logrotate failed (exit: %d)\n", result)); } } From 9d5c66a6f15d2e213d793e927138ebe8a0231ab4 Mon Sep 17 00:00:00 2001 From: sowmiyachelliah Date: Wed, 4 Mar 2026 09:51:43 +0000 Subject: [PATCH 06/24] Updating ssp_main.c --- source/AdvSecuritySsp/ssp_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/AdvSecuritySsp/ssp_main.c b/source/AdvSecuritySsp/ssp_main.c index 47b70b3..a1c2a42 100644 --- a/source/AdvSecuritySsp/ssp_main.c +++ b/source/AdvSecuritySsp/ssp_main.c @@ -42,7 +42,7 @@ #define ADVSEC_AGENT_PROC_NAME "cujo-agent" #define ADVSEC_AGENT_LOG_FILE "/rdklogs/logs/agent.txt" #define ADVSEC_AGENT_LOG_MAX_SIZE (2 * 1024 * 1024) /* 2MB - for testing, change to 4MB for production */ -#define ADVSEC_AGENT_LOGROTATE_CONF "/etc/logrotate.d/advsec-agent" +#define ADVSEC_AGENT_LOGROTATE_CONF "/nvram/advsec-agent-logrotate.conf" #define LOGROTATE_BINARY "/usr/sbin/logrotate" #define NUM_SUBSYSTEM_TYPES (sizeof(gSubsystem_type_table)/sizeof(gSubsystem_type_table[0])) From 1868a674cbaeb59421371ac76f333227e9841961 Mon Sep 17 00:00:00 2001 From: sowmiyachelliah <162420027+sowmiyachelliah@users.noreply.github.com> Date: Thu, 5 Mar 2026 11:11:41 +0530 Subject: [PATCH 07/24] Update ssp_main.c --- source/AdvSecuritySsp/ssp_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/AdvSecuritySsp/ssp_main.c b/source/AdvSecuritySsp/ssp_main.c index a1c2a42..00301bf 100644 --- a/source/AdvSecuritySsp/ssp_main.c +++ b/source/AdvSecuritySsp/ssp_main.c @@ -41,7 +41,7 @@ #define BLOCKLIST_FILE "/opt/secure/Blocklist_file.txt" #define ADVSEC_AGENT_PROC_NAME "cujo-agent" #define ADVSEC_AGENT_LOG_FILE "/rdklogs/logs/agent.txt" -#define ADVSEC_AGENT_LOG_MAX_SIZE (2 * 1024 * 1024) /* 2MB - for testing, change to 4MB for production */ +#define ADVSEC_AGENT_LOG_MAX_SIZE (2 * 1024 * 1024) /* 2MB - for testing */ #define ADVSEC_AGENT_LOGROTATE_CONF "/nvram/advsec-agent-logrotate.conf" #define LOGROTATE_BINARY "/usr/sbin/logrotate" #define NUM_SUBSYSTEM_TYPES (sizeof(gSubsystem_type_table)/sizeof(gSubsystem_type_table[0])) From ffd7edbecac93b9c03ca996d350d8c8a596fb27d Mon Sep 17 00:00:00 2001 From: sowmiyachelliah Date: Sat, 4 Apr 2026 07:03:31 +0000 Subject: [PATCH 08/24] Adding log rotate code in cosa_adv_security_internal.c --- .../cosa_adv_security_internal.c | 109 +++++++++++++++ source/AdvSecuritySsp/ssp_main.c | 131 ------------------ 2 files changed, 109 insertions(+), 131 deletions(-) diff --git a/source/AdvSecurityDml/cosa_adv_security_internal.c b/source/AdvSecurityDml/cosa_adv_security_internal.c index f722552..0988b23 100644 --- a/source/AdvSecurityDml/cosa_adv_security_internal.c +++ b/source/AdvSecurityDml/cosa_adv_security_internal.c @@ -43,6 +43,9 @@ #include "safec_lib_common.h" #include "secure_wrapper.h" #include +#include +#include +#include #if defined(_COSA_BCM_MIPS_) #include #else @@ -91,6 +94,12 @@ #define SAFEBRO_CONFIG_FILE_PATH "/tmp/safebro.json" #define ADVSEC_PRIMARY_WAN_IF_NAME "erouter0" +/* Logrotate configuration for agent.txt */ +#define ADVSEC_AGENT_LOG_FILE "/rdklogs/logs/agent.txt" +#define ADVSEC_AGENT_LOG_MAX_SIZE (2 * 1024 * 1024) /* 2MB - for testing, change to 4MB for production */ +#define ADVSEC_AGENT_LOGROTATE_CONF "/etc/logrotate.d/advsec-agent" +#define LOGROTATE_BINARY "/usr/sbin/logrotate" + #ifdef CONFIG_CISCO #define CONFIG_VENDOR_NAME "Cisco" #endif @@ -153,6 +162,7 @@ static char prevWanIfname[MAX_INTERFACE_SIZE] = {0}; void advsec_handle_sysevent_async(void); static void advsec_start_logger_thread(void); +static void* agent_log_monitor_thread(void* arg); static BOOL WaitForLoggerTimeout(ULONG period); enum advSysEvent_e{ SYSEVENT_BRIDGE_MODE_EVENT, @@ -1398,6 +1408,19 @@ CosaSecurityInitialize rc = strcpy_s(prevWanIfname, sizeof(prevWanIfname), ADVSEC_PRIMARY_WAN_IF_NAME); ERR_CHK(rc); advsec_start_logger_thread(); + + /* Start the agent log monitor thread */ + pthread_t log_monitor_tid; + if (pthread_create(&log_monitor_tid, NULL, agent_log_monitor_thread, NULL) != 0) + { + CcspTraceError(("Failed to create agent log monitor thread\n")); + } + else + { + pthread_detach(log_monitor_tid); + CcspTraceInfo(("Agent log monitor thread created successfully\n")); + } + advsec_handle_sysevent_async(); #ifdef WAN_FAILOVER_SUPPORTED @@ -2552,6 +2575,92 @@ static void *advsec_sysevent_handler_th(void *arg) } +/* Log rotation function for agent.txt using logrotate binary */ +void rotate_agent_log(void) +{ + struct stat st; + char cmd[512]; + errno_t rc; + int result; + + /* Check if file exists and get its size */ + if (stat(ADVSEC_AGENT_LOG_FILE, &st) != 0) + { + return; /* File doesn't exist */ + } + + /* Only call logrotate if file is >= 2MB to avoid excessive calls */ + if (st.st_size < ADVSEC_AGENT_LOG_MAX_SIZE) + { + return; /* File too small, skip */ + } + + CcspTraceInfo(("Agent log reached %ld bytes, calling logrotate...\n", st.st_size)); + + /* Call logrotate with verbose flag to capture errors */ + rc = sprintf_s(cmd, sizeof(cmd), "%s -v -s /tmp/logrotate-advsec.status %s 2>&1 | logger -t ADVSEC_LOGROTATE", + LOGROTATE_BINARY, ADVSEC_AGENT_LOGROTATE_CONF); + + if (rc < EOK) + { + ERR_CHK(rc); + return; + } + + result = system(cmd); + + if (result == 0) + { + CcspTraceInfo(("Logrotate completed successfully\n")); + } + else + { + CcspTraceError(("Logrotate failed (exit: %d)\n", result)); + } +} + +/* Callback function for libev stat watcher */ +void agent_log_stat_cb(EV_P_ ev_stat *w, int revents) +{ + (void)loop; + (void)revents; + + if (w->attr.st_nlink) + { + rotate_agent_log(); + } +} + +/* Thread function to run libev event loop for log monitoring */ +void* agent_log_monitor_thread(void* arg) +{ + (void)arg; + + struct ev_loop *loop = NULL; + static ev_stat stat_watcher; + + CcspTraceInfo(("Starting agent log monitor thread\n")); + + /* Create dedicated event loop for this thread */ + /* Note: Logrotate config is installed at build time in /etc/logrotate.d/advsec-agent */ + loop = ev_loop_new(0); + if (!loop) + { + CcspTraceError(("Failed to create libev event loop\n")); + return NULL; + } + + ev_stat_init(&stat_watcher, agent_log_stat_cb, ADVSEC_AGENT_LOG_FILE, 5.0); + + ev_stat_start(loop, &stat_watcher); + + CcspTraceInfo(("Agent log monitoring started on %s\n", ADVSEC_AGENT_LOG_FILE)); + + ev_run(loop, 0); + ev_loop_destroy(loop); + return NULL; +} + /* * Create a thread to handle the sysevent asynchronously */ diff --git a/source/AdvSecuritySsp/ssp_main.c b/source/AdvSecuritySsp/ssp_main.c index 00301bf..e23e68a 100644 --- a/source/AdvSecuritySsp/ssp_main.c +++ b/source/AdvSecuritySsp/ssp_main.c @@ -32,18 +32,12 @@ #include "webconfig_framework.h" #include "safec_lib_common.h" #include -#include -#include #define MAX_SUBSYSTEM_SIZE 32 #define ADVSEC_CCSP_INIT_FILE_BOOTUP "/tmp/advsec_ccsp_initialized_bootup" #define ADVSEC_CUJO_AGENT_ROOT_PRIV "/tmp/advsec_cujo_agent_root_priv" #define BLOCKLIST_FILE "/opt/secure/Blocklist_file.txt" #define ADVSEC_AGENT_PROC_NAME "cujo-agent" -#define ADVSEC_AGENT_LOG_FILE "/rdklogs/logs/agent.txt" -#define ADVSEC_AGENT_LOG_MAX_SIZE (2 * 1024 * 1024) /* 2MB - for testing */ -#define ADVSEC_AGENT_LOGROTATE_CONF "/nvram/advsec-agent-logrotate.conf" -#define LOGROTATE_BINARY "/usr/sbin/logrotate" #define NUM_SUBSYSTEM_TYPES (sizeof(gSubsystem_type_table)/sizeof(gSubsystem_type_table[0])) PDSLH_CPE_CONTROLLER_OBJECT pDslhCpeController = NULL; @@ -397,120 +391,6 @@ void drop_root(void) } } -/* Create logrotate configuration file for agent.txt */ -void create_logrotate_config(void) -{ - FILE *fp = fopen(ADVSEC_AGENT_LOGROTATE_CONF, "w"); - if (!fp) - { - CcspTraceError(("Failed to create logrotate config file: %s\n", ADVSEC_AGENT_LOGROTATE_CONF)); - return; - } - - fprintf(fp, "%s {\n", ADVSEC_AGENT_LOG_FILE); - fprintf(fp, " size 2M\n"); // Match C code threshold for testing - fprintf(fp, " rotate 2\n"); - fprintf(fp, " start 0\n"); - fprintf(fp, " nodateext\n"); - fprintf(fp, " copytruncate\n"); - fprintf(fp, " missingok\n"); - fprintf(fp, " notifempty\n"); - fprintf(fp, " nocompress\n"); - fprintf(fp, "}\n"); - - fclose(fp); - - CcspTraceInfo(("Logrotate config file created: %s\n", - ADVSEC_AGENT_LOGROTATE_CONF)); -} - -/* Log rotation function for agent.txt using logrotate binary */ -void rotate_agent_log(void) -{ - struct stat st; - char cmd[512]; - errno_t rc; - int result; - - /* Check if file exists and get its size */ - if (stat(ADVSEC_AGENT_LOG_FILE, &st) != 0) - { - return; /* File doesn't exist */ - } - - /* Only call logrotate if file is >= 2MB to avoid excessive calls */ - if (st.st_size < ADVSEC_AGENT_LOG_MAX_SIZE) - { - return; /* File too small, skip */ - } - - CcspTraceInfo(("Agent log reached %ld bytes, calling logrotate...\n", st.st_size)); - - /* Call logrotate with verbose flag to capture errors */ - rc = sprintf_s(cmd, sizeof(cmd), "%s -v -s /tmp/logrotate-advsec.status %s 2>&1 | logger -t ADVSEC_LOGROTATE", - LOGROTATE_BINARY, ADVSEC_AGENT_LOGROTATE_CONF); - - if (rc < EOK) - { - ERR_CHK(rc); - return; - } - - result = system(cmd); - - if (result == 0) - { - CcspTraceInfo(("Logrotate completed successfully\n")); - } - else - { - CcspTraceError(("Logrotate failed (exit: %d)\n", result)); - } -} - -/* Callback function for libev stat watcher */ -void agent_log_stat_cb(EV_P_ ev_stat *w, int revents) -{ - (void)loop; - (void)revents; - - if (w->attr.st_nlink) - { - rotate_agent_log(); - } -} - -/* Thread function to run libev event loop for log monitoring */ -void* agent_log_monitor_thread(void* arg) -{ - (void)arg; - - struct ev_loop *loop = NULL; - static ev_stat stat_watcher; - - CcspTraceInfo(("Starting agent log monitor thread\n")); - - /* Create logrotate configuration file */ - create_logrotate_config(); - - /* Create dedicated event loop for this thread */ - loop = ev_loop_new(0); - if (!loop) - { - CcspTraceError(("Failed to create libev event loop\n")); - return NULL; - } - - ev_stat_init(&stat_watcher, agent_log_stat_cb, ADVSEC_AGENT_LOG_FILE, 5.0); - - ev_stat_start(loop, &stat_watcher); - - CcspTraceInfo(("Agent log monitoring started on %s\n", ADVSEC_AGENT_LOG_FILE)); - - ev_run(loop, 0); - ev_loop_destroy(loop); - return NULL; -} int main(int argc, char* argv[]) { ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; @@ -658,17 +538,6 @@ int main(int argc, char* argv[]) exit(0); } - /* Start the agent log monitor thread */ - pthread_t log_monitor_tid; - if (pthread_create(&log_monitor_tid, NULL, agent_log_monitor_thread, NULL) != 0) - { - CcspTraceError(("Failed to create agent log monitor thread\n")); - } - else - { - CcspTraceInfo(("Agent log monitor thread created successfully\n")); - } - if ( bRunAsDaemon ) { while(1) From 0034e57ae0e45f33f8d4b9f40ac384b656a86283 Mon Sep 17 00:00:00 2001 From: sowmiyachelliah Date: Sat, 4 Apr 2026 07:06:56 +0000 Subject: [PATCH 09/24] Adding libraries in Makefile.am --- source/AdvSecurityDml/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/AdvSecurityDml/Makefile.am b/source/AdvSecurityDml/Makefile.am index 3fc1176..d2d8456 100644 --- a/source/AdvSecurityDml/Makefile.am +++ b/source/AdvSecurityDml/Makefile.am @@ -26,7 +26,7 @@ hardware_platform = i686-linux-gnu lib_LTLIBRARIES = libdmlasecurity.la libdmlasecurity_la_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/source/AdvSecurityDml -I$(top_srcdir)/source/AdvSecuritySsp $(CPPFLAGS) -I$(top_srcdir)/../Utopia/source/include/sysevent -I${PKG_CONFIG_SYSROOT_DIR}$(includedir)/rbus libdmlasecurity_la_SOURCES = plugin_main.c cosa_adv_security_internal.c cosa_adv_security_dml.c cosa_adv_security_webconfig.c advsecurity_helpers.c advsecurity_param.c -libdmlasecurity_la_LDFLAGS = -lccsp_common -lsyscfg -lsysevent -lwebconfig_framework -lmsgpackc -ltrower-base64 -lsecure_wrapper -lrbus $(SSP_LDFLAGS) +libdmlasecurity_la_LDFLAGS = -lccsp_common -lsyscfg -lsysevent -lwebconfig_framework -lmsgpackc -ltrower-base64 -lsecure_wrapper -lrbus -lev -lpthread $(SSP_LDFLAGS) if WIFI_DATA_COLLECTION libdmlasecurity_la_CPPFLAGS += -DDML_SUPPORT -DNON_PRIVILEGED -DWIFI_DATA_COLLECTION From 62357f59667e961327db486e06eb0ab4688b90b0 Mon Sep 17 00:00:00 2001 From: sowmiyachelliah Date: Sat, 4 Apr 2026 08:22:19 +0000 Subject: [PATCH 10/24] Updating cosa_adv_security_internal.c --- source/AdvSecurityDml/cosa_adv_security_internal.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/source/AdvSecurityDml/cosa_adv_security_internal.c b/source/AdvSecurityDml/cosa_adv_security_internal.c index 0988b23..d74c2cf 100644 --- a/source/AdvSecurityDml/cosa_adv_security_internal.c +++ b/source/AdvSecurityDml/cosa_adv_security_internal.c @@ -2607,15 +2607,14 @@ void rotate_agent_log(void) return; } - result = system(cmd); - - if (result == 0) + result = v_secure_system(cmd); + if (result != 0) { - CcspTraceInfo(("Logrotate completed successfully\n")); + CcspTraceError(("Logrotate failed with return code: %d\n", result)); } else { - CcspTraceError(("Logrotate failed (exit: %d)\n", result)); + CcspTraceInfo(("Logrotate completed successfully\n")); } } From 942b1a0030e2e0c7af806e61bc2b97b73186a8cd Mon Sep 17 00:00:00 2001 From: sowmiyachelliah Date: Sat, 4 Apr 2026 09:06:56 +0000 Subject: [PATCH 11/24] Updating cosa_adv_security_internal.c --- source/AdvSecurityDml/cosa_adv_security_internal.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/source/AdvSecurityDml/cosa_adv_security_internal.c b/source/AdvSecurityDml/cosa_adv_security_internal.c index d74c2cf..4b082e5 100644 --- a/source/AdvSecurityDml/cosa_adv_security_internal.c +++ b/source/AdvSecurityDml/cosa_adv_security_internal.c @@ -2579,8 +2579,6 @@ static void *advsec_sysevent_handler_th(void *arg) void rotate_agent_log(void) { struct stat st; - char cmd[512]; - errno_t rc; int result; /* Check if file exists and get its size */ @@ -2598,16 +2596,8 @@ void rotate_agent_log(void) CcspTraceInfo(("Agent log reached %ld bytes, calling logrotate...\n", st.st_size)); /* Call logrotate with verbose flag to capture errors */ - rc = sprintf_s(cmd, sizeof(cmd), "%s -v -s /tmp/logrotate-advsec.status %s 2>&1 | logger -t ADVSEC_LOGROTATE", - LOGROTATE_BINARY, ADVSEC_AGENT_LOGROTATE_CONF); - - if (rc < EOK) - { - ERR_CHK(rc); - return; - } - - result = v_secure_system(cmd); + result = v_secure_system("%s -v -s /tmp/logrotate-advsec.status %s 2>&1 | logger -t ADVSEC_LOGROTATE", + LOGROTATE_BINARY, ADVSEC_AGENT_LOGROTATE_CONF); if (result != 0) { CcspTraceError(("Logrotate failed with return code: %d\n", result)); From f6a125631b7b325bcfd1bc3d6a31fd62a77d171e Mon Sep 17 00:00:00 2001 From: sowmiyachelliah Date: Mon, 6 Apr 2026 07:45:20 +0000 Subject: [PATCH 12/24] Updating cosa_adv_security_internal.c --- source/AdvSecurityDml/cosa_adv_security_internal.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/source/AdvSecurityDml/cosa_adv_security_internal.c b/source/AdvSecurityDml/cosa_adv_security_internal.c index 4b082e5..be26789 100644 --- a/source/AdvSecurityDml/cosa_adv_security_internal.c +++ b/source/AdvSecurityDml/cosa_adv_security_internal.c @@ -2581,22 +2581,19 @@ void rotate_agent_log(void) struct stat st; int result; - /* Check if file exists and get its size */ if (stat(ADVSEC_AGENT_LOG_FILE, &st) != 0) { - return; /* File doesn't exist */ + return; } - /* Only call logrotate if file is >= 2MB to avoid excessive calls */ if (st.st_size < ADVSEC_AGENT_LOG_MAX_SIZE) { - return; /* File too small, skip */ + return; } CcspTraceInfo(("Agent log reached %ld bytes, calling logrotate...\n", st.st_size)); - /* Call logrotate with verbose flag to capture errors */ - result = v_secure_system("%s -v -s /tmp/logrotate-advsec.status %s 2>&1 | logger -t ADVSEC_LOGROTATE", + result = v_secure_system("%s -s /tmp/logrotate-advsec.status %s 2>&1 | logger -t ADVSEC_LOGROTATE", LOGROTATE_BINARY, ADVSEC_AGENT_LOGROTATE_CONF); if (result != 0) { @@ -2630,8 +2627,6 @@ void* agent_log_monitor_thread(void* arg) CcspTraceInfo(("Starting agent log monitor thread\n")); - /* Create dedicated event loop for this thread */ - /* Note: Logrotate config is installed at build time in /etc/logrotate.d/advsec-agent */ loop = ev_loop_new(0); if (!loop) { From 73fd38c1b95d87503c49a7be81e5b2c045dee799 Mon Sep 17 00:00:00 2001 From: sowmiyachelliah <162420027+sowmiyachelliah@users.noreply.github.com> Date: Mon, 6 Apr 2026 16:15:41 +0530 Subject: [PATCH 13/24] Update cosa_adv_security_internal.c --- source/AdvSecurityDml/cosa_adv_security_internal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/AdvSecurityDml/cosa_adv_security_internal.c b/source/AdvSecurityDml/cosa_adv_security_internal.c index be26789..e27b34f 100644 --- a/source/AdvSecurityDml/cosa_adv_security_internal.c +++ b/source/AdvSecurityDml/cosa_adv_security_internal.c @@ -96,7 +96,7 @@ /* Logrotate configuration for agent.txt */ #define ADVSEC_AGENT_LOG_FILE "/rdklogs/logs/agent.txt" -#define ADVSEC_AGENT_LOG_MAX_SIZE (2 * 1024 * 1024) /* 2MB - for testing, change to 4MB for production */ +#define ADVSEC_AGENT_LOG_MAX_SIZE (2 * 1024 * 1024) #define ADVSEC_AGENT_LOGROTATE_CONF "/etc/logrotate.d/advsec-agent" #define LOGROTATE_BINARY "/usr/sbin/logrotate" From 21369657affc260789ef8a0aa5cb45dc5fd670ed Mon Sep 17 00:00:00 2001 From: sowmiyachelliah Date: Mon, 6 Apr 2026 15:02:33 +0000 Subject: [PATCH 14/24] cosa_adv_security_internal.c --- source/AdvSecurityDml/cosa_adv_security_internal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/AdvSecurityDml/cosa_adv_security_internal.c b/source/AdvSecurityDml/cosa_adv_security_internal.c index e27b34f..09812f0 100644 --- a/source/AdvSecurityDml/cosa_adv_security_internal.c +++ b/source/AdvSecurityDml/cosa_adv_security_internal.c @@ -2593,7 +2593,7 @@ void rotate_agent_log(void) CcspTraceInfo(("Agent log reached %ld bytes, calling logrotate...\n", st.st_size)); - result = v_secure_system("%s -s /tmp/logrotate-advsec.status %s 2>&1 | logger -t ADVSEC_LOGROTATE", + result = v_secure_system("%s -s /tmp/logrotate-advsec.status %s", LOGROTATE_BINARY, ADVSEC_AGENT_LOGROTATE_CONF); if (result != 0) { From e8a8fa62b743f9ed75ba461f60ab18be34138a0b Mon Sep 17 00:00:00 2001 From: sowmiyachelliah Date: Mon, 6 Apr 2026 16:03:39 +0000 Subject: [PATCH 15/24] Updating cosa_adv_security_internal.c --- source/AdvSecurityDml/cosa_adv_security_internal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/AdvSecurityDml/cosa_adv_security_internal.c b/source/AdvSecurityDml/cosa_adv_security_internal.c index 09812f0..c63e5f3 100644 --- a/source/AdvSecurityDml/cosa_adv_security_internal.c +++ b/source/AdvSecurityDml/cosa_adv_security_internal.c @@ -2593,7 +2593,7 @@ void rotate_agent_log(void) CcspTraceInfo(("Agent log reached %ld bytes, calling logrotate...\n", st.st_size)); - result = v_secure_system("%s -s /tmp/logrotate-advsec.status %s", + result = v_secure_system("%s /tmp/logrotate-advsec.status %s", LOGROTATE_BINARY, ADVSEC_AGENT_LOGROTATE_CONF); if (result != 0) { From 760dd0b3826872f65ad1bbd4ec936e59ccb55080 Mon Sep 17 00:00:00 2001 From: sowmiyachelliah Date: Tue, 7 Apr 2026 15:18:15 +0000 Subject: [PATCH 16/24] Updating cosa_adv_security_internal.c --- source/AdvSecurityDml/cosa_adv_security_internal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/AdvSecurityDml/cosa_adv_security_internal.c b/source/AdvSecurityDml/cosa_adv_security_internal.c index c63e5f3..66843d8 100644 --- a/source/AdvSecurityDml/cosa_adv_security_internal.c +++ b/source/AdvSecurityDml/cosa_adv_security_internal.c @@ -2308,7 +2308,7 @@ static async_id_t async_id[4]; enum {SYS_EVENT_ERROR=-1, SYS_EVENT_OK, SYS_EVENT_TIMEOUT, SYS_EVENT_HANDLE_EXIT, SYS_EVENT_RECEIVED=0x10}; /* - * Initialize sysevnt + * Initialize sysevent * return 0 if success and -1 if failure. */ int advsec_sysevent_init(void) @@ -2593,8 +2593,8 @@ void rotate_agent_log(void) CcspTraceInfo(("Agent log reached %ld bytes, calling logrotate...\n", st.st_size)); - result = v_secure_system("%s /tmp/logrotate-advsec.status %s", - LOGROTATE_BINARY, ADVSEC_AGENT_LOGROTATE_CONF); + result = v_secure_system("%s %s", + LOGROTATE_BINARY, ADVSEC_AGENT_LOGROTATE_CONF); if (result != 0) { CcspTraceError(("Logrotate failed with return code: %d\n", result)); From 6b6d9620c1c4f25734d44566185fae6692e15679 Mon Sep 17 00:00:00 2001 From: sowmiyachelliah <162420027+sowmiyachelliah@users.noreply.github.com> Date: Wed, 8 Apr 2026 11:18:05 +0530 Subject: [PATCH 17/24] Update cosa_adv_security_internal.c --- source/AdvSecurityDml/cosa_adv_security_internal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/AdvSecurityDml/cosa_adv_security_internal.c b/source/AdvSecurityDml/cosa_adv_security_internal.c index 66843d8..e1b18bf 100644 --- a/source/AdvSecurityDml/cosa_adv_security_internal.c +++ b/source/AdvSecurityDml/cosa_adv_security_internal.c @@ -2308,7 +2308,7 @@ static async_id_t async_id[4]; enum {SYS_EVENT_ERROR=-1, SYS_EVENT_OK, SYS_EVENT_TIMEOUT, SYS_EVENT_HANDLE_EXIT, SYS_EVENT_RECEIVED=0x10}; /* - * Initialize sysevent + * Initialize sysevnt * return 0 if success and -1 if failure. */ int advsec_sysevent_init(void) From 9f9b4550a42606aec6310d133a48c67b5b616871 Mon Sep 17 00:00:00 2001 From: sowmiyachelliah Date: Fri, 10 Apr 2026 09:28:34 +0000 Subject: [PATCH 18/24] Updating cosa_adv_security_internal.c --- .../cosa_adv_security_internal.c | 175 +++++++++--------- 1 file changed, 91 insertions(+), 84 deletions(-) diff --git a/source/AdvSecurityDml/cosa_adv_security_internal.c b/source/AdvSecurityDml/cosa_adv_security_internal.c index e1b18bf..1c4546a 100644 --- a/source/AdvSecurityDml/cosa_adv_security_internal.c +++ b/source/AdvSecurityDml/cosa_adv_security_internal.c @@ -96,7 +96,8 @@ /* Logrotate configuration for agent.txt */ #define ADVSEC_AGENT_LOG_FILE "/rdklogs/logs/agent.txt" -#define ADVSEC_AGENT_LOG_MAX_SIZE (2 * 1024 * 1024) +#define ADVSEC_AGENT_LOG_MAX_SIZE (2 * 1024 * 1024) /* 2MB */ +#define ADVSEC_AGENT_LOG_INTERVAL 5.0 #define ADVSEC_AGENT_LOGROTATE_CONF "/etc/logrotate.d/advsec-agent" #define LOGROTATE_BINARY "/usr/sbin/logrotate" @@ -163,6 +164,7 @@ static char prevWanIfname[MAX_INTERFACE_SIZE] = {0}; void advsec_handle_sysevent_async(void); static void advsec_start_logger_thread(void); static void* agent_log_monitor_thread(void* arg); +static void advsec_start_log_monitor_thread(void); static BOOL WaitForLoggerTimeout(ULONG period); enum advSysEvent_e{ SYSEVENT_BRIDGE_MODE_EVENT, @@ -1408,19 +1410,7 @@ CosaSecurityInitialize rc = strcpy_s(prevWanIfname, sizeof(prevWanIfname), ADVSEC_PRIMARY_WAN_IF_NAME); ERR_CHK(rc); advsec_start_logger_thread(); - - /* Start the agent log monitor thread */ - pthread_t log_monitor_tid; - if (pthread_create(&log_monitor_tid, NULL, agent_log_monitor_thread, NULL) != 0) - { - CcspTraceError(("Failed to create agent log monitor thread\n")); - } - else - { - pthread_detach(log_monitor_tid); - CcspTraceInfo(("Agent log monitor thread created successfully\n")); - } - + advsec_start_log_monitor_thread(); advsec_handle_sysevent_async(); #ifdef WAN_FAILOVER_SUPPORTED @@ -1770,6 +1760,93 @@ static void advsec_start_logger_thread(void) } } +/* Log rotation function for agent.txt using logrotate binary */ +void rotate_agent_log(void) +{ + struct stat st; + int result; + + if (stat(ADVSEC_AGENT_LOG_FILE, &st) != 0) + { + return; + } + + if (st.st_size < ADVSEC_AGENT_LOG_MAX_SIZE) + { + return; + } + + CcspTraceInfo(("Agent log reached %ld bytes, calling logrotate...\n", st.st_size)); + + result = v_secure_system("%s /tmp/logrotate-advsec.status %s", + LOGROTATE_BINARY, ADVSEC_AGENT_LOGROTATE_CONF); + if (result != 0) + { + CcspTraceError(("Logrotate failed with return code: %d\n", result)); + } + else + { + CcspTraceInfo(("Logrotate completed successfully\n")); + } +} + +/* Callback function for libev stat watcher */ +void agent_log_stat_cb(EV_P_ ev_stat *w, int revents) +{ + (void)loop; + (void)revents; + + if (w->attr.st_nlink) + { + rotate_agent_log(); + } +} + +/* Thread function to run libev event loop for log monitoring */ +void* agent_log_monitor_thread(void* arg) +{ + (void)arg; + + struct ev_loop *loop = NULL; + static ev_stat stat_watcher; + + CcspTraceDebug(("Starting agent log monitor thread\n")); + + loop = ev_loop_new(0); + if (!loop) + { + CcspTraceError(("Failed to create libev event loop\n")); + return NULL; + } + + ev_stat_init(&stat_watcher, agent_log_stat_cb, ADVSEC_AGENT_LOG_FILE, ADVSEC_AGENT_LOG_INTERVAL); + + ev_stat_start(loop, &stat_watcher); + + CcspTraceDebug(("Agent log monitoring started on %s\n", ADVSEC_AGENT_LOG_FILE)); + + ev_run(loop, 0); + ev_loop_destroy(loop); + return NULL; +} + +static void advsec_start_log_monitor_thread(void) +{ + int err; + pthread_t log_monitor_tid; + + err = pthread_create(&log_monitor_tid, NULL, agent_log_monitor_thread, NULL); + if (err != 0) + { + CcspTraceError(("%s: Failed to create agent log monitor thread\n", __FUNCTION__)); + } + else + { + pthread_detach(log_monitor_tid); + CcspTraceDebug(("%s: Agent log monitor thread created successfully\n", __FUNCTION__)); + } +} + ANSC_STATUS CosaAdvSecStartFeatures(advsec_feature_type type) { ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; @@ -2575,76 +2652,6 @@ static void *advsec_sysevent_handler_th(void *arg) } -/* Log rotation function for agent.txt using logrotate binary */ -void rotate_agent_log(void) -{ - struct stat st; - int result; - - if (stat(ADVSEC_AGENT_LOG_FILE, &st) != 0) - { - return; - } - - if (st.st_size < ADVSEC_AGENT_LOG_MAX_SIZE) - { - return; - } - - CcspTraceInfo(("Agent log reached %ld bytes, calling logrotate...\n", st.st_size)); - - result = v_secure_system("%s %s", - LOGROTATE_BINARY, ADVSEC_AGENT_LOGROTATE_CONF); - if (result != 0) - { - CcspTraceError(("Logrotate failed with return code: %d\n", result)); - } - else - { - CcspTraceInfo(("Logrotate completed successfully\n")); - } -} - -/* Callback function for libev stat watcher */ -void agent_log_stat_cb(EV_P_ ev_stat *w, int revents) -{ - (void)loop; - (void)revents; - - if (w->attr.st_nlink) - { - rotate_agent_log(); - } -} - -/* Thread function to run libev event loop for log monitoring */ -void* agent_log_monitor_thread(void* arg) -{ - (void)arg; - - struct ev_loop *loop = NULL; - static ev_stat stat_watcher; - - CcspTraceInfo(("Starting agent log monitor thread\n")); - - loop = ev_loop_new(0); - if (!loop) - { - CcspTraceError(("Failed to create libev event loop\n")); - return NULL; - } - - ev_stat_init(&stat_watcher, agent_log_stat_cb, ADVSEC_AGENT_LOG_FILE, 5.0); - - ev_stat_start(loop, &stat_watcher); - - CcspTraceInfo(("Agent log monitoring started on %s\n", ADVSEC_AGENT_LOG_FILE)); - - ev_run(loop, 0); - ev_loop_destroy(loop); - return NULL; -} - /* * Create a thread to handle the sysevent asynchronously */ From bb8ad44c13b92336150799740d913a6163997bdc Mon Sep 17 00:00:00 2001 From: sowmiyachelliah Date: Fri, 10 Apr 2026 10:02:07 +0000 Subject: [PATCH 19/24] Updating Makefile.am to resolve unit test case failure --- source/test/CcspAdvSecurityDmlTest/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/test/CcspAdvSecurityDmlTest/Makefile.am b/source/test/CcspAdvSecurityDmlTest/Makefile.am index 2d61c7b..111e72d 100644 --- a/source/test/CcspAdvSecurityDmlTest/Makefile.am +++ b/source/test/CcspAdvSecurityDmlTest/Makefile.am @@ -46,7 +46,7 @@ CcspAdvSecurityDmlTest_gtest_bin_SOURCES = CcspAdvSecurityMock.cpp \ ${top_builddir}/source/AdvSecurityDml/plugin_main.c \ gtest_main.cpp -CcspAdvSecurityDmlTest_gtest_bin_LDFLAGS = -lgtest -lgmock -lgcov -pthread +CcspAdvSecurityDmlTest_gtest_bin_LDFLAGS = -lgtest -lgmock -lgcov -pthread -lev CcspAdvSecurityDmlTest_gtest_bin_LDADD = \ $(HOME)/usr/local/lib/libmock_syscfg.la \ From d1d8fffe8d422cbd14b2d72ae7f045b5c51b7c03 Mon Sep 17 00:00:00 2001 From: sowmiyachelliah Date: Fri, 10 Apr 2026 14:35:32 +0000 Subject: [PATCH 20/24] Updating cosa_adv_security_internal.c and Makefile.am --- source/AdvSecurityDml/cosa_adv_security_internal.c | 1 - source/AdvSecuritySsp/Makefile.am | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/source/AdvSecurityDml/cosa_adv_security_internal.c b/source/AdvSecurityDml/cosa_adv_security_internal.c index 1c4546a..db2877f 100644 --- a/source/AdvSecurityDml/cosa_adv_security_internal.c +++ b/source/AdvSecurityDml/cosa_adv_security_internal.c @@ -95,7 +95,6 @@ #define ADVSEC_PRIMARY_WAN_IF_NAME "erouter0" /* Logrotate configuration for agent.txt */ -#define ADVSEC_AGENT_LOG_FILE "/rdklogs/logs/agent.txt" #define ADVSEC_AGENT_LOG_MAX_SIZE (2 * 1024 * 1024) /* 2MB */ #define ADVSEC_AGENT_LOG_INTERVAL 5.0 #define ADVSEC_AGENT_LOGROTATE_CONF "/etc/logrotate.d/advsec-agent" diff --git a/source/AdvSecuritySsp/Makefile.am b/source/AdvSecuritySsp/Makefile.am index 95f7a24..89258ef 100644 --- a/source/AdvSecuritySsp/Makefile.am +++ b/source/AdvSecuritySsp/Makefile.am @@ -30,4 +30,4 @@ hardware_platform = i686-linux-gnu bin_PROGRAMS = CcspAdvSecuritySsp CcspAdvSecuritySsp_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/source/AdvSecurityDml -I$(top_srcdir)/source/AdvSecuritySsp $(CPPFLAGS) CcspAdvSecuritySsp_SOURCES = ssp_messagebus_interface.c ssp_main.c ssp_action.c ssp_messagebus_interface_priv.c dm_pack_datamodel.c -CcspAdvSecuritySsp_LDFLAGS = -lccsp_common -ldl -lsyscfg -rdynamic -lwebconfig_framework -lpthread -lev $(SSP_LDFLAGS) +CcspAdvSecuritySsp_LDFLAGS = -lccsp_common -ldl -lsyscfg -rdynamic -lwebconfig_framework $(SSP_LDFLAGS) From eb9ffe4162fbc4a90c50f73c08d0b525e0c094a4 Mon Sep 17 00:00:00 2001 From: sowmiyachelliah Date: Fri, 10 Apr 2026 14:53:49 +0000 Subject: [PATCH 21/24] Updating cosa_adv_security_internal.c --- source/AdvSecurityDml/cosa_adv_security_internal.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/AdvSecurityDml/cosa_adv_security_internal.c b/source/AdvSecurityDml/cosa_adv_security_internal.c index db2877f..1c4546a 100644 --- a/source/AdvSecurityDml/cosa_adv_security_internal.c +++ b/source/AdvSecurityDml/cosa_adv_security_internal.c @@ -95,6 +95,7 @@ #define ADVSEC_PRIMARY_WAN_IF_NAME "erouter0" /* Logrotate configuration for agent.txt */ +#define ADVSEC_AGENT_LOG_FILE "/rdklogs/logs/agent.txt" #define ADVSEC_AGENT_LOG_MAX_SIZE (2 * 1024 * 1024) /* 2MB */ #define ADVSEC_AGENT_LOG_INTERVAL 5.0 #define ADVSEC_AGENT_LOGROTATE_CONF "/etc/logrotate.d/advsec-agent" From e263014e2fbe3868857e91a3f1d568e358226f66 Mon Sep 17 00:00:00 2001 From: sowmiyachelliah Date: Tue, 14 Apr 2026 09:25:06 +0000 Subject: [PATCH 22/24] Updating cosa_adv_security_internal.c --- source/AdvSecurityDml/cosa_adv_security_internal.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/AdvSecurityDml/cosa_adv_security_internal.c b/source/AdvSecurityDml/cosa_adv_security_internal.c index 1c4546a..e39f781 100644 --- a/source/AdvSecurityDml/cosa_adv_security_internal.c +++ b/source/AdvSecurityDml/cosa_adv_security_internal.c @@ -98,7 +98,6 @@ #define ADVSEC_AGENT_LOG_FILE "/rdklogs/logs/agent.txt" #define ADVSEC_AGENT_LOG_MAX_SIZE (2 * 1024 * 1024) /* 2MB */ #define ADVSEC_AGENT_LOG_INTERVAL 5.0 -#define ADVSEC_AGENT_LOGROTATE_CONF "/etc/logrotate.d/advsec-agent" #define LOGROTATE_BINARY "/usr/sbin/logrotate" #ifdef CONFIG_CISCO From 116f39e5748fac1030e742d9775b57a81d88ec54 Mon Sep 17 00:00:00 2001 From: sowmiyachelliah Date: Tue, 14 Apr 2026 09:36:50 +0000 Subject: [PATCH 23/24] Updating cosa_adv_security_internal.c --- source/AdvSecurityDml/cosa_adv_security_internal.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/AdvSecurityDml/cosa_adv_security_internal.c b/source/AdvSecurityDml/cosa_adv_security_internal.c index e39f781..194ed29 100644 --- a/source/AdvSecurityDml/cosa_adv_security_internal.c +++ b/source/AdvSecurityDml/cosa_adv_security_internal.c @@ -99,6 +99,7 @@ #define ADVSEC_AGENT_LOG_MAX_SIZE (2 * 1024 * 1024) /* 2MB */ #define ADVSEC_AGENT_LOG_INTERVAL 5.0 #define LOGROTATE_BINARY "/usr/sbin/logrotate" +#define ADVSEC_AGENT_LOGROTATE_CONF "/etc/logrotate.d/advsec-agent" #ifdef CONFIG_CISCO #define CONFIG_VENDOR_NAME "Cisco" From 5529ea6a6692cc793a6064567c0ce71933d36877 Mon Sep 17 00:00:00 2001 From: sowmiyachelliah Date: Mon, 20 Apr 2026 16:30:56 +0000 Subject: [PATCH 24/24] Updating cosa_adv_security_internal.c --- source/AdvSecurityDml/cosa_adv_security_internal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/AdvSecurityDml/cosa_adv_security_internal.c b/source/AdvSecurityDml/cosa_adv_security_internal.c index 194ed29..6dfb319 100644 --- a/source/AdvSecurityDml/cosa_adv_security_internal.c +++ b/source/AdvSecurityDml/cosa_adv_security_internal.c @@ -1778,7 +1778,7 @@ void rotate_agent_log(void) CcspTraceInfo(("Agent log reached %ld bytes, calling logrotate...\n", st.st_size)); - result = v_secure_system("%s /tmp/logrotate-advsec.status %s", + result = v_secure_system("%s %s", LOGROTATE_BINARY, ADVSEC_AGENT_LOGROTATE_CONF); if (result != 0) {