4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7 * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
32 #include <privilege-control.h>
33 #include "sys/smack.h"
35 #include "rpm-installer.h"
39 static int __ri_privilege_perm_begin(void)
44 _LOGD("[smack] perm_begin, result=[%d]",ret);
49 static int __ri_privilege_perm_end(void)
54 _LOGD("[smack] perm_end, result=[%d]",ret);
59 int _ri_privilege_register_package(const char *pkgid)
63 ret = perm_app_install(pkgid);
64 _LOGD("[smack] app_install(%s), result=[%d]", pkgid, ret);
69 int _ri_privilege_unregister_package(const char *pkgid)
73 ret = perm_app_uninstall(pkgid);
74 _LOGD("[smack] app_uninstall(%s), result=[%d]", pkgid, ret);
79 int _ri_privilege_revoke_permissions(const char *pkgid)
83 ret = perm_app_revoke_permissions(pkgid);
84 _LOGD("[smack] app_revoke_permissions(%s), result=[%d]", pkgid, ret);
89 int _ri_privilege_enable_permissions(const char *pkgid, int apptype,
90 const char **perms, int persistent)
94 __ri_privilege_perm_begin();
96 ret = perm_app_enable_permissions(pkgid, apptype, perms, persistent);
97 _LOGD("[smack] app_enable_permissions(%s, %d), result=[%d]", pkgid, apptype, ret);
99 __ri_privilege_perm_end();
104 int _ri_privilege_setup_path(const char *pkgid, const char *dirpath, int apppathtype, const char *groupid)
108 if (groupid == NULL) {
109 ret = perm_app_setup_path(pkgid, dirpath, apppathtype);
110 _LOGD("[smack] app_setup_path(%s, %s, %d), result=[%d]", pkgid, dirpath, apppathtype, ret);
112 ret = perm_app_setup_path(pkgid, dirpath, apppathtype, groupid);
113 _LOGD("[smack] app_setup_path(%s, %s, %d, %s), result=[%d]", pkgid, dirpath, apppathtype, groupid, ret);
119 int _ri_privilege_add_friend(const char *pkgid1, const char *pkgid2)
123 ret = perm_app_add_friend(pkgid1, pkgid2);
124 _LOGD("[smack] app_add_friend(%s, %s), result=[%d]", pkgid1, pkgid2, ret);
129 int _ri_privilege_change_smack_label(const char *path, const char *label,
132 if (path == NULL || label == NULL)
136 ret = smack_lsetlabel(path, label, label_type);
137 _LOGD("[smack] smack_lsetlabel(%s, %s, %d), result=[%d]", path, label, label_type, ret);