Changed dlog logging buffer.
authorJan Olszak <j.olszak@samsung.com>
Thu, 4 Jul 2013 12:22:02 +0000 (14:22 +0200)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Mon, 12 Aug 2013 09:24:32 +0000 (09:24 +0000)
[Issue#] dlog logged in a wrong buffer.
[Bug/Feature]   Recent prevent bugs need fix.
[Cause]         N/A
[Solution]      N/A
[Verification]  Build, install, run "dlogutil -c", run tests, run "dlogutil -b main PRIVILEGE_CONTROL" (no loggs), "dlogutil -b system PRIVILEGE_CONTROL" (loggs..)

Change-Id: Ief75512faddec867ad82c2e710b78b9f2be18659

include/common.h
src/access-db.c
src/privilege-control.c
src/slp-su.c

index e6cc5f2..b3de866 100644 (file)
 
 // conditional log macro for dlogutil (debug)
 #ifdef DLOG_DEBUG_ENABLED
-#define C_LOGD(...) LOGD(__VA_ARGS__)
+#define C_LOGD(...) SLOGD(__VA_ARGS__)
 #else
 #define C_LOGD(...) do { } while(0)
 #endif //DDLOG_DEBUG_ENABLED
 
 // conditional log macro for dlogutil (warning)
 #ifdef DLOG_WARN_ENABLED
-#define C_LOGW(...) LOGW(__VA_ARGS__)
+#define C_LOGW(...) SLOGW(__VA_ARGS__)
 #else
 #define C_LOGW(...) do { } while(0)
 #endif //DLOG_WARN_ENABLED
 
 // conditional log macro for dlogutil (error)
 #ifdef DLOG_ERROR_ENABLED
-#define C_LOGE(...) LOGE(__VA_ARGS__)
+#define C_LOGE(...) SLOGE(__VA_ARGS__)
 #else
 #define C_LOGE(...) do { } while(0)
 #endif //DLOG_ERROR_ENABLED
index 5310c7d..68b9bf9 100644 (file)
@@ -105,12 +105,12 @@ static int add_id_to_database_internal(const char * id, db_app_type_t app_type)
 
        file_db = fopen(db_file_name, "a");
        if (NULL == file_db) {
-               SECURE_LOGE("Error while opening database file: %s", db_file_name);
+               SECURE_SLOGE("Error while opening database file: %s", db_file_name);
                return PC_ERR_FILE_OPERATION;
        }
 
        if (0 > fprintf(file_db, "%s\n", id)) {
-               SECURE_LOGE("Write label %s to database failed: %s", id, strerror(errno));
+               SECURE_SLOGE("Write label %s to database failed: %s", id, strerror(errno));
                return PC_ERR_FILE_OPERATION;
        }
 
@@ -134,7 +134,7 @@ static int get_all_ids_internal (char *** ids, int * len, db_app_type_t app_type
 
        file_db = fopen(db_file_name, "r");
        if (NULL == file_db) {
-               SECURE_LOGE("Error while opening database file: %s", db_file_name);
+               SECURE_SLOGE("Error while opening database file: %s", db_file_name);
                ret = PC_ERR_FILE_OPERATION;
                goto out;
        }
index 6083a05..27d975c 100644 (file)
@@ -373,7 +373,7 @@ static int set_dac(const char *smack_label, const char *pkg_name)
                        goto error;
                }
 
-               SECURE_LOGD("setenv(): USER = %s, HOME = %s", usr.user_name, usr.home_dir);
+               SECURE_SLOGD("setenv(): USER = %s, HOME = %s", usr.user_name, usr.home_dir);
                if(setenv("USER", usr.user_name, 1) != 0)       //fail
                {
                        C_LOGE("Failed to execute setenv() [USER].");
@@ -542,7 +542,7 @@ API int set_app_privilege(const char* name, const char* type, const char* path)/
 API int perm_app_set_privilege(const char* name, const char* type, const char* path)
 {
        C_LOGD("Enter function: %s", __func__);
-       SECURE_LOGD("Function params: name = %s, type = %s, path = %s", name, type, path);
+       SECURE_SLOGD("Function params: name = %s, type = %s, path = %s", name, type, path);
        int ret = PC_OPERATION_SUCCESS;
        int were_rules_loaded = 0;
        char *smack_label AUTO_FREE;
@@ -821,7 +821,7 @@ static int perm_to_dac(const char* app_label, app_type_t app_type, const char* p
        }
 
        while (fscanf(file, "%d\n", &gid) == 1) {
-               SECURE_LOGD("Adding app_id %s to group %d", app_label, gid);
+               SECURE_SLOGD("Adding app_id %s to group %d", app_label, gid);
                ret = add_app_gid(app_label, gid);
                if (ret != PC_OPERATION_SUCCESS) {
                        C_LOGE("sadd_app_gid failed");
@@ -945,7 +945,7 @@ API char* perm_app_id_from_socket(int sockfd)
                return NULL;
        }
 
-       C_LOGD("app_id: %s", app_id);
+       SECURE_SLOGD("app_id: %s", app_id);
 
        return app_id;
 }
@@ -1116,9 +1116,9 @@ static int register_app_for_av(const char * app_id)
 
        // for each anti-virus label put rule: "anti_virus_label app_id rwx"
        for (i = 0; i < smack_label_av_list_len; ++i) {
-               SECURE_LOGD("Antivirus: app_add_rule (%s, %s rx)", smack_label_av_list[i], app_id);
+               SECURE_SLOGD("Antivirus: app_add_rule (%s, %s rx)", smack_label_av_list[i], app_id);
                if (strcmp(app_id, smack_label_av_list[i])==0) {
-                       SECURE_LOGW("Trying to add antivirus rule for self. Skipping");
+                       SECURE_SLOGW("Trying to add antivirus rule for self. Skipping");
                        continue;
                }
                ret = app_add_rule(smack_label_av_list[i], app_id, "wrx");
@@ -1163,12 +1163,12 @@ static int register_app_for_appsetting(const char *app_id)
 
        /* for each appsetting put rule: "appsetting_id app_id rx"*/
        for (i = 0; i < smack_label_list_len; ++i) {
-               SECURE_LOGD("Appsetting: app_add_rule (%s, %s rx)", smack_label_list[i], app_id);
+
+               SECURE_SLOGD("Appsetting: app_add_rule (%s, %s rx)", smack_label_list[i], app_id);
                if (strcmp(app_id, smack_label_list[i])==0) {
-                       SECURE_LOGW("Trying to add setting rule for self. Skipping");
+                       SECURE_SLOGW("Trying to add setting rule for self. Skipping");
                        continue;
                }
-
                ret = app_add_rule(smack_label_list[i], app_id, "rx");
                if (ret != PC_OPERATION_SUCCESS) {
                        C_LOGE("app_add_rule failed");
@@ -1210,7 +1210,7 @@ static int register_app_for_public_dirs(const char *app_id, struct smack_accesse
        }
 
        for (i = 0; i < public_dirs_cnt; ++i) {
-               SECURE_LOGD("Allowing app %s to access public path %s", app_id, public_dirs[i]);
+               SECURE_SLOGD("Allowing app %s to access public path %s", app_id, public_dirs[i]);
                if (smack_accesses_add_modify(smack, app_id, public_dirs[i], "rx", "")) {
                        C_LOGE("app_add_rule_modify failed");
                        while (i < public_dirs_cnt)
@@ -1258,7 +1258,7 @@ static int app_add_permissions_internal(const char* app_id, app_type_t app_type,
        /* Implicitly enable base permission for an app_type */
        base_perm = app_type_name(app_type);
        if (base_perm) {
-               SECURE_LOGD("perm_to_smack params: app_id: %s, %s", app_id, base_perm);
+               SECURE_SLOGD("perm_to_smack params: app_id: %s, %s", app_id, base_perm);
                ret = perm_to_smack(smack, app_id, APP_TYPE_OTHER, base_perm);
                if (ret != PC_OPERATION_SUCCESS){
                        C_LOGE("perm_to_smack failed");
@@ -1266,7 +1266,7 @@ static int app_add_permissions_internal(const char* app_id, app_type_t app_type,
                }
 
                // Add early permission - such permissions should be enabled right after system boot
-               SECURE_LOGD("perm_to_smack params: app_id: %s, %s", app_id, base_perm);
+               SECURE_SLOGD("perm_to_smack params: app_id: %s, %s", app_id, base_perm);
                ret = perm_to_smack_early(smack_early, app_id, APP_TYPE_OTHER, base_perm);
                if (ret != PC_OPERATION_SUCCESS){
                        C_LOGE("perm_to_smack failed");
@@ -1275,7 +1275,7 @@ static int app_add_permissions_internal(const char* app_id, app_type_t app_type,
 
        }
        for (i = 0; perm_list[i] != NULL; ++i) {
-               SECURE_LOGD("perm_to_smack params: app_id: %s, perm_list[%d]: %s", app_id, i, perm_list[i]);
+               SECURE_SLOGD("perm_to_smack params: app_id: %s, perm_list[%d]: %s", app_id, i, perm_list[i]);
                if (strcmp(perm_list[i], TIZEN_PRIVILEGE_ANTIVIRUS) == 0) {
                        ret = app_register_av_internal(app_id, smack);
                        if (ret != PC_OPERATION_SUCCESS) {
@@ -1775,7 +1775,7 @@ static int perm_app_setup_path_internal(const char* pkg_id, const char* path, ap
        }
 
        if (!smack_label_is_valid(pkg_id)) {
-               C_LOGE("Invalid app_id %s", pkg_id);
+               SECURE_SLOGE("Invalid app_id %s", pkg_id);
                return PC_ERR_INVALID_PARAM;
        }
 
@@ -1834,7 +1834,7 @@ static int perm_app_setup_path_internal(const char* pkg_id, const char* path, ap
                        return ret;
 
                for (i = 0; i < app_ids_cnt; ++i) {
-                       SECURE_LOGD("Allowing app %s to access public path %s", app_ids[i], path);
+                       SECURE_SLOGD("Allowing app %s to access public path %s", app_ids[i], path);
                        ret = app_add_rule(app_ids[i], label, "rx");
                        if (ret != PC_OPERATION_SUCCESS) {
                                C_LOGE("smack_accesses_new failed");
@@ -1997,25 +1997,25 @@ API int perm_app_install(const char* pkg_id)
 
        ret = add_app_id_to_databse(pkg_id);
        if (ret != PC_OPERATION_SUCCESS ) {
-               SECURE_LOGE("Error while adding app %s to database: %s ", pkg_id, strerror(errno));
+               SECURE_SLOGE("Error while adding app %s to database: %s ", pkg_id, strerror(errno));
                return ret;
        }
 
        ret = register_app_for_av(pkg_id);
        if (ret != PC_OPERATION_SUCCESS) {
-               SECURE_LOGE("Error while adding rules for anti viruses to app %s: %s ", pkg_id, strerror(errno));
+               SECURE_SLOGE("Error while adding rules for anti viruses to app %s: %s ", pkg_id, strerror(errno));
                return ret;
        }
 
        ret = register_app_for_appsetting(pkg_id);
        if (ret != PC_OPERATION_SUCCESS) {
-               SECURE_LOGE("Error while adding rules for setting managers to app %s: %s ", pkg_id, strerror(errno));
+               SECURE_SLOGE("Error while adding rules for setting managers to app %s: %s ", pkg_id, strerror(errno));
                return ret;
        }
 
        ret = register_app_for_public_dirs(pkg_id, smack);
        if (ret != PC_OPERATION_SUCCESS) {
-               SECURE_LOGE("Error while adding rules for access to public dirs for app %s: %s ", pkg_id, strerror(errno));
+               SECURE_SLOGE("Error while adding rules for access to public dirs for app %s: %s ", pkg_id, strerror(errno));
                return ret;
        }
 
index 6eba310..d8147de 100644 (file)
 
 // conditional log macro for dlogutil (debug)
 #ifdef DLOG_DEBUG_ENABLED
-#define C_LOGD(...) LOGD(__VA_ARGS__)
+#define C_LOGD(...) SLOGD(__VA_ARGS__)
 #else
 #define C_LOGD(...) do { } while(0)
 #endif //DLOG_DEBUG_ENABLED
 
 // conditional log macro for dlogutil (error)
 #ifdef DLOG_ERROR_ENABLED
-#define C_LOGE(...) LOGE(__VA_ARGS__)
+#define C_LOGE(...) SLOGE(__VA_ARGS__)
 #else
 #define C_LOGE(...) do { } while(0)
 #endif //DLOG_ERROR_ENABLED