[systemd-commits] 5 commits - man/systemd.xml src/execute.c src/systemctl.c src/update-utmp.c src/utmp-wtmp.c src/utmp-wtmp.h
Michal Schmidt
michich at kemper.freedesktop.org
Sun Nov 6 16:12:43 PST 2011
man/systemd.xml | 2 +-
src/execute.c | 2 +-
src/systemctl.c | 2 +-
src/update-utmp.c | 4 ++--
src/utmp-wtmp.c | 34 ++++++++++++++++++++--------------
src/utmp-wtmp.h | 6 +++---
6 files changed, 28 insertions(+), 22 deletions(-)
New commits:
commit 75c982a79f68a9209f0bcaf422d50414167bc5d1
Author: Michal Schmidt <mschmidt at redhat.com>
Date: Mon Nov 7 01:08:21 2011 +0100
man: fix a typo in signal number
diff --git a/man/systemd.xml b/man/systemd.xml
index a8a6967..c1766e2 100644
--- a/man/systemd.xml
+++ b/man/systemd.xml
@@ -813,7 +813,7 @@
<listitem><para>Sets the log level to
<literal>debug</literal>
(resp. <literal>info</literal> on
- <literal>SIGRTMIN+32</literal>), as
+ <literal>SIGRTMIN+23</literal>), as
controlled via
<varname>systemd.log_level=debug</varname>
(resp. <varname>systemd.log_level=info</varname>
commit 4743137a4b7ce6214a06d02872bdfac080b6f131
Author: Michal Schmidt <mschmidt at redhat.com>
Date: Sun Nov 6 23:55:06 2011 +0100
utmp: for DEAD_PROCESS write the current time to wtmp
Zeroed .ut_tv values in wtmp confuse chkrootkit.
Reported and debugged by Norman Smith. This is based on his patch,
but modified to behave more like upstart did in F14 and cleaned up.
https://bugzilla.redhat.com/show_bug.cgi?id=743696
diff --git a/src/utmp-wtmp.c b/src/utmp-wtmp.c
index 00e19a3..217ae1e 100644
--- a/src/utmp-wtmp.c
+++ b/src/utmp-wtmp.c
@@ -155,11 +155,11 @@ static int write_entry_wtmp(const struct utmpx *store) {
return -errno;
}
-static int write_entry_both(const struct utmpx *store) {
+static int write_utmp_wtmp(const struct utmpx *store_utmp, const struct utmpx *store_wtmp) {
int r, s;
- r = write_entry_utmp(store);
- s = write_entry_wtmp(store);
+ r = write_entry_utmp(store_utmp);
+ s = write_entry_wtmp(store_wtmp);
if (r >= 0)
r = s;
@@ -172,6 +172,10 @@ static int write_entry_both(const struct utmpx *store) {
return r;
}
+static int write_entry_both(const struct utmpx *store) {
+ return write_utmp_wtmp(store, store);
+}
+
int utmp_put_shutdown(void) {
struct utmpx store;
@@ -226,7 +230,7 @@ int utmp_put_init_process(const char *id, pid_t pid, pid_t sid, const char *line
}
int utmp_put_dead_process(const char *id, pid_t pid, int code, int status) {
- struct utmpx lookup, store, *found;
+ struct utmpx lookup, store, store_wtmp, *found;
assert(id);
@@ -251,7 +255,11 @@ int utmp_put_dead_process(const char *id, pid_t pid, int code, int status) {
zero(store.ut_host);
zero(store.ut_tv);
- return write_entry_both(&store);
+ memcpy(&store_wtmp, &store, sizeof(store_wtmp));
+ /* wtmp wants the current time */
+ init_timestamp(&store_wtmp, 0);
+
+ return write_utmp_wtmp(&store, &store_wtmp);
}
commit fa4ad7ceca6c96d9f0b7022819acf8954cba35ea
Author: Michal Schmidt <mschmidt at redhat.com>
Date: Sun Nov 6 23:31:46 2011 +0100
utmp: initialize store with the found entry, not with the lookup key
diff --git a/src/utmp-wtmp.c b/src/utmp-wtmp.c
index 98c1a25..00e19a3 100644
--- a/src/utmp-wtmp.c
+++ b/src/utmp-wtmp.c
@@ -242,7 +242,7 @@ int utmp_put_dead_process(const char *id, pid_t pid, int code, int status) {
if (found->ut_pid != pid)
return 0;
- memcpy(&store, &lookup, sizeof(store));
+ memcpy(&store, found, sizeof(store));
store.ut_type = DEAD_PROCESS;
store.ut_exit.e_termination = code;
store.ut_exit.e_exit = status;
commit b8e47420b32b52619c6c49c98a663bee7929ccbe
Author: Michal Schmidt <mschmidt at redhat.com>
Date: Sun Nov 6 23:07:54 2011 +0100
utmp: no need to zero a struct before overwriting it with memcpy
diff --git a/src/utmp-wtmp.c b/src/utmp-wtmp.c
index e7b2e3c..98c1a25 100644
--- a/src/utmp-wtmp.c
+++ b/src/utmp-wtmp.c
@@ -242,8 +242,6 @@ int utmp_put_dead_process(const char *id, pid_t pid, int code, int status) {
if (found->ut_pid != pid)
return 0;
- zero(store);
-
memcpy(&store, &lookup, sizeof(store));
store.ut_type = DEAD_PROCESS;
store.ut_exit.e_termination = code;
commit 0ad26e09de813857382ec3a787fc6df5e52cf98b
Author: Michal Schmidt <mschmidt at redhat.com>
Date: Sun Nov 6 23:06:38 2011 +0100
utmp: remove unneded parameters
With these functions no caller ever passes anything else than 0
for 't' (meaning the current time will be used).
diff --git a/src/execute.c b/src/execute.c
index 866e8bf..250d53a 100644
--- a/src/execute.c
+++ b/src/execute.c
@@ -1170,7 +1170,7 @@ int exec_spawn(ExecCommand *command,
}
if (context->utmp_id)
- utmp_put_init_process(0, context->utmp_id, getpid(), getsid(0), context->tty_path);
+ utmp_put_init_process(context->utmp_id, getpid(), getsid(0), context->tty_path);
if (context->user) {
username = context->user;
diff --git a/src/systemctl.c b/src/systemctl.c
index 175159d..7373e64 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -5156,7 +5156,7 @@ static int halt_main(DBusConnection *bus) {
if (!arg_no_wtmp) {
if (sd_booted() > 0)
log_debug("Not writing utmp record, assuming that systemd-update-utmp is used.");
- else if ((r = utmp_put_shutdown(0)) < 0)
+ else if ((r = utmp_put_shutdown()) < 0)
log_warning("Failed to write utmp record: %s", strerror(-r));
}
diff --git a/src/update-utmp.c b/src/update-utmp.c
index 12e4d11..073f28e 100644
--- a/src/update-utmp.c
+++ b/src/update-utmp.c
@@ -284,7 +284,7 @@ static int on_shutdown(Context *c) {
}
#endif
- if ((q = utmp_put_shutdown(0)) < 0) {
+ if ((q = utmp_put_shutdown()) < 0) {
log_error("Failed to write utmp record: %s", strerror(-q));
r = q;
}
@@ -339,7 +339,7 @@ static int on_runlevel(Context *c) {
}
#endif
- if ((q = utmp_put_runlevel(0, runlevel, previous)) < 0) {
+ if ((q = utmp_put_runlevel(runlevel, previous)) < 0) {
log_error("Failed to write utmp record: %s", strerror(-q));
r = q;
}
diff --git a/src/utmp-wtmp.c b/src/utmp-wtmp.c
index b03a3e7..e7b2e3c 100644
--- a/src/utmp-wtmp.c
+++ b/src/utmp-wtmp.c
@@ -172,10 +172,10 @@ static int write_entry_both(const struct utmpx *store) {
return r;
}
-int utmp_put_shutdown(usec_t t) {
+int utmp_put_shutdown(void) {
struct utmpx store;
- init_entry(&store, t);
+ init_entry(&store, 0);
store.ut_type = RUN_LVL;
strncpy(store.ut_user, "shutdown", sizeof(store.ut_user));
@@ -206,12 +206,12 @@ static const char *sanitize_id(const char *id) {
return id + l - sizeof(((struct utmpx*) NULL)->ut_id);
}
-int utmp_put_init_process(usec_t t, const char *id, pid_t pid, pid_t sid, const char *line) {
+int utmp_put_init_process(const char *id, pid_t pid, pid_t sid, const char *line) {
struct utmpx store;
assert(id);
- init_timestamp(&store, t);
+ init_timestamp(&store, 0);
store.ut_type = INIT_PROCESS;
store.ut_pid = pid;
@@ -257,7 +257,7 @@ int utmp_put_dead_process(const char *id, pid_t pid, int code, int status) {
}
-int utmp_put_runlevel(usec_t t, int runlevel, int previous) {
+int utmp_put_runlevel(int runlevel, int previous) {
struct utmpx store;
int r;
@@ -277,7 +277,7 @@ int utmp_put_runlevel(usec_t t, int runlevel, int previous) {
if (previous == runlevel)
return 0;
- init_entry(&store, t);
+ init_entry(&store, 0);
store.ut_type = RUN_LVL;
store.ut_pid = (runlevel & 0xFF) | ((previous & 0xFF) << 8);
diff --git a/src/utmp-wtmp.h b/src/utmp-wtmp.h
index 4054aff..a5998eb 100644
--- a/src/utmp-wtmp.h
+++ b/src/utmp-wtmp.h
@@ -26,12 +26,12 @@
int utmp_get_runlevel(int *runlevel, int *previous);
-int utmp_put_shutdown(usec_t timestamp);
+int utmp_put_shutdown(void);
int utmp_put_reboot(usec_t timestamp);
-int utmp_put_runlevel(usec_t timestamp, int runlevel, int previous);
+int utmp_put_runlevel(int runlevel, int previous);
int utmp_put_dead_process(const char *id, pid_t pid, int code, int status);
-int utmp_put_init_process(usec_t timestamp, const char *id, pid_t pid, pid_t sid, const char *line);
+int utmp_put_init_process(const char *id, pid_t pid, pid_t sid, const char *line);
int utmp_wall(const char *message, bool (*match_tty)(const char *tty));
More information about the systemd-commits
mailing list