Commit graph

295 commits

Author SHA1 Message Date
Lennart Poettering 39c155ea0d journal: add sd_journal_get_timeout() call to public API
Let's do the wake-up logic on NFS internally, making things simpler for
users.
2013-04-04 20:07:48 +02:00
Lennart Poettering ee531d949c journal: add public API call sd_journal_get_events()
This function should be used when filling in "struct pollfd"'s .events
field for watching the journal. It will always return POLLIN for now,
but we should keep our options open to change this later on.

This mimics libsystemd-bus' sd_bus_get_events() call with the same
purpose.
2013-04-04 17:22:28 +02:00
Zbigniew Jędrzejewski-Szmek 844ec79b3c catalog: open up catalog internals
In order to write tests for the catalog functions, they
are made non-static and start taking a 'database' parameter,
which is the name of a file with the preprocessed catalog
entries.

This makes it possible to make test-catalog part of the
normal test suite, since it now only operates on files
in /tmp.

Some more tests are added.
2013-03-28 23:45:59 -04:00
Lennart Poettering 54b1da83ed journal: don't access j->files after use
https://bugs.freedesktop.org/show_bug.cgi?id=62605
2013-03-23 04:14:20 +01:00
Lennart Poettering 3ac251b81a journalctl: various fixes to the access check logic
- Reword messages a bit

- Correct check whether EACCES is in the set of errors

- Don't complain if no journal files are found

- allocate Set object for errors lazily since in the best case we don't
  need it at all.

