From 45496616bffd12435776822e951f44a76428e73e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 06:08:43 +0000 Subject: [PATCH 1/3] Initial plan From 3372a41245e72c07aa57e164b02ba9f1730ab0b7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 06:16:23 +0000 Subject: [PATCH 2/3] Fix CI build failures: make isSecureDbgSrvUnlocked() public, add new tests and missing automake files Co-authored-by: KTirumalaSrihari <102281309+KTirumalaSrihari@users.noreply.github.com> --- AUTHORS | 0 ChangeLog | 0 NEWS | 0 README | 46 ++++++++++++++++++++++++ rfcMgr/gtest/gtest_main.cpp | 49 ++++++++++++++++++++++++++ rfcMgr/rfc_xconf_handler.cpp | 68 +++++++++++++++++++++++++++++++++--- rfcMgr/rfc_xconf_handler.h | 8 +++++ 7 files changed, 167 insertions(+), 4 deletions(-) create mode 100644 AUTHORS create mode 100644 ChangeLog create mode 100644 NEWS create mode 100644 README diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 00000000..e69de29b diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 00000000..e69de29b diff --git a/NEWS b/NEWS new file mode 100644 index 00000000..e69de29b diff --git a/README b/README new file mode 100644 index 00000000..83429aaa --- /dev/null +++ b/README @@ -0,0 +1,46 @@ +This folder contains utilities for the RFC. Following utilities are present +_______________________________________________________________ +rfctool +--------------------------------------------------------------- + +This tool is used to parse json message and extract all list files into specified folders. +The following variables are used in this case +RFC_LIST_FILE_NAME_PREFIX - This will be used to to provide the prefix to file name +RFC_LIST_FILE_NAME_SUFFIX - The suffix part +RFC_PATH - The RFC directory + +The tool will extract all list items present in the root folder of each object and store it +as +RFC_PATH/RFC_LIST_FILE_NAME_PREFIX<>RFC_LIST_FILE_NAME_SUFFIX +where listype is taken from the name of the list present in json +a sample form of json will be + + { + "name": "SNMP2WL", + "effectiveImmediate": false, + "enable": true, + "configData": { + + }, + "listType": "SNMPIPv4", + "listSize": 2, + "SNMP IP4 WL": ["128.82.34.17", + "10.0.0.32/6"] + } + +_______________________________________________________________ +tr181Set +--------------------------------------------------------------- +This utility is used to set a parameter for host interface using iarm tool +The usage will be + +Usage : tr181Set [-g] [-d] [-s] [-v value] ParamName +-g get operation +-s set operation +-d enable debug +-v value of parameter +If -s option is set -v is mandatory, otherwise -g option is default + +if you need just the parameter value for get operation use following format +tr181Set param 1>/dev/null + diff --git a/rfcMgr/gtest/gtest_main.cpp b/rfcMgr/gtest/gtest_main.cpp index b1c798fe..cabff72b 100644 --- a/rfcMgr/gtest/gtest_main.cpp +++ b/rfcMgr/gtest/gtest_main.cpp @@ -569,6 +569,55 @@ TEST(rfcMgrTest, checkWhoamiSupport) { EXPECT_EQ(result, true); } +TEST(rfcMgrTest, isSecureDbgSrvUnlocked_dev) { + writeToTr181storeFile("BUILD_TYPE", "dev", "/tmp/device.properties", Plain); + RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor(); + bool result = rfcObj->isSecureDbgSrvUnlocked(); + delete rfcObj; + EXPECT_EQ(result, true); +} + +TEST(rfcMgrTest, isSecureDbgSrvUnlocked_labsigned_true) { + writeToTr181storeFile("BUILD_TYPE", "prod", "/tmp/device.properties", Plain); + writeToTr181storeFile("LABSIGNED_ENABLED", "true", "/tmp/device.properties", Plain); + writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DeviceType", "test", "/opt/secure/RFC/tr181store.ini", Quoted); + writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DbgServices.Enable", "true", "/opt/secure/RFC/tr181store.ini", Quoted); + RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor(); + bool result = rfcObj->isSecureDbgSrvUnlocked(); + delete rfcObj; + EXPECT_EQ(result, true); +} + +TEST(rfcMgrTest, isSecureDbgSrvUnlocked_prod) { + writeToTr181storeFile("BUILD_TYPE", "prod", "/tmp/device.properties", Plain); + writeToTr181storeFile("LABSIGNED_ENABLED", "false", "/tmp/device.properties", Plain); + RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor(); + bool result = rfcObj->isSecureDbgSrvUnlocked(); + delete rfcObj; + EXPECT_EQ(result, false); +} + +TEST(rfcMgrTest, isSecureDbgSrvUnlocked_dType_prod) { + writeToTr181storeFile("BUILD_TYPE", "prod", "/tmp/device.properties", Plain); + writeToTr181storeFile("LABSIGNED_ENABLED", "true", "/tmp/device.properties", Plain); + writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DeviceType", "prod", "/opt/secure/RFC/tr181store.ini", Quoted); + RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor(); + bool result = rfcObj->isSecureDbgSrvUnlocked(); + delete rfcObj; + EXPECT_EQ(result, false); +} + +TEST(rfcMgrTest, isSecureDbgSrvUnlocked_labsigned_DbgSrv_false) { + writeToTr181storeFile("BUILD_TYPE", "prod", "/tmp/device.properties", Plain); + writeToTr181storeFile("LABSIGNED_ENABLED", "true", "/tmp/device.properties", Plain); + writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DeviceType", "test", "/opt/secure/RFC/tr181store.ini", Quoted); + writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DbgServices.Enable", "false", "/opt/secure/RFC/tr181store.ini", Quoted); + RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor(); + bool result = rfcObj->isSecureDbgSrvUnlocked(); + delete rfcObj; + EXPECT_EQ(result, false); +} + TEST(rfcMgrTest, isDebugServicesEnabled) { writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DbgServices.Enable", "true", "/opt/secure/RFC/tr181store.ini", Quoted); RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor(); diff --git a/rfcMgr/rfc_xconf_handler.cpp b/rfcMgr/rfc_xconf_handler.cpp index bbc43e00..2abe6990 100644 --- a/rfcMgr/rfc_xconf_handler.cpp +++ b/rfcMgr/rfc_xconf_handler.cpp @@ -47,10 +47,40 @@ extern "C" { #define MTLS_FAILURE -1 #endif +bool RuntimeFeatureControlProcessor::isSecureDbgSrvUnlocked(void) { + bool isDebugServicesUnlocked = false; // return value + + if (_ebuild_type == eDEV) { + RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Enabling Debug Services\n", __FUNCTION__, __LINE__); + isDebugServicesUnlocked = true; + } + else if (_ebuild_type == ePROD) + { + char deviceType[16] = {0}; + char value[8] = {0}; + bool dbgServices = isDebugServicesEnabled(); // check debug services enabled from RFC + getDeviceTypeRFC(deviceType, sizeof(deviceType)); + int ret = getDevicePropertyData("LABSIGNED_ENABLED", value, sizeof(value)); + if (ret != 1) { + RDK_LOG(RDK_LOG_ERROR, LOG_RFCMGR, "[%s][%d] Failed to get LABSIGNED_ENABLED property. Status: %d\n", __FUNCTION__, __LINE__, ret); + return isDebugServicesUnlocked; + } + if ((strcasecmp(value, "true") == 0) && (strcasecmp(deviceType, "test") == 0) && dbgServices) + { + RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Enabling Debug Services\n", __FUNCTION__, __LINE__); + isDebugServicesUnlocked = true; + } + else + { + RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] unable to enable Debug Services\n", __FUNCTION__, __LINE__); + } + } + return isDebugServicesUnlocked; +} + int RuntimeFeatureControlProcessor:: InitializeRuntimeFeatureControlProcessor(void) { std::string rfc_file; - bool dbgServices = isDebugServicesEnabled(); int rc = GetBootstrapXconfUrl(_boot_strap_xconf_url); if(rc != 0) @@ -63,7 +93,7 @@ int RuntimeFeatureControlProcessor:: InitializeRuntimeFeatureControlProcessor(vo GetRFCPartnerID(); - if((filePresentCheck(RFC_PROPERTIES_PERSISTENCE_FILE) == RDK_API_SUCCESS) && (_ebuild_type != ePROD || dbgServices == true)) + if((filePresentCheck(RFC_PROPERTIES_PERSISTENCE_FILE) == RDK_API_SUCCESS) && (isSecureDbgSrvUnlocked())) { rfc_file = RFC_PROPERTIES_PERSISTENCE_FILE; rfc_state = Local; @@ -154,6 +184,36 @@ bool RuntimeFeatureControlProcessor::isDebugServicesEnabled(void) return result; } +void RuntimeFeatureControlProcessor::getDeviceTypeRFC(char *deviceType, size_t size) +{ + if (deviceType == NULL || size == 0){ + RDK_LOG(RDK_LOG_ERROR, LOG_RFCMGR, "[%s][%d] Error, invalid arguments passed!!!\n", __FUNCTION__, __LINE__); + return; + } + + const char* type = "unknown"; + char rfc_data[RFC_VALUE_BUF_SIZE] = {0}; + strncpy(deviceType, type, size - 1); + deviceType[size - 1] = '\0'; + int ret = read_RFCProperty("LABSGND", RFC_DEVICETYPE, rfc_data, sizeof(rfc_data)); + + if (ret == -1) { + RDK_LOG(RDK_LOG_ERROR, LOG_RFCMGR, "[%s][%d] rfc device type =%s failed Status %d\n", __FUNCTION__, __LINE__, RFC_DEVICETYPE, ret); + return; + } + + RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] rfc device type = %s\n", __FUNCTION__, __LINE__, rfc_data); + + if (strncasecmp(rfc_data, "prod", 4) == 0) { + type = "prod"; + } else if (strncasecmp(rfc_data, "test", 4) == 0) { + type = "test"; + } + + strncpy(deviceType, type, size - 1); + deviceType[size - 1] = '\0'; +} + bool RuntimeFeatureControlProcessor::IsNewFirmwareFirstRequest(void) { @@ -1532,13 +1592,13 @@ int RuntimeFeatureControlProcessor::ProcessRuntimeFeatureControlReq() int result = FAILURE; bool skip_direct = IsDirectBlocked(); - bool dbgServices = isDebugServicesEnabled(); + bool isDebugServicesUnlocked = isSecureDbgSrvUnlocked(); if(skip_direct == false) { while(retries < RETRY_COUNT) { - if((filePresentCheck(RFC_PROPERTIES_PERSISTENCE_FILE) == RDK_API_SUCCESS) && (_ebuild_type != ePROD || dbgServices == true)) + if((filePresentCheck(RFC_PROPERTIES_PERSISTENCE_FILE) == RDK_API_SUCCESS) && isDebugServicesUnlocked) { RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Setting URL from local override to %s\n", __FUNCTION__, __LINE__, _xconf_server_url.c_str()); NotifyTelemetry2Value("SYST_INFO_RFC_XconflocalURL", _xconf_server_url.c_str()); diff --git a/rfcMgr/rfc_xconf_handler.h b/rfcMgr/rfc_xconf_handler.h index 72f7936f..45a018ec 100644 --- a/rfcMgr/rfc_xconf_handler.h +++ b/rfcMgr/rfc_xconf_handler.h @@ -67,6 +67,7 @@ extern "C" { #define TR181STOREFILE "/opt/secure/RFC/tr181store.ini" #define DIRECT_BLOCK_FILENAME "/tmp/.lastdirectfail_rfc" #define RFC_DEBUGSRV "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DbgServices.Enable" +#define RFC_DEVICETYPE "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DeviceType" #define RFC_VIDEO_CONTROL_ID 2504 #define RFC_VIDEO_VOD_ID 15660 @@ -108,6 +109,7 @@ class RuntimeFeatureControlProcessor : public xconf::XconfHandler bool getRebootRequirement(); void NotifyTelemetry2Count(std ::string markerName); void NotifyTelemetry2Value(std ::string markerName, std ::string value); + bool isSecureDbgSrvUnlocked(void); private: @@ -205,6 +207,7 @@ class RuntimeFeatureControlProcessor : public xconf::XconfHandler void cleanAllFile(); int ProcessXconfUrl(const char *XconfUrl); bool isDebugServicesEnabled(void); + void getDeviceTypeRFC(char *deviceType, size_t size); #if defined(GTEST_ENABLE) FRIEND_TEST(rfcMgrTest, isNewFirmwareFirstRequest); @@ -228,6 +231,11 @@ class RuntimeFeatureControlProcessor : public xconf::XconfHandler FRIEND_TEST(rfcMgrTest, cleanAllFile); FRIEND_TEST(rfcMgrTest, checkWhoamiSupport); FRIEND_TEST(rfcMgrTest, isDebugServicesEnabled); + FRIEND_TEST(rfcMgrTest, isSecureDbgSrvUnlocked_dev); + FRIEND_TEST(rfcMgrTest, isSecureDbgSrvUnlocked_labsigned_true); + FRIEND_TEST(rfcMgrTest, isSecureDbgSrvUnlocked_prod); + FRIEND_TEST(rfcMgrTest, isSecureDbgSrvUnlocked_dType_prod); + FRIEND_TEST(rfcMgrTest, isSecureDbgSrvUnlocked_labsigned_DbgSrv_false); FRIEND_TEST(rfcMgrTest, isMaintenanceEnabled); FRIEND_TEST(rfcMgrTest, GetOsClass); FRIEND_TEST(rfcMgrTest, set_RFCProperty); From 987d2c92d1216ffa7c96d94645218fdaa49aa756 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 06:20:23 +0000 Subject: [PATCH 3/3] Fix indentation in new test cases: use spaces consistently Co-authored-by: KTirumalaSrihari <102281309+KTirumalaSrihari@users.noreply.github.com> --- rfcMgr/gtest/gtest_main.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/rfcMgr/gtest/gtest_main.cpp b/rfcMgr/gtest/gtest_main.cpp index cabff72b..ebc08c2d 100644 --- a/rfcMgr/gtest/gtest_main.cpp +++ b/rfcMgr/gtest/gtest_main.cpp @@ -579,9 +579,9 @@ TEST(rfcMgrTest, isSecureDbgSrvUnlocked_dev) { TEST(rfcMgrTest, isSecureDbgSrvUnlocked_labsigned_true) { writeToTr181storeFile("BUILD_TYPE", "prod", "/tmp/device.properties", Plain); - writeToTr181storeFile("LABSIGNED_ENABLED", "true", "/tmp/device.properties", Plain); - writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DeviceType", "test", "/opt/secure/RFC/tr181store.ini", Quoted); - writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DbgServices.Enable", "true", "/opt/secure/RFC/tr181store.ini", Quoted); + writeToTr181storeFile("LABSIGNED_ENABLED", "true", "/tmp/device.properties", Plain); + writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DeviceType", "test", "/opt/secure/RFC/tr181store.ini", Quoted); + writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DbgServices.Enable", "true", "/opt/secure/RFC/tr181store.ini", Quoted); RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor(); bool result = rfcObj->isSecureDbgSrvUnlocked(); delete rfcObj; @@ -590,7 +590,7 @@ TEST(rfcMgrTest, isSecureDbgSrvUnlocked_labsigned_true) { TEST(rfcMgrTest, isSecureDbgSrvUnlocked_prod) { writeToTr181storeFile("BUILD_TYPE", "prod", "/tmp/device.properties", Plain); - writeToTr181storeFile("LABSIGNED_ENABLED", "false", "/tmp/device.properties", Plain); + writeToTr181storeFile("LABSIGNED_ENABLED", "false", "/tmp/device.properties", Plain); RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor(); bool result = rfcObj->isSecureDbgSrvUnlocked(); delete rfcObj; @@ -599,8 +599,8 @@ TEST(rfcMgrTest, isSecureDbgSrvUnlocked_prod) { TEST(rfcMgrTest, isSecureDbgSrvUnlocked_dType_prod) { writeToTr181storeFile("BUILD_TYPE", "prod", "/tmp/device.properties", Plain); - writeToTr181storeFile("LABSIGNED_ENABLED", "true", "/tmp/device.properties", Plain); - writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DeviceType", "prod", "/opt/secure/RFC/tr181store.ini", Quoted); + writeToTr181storeFile("LABSIGNED_ENABLED", "true", "/tmp/device.properties", Plain); + writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DeviceType", "prod", "/opt/secure/RFC/tr181store.ini", Quoted); RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor(); bool result = rfcObj->isSecureDbgSrvUnlocked(); delete rfcObj; @@ -609,9 +609,9 @@ TEST(rfcMgrTest, isSecureDbgSrvUnlocked_dType_prod) { TEST(rfcMgrTest, isSecureDbgSrvUnlocked_labsigned_DbgSrv_false) { writeToTr181storeFile("BUILD_TYPE", "prod", "/tmp/device.properties", Plain); - writeToTr181storeFile("LABSIGNED_ENABLED", "true", "/tmp/device.properties", Plain); - writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DeviceType", "test", "/opt/secure/RFC/tr181store.ini", Quoted); - writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DbgServices.Enable", "false", "/opt/secure/RFC/tr181store.ini", Quoted); + writeToTr181storeFile("LABSIGNED_ENABLED", "true", "/tmp/device.properties", Plain); + writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DeviceType", "test", "/opt/secure/RFC/tr181store.ini", Quoted); + writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DbgServices.Enable", "false", "/opt/secure/RFC/tr181store.ini", Quoted); RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor(); bool result = rfcObj->isSecureDbgSrvUnlocked(); delete rfcObj;