//#include "util.h"
#include "utmp-wtmp.h"
-/// includes needed by elogind:
+/// Additional includes needed by elogind
#include "string-util.h"
#include "time-util.h"
#include "update-utmp.h"
-
-
typedef struct Context {
sd_bus *bus;
#ifdef HAVE_AUDIT
#endif
} Context;
+#if 0 /// UNNEEDED by elogind
static usec_t get_startup_time(Context *c) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
usec_t t = 0;
return t;
}
-#if 0 /// UNNEEDED by elogind
static int get_current_runlevel(Context *c) {
static const struct {
const int runlevel;
if (r < 0)
return log_warning_errno(r, "Failed to get state: %s", bus_error_message(&error, r));
- if (streq(state, "active") || streq(state, "reloading"))
+ if (STR_IN_SET(state, "active", "reloading"))
return table[i].runlevel;
}
}
#endif
+#if 0 /// systemd hasn't started the system, so elogind always uses NOW()
/* If this call fails it will return 0, which
* utmp_put_reboot() will then fix to the current time */
t = get_startup_time(c);
+#else
+ t = now(CLOCK_REALTIME);
+#endif // 0
q = utmp_put_reboot(t);
if (q < 0) {
if (c.audit_fd < 0 && errno != EAFNOSUPPORT && errno != EPROTONOSUPPORT)
log_error_errno(errno, "Failed to connect to audit log: %m");
#endif
-
#if 0 /// UNNEEDED by elogind
r = bus_connect_system_systemd(&c.bus);
if (r < 0) {
else if (streq(argv[1], "shutdown"))
(void)on_shutdown(&c);
#endif // 0
-
#ifdef HAVE_AUDIT
if (c.audit_fd >= 0)
audit_close(c.audit_fd);
#endif
sd_bus_flush_close_unref(c.bus);
-
#if 0 /// UNNEEDED by elogind
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
#endif // 0