From: Lennart Poettering Date: Fri, 14 Jul 2017 16:58:57 +0000 (+0200) Subject: execute: make some code shorter X-Git-Tag: v235~281^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=92a17af991c45b96e9fe2095028561f5baf6cab9;p=thirdparty%2Fsystemd.git execute: make some code shorter Let's simplify some lines to make it shorter. --- diff --git a/src/core/execute.c b/src/core/execute.c index f9580a25ad1..b76b9b9e6f7 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. */