Add to mount lib directory for rpk 13/311913/2
authorSangyoon Jang <jeremy.jang@samsung.com>
Thu, 30 May 2024 07:49:31 +0000 (16:49 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Fri, 31 May 2024 00:29:28 +0000 (09:29 +0900)
- The RPK supports Libs sharing. Libs are packaged in /lib directory in
rpk package. And then it's mounted to user package's /lib directory path.

Change-Id: Ie7fc4b118eb293d995a507f104a1c4be55430867
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/launchpad-process-pool/src/launchpad.c
src/launchpad-process-pool/src/loader_mount.c
src/lib/common/inc/key.h
src/lib/common/inc/launchpad_common.h
src/lib/common/src/launchpad_common.c
src/lib/launchpad/src/launchpad_lib.c

index 9aa5baaa5756c09687f22ba42b08362378e849f4..f482496d521615ca242bcfe630957d38b2778218 100644 (file)
@@ -1360,6 +1360,10 @@ static int __prepare_exec(const char *appid, const char *app_path,
        if (ret < 0)
                return PAD_ERR_FAILED;
 
+       ret = _mount_lib_dir(kb);
+       if (ret < 0)
+               return PAD_ERR_FAILED;
+
        if (bundle_get_type(kb, AUL_K_SDK) != BUNDLE_TYPE_NONE)
                _debug_change_mount_namespace();
 
index fd37e0d47e60fc2fd20f70000a52b6570ca1e44a..2dbf438d4fc51ce9bc94c16ad5abc171ae0d2e55 100644 (file)
@@ -254,7 +254,10 @@ static int __process_requests(void)
 
                ret = __change_mount_namespace(request->pid);
                if (ret == 0) {
-                       ret = _mount_gadget_dirs(request->b);
+                       if (bundle_get_type(request->b, AUL_K_MOUNT_GADGET_PATHS) != BUNDLE_TYPE_NONE)
+                               ret |= _mount_gadget_dirs(request->b);
+                       if (bundle_get_type(request->b, AUL_K_MOUNT_LIB_DIR) != BUNDLE_TYPE_NONE)
+                               ret |= _mount_lib_dir(request->b);
                        if (ret != 0)
                                _E("Failed to mount gadget paths");
 
@@ -393,7 +396,8 @@ int _loader_mount_mount(pid_t pid, bundle *kb)
        if (kb == NULL)
                return -EINVAL;
 
-       if (bundle_get_type(kb, AUL_K_MOUNT_GADGET_PATHS) == BUNDLE_TYPE_NONE)
+       if (bundle_get_type(kb, AUL_K_MOUNT_GADGET_PATHS) == BUNDLE_TYPE_NONE &&
+                       bundle_get_type(kb, AUL_K_MOUNT_LIB_DIR) == BUNDLE_TYPE_NONE)
                return 0;
 
        request = __request_create(pid, kb);
index 3b7f5b95ea958bd8a802133a7b1f933bdbf97330..2971db9ab993244d8b12f2756d5196a7bd3b1196 100644 (file)
@@ -54,6 +54,7 @@ extern "C" {
 #define AUL_K_ENABLED_LIGHT_USER       "__AUL_ENABLED_LIGHT_USER__"
 #define AUL_K_MOUNT_GADGET_PATHS        "__AUL_MOUNT_GADGET_PATHS__"
 #define AUL_K_MOUNT_GADGET_PKGIDS       "__AUL_MOUNT_GADGET_PKGIDS__"
+#define AUL_K_MOUNT_LIB_DIR            "__AUL_MOUNT_LIB_DIR__"
 
 
 #ifdef __cplusplus
index 5420a07f3c93f405dce67b053a92d3346847324d..c41f067489f55ba5caa7ae8102e0b93b619ecc7d 100644 (file)
@@ -138,6 +138,7 @@ int _verify_proc_caps(void);
 int _prepare_id_file(void);
 void _print_hwc_log(const char *format, ...);
 int _mount_res_dir(const char *menu_info, bundle *kb);
+int _mount_lib_dir(bundle *kb);
 int _mount_gadget_dirs(bundle *kb);
 int _close_fds(int *except_fds, int len);
 
@@ -145,4 +146,3 @@ int _close_fds(int *except_fds, int len);
 }
 #endif
 #endif /* __LAUNCHPAD_COMMON_H__ */
-
index 725eb426f20a1ed3b4ddfeba45824683df6bb29b..a389c96dfd52ba8cca6fdfea125220e2bffe7565 100644 (file)
@@ -1683,6 +1683,29 @@ int _mount_gadget_dirs(bundle *kb)
   return 0;
 }
 
+int _mount_lib_dir(bundle *kb)
+{
+       const char *root_path;
+       const char **val;
+       int len;
+       char dest[PATH_MAX];
+
+       root_path = bundle_get_val(kb, AUL_K_ROOT_PATH);
+       if (!root_path)
+               return -1;
+
+       val = bundle_get_str_array(kb, AUL_K_MOUNT_LIB_DIR, &len);
+       if (val) {
+               snprintf(dest, sizeof(dest), "%s/lib", root_path);
+               __mount_dir(val, len, dest);
+       } else if (get_last_result() != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
+               _E("invalid mount info");
+               return -1;
+       }
+
+       return 0;
+}
+
 static bool __is_exceptable(int *except_fds, int len, int fd)
 {
        int i = 0;
index b107ed4abed7393e797658ba79e65ba5e8279f27..fb69775057aeeb2a21999a3af84a6ea3f5b41167 100644 (file)
@@ -111,6 +111,10 @@ static int __prepare_exec(const char *appid, const char *app_path,
                ret = _mount_gadget_dirs(kb);
                if (ret < 0)
                        return -1;
+
+               ret = _mount_lib_dir(kb);
+               if (ret < 0)
+                       return -1;
        }
 
        ret = _mount_res_dir(root_path, kb);