feat: Add ismodulerestarted parameter to DeviceFingerPrint section#78
Closed
jayasrikadiyal wants to merge 1 commit into
Closed
feat: Add ismodulerestarted parameter to DeviceFingerPrint section#78jayasrikadiyal wants to merge 1 commit into
jayasrikadiyal wants to merge 1 commit into
Conversation
Add a new read-only boolean TR-181 parameter 'ismodulerestarted' under Device.DeviceInfo.X_RDKCENTRAL-COM_DeviceFingerPrint that indicates whether the cujo-agent has been restarted since system boot. The parameter compares the cujo-agent process start time (from /proc/<pid>/stat) against the system uptime. If the agent started after boot (start time > 0 seconds after boot), it is considered restarted. Changes: - Add CosaAdvSecIsAgentRestarted() in cosa_adv_security_internal.c - Add declaration in cosa_adv_security_internal.h - Add ismodulerestarted case in DeviceFingerPrint_GetParamBoolValue - Add parameter definition in TR181-AdvSecurity.xml (read-only boolean) - Add unit tests for the new parameter Resolves #66
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new read-only TR-181 boolean parameter Device.DeviceInfo.X_RDKCENTRAL-COM_DeviceFingerPrint.ismodulerestarted intended to indicate whether cujo-agent has restarted since system boot.
Changes:
- Introduces
CosaAdvSecIsAgentRestarted()to infer restart status from/tmp/cujo-agent.pidand/proc/<pid>/stat. - Wires
ismodulerestartedintoDeviceFingerPrint_GetParamBoolValue. - Updates TR-181 XML and adds a unit test for the new parameter.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| source/AdvSecurityDml/cosa_adv_security_internal.c | Adds restart-detection helper based on PID + /proc start time and uptime. |
| source/AdvSecurityDml/cosa_adv_security_internal.h | Declares the new helper function. |
| source/AdvSecurityDml/cosa_adv_security_dml.c | Exposes ismodulerestarted via the DeviceFingerPrint boolean getter. |
| config/TR181-AdvSecurity.xml | Adds the new read-only TR-181 parameter definition. |
| source/test/CcspAdvSecurityDmlTest/CcspAdvSecurityDmlTest.cpp | Adds a unit test covering the new parameter dispatch path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+3618
to
+3625
| agent_start_sec = (long)(starttime / (unsigned long long)clk_tck); | ||
|
|
||
| /* If agent started after boot (agent_start_sec > 0), it has been restarted */ | ||
| if (agent_start_sec > 0) | ||
| { | ||
| CcspTraceInfo(("%s: Agent restarted. Agent start=%ld sec after boot, system uptime=%ld sec\n", | ||
| __FUNCTION__, agent_start_sec, uptime_sec)); | ||
| return TRUE; |
Comment on lines
+3553
to
+3562
| /* Remove trailing newline */ | ||
| pid_str[strcspn(pid_str, "\n")] = '\0'; | ||
| if (pid_str[0] == '\0') | ||
| { | ||
| return FALSE; | ||
| } | ||
|
|
||
| /* Read /proc/<pid>/stat to get process start time */ | ||
| snprintf(proc_path, sizeof(proc_path), "/proc/%s/stat", pid_str); | ||
| fp = fopen(proc_path, "r"); |
Comment on lines
+3560
to
+3566
| /* Read /proc/<pid>/stat to get process start time */ | ||
| snprintf(proc_path, sizeof(proc_path), "/proc/%s/stat", pid_str); | ||
| fp = fopen(proc_path, "r"); | ||
| if (fp == NULL) | ||
| { | ||
| CcspTraceInfo(("%s: Cannot open %s, agent process not found\n", __FUNCTION__, proc_path)); | ||
| return FALSE; |
Comment on lines
+164
to
+167
| BOOL result = DeviceFingerPrint_GetParamBoolValue(NULL, (char*)ParamName, &resultBool); | ||
|
|
||
| EXPECT_TRUE(result); | ||
|
|
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #66.
Summary
Adds a new read-only boolean TR-181 parameter
ismodulerestartedunderDevice.DeviceInfo.X_RDKCENTRAL-COM_DeviceFingerPrintthat indicates whether the cujo-agent has been restarted since system boot.Implementation
CosaAdvSecIsAgentRestarted()incosa_adv_security_internal.c: Reads the cujo-agent PID from/tmp/cujo-agent.pid, then reads/proc/<pid>/statto get the process start time (field 22, in clock ticks). Compares this with system uptime viasysinfo(). If the agent started after boot (start time > 0 seconds), it is considered restarted.ismodulerestartedcase inDeviceFingerPrint_GetParamBoolValueusing the standardstrcmp_spattern.TR181-AdvSecurity.xml.CcspAdvSecurityDmlTest.cpp.Files Changed
source/AdvSecurityDml/cosa_adv_security_internal.cCosaAdvSecIsAgentRestarted()functionsource/AdvSecurityDml/cosa_adv_security_internal.hsource/AdvSecurityDml/cosa_adv_security_dml.cismodulerestartedhandling in GetParamBoolValueconfig/TR181-AdvSecurity.xmlsource/test/CcspAdvSecurityDmlTest/CcspAdvSecurityDmlTest.cppTesting
dmcli eRT getv Device.DeviceInfo.X_RDKCENTRAL-COM_DeviceFingerPrint.ismodulerestartedtrueif cujo-agent runtime < system uptime (agent restarted since boot)falseif agent has been running since boot or is not running