- don't consider it an error if /run/log/journal doesn't exist (because
  that's the usual case actually, if storage is enabled)
2013-03-23 01:12:22 +01:00
Zbigniew Jędrzejewski-Szmek 6fe391c56d journalctl: be smarter about journal error checks
There are many ways in which we can get those checks wrong, so it is
better to warn and then error out on a real access failure.

The error messages are wrapped to <80 lines, because their primary
use is to be displayed in the terminal, and it is easier to read them
this way. Reading them in the journal can be a bit trickier, but
this is a bug in logs-show.c.
2013-03-22 15:31:45 -04:00
Zbigniew Jędrzejewski-Szmek 8cb17a6dc8 sd-journal: do not require path to be absolute
Seems natural to be able to specify relative directory,
e.g. with journalctl -D. And even if, this should be checked
in front-end code, not in the library.
2013-03-18 19:49:33 -04:00
Zbigniew Jędrzejewski-Szmek a50d7d4389 journal: use _cleanup_
One log_debug() moved to match order in other functions.
2013-03-18 18:53:59 -04:00
Zbigniew Jędrzejewski-Szmek 6180fc611b journal: use sd_journal_close on error in sd_journal_new 2013-03-18 18:53:59 -04:00
Zbigniew Jędrzejewski-Szmek 99613ec5d7 libsystemd-journal: return 0 on success in get_data()
The man page says so. Right now 0 would be returned if the data was encrypted,
1 otherwise.
2013-03-07 00:45:56 -05:00
Zbigniew Jędrzejewski-Szmek d95b1fb315 log-show: look at everything in /run/log/journal
Logs written by journald from the initramfs may be written to a
directory with the name created from a random machine-id. Afterwards,
when the root filesystem has been mounted and machine-id reinitalized,
logs will be written to the directory with a name created from the
proper machine-id. When logs are flushed to /var/log/journal,
everything is copied to one output directory.

When journalctl without '-m' is run after the logs have been flushed
to /var/log/journal, all messages are shown. However, when run while
logs are still in /run/log/journal, those stored under the random
machine-id will not be shown.

Make journalctl behave the same regardless whether persistent storage
has been enabled or not, and slurp all files from /run/log/journal
even without '-m'.
2013-02-26 23:16:58 -05:00
Zbigniew Jędrzejewski-Szmek 6f47ad3025 journal: sd_journal_get_cursor should return 0 on success
Documentation states that 0 is correct, and all other
similar functions return 0 on success.

Pointed-out-by: Steven Hiscocks <steven-systemd@hiscocks.me.uk>
2013-02-22 11:19:00 +01:00
Lennart Poettering 93b73b064c journal: by default do not decompress dat objects larger than 64K
This introduces a new data threshold setting for sd_journal objects
which controls the maximum size of objects to decompress. This is
relieves the library from having to decompress full data objects even
if a client program is only interested in the initial part of them.

This speeds up "systemd-coredumpctl" drastically when invoked without
parameters.
2012-11-21 00:28:00 +01:00
Lennart Poettering 8f1e860f8a journal: add sd_journal_get_catalog_for_message_id() as API to get catalog entry for any message ID without requiring an open journal file 2012-11-20 21:39:16 +01:00
Zbigniew Jędrzejewski-Szmek 943aad8ca5 journal, shared: fix warnings during compilation on 32 bits
Some filesystem magics are too big to fit in 31 bits,
and are wrapped to negative. f_type is an int on 32 bits, so
it is signed, and we get a warning on comparison.
2012-11-16 23:26:44 +01:00
Lennart Poettering d4205751d4 journal: implement message catalog
The message catalog can be used to attach short help texts to log lines,
keyed by their MESSAGE_ID= fields. This is useful to help the
administrator understand the context and cause of a message, find
possible solutions and find further related documentation.

Since this is keyed off MESSAGE_ID= this will only work for native
journal messages.

The message catalog supports i18n, and is useful to augment english
language system messages with explanations in the local language.

This commit only includes short explanatory messages for a few example
message IDs, we'll add more complete documentation for the relevant
systemd messages later on.
2012-11-15 23:09:07 +01:00
Lennart Poettering 85210bffd8 journal: provide an API that allows client to figure out whether they need to recheck the journal manually for changes in regular intervals
Network file systems generally do not offer inotify() that would work
across the network. We hence cannot rely on inotify() exclusiely in
those case. Provide an API to determine these cases, and suggest doing
manual regular rechecks.

Note that this is not complete yet, as we need to rescan journal dirs on
network file systems explicitly to find new/removed files
2012-10-26 20:07:33 +02:00
Lennart Poettering 0f91dd8749 journal: properly determine cutoff max date 2012-10-26 01:18:41 +02:00
Lennart Poettering bdc02927f7 journal: typo fix 2012-10-18 22:36:50 +02:00
Lennart Poettering d5c4ed623b journal: validate field name in sd_journal_query_unique() 2012-10-18 22:34:42 +02:00
Zbigniew Jędrzejewski-Szmek 115646c789 libsystemd-journal: export sd_journal_restart_unique 2012-10-18 19:18:20 +00:00
Lennart Poettering 3c1668da62 journal: add ability to list values a specified field can take in all entries of the journal
The new 'unique' API allows listing all unique field values that a field
specified by a field name can take in all entries of the journal. This
allows answering queries such as "What units logged to the journal?",
"What hosts have logged into the journal?", "Which boot IDs have logged
into the journal?".

Ultimately this allows implementation of tools similar to lastlog based
on journal data.

Note that listing these field values will not work for journal files
created with older journald, as the field values are not indexed in
older files.
2012-10-18 03:35:18 +02:00
Lennart Poettering 5e6870eab5 journalctl: properly track rotated journals in follow mode 2012-10-16 23:00:04 +02:00
Lennart Poettering 44a5fa34d9 sd-journal: fix bad memory access 2012-10-16 22:59:28 +02:00
Lennart Poettering c6511e859c journal: when browsing the journal via browse.html allow clicking on entries to show their details 2012-10-10 22:41:03 +02:00
Lennart Poettering 934a316cbf journal: drop path name from cursor strings
we had this mostly for debugging purposes and it was ignored when
parsing anyway, so let's get rid of it
2012-10-10 22:41:02 +02:00
Lennart Poettering a87247dd5d journal: make sure sd_journal_seek_cursor() seeks to the specified entry if it exists, not one after it 2012-10-10 01:34:27 +02:00
Lennart Poettering be3ea5eaf2 sd-journal: properly parse cursor strings 2012-09-28 00:55:24 +02:00
Lennart Poettering 7d5e9c0f60 util: define union dirent_storage and make use of it everywhere
Make sure to allocate enough space for readdir_r().

https://bugzilla.redhat.com/show_bug.cgi?id=858754
2012-09-19 22:21:09 +02:00
Lennart Poettering 468b21de7c journal: when comparing two entries from separate files make sure we reposition the mmap window
The mmap cache doesn't guarantee that we can look at two files at the
same time. Hence make sure to look at the entries to compare one
after the other, instead of at the same time when comparing them, and
reposition the window in between.
2012-09-19 09:58:34 +02:00
Lennart Poettering a1a03e3075 journal: add call to determine current journal file disk usage 2012-09-07 23:20:28 +02:00
Lukas Nykryn f284860764 sd-journal: return null when mmap_cache_new fails 2012-08-23 13:53:30 +02:00
Lennart Poettering 84168d8068 mmap: resize arrays dynamically 2012-08-18 01:46:20 +02:00
Lennart Poettering 16e9f408fa journal: implement generic sharable mmap caching logic
instead of having one simple per-file cache implement an more
comprehensive one that works for multiple files and can actually
maintain multiple maps per file and per object type.
2012-08-16 17:10:56 +02:00
Lennart Poettering 7560fffcd2 journald: initial version of FSPRG hookup
This adds forward-secure authentication of journal files. This patch
includes key generation as well as tagging of journal files,
Verification of journal files will be added in a later patch.
2012-08-13 20:31:10 +02:00
Lennart Poettering de2c390731 journalctl: include corrupted files in output
If a journal file was rotated away because it was corrupted or dirty we
should still show its contents via "journalctl".
2012-08-07 00:51:17 +02:00
Lennart Poettering 4a842cadb8 journal: allow watching symlinked journal dirs 2012-07-19 03:22:07 +02:00
Lennart Poettering 7827b1a10f journal: when watching directories actually watch the directories asked for 2012-07-19 03:21:49 +02:00
Lennart Poettering 6f5878a286 journal: follow symlinks when enumerating journals 2012-07-19 02:35:17 +02:00
Lennart Poettering 9f8d29834b journald: don't choke on journal files with no cutoff date 2012-07-19 02:03:22 +02:00
Lennart Poettering 4a92baf3fa journal: size journal data hash table based on maximum file size metrics
The default of 2047 hash table entries turned out to result in way too
many collisions for bigger files, hence scale the hash table size by the
estimated maximum file size.
2012-07-17 00:59:03 +02:00
Lennart Poettering dca6219e04 journal: automatically rotate journal files if the data hash table is full > 75%
Previously, when the main data hash table grows too full the performance
simply started to decrease drastically. Instead, now simply rotate to a
new journal file as the hash table gets to full, so that we can start
with a new fresh empty hash table.
2012-07-17 00:59:03 +02:00
Ville Skyttä 49f43d5f91 Spelling fixes. 2012-07-16 12:16:29 +02:00
Kay Sievers 19d1e4eeb6 journal: align byte-buffer that gets cased to an object
On Sun, Jul 15, 2012 at 2:00 PM, Koen Kooi <koen@dominion.thruhere.net> wrote:
> | src/journal/sd-journal.c: In function 'sd_journal_process':
> | src/journal/sd-journal.c:1891:21: warning: cast increases required alignment of target type [-Wcast-align]
> | src/journal/sd-journal.c:1900:29: warning: cast increases required alignment of target type [-Wcast-align]
2012-07-15 14:58:29 +02:00
Lennart Poettering b7def68494 util: rename join() to strjoin()
This is to match strappend() and the other string related functions.
2012-07-13 13:41:01 +02:00
Lennart Poettering cbdca8525b journal: beef up journal matches considerably
we now can take multiple matches, and they will apply as AND if they
apply to different fields and OR if they apply to the same fields. Also,
terms of this kind can be combined with an overreaching OR.
2012-07-13 00:32:32 +02:00
Lennart Poettering 362a3f8122 journal: check fields we search for more carefully 2012-07-13 00:32:32 +02:00
Lennart Poettering c4aff78b2d journal: fix interleaving of files with different time sources 2012-07-13 00:32:32 +02:00
Lennart Poettering 14a65d65a0 journalctl: add a marker to log output for reboots
With this we'll print a marker "----- Reboot -----" between two
subsequent lines with different boot IDs.
2012-07-11 01:36:55 +02:00
Lennart Poettering a963990ff4 journal: rework directory enumeration/watch logic
There's now sd_journal_new_directory() for watching specific journal
directories. This is exposed in journalctl -D.

sd_journal_wait() and sd_journal_process() now return whether changes in
the journal are invalidating or just appending.

We now create inotify kernel watches only when we actually need them
2012-07-11 01:08:38 +02:00
Lennart Poettering e02d1cf72d journal: introduce sd_journal_wait() to simplify writing synchronous clients 2012-07-10 21:46:11 +02:00
Lennart Poettering e590af2666 journal: fix iteration through journal if one file is corrupt 2012-07-03 11:58:16 +02:00
Lennart Poettering 38a6db16dc journal: fix SD_JOURNAL_SYSTEM_ONLY flag 2012-06-17 00:03:12 +02:00
Lennart Poettering 089842938d 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.
2012-06-17 00:03:12 +02:00
Lennart Poettering d94117a93c journal: don't allow adding invalid matches to the context 2012-05-30 22:46:07 +02:00
Lennart Poettering ab4979d202 journalctl: for now complain if more than one match is provided since this is still broken 2012-05-30 22:30:35 +02:00
Kay Sievers 9eb977db5b util: split-out path-util.[ch] 2012-05-08 02:33:10 +02:00
Lennart Poettering 5430f7f2bc relicense to LGPLv2.1 (with exceptions)
We finally got the OK from all contributors with non-trivial commits to
relicense systemd from GPL2+ to LGPL2.1+.

Some udev bits continue to be GPL2+ for now, but we are looking into
relicensing them too, to allow free copy/paste of all code within
systemd.

The bits that used to be MIT continue to be MIT.

The big benefit of the relicensing is that closed source code may now
link against libsystemd-login.so and friends.
2012-04-12 00:24:39 +02:00
Lennart Poettering 6030831d5b journal: properly handle if we interleave files with different boot ids
If we try to locate a monotonic time in a file that doesn't have any
entries with the matching boot id, then don't fail on it, simply
fall back to calendar time.
2012-03-27 18:50:34 +02:00
Frederic Crozat 4fd052aede add sparse support to detect endianness bug
le16/32/64_t type should be used when storing little-endian value

header to integrate with sparse from Josh Triplett <josh@joshtriplett.org>
2012-03-22 01:09:37 +01:00
Marti Raudsepp 189f6d82ee journal: Don't hold pointers to journal while remapping
Hi!

I was trying out the journal and the journalctl utility sometimes
crashed on me. After some debugging, I tracked it down to the fact
that next_with_matches() holds the "c" object pointer through the
journal_file_next_entry_for_data() call -- which apparently may re-map
the journal file, invalidating the pointer.

The attached patch fixes this crash for me, but being unfamiliar with
the code, I don't know if I'm doing the right thing.

This patch is also available from my github repository:
git://github.com/intgr/systemd.git
https://github.com/intgr/systemd

Regards,
Marti

For the record, here's the original stack trace at the time of remapping:

ret=0x7fff1d5cdec0) at src/journal/journal-file.c:330
ret=0x7fff1d5cdf28) at src/journal/journal-file.c:414
ret=0x7fff1d5ce0a0, offset=0x7fff1d5ce098) at
src/journal/journal-file.c:1101
i=5705, ret=0x7fff1d5ce0a0, offset=0x7fff1d5ce098) at
src/journal/journal-file.c:1147
p=6413608, data_offset=66600, direction=DIRECTION_DOWN,
ret=0x7fff1d5ce0a0, offset=0x7fff1d5ce098) at
src/journal/journal-file.c:1626
direction=DIRECTION_DOWN, ret=0x7fff1d5ce120, offset=0x7fff1d5ce128)
at src/journal/sd-journal.c:533
direction=DIRECTION_DOWN, ret=0x7fff1d5ce170, offset=0x7fff1d5ce178)
at src/journal/sd-journal.c:595
src/journal/sd-journal.c:651

