diff --git a/man/.dir-locals.el b/man/.dir-locals.el new file mode 100644 index 0000000000..1c2512052d --- /dev/null +++ b/man/.dir-locals.el @@ -0,0 +1,14 @@ +; special .c mode with reduced indentation for man pages +((nil . ((indent-tabs-mode . nil) + (tab-width . 8) + (fill-column . 79))) + (c-mode . ((fill-column . 80) + (c-basic-offset . 2) + (eval . (c-set-offset 'substatement-open 0)) + (eval . (c-set-offset 'statement-case-open 0)) + (eval . (c-set-offset 'case-label 0)) + (eval . (c-set-offset 'arglist-intro '++)) + (eval . (c-set-offset 'arglist-close 0)))) + (nxml-mode . ((nxml-child-indent . 2) + (fill-column . 119))) + (meson-mode . ((meson-indent-basic . 8)))) diff --git a/man/glib-event-glue.c b/man/glib-event-glue.c index 32d8e921b8..6349485b3a 100644 --- a/man/glib-event-glue.c +++ b/man/glib-event-glue.c @@ -1,70 +1,49 @@ -/*** - SPDX-License-Identifier: MIT - - Copyright 2014 Tom Gundersen - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation files - (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, - publish, distribute, sublicense, and/or sell copies of the Software, - and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -***/ +/* SPDX-License-Identifier: MIT */ +/* Copyright 2014 Tom Gundersen */ #include +#include +#include typedef struct SDEventSource { - GSource source; - GPollFD pollfd; - sd_event *event; + GSource source; + GPollFD pollfd; + sd_event *event; } SDEventSource; static gboolean event_prepare(GSource *source, gint *timeout_) { - return sd_event_prepare(((SDEventSource *)source)->event) > 0; + return sd_event_prepare(((SDEventSource *)source)->event) > 0; } static gboolean event_check(GSource *source) { - return sd_event_wait(((SDEventSource *)source)->event, 0) > 0; + return sd_event_wait(((SDEventSource *)source)->event, 0) > 0; } static gboolean event_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) { - return sd_event_dispatch(((SDEventSource *)source)->event) > 0; + return sd_event_dispatch(((SDEventSource *)source)->event) > 0; } static void event_finalize(GSource *source) { - sd_event_unref(((SDEventSource *)source)->event); + sd_event_unref(((SDEventSource *)source)->event); } static GSourceFuncs event_funcs = { - .prepare = event_prepare, - .check = event_check, - .dispatch = event_dispatch, - .finalize = event_finalize, + .prepare = event_prepare, + .check = event_check, + .dispatch = event_dispatch, + .finalize = event_finalize, }; GSource *g_sd_event_create_source(sd_event *event) { - SDEventSource *source; + SDEventSource *source; - source = (SDEventSource *)g_source_new(&event_funcs, sizeof(SDEventSource)); + source = (SDEventSource *)g_source_new(&event_funcs, sizeof(SDEventSource)); - source->event = sd_event_ref(event); - source->pollfd.fd = sd_event_get_fd(event); - source->pollfd.events = G_IO_IN | G_IO_HUP | G_IO_ERR; + source->event = sd_event_ref(event); + source->pollfd.fd = sd_event_get_fd(event); + source->pollfd.events = G_IO_IN | G_IO_HUP | G_IO_ERR; - g_source_add_poll((GSource *)source, &source->pollfd); + g_source_add_poll((GSource *)source, &source->pollfd); - return (GSource *)source; + return (GSource *)source; } diff --git a/man/journal-iterate-poll.c b/man/journal-iterate-poll.c new file mode 100644 index 0000000000..100d07e202 --- /dev/null +++ b/man/journal-iterate-poll.c @@ -0,0 +1,25 @@ +#include +#include +#include + +int wait_for_changes(sd_journal *j) { + uint64_t t; + int msec; + struct pollfd pollfd; + + sd_journal_get_timeout(j, &t); + if (t == (uint64_t) -1) + msec = -1; + else { + struct timespec ts; + uint64_t n; + clock_gettime(CLOCK_MONOTONIC, &ts); + n = (uint64_t) ts.tv_sec * 1000000 + ts.tv_nsec / 1000; + msec = t > n ? (int) ((t - n + 999) / 1000) : 0; + } + + pollfd.fd = sd_journal_get_fd(j); + pollfd.events = sd_journal_get_events(j); + poll(&pollfd, 1, msec); + return sd_journal_process(j); +} diff --git a/man/journal-iterate-wait.c b/man/journal-iterate-wait.c new file mode 100644 index 0000000000..0a23569f79 --- /dev/null +++ b/man/journal-iterate-wait.c @@ -0,0 +1,39 @@ +#include +#include +#include + +int main(int argc, char *argv[]) { + int r; + sd_journal *j; + r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY); + if (r < 0) { + fprintf(stderr, "Failed to open journal: %s\n", strerror(-r)); + return 1; + } + for (;;) { + const void *d; + size_t l; + r = sd_journal_next(j); + if (r < 0) { + fprintf(stderr, "Failed to iterate to next entry: %s\n", strerror(-r)); + break; + } + if (r == 0) { + /* Reached the end, let's wait for changes, and try again */ + r = sd_journal_wait(j, (uint64_t) -1); + if (r < 0) { + fprintf(stderr, "Failed to wait for changes: %s\n", strerror(-r)); + break; + } + continue; + } + r = sd_journal_get_data(j, "MESSAGE", &d, &l); + if (r < 0) { + fprintf(stderr, "Failed to read message field: %s\n", strerror(-r)); + continue; + } + printf("%.*s\n", (int) l, (const char*) d); + } + sd_journal_close(j); + return 0; +} diff --git a/man/journalctl.xml b/man/journalctl.xml index 37fb0d67fd..be2916c0c1 100644 --- a/man/journalctl.xml +++ b/man/journalctl.xml @@ -752,7 +752,7 @@ - Removes archived journal files until the disk + Removes the oldest archived journal files until the disk space they use falls below the specified size (specified with the usual K, M, G and T suffixes), or all @@ -930,7 +930,8 @@ With one match specified, all entries with a field matching the expression are shown: - journalctl _SYSTEMD_UNIT=avahi-daemon.service + journalctl _SYSTEMD_UNIT=avahi-daemon.service +journalctl _SYSTEMD_CGROUP=/user.slice/user-42.slice/session-c1.scope If two different fields are matched, only entries matching both expressions at the same time are shown: @@ -950,6 +951,19 @@ journalctl _SYSTEMD_UNIT=avahi-daemon.service _PID=28097 + _SYSTEMD_UNIT=dbus.service + To show all fields emited by a unit and about + the unit, option / should be used. + journalctl -u name + expands to a complex filter similar to + _SYSTEMD_UNIT=name.service + + UNIT=name.service _PID=1 + + OBJECT_SYSTEMD_UNIT=name.service _UID=0 + + COREDUMP_UNIT=name.service _UID=0 MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1 + + (see systemd.journal-fields5 + for an explanation of those patterns). + + Show all logs generated by the D-Bus executable: journalctl /usr/bin/dbus-daemon diff --git a/man/pam_systemd.xml b/man/pam_systemd.xml index f45631688c..a769a49bbe 100644 --- a/man/pam_systemd.xml +++ b/man/pam_systemd.xml @@ -255,8 +255,11 @@ for, if any. (Only applies to seats with a VT available, such as seat0) - + + If not set, pam_systemd will determine the + values for $XDG_SEAT and $XDG_VTNR + based on the $DISPLAY variable. diff --git a/man/sd_journal_get_fd.xml b/man/sd_journal_get_fd.xml index b15fc1728c..f51fbc3415 100644 --- a/man/sd_journal_get_fd.xml +++ b/man/sd_journal_get_fd.xml @@ -23,7 +23,7 @@ along with systemd; If not, see . --> - + sd_journal_get_fd @@ -263,73 +263,13 @@ else { Iterating through the journal, in a live view tracking all changes: - #include <stdio.h> -#include <string.h> -#include <systemd/sd-journal.h> - -int main(int argc, char *argv[]) { - int r; - sd_journal *j; - r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY); - if (r < 0) { - fprintf(stderr, "Failed to open journal: %s\n", strerror(-r)); - return 1; - } - for (;;) { - const void *d; - size_t l; - r = sd_journal_next(j); - if (r < 0) { - fprintf(stderr, "Failed to iterate to next entry: %s\n", strerror(-r)); - break; - } - if (r == 0) { - /* Reached the end, let's wait for changes, and try again */ - r = sd_journal_wait(j, (uint64_t) -1); - if (r < 0) { - fprintf(stderr, "Failed to wait for changes: %s\n", strerror(-r)); - break; - } - continue; - } - r = sd_journal_get_data(j, "MESSAGE", &d, &l); - if (r < 0) { - fprintf(stderr, "Failed to read message field: %s\n", strerror(-r)); - continue; - } - printf("%.*s\n", (int) l, (const char*) d); - } - sd_journal_close(j); - return 0; -} + Waiting with poll() (this example lacks all error checking for the sake of simplicity): - #include <poll.h> -#include <systemd/sd-journal.h> - -int wait_for_changes(sd_journal *j) { - struct pollfd pollfd; - int msec; - - sd_journal_get_timeout(m, &t); - if (t == (uint64_t) -1) - msec = -1; - else { - struct timespec ts; - uint64_t n; - clock_gettime(CLOCK_MONOTONIC, &ts); - n = (uint64_t) ts.tv_sec * 1000000 + ts.tv_nsec / 1000; - msec = t > n ? (int) ((t - n + 999) / 1000) : 0; - } - - pollfd.fd = sd_journal_get_fd(j); - pollfd.events = sd_journal_get_events(j); - poll(&pollfd, 1, msec); - return sd_journal_process(j); -} + diff --git a/man/systemd-gpt-auto-generator.xml b/man/systemd-gpt-auto-generator.xml index 3fbe215c41..a02eabba6d 100644 --- a/man/systemd-gpt-auto-generator.xml +++ b/man/systemd-gpt-auto-generator.xml @@ -62,8 +62,9 @@ generator that automatically discovers root, /home, /srv and swap partitions and creates mount and swap units for them, based on the - partition type GUIDs of GUID partition tables (GPT). It implements - the UEFI Specification, chapter 5. + It implements the Discoverable Partitions Specification. Note that this generator has no effect on non-GPT systems, or where the directories under the @@ -78,13 +79,13 @@ same physical disk the EFI System Partition (ESP) is located on. It will only look for the other partitions on the same physical disk the root file system is located on. These partitions will not - be searched on systems where the root file system is distributed + be searched for on systems where the root file system is distributed on multiple disks, for example via btrfs RAID. systemd-gpt-auto-generator is useful for centralizing file system configuration in the partition table - and making manual configuration in /etc/fstab - or suchlike unnecessary. + and making configuration in /etc/fstab unnecessary. + This generator looks for the partitions based on their partition type GUID. The following partition type GUIDs are @@ -153,6 +154,48 @@ + This generator understands the following attribute flags for partitions: + + + Partition Attributes + + + + + + + + Name + Value + Applicable to + Explanation + + + + + GPT_FLAG_READ_ONLY + 0x1000000000000000 + /, /srv, /home + Partition is mounted read-only + + + + GPT_FLAG_NO_AUTO + 0x8000000000000000 + /, /srv, /home + Partition is not mounted automatically + + + + GPT_FLAG_NO_BLOCK_IO_PROTOCOL + 0x0000000000000002 + ESP + Partition is not mounted automatically + + + +
+ The /home and /srv partitions may be encrypted in LUKS format. In this case, a device mapper device is set up under the names diff --git a/man/systemd-journald.service.xml b/man/systemd-journald.service.xml index 8ca0e896ab..d78aef3a63 100644 --- a/man/systemd-journald.service.xml +++ b/man/systemd-journald.service.xml @@ -261,9 +261,7 @@ systemd-tmpfiles --create --prefix /var/log/journal /etc/systemd/journald.conf - Configure - systemd-journald - behavior. See + Configure systemd-journald behavior. See journald.conf5. @@ -274,8 +272,7 @@ systemd-tmpfiles --create --prefix /var/log/journal /var/log/journal/machine-id/*.journal /var/log/journal/machine-id/*.journal~ - systemd-journald writes - entries to files in + systemd-journald writes entries to files in /run/log/journal/machine-id/ or /var/log/journal/machine-id/ @@ -287,7 +284,24 @@ systemd-tmpfiles --create --prefix /var/log/journal /var/log/journal is not available, or when is set in the journald.conf5 - configuration file. + configuration file. + + When systemd-journald ceases writing to a journal file, + it will be renamed to original-name@suffix.journal + (or original-name@suffix.journal~). + Such files are "archived" and will not be written to any more. + + In general, it is safe to read or copy any journal file (active or archived). + journalctl1 + and the functions in the + sd-journal3 + library should be able to read all entries that have been fully written. + + systemd-journald will automatically remove the oldest + archived journal files to limit disk use. See SystemMaxUse= + and related settings in + journald.conf5. + diff --git a/man/systemd-nspawn.xml b/man/systemd-nspawn.xml index 633d939384..55ef48bfec 100644 --- a/man/systemd-nspawn.xml +++ b/man/systemd-nspawn.xml @@ -519,8 +519,10 @@ configured with . If this option is specified, the CAP_NET_ADMIN capability will be added to the set of capabilities the container retains. The - latter may be disabled by using - .
+ latter may be disabled by using . + If this option is not specified (or implied by one of the options + listed below), the container will have full access to the host network. + diff --git a/src/core/service.c b/src/core/service.c index 588f08fef3..a39c95da55 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -3399,10 +3399,15 @@ static int service_dispatch_timer(sd_event_source *source, usec_t usec, void *us break; case SERVICE_AUTO_RESTART: - log_unit_info(UNIT(s), - s->restart_usec > 0 ? - "Service hold-off time over, scheduling restart." : - "Service has no hold-off time, scheduling restart."); + if (s->restart_usec > 0) { + char buf_restart[FORMAT_TIMESPAN_MAX]; + log_unit_info(UNIT(s), + "Service RestartSec=%s expired, scheduling restart.", + format_timespan(buf_restart, sizeof buf_restart, s->restart_usec, USEC_PER_SEC)); + } else + log_unit_info(UNIT(s), + "Service has no hold-off time (RestartSec=0), scheduling restart."); + service_enter_restart(s); break;