chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mount: properly handle LABEL="" in fstab
[elogind.git]
/
src
/
utmp-wtmp.c
diff --git
a/src/utmp-wtmp.c
b/src/utmp-wtmp.c
index 5aafb7b722272b411c051746a2bc834f64e0475f..77baaffacfdec7cc3a49f519bf69731664f61e24 100644
(file)
--- a/
src/utmp-wtmp.c
+++ b/
src/utmp-wtmp.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.
@@
-202,11
+202,11
@@
int utmp_put_runlevel(usec_t t, int runlevel, int previous) {
previous = 0;
}
previous = 0;
}
-
- if (previous == runlevel)
- return 0;
}
}
+ if (previous == runlevel)
+ return 0;
+
init_entry(&store, t);
store.ut_type = RUN_LVL;
init_entry(&store, t);
store.ut_type = RUN_LVL;
@@
-290,27
+290,26
@@
finish:
int utmp_wall(const char *message) {
struct utmpx *u;
int utmp_wall(const char *message) {
struct utmpx *u;
- char date[
26
];
- char *text
, *hn, *un, *tty
;
+ char date[
FORMAT_TIMESTAMP_MAX
];
+ char *text
= NULL, *hn = NULL, *un = NULL, *tty = NULL
;
int r;
int r;
- time_t t;
if (!(hn = gethostname_malloc()) ||
if (!(hn = gethostname_malloc()) ||
- !(un = getlogname_malloc()) ||
- !(tty = getttyname_malloc())) {
+ !(un = getlogname_malloc())) {
r = -ENOMEM;
goto finish;
}
r = -ENOMEM;
goto finish;
}
- time(&t);
- assert_se(ctime_r(&t, date));
- delete_chars(date, "\n\r");
+ getttyname_malloc(&tty);
if (asprintf(&text,
"\a\r\n"
if (asprintf(&text,
"\a\r\n"
- "Broadcast message from %s@%s
on
%s (%s):\r\n\r\n"
+ "Broadcast message from %s@%s
%s
%s (%s):\r\n\r\n"
"%s\r\n\r\n",
"%s\r\n\r\n",
- un, hn, tty, date, message) < 0) {
+ un, hn,
+ tty ? " on " : "", strempty(tty),
+ format_timestamp(date, sizeof(date), now(CLOCK_REALTIME)),
+ message) < 0) {
r = -ENOMEM;
goto finish;
}
r = -ENOMEM;
goto finish;
}