chiark / gitweb /
Prep v228: Removed utmp bits. elogind does not support utmp-wtmp.
authorSven Eden <yamakuzure@gmx.net>
Mon, 10 Apr 2017 09:57:04 +0000 (11:57 +0200)
committerSven Eden <yamakuzure@gmx.net>
Wed, 26 Apr 2017 10:59:13 +0000 (12:59 +0200)
Makefile.am
cb/elogind.cbp
src/basic/memfd-util.c
src/login/logind-dbus.c
src/login/logind-utmp.c [deleted file]
src/login/logind.h
src/shared/utmp-wtmp.h [deleted file]

index 840e8f3a1d54ccd7d180929aa1de584033a6fd80..c36d718dd0fa233e44e39a9d4fcc08e1194476e1 100644 (file)
@@ -446,7 +446,6 @@ libshared_la_SOURCES = \
        src/shared/spawn-polkit-agent.h \
        src/shared/clean-ipc.c \
        src/shared/clean-ipc.h \
        src/shared/spawn-polkit-agent.h \
        src/shared/clean-ipc.c \
        src/shared/clean-ipc.h \
-       src/shared/utmp-wtmp.h \
        src/shared/bus-util.c \
        src/shared/bus-util.h
 
        src/shared/bus-util.c \
        src/shared/bus-util.h
 
@@ -660,7 +659,6 @@ libelogind_core_la_SOURCES = \
        src/login/logind-session-dbus.c \
        src/login/logind-seat-dbus.c \
        src/login/logind-user-dbus.c \
        src/login/logind-session-dbus.c \
        src/login/logind-seat-dbus.c \
        src/login/logind-user-dbus.c \
-       src/login/logind-utmp.c \
        src/login/logind-acl.h \
        src/core/cgroup.h \
        src/core/cgroup.c \
        src/login/logind-acl.h \
        src/core/cgroup.h \
        src/core/cgroup.c \
index a0861754f15d4776cf9091e753825f7c451f253e..4ccb9d3c22f235fb0a4f87826603ea9188aecc6a 100644 (file)
                        <Option compilerVar="CC" />
                </Unit>
                <Unit filename="../src/login/logind-user.h" />
                        <Option compilerVar="CC" />
                </Unit>
                <Unit filename="../src/login/logind-user.h" />
-               <Unit filename="../src/login/logind-utmp.c">
-                       <Option compilerVar="CC" />
-               </Unit>
                <Unit filename="../src/login/logind.c">
                        <Option compilerVar="CC" />
                </Unit>
                <Unit filename="../src/login/logind.c">
                        <Option compilerVar="CC" />
                </Unit>
                <Unit filename="../src/shared/spawn-polkit-agent.h" />
                <Unit filename="../src/shared/test-tables.h" />
                <Unit filename="../src/shared/udev-util.h" />
                <Unit filename="../src/shared/spawn-polkit-agent.h" />
                <Unit filename="../src/shared/test-tables.h" />
                <Unit filename="../src/shared/udev-util.h" />
-               <Unit filename="../src/shared/utmp-wtmp.h" />
                <Unit filename="../src/systemd/_sd-common.h" />
                <Unit filename="../src/systemd/sd-bus-protocol.h" />
                <Unit filename="../src/systemd/sd-bus-vtable.h" />
                <Unit filename="../src/systemd/_sd-common.h" />
                <Unit filename="../src/systemd/sd-bus-protocol.h" />
                <Unit filename="../src/systemd/sd-bus-vtable.h" />
index e6eb1d45fc5d2f46a5c16582213d2c41178c63fa..a103a6fae0535601e8b3ab5db027f22c4f5b5e82 100644 (file)
@@ -125,8 +125,6 @@ int memfd_get_sealed(int fd) {
         return r == (F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_WRITE | F_SEAL_SEAL);
 }
 
         return r == (F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_WRITE | F_SEAL_SEAL);
 }
 
