OSDN Git Service

jni: correct the database path
authorChih-Wei Huang <cwhuang@linux.org.tw>
Thu, 1 Feb 2018 14:52:52 +0000 (22:52 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Fri, 2 Feb 2018 02:14:23 +0000 (10:14 +0800)
It was moved to the device encrypted user data dir.

Superuser/jni/su/db.c
Superuser/jni/su/su.c
Superuser/jni/su/su.h

index 06ea4a5..6b5b2e5 100644 (file)
@@ -84,7 +84,7 @@ policy_t database_check(struct su_context *ctx) {
     snprintf(query, sizeof(query), "select policy, until, command from uid_policy where uid=%d", ctx->from.uid);
     int ret = sqlite3_open_v2(ctx->user.database_path, &db, SQLITE_OPEN_READONLY, NULL);
     if (ret) {
-        LOGE("sqlite3 open failure: %d", ret);
+        LOGE("sqlite3 open %s failure: %d", ctx->user.database_path, ret);
         sqlite3_close(db);
         return INTERACTIVE;
     }
index 058590a..9cfaa6f 100644 (file)
@@ -239,12 +239,10 @@ static void read_options(struct su_context *ctx) {
 }
 
 static void user_init(struct su_context *ctx) {
-    if (ctx->from.uid > 99999) {
+    if (ctx->user.multiuser_mode != MULTIUSER_MODE_NONE) {
         ctx->user.android_user_id = ctx->from.uid / 100000;
-        if (ctx->user.multiuser_mode == MULTIUSER_MODE_USER) {
-            snprintf(ctx->user.database_path, PATH_MAX, "%s/%d/%s", REQUESTOR_USER_PATH, ctx->user.android_user_id, REQUESTOR_DATABASE_PATH);
-            snprintf(ctx->user.base_path, PATH_MAX, "%s/%d/%s", REQUESTOR_USER_PATH, ctx->user.android_user_id, REQUESTOR);
-        }
+        snprintf(ctx->user.database_path, PATH_MAX, "%s/%d/%s", REQUESTOR_USER_PATH, ctx->user.android_user_id, REQUESTOR_DATABASE_PATH);
+        snprintf(ctx->user.base_path, PATH_MAX, "%s/%d/%s", REQUESTOR_USER_PATH, ctx->user.android_user_id, REQUESTOR);
     }
 }
 
index 070d7fa..253a1f2 100644 (file)
@@ -61,7 +61,7 @@
 #endif
 #define REQUESTOR_DATA_PATH "/data/data/"
 #define REQUESTOR_FILES_PATH REQUESTOR_DATA_PATH REQUESTOR "/files"
-#define REQUESTOR_USER_PATH "/data/user/"
+#define REQUESTOR_USER_PATH "/data/user_de"
 #define REQUESTOR_CACHE_PATH "/dev/" REQUESTOR
 #define REQUESTOR_DAEMON_PATH REQUESTOR_CACHE_PATH ".daemon"