#endif //DLOG_ERROR_ENABLED
+static int nosmack = -1;
+
+#define IFNOSMACK(ret) \
+do { \
+ if (-1 == nosmack) { \
+ int fd = open("/smack/load2", O_WRONLY); \
+ if (-1 == fd) { \
+ C_LOGD("Libprivilage-control: no smack found on phone"); \
+ nosmack = 1; \
+ } else { \
+ C_LOGD("Libprivilege-control: found smack on phone"); \
+ close(fd); \
+ nosmack = 0; \
+ } \
+ } \
+ if (1 == nosmack) { \
+ return (ret); \
+ } \
+} while(0)
+
typedef enum {
APP_TYPE_WGT,
APP_TYPE_OTHER,
API int control_privilege(void)
{
C_LOGD("Enter function: %s", __func__);
- if(getuid() == APP_UID) // current user is 'app'
+ if(getuid() == APP_UID) // current user is 'app'
return PC_OPERATION_SUCCESS;
if(set_app_privilege("com.samsung.", NULL, NULL) == PC_OPERATION_SUCCESS)
API int set_app_privilege(const char* name, const char* type, const char* path)
{
- C_LOGD("Enter function: %s", __func__);
+ C_LOGD("Enter function: %s", __func__);
C_LOGD("Function params: name = %s, type = %s, path = %s", name, type, path);
+ IFNOSMACK(set_dac(name));
#ifdef SMACK_ENABLED
const char* widget_id;
int ret = PC_OPERATION_SUCCESS;
API int set_privilege(const char* pkg_name)
{
- C_LOGD("Enter function: %s", __func__);
+ C_LOGD("Enter function: %s", __func__);
return set_app_privilege(pkg_name, NULL, NULL);
}
API char* app_id_from_socket(int sockfd)
{
- C_LOGD("Enter function: %s", __func__);
+ C_LOGD("Enter function: %s", __func__);
+ IFNOSMACK(PC_OPERATION_SUCCESS);
#ifdef SMACK_ENABLED
char* app_id;
int ret;
API int app_add_permissions(const char* app_id, const char** perm_list)
{
- C_LOGD("Enter function: %s", __func__);
+ C_LOGD("Enter function: %s", __func__);
+ IFNOSMACK(PC_OPERATION_SUCCESS);
return app_add_permissions_internal(app_id, perm_list, 1);
}
API int app_add_volatile_permissions(const char* app_id, const char** perm_list)
{
- C_LOGD("Enter function: %s", __func__);
+ C_LOGD("Enter function: %s", __func__);
+ IFNOSMACK(PC_OPERATION_SUCCESS);
return app_add_permissions_internal(app_id, perm_list, 0);
}
API int app_revoke_permissions(const char* app_id)
{
- C_LOGD("Enter function: %s", __func__);
+ C_LOGD("Enter function: %s", __func__);
+ IFNOSMACK(PC_OPERATION_SUCCESS);
return app_revoke_permissions_internal(app_id, 1);
}
API int app_reset_permissions(const char* app_id)
{
- C_LOGD("Enter function: %s", __func__);
+ C_LOGD("Enter function: %s", __func__);
+ IFNOSMACK(PC_OPERATION_SUCCESS);
int ret;
ret = app_revoke_permissions_internal(app_id, 0);
API int app_label_dir(const char* label, const char* path)
{
- C_LOGD("Enter function: %s", __func__);
+ C_LOGD("Enter function: %s", __func__);
+ IFNOSMACK(PC_OPERATION_SUCCESS);
#ifdef SMACK_ENABLED
int ret = PC_OPERATION_SUCCESS;
API int app_label_shared_dir(const char* app_label, const char* shared_label, const char* path)
{
C_LOGD("Enter function: %s", __func__);
+ IFNOSMACK(PC_OPERATION_SUCCESS);
#ifdef SMACK_ENABLED
char* smack_path = NULL;
int ret;