update-utmp.c revision 5430f7f2bc7330f3088b894166bf3524a067e3d8
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering This file is part of systemd.
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering Copyright 2010 Lennart Poettering
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering systemd is free software; you can redistribute it and/or modify it
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering under the terms of the GNU Lesser General Public License as published by
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering (at your option) any later version.
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering systemd is distributed in the hope that it will be useful, but
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering Lesser General Public License for more details.
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering You should have received a copy of the GNU Lesser General Public License
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poetteringtypedef struct Context {
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poetteringstatic usec_t get_startup_time(Context *c) {
usec_t t = 0;
assert(c);
if (!(m = dbus_message_new_method_call(
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
goto finish;
if (!dbus_message_append_args(m,
goto finish;
goto finish;
goto finish;
goto finish;
if (reply)
const int runlevel;
const char *special;
} table[] = {
assert(c);
if (!(m = dbus_message_new_method_call(
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
r = -ENOMEM;
goto finish;
if (!dbus_message_append_args(m,
r = -ENOMEM;
goto finish;
r = -EIO;
goto finish;
if (!(m = dbus_message_new_method_call(
"org.freedesktop.systemd1",
path,
r = -ENOMEM;
goto finish;
if (!dbus_message_append_args(m,
r = -ENOMEM;
goto finish;
r = -EIO;
goto finish;
r = -EIO;
goto finish;
r = -EIO;
goto finish;
if (reply)
usec_t t;
assert(c);
#ifdef HAVE_AUDIT
if (c->audit_fd >= 0)
r = -errno;
t = get_startup_time(c);
if ((q = utmp_put_reboot(t)) < 0) {
assert(c);
#ifdef HAVE_AUDIT
if (c->audit_fd >= 0)
r = -errno;
if ((q = utmp_put_shutdown()) < 0) {
assert(c);
r = on_reboot(c);
previous = 0;
return runlevel;
#ifdef HAVE_AUDIT
if (c->audit_fd >= 0) {
char *s = NULL;
return -ENOMEM;
r = -errno;
free(s);
Context c;
zero(c);
#ifdef HAVE_AUDIT
return EXIT_FAILURE;
return EXIT_FAILURE;
log_open();
#ifdef HAVE_AUDIT
r = -EIO;
goto finish;
r = on_reboot(&c);
r = on_shutdown(&c);
r = on_runlevel(&c);
r = -EINVAL;
#ifdef HAVE_AUDIT
if (c.audit_fd >= 0)
if (c.bus) {