Run filtered requests on global db if we are GLOBAL_USER 58/27258/4 accepted/tizen/common/20140909.100225 accepted/tizen/ivi/20140909.153726 submit/tizen/20140909.093454
authorManuel Bachmann <manuel.bachmann@open.eurogiciel.org>
Tue, 9 Sep 2014 08:35:04 +0000 (10:35 +0200)
committerManuel Bachmann <manuel.bachmann@open.eurogiciel.org>
Tue, 9 Sep 2014 09:26:54 +0000 (11:26 +0200)
We should automatically redirect calls from "ail_filter
_count_usr_appinfo()" to "ail_filter_count_appinfo()" if
the calling user is GLOBAL_USER (i.e. root). Filtered
requests will target the wrong DB, and fail otherwise.

Bug-Tizen: TC-1574

Change-Id: I774aa5f270cc6148639fcb6f449a7cb949f0fff8
Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
src/ail_filter.c

index 627cd2c..16256e8 100755 (executable)
@@ -278,15 +278,12 @@ EXPORT_API ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *cnt)
        }
        else
                _D("No filter exists. All records are retreived");
+
 //is_admin
-       if (db_prepare(q, &stmt) != AIL_ERROR_OK) {
-               _E("db_prepare fail for query = %s",q);
+       if (db_prepare_globalro(q, &stmt) != AIL_ERROR_OK) {
+               _E("db_prepare_globalro fail for query = %s",q);
                return AIL_ERROR_DB_FAILED;
        }
-/*     if (db_prepare(q, &stmt) != AIL_ERROR_OK) {
-               _E("db_prepare fail for query = %s",q);
-               return AIL_ERROR_DB_FAILED;
-       }*/
        ai = appinfo_create();
 
        appinfo_set_stmt(ai, stmt);
@@ -319,6 +316,10 @@ EXPORT_API ail_error_e ail_filter_count_usr_appinfo(ail_filter_h filter, int *cn
 
        retv_if(!cnt, AIL_ERROR_INVALID_PARAMETER);
 
+//is_admin ; redirect
+       if (uid == GLOBAL_USER)
+               return ail_filter_count_appinfo(filter, cnt);
+
        if (db_open(DB_OPEN_RO, uid) != AIL_ERROR_OK)
                return AIL_ERROR_DB_FAILED;