]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/shared/utmp-wtmp.c
tree-wide: drop license boilerplate
[thirdparty/systemd.git] / src / shared / utmp-wtmp.c
index 13b32a0509b5b6ee33cddc1faae131e87022e993..314488ab8f2e14d141c8fded87a100de4502f7b9 100644 (file)
@@ -1,28 +1,18 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
   Copyright 2010 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 <errno.h>
 #include <fcntl.h>
 #include <poll.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
+#include <sys/time.h>
 #include <sys/utsname.h>
 #include <unistd.h>
 #include <utmpx.h>
@@ -34,7 +24,9 @@
 #include "path-util.h"
 #include "string-util.h"
 #include "terminal-util.h"
+#include "time-util.h"
 #include "user-util.h"
+#include "util.h"
 #include "utmp-wtmp.h"
 
 int utmp_get_runlevel(int *runlevel, int *previous) {
@@ -230,7 +222,7 @@ int utmp_put_init_process(const char *id, pid_t pid, pid_t sid, const char *line
         if (r < 0)
                 return r;
 
-        if (ut_type == LOGIN_PROCESS || ut_type == USER_PROCESS) {
+        if (IN_SET(ut_type, LOGIN_PROCESS, USER_PROCESS)) {
                 store.ut_type = LOGIN_PROCESS;
                 r = write_entry_both(&store);
                 if (r < 0)
@@ -325,7 +317,7 @@ static int write_to_terminal(const char *tty, const char *message) {
         assert(tty);
         assert(message);
 
-        fd = open(tty, O_WRONLY|O_NDELAY|O_NOCTTY|O_CLOEXEC);
+        fd = open(tty, O_WRONLY|O_NONBLOCK|O_NOCTTY|O_CLOEXEC);
         if (fd < 0 || !isatty(fd))
                 return -errno;
 
@@ -420,7 +412,7 @@ int utmp_wall(
                 if (u->ut_type != USER_PROCESS || u->ut_user[0] == 0)
                         continue;
 
-                /* this access is fine, because strlen("/dev/") << 32 (UT_LINESIZE) */
+                /* this access is fine, because STRLEN("/dev/") << 32 (UT_LINESIZE) */
                 if (path_startswith(u->ut_line, "/dev/"))
                         path = u->ut_line;
                 else {