chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
log: SCM_CREDENTIALS will be added by the kernel anyway, so there's no need to write...
[elogind.git]
/
src
/
update-utmp.c
diff --git
a/src/update-utmp.c
b/src/update-utmp.c
index e64a819aa4fed54af1675a218974a9d82b616860..5a48bd98dd9cf682f829933513d09a00b28fa4d4 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"
@@
-112,8
+115,6
@@
static int get_current_runlevel(Context *c) {
} table[] = {
/* The first target of this list that is active or has
* a job scheduled wins */
} table[] = {
/* The first target of this list that is active or has
* a job scheduled wins */
- { '0', SPECIAL_POWEROFF_TARGET },
- { '6', SPECIAL_REBOOT_TARGET },
{ '5', SPECIAL_RUNLEVEL5_TARGET },
{ '4', SPECIAL_RUNLEVEL4_TARGET },
{ '3', SPECIAL_RUNLEVEL3_TARGET },
{ '5', SPECIAL_RUNLEVEL5_TARGET },
{ '4', SPECIAL_RUNLEVEL4_TARGET },
{ '3', SPECIAL_RUNLEVEL3_TARGET },
@@
-246,7
+247,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;
}
@@
-274,7
+275,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;
}
@@
-310,7
+311,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;
@@
-321,7
+322,9
@@
static int on_runlevel(Context *c) {
if (c->audit_fd >= 0) {
char *s = NULL;
if (c->audit_fd >= 0) {
char *s = NULL;
- if (asprintf(&s, "old-level=%c new-level=%c", previous, runlevel) < 0)
+ if (asprintf(&s, "old-level=%c new-level=%c",
+ previous > 0 ? previous : 'N',
+ runlevel > 0 ? runlevel : 'N') < 0)
return -ENOMEM;
if (audit_log_user_message(c->audit_fd, AUDIT_SYSTEM_RUNLEVEL, s, NULL, NULL, NULL, 1) < 0) {
return -ENOMEM;
if (audit_log_user_message(c->audit_fd, AUDIT_SYSTEM_RUNLEVEL, s, NULL, NULL, NULL, 1) < 0) {
@@
-353,10
+356,10
@@
int main(int argc, char *argv[]) {
c.audit_fd = -1;
#endif
c.audit_fd = -1;
#endif
- /* if (getppid() != 1) { */
- /* log_error("This program should be invoked by init only."); */
- /* return 1; */
- /* } */
+ if (getppid() != 1) {
+ log_error("This program should be invoked by init only.");
+ return 1;
+ }
if (argc != 2) {
log_error("This program requires one argument.");
if (argc != 2) {
log_error("This program requires one argument.");
@@
-365,6
+368,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)
@@
-377,7
+381,7
@@
int main(int argc, char *argv[]) {
goto finish;
}
goto finish;
}
- log_
info
("systemd-update-utmp running as pid %lu", (unsigned long) getpid());
+ log_
debug
("systemd-update-utmp running as pid %lu", (unsigned long) getpid());
if (streq(argv[1], "reboot"))
r = on_reboot(&c);
if (streq(argv[1], "reboot"))
r = on_reboot(&c);
@@
-390,9
+394,9
@@
int main(int argc, char *argv[]) {
r = -EINVAL;
}
r = -EINVAL;
}
- log_info("systemd-update-utmp stopped as pid %lu", (unsigned long) getpid());
-finish:
+ log_debug("systemd-update-utmp stopped as pid %lu", (unsigned long) getpid());
+finish:
#ifdef HAVE_AUDIT
if (c.audit_fd >= 0)
audit_close(c.audit_fd);
#ifdef HAVE_AUDIT
if (c.audit_fd >= 0)
audit_close(c.audit_fd);