summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-07-14 18:58:57 +0200
committerLennart Poettering <lennart@poettering.net>2017-07-31 18:01:42 +0200
commit92a17af991c45b96e9fe2095028561f5baf6cab9 (patch)
treebf1a77798053731977b7c0896c5c30970d2ac521
parent54191eb3e74a8fa8bdd049471e630541c65e4f25 (diff)
downloadsystemd-92a17af991c45b96e9fe2095028561f5baf6cab9.tar.gz
execute: make some code shorter
Let's simplify some lines to make it shorter.
-rw-r--r--src/core/execute.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/core/execute.c b/src/core/execute.c
index f9580a25ad..b76b9b9e6f 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -278,7 +278,7 @@ static int open_null_as(int flags, int nfd) {
}
static int connect_journal_socket(int fd, uid_t uid, gid_t gid) {
- union sockaddr_union sa = {
+ static const union sockaddr_union sa = {
.un.sun_family = AF_UNIX,
.un.sun_path = "/run/systemd/journal/stdout",
};
@@ -289,24 +289,20 @@ static int connect_journal_socket(int fd, uid_t uid, gid_t gid) {
if (gid_is_valid(gid)) {
oldgid = getgid();
- r = setegid(gid);
- if (r < 0)
+ if (setegid(gid) < 0)
return -errno;
}
if (uid_is_valid(uid)) {
olduid = getuid();
- r = seteuid(uid);
- if (r < 0) {
+ if (seteuid(uid) < 0) {
r = -errno;
goto restore_gid;
}
}
- r = connect(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un));
- if (r < 0)
- r = -errno;
+ r = connect(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0 ? -errno : 0;
/* If we fail to restore the uid or gid, things will likely
fail later on. This should only happen if an LSM interferes. */