From 54e1baf571af5ff1b60b1ded84cddf33ad50d290 Mon Sep 17 00:00:00 2001 From: mtirum011 Date: Tue, 3 Feb 2026 09:54:18 +0000 Subject: [PATCH 1/3] RDKEMW-12845 Port Dedicated Bundle Name Support for RDM Agent --- .github/workflows/L2-tests.yml | 10 ++++ run_l2.sh | 4 +- src/deviceutils/device_api.c | 5 +- src/deviceutils/device_api.h | 4 +- src/deviceutils/deviceutils.c | 34 +++++++++++--- src/deviceutils/deviceutils.h | 4 +- src/include/json_process.h | 1 + src/json_process.c | 53 ++++++++++++++++++---- src/rdkv_main.c | 1 + unittest/deviceutils/device_api_gtest.cpp | 8 ++-- unittest/deviceutils/deviceutils_gtest.cpp | 2 +- 11 files changed, 98 insertions(+), 28 deletions(-) diff --git a/.github/workflows/L2-tests.yml b/.github/workflows/L2-tests.yml index 6c709b1b..7a11cabd 100644 --- a/.github/workflows/L2-tests.yml +++ b/.github/workflows/L2-tests.yml @@ -24,6 +24,12 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Check out dependent repostiories + uses: actions/checkout@v4 + with: + repository: 'rdkcentral/rdm-agent' + path: rdm-agent + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 @@ -40,6 +46,10 @@ jobs: run: | docker run -d --name native-platform --link mockxconf -e ENABLE_MTLS=true -v ${{ github.workspace }}:/mnt/L2_CONTAINER_SHARED_VOLUME ghcr.io/rdkcentral/docker-device-mgt-service-test/native-platform:latest + - name: Enter Inside container run rdm-agent cov_build.sh + run: | + docker exec -i native-platform /bin/bash -c "cd /mnt/L2_CONTAINER_SHARED_VOLUME/rdm-agent && sh cov_build.sh && export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu:/lib/aarch64-linux-gnu:/usr/local/lib: && cp /usr/local/bin/rdm /usr/bin/rdm" + - name: Enter Inside Platform native container and run L2 Test run: | docker exec -i native-platform /bin/bash -c "cd /mnt/L2_CONTAINER_SHARED_VOLUME/ && export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu:/lib/aarch64-linux-gnu:/usr/local/lib: && sh run_l2.sh" diff --git a/run_l2.sh b/run_l2.sh index 6c758336..98562b81 100755 --- a/run_l2.sh +++ b/run_l2.sh @@ -1,5 +1,5 @@ # Copyright 2023 Comcast Cable Communications Management, LLC -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -33,7 +33,7 @@ make && make install #./cov_build.sh # Compile Test binary for mfrutils -cc -o /usr/bin/mfr_util test/functional-tests/tests/mfrutils.c +cc -o /usr/bin/mfr_util test/functional-tests/tests/mfrutils.c rbuscli setv Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.Enable boolean true rbuscli setv Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.TopSpeed int 1280000 diff --git a/src/deviceutils/device_api.c b/src/deviceutils/device_api.c index 28b83c94..747f92ae 100644 --- a/src/deviceutils/device_api.c +++ b/src/deviceutils/device_api.c @@ -187,7 +187,7 @@ size_t GetPDRIFileName( char *pPDRIFilename, size_t szBufSize ) RETURN - number of characters copied to the output buffer. */ -size_t GetInstalledBundles(char *pBundles, size_t szBufSize) +size_t GetInstalledBundles(char *pBundles, size_t szBufSize, const char *bundleType) { JSON *pJsonTop; JSON *pJson; @@ -199,7 +199,8 @@ size_t GetInstalledBundles(char *pBundles, size_t szBufSize) if (pBundles != NULL) { *pBundles = 0; - installedBundleListNode = getInstalledBundleFileList(); + SWLOG_INFO("GetInstalledBundles: Invoking getInstalledBundleFileList to get %s bundle list ",bundleType); + installedBundleListNode = getInstalledBundleFileList(bundleType); while (installedBundleListNode != NULL) { diff --git a/src/deviceutils/device_api.h b/src/deviceutils/device_api.h index 0dee9ee8..7318f715 100644 --- a/src/deviceutils/device_api.h +++ b/src/deviceutils/device_api.h @@ -143,9 +143,11 @@ size_t GetPDRIFileName(char *pPDRIFilename, size_t szBufSize); szBufSize - the size of the character buffer in argument 1. + bundleType - type of the bundle. + RETURN - number of characters copied to the output buffer. */ -size_t GetInstalledBundles(char *pBundles, size_t szBufSize); +size_t GetInstalledBundles(char *pBundles, size_t szBufSize, const char *bundleType); /* function GetPartnerId - gets the partner ID of the device. Usage: size_t GetPartnerId diff --git a/src/deviceutils/deviceutils.c b/src/deviceutils/deviceutils.c index f8d2a5ae..6a5711c3 100644 --- a/src/deviceutils/deviceutils.c +++ b/src/deviceutils/deviceutils.c @@ -42,11 +42,15 @@ int v_secure_pclose(FILE *fp); #include #ifndef GTEST_ENABLE - #define BUNDLE_METADATA_NVM_PATH "/media/apps/etc/certs" - #define BUNDLE_METADATA_RFS_PATH "/etc/certs" + #define BUNDLE_METADATA_NVM_CERT_PATH "/media/apps/etc/certs" + #define BUNDLE_METADATA_RFS_CERT_PATH "/etc/certs" + #define BUNDLE_METADATA_NVM_APPS_PATH "/media/apps/etc/apps" + #define BUNDLE_METADATA_RFS_APPS_PATH "/etc/apps" #else - #define BUNDLE_METADATA_NVM_PATH "/tmp/certs" - #define BUNDLE_METADATA_RFS_PATH "/tmp/rfc/certs" + #define BUNDLE_METADATA_NVM_CERT_PATH "/tmp/certs" + #define BUNDLE_METADATA_RFS_CERT_PATH "/tmp/rfc/certs" +#define BUNDLE_METADATA_NVM_APPS_PATH "/media/apps/etc/apps" +#define BUNDLE_METADATA_RFS_APPS_PATH "/etc/apps" #endif #define WPEFRAMEWORKSECURITYUTILITY "/usr/bin/WPEFrameworkSecurityUtility" @@ -375,8 +379,24 @@ int getJRPCTokenData( char *token, char *pJsonStr, unsigned int token_size ) Input : void RETURN - List of installed Bundle in NVM and RFS directory */ -metaDataFileList_st *getInstalledBundleFileList() +metaDataFileList_st *getInstalledBundleFileList(const char *bundleType) { + const char *BUNDLE_METADATA_NVM_PATH = NULL; + const char *BUNDLE_METADATA_RFS_PATH = NULL; + + if (strcmp(bundleType, "dlCertBundle") == 0) { + SWLOG_INFO("Setting bundle path for installed Cert packages\n"); + BUNDLE_METADATA_NVM_PATH = BUNDLE_METADATA_NVM_CERT_PATH; + BUNDLE_METADATA_RFS_PATH = BUNDLE_METADATA_RFS_CERT_PATH; + } else if (strcmp(bundleType, "dlAppBundle") == 0) { + SWLOG_INFO("Setting bundle path for installed App packages\n"); + BUNDLE_METADATA_NVM_PATH = BUNDLE_METADATA_NVM_APPS_PATH; + BUNDLE_METADATA_RFS_PATH = BUNDLE_METADATA_RFS_APPS_PATH; + } else { + SWLOG_ERROR("Unknown bundleType: %s\n", bundleType); + return NULL; + } + metaDataFileList_st *metadataNVMls = NULL, *metadataRFSls = NULL, *metaDataList = NULL; metadataNVMls = getMetaDataFile(BUNDLE_METADATA_NVM_PATH); @@ -414,11 +434,11 @@ metaDataFileList_st *getInstalledBundleFileList() } /* function getMetaDataFile - gets the files list in the directory - Usage: metaDataFileList_st *getMetaDataFile(char *dir) + Usage: metaDataFileList_st *getMetaDataFile(const char *dir) dir : directory of NVM or RFS Path RETURN - List of installed Bundle in NVM or RFS directory */ -metaDataFileList_st *getMetaDataFile(char *dir) +metaDataFileList_st *getMetaDataFile(const char *dir) { metaDataFileList_st *newnode = NULL, *prevnode = NULL, *headNode = NULL; struct dirent *pDirent = NULL; diff --git a/src/deviceutils/deviceutils.h b/src/deviceutils/deviceutils.h index fc59f231..a4110702 100644 --- a/src/deviceutils/deviceutils.h +++ b/src/deviceutils/deviceutils.h @@ -110,8 +110,8 @@ int getJsonRpc(char *post_data, DownloadData* pJsonRpc); * */ int getJRPCTokenData(char *token, char *pJsonStr, unsigned int token_size); -metaDataFileList_st *getInstalledBundleFileList(); -metaDataFileList_st *getMetaDataFile(char *dir); +metaDataFileList_st *getInstalledBundleFileList(const char *bundleType); +metaDataFileList_st *getMetaDataFile(const char *dir); metaDataFileList_st * mergeLists(metaDataFileList_st *nvmList, metaDataFileList_st *rfsList); diff --git a/src/include/json_process.h b/src/include/json_process.h index 13572619..aee07c71 100644 --- a/src/include/json_process.h +++ b/src/include/json_process.h @@ -35,6 +35,7 @@ typedef struct xconf_response { char cloudImmediateRebootFlag[12]; char peripheralFirmwares[256]; char dlCertBundle[64]; + char dlAppBundle[64]; char cloudPDRIVersion[64]; char rdmCatalogueVersion[512]; } XCONFRES; diff --git a/src/json_process.c b/src/json_process.c index 7d0fc6d8..8b9be9ce 100644 --- a/src/json_process.c +++ b/src/json_process.c @@ -207,7 +207,7 @@ size_t createJsonString( char *pPostFieldOut, size_t szPostFieldOut ) remainlen = szPostFieldOut - totlen; totlen += snprintf( (pTmpPost + totlen), remainlen, "localtime=%s", tmpbuf ); } - len = GetInstalledBundles( tmpbuf, sizeof(tmpbuf) ); + len = GetInstalledBundles( tmpbuf, sizeof(tmpbuf), "dlCertBundle" ); if( totlen ) { *(pTmpPost + totlen) = '&'; @@ -215,6 +215,14 @@ size_t createJsonString( char *pPostFieldOut, size_t szPostFieldOut ) } remainlen = szPostFieldOut - totlen; totlen += snprintf( (pTmpPost + totlen), remainlen, "dlCertBundle=%s", tmpbuf ); + len = GetInstalledBundles( tmpbuf, sizeof(tmpbuf), "dlAppBundle" ); + if( totlen ) + { + *(pTmpPost + totlen) = '&'; + ++totlen; + } + remainlen = szPostFieldOut - totlen; + totlen += snprintf( (pTmpPost + totlen), remainlen, "dlAppBundle=%s", tmpbuf ); len = GetRdmManifestVersion( tmpbuf, sizeof(tmpbuf) ); if( totlen ) { @@ -272,6 +280,7 @@ int getXconfRespData( XCONFRES *pResponse, char *pJsonStr ) GetJsonValContaining( pJson, "remCtrl", pResponse->peripheralFirmwares, sizeof(pResponse->peripheralFirmwares) ); t2ValNotify("SYST_INFO_PRXR_Ver_split", pResponse->peripheralFirmwares); GetJsonVal( pJson, "dlCertBundle", pResponse->dlCertBundle, sizeof(pResponse->dlCertBundle) ); + GetJsonVal( pJson, "dlAppBundle", pResponse->dlAppBundle, sizeof(pResponse->dlAppBundle) ); strncmp(pResponse->dlCertBundle, "lxyupdate-bundle:", 17)?1:t2ValNotify("lxybundleversion_split", pResponse->dlCertBundle + 17); GetJsonVal( pJson, "rdmCatalogueVersion", pResponse->rdmCatalogueVersion, sizeof(pResponse->rdmCatalogueVersion) ); GetJsonVal( pJson, "ipv6FirmwareLocation", pResponse->ipv6cloudFWLocation, sizeof(pResponse->ipv6cloudFWLocation) ); @@ -335,6 +344,7 @@ int processJsonResponse(XCONFRES *response, const char *myfwversion, const char SWLOG_INFO("cloudImmediateRebootFlag: %s\n", response->cloudImmediateRebootFlag); SWLOG_INFO("peripheralFirmwares: %s\n", response->peripheralFirmwares); SWLOG_INFO("dlCertBundle: %s\n", response->dlCertBundle); + SWLOG_INFO("dlAppBundle: %s\n", response->dlAppBundle); SWLOG_INFO("cloudPDRIVersion: %s\n", response->cloudPDRIVersion); SWLOG_INFO("rdmCatalogueVersion: %s\n", response->rdmCatalogueVersion); @@ -351,17 +361,42 @@ int processJsonResponse(XCONFRES *response, const char *myfwversion, const char fprintf( fp, "%s\n", response->rdmCatalogueVersion ); fclose( fp ); } - if (response->dlCertBundle[0] != 0) { + if (response->dlCertBundle[0] != 0 || response->dlAppBundle[0] != '\0') { SWLOG_INFO("Calling rdm Versioned_app download to process bundle update\n"); - if (access("/usr/bin/rdm", F_OK) == 0) { + + char dlBundle[1024] = {0}; + size_t available = sizeof(dlBundle); + + if (response->dlCertBundle[0] != '\0') { + int retval = snprintf(dlBundle, available, "dlCertBundle=%s", response->dlCertBundle); + if (retval < 0 || retval >= available) { + SWLOG_ERROR("dlCertBundle string too long, truncation occurred\n"); + return ret; + } + available -= retval; + } + + if (response->dlAppBundle[0] != '\0') { + size_t current_len = strlen(dlBundle); + available = sizeof(dlBundle) - current_len; + + int retval; + if (dlBundle[0] != '\0') { + retval = snprintf(dlBundle + current_len, available, "|dlAppBundle=%s", response->dlAppBundle); + } else { + retval = snprintf(dlBundle + current_len, available, "dlAppBundle=%s", response->dlAppBundle); + } + + if (retval < 0 || retval >= available) { + SWLOG_ERROR("dlAppBundle string too long, truncation occurred\n"); + return ret; + } + } + + if ((access("/usr/bin/rdm", F_OK) == 0) && (strlen(dlBundle) > 0)) { // file exists SWLOG_INFO("RDM binary is present\n"); - v_secure_system("rdm -v \"%s\" >> /opt/logs/rdm_status.log 2>&1", response->dlCertBundle); - SWLOG_INFO("RDM Versioned app Download started and completed\n"); - } else if (access("/etc/rdm/rdmBundleMgr.sh", F_OK) == 0) { - // Script file exist - SWLOG_INFO("RDM binary is not present, using scripts\n"); - v_secure_system("sh /etc/rdm/rdmBundleMgr.sh '%s' '%s' >> /opt/logs/rdm_status.log 2>&1", response->dlCertBundle, response->cloudFWLocation); + v_secure_system("rdm -v \"%s\" >> /opt/logs/rdm_status.log 2>&1", dlBundle); SWLOG_INFO("RDM Versioned app Download started and completed\n"); } else { // file doesn't exist diff --git a/src/rdkv_main.c b/src/rdkv_main.c index b234e5d8..c4a61c43 100644 --- a/src/rdkv_main.c +++ b/src/rdkv_main.c @@ -1011,6 +1011,7 @@ int main(int argc, char *argv[]) { *response.cloudImmediateRebootFlag = 0; *response.peripheralFirmwares = 0; *response.dlCertBundle = 0; + *response.dlAppBundle = 0; *response.cloudPDRIVersion = 0; SWLOG_INFO("Starting c method rdkvfwupgrader\n"); t2CountNotify("SYST_INFO_C_CDL", 1); diff --git a/unittest/deviceutils/device_api_gtest.cpp b/unittest/deviceutils/device_api_gtest.cpp index 17b350cf..f7918bbd 100644 --- a/unittest/deviceutils/device_api_gtest.cpp +++ b/unittest/deviceutils/device_api_gtest.cpp @@ -196,14 +196,14 @@ TEST(TestGetPDRIFileName, Test_pdri_Nullcheck) } TEST_F(DeviceApiTestFixture,TestName_bundle_Nullcheck) { - EXPECT_EQ(GetInstalledBundles(NULL, 0), 0); + EXPECT_EQ(GetInstalledBundles(NULL, 0, "dlCertBundle"), 0); } TEST_F(DeviceApiTestFixture,TestName_bundle_Success) { int ret; char pBundles[32] = {0}; ret = system("mkdir /tmp/certs;cp ca-store-update-bundle_package.json /tmp/certs/ "); - EXPECT_NE(GetInstalledBundles(pBundles, sizeof(pBundles)), 0); + EXPECT_NE(GetInstalledBundles(pBundles, sizeof(pBundles), "dlCertBundle"), 0); ret = system("rm -rf /tmp/certs/ "); printf("BUNDLE = %s\n",pBundles); } @@ -212,7 +212,7 @@ TEST_F(DeviceApiTestFixture,TestName_bundle_rfcpath) int ret; char pBundles[32] = {0}; ret = system("mkdir /tmp/rfc;mkdir /tmp/rfc/certs; cp ca-store-update-bundle_package.json /tmp/rfc/certs/ "); - EXPECT_NE(GetInstalledBundles(pBundles, sizeof(pBundles)), 0); + EXPECT_NE(GetInstalledBundles(pBundles, sizeof(pBundles), "dlCertBundle"), 0); ret = system("rm -rf /tmp/rfc/certs/ "); ret = system("rm -rf /tmp/rfc/ "); printf("BUNDLE = %s\n",pBundles); @@ -220,7 +220,7 @@ TEST_F(DeviceApiTestFixture,TestName_bundle_rfcpath) TEST_F(DeviceApiTestFixture,TestName_bundle_Fail) { char pBundles[32] = {0}; - EXPECT_EQ(GetInstalledBundles(pBundles, sizeof(pBundles)), 0); + EXPECT_EQ(GetInstalledBundles(pBundles, sizeof(pBundles), "dlCertBundle"), 0); } /* COMMENTED OUT: GetUTCTime and GetCapabilities are now in common_utilities diff --git a/unittest/deviceutils/deviceutils_gtest.cpp b/unittest/deviceutils/deviceutils_gtest.cpp index 0333b0a0..1bdcb65b 100644 --- a/unittest/deviceutils/deviceutils_gtest.cpp +++ b/unittest/deviceutils/deviceutils_gtest.cpp @@ -218,7 +218,7 @@ TEST_F(DeviceUtilsTestFixture, TestName_getJsonRpc_Fail) TEST_F(DeviceUtilsTestFixture, TestName_getInstalledBundleFileList_Fail) { metaDataFileList_st *meta_ret = NULL; - EXPECT_EQ(getInstalledBundleFileList(), meta_ret); + EXPECT_EQ(getInstalledBundleFileList(NULL), meta_ret); } TEST_F(DeviceUtilsTestFixture, TestName_getMetaDataFile_Null) { From 35d0332595806e2db070d25d7bbc008f380c5adf Mon Sep 17 00:00:00 2001 From: mtirum011 Date: Thu, 12 Feb 2026 16:28:27 +0000 Subject: [PATCH 2/3] RDKE test app bundle --- .github/workflows/L2-tests.yml | 4 ++++ test/xconf-certbundle-response.json | 1 + 2 files changed, 5 insertions(+) create mode 100644 test/xconf-certbundle-response.json diff --git a/.github/workflows/L2-tests.yml b/.github/workflows/L2-tests.yml index 7a11cabd..ddb8c9b3 100644 --- a/.github/workflows/L2-tests.yml +++ b/.github/workflows/L2-tests.yml @@ -42,6 +42,10 @@ jobs: run: | docker run -d --name mockxconf -p 50050:50050 -p 50051:50051 -p 50052:50052 -e ENABLE_MTLS=true -v ${{ github.workspace }}:/mnt/L2_CONTAINER_SHARED_VOLUME ghcr.io/rdkcentral/docker-device-mgt-service-test/mockxconf:latest + - name: Copy unknown-accountid-xconf-rfc-response json to mockxconf service + run: | + docker cp ${{ github.workspace }}/test/xconf-certbundle-response.json mockxconf:/etc/xconf/xconf-certbundle-response.json + - name: Start l2-container service with mTLS enabled run: | docker run -d --name native-platform --link mockxconf -e ENABLE_MTLS=true -v ${{ github.workspace }}:/mnt/L2_CONTAINER_SHARED_VOLUME ghcr.io/rdkcentral/docker-device-mgt-service-test/native-platform:latest diff --git a/test/xconf-certbundle-response.json b/test/xconf-certbundle-response.json new file mode 100644 index 00000000..0b3d14fc --- /dev/null +++ b/test/xconf-certbundle-response.json @@ -0,0 +1 @@ +{"additionalFwVerInfo":"ABCD_PDRI_firmware_test","firmwareDownloadProtocol":"http","firmwareFilename":"ABCD_firmware_test.bin","firmwareLocation":"https://mockxconf:50052/getfirmwarefile/","firmwareVersion":"ABCD_firmware_test","rebootImmediately":false,"remCtrlAB11-20":"AB11-20_firmware_5103.3.4","dlCertBundle":"ca-store-update-bundle:0.1","dlAppBundle" : "XApp:1.0, YApp:2.0"} From 624b1155f864c5bad9c2a72092d7d8b443f32b8f Mon Sep 17 00:00:00 2001 From: madhubabutt <114217841+madhubabutt@users.noreply.github.com> Date: Mon, 23 Feb 2026 20:12:56 +0530 Subject: [PATCH 3/3] Update json_process.c --- src/json_process.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/json_process.c b/src/json_process.c index 51643563..5f1d40ee 100644 --- a/src/json_process.c +++ b/src/json_process.c @@ -371,8 +371,7 @@ int processJsonResponse(XCONFRES *response, const char *myfwversion, const char if (retval < 0 || retval >= available) { SWLOG_ERROR("dlCertBundle string too long, truncation occurred\n"); return ret; - } - available -= retval; + } } if (response->dlAppBundle[0] != '\0') {