[systemd-commits] 4 commits - CODING_STYLE TODO man/journalctl.xml src/timedate
Lennart Poettering
lennart at kemper.freedesktop.org
Thu Apr 2 03:17:46 PDT 2015
CODING_STYLE | 6 ++++++
TODO | 6 ++++++
man/journalctl.xml | 5 -----
src/timedate/timedatectl.c | 37 +++++++++++++++++++++++--------------
4 files changed, 35 insertions(+), 19 deletions(-)
New commits:
commit d95a74ed1191bb09f5be57b0619d3d77708e019d
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Apr 2 12:15:53 2015 +0200
timedatectl: many fixes
- print runtime warnings with log_warning()
- save and restore $TZ properly
- Get rid of exit() pseudo error handling
- Using time() is OK when connecting to a local container or when
showing data about local host, but certainly not for remote hosts.
diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c
index 1d10c19..89913cc 100644
--- a/src/timedate/timedatectl.c
+++ b/src/timedate/timedatectl.c
@@ -77,31 +77,30 @@ static void print_status_info(const StatusInfo *i) {
struct tm tm;
time_t sec;
bool have_time = false;
+ const char *old_tz = NULL, *tz;
int r;
assert(i);
- /* Enforce the values of /etc/localtime */
- if (getenv("TZ")) {
- fprintf(stderr, "Warning: Ignoring the TZ variable.\n\n");
- unsetenv("TZ");
- }
+ /* Save the old $TZ */
+ tz = getenv("TZ");
+ if (tz)
+ old_tz = strdupa(tz);
- r = setenv("TZ", i->timezone, false);
- if (r < 0) {
- log_error_errno(errno, "Failed to set TZ environment variable: %m");
- exit(EXIT_FAILURE);
- }
- tzset();
+ /* Set the new $TZ */
+ if (setenv("TZ", i->timezone, true) < 0)
+ log_warning_errno(errno, "Failed to set TZ environment variable, ignoring: %m");
+ else
+ tzset();
if (i->time != 0) {
sec = (time_t) (i->time / USEC_PER_SEC);
have_time = true;
- } else if (IN_SET(arg_transport, BUS_TRANSPORT_REMOTE, BUS_TRANSPORT_MACHINE)) {
+ } else if (IN_SET(arg_transport, BUS_TRANSPORT_LOCAL, BUS_TRANSPORT_MACHINE)) {
sec = time(NULL);
have_time = true;
} else
- fprintf(stderr, "Warning: Could not get time from timedated and not operating locally.\n\n");
+ log_warning("Could not get time from timedated and not operating locally, ignoring.");
if (have_time) {
xstrftime(a, "%a %Y-%m-%d %H:%M:%S %Z", localtime_r(&sec, &tm));
@@ -117,7 +116,7 @@ static void print_status_info(const StatusInfo *i) {
if (i->rtc_time > 0) {
time_t rtc_sec;
- rtc_sec = (time_t)(i->rtc_time / USEC_PER_SEC);
+ rtc_sec = (time_t) (i->rtc_time / USEC_PER_SEC);
xstrftime(a, "%a %Y-%m-%d %H:%M:%S", gmtime_r(&rtc_sec, &tm));
printf(" RTC time: %.*s\n", (int) sizeof(a), a);
} else
@@ -126,6 +125,16 @@ static void print_status_info(const StatusInfo *i) {
if (have_time)
xstrftime(a, "%Z, %z", localtime_r(&sec, &tm));
+ /* Restore the $TZ */
+ if (old_tz)
+ r = setenv("TZ", old_tz, true);
+ else
+ r = unsetenv("TZ");
+ if (r < 0)
+ log_warning_errno(errno, "Failed to set TZ environment variable, ignoring: %m");
+ else
+ tzset();
+
printf(" Time zone: %s (%.*s)\n"
" NTP enabled: %s\n"
"NTP synchronized: %s\n"
commit c4f54721175bde35e2051d61d3d23285def9619d
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Apr 2 12:14:57 2015 +0200
man: don't mention "journalctl /dev/sda"
It never worked, and nobody ever worked on it, hence don't mention it.
diff --git a/man/journalctl.xml b/man/journalctl.xml
index 770cf9b..08de0ff 100644
--- a/man/journalctl.xml
+++ b/man/journalctl.xml
@@ -817,11 +817,6 @@
<programlisting>journalctl /usr/bin/dbus-daemon</programlisting>
- <para>Show all logs of the kernel device node
- <filename noindex='true'>/dev/sda</filename>:</para>
-
- <programlisting>journalctl /dev/sda</programlisting>
-
<para>Show all kernel logs from previous boot:</para>
<programlisting>journalctl -k -b -1</programlisting>
commit ac749874bbb66c0e7eff15ca35d1616d29b6f3c1
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Apr 2 12:14:51 2015 +0200
update TODO
diff --git a/TODO b/TODO
index fd8099e..abc3dee 100644
--- a/TODO
+++ b/TODO
@@ -44,6 +44,12 @@ Before 220:
Features:
+* .timer units should optionally support CLOCK_BOOTTIME in addition to CLOCK_MONOTONIC
+
+* rm_rf() should be able to remove subvolumes
+
+* systemd-run should support a mode where we wait for the unit to be started up
+
* create a btrfs qgroup for /var/lib/machines, and add all container
subvolumes we create to it.
commit 3dbafa39b08025350e7b17f4874a343c789ff9b3
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Apr 2 12:14:43 2015 +0200
CODING_STYLE: clarify that exit() is never OK to call
diff --git a/CODING_STYLE b/CODING_STYLE
index b687e72..1748dc4 100644
--- a/CODING_STYLE
+++ b/CODING_STYLE
@@ -226,3 +226,9 @@
instead of just this:
unlink("/foo/bar/baz");
+
+- Don't invoke exit(), ever. It is not replacement for proper error
+ handling. Please escalate errors up your call chain, and use normal
+ "return" to exit from the main function of a process. If you
+ fork()ed off a child process, please use _exit() instead of exit(),
+ so that the exit handlers are not run.
More information about the systemd-commits
mailing list