TARGET_INCLUDE_DIRECTORIES(${NI_COMMON} PRIVATE ${RUNTIME_DIR}/src/ ${RUNTIME_DIR}/src/pal ${RUNTIME_DIR}/src/pal/inc ${RUNTIME_DIR}/src/pal/inc/rt)
TARGET_LINK_LIBRARIES(${NI_COMMON} ${${PROJECT_NAME}_LDFLAGS} ${DOTNET_LAUNCHER_UTIL} ${TAC_COMMON})
+SET(PROFILE_COMMON "profile_common")
+SET(${PROFILE_COMMON}_SOURCE_FILES
+ tool/profile_common.cc
+)
+ADD_LIBRARY(${PROFILE_COMMON} SHARED ${${PROFILE_COMMON}_SOURCE_FILES})
+SET_TARGET_PROPERTIES(${PROFILE_COMMON} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_LIB})
+TARGET_LINK_LIBRARIES(${PROFILE_COMMON} ${${PROJECT_NAME}_LDFLAGS} ${DOTNET_LAUNCHER_UTIL})
+
SET(MULTI_TARGET_RESOLVER "multi_target_resolver")
SET(${MULTI_TARGET_RESOLVER}_SOURCE_FILES
tool/multi_target_resolver.cc
)
ADD_EXECUTABLE(${DOTNETTOOL} ${${DOTNETTOOL}_SOURCE_FILES})
SET_TARGET_PROPERTIES(${DOTNETTOOL} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_EXE})
-TARGET_LINK_LIBRARIES(${DOTNETTOOL} ${${PROJECT_NAME}_LDFLAGS} "-pie" ${DOTNET_LAUNCHER_UTIL} ${NI_COMMON} ${TAC_COMMON} ${MULTI_TARGET_RESOLVER})
+TARGET_LINK_LIBRARIES(${DOTNETTOOL} ${${PROJECT_NAME}_LDFLAGS} "-pie" ${DOTNET_LAUNCHER_UTIL} ${NI_COMMON} ${TAC_COMMON} ${PROFILE_COMMON} ${MULTI_TARGET_RESOLVER})
SET(PREFER_DOTNET_AOT_PLUGIN "prefer_dotnet_aot_plugin")
SET(${PREFER_DOTNET_AOT_PLUGIN}_SOURCE_FILES
INSTALL(TARGETS ${DOTNET_HYDRA_LOADER} DESTINATION ${BINDIR})
INSTALL(TARGETS ${TAC_COMMON} DESTINATION ${LIBDIR})
INSTALL(TARGETS ${NI_COMMON} DESTINATION ${LIBDIR})
+INSTALL(TARGETS ${PROFILE_COMMON} DESTINATION ${LIBDIR})
INSTALL(TARGETS ${MULTI_TARGET_RESOLVER} DESTINATION ${LIBDIR})
INSTALL(TARGETS ${TPATOOL} DESTINATION ${BINDIR})
INSTALL(TARGETS ${DOTNETTOOL} DESTINATION ${BINDIR})
INSTALL(FILES inc/dotnet_launcher_plugin.h DESTINATION ${INCLUDEDIR})
INSTALL(FILES inc/ni_common.h DESTINATION ${INCLUDEDIR})
INSTALL(FILES inc/tac_common.h DESTINATION ${INCLUDEDIR})
+INSTALL(FILES inc/profile_common.h DESTINATION ${INCLUDEDIR})
INSTALL(FILES ../dotnet-launcher.pc DESTINATION ${LIBDIR}/pkgconfig)
INSTALL(FILES dotnet-launcher.info DESTINATION /usr/share/parser-plugins)
IF(DEFINED BUILD_DOTNET_PLUGIN)
*/
ni_error_e regenerateTACNI(NIOption* opt);
-/**
- * @brief remove app profile data of a package
- * @param[in] pkgId package ID
- * @return ni_error_e
- */
-ni_error_e removeAppProfileData(const std::string& pkgId);
-
-/**
- * @brief remove all app profile data
- */
-void removeAllAppProfileData();
-
#endif /* __NI_COMMON_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __PROFILE_COMMON_H__
+#define __PROFILE_COMMON_H__
+
+#include <functional>
+#include <string>
+
+typedef enum {
+ PROFILE_ERROR_NONE = 0,
+ PROFILE_ERROR_INVALID_PARAMETER = -1,
+ PROFILE_ERROR_UNKNOWN = -9
+} profile_error_e;
+
+/**
+ * @brief remove app profile data of a package
+ * @param[in] pkgId package id
+ * @return profile_error_e
+ */
+profile_error_e removeAppProfileData(const std::string& pkgId);
+
+/**
+ * @brief remove all app profile data
+ */
+void removeAllAppProfileData();
+
+#endif /* __PROFILE_COMMON_H__ */
#include "utils.h"
#include "multi_target_resolver.h"
#include "ni_common.h"
+#include "profile_common.h"
#include "launcher_env.h"
#include <vector>
return 0;
}
- if (removeAppProfileData(pkgId) != NI_ERROR_NONE) {
+ if (removeAppProfileData(pkgId) != PROFILE_ERROR_NONE) {
_ERR("Failed to remove [%s] profile data", pkgId);
}
#include "utils.h"
#include "ni_common.h"
#include "tac_common.h"
+#include "profile_common.h"
#include "multi_target_resolver.h"
#include "log.h"
}
while (it != args.end()) {
std::string pkg = std::string(*it);
- if (removeAppProfileData(pkg) != NI_ERROR_NONE) {
+ if (removeAppProfileData(pkg) != PROFILE_ERROR_NONE) {
_SERR("Failed to remove [%s] profile data", pkg.c_str());
}
it = args.erase(it);
#include <pkgmgr-info.h>
#include <pkgmgr_installer_info.h>
#include <aul.h>
-#include <tzplatform_config.h>
#include "log.h"
#include "utils.h"
#include <fstream>
#include <sstream>
-#include <pwd.h>
#include <grp.h>
#include <unistd.h>
#include <string.h>
return NI_ERROR_NONE;
}
-static std::vector<uid_t> getUserIds()
-{
- std::vector<uid_t> list;
-
- while (true) {
- errno = 0; // so we can distinguish errors from no more entries
- passwd* entry = getpwent();
- if (!entry) {
- if (errno) {
- _SERR("Error while getting userIDs");
- list.clear();
- return list;
- }
- break;
- }
- list.push_back(entry->pw_uid);
- }
- endpwent();
-
- return list;
-}
-
-static std::string getAppDataPath(const std::string& pkgId, uid_t uid)
-{
- std::string pDataFile;
-
- tzplatform_set_user(uid);
-
- const char* tzUserApp = tzplatform_getenv(TZ_USER_APP);
- if (tzUserApp != NULL) {
- pDataFile = std::string(tzUserApp) + "/" + pkgId + "/data/";
- }
-
- tzplatform_reset_user();
-
- return pDataFile;
-}
-
-ni_error_e removeAppProfileData(const std::string& pkgId)
-{
- if (pkgId.empty()) {
- return NI_ERROR_INVALID_PARAMETER;
- }
-
- std::vector<uid_t> uidList = getUserIds();
- for (auto& uid : uidList) {
- // get data path from pkgid
- std::string dataPath = getAppDataPath(pkgId, uid);
- if (!dataPath.empty() && exist(dataPath)) {
- std::string pDataFile = dataPath + PROFILE_BASENAME;
-
- if (exist(pDataFile)) {
- if (!removeFile(pDataFile)) {
- _SERR("Fail to remove profile data file (%s).", pDataFile.c_str());
- return NI_ERROR_UNKNOWN;
- }
- _SOUT("Profile data (%s) is removed successfully", pDataFile.c_str());
- }
- }
- }
-
- return NI_ERROR_NONE;
-}
-
-static int appTypeListCb(pkgmgrinfo_appinfo_h handle, void *user_data)
-{
- char *pkgId = NULL;
- int ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgId);
- if (ret != PMINFO_R_OK || pkgId == NULL) {
- _SERR("Fail to get pkgid");
- return 0;
- }
-
- if (removeAppProfileData(pkgId) != NI_ERROR_NONE) {
- _SERR("Fail to remove profile data for (%s)", pkgId);
- }
-
- return 0;
-}
-
-static ni_error_e removeAppProfileByAppType(const char* type)
-{
- int ret;
-
- pkgmgrinfo_appinfo_filter_h filter;
-
- ret = pkgmgrinfo_appinfo_filter_create(&filter);
- if (ret != PMINFO_R_OK) {
- _SERR("Fail to create appinfo filter");
- return NI_ERROR_UNKNOWN;
- }
-
- ret = pkgmgrinfo_appinfo_filter_add_string(filter, PMINFO_APPINFO_PROP_APP_TYPE, type);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_appinfo_filter_destroy(filter);
- _SERR("Fail to add appinfo filter (%s)", type);
- return NI_ERROR_UNKNOWN;
- }
-
- ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(filter, appTypeListCb, NULL);
- if (ret != PMINFO_R_OK) {
- _SERR("Fail to pkgmgrinfo_pkginfo_filter_foreach_pkginfo");
- pkgmgrinfo_appinfo_filter_destroy(filter);
- return NI_ERROR_UNKNOWN;
- }
-
- pkgmgrinfo_appinfo_filter_destroy(filter);
-
- return NI_ERROR_NONE;
-}
-
-void removeAllAppProfileData()
-{
- std::vector<const char*> appTypeList = {"dotnet", "dotnet-nui", "dotnet-inhouse"};
-
- for (auto& type : appTypeList) {
- if (removeAppProfileByAppType(type) != NI_ERROR_NONE) {
- _SERR("Fail to removeAppProfileByAppType for type (%s)", type);
- }
- }
-}
--- /dev/null
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */\r
+\r
+#include "log.h"
+#include "utils.h"\r
+#include "profile_common.h"\r
+#include "launcher_env.h"\r
+\r
+#include <sys/types.h>\r
+#include <pwd.h>\r
+#include <tzplatform_config.h>\r
+\r
+static std::vector<uid_t> getUserIds()\r
+{
+ std::vector<uid_t> list;
+
+ while (true) {
+ errno = 0; // so we can distinguish errors from no more entries
+ passwd* entry = getpwent();
+ if (!entry) {
+ if (errno) {
+ _SERR("Error while getting userIDs");
+ list.clear();
+ return list;
+ }
+ break;
+ }
+ list.push_back(entry->pw_uid);
+ }
+ endpwent();
+
+ return list;
+}
+
+static std::string getAppDataPath(const std::string& pkgId, uid_t uid)
+{
+ std::string pDataFile;
+
+ tzplatform_set_user(uid);
+
+ const char* tzUserApp = tzplatform_getenv(TZ_USER_APP);
+ if (tzUserApp != NULL) {
+ pDataFile = std::string(tzUserApp) + "/" + pkgId + "/data/";
+ }
+
+ tzplatform_reset_user();
+
+ return pDataFile;
+}\r
+\r
+profile_error_e removeAppProfileData(const std::string& pkgId)\r
+{
+ if (pkgId.empty()) {
+ return PROFILE_ERROR_INVALID_PARAMETER;\r
+ }
+
+ std::vector<uid_t> uidList = getUserIds();
+ for (auto& uid : uidList) {
+ // get data path from pkgid
+ std::string dataPath = getAppDataPath(pkgId, uid);
+ if (!dataPath.empty() && exist(dataPath)) {
+ std::string pDataFile = dataPath + PROFILE_BASENAME;
+
+ if (exist(pDataFile)) {
+ if (!removeFile(pDataFile)) {
+ _SERR("Failed to remove profile data file (%s).", pDataFile.c_str());\r
+ return PROFILE_ERROR_UNKNOWN;\r
+ }
+ _SOUT("Profile data (%s) is removed successfully", pDataFile.c_str());
+ }
+ }
+ }
+
+ return PROFILE_ERROR_NONE;\r
+}
+
+static int removeAppProfileListCb(pkgmgrinfo_appinfo_h handle, void *user_data)\r
+{
+ char *pkgId = NULL;
+ int ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgId);
+ if (ret != PMINFO_R_OK || pkgId == NULL) {
+ _SERR("Failed to get package id");\r
+ return 0;
+ }
+
+ if (removeAppProfileData(pkgId) != PROFILE_ERROR_NONE) {\r
+ _SERR("Failed to remove profile data for (%s)", pkgId);\r
+ }
+
+ return 0;
+}
+
+static void removeAppProfileByAppType(const char* type)\r
+{
+ pkgmgrinfo_appinfo_filter_h filter;\r
+
+ int ret = pkgmgrinfo_appinfo_filter_create(&filter);\r
+ if (ret != PMINFO_R_OK) {
+ _SERR("Failed to create appinfo filter");\r
+ return;\r
+ }
+
+ ret = pkgmgrinfo_appinfo_filter_add_string(filter, PMINFO_APPINFO_PROP_APP_TYPE, type);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ _SERR("Failed to add appinfo filter (%s)", type);\r
+ return;\r
+ }
+
+ ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(filter, removeAppProfileListCb, NULL);\r
+ if (ret != PMINFO_R_OK) {
+ _SERR("Failed to pkgmgrinfo_pkginfo_filter_foreach_pkginfo");\r
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ return;\r
+ }
+
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+
+ return;\r
+}
+
+void removeAllAppProfileData()
+{
+ std::vector<const char*> appTypeList = {"dotnet", "dotnet-nui", "dotnet-inhouse"};
+
+ for (auto& type : appTypeList) {
+ removeAppProfileByAppType(type);\r
+ }
+}\r
+\r
%{_libdir}/libdotnet_launcher_core.so
%{_libdir}/libni_common.so
%{_libdir}/libtac_common.so
+%{_libdir}/libprofile_common.so
%{_libdir}/libmulti_target_resolver.so
%{_tmpfilesdir}/%{name}.conf
/usr/share/parser-plugins/dotnet-launcher.info
%defattr(-,root,root,-)
%{_includedir}/ni_common.h
%{_includedir}/tac_common.h
+%{_includedir}/profile_common.h
%{_includedir}/dotnet_launcher_plugin.h
%{_includedir}/coreclr_host.h
%{_libdir}/libdotnet_launcher_util.so
%{_libdir}/libni_common.so
%{_libdir}/libtac_common.so
+%{_libdir}/libprofile_common.so
%{_libdir}/pkgconfig/dotnet-launcher.pc
%{_framework_dir}/Tizen.Runtime.pdb