X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Flogs-show.c;h=12d4a1caecae75fd8090e98adc3e001efe9e5d59;hb=98b2f766b24c84fc49a4df954717b1f96bbce00d;hp=b24bce50c06710fc018816cd2eed722c9bfb45b8;hpb=e04b0cdb9001edec916216e1fd7b6e814bc46fc3;p=elogind.git diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index b24bce50c..12d4a1cae 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -124,6 +124,11 @@ static bool print_multiline(FILE *f, unsigned prefix, unsigned n_columns, Output } } + /* A special case: make sure that we print a newline when + the message is empty. */ + if (message_len == 0) + fputs("\n", f); + for (pos = message; pos < message + message_len; pos = end + 1, line++) { @@ -1117,7 +1122,7 @@ int add_matches_for_user_unit(sd_journal *j, const char *unit, uid_t uid) { static int get_boot_id_for_machine(const char *machine, sd_id128_t *boot_id) { _cleanup_close_pipe_ int pair[2] = { -1, -1 }; - _cleanup_close_ int nsfd = -1, rootfd = -1; + _cleanup_close_ int pidnsfd = -1, mntnsfd = -1, rootfd = -1; pid_t pid, child; siginfo_t si; char buf[37]; @@ -1134,7 +1139,7 @@ static int get_boot_id_for_machine(const char *machine, sd_id128_t *boot_id) { if (r < 0) return r; - r = namespace_open(pid, &nsfd, &rootfd); + r = namespace_open(pid, &pidnsfd, &mntnsfd, &rootfd); if (r < 0) return r; @@ -1151,7 +1156,7 @@ static int get_boot_id_for_machine(const char *machine, sd_id128_t *boot_id) { close_nointr_nofail(pair[0]); pair[0] = -1; - r = namespace_enter(nsfd, rootfd); + r = namespace_enter(pidnsfd, mntnsfd, rootfd); if (r < 0) _exit(EXIT_FAILURE); @@ -1174,14 +1179,14 @@ static int get_boot_id_for_machine(const char *machine, sd_id128_t *boot_id) { close_nointr_nofail(pair[1]); pair[1] = -1; - k = recv(pair[0], buf, 36, 0); - if (k != 36) - return -EIO; - r = wait_for_terminate(child, &si); if (r < 0 || si.si_code != CLD_EXITED || si.si_status != EXIT_SUCCESS) return r < 0 ? r : -EIO; + k = recv(pair[0], buf, 36, 0); + if (k != 36) + return -EIO; + buf[36] = 0; r = sd_id128_from_string(buf, boot_id); if (r < 0)