-/// UNNEEDED by elogind
-#if 0
 int memfd_get_size(int fd, uint64_t *sz) {
         struct stat stat;
         int r;
 int memfd_get_size(int fd, uint64_t *sz) {
         struct stat stat;
         int r;
index 0c25d1f6f13dc70286cfb76c438eb13a55d2c271..ab9c5728eeefde0f86b66ed5d57428b652cec6b8 100644 (file)
@@ -50,7 +50,7 @@
 #include "udev-util.h"
 #include "unit-name.h"
 #include "user-util.h"
 #include "udev-util.h"
 #include "unit-name.h"
 #include "user-util.h"
-#include "utmp-wtmp.h"
+//#include "utmp-wtmp.h"
 
 int manager_get_session_from_creds(Manager *m, sd_bus_message *message, const char *name, sd_bus_error *error, Session **ret) {
         _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
 
 int manager_get_session_from_creds(Manager *m, sd_bus_message *message, const char *name, sd_bus_error *error, Session **ret) {
         _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
@@ -2052,9 +2052,12 @@ static int method_schedule_shutdown(sd_bus_message *message, void *userdata, sd_
                 }
         }
 
                 }
         }
 
+/// elogind does not support utmp-wtmp
+#if 0
         r = manager_setup_wall_message_timer(m);
         if (r < 0)
                 return r;
         r = manager_setup_wall_message_timer(m);
         if (r < 0)
                 return r;
+#endif // 0
 
         if (!isempty(type)) {
                 r = update_schedule_file(m);
 
         if (!isempty(type)) {
                 r = update_schedule_file(m);
@@ -2076,6 +2079,8 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd
         cancelled = m->scheduled_shutdown_type != NULL;
         reset_scheduled_shutdown(m);
 
         cancelled = m->scheduled_shutdown_type != NULL;
         reset_scheduled_shutdown(m);
 
+/// elogind does not support utmp-wtmp
+#if 0
         if (cancelled) {
                 _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
                 const char *tty = NULL;
         if (cancelled) {
                 _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
                 const char *tty = NULL;
@@ -2091,6 +2096,7 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd
                 utmp_wall("The system shutdown has been cancelled",
                           uid_to_name(uid), tty, logind_wall_tty_filter, m);
         }
                 utmp_wall("The system shutdown has been cancelled",
                           uid_to_name(uid), tty, logind_wall_tty_filter, m);
         }
+#endif // 0
 
         return sd_bus_reply_method_return(message, "b", cancelled);
 }
 
         return sd_bus_reply_method_return(message, "b", cancelled);
 }
diff --git a/src/login/logind-utmp.c b/src/login/logind-utmp.c
deleted file mode 100644 (file)
index 8c2bfb0..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2015 Daniel Mack
-
-  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 <pwd.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "sd-messages.h"
-
-#include "alloc-util.h"
-#include "audit-util.h"
-#include "bus-common-errors.h"
-#include "bus-error.h"
-#include "bus-util.h"
-#include "formats-util.h"
-#include "logind.h"
-//#include "special.h"
-#include "strv.h"
-#include "unit-name.h"
-#include "user-util.h"
-#include "utmp-wtmp.h"
-
-_const_ static usec_t when_wall(usec_t n, usec_t elapse) {
-
-        usec_t left;
-        unsigned int i;
-        static const int wall_timers[] = {
-                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
-                25, 40, 55, 70, 100, 130, 150, 180,
-        };
-
-        /* If the time is already passed, then don't announce */
-        if (n >= elapse)
-                return 0;
-
-        left = elapse - n;
-
-        for (i = 1; i < ELEMENTSOF(wall_timers); i++)
-                if (wall_timers[i] * USEC_PER_MINUTE >= left)
-                        return left - wall_timers[i-1] * USEC_PER_MINUTE;
-
-        return left % USEC_PER_HOUR;
-}
-
-bool logind_wall_tty_filter(const char *tty, void *userdata) {
-
-        Manager *m = userdata;
-
-        assert(m);
-
-        if (!startswith(tty, "/dev/"))
-                return true;
-
-        return !streq(tty + 5, m->scheduled_shutdown_tty);
-}
-
-static int warn_wall(Manager *m, usec_t n) {
-        char date[FORMAT_TIMESTAMP_MAX] = {};
-        _cleanup_free_ char *l = NULL;
-        usec_t left;
-        int r;
-
-        assert(m);
-
-        if (!m->enable_wall_messages)
-                return 0;
-
-        left = m->scheduled_shutdown_timeout > n;
-
-        r = asprintf(&l, "%s%sThe system is going down for %s %s%s!",
-                     strempty(m->wall_message),
-                     isempty(m->wall_message) ? "" : "\n",
-                     m->scheduled_shutdown_type,
-                     left ? "at " : "NOW",
-                     left ? format_timestamp(date, sizeof(date), m->scheduled_shutdown_timeout) : "");
-        if (r < 0) {
-                log_oom();
-                return 0;
-        }
-
-        utmp_wall(l, uid_to_name(m->scheduled_shutdown_uid),
-                  m->scheduled_shutdown_tty, logind_wall_tty_filter, m);
-
-        return 1;
-}
-
-static int wall_message_timeout_handler(
-                        sd_event_source *s,
-                        uint64_t usec,
-                        void *userdata) {
-
-        Manager *m = userdata;
-        usec_t n, next;
-        int r;
-
-        assert(m);
-        assert(s == m->wall_message_timeout_source);
-
-        n = now(CLOCK_REALTIME);
-
-        r = warn_wall(m, n);
-        if (r == 0)
-                return 0;
-
-        next = when_wall(n, m->scheduled_shutdown_timeout);
-        if (next > 0) {
-                r = sd_event_source_set_time(s, n + next);
-                if (r < 0)
-                        return log_error_errno(r, "sd_event_source_set_time() failed. %m");
-
-                r = sd_event_source_set_enabled(s, SD_EVENT_ONESHOT);
-                if (r < 0)
-                        return log_error_errno(r, "sd_event_source_set_enabled() failed. %m");
-        }
-
-        return 0;
-}
-
-int manager_setup_wall_message_timer(Manager *m) {
-
-        usec_t n, elapse;
-        int r;
-
-        assert(m);
-
-        n = now(CLOCK_REALTIME);
-        elapse = m->scheduled_shutdown_timeout;
-
-        /* wall message handling */
-
-        if (isempty(m->scheduled_shutdown_type)) {
-                warn_wall(m, n);
-                return 0;
-        }
-
-        if (elapse < n)
-                return 0;
-
-        /* Warn immediately if less than 15 minutes are left */
-        if (elapse - n < 15 * USEC_PER_MINUTE) {
-                r = warn_wall(m, n);
-                if (r == 0)
-                        return 0;
-        }
-
-        elapse = when_wall(n, elapse);
-        if (elapse == 0)
-                return 0;
-
-        if (m->wall_message_timeout_source) {
-                r = sd_event_source_set_time(m->wall_message_timeout_source, n + elapse);
-                if (r < 0)
-                        return log_error_errno(r, "sd_event_source_set_time() failed. %m");
-
-                r = sd_event_source_set_enabled(m->wall_message_timeout_source, SD_EVENT_ONESHOT);
-                if (r < 0)
-                        return log_error_errno(r, "sd_event_source_set_enabled() failed. %m");
-        } else {
-                r = sd_event_add_time(m->event, &m->wall_message_timeout_source,
-                                      CLOCK_REALTIME, n + elapse, 0, wall_message_timeout_handler, m);
-                if (r < 0)
-                        return log_error_errno(r, "sd_event_add_time() failed. %m");
-        }
-
-        return 0;
-}
index b57e8d0a2ebe439dece54cd129008ea92b4e4632..c4bfd92cff415c1beb00052dfe426907e1eb731c 100644 (file)
@@ -226,7 +226,7 @@ int manager_get_session_from_creds(Manager *m, sd_bus_message *message, const ch
 int manager_get_user_from_creds(Manager *m, sd_bus_message *message, uid_t uid, sd_bus_error *error, User **ret);
 int manager_get_seat_from_creds(Manager *m, sd_bus_message *message, const char *name, sd_bus_error *error, Seat **ret);
 
 int manager_get_user_from_creds(Manager *m, sd_bus_message *message, uid_t uid, sd_bus_error *error, User **ret);
 int manager_get_seat_from_creds(Manager *m, sd_bus_message *message, const char *name, sd_bus_error *error, Seat **ret);
 
-int manager_setup_wall_message_timer(Manager *m);
-bool logind_wall_tty_filter(const char *tty, void *userdata);
+// UNNEEDED int manager_setup_wall_message_timer(Manager *m);
+// UNNEEDED bool logind_wall_tty_filter(const char *tty, void *userdata);
 
 int manager_dispatch_delayed(Manager *manager, bool timeout);
 
 int manager_dispatch_delayed(Manager *manager, bool timeout);
diff --git a/src/shared/utmp-wtmp.h b/src/shared/utmp-wtmp.h
deleted file mode 100644 (file)
index e0ceb87..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
-  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 "util.h"
-
-#ifdef HAVE_UTMP
-int utmp_get_runlevel(int *runlevel, int *previous);
-
-int utmp_put_shutdown(void);
-int utmp_put_reboot(usec_t timestamp);
-int utmp_put_runlevel(int runlevel, int previous);
-
-int utmp_put_dead_process(const char *id, pid_t pid, int code, int status);
-int utmp_put_init_process(const char *id, pid_t pid, pid_t sid, const char *line, int ut_type, const char *user);
-
-int utmp_wall(
-        const char *message,
-        const char *username,
-        const char *origin_tty,
-        bool (*match_tty)(const char *tty, void *userdata),
-        void *userdata);
-
-#else /* HAVE_UTMP */
-
-static inline int utmp_get_runlevel(int *runlevel, int *previous) {
-        return -ESRCH;
-}
-static inline int utmp_put_shutdown(void) {
-        return 0;
-}
-static inline int utmp_put_reboot(usec_t timestamp) {
-        return 0;
-}
-static inline int utmp_put_runlevel(int runlevel, int previous) {
-        return 0;
-}
-static inline int utmp_put_dead_process(const char *id, pid_t pid, int code, int status) {
-        return 0;
-}
-static inline int utmp_put_init_process(const char *id, pid_t pid, pid_t sid, const char *line, int ut_type, const char *user) {
-        return 0;
-}
-static inline int utmp_wall(
-                const char *message,
-                const char *username,
-                const char *origin_tty,
-                bool (*match_tty)(const char *tty, void *userdata),
-                void *userdata) {
-        return 0;
-}
-
-#endif /* HAVE_UTMP */