[systemd/f17] more patches with fixes for BZs

Michal Schmidt michich at fedoraproject.org
Tue Jun 19 15:44:15 UTC 2012


commit 59f8e6d1955b2258b1e271d7cd77ccfe7be13829
Author: Michal Schmidt <mschmidt at redhat.com>
Date:   Tue Jun 19 17:34:48 2012 +0200

    more patches with fixes for BZs
    
    Apply timeouts to oneshot services (#761656)
    Report error when stopping an unknown unit (#732874)
    logind: more robust on VT-less systems (s390x) (#832210)
    journal: various fixes, expose cutoff times

 0420-service-timeout-for-oneshot-services.patch    |  141 ++++++++
 ...d-more-robust-handling-of-VT-less-systems.patch |   31 ++
 ...urnal-replace-arena-offset-by-header-size.patch |   92 +++++
 ...dd-basic-object-definition-for-signatures.patch |   91 +++++
 ...l-correct-list-link-up-on-hash-collisions.patch |   24 ++
 ...-F17-fix-libsystemd-journal-symver-script.patch |   23 ++
 ...ose-and-make-use-of-cutoff-times-of-journ.patch |  348 ++++++++++++++++++++
 0427-journal-fix-SD_JOURNAL_SYSTEM_ONLY-flag.patch |   24 ++
 0428-journal-rotate-on-SIGUSR2.patch               |  120 +++++++
 0429-journal-fix-monotonic-seeking.patch           |   28 ++
 ...urn-error-when-asked-to-stop-unknown-unit.patch |   30 ++
 systemd.spec                                       |   19 +-
 12 files changed, 970 insertions(+), 1 deletions(-)
---
diff --git a/0420-service-timeout-for-oneshot-services.patch b/0420-service-timeout-for-oneshot-services.patch
new file mode 100644
index 0000000..26e0baf
--- /dev/null
+++ b/0420-service-timeout-for-oneshot-services.patch
@@ -0,0 +1,141 @@
+From a9d76542130e6c0ce12a6276c8e9869cc1bd8e6f Mon Sep 17 00:00:00 2001
+From: Lukas Nykryn <lnykryn at redhat.com>
+Date: Thu, 14 Jun 2012 17:07:07 +0200
+Subject: [PATCH] service: timeout for oneshot services
+
+Add possibility to specify timeout for oneshot services.
+
+[ https://bugzilla.redhat.com/show_bug.cgi?id=761656
+  Added minor fixups. -- michich ]
+(cherry picked from commit 98709151f3e782eb508ba15e2a12c0b46003f061)
+---
+ man/systemd.service.xml               |    4 +++-
+ src/core/load-fragment-gperf.gperf.m4 |    2 +-
+ src/core/load-fragment.c              |   26 ++++++++++++++++++++++++++
+ src/core/load-fragment.h              |    1 +
+ src/core/service.c                    |    8 ++++++--
+ src/core/service.h                    |    1 +
+ 6 files changed, 38 insertions(+), 4 deletions(-)
+
+diff --git a/man/systemd.service.xml b/man/systemd.service.xml
+index 9a80dd7..dc14113 100644
+--- a/man/systemd.service.xml
++++ b/man/systemd.service.xml
+@@ -459,7 +459,9 @@
+                                 time span value such as "5min
+                                 20s". Pass 0 to disable the timeout
+                                 logic. Defaults to
+-                                90s.</para></listitem>
++                                90s, except when <varname>Type=oneshot</varname> is
++                                used in which case the timeout
++                                is disabled by default.</para></listitem>
+                         </varlistentry>
+ 
+                         <varlistentry>
+diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4
+index d32aae9..50fba45 100644
+--- a/src/core/load-fragment-gperf.gperf.m4
++++ b/src/core/load-fragment-gperf.gperf.m4
+@@ -137,7 +137,7 @@ Service.ExecReload,              config_parse_exec,                  SERVICE_EXE
+ Service.ExecStop,                config_parse_exec,                  SERVICE_EXEC_STOP,             offsetof(Service, exec_command)
+ Service.ExecStopPost,            config_parse_exec,                  SERVICE_EXEC_STOP_POST,        offsetof(Service, exec_command)
+ Service.RestartSec,              config_parse_usec,                  0,                             offsetof(Service, restart_usec)
+-Service.TimeoutSec,              config_parse_usec,                  0,                             offsetof(Service, timeout_usec)
++Service.TimeoutSec,              config_parse_service_timeout,       0,                             offsetof(Service, timeout_usec)
+ Service.WatchdogSec,             config_parse_usec,                  0,                             offsetof(Service, watchdog_usec)
+ Service.StartLimitInterval,      config_parse_usec,                  0,                             offsetof(Service, start_limit.interval)
+ Service.StartLimitBurst,         config_parse_unsigned,              0,                             offsetof(Service, start_limit.burst)
+diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
+index 9bbb45e..94d8a5b 100644
+--- a/src/core/load-fragment.c
++++ b/src/core/load-fragment.c
+@@ -1398,6 +1398,32 @@ int config_parse_service_sockets(
+         return 0;
+ }
+ 
++int config_parse_service_timeout(
++                const char *filename,
++                unsigned line,
++                const char *section,
++                const char *lvalue,
++                int ltype,
++                const char *rvalue,
++                void *data,
++                void *userdata) {
++
++        Service *s = userdata;
++        int r;
++
++        assert(filename);
++        assert(lvalue);
++        assert(rvalue);
++        assert(s);
++
++        r = config_parse_usec(filename, line, section, lvalue, ltype, rvalue, data, userdata);
++
++        if (!r)
++                s->timeout_defined = true;
++
++        return r;
++}
++
+ int config_parse_unit_env_file(
+                 const char *filename,
+                 unsigned line,
+diff --git a/src/core/load-fragment.h b/src/core/load-fragment.h
+index 3166b18..c819e05 100644
+--- a/src/core/load-fragment.h
++++ b/src/core/load-fragment.h
+@@ -42,6 +42,7 @@ int config_parse_socket_bind(const char *filename, unsigned line, const char *se
+ int config_parse_exec_nice(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+ int config_parse_exec_oom_score_adjust(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+ int config_parse_exec(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
++int config_parse_service_timeout(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+ int config_parse_service_type(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+ int config_parse_service_restart(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+ int config_parse_socket_bindtodevice(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+diff --git a/src/core/service.c b/src/core/service.c
+index 53b0847..c5a6df6 100644
+--- a/src/core/service.c
++++ b/src/core/service.c
+@@ -1245,6 +1245,10 @@ static int service_load(Unit *u) {
+                 if (s->type == _SERVICE_TYPE_INVALID)
+                         s->type = s->bus_name ? SERVICE_DBUS : SERVICE_SIMPLE;
+ 
++                /* Oneshot services have disabled timeout by default */
++                if (s->type == SERVICE_ONESHOT && !s->timeout_defined)
++                        s->timeout_usec = 0;
++
+                 service_fix_output(s);
+ 
+                 if ((r = unit_add_exec_dependencies(u, &s->exec_context)) < 0)
+@@ -2155,7 +2159,7 @@ static void service_enter_start(Service *s) {
+ 
+         r = service_spawn(s,
+                           c,
+-                          s->type == SERVICE_FORKING || s->type == SERVICE_DBUS || s->type == SERVICE_NOTIFY,
++                          s->type == SERVICE_FORKING || s->type == SERVICE_DBUS || s->type == SERVICE_NOTIFY || s->type == SERVICE_ONESHOT,
+                           true,
+                           true,
+                           true,
+@@ -2370,7 +2374,7 @@ static void service_run_next_main(Service *s) {
+ 
+         r = service_spawn(s,
+                           s->main_command,
+-                          false,
++                          true,
+                           true,
+                           true,
+                           true,
+diff --git a/src/core/service.h b/src/core/service.h
+index 8b92aa3..48f4dbb 100644
+--- a/src/core/service.h
++++ b/src/core/service.h
+@@ -164,6 +164,7 @@ struct Service {
+         bool bus_name_good:1;
+         bool forbid_restart:1;
+         bool got_socket_fd:1;
++        bool timeout_defined:1;
+ #ifdef HAVE_SYSV_COMPAT
+         bool sysv_has_lsb:1;
+         bool sysv_enabled:1;
diff --git a/0421-logind-more-robust-handling-of-VT-less-systems.patch b/0421-logind-more-robust-handling-of-VT-less-systems.patch
new file mode 100644
index 0000000..8975960
--- /dev/null
+++ b/0421-logind-more-robust-handling-of-VT-less-systems.patch
@@ -0,0 +1,31 @@
+From fca20756b10d091170409e7c665367e6ac8101a9 Mon Sep 17 00:00:00 2001
+From: Michal Schmidt <mschmidt at redhat.com>
+Date: Fri, 15 Jun 2012 22:22:24 +0200
+Subject: [PATCH] logind: more robust handling of VT-less systems
+
+Restore the check that was removed in commit 74afee9c. Its removal
+caused a regression on some s390x systems where for whatever reason the
+device node /dev/tty0 exists and makes the preceding access() check
+pass.
+(cherry picked from commit cdc564d27f71f82457e96e9b237564fc6e8e84c9)
+---
+ src/login/logind.c |    6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/src/login/logind.c b/src/login/logind.c
+index c3f79df..0fcf48c 100644
+--- a/src/login/logind.c
++++ b/src/login/logind.c
+@@ -1092,6 +1092,12 @@ static int manager_connect_console(Manager *m) {
+ 
+         m->console_active_fd = open("/sys/class/tty/tty0/active", O_RDONLY|O_NOCTTY|O_CLOEXEC);
+         if (m->console_active_fd < 0) {
++
++                /* On some systems the device node /dev/tty0 may exist
++                 * even though /sys/class/tty/tty0 does not. */
++                if (errno == ENOENT)
++                        return 0;
++
+                 log_error("Failed to open /sys/class/tty/tty0/active: %m");
+                 return -errno;
+         }
diff --git a/0422-journal-replace-arena-offset-by-header-size.patch b/0422-journal-replace-arena-offset-by-header-size.patch
new file mode 100644
index 0000000..9fe2520
--- /dev/null
+++ b/0422-journal-replace-arena-offset-by-header-size.patch
@@ -0,0 +1,92 @@
+From 12e1e4c67f98c6634c7de05a3f774c0feec9baf8 Mon Sep 17 00:00:00 2001
+From: Lennart Poettering <lennart at poettering.net>
+Date: Tue, 5 Jun 2012 20:32:55 +0200
+Subject: [PATCH] journal: replace arena offset by header size (cherry picked
+ from commit 23b0b2b2647d3f0f3fd0219c877d6233b4585421)
+
+---
+ src/journal/journal-def.h  |    2 +-
+ src/journal/journal-file.c |   19 +++++++++++--------
+ 2 files changed, 12 insertions(+), 9 deletions(-)
+
+diff --git a/src/journal/journal-def.h b/src/journal/journal-def.h
+index 9cb8051..2e13228 100644
+--- a/src/journal/journal-def.h
++++ b/src/journal/journal-def.h
+@@ -145,7 +145,7 @@ _packed_ struct Header {
+         sd_id128_t machine_id;
+         sd_id128_t boot_id;
+         sd_id128_t seqnum_id;
+-        le64_t arena_offset;
++        le64_t header_size;
+         le64_t arena_size;
+         le64_t data_hash_table_offset;     /* for looking up data objects */
+         le64_t data_hash_table_size;
+diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
+index df4cbd5..1f1f81f 100644
+--- a/src/journal/journal-file.c
++++ b/src/journal/journal-file.c
+@@ -99,7 +99,7 @@ static int journal_file_init_header(JournalFile *f, JournalFile *template) {
+ 
+         zero(h);
+         memcpy(h.signature, signature, 8);
+-        h.arena_offset = htole64(ALIGN64(sizeof(h)));
++        h.header_size = htole64(ALIGN64(sizeof(h)));
+ 
+         r = sd_id128_randomize(&h.file_id);
+         if (r < 0)
+@@ -161,7 +161,10 @@ static int journal_file_verify_header(JournalFile *f) {
+                 return -EPROTONOSUPPORT;
+ #endif
+ 
+-        if ((uint64_t) f->last_stat.st_size < (le64toh(f->header->arena_offset) + le64toh(f->header->arena_size)))
++        if (f->header->header_size != htole64(ALIGN64(sizeof(*(f->header)))))
++                return -EBADMSG;
++
++        if ((uint64_t) f->last_stat.st_size < (le64toh(f->header->header_size) + le64toh(f->header->arena_size)))
+                 return -ENODATA;
+ 
+         if (f->writable) {
+@@ -200,12 +203,12 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size)
+          * ourselves */
+ 
+         old_size =
+-                le64toh(f->header->arena_offset) +
++                le64toh(f->header->header_size) +
+                 le64toh(f->header->arena_size);
+ 
+         new_size = PAGE_ALIGN(offset + size);
+-        if (new_size < le64toh(f->header->arena_offset))
+-                new_size = le64toh(f->header->arena_offset);
++        if (new_size < le64toh(f->header->header_size))
++                new_size = le64toh(f->header->header_size);
+ 
+         if (new_size <= old_size)
+                 return 0;
+@@ -243,7 +246,7 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size)
+         if (fstat(f->fd, &f->last_stat) < 0)
+                 return -errno;
+ 
+-        f->header->arena_size = htole64(new_size - le64toh(f->header->arena_offset));
++        f->header->arena_size = htole64(new_size - le64toh(f->header->header_size));
+ 
+         return 0;
+ }
+@@ -457,7 +460,7 @@ static int journal_file_append_object(JournalFile *f, int type, uint64_t size, O
+ 
+         p = le64toh(f->header->tail_object_offset);
+         if (p == 0)
+-                p = le64toh(f->header->arena_offset);
++                p = le64toh(f->header->header_size);
+         else {
+                 r = journal_file_move_to_object(f, -1, p, &tail);
+                 if (r < 0)
+@@ -1665,7 +1668,7 @@ void journal_file_dump(JournalFile *f) {
+                (unsigned long) le64toh(f->header->n_objects),
+                (unsigned long) le64toh(f->header->n_entries));
+ 
+-        p = le64toh(f->header->arena_offset);
++        p = le64toh(f->header->header_size);
+         while (p != 0) {
+                 r = journal_file_move_to_object(f, -1, p, &o);
+                 if (r < 0)
diff --git a/0423-journal-add-basic-object-definition-for-signatures.patch b/0423-journal-add-basic-object-definition-for-signatures.patch
new file mode 100644
index 0000000..91688ba
--- /dev/null
+++ b/0423-journal-add-basic-object-definition-for-signatures.patch
@@ -0,0 +1,91 @@
+From 5280e6772732eb4841a749a3fea50c0705232177 Mon Sep 17 00:00:00 2001
+From: Lennart Poettering <lennart at poettering.net>
+Date: Tue, 5 Jun 2012 20:45:54 +0200
+Subject: [PATCH] journal: add basic object definition for signatures (cherry
+ picked from commit
+ 8144056fa63291e5b25d91a48cd77b91e845eabf)
+
+---
+ src/journal/journal-def.h  |   18 ++++++++++++++++++
+ src/journal/journal-file.c |    4 ++++
+ 2 files changed, 22 insertions(+)
+
+diff --git a/src/journal/journal-def.h b/src/journal/journal-def.h
+index 2e13228..8d250b2 100644
+--- a/src/journal/journal-def.h
++++ b/src/journal/journal-def.h
+@@ -29,13 +29,17 @@
+ #include "macro.h"
+ 
+ typedef struct Header Header;
++
+ typedef struct ObjectHeader ObjectHeader;
+ typedef union Object Object;
++
+ typedef struct DataObject DataObject;
+ typedef struct FieldObject FieldObject;
+ typedef struct EntryObject EntryObject;
+ typedef struct HashTableObject HashTableObject;
+ typedef struct EntryArrayObject EntryArrayObject;
++typedef struct SignatureObject SignatureObject;
++
+ typedef struct EntryItem EntryItem;
+ typedef struct HashItem HashItem;
+ 
+@@ -48,6 +52,7 @@ enum {
+         OBJECT_DATA_HASH_TABLE,
+         OBJECT_FIELD_HASH_TABLE,
+         OBJECT_ENTRY_ARRAY,
++        OBJECT_SIGNATURE,
+         _OBJECT_TYPE_MAX
+ };
+ 
+@@ -115,6 +120,14 @@ _packed_ struct EntryArrayObject {
+         le64_t items[];
+ };
+ 
++#define SIGNATURE_LENGTH 160
++
++_packed_ struct SignatureObject {
++        ObjectHeader object;
++        le64_t from;
++        uint8_t signature[SIGNATURE_LENGTH];
++};
++
+ union Object {
+         ObjectHeader object;
+         DataObject data;
+@@ -122,6 +135,7 @@ union Object {
+         EntryObject entry;
+         HashTableObject hash_table;
+         EntryArrayObject entry_array;
++        SignatureObject signature;
+ };
+ 
+ enum {
+@@ -135,6 +149,10 @@ enum {
+         HEADER_INCOMPATIBLE_COMPRESSED = 1
+ };
+ 
++enum {
++        HEADER_COMPATIBLE_SIGNED = 1
++};
++
+ _packed_ struct Header {
+         uint8_t signature[8]; /* "LPKSHHRH" */
+         uint32_t compatible_flags;
+diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
+index 1f1f81f..8002480 100644
+--- a/src/journal/journal-file.c
++++ b/src/journal/journal-file.c
+@@ -1702,6 +1702,10 @@ void journal_file_dump(JournalFile *f) {
+                 case OBJECT_ENTRY_ARRAY:
+                         printf("Type: OBJECT_ENTRY_ARRAY\n");
+                         break;
++
++                case OBJECT_SIGNATURE:
++                        printf("Type: OBJECT_SIGNATURE\n");
++                        break;
+                 }
+ 
+                 if (o->object.flags & OBJECT_COMPRESSED)
diff --git a/0424-journal-correct-list-link-up-on-hash-collisions.patch b/0424-journal-correct-list-link-up-on-hash-collisions.patch
new file mode 100644
index 0000000..f8e3612
--- /dev/null
+++ b/0424-journal-correct-list-link-up-on-hash-collisions.patch
@@ -0,0 +1,24 @@
+From 07d340022efb397f3efebf03abc9137f1f94064f Mon Sep 17 00:00:00 2001
+From: Lennart Poettering <lennart at poettering.net>
+Date: Sat, 9 Jun 2012 10:30:44 +0200
+Subject: [PATCH] journal: correct list link up on hash collisions (cherry
+ picked from commit
+ 8db4213e7b38ebc54bfdc7215991cc23b9580e3a)
+
+---
+ src/journal/journal-file.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
+index 8002480..f793d08 100644
+--- a/src/journal/journal-file.c
++++ b/src/journal/journal-file.c
+@@ -596,7 +596,7 @@ static int journal_file_link_data(JournalFile *f, Object *o, uint64_t offset, ui
+         o->data.n_entries = 0;
+ 
+         h = hash % (le64toh(f->header->data_hash_table_size) / sizeof(HashItem));
+-        p = le64toh(f->data_hash_table[h].head_hash_offset);
++        p = le64toh(f->data_hash_table[h].tail_hash_offset);
+         if (p == 0) {
+                 /* Only entry in the hash table is easy */
+                 f->data_hash_table[h].head_hash_offset = htole64(offset);
diff --git a/0425-F17-fix-libsystemd-journal-symver-script.patch b/0425-F17-fix-libsystemd-journal-symver-script.patch
new file mode 100644
index 0000000..22588ee
--- /dev/null
+++ b/0425-F17-fix-libsystemd-journal-symver-script.patch
@@ -0,0 +1,23 @@
+From 86d38d5c7e4644a19b686cedb0d006a427f80431 Mon Sep 17 00:00:00 2001
+From: Michal Schmidt <mschmidt at redhat.com>
+Date: Tue, 19 Jun 2012 17:18:16 +0200
+Subject: [PATCH] F17: fix libsystemd-journal symver script
+
+Upstream has no LIBSYSTEMD_JOURNAL_45, because it got renamed to
+LIBSYSTEMD_JOURNAL_183. Rather than renaming it in F17 too, provide
+both.
+---
+ src/journal/libsystemd-journal.sym |    3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/journal/libsystemd-journal.sym b/src/journal/libsystemd-journal.sym
+index cd434ae..b5b4f81 100644
+--- a/src/journal/libsystemd-journal.sym
++++ b/src/journal/libsystemd-journal.sym
+@@ -51,3 +51,6 @@ global:
+         sd_journal_send_with_location;
+         sd_journal_sendv_with_location;
+ } LIBSYSTEMD_JOURNAL_38;
++
++LIBSYSTEMD_JOURNAL_183 {
++} LIBSYSTEMD_JOURNAL_45;
diff --git a/0426-journal-expose-and-make-use-of-cutoff-times-of-journ.patch b/0426-journal-expose-and-make-use-of-cutoff-times-of-journ.patch
new file mode 100644
index 0000000..cd9ed8e
--- /dev/null
+++ b/0426-journal-expose-and-make-use-of-cutoff-times-of-journ.patch
@@ -0,0 +1,348 @@
+From 900913bf16345a172ae742683541efad16c412c6 Mon Sep 17 00:00:00 2001
+From: Lennart Poettering <lennart at poettering.net>
+Date: Sat, 9 Jun 2012 10:32:38 +0200
+Subject: [PATCH] journal: expose and make use of cutoff times of journal
+
+This helps explaining when the log output of "systemctl status" is
+incomplete because the logs got rotated since the service was started.
+(cherry picked from commit 089842938dd0f4080084044bb9a1a3b00137926a)
+---
+ src/journal/journal-def.h          |    4 +-
+ src/journal/journal-file.c         |   72 ++++++++++++++++++++++++++++++++++
+ src/journal/journal-file.h         |    3 ++
+ src/journal/journalctl.c           |   20 ++++++++++
+ src/journal/libsystemd-journal.sym |    6 +++
+ src/journal/sd-journal.c           |   75 ++++++++++++++++++++++++++++++++++++
+ src/shared/logs-show.c             |   23 ++++++++++-
+ src/shared/logs-show.h             |    3 +-
+ src/systemctl/systemctl.c          |    2 +-
+ src/systemd/sd-journal.h           |    3 ++
+ 10 files changed, 206 insertions(+), 5 deletions(-)
+
+diff --git a/src/journal/journal-def.h b/src/journal/journal-def.h
+index 8d250b2..04483f2 100644
+--- a/src/journal/journal-def.h
++++ b/src/journal/journal-def.h
+@@ -160,8 +160,8 @@ _packed_ struct Header {
+         uint8_t state;
+         uint8_t reserved[7];
+         sd_id128_t file_id;
+-        sd_id128_t machine_id;
+-        sd_id128_t boot_id;
++        sd_id128_t machine_id; /* last writer */
++        sd_id128_t boot_id;    /* last writer */
+         sd_id128_t seqnum_id;
+         le64_t header_size;
+         le64_t arena_size;
+diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
+index f793d08..d0a14c2 100644
+--- a/src/journal/journal-file.c
++++ b/src/journal/journal-file.c
+@@ -183,6 +183,7 @@ static int journal_file_verify_header(JournalFile *f) {
+ 
+                 if (state == STATE_ONLINE)
+                         log_debug("Journal file %s is already online. Assuming unclean closing. Ignoring.", f->path);
++                        /* FIXME: immediately rotate */
+                 else if (state == STATE_ARCHIVED)
+                         return -ESHUTDOWN;
+                 else if (state != STATE_OFFLINE)
+@@ -2284,3 +2285,74 @@ void journal_default_metrics(JournalMetrics *m, int fd) {
+                  format_bytes(c, sizeof(c), m->min_size),
+                  format_bytes(d, sizeof(d), m->keep_free));
+ }
++
++int journal_file_get_cutoff_realtime_usec(JournalFile *f, usec_t *from, usec_t *to) {
++        Object *o;
++        int r;
++
++        assert(f);
++        assert(from || to);
++
++        if (from) {
++                r = journal_file_next_entry(f, NULL, 0, DIRECTION_DOWN, &o, NULL);
++                if (r <= 0)
++                        return r;
++
++                *from = le64toh(o->entry.realtime);
++        }
++
++        if (to) {
++                r = journal_file_next_entry(f, NULL, 0, DIRECTION_UP, &o, NULL);
++                if (r <= 0)
++                        return r;
++
++                *to = le64toh(o->entry.realtime);
++        }
++
++        return 1;
++}
++
++int journal_file_get_cutoff_monotonic_usec(JournalFile *f, sd_id128_t boot_id, usec_t *from, usec_t *to) {
++        char t[9+32+1] = "_BOOT_ID=";
++        Object *o;
++        uint64_t p;
++        int r;
++
++        assert(f);
++        assert(from || to);
++
++        sd_id128_to_string(boot_id, t + 9);
++
++        r = journal_file_find_data_object(f, t, strlen(t), &o, &p);
++        if (r <= 0)
++                return r;
++
++        if (le64toh(o->data.n_entries) <= 0)
++                return 0;
++
++        if (from) {
++                r = journal_file_move_to_object(f, OBJECT_ENTRY, le64toh(o->data.entry_offset), &o);
++                if (r < 0)
++                        return r;
++
++                *from = le64toh(o->entry.monotonic);
++        }
++
++        if (to) {
++                r = journal_file_move_to_object(f, OBJECT_DATA, p, &o);
++                if (r < 0)
++                        return r;
++
++                r = generic_array_get_plus_one(f,
++                                               le64toh(o->data.entry_offset),
++                                               le64toh(o->data.entry_array_offset),
++                                               le64toh(o->data.n_entries)-1,
++                                               &o, NULL);
++                if (r <= 0)
++                        return r;
++
++                *to = le64toh(o->entry.monotonic);
++        }
++
++        return 1;
++}
+diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
+index 57d66ca..fdb7604 100644
+--- a/src/journal/journal-file.h
++++ b/src/journal/journal-file.h
+@@ -125,4 +125,7 @@ void journal_file_post_change(JournalFile *f);
+ 
+ void journal_default_metrics(JournalMetrics *m, int fd);
+ 
++int journal_file_get_cutoff_realtime_usec(JournalFile *f, usec_t *from, usec_t *to);
++int journal_file_get_cutoff_monotonic_usec(JournalFile *f, sd_id128_t boot, usec_t *from, usec_t *to);
++
+ #endif
+diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
+index 53f0160..3f6e78f 100644
+--- a/src/journal/journalctl.c
++++ b/src/journal/journalctl.c
+@@ -281,6 +281,26 @@ int main(int argc, char *argv[]) {
+                 goto finish;
+         }
+ 
++        if (!arg_quiet) {
++                usec_t start, end;
++                char start_buf[FORMAT_TIMESTAMP_MAX], end_buf[FORMAT_TIMESTAMP_MAX];
++
++                r = sd_journal_get_cutoff_realtime_usec(j, &start, &end);
++                if (r < 0) {
++                        log_error("Failed to get cutoff: %s", strerror(-r));
++                        goto finish;
++                }
++
++                if (r > 0) {
++                        if (arg_follow)
++                                printf("Logs begin at %s.\n", format_timestamp(start_buf, sizeof(start_buf), start));
++                        else
++                                printf("Logs begin at %s, end at %s.\n",
++                                       format_timestamp(start_buf, sizeof(start_buf), start),
++                                       format_timestamp(end_buf, sizeof(end_buf), end));
++                }
++        }
++
+         if (arg_lines >= 0) {
+                 r = sd_journal_seek_tail(j);
+                 if (r < 0) {
+diff --git a/src/journal/libsystemd-journal.sym b/src/journal/libsystemd-journal.sym
+index b5b4f81..9059c79 100644
+--- a/src/journal/libsystemd-journal.sym
++++ b/src/journal/libsystemd-journal.sym
+@@ -54,3 +54,9 @@ global:
+ 
+ LIBSYSTEMD_JOURNAL_183 {
+ } LIBSYSTEMD_JOURNAL_45;
++
++LIBSYSTEMD_JOURNAL_184 {
++global:
++        sd_journal_get_cutoff_realtime_usec;
++        sd_journal_get_cutoff_monotonic_usec;
++} LIBSYSTEMD_JOURNAL_183;
+diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
+index e80c6cb..9fc7090 100644
+--- a/src/journal/sd-journal.c
++++ b/src/journal/sd-journal.c
+@@ -1620,6 +1620,81 @@ _public_ int sd_journal_process(sd_journal *j) {
+         }
+ }
+ 
++_public_ int sd_journal_get_cutoff_realtime_usec(sd_journal *j, uint64_t *from, uint64_t *to) {
++        Iterator i;
++        JournalFile *f;
++        bool first = true;
++        int r;
++
++        if (!j)
++                return -EINVAL;
++        if (!from && !to)
++                return -EINVAL;
++
++        HASHMAP_FOREACH(f, j->files, i) {
++                usec_t fr, t;
++
++                r = journal_file_get_cutoff_realtime_usec(f, &fr, &t);
++                if (r < 0)
++                        return r;
++                if (r == 0)
++                        continue;
++
++                if (first) {
++                        if (from)
++                                *from = fr;
++                        if (to)
++                                *to = t;
++                        first = false;
++                } else {
++                        if (from)
++                                *from = MIN(fr, *from);
++                        if (to)
++                                *to = MIN(t, *to);
++                }
++        }
++
++        return first ? 0 : 1;
++}
++
++_public_ int sd_journal_get_cutoff_monotonic_usec(sd_journal *j, sd_id128_t boot_id, uint64_t *from, uint64_t *to) {
++        Iterator i;
++        JournalFile *f;
++        bool first = true;
++        int r;
++
++        if (!j)
++                return -EINVAL;
++        if (!from && !to)
++                return -EINVAL;
++
++        HASHMAP_FOREACH(f, j->files, i) {
++                usec_t fr, t;
++
++                r = journal_file_get_cutoff_monotonic_usec(f, boot_id, &fr, &t);
++                if (r < 0)
++                        return r;
++                if (r == 0)
++                        continue;
++
++                if (first) {
++                        if (from)
++                                *from = fr;
++                        if (to)
++                                *to = t;
++                        first = false;
++                } else {
++                        if (from)
++                                *from = MIN(fr, *from);
++                        if (to)
++                                *to = MIN(t, *to);
++                }
++        }
++
++        return first ? 0 : 1;
++}
++
++
+ /* _public_ int sd_journal_query_unique(sd_journal *j, const char *field) { */
+ /*         if (!j) */
+ /*                 return -EINVAL; */
+diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
+index 95df3bb..c4731a2 100644
+--- a/src/shared/logs-show.c
++++ b/src/shared/logs-show.c
+@@ -551,7 +551,8 @@ int show_journal_by_unit(
+                 usec_t not_before,
+                 unsigned how_many,
+                 bool show_all,
+-                bool follow) {
++                bool follow,
++                bool warn_cutoff) {
+ 
+         char *m = NULL;
+         sd_journal *j = NULL;
+@@ -639,6 +640,26 @@ int show_journal_by_unit(
+                                 goto finish;
+                 }
+ 
++                if (warn_cutoff && line < how_many && not_before > 0) {
++                        sd_id128_t boot_id;
++                        usec_t cutoff;
++
++                        /* Check whether the cutoff line is too early */
++
++                        r = sd_id128_get_boot(&boot_id);
++                        if (r < 0)
++                                goto finish;
++
++                        r = sd_journal_get_cutoff_monotonic_usec(j, boot_id, &cutoff, NULL);
++                        if (r < 0)
++                                goto finish;
++
++                        if (not_before < cutoff)
++                                printf("Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.\n");
++
++                        warn_cutoff = false;
++                }
++
+                 if (!follow)
+                         break;
+ 
+diff --git a/src/shared/logs-show.h b/src/shared/logs-show.h
+index db9c7e3..d7bbb31 100644
+--- a/src/shared/logs-show.h
++++ b/src/shared/logs-show.h
+@@ -48,7 +48,8 @@ int show_journal_by_unit(
+                 usec_t not_before,
+                 unsigned how_many,
+                 bool show_all,
+-                bool follow);
++                bool follow,
++                bool warn_cutoff);
+ 
+ const char* output_mode_to_string(OutputMode m);
+ OutputMode output_mode_from_string(const char *s);
+diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
+index 4d26398..2cc016e 100644
+--- a/src/systemctl/systemctl.c
++++ b/src/systemctl/systemctl.c
+@@ -2545,7 +2545,7 @@ static void print_status_info(UnitStatusInfo *i) {
+ 
+         if (i->id && arg_transport != TRANSPORT_SSH) {
+                 printf("\n");
+-                show_journal_by_unit(i->id, arg_output, 0, i->inactive_exit_timestamp_monotonic, arg_lines, arg_all, arg_follow);
++                show_journal_by_unit(i->id, arg_output, 0, i->inactive_exit_timestamp_monotonic, arg_lines, arg_all, arg_follow, !arg_quiet);
+         }
+ 
+         if (i->need_daemon_reload)
+diff --git a/src/systemd/sd-journal.h b/src/systemd/sd-journal.h
+index f27e461..ded1bac 100644
+--- a/src/systemd/sd-journal.h
++++ b/src/systemd/sd-journal.h
+@@ -97,6 +97,9 @@ int sd_journal_seek_cursor(sd_journal *j, const char *cursor);
+ 
+ int sd_journal_get_cursor(sd_journal *j, char **cursor);
+ 
++int sd_journal_get_cutoff_realtime_usec(sd_journal *j, uint64_t *from, uint64_t *to);
++int sd_journal_get_cutoff_monotonic_usec(sd_journal *j, const sd_id128_t boot_id, uint64_t *from, uint64_t *to);
++
+ /* int sd_journal_query_unique(sd_journal *j, const char *field);      /\* missing *\/ */
+ /* int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_t *l); /\* missing *\/ */
+ /* void sd_journal_restart_unique(sd_journal *j);                      /\* missing *\/ */
diff --git a/0427-journal-fix-SD_JOURNAL_SYSTEM_ONLY-flag.patch b/0427-journal-fix-SD_JOURNAL_SYSTEM_ONLY-flag.patch
new file mode 100644
index 0000000..6889239
--- /dev/null
+++ b/0427-journal-fix-SD_JOURNAL_SYSTEM_ONLY-flag.patch
@@ -0,0 +1,24 @@
+From 7ee5322c274ecd7199165c4e2070186577f8498e Mon Sep 17 00:00:00 2001
+From: Lennart Poettering <lennart at poettering.net>
+Date: Sat, 9 Jun 2012 15:03:22 +0200
+Subject: [PATCH] journal: fix SD_JOURNAL_SYSTEM_ONLY flag (cherry picked from
+ commit 38a6db16dc6f3ac6e6f497c90e51fb9904d785ba)
+
+---
+ src/journal/sd-journal.c |    3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
+index 9fc7090..a91e94c 100644
+--- a/src/journal/sd-journal.c
++++ b/src/journal/sd-journal.c
+@@ -943,7 +943,8 @@ static int add_file(sd_journal *j, const char *prefix, const char *dir, const ch
+         assert(filename);
+ 
+         if ((j->flags & SD_JOURNAL_SYSTEM_ONLY) &&
+-            !startswith(filename, "system.journal"))
++            !(streq(filename, "system.journal") ||
++             (startswith(filename, "system@") && endswith(filename, ".journal"))))
+                 return 0;
+ 
+         if (dir)
diff --git a/0428-journal-rotate-on-SIGUSR2.patch b/0428-journal-rotate-on-SIGUSR2.patch
new file mode 100644
index 0000000..22012d5
--- /dev/null
+++ b/0428-journal-rotate-on-SIGUSR2.patch
@@ -0,0 +1,120 @@
+From 59b659288539442db922fa1909607cb0a8ba0bed Mon Sep 17 00:00:00 2001
+From: Lennart Poettering <lennart at poettering.net>
+Date: Sat, 9 Jun 2012 15:04:14 +0200
+Subject: [PATCH] journal: rotate on SIGUSR2 (cherry picked from commit
+ ba6b3039531a70466dd955c6faa9bf521b3dfbac)
+
+---
+ TODO                             |    6 ------
+ man/systemd-journald.service.xml |   33 +++++++++++++++++++++++++++++++++
+ src/journal/journald.c           |   11 +++++++++--
+ 3 files changed, 42 insertions(+), 8 deletions(-)
+
+diff --git a/TODO b/TODO
+index 5dfaf3d..7127b53 100644
+--- a/TODO
++++ b/TODO
+@@ -87,8 +87,6 @@ Features:
+ 
+ * figure out whether we should leave dbus around during shutdown
+ 
+-* add interface to allow immediate rotation of the journal, and even flushing.
+-
+ * dbus: in fedora, make the machine a symlink to /etc/machine-id
+ 
+ * journald: reuse XZ context
+@@ -123,14 +121,10 @@ Features:
+ 
+ * systemctl status: show coredumps
+ 
+-* systemctl status: show whether journal was rotated since service started
+-
+ * save coredump in Windows/Mozilla minidump format
+ 
+ * support crash reporting operation modes (https://live.gnome.org/GnomeOS/Design/Whiteboards/ProblemReporting)
+ 
+-* journal: allow per-entry control on /var vs. /run (think incognito browser mode)
+-
+ * clean up session cgroups that remain after logout (think sshd), but eventually run empty
+ 
+ * support "systemctl stop foobar at .service" to stop all units matching a certain template
+diff --git a/man/systemd-journald.service.xml b/man/systemd-journald.service.xml
+index 5d39c50..8ee0cf4 100644
+--- a/man/systemd-journald.service.xml
++++ b/man/systemd-journald.service.xml
+@@ -98,6 +98,39 @@
+         </refsect1>
+ 
+         <refsect1>
++                <title>Signals</title>
++
++                <variablelist>
++                        <varlistentry>
++                                <term>SIGUSR1</term>
++
++                                <listitem><para>Request that journal
++                                data from <filename>/run/</filename>
++                                is flushed to
++                                <filename>/var/</filename> in order to
++                                make it persistent (if this is
++                                enabled). This may be used after
++                                <filename>/var/</filename> is mounted,
++                                but is generally not required since
++                                the first journal write when
++                                <filename>/var/</filename> becomes
++                                writable triggers the flushing
++                                anyway.</para></listitem>
++                        </varlistentry>
++
++                        <varlistentry>
++                                <term>SIGUSR2</term>
++
++                                <listitem><para>Request immediate
++                                rotation of the journal
++                                files.</para></listitem>
++                        </varlistentry>
++                </variablelist>
++        </refsect1>
++
++
++
++        <refsect1>
+                 <title>See Also</title>
+                 <para>
+                         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
+diff --git a/src/journal/journald.c b/src/journal/journald.c
+index bd62999..3fca09f 100644
+--- a/src/journal/journald.c
++++ b/src/journal/journald.c
+@@ -2143,6 +2143,7 @@ static int server_flush_proc_kmsg(Server *s) {
+ 
+ static int process_event(Server *s, struct epoll_event *ev) {
+         assert(s);
++        assert(ev);
+ 
+         if (ev->data.fd == s->signal_fd) {
+                 struct signalfd_siginfo sfsi;
+@@ -2167,7 +2168,13 @@ static int process_event(Server *s, struct epoll_event *ev) {
+ 
+                 if (sfsi.ssi_signo == SIGUSR1) {
+                         server_flush_to_var(s);
+-                        return 0;
++                        return 1;
++                }
++
++                if (sfsi.ssi_signo == SIGUSR2) {
++                        server_rotate(s);
++                        server_vacuum(s);
++                        return 1;
+                 }
+ 
+                 log_debug("Received SIG%s", signal_to_string(sfsi.ssi_signo));
+@@ -2558,7 +2565,7 @@ static int open_signalfd(Server *s) {
+         assert(s);
+ 
+         assert_se(sigemptyset(&mask) == 0);
+-        sigset_add_many(&mask, SIGINT, SIGTERM, SIGUSR1, -1);
++        sigset_add_many(&mask, SIGINT, SIGTERM, SIGUSR1, SIGUSR2, -1);
+         assert_se(sigprocmask(SIG_SETMASK, &mask, NULL) == 0);
+ 
+         s->signal_fd = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC);
diff --git a/0429-journal-fix-monotonic-seeking.patch b/0429-journal-fix-monotonic-seeking.patch
new file mode 100644
index 0000000..4a83d48
--- /dev/null
+++ b/0429-journal-fix-monotonic-seeking.patch
@@ -0,0 +1,28 @@
+From 5cdbddf63621119eb40780f2e9143fe7a35b20a5 Mon Sep 17 00:00:00 2001
+From: Lennart Poettering <lennart at poettering.net>
+Date: Sat, 9 Jun 2012 15:20:42 +0200
+Subject: [PATCH] journal: fix monotonic seeking (cherry picked from commit
+ 10b6f904cc58c5a725f123e17819516eca606a3e)
+
+---
+ src/journal/journal-file.c |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
+index d0a14c2..f2b5bc5 100644
+--- a/src/journal/journal-file.c
++++ b/src/journal/journal-file.c
+@@ -1400,11 +1400,11 @@ int journal_file_move_to_entry_by_monotonic(
+                 Object **ret,
+                 uint64_t *offset) {
+ 
+-        char t[8+32+1] = "_BOOT_ID=";
++        char t[9+32+1] = "_BOOT_ID=";
+         Object *o;
+         int r;
+ 
+-        sd_id128_to_string(boot_id, t + 8);
++        sd_id128_to_string(boot_id, t + 9);
+ 
+         r = journal_file_find_data_object(f, t, strlen(t), &o, NULL);
+         if (r < 0)
diff --git a/0430-systemd-return-error-when-asked-to-stop-unknown-unit.patch b/0430-systemd-return-error-when-asked-to-stop-unknown-unit.patch
new file mode 100644
index 0000000..49d1711
--- /dev/null
+++ b/0430-systemd-return-error-when-asked-to-stop-unknown-unit.patch
@@ -0,0 +1,30 @@
+From ef5fc8087d3b22bd826167a59305b3e8e15f8d68 Mon Sep 17 00:00:00 2001
+From: Michal Sekletar <msekleta at redhat.com>
+Date: Tue, 19 Jun 2012 10:00:54 +0200
+Subject: [PATCH] systemd: return error when asked to stop unknown unit
+
+Command systemctl stop foo.service, will print error message, when
+foo.service is unknown to systemd, i.e. there is no unit file loaded for
+this service.
+https://bugzilla.redhat.com/show_bug.cgi?id=732874
+(cherry picked from commit 9722ef2565fdddd64deaa99d7665ca0fdafed1a5)
+---
+ src/core/dbus-manager.c |    5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
+index aaaeec4..a610a6b 100644
+--- a/src/core/dbus-manager.c
++++ b/src/core/dbus-manager.c
+@@ -1594,6 +1594,11 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
+                                 job_type = JOB_RELOAD;
+                 }
+ 
++                if (job_type == JOB_STOP && u->load_state == UNIT_ERROR && unit_active_state(u) == UNIT_INACTIVE) {
++                        dbus_set_error(&error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s not loaded.", name);
++                        return bus_send_error_reply(connection, message, &error, -EPERM);
++                }
++
+                 if ((job_type == JOB_START && u->refuse_manual_start) ||
+                     (job_type == JOB_STOP && u->refuse_manual_stop) ||
+                     ((job_type == JOB_RESTART || job_type == JOB_TRY_RESTART) &&
diff --git a/systemd.spec b/systemd.spec
index d0198fc..f2aab1d 100644
--- a/systemd.spec
+++ b/systemd.spec
@@ -3,7 +3,7 @@
 Name:           systemd
 Url:            http://www.freedesktop.org/wiki/Software/systemd
 Version:        44
-Release:        14%{?gitcommit:.git%{gitcommit}}%{?dist}
+Release:        15%{?gitcommit:.git%{gitcommit}}%{?dist}
 License:        GPLv2+
 Group:          System Environment/Base
 Summary:        A System and Service Manager
@@ -479,6 +479,17 @@ Patch0416:      0416-systemctl-warn-about-all-active-triggers-not-just-so.patch
 Patch0417:      0417-unit-name-introduce-unit_dbus_path_from_name.patch
 Patch0418:      0418-tmpfiles-create-char-devices-with-correct-SELinux-co.patch
 Patch0419:      0419-systemctl-clearer-error-message-for-missing-install-.patch
+Patch0420:      0420-service-timeout-for-oneshot-services.patch
+Patch0421:      0421-logind-more-robust-handling-of-VT-less-systems.patch
+Patch0422:      0422-journal-replace-arena-offset-by-header-size.patch
+Patch0423:      0423-journal-add-basic-object-definition-for-signatures.patch
+Patch0424:      0424-journal-correct-list-link-up-on-hash-collisions.patch
+Patch0425:      0425-F17-fix-libsystemd-journal-symver-script.patch
+Patch0426:      0426-journal-expose-and-make-use-of-cutoff-times-of-journ.patch
+Patch0427:      0427-journal-fix-SD_JOURNAL_SYSTEM_ONLY-flag.patch
+Patch0428:      0428-journal-rotate-on-SIGUSR2.patch
+Patch0429:      0429-journal-fix-monotonic-seeking.patch
+Patch0430:      0430-systemd-return-error-when-asked-to-stop-unknown-unit.patch
 
 # For sysvinit tools
 Obsoletes:      SysVinit < 2.86-24, sysvinit < 2.86-24
@@ -856,6 +867,12 @@ mv /etc/systemd/system/default.target.save /etc/systemd/system/default.target >/
 %{_bindir}/systemd-analyze
 
 %changelog
+* Tue Jun 19 2012 Michal Schmidt <mschmidt at redhat.com> - 44-15
+- Apply timeouts to oneshot services (#761656)
+- Report error when stopping an unknown unit (#732874)
+- logind: more robust on VT-less systems (s390x) (#832210)
+- journal: various fixes, expose cutoff times
+
 * Thu Jun 14 2012 Michal Schmidt <mschmidt at redhat.com> - 44-14
 - tmpfiles: correct SELinux context for char devices (#824059)
 - systemctl: warn when stopping a triggerable unit (#714525)


More information about the scm-commits mailing list