Accept legacy app path to keep backwards compatibility 71/225171/1
authorSeonah Moon <seonah1.moon@samsung.com>
Tue, 18 Feb 2020 03:49:21 +0000 (12:49 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Tue, 18 Feb 2020 03:51:11 +0000 (12:51 +0900)
Change-Id: I6164dd62f8a2c0a55732539a0bd5a73eb772d051
Signed-off-by: Seonah Moon <seonah1.moon@samsung.com>
provider/download-provider-security.c

index 8902008..332080a 100644 (file)
@@ -40,6 +40,7 @@
 #define MAX_ARRAY_LEN 1024
 #define SECURITY_ATTRIBUTES_PATH "/proc/%d/attr/current"
 #define TEMP_DIR "/tmp/"
+#define LEGACY_USER_APP "/opt/usr/apps/"
 
 static int dp_is_exist_dir(const char *dirpath)
 {
@@ -209,9 +210,16 @@ int dp_is_valid_dir(dp_credential cred, const char *dirpath)
        }
 
        // Check permission: private storage
-       temp = tzplatform_getenv(TZ_USER_APP);
-       if (temp) {
+       if (strncmp(resolved_path, LEGACY_USER_APP, strlen(LEGACY_USER_APP)) == 0) {
+               // Some applications use a legacy app path.
+               snprintf(apps_storage, PATH_MAX - 1, "%s", LEGACY_USER_APP);
+       } else {
+               temp = tzplatform_getenv(TZ_USER_APP);
                snprintf(apps_storage, PATH_MAX - 1, "%s/", temp);
+               temp = NULL;
+       }
+
+       if (strlen(apps_storage) > 0) {
                if (strncmp(resolved_path, apps_storage,
                                        strlen(apps_storage)) == 0) {
                        pkg_id = _dp_get_pkg_id(cred);
@@ -228,7 +236,6 @@ int dp_is_valid_dir(dp_credential cred, const char *dirpath)
                        free(pkg_id);
                        return DP_ERROR_NONE;
                }
-               temp = NULL;
        }
 
        // Check whether directory is shared directory or not.