Mount app legacy path as private explicitly 47/81247/1
authorSemun Lee <sm79.lee@samsung.com>
Mon, 25 Jul 2016 04:50:58 +0000 (13:50 +0900)
committerSemun Lee <sm79.lee@samsung.com>
Mon, 25 Jul 2016 04:50:58 +0000 (13:50 +0900)
Change-Id: Iba25fb8619d04b235a6bb421a9a9fa2c7f58b695
Signed-off-by: Semun Lee <sm79.lee@samsung.com>
src/launchpad_common.c

index a206e63..f6e314f 100644 (file)
@@ -814,6 +814,30 @@ int _close_all_fds(const int except)
        return 0;
 }
 
+static int __mount_and_make_private(const char *source, const char *target)
+{
+       int ret;
+
+       ret = mount(NULL, "/", NULL,
+                       MS_SLAVE | MS_REC, NULL);
+       if (ret != 0) {
+               _E("failed to set / as slave dir(%d)", ret);
+               return ret;
+       }
+
+       ret = mount(source, target,
+                       NULL, MS_BIND, NULL);
+       if (ret != 0) {
+               _E("failed to mount legacy dir(%d): %s to %s",
+                       ret, source, target);
+               return ret;
+       }
+
+       _D("end legacy path mount");
+
+       return ret;
+}
+
 int _mount_legacy_app_path(const char *app_root_path,
                        const char *pkgid)
 {
@@ -823,6 +847,8 @@ int _mount_legacy_app_path(const char *app_root_path,
        char user_app_data_path[PATH_MAX];
        char legacy_app_data_path[PATH_MAX];
 
+       _D("start legacy path mount");
+
        char *app_data_paths[5] = {
                "data",
                "cache",
@@ -841,8 +867,7 @@ int _mount_legacy_app_path(const char *app_root_path,
 
        /* for user private app */
        if (!strncmp(app_root_path, user_app_dir, strlen(user_app_dir))) {
-               return mount(app_root_path, legacy_app_path,
-                               NULL, MS_BIND, NULL);
+               return __mount_and_make_private(app_root_path, legacy_app_path);
        }
 
        /* for global app */
@@ -855,8 +880,8 @@ int _mount_legacy_app_path(const char *app_root_path,
 
                snprintf(legacy_app_data_path, PATH_MAX, "%s/%s",
                                legacy_app_path, app_data_paths[i]);
-               ret = mount(user_app_data_path, legacy_app_data_path,
-                               NULL, MS_BIND, NULL);
+               ret = __mount_and_make_private(user_app_data_path,
+                               legacy_app_data_path);
                if (ret != 0)
                        return ret;
        }