From 89bf5f2763a62b57e5c0ee17f70245e78122f6ec Mon Sep 17 00:00:00 2001 From: Debaucher Date: Thu, 12 May 2022 14:54:12 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=8D=8E=E4=B8=BA=E4=BA=91=E5=B9=B3=E5=8F=B0=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98=20[=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D]=20=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=AF=91=E5=90=8E?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=BA=93rpath=E6=90=9C=E7=B4=A2=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E7=BC=BA=E5=A4=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 1 + debian/changelog | 12 ++++++++++++ src/systeminfo/libkysysinfo.c | 8 ++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5dbebef..7f7ea66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,7 @@ endif() message("Build Type: ${CMAKE_BUILD_TYPE}") set (CMAKE_INSTALL_PREFIX /usr) +set (CMAKE_INSTALL_RPATH /usr/lib/kysdk/kysdk-system;/usr/lib/kysdk/kysdk-base) set (LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) diff --git a/debian/changelog b/debian/changelog index 1de0a7e..43bfed5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +libkysdk-system (1.1.0kylin1b3) v101; urgency=medium + + *Bug号:无 + *需求号:无 + *其他修改: + * 新增获取操作系统ProjectName的接口 + * 新增获取当前登录有效用户用户名的接口 + * 新增获取当前宿主机虚拟环境类型的接口 + * 新增获取当前宿主机云平台类型的接口 + + -- liuyunhe Wed, 11 May 2022 19:01:54 +0800 + libkysdk-system (1.1.0kylin1) v101; urgency=medium *Bug号:无 diff --git a/src/systeminfo/libkysysinfo.c b/src/systeminfo/libkysysinfo.c index 037d984..86c02c4 100644 --- a/src/systeminfo/libkysysinfo.c +++ b/src/systeminfo/libkysysinfo.c @@ -436,10 +436,11 @@ char* kdk_system_get_hostCloudPlatform() bool res_flag = false; if (geteuid() == 0) // root 用户,可以用dmidecode { - FILE *pipeLine = popen("dmidecode -s system-manufacturer", "r"); + FILE *pipeLine = popen("dmidecode -s chassis-manufacturer", "r"); if (__glibc_likely(pipeLine != NULL)) { fgets(buf, 255 * sizeof(char), pipeLine); + strstripspace(buf); if (strcmp(buf, "Huawei Inc.") == 0) // 华为云 { strcpy(cloudplat, "huawei"); @@ -453,6 +454,7 @@ char* kdk_system_get_hostCloudPlatform() if (__glibc_likely(pipeLine != NULL)) { fgets(buf, 255 * sizeof(char), pipeLine); + strstripspace(buf); if (strcmp(buf, "HUAWEICLOUD") == 0) // 华为云 { strcpy(cloudplat, "huawei"); @@ -463,10 +465,11 @@ char* kdk_system_get_hostCloudPlatform() } else // 普通用户,只能读取文件 { - FILE *fp = fopen("/sys/devices/virtual/dmi/id/sys_vendor", "rt"); + FILE *fp = fopen("/sys/devices/virtual/dmi/id/chassis_vendor", "rt"); if (__glibc_likely(fp != NULL)) { fgets(buf, 255 * sizeof(char), fp); + strstripspace(buf); if (strcmp(buf, "Huawei Inc.") == 0) // 华为云 { strcpy(cloudplat, "huawei"); @@ -480,6 +483,7 @@ char* kdk_system_get_hostCloudPlatform() if (__glibc_likely(fp != NULL)) { fgets(buf, 255 * sizeof(char), fp); + strstripspace(buf); if (strcmp(buf, "HUAWEICLOUD") == 0) // 华为云 { strcpy(cloudplat, "huawei");