tizen: logind: change group and permission /run/user/%UID
authorINSUN PYO <insun.pyo@samsung.com>
Tue, 27 Feb 2018 08:48:52 +0000 (17:48 +0900)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Wed, 17 Jul 2024 14:10:51 +0000 (16:10 +0200)
1. change group and pemission of /run/usre/%UID to uid/system_share,0750
2. make /run/user/%UID/system_share to uid/system_share,0750

Signed-off-by: INSUN PYO <insun.pyo@samsung.com>
Change-Id: Ie22b8d4e96c1669f7068005952d83f7f4086b60c
Signed-off-by: INSUN PYO <insun.pyo@samsung.com>
src/login/user-runtime-dir.c

index ed8a80e..eaf5a25 100644 (file)
@@ -49,6 +49,32 @@ static int acquire_runtime_dir_properties(uint64_t *size, uint64_t *inodes) {
         return 0;
 }
 
+static int user_mkdir_system_share_path(const char *runtime_path, uid_t uid) {
+        int r;
+        gid_t system_share_gid;
+        _cleanup_free_ char *t = NULL;
+        const char *system_share_group = "system_share";
+
+        r = get_group_creds(&system_share_group, &system_share_gid, 0);
+        if (r < 0)
+                return r;
+
+        /* mount option "gid=system_share" doesn't work. So, we have to modify gid here*/
+        r = chmod_and_chown(runtime_path, 0750, uid, system_share_gid);
+        if (r < 0)
+                return log_error_errno(r, "Failed to change runtime directory ownership and mode: %m");
+
+        r = asprintf(&t, "/run/user/"UID_FMT"/system_share", uid);
+        if (r < 0)
+                return log_oom();
+
+        r = mkdir_safe_label(t, 0750, uid, system_share_gid, MKDIR_WARN_MODE);
+        if (r < 0)
+                return log_error_errno(r, "Failed to create '%s': %m", t);
+
+        return 0;
+}
+
 static int user_mkdir_runtime_path(
                 const char *runtime_path,
                 uid_t uid,
@@ -106,6 +132,10 @@ static int user_mkdir_runtime_path(
                 r = label_fix(runtime_path, 0);
                 if (r < 0)
                         log_warning_errno(r, "Failed to fix label of \"%s\", ignoring: %m", runtime_path);
+
+                r = user_mkdir_system_share_path(runtime_path, uid);
+                if (r < 0)
+                        goto fail;
         }
 
         return 0;