summaryrefslogtreecommitdiff
path: root/src/nspawn/nspawn-setuid.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nspawn/nspawn-setuid.c')
-rw-r--r--src/nspawn/nspawn-setuid.c28
1 files changed, 4 insertions, 24 deletions
diff --git a/src/nspawn/nspawn-setuid.c b/src/nspawn/nspawn-setuid.c
index 2dee5f8ec8..44f5b17675 100644
--- a/src/nspawn/nspawn-setuid.c
+++ b/src/nspawn/nspawn-setuid.c
@@ -1,22 +1,4 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
-/***
- This file is part of systemd.
-
- Copyright 2015 Lennart Poettering
-
- systemd is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
#include <grp.h>
#include <sys/types.h>
@@ -226,8 +208,8 @@ int change_uid_gid(const char *user, char **_home) {
if (r < 0)
return log_error_errno(r, "Failed to make home root directory: %m");
- r = mkdir_safe(home, 0755, uid, gid, false);
- if (r < 0 && r != -EEXIST)
+ r = mkdir_safe(home, 0755, uid, gid, 0);
+ if (r < 0 && !IN_SET(r, -EEXIST, -ENOTDIR))
return log_error_errno(r, "Failed to make home directory: %m");
(void) fchown(STDIN_FILENO, uid, gid);
@@ -243,10 +225,8 @@ int change_uid_gid(const char *user, char **_home) {
if (setresuid(uid, uid, uid) < 0)
return log_error_errno(errno, "setresuid() failed: %m");
- if (_home) {
- *_home = home;
- home = NULL;
- }
+ if (_home)
+ *_home = TAKE_PTR(home);
return 0;
}