logind: change group and permission /run/user/%UID 90/171190/12 accepted/tizen/unified/20180307.071353 submit/tizen/20180307.004745
authorINSUN PYO <insun.pyo@samsung.com>
Tue, 27 Feb 2018 08:48:52 +0000 (17:48 +0900)
committerINSUN PYO <insun.pyo@samsung.com>
Wed, 7 Mar 2018 00:42:19 +0000 (09:42 +0900)
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/logind-user.c

index d7af761..15d0fed 100644 (file)
@@ -328,6 +328,32 @@ int user_load(User *u) {
         return r;
 }
 
+static int user_mkdir_system_share_path(User *u) {
+        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);
+        if (r < 0)
+                return r;
+
+        /* mount option "gid=system_share" doesn't work. So, we have to modify gid here*/
+        r = chmod_and_chown(u->runtime_path, 0750, u->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", u->uid);
+        if (r < 0)
+                return log_oom();
+
+        r = mkdir_safe_label(t, 0750, u->uid, system_share_gid);
+        if (r < 0)
+                return log_error_errno(r, "Failed to create '%s': %m", t);
+
+        return 0;
+}
+
 static int user_mkdir_runtime_path(User *u) {
         int r;
 
@@ -372,6 +398,10 @@ static int user_mkdir_runtime_path(User *u) {
                 r = label_fix(u->runtime_path, false, false);
                 if (r < 0)
                         log_warning_errno(r, "Failed to fix label of '%s', ignoring: %m", u->runtime_path);
+
+                r = user_mkdir_system_share_path(u);
+                if (r < 0)
+                        goto fail;
         }
 
         return 0;