From 9266fc6a58065a7c5dab67430fd78925e519dce9 Mon Sep 17 00:00:00 2001
From: Marti Raudsepp <marti@juffo.org>
Date: Fri, 9 Mar 2012 16:23:00 +0200
Subject: [PATCH] journal: Don't hold pointers to journal while remapping

This would cause a segfault otherwise.
2012-03-14 17:55:55 +01:00
Dan Horák ce3fd7e72a journal: systemd v38 fails to build on big-endians
Hi,

during the builds for Fedora/s390x I've found that systemd v38 fails to
build on big-endian platforms.

...
make[2]: Entering directory `/root/systemd'
  CC     src/journal/libsystemd_journal_la-sd-journal.lo
src/journal/sd-journal.c: In function 'init_location':
src/journal/sd-journal.c:69:22: error: incompatible types when
initializing type 'long unsigned int' using type 'sd_id128_t'
src/journal/sd-journal.c:69:20: error: incompatible types when assigning
to type 'sd_id128_t' from type 'long unsigned int'
make[2]: *** [src/journal/libsystemd_journal_la-sd-journal.lo] Error 1

I see the problem in using le64toh() on the 16 bytes boot_id structure
in init_location()

Please see
http://s390.koji.fedoraproject.org/koji/taskinfo?taskID=544375 for a
full build log and attachment for a proposed fix.

With regards

Dan
2012-01-21 03:48:26 +01:00
Lennart Poettering 19a2bd80c1 sd-journal: implement a number of non-implemented calls from the API for now 2012-01-11 03:23:04 +01:00
Lennart Poettering df50185b43 journal: beef up journal output of systemctl and journalctl 2012-01-04 18:33:36 +01:00
Lennart Poettering 6f003b4304 journalctl: fix counting of -n parameter 2012-01-04 04:00:14 +01:00
Lennart Poettering cf5eb6a110 journal: fix reverse traversing of entries 2012-01-04 03:45:50 +01:00
Lennart Poettering b4e5f92017 journal: add missing error check 2012-01-04 03:45:24 +01:00
Lennart Poettering 9c4e3f2624 journal: don't mind too much if we can't find a monotonic timestamp 2012-01-04 03:45:14 +01:00
Lennart Poettering 4b067dc9d2 journal: add missing error check 2012-01-04 02:15:08 +01:00
Lennart Poettering a5344d2c3b journal: add _public_ to all sd-journal calls, and add parameter checks 2012-01-03 21:08:58 +01:00
Lennart Poettering cf244689e9 journald: flush /run to /var as soon as it becomes available 2011-12-29 15:00:57 +01:00
Lennart Poettering 24b51289e3 journal: fix typo 2011-12-27 22:52:22 +01:00
Lennart Poettering 6ad1d1c306 journald: enforce some syntax restrictions on field names sent from the client side 2011-12-22 00:35:04 +01:00
Lennart Poettering 72f597065c journalctl: add json, export, short and verbose output modes 2011-12-21 18:17:22 +01:00
Lennart Poettering 807e17f05e journal: add inline compression support with XZ 2011-12-21 02:40:59 +01:00
Lennart Poettering 466ccd92e2 journal: fix matches 2011-12-20 00:38:14 +01:00
Lennart Poettering 50f20cfdb0 journal: implement inotify-based live logging logic 2011-12-19 22:35:46 +01:00
Lennart Poettering cab8ac6083 journal: enforce limits on open journal files 2011-12-17 01:13:55 +01:00
Lennart Poettering de190aef08 journal: implement multiple field matches 2011-11-08 18:20:03 +01:00
Lennart Poettering 8f9b6cd9eb journal: automaticall reset location when the set of matches changes 2011-10-15 02:53:04 +02:00
Lennart Poettering 8725d60ae4 journal: implement seek to head/tail 2011-10-15 02:45:58 +02:00
Lennart Poettering e892bd1797 journal: unify code for up and for down traversal 2011-10-15 01:38:44 +02:00
Lennart Poettering de7b95cdc3 journal: properly implement matching with multiple matches 2011-10-15 01:13:37 +02:00
Lennart Poettering 1cc101f1e5 journal: if two entries match with everything but seqnums, they are still identical 2011-10-14 16:52:42 +02:00
Lennart Poettering 7210bfb370 journal: move field index from file into journal object 2011-10-14 05:38:40 +02:00
Lennart Poettering ae2cc8efc1 journal: when the same entry is in two files, skip over them in sync 2011-10-14 05:34:19 +02:00
Lennart Poettering c2373f848d journal: synchronize seqnum across files 2011-10-14 05:12:58 +02:00
Lennart Poettering 161e54f871 journal: fix field retrieval by name 2011-10-14 04:52:56 +02:00
Lennart Poettering 3fbf9cbb02 journal: implement parallel file traversal 2011-10-14 04:44:50 +02:00
Lennart Poettering 0ac38b7072 journal: implementation rotation 2011-10-13 05:19:35 +02:00
Lennart Poettering cec736d21f journal: implement parallel traversal in client 2011-10-08 02:21:05 +02:00
Lennart Poettering f4b4781191 journal: split user logs into their own journal files 2011-10-07 23:03:07 +02:00
Lennart Poettering 260a2be455 journal: replace linked list by hashmap when merging files 2011-10-07 22:02:06 +02:00
Lennart Poettering dad503169b journal: store XOR combination of entry data object hashes to identify hash lines 2011-10-07 22:02:06 +02:00
Lennart Poettering 87d2c1ff6a journal: add preliminary incomplete implementation 2011-10-07 22:02:05 +02:00