logind: simplify one conditional
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 7 Dec 2017 11:57:31 +0000 (12:57 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 15 Dec 2017 13:57:07 +0000 (14:57 +0100)
Don't bother with removing the directory if we didn't create it.

src/login/logind-user.c

index 94e250b..f17bc26 100644 (file)
@@ -344,16 +344,13 @@ static int user_mkdir_runtime_path(User *u) {
         if (path_is_mount_point(u->runtime_path, NULL, 0) <= 0) {
                 _cleanup_free_ char *t = NULL;
 
-                (void) mkdir_label(u->runtime_path, 0700);
+                r = asprintf(&t, "mode=0700,uid=" UID_FMT ",gid=" GID_FMT ",size=%zu%s",
+                             u->uid, u->gid, u->manager->runtime_dir_size,
+                             mac_smack_use() ? ",smackfsroot=*" : "");
+                if (r < 0)
+                        return log_oom();
 
-                if (mac_smack_use())
-                        r = asprintf(&t, "mode=0700,smackfsroot=*,uid=" UID_FMT ",gid=" GID_FMT ",size=%zu", u->uid, u->gid, u->manager->runtime_dir_size);
-                else
-                        r = asprintf(&t, "mode=0700,uid=" UID_FMT ",gid=" GID_FMT ",size=%zu", u->uid, u->gid, u->manager->runtime_dir_size);
-                if (r < 0) {
-                        r = log_oom();
-                        goto fail;
-                }
+                (void) mkdir_label(u->runtime_path, 0700);
 
                 r = mount("tmpfs", u->runtime_path, "tmpfs", MS_NODEV|MS_NOSUID, t);
                 if (r < 0) {