chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
dbus: simplify some dbus error messages a bit
[elogind.git]
/
src
/
update-utmp.c
diff --git
a/src/update-utmp.c
b/src/update-utmp.c
index b8b0d36ae7536e8518c68d172f55b841c3476221..644b6df67cb831627b646f570359375d3b7539a3 100644
(file)
--- a/
src/update-utmp.c
+++ b/
src/update-utmp.c
@@
-1,4
+1,4
@@
-/*-*- Mode: C; c-basic-offset: 8 -*-*/
+/*-*- Mode: C; c-basic-offset: 8
; indent-tabs-mode: nil
-*-*/
/***
This file is part of systemd.
/***
This file is part of systemd.
@@
-22,12
+22,15
@@
#include <assert.h>
#include <errno.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <string.h>
-#include <libaudit.h>
#include <sys/types.h>
#include <unistd.h>
#include <dbus/dbus.h>
#include <sys/types.h>
#include <unistd.h>
#include <dbus/dbus.h>
+#ifdef HAVE_AUDIT
+#include <libaudit.h>
+#endif
+
#include "log.h"
#include "macro.h"
#include "util.h"
#include "log.h"
#include "macro.h"
#include "util.h"
@@
-74,7
+77,7
@@
static usec_t get_startup_time(Context *c) {
}
if (!(reply = dbus_connection_send_with_reply_and_block(c->bus, m, -1, &error))) {
}
if (!(reply = dbus_connection_send_with_reply_and_block(c->bus, m, -1, &error))) {
- log_error("Failed to send command: %s",
error.message
);
+ log_error("Failed to send command: %s",
bus_error_message(&error)
);
goto finish;
}
goto finish;
}
@@
-111,12
+114,15
@@
static int get_current_runlevel(Context *c) {
const char *special;
} table[] = {
/* The first target of this list that is active or has
const char *special;
} table[] = {
/* The first target of this list that is active or has
- * a job scheduled wins */
+ * a job scheduled wins. We prefer runlevels 5 and 3
+ * here over the others, since these are the main
+ * runlevels used on Fedora. It might make sense to
+ * change the order on some distributions. */
{ '5', SPECIAL_RUNLEVEL5_TARGET },
{ '5', SPECIAL_RUNLEVEL5_TARGET },
- { '4', SPECIAL_RUNLEVEL4_TARGET },
{ '3', SPECIAL_RUNLEVEL3_TARGET },
{ '3', SPECIAL_RUNLEVEL3_TARGET },
+ { '4', SPECIAL_RUNLEVEL4_TARGET },
{ '2', SPECIAL_RUNLEVEL2_TARGET },
{ '2', SPECIAL_RUNLEVEL2_TARGET },
- { '
1
', SPECIAL_RESCUE_TARGET },
+ { '
S
', SPECIAL_RESCUE_TARGET },
};
const char
*interface = "org.freedesktop.systemd1.Unit",
};
const char
*interface = "org.freedesktop.systemd1.Unit",
@@
-161,7
+167,7
@@
static int get_current_runlevel(Context *c) {
if (!dbus_message_get_args(reply, &error,
DBUS_TYPE_OBJECT_PATH, &path,
DBUS_TYPE_INVALID)) {
if (!dbus_message_get_args(reply, &error,
DBUS_TYPE_OBJECT_PATH, &path,
DBUS_TYPE_INVALID)) {
- log_error("Failed to parse reply: %s",
error.message
);
+ log_error("Failed to parse reply: %s",
bus_error_message(&error)
);
r = -EIO;
goto finish;
}
r = -EIO;
goto finish;
}
@@
-188,7
+194,7
@@
static int get_current_runlevel(Context *c) {
dbus_message_unref(reply);
if (!(reply = dbus_connection_send_with_reply_and_block(c->bus, m, -1, &error))) {
dbus_message_unref(reply);
if (!(reply = dbus_connection_send_with_reply_and_block(c->bus, m, -1, &error))) {
- log_error("Failed to send command: %s",
error.message
);
+ log_error("Failed to send command: %s",
bus_error_message(&error)
);
r = -EIO;
goto finish;
}
r = -EIO;
goto finish;
}
@@
-244,7
+250,7
@@
static int on_reboot(Context *c) {
#ifdef HAVE_AUDIT
if (c->audit_fd >= 0)
#ifdef HAVE_AUDIT
if (c->audit_fd >= 0)
- if (audit_log_user_message(c->audit_fd, AUDIT_SYSTEM_BOOT, "", NULL, NULL, NULL, 1) < 0) {
+ if (audit_log_user_message(c->audit_fd, AUDIT_SYSTEM_BOOT, "
init
", NULL, NULL, NULL, 1) < 0) {
log_error("Failed to send audit message: %m");
r = -errno;
}
log_error("Failed to send audit message: %m");
r = -errno;
}
@@
-272,7
+278,7
@@
static int on_shutdown(Context *c) {
#ifdef HAVE_AUDIT
if (c->audit_fd >= 0)
#ifdef HAVE_AUDIT
if (c->audit_fd >= 0)
- if (audit_log_user_message(c->audit_fd, AUDIT_SYSTEM_SHUTDOWN, "", NULL, NULL, NULL, 1) < 0) {
+ if (audit_log_user_message(c->audit_fd, AUDIT_SYSTEM_SHUTDOWN, "
init
", NULL, NULL, NULL, 1) < 0) {
log_error("Failed to send audit message: %m");
r = -errno;
}
log_error("Failed to send audit message: %m");
r = -errno;
}
@@
-308,7
+314,7
@@
static int on_runlevel(Context *c) {
previous = 0;
}
previous = 0;
}
- /* Second get new runlevel */
+ /* Second
ly,
get new runlevel */
if ((runlevel = get_current_runlevel(c)) < 0)
return runlevel;
if ((runlevel = get_current_runlevel(c)) < 0)
return runlevel;
@@
-365,6
+371,7
@@
int main(int argc, char *argv[]) {
log_set_target(LOG_TARGET_SYSLOG_OR_KMSG);
log_parse_environment();
log_set_target(LOG_TARGET_SYSLOG_OR_KMSG);
log_parse_environment();
+ log_open();
#ifdef HAVE_AUDIT
if ((c.audit_fd = audit_open()) < 0)
#ifdef HAVE_AUDIT
if ((c.audit_fd = audit_open()) < 0)
@@
-372,7
+379,7
@@
int main(int argc, char *argv[]) {
#endif
if (bus_connect(DBUS_BUS_SYSTEM, &c.bus, NULL, &error) < 0) {
#endif
if (bus_connect(DBUS_BUS_SYSTEM, &c.bus, NULL, &error) < 0) {
- log_error("Failed to get D-Bus connection: %s",
error.message
);
+ log_error("Failed to get D-Bus connection: %s",
bus_error_message(&error)
);
r = -EIO;
goto finish;
}
r = -EIO;
goto finish;
}