From 3e56bc3c2dd0b950fbb543617d403a331356fce2 Mon Sep 17 00:00:00 2001 From: "junsuk77.oh" Date: Thu, 27 Jun 2013 21:18:54 +0900 Subject: [PATCH] implement smack to rpm pkg Change-Id: I494d35c1c874684ec3721e42cc2b14d1344221b3 Signed-off-by: junsuk77.oh --- CMakeLists.txt | 2 + mdparser_list.txt.in | 3 +- packaging/pkgmgr-info.spec | 3 +- parser/CMakeLists.txt | 2 +- parser/pkgmgr_parser.c | 171 ++++++++++++++++++++++--- parser/pkgmgr_parser_db.h | 13 ++ parser/pkgmgr_parser_privilege.c | 270 +++++++++++++++++++++++++++++++++++++++ pkgmgr_smack_list.txt.in | 1 + 8 files changed, 441 insertions(+), 24 deletions(-) create mode 100644 parser/pkgmgr_parser_privilege.c create mode 100644 pkgmgr_smack_list.txt.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 64c6a0c..39e22b0 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,9 +57,11 @@ configure_file(parser_path.conf.in parser_path.conf @ONLY) configure_file(pkgmgr-info.manifest.in pkgmgr-info.manifest @ONLY) configure_file(pkgmgr-parser.manifest.in pkgmgr-parser.manifest @ONLY) configure_file(mdparser_list.txt.in mdparser_list.txt @ONLY) +configure_file(pkgmgr_smack_list.txt.in pkgmgr_smack_list.txt @ONLY) INSTALL(TARGETS pkgmgr-info DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-info.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/pkgmgr-info.h DESTINATION include) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/parser_path.conf DESTINATION ${PREFIX}/etc/package-manager/) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mdparser_list.txt DESTINATION ${PREFIX}/etc/package-manager/parserlib/metadata) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr_smack_list.txt DESTINATION ${PREFIX}/etc/package-manager/) diff --git a/mdparser_list.txt.in b/mdparser_list.txt.in index e136d0d..1d52ae8 100644 --- a/mdparser_list.txt.in +++ b/mdparser_list.txt.in @@ -1,2 +1,3 @@ http://developer.samsung.com/tizen/metadata/sticker -http://developer.samsung.com/tizen/metadata/tts \ No newline at end of file +http://developer.samsung.com/tizen/metadata/tts +http://developer.samsung.com/tizen/metadata/downloadable_filters \ No newline at end of file diff --git a/packaging/pkgmgr-info.spec b/packaging/pkgmgr-info.spec index b81b2e1..85ff1b6 100755 --- a/packaging/pkgmgr-info.spec +++ b/packaging/pkgmgr-info.spec @@ -1,6 +1,6 @@ Name: pkgmgr-info Summary: Packager Manager infomation api for package -Version: 0.0.125 +Version: 0.0.126 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 @@ -85,6 +85,7 @@ chsmack -a '_' /usr/etc/package-manager %{_prefix}/etc/package-manager/preload/xml.xsd %{_prefix}/etc/package-manager/parser_path.conf %{_prefix}/etc/package-manager/parserlib/metadata/mdparser_list.txt +%{_prefix}/etc/package-manager/pkgmgr_smack_list.txt %files parser-devel %defattr(-,root,root,-) diff --git a/parser/CMakeLists.txt b/parser/CMakeLists.txt index 870973d..e44b345 100755 --- a/parser/CMakeLists.txt +++ b/parser/CMakeLists.txt @@ -43,7 +43,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) ## pkgmgr_parser object (by sewook.park) # This library is for installer backend -add_library(pkgmgr_parser SHARED pkgmgr_parser.c pkgmgr_parser_db.c) +add_library(pkgmgr_parser SHARED pkgmgr_parser.c pkgmgr_parser_db.c pkgmgr_parser_privilege.c) #add_library(pkgmgr_parser SHARED pkgmgr_parser.c) set_target_properties(pkgmgr_parser PROPERTIES SOVERSION ${VERSION_MAJOR}) set_target_properties(pkgmgr_parser PROPERTIES VERSION ${VERSION}) diff --git a/parser/pkgmgr_parser.c b/parser/pkgmgr_parser.c index 49b827f..6f2e712 100755 --- a/parser/pkgmgr_parser.c +++ b/parser/pkgmgr_parser.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "pkgmgr_parser.h" #include "pkgmgr_parser_internal.h" @@ -44,9 +45,43 @@ #define ASCII(s) (const char *)s #define XMLCHAR(s) (const xmlChar *)s +#define PRELOAD_PACKAGE_LIST "/usr/etc/package-manager/preload/preload_list.txt" +#define SCHEMA_FILE "/usr/etc/package-manager/preload/manifest.xsd" + #define MDPARSER_LIST "/usr/etc/package-manager/parserlib/metadata/mdparser_list.txt" #define MDPARSER_NAME "mdparser:" +#define SMACK_LIST "/usr/etc/package-manager/pkgmgr_smack_list.txt" + +#define BUFMAX 1024*128 + +#define BUFF_SIZE 256 +#define APP_OWNER_ID 5000 +#define APP_GROUP_ID 5000 + +#define LIBAPPSVC_PATH "/usr/lib/libappsvc.so.0" +#define LIBAIL_PATH "/usr/lib/libail.so.0" +#define DESKTOP_RW_PATH "/opt/share/applications/" +#define DESKTOP_RO_PATH "/usr/share/applications/" +#define MANIFEST_RO_PREFIX "/usr/share/packages/" + +/* operation_type */ +typedef enum { + AIL_INSTALL = 0, + AIL_UPDATE, + AIL_REMOVE, + AIL_CLEAN, + AIL_MAX +} AIL_TYPE; + +enum rpm_path_type { + RPM_PATH_PRIVATE, + RPM_PATH_GROUP_RW, + RPM_PATH_PUBLIC_RO, + RPM_PATH_SETTINGS_RW, + RPM_PATH_ANY_LABEL +}; + /* operation_type */ typedef enum { ACTION_INSTALL = 0, @@ -142,6 +177,73 @@ static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *con static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid); static int __validate_appid(const char *pkgid, const char *appid, char **newappid); +static int __is_dir(char *dirname) +{ + struct stat stFileInfo; + stat(dirname, &stFileInfo); + if (S_ISDIR(stFileInfo.st_mode)) { + return 1; + } + return 0; +} + +static void __apply_shared_privileges(char *pkgname, int flag) +{ + char dirpath[BUFF_SIZE] = {'\0'}; + /*execute privilege APIs. The APIs should not fail*/ + pkgmgr_parser_privilege_register_package(pkgname); + +#if 0 + /*home dir. Dont setup path but change smack access to "_" */ + snprintf(dirpath, BUFF_SIZE, "/usr/apps/%s", pkgname); + if (__is_dir(dirpath)) + pkgmgr_parser_privilege_change_smack_label(dirpath, "_", 0);/*0 is SMACK_LABEL_ACCESS*/ + memset(dirpath, '\0', BUFF_SIZE); + snprintf(dirpath, BUFF_SIZE, "/opt/usr/apps/%s", pkgname); + if (__is_dir(dirpath)) + pkgmgr_parser_privilege_change_smack_label(dirpath, "_", 0);/*0 is SMACK_LABEL_ACCESS*/ + memset(dirpath, '\0', BUFF_SIZE); + + /*/shared dir. Dont setup path but change smack access to "_" */ + snprintf(dirpath, BUFF_SIZE, "/usr/apps/%s/shared", pkgname); + if (__is_dir(dirpath)) + pkgmgr_parser_privilege_change_smack_label(dirpath, "_", 0);/*0 is SMACK_LABEL_ACCESS*/ + memset(dirpath, '\0', BUFF_SIZE); + snprintf(dirpath, BUFF_SIZE, "/opt/usr/apps/%s/shared", pkgname); + if (__is_dir(dirpath)) + pkgmgr_parser_privilege_change_smack_label(dirpath, "_", 0);/*0 is SMACK_LABEL_ACCESS*/ + memset(dirpath, '\0', BUFF_SIZE); + + /*/shared/res dir. setup path */ + if (flag == 0) + snprintf(dirpath, BUFF_SIZE, "/usr/apps/%s/shared/res", pkgname); + else + snprintf(dirpath, BUFF_SIZE, "/opt/usr/apps/%s/shared/res", pkgname); + if (__is_dir(dirpath)) + pkgmgr_parser_privilege_setup_path(pkgname, dirpath, RPM_PATH_PUBLIC_RO, NULL); + memset(dirpath, '\0', BUFF_SIZE); + + /*/shared/data dir. setup path and change group to 'app'*/ + if (flag == 0) + snprintf(dirpath, BUFF_SIZE, "/usr/apps/%s/shared/data", pkgname); + else + snprintf(dirpath, BUFF_SIZE, "/opt/usr/apps/%s/shared/data", pkgname); + if (__is_dir(dirpath)) { + chown(dirpath, APP_OWNER_ID, APP_GROUP_ID); + pkgmgr_parser_privilege_setup_path(pkgname, dirpath, RPM_PATH_PUBLIC_RO, NULL); + } else { + memset(dirpath, '\0', BUFF_SIZE); + if (flag == 0) + snprintf(dirpath, BUFF_SIZE, "/opt/usr/apps/%s/shared/data", pkgname); + else + snprintf(dirpath, BUFF_SIZE, "/usr/apps/%s/shared/data", pkgname); + if (__is_dir(dirpath)) + chown(dirpath, APP_OWNER_ID, APP_GROUP_ID); + pkgmgr_parser_privilege_setup_path(pkgname, dirpath, RPM_PATH_PUBLIC_RO, NULL); + } +#endif +} + static void __str_trim(char *input) { char *trim_str = input; @@ -1827,6 +1929,47 @@ static void __ps_free_ime(ime_x *ime) ime = NULL; } +static void __ps_apply_shared_privileges(manifest_x * mfx, const char *manifest) +{ + int home_dir = 0; + + if(strstr(manifest, MANIFEST_RO_PREFIX)) + home_dir = 0; + else + home_dir = 1; + + if ((strcmp(mfx->type,"tpk")!=0) || (strcmp(mfx->type,"wgt")!=0)){ + DBG("rpm pkg is detected, apply smack\n"); + __apply_shared_privileges(mfx->package, home_dir); + } +} + +static void __ps_process_smack() +{ + FILE *fp = NULL; + char pkgid[PKG_STRING_LEN_MAX] = { 0 }; + + fp = fopen(SMACK_LIST, "r"); + if (fp == NULL) { + DBG("no preload list\n"); + return -1; + } + + while (fgets(pkgid, sizeof(pkgid), fp) != NULL) { + __str_trim(pkgid); + DBG("pkgid = %s\n", pkgid); + + __apply_shared_privileges(pkgid,0); + + memset(pkgid, 0x00, sizeof(pkgid)); + } + + if (fp != NULL) + fclose(fp); + + return 0; +} + int __ps_process_mdparser(manifest_x *mfx, ACTION_TYPE action) { int ret = -1; @@ -3570,10 +3713,6 @@ static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx) return ret; } -#define DESKTOP_RW_PATH "/opt/share/applications/" -#define DESKTOP_RO_PATH "/usr/share/applications/" -#define MANIFEST_RO_PREFIX "/usr/share/packages/" - static char* __convert_to_system_locale(const char *mlocale) { if (mlocale == NULL) @@ -3592,17 +3731,6 @@ static char* __convert_to_system_locale(const char *mlocale) return locale; } -#define LIBAIL_PATH "/usr/lib/libail.so.0" - -/* operation_type */ -typedef enum { - AIL_INSTALL = 0, - AIL_UPDATE, - AIL_REMOVE, - AIL_CLEAN, - AIL_MAX -} AIL_TYPE; - static int __ail_change_info(int op, const char *appid) { void *lib_handle = NULL; @@ -3652,7 +3780,6 @@ END: /* desktop shoud be generated automatically based on manifest */ /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/ -#define BUFMAX 1024*128 static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, bool is_update) { FILE* file = NULL; @@ -4029,8 +4156,6 @@ static int __ps_remove_nativeapp_desktop(manifest_x *mfx) return 0; } -#define LIBAPPSVC_PATH "/usr/lib/libappsvc.so.0" - static int __ps_remove_appsvc_db(manifest_x *mfx) { void *lib_handle = NULL; @@ -4062,7 +4187,6 @@ END: return ret; } -#define PRELOAD_PACKAGE_LIST "/usr/etc/package-manager/preload/preload_list.txt" static int __add_preload_info(manifest_x * mfx, const char *manifest) { FILE *fp = NULL; @@ -4436,7 +4560,7 @@ API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char DBG("Parsing Finished\n"); if (mfx == NULL) return PMINFO_R_ERROR; - + __streamFile(manifest, ACTION_INSTALL, temp, mfx->package); __add_preload_info(mfx, manifest); DBG("Added preload infomation\n"); @@ -4459,6 +4583,8 @@ API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char else DBG("Creating desktop file Success\n"); + __ps_apply_shared_privileges(mfx, manifest); + pkgmgr_parser_free_manifest_xml(mfx); DBG("Free Done\n"); xmlCleanupParser(); @@ -4530,6 +4656,8 @@ API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *con else DBG("Creating desktop file Success\n"); + __ps_apply_shared_privileges(mfx, manifest); + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); pkgmgr_parser_free_manifest_xml(mfx); DBG("Free Done\n"); @@ -4589,6 +4717,8 @@ API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, ch API int pkgmgr_parser_parse_manifest_for_preload() { + __ps_process_smack(); + return pkgmgr_parser_update_preload_info_in_db(); } @@ -4612,7 +4742,6 @@ API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid); } -#define SCHEMA_FILE "/usr/etc/package-manager/preload/manifest.xsd" #if 1 API int pkgmgr_parser_check_manifest_validation(const char *manifest) { diff --git a/parser/pkgmgr_parser_db.h b/parser/pkgmgr_parser_db.h index 7dd2975..11400b0 100755 --- a/parser/pkgmgr_parser_db.h +++ b/parser/pkgmgr_parser_db.h @@ -128,6 +128,19 @@ int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx); int pkgmgr_parser_update_preload_info_in_db(); int pkgmgr_parser_check_and_create_db(); int pkgmgr_parser_initialize_db(); + +/* libprivilege-control specific operations prototype*/ +int pkgmgr_parser_privilege_register_package(const char *pkgid); +int pkgmgr_parser_privilege_unregister_package(const char *pkgid); +int pkgmgr_parser_privilege_revoke_permissions(const char *pkgid); +int pkgmgr_parser_privilege_enable_permissions(const char *pkgid, int apptype, + const char **perms, int persistent); +int pkgmgr_parser_privilege_setup_path(const char *pkgid, const char *dirpath, + int apppathtype, const char *groupid); +int pkgmgr_parser_privilege_add_friend(const char *pkgid1, const char *pkgid2); +int pkgmgr_parser_privilege_change_smack_label(const char *path, const char *label, + int label_type); + /** @} */ #ifdef __cplusplus } diff --git a/parser/pkgmgr_parser_privilege.c b/parser/pkgmgr_parser_privilege.c new file mode 100644 index 0000000..5b32602 --- /dev/null +++ b/parser/pkgmgr_parser_privilege.c @@ -0,0 +1,270 @@ +/* + * rpm-installer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Jayoun Lee , Sewook Park , + * Jaeho Lee , Shobhit Srivastava + * + * 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 _GNU_SOURCE +#define _GNU_SOURCE +#endif +#define __USE_GNU +#include +#include +#include +#include +#include +#include +#include + +#include "pkgmgr_parser_internal.h" + +#define LIB_PRIVILEGE_CONTROL "libprivilege-control.so.0" +#define LIB_SMACK "libsmack.so.1" + +int pkgmgr_parser_privilege_register_package(const char *pkgid) +{ + int ret = 0; + void *handle = NULL; + char *errmsg = NULL; + int (*app_install)(const char*) = NULL; + + if (pkgid == NULL) + return -1; + + handle = dlopen(LIB_PRIVILEGE_CONTROL, RTLD_LAZY | RTLD_GLOBAL); + if (!handle) { + DBG( "register package: dlopen() failed. [%s]", dlerror()); + return -1; + } + + app_install = dlsym(handle, "app_install"); + errmsg = dlerror(); + if ((errmsg != NULL) || (app_install == NULL)) { + DBG( "register package: dlsym() failed. [%s]", errmsg); + dlclose(handle); + return -1; + } + + DBG( "[smack] app_install(%s)", pkgid); + ret = app_install(pkgid); + DBG( "[smack] app_install(%s), result = [%d]", pkgid, ret); + + dlclose(handle); + return ret; +} + +int pkgmgr_parser_privilege_unregister_package(const char *pkgid) +{ + int ret = 0; + void *handle = NULL; + char *errmsg = NULL; + int (*app_uninstall)(const char*) = NULL; + + if (pkgid == NULL) + return -1; + + handle = dlopen(LIB_PRIVILEGE_CONTROL, RTLD_LAZY | RTLD_GLOBAL); + if (!handle) { + DBG( "unregister package: dlopen() failed. [%s]", dlerror()); + return -1; + } + + app_uninstall = dlsym(handle, "app_uninstall"); + errmsg = dlerror(); + if ((errmsg != NULL) || (app_uninstall == NULL)) { + DBG( "unregister package: dlsym() failed. [%s]", errmsg); + dlclose(handle); + return -1; + } + + DBG( "[smack] app_uninstall(%s)", pkgid); + ret = app_uninstall(pkgid); + DBG( "[smack] app_uninstall(%s), result = [%d]", pkgid, ret); + + dlclose(handle); + return ret; +} + +int pkgmgr_parser_privilege_revoke_permissions(const char *pkgid) +{ + int ret = 0; + void *handle = NULL; + char *errmsg = NULL; + int (*app_revoke_permissions)(const char*) = NULL; + + if (pkgid == NULL) + return -1; + + handle = dlopen(LIB_PRIVILEGE_CONTROL, RTLD_LAZY | RTLD_GLOBAL); + if (!handle) { + DBG( "revoke permissions: dlopen() failed. [%s][%s]", pkgid, dlerror()); + return -1; + } + + app_revoke_permissions = dlsym(handle, "app_revoke_permissions"); + errmsg = dlerror(); + if ((errmsg != NULL) || (app_revoke_permissions == NULL)) { + DBG( "revoke permissions(): dlsym() failed. [%s][%s]", pkgid, errmsg); + dlclose(handle); + return -1; + } + + DBG( "[smack] app_revoke_permissions(%s)", pkgid); + ret = app_revoke_permissions(pkgid); + DBG( "[smack] app_revoke_permissions(%s), result = [%d]", pkgid, ret); + + dlclose(handle); + return ret; +} + +int pkgmgr_parser_privilege_enable_permissions(const char *pkgid, int apptype, + const char **perms, int persistent) +{ + int ret = 0; + void *handle = NULL; + char *errmsg = NULL; + int (*app_enable_permissions)(const char*, int, const char**, bool) = NULL; + + if (pkgid == NULL) + return -1; + + handle = dlopen(LIB_PRIVILEGE_CONTROL, RTLD_LAZY | RTLD_GLOBAL); + if (!handle) { + DBG( "enable permissions(): dlopen() failed. [%s]", dlerror()); + return -1; + } + + app_enable_permissions = dlsym(handle, "app_enable_permissions"); + errmsg = dlerror(); + if ((errmsg != NULL) || (app_enable_permissions == NULL)) { + DBG( "enable permissions(): dlsym() failed. [%s]", errmsg); + dlclose(handle); + return -1; + } + + DBG( "[smack] app_enable_permissions(%s, %d)", pkgid, apptype); + ret = app_enable_permissions(pkgid, apptype, perms, persistent); + DBG( "[smack] app_enable_permissions(%s, %d), result = [%d]", pkgid, apptype, ret); + + dlclose(handle); + return ret; +} + +int pkgmgr_parser_privilege_setup_path(const char *pkgid, const char *dirpath, + int apppathtype, const char *groupid) +{ + int ret = 0; + void *handle = NULL; + char *errmsg = NULL; + int (*app_setup_path)(const char*, const char*, int, ...) = NULL; + + if (pkgid == NULL || dirpath == NULL) + return -1; + + handle = dlopen(LIB_PRIVILEGE_CONTROL, RTLD_LAZY | RTLD_GLOBAL); + if (!handle) { + DBG( "setup path: dlopen() failed. [%s]", dlerror()); + return -1; + } + + app_setup_path = dlsym(handle, "app_setup_path"); + errmsg = dlerror(); + if ((errmsg != NULL) || (app_setup_path == NULL)) { + DBG( "setup path: dlsym() failed. [%s]", errmsg); + dlclose(handle); + return -1; + } + + if (groupid == NULL) { + DBG( "[smack] app_setup_path(%s, %s, %d)", pkgid, dirpath, apppathtype); + ret = app_setup_path(pkgid, dirpath, apppathtype); + DBG( "[smack] app_setup_path(), result = [%d]", ret); + } else { + DBG( "[smack] app_setup_path(%s, %s, %d, %s)", pkgid, dirpath, apppathtype, groupid); + ret = app_setup_path(pkgid, dirpath, apppathtype, groupid); + DBG( "[smack] app_setup_path(), result = [%d]", ret); + } + + dlclose(handle); + return ret; +} + +int pkgmgr_parser_privilege_add_friend(const char *pkgid1, const char *pkgid2) +{ + int ret = 0; + void *handle = NULL; + char *errmsg = NULL; + int (*app_add_friend)(const char*, const char*) = NULL; + + if (pkgid1 == NULL || pkgid2 == NULL) + return -1; + + handle = dlopen(LIB_PRIVILEGE_CONTROL, RTLD_LAZY | RTLD_GLOBAL); + if (!handle) { + DBG( "add friend: dlopen() failed. [%s]", dlerror()); + return -1; + } + + app_add_friend = dlsym(handle, "app_add_friend"); + errmsg = dlerror(); + if ((errmsg != NULL) || (app_add_friend == NULL)) { + DBG( "add friend: dlsym() failed. [%s]", errmsg); + dlclose(handle); + return -1; + } + + DBG( "[smack] app_add_friend(%s, %s)", pkgid1, pkgid2); + ret = app_add_friend(pkgid1, pkgid2); + DBG( "[smack] app_add_friend(%s, %s), result = [%d]", pkgid1, pkgid2, ret); + + dlclose(handle); + return ret; +} + +int pkgmgr_parser_privilege_change_smack_label(const char *path, const char *label, + int label_type) +{ + if (path == NULL || label == NULL) + return -1; + int ret = 0; + void *handle = NULL; + char *errmsg = NULL; + int (*smack_lsetlabel)(const char*, const char*, int) = NULL; + + handle = dlopen(LIB_SMACK, RTLD_LAZY | RTLD_GLOBAL); + if (!handle) { + DBG( "change smack label: dlopen() failed. [%s]", dlerror()); + return -1; + } + + smack_lsetlabel = dlsym(handle, "smack_lsetlabel"); + errmsg = dlerror(); + if ((errmsg != NULL) || (smack_lsetlabel == NULL)) { + DBG( "change smack label: dlsym() failed. [%s]", errmsg); + dlclose(handle); + return -1; + } + + DBG( "[smack] smack_lsetlabel(%s, %s, %d)", path, label, label_type); + ret = smack_lsetlabel(path, label, label_type); + DBG( "[smack] smack_lsetlabel(%s, %s, %d), result = [%d]", path, label, label_type, ret); + + dlclose(handle); + return ret; +} diff --git a/pkgmgr_smack_list.txt.in b/pkgmgr_smack_list.txt.in new file mode 100644 index 0000000..5a2c6d9 --- /dev/null +++ b/pkgmgr_smack_list.txt.in @@ -0,0 +1 @@ +ui-gadget::client \ No newline at end of file -- 2.7.4