diff options
-rw-r--r-- | Makefile.am | 113 | ||||
-rw-r--r-- | man/hostname.xml | 4 | ||||
-rw-r--r-- | man/hostnamectl.xml | 8 | ||||
-rw-r--r-- | man/systemd.generator.xml | 15 | ||||
-rw-r--r-- | shell-completion/bash/journalctl | 13 | ||||
-rw-r--r-- | shell-completion/zsh/_busctl | 2 | ||||
-rw-r--r-- | src/basic/time-util.c | 46 | ||||
-rw-r--r-- | src/random-seed/random-seed.c | 22 | ||||
-rwxr-xr-x | test/TEST-03-JOBS/test-jobs.sh | 1 | ||||
-rwxr-xr-x | test/TEST-04-JOURNAL/test-journal.sh | 1 | ||||
-rwxr-xr-x | test/TEST-05-RLIMITS/test-rlimits.sh | 1 | ||||
-rwxr-xr-x | test/TEST-06-SELINUX/test-selinux-checks.sh | 1 | ||||
-rw-r--r-- | test/sys.tar.xz | bin | 165116 -> 261380 bytes | |||
-rwxr-xr-x | test/udev-test.pl | 4 |
14 files changed, 104 insertions, 127 deletions
diff --git a/Makefile.am b/Makefile.am index f1f8315f30..a3a473097b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -155,6 +155,14 @@ else noinst_PROGRAMS = TESTS = endif +if ENABLE_BASH_COMPLETION +dist_bashcompletion_DATA = $(dist_bashcompletion_data) +nodist_bashcompletion_DATA = $(nodist_bashcompletion_data) +endif +if ENABLE_ZSH_COMPLETION +dist_zshcompletion_DATA = $(dist_zshcompletion_data) +nodist_zshcompletion_DATA = $(nodist_zshcompletion_data) +endif udevlibexec_PROGRAMS = gperf_gperf_sources = @@ -165,6 +173,8 @@ m4_files = $(filter %.m4,$(EXTRA_DIST) $(in_files:.m4.in=.m4)) CLEANFILES = $(BUILT_SOURCES) \ $(pkgconfigdata_DATA) \ $(pkgconfiglib_DATA) \ + $(nodist_bashcompletion_data) \ + $(nodist_zshcompletion_data) \ $(in_files:.in=) $(in_in_files:.in.in=) \ $(m4_files:.m4=) @@ -416,8 +426,7 @@ systemgenerator_PROGRAMS = \ systemd-system-update-generator \ systemd-debug-generator -if ENABLE_BASH_COMPLETION -dist_bashcompletion_DATA = \ +dist_bashcompletion_data = \ shell-completion/bash/busctl \ shell-completion/bash/journalctl \ shell-completion/bash/systemd-analyze \ @@ -432,12 +441,10 @@ dist_bashcompletion_DATA = \ shell-completion/bash/udevadm \ shell-completion/bash/kernel-install -nodist_bashcompletion_DATA = \ +nodist_bashcompletion_data = \ shell-completion/bash/systemctl -endif -if ENABLE_ZSH_COMPLETION -dist_zshcompletion_DATA = \ +dist_zshcompletion_data = \ shell-completion/zsh/_busctl \ shell-completion/zsh/_journalctl \ shell-completion/zsh/_udevadm \ @@ -451,18 +458,13 @@ dist_zshcompletion_DATA = \ shell-completion/zsh/_systemd-delta \ shell-completion/zsh/_systemd -nodist_zshcompletion_DATA = \ +nodist_zshcompletion_data = \ shell-completion/zsh/_systemctl -endif EXTRA_DIST += \ shell-completion/bash/systemctl.in \ shell-completion/zsh/_systemctl.in -CLEANFILES += \ - $(nodist_bashcompletion_DATA) \ - $(nodist_zshcompletion_DATA) - dist_sysctl_DATA = \ sysctl.d/50-default.conf @@ -2396,10 +2398,8 @@ SYSINIT_TARGET_WANTS += \ systemd-tmpfiles-setup-dev.service \ systemd-tmpfiles-setup.service -if ENABLE_ZSH_COMPLETION -dist_zshcompletion_DATA += \ +dist_zshcompletion_data += \ shell-completion/zsh/_systemd-tmpfiles -endif TIMERS_TARGET_WANTS += \ systemd-tmpfiles-clean.timer @@ -2627,16 +2627,12 @@ bootctl_LDADD = \ bin_PROGRAMS += \ bootctl -if ENABLE_BASH_COMPLETION -dist_bashcompletion_DATA += \ +dist_bashcompletion_data += \ shell-completion/bash/bootctl -endif -if ENABLE_ZSH_COMPLETION -dist_zshcompletion_DATA += \ +dist_zshcompletion_data += \ shell-completion/zsh/_bootctl endif -endif # ------------------------------------------------------------------------------ if HAVE_GNUEFI @@ -2717,14 +2713,13 @@ systemd_boot_sources = \ EXTRA_DIST += $(systemd_boot_sources) $(systemd_boot_headers) -if ENABLE_EFI -if HAVE_GNUEFI systemd_boot_objects = $(addprefix $(top_builddir)/,$(systemd_boot_sources:.c=.o)) systemd_boot_solib = $(top_builddir)/src/boot/efi/systemd_boot.so systemd_boot = systemd-boot$(EFI_MACHINE_TYPE_NAME).efi +if ENABLE_EFI +if HAVE_GNUEFI bootlib_DATA = $(systemd_boot) -CLEANFILES += $(systemd_boot_objects) $(systemd_boot_solib) $(systemd_boot) $(top_builddir)/src/boot/efi/%.o: $(top_srcdir)/src/boot/efi/%.c $(addprefix $(top_srcdir)/,$(systemd_boot_headers)) @$(MKDIR_P) $(top_builddir)/src/boot/efi/ @@ -2741,6 +2736,8 @@ $(systemd_boot): $(systemd_boot_solib) endif endif +CLEANFILES += $(systemd_boot_objects) $(systemd_boot_solib) $(systemd_boot) + # ------------------------------------------------------------------------------ stub_headers = \ src/boot/efi/util.h \ @@ -2764,14 +2761,13 @@ EXTRA_DIST += \ $(stub_headers) \ test/splash.bmp -if ENABLE_EFI -if HAVE_GNUEFI stub_objects = $(addprefix $(top_builddir)/,$(stub_sources:.c=.o)) stub_solib = $(top_builddir)/src/boot/efi/stub.so stub = linux$(EFI_MACHINE_TYPE_NAME).efi.stub +if ENABLE_EFI +if HAVE_GNUEFI bootlib_DATA += $(stub) -CLEANFILES += $(stub_objects) $(stub_solib) $(stub) $(top_builddir)/src/boot/efi/%.o: $(top_srcdir)/src/boot/efi/%.c $(addprefix $(top_srcdir)/,$(stub_headers)) @$(MKDIR_P) $(top_builddir)/src/boot/efi/ @@ -2785,6 +2781,11 @@ $(stub_solib): $(stub_objects) $(stub): $(stub_solib) $(AM_V_GEN)$(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic \ -j .dynsym -j .rel -j .rela -j .reloc $(EFI_FORMAT) $< $@ +endif +endif + +CLEANFILES += $(stub_objects) $(stub_solib) $(stub) + # ------------------------------------------------------------------------------ CLEANFILES += test-efi-disk.img @@ -2794,8 +2795,6 @@ test-efi-disk.img: $(systemd_boot) $(stub) test/test-efi-create-disk.sh test-efi: test-efi-disk.img $(QEMU) -machine accel=kvm -m 1024 -bios $(QEMU_BIOS) -snapshot test-efi-disk.img -endif -endif EXTRA_DIST += test/test-efi-create-disk.sh @@ -4440,15 +4439,11 @@ test_coredump_vacuum_SOURCES = \ test_coredump_vacuum_LDADD = \ libshared.la -if ENABLE_BASH_COMPLETION -dist_bashcompletion_DATA += \ +dist_bashcompletion_data += \ shell-completion/bash/coredumpctl -endif -if ENABLE_ZSH_COMPLETION -dist_zshcompletion_DATA += \ +dist_zshcompletion_data += \ shell-completion/zsh/_coredumpctl -endif nodist_sysctl_DATA = \ sysctl.d/50-coredump.conf @@ -4699,16 +4694,12 @@ hostnamectl_LDADD = \ bin_PROGRAMS += \ hostnamectl -if ENABLE_BASH_COMPLETION -dist_bashcompletion_DATA += \ +dist_bashcompletion_data += \ shell-completion/bash/hostnamectl -endif -if ENABLE_ZSH_COMPLETION -dist_zshcompletion_DATA += \ +dist_zshcompletion_data += \ shell-completion/zsh/_hostnamectl endif -endif polkitpolicy_in_files += \ src/hostname/org.freedesktop.hostname1.policy.in @@ -4773,16 +4764,12 @@ localectl_LDADD = \ bin_PROGRAMS += \ localectl -if ENABLE_BASH_COMPLETION -dist_bashcompletion_DATA += \ +dist_bashcompletion_data += \ shell-completion/bash/localectl -endif -if ENABLE_ZSH_COMPLETION -dist_zshcompletion_DATA += \ +dist_zshcompletion_data += \ shell-completion/zsh/_localectl endif -endif .PHONY: update-kbd-model-map @@ -4833,16 +4820,12 @@ timedatectl_LDADD = \ bin_PROGRAMS += \ timedatectl -if ENABLE_BASH_COMPLETION -dist_bashcompletion_DATA += \ +dist_bashcompletion_data += \ shell-completion/bash/timedatectl -endif -if ENABLE_ZSH_COMPLETION -dist_zshcompletion_DATA += \ +dist_zshcompletion_data += \ shell-completion/zsh/_timedatectl endif -endif polkitpolicy_in_files += \ src/timedate/org.freedesktop.timedate1.policy.in @@ -4948,11 +4931,6 @@ machinectl_LDADD = \ rootbin_PROGRAMS += \ machinectl -if ENABLE_BASH_COMPLETION -dist_bashcompletion_DATA += \ - shell-completion/bash/machinectl -endif - test_machine_tables_SOURCES = \ src/machine/test-machine-tables.c @@ -4980,11 +4958,12 @@ dist_dbuspolicy_DATA += \ polkitpolicy_files += \ src/machine/org.freedesktop.machine1.policy -if ENABLE_ZSH_COMPLETION -dist_zshcompletion_DATA += \ +dist_bashcompletion_data += \ + shell-completion/bash/machinectl + +dist_zshcompletion_data += \ shell-completion/zsh/_machinectl \ shell-completion/zsh/_sd_machines -endif SYSTEM_UNIT_ALIASES += \ systemd-machined.service dbus-org.freedesktop.machine1.service @@ -5474,10 +5453,8 @@ networkctl_LDADD = \ libshared.la \ libsystemd-network.la -if ENABLE_BASH_COMPLETION -dist_bashcompletion_DATA += \ +dist_bashcompletion_data += \ shell-completion/bash/networkctl -endif test_network_SOURCES = \ src/network/test-network.c @@ -5607,16 +5584,12 @@ loginctl_LDADD = \ rootbin_PROGRAMS += \ loginctl -if ENABLE_BASH_COMPLETION -dist_bashcompletion_DATA += \ +dist_bashcompletion_data += \ shell-completion/bash/loginctl -endif -if ENABLE_ZSH_COMPLETION -dist_zshcompletion_DATA += \ +dist_zshcompletion_data += \ shell-completion/zsh/_loginctl \ shell-completion/zsh/_systemd-inhibit -endif systemd_inhibit_SOURCES = \ src/login/inhibit.c diff --git a/man/hostname.xml b/man/hostname.xml index 9688450e1c..8a4c0d5ac0 100644 --- a/man/hostname.xml +++ b/man/hostname.xml @@ -64,10 +64,6 @@ for DNS domain name labels, even though this is not a strict requirement.</para> - <para>Depending on the operating system, other configuration files - might be checked for configuration of the hostname as well, - however only as fallback.</para> - <para>You may use <citerefentry><refentrytitle>hostnamectl</refentrytitle><manvolnum>1</manvolnum></citerefentry> to change the value of this file during runtime from the command diff --git a/man/hostnamectl.xml b/man/hostnamectl.xml index b1f038156d..60004e9d04 100644 --- a/man/hostnamectl.xml +++ b/man/hostnamectl.xml @@ -66,10 +66,10 @@ high-level "pretty" hostname which might include all kinds of special characters (e.g. "Lennart's Laptop"), the static hostname which is used to initialize the kernel hostname at boot (e.g. - "lennarts-laptop"), and the transient hostname which is a default - received from network configuration. If a static hostname is set, - and is valid (something other than localhost), then the transient - hostname is not used.</para> + "lennarts-laptop"), and the transient hostname which is a fallback + value received from network configuration. If a static hostname is + set, and is valid (something other than localhost), then the + transient hostname is not used.</para> <para>Note that the pretty hostname has little restrictions on the characters used, while the static and transient hostnames are diff --git a/man/systemd.generator.xml b/man/systemd.generator.xml index 62658fb115..4b80dab108 100644 --- a/man/systemd.generator.xml +++ b/man/systemd.generator.xml @@ -164,13 +164,16 @@ Generators are run very early at boot and cannot rely on any external services. They may not talk to any other process. That includes simple things such as logging to - <citerefentry - project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>, + <citerefentry project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>, or <command>systemd</command> itself (this means: no - <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>!). They - can however rely on the most basic kernel functionality to - be available, including a mounted <filename>/sys</filename>, - <filename>/proc</filename>, <filename>/dev</filename>. + <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>)!. + Non-essential file systems like + <filename>/var</filename> and <filename>/home</filename> + are mounted after generators have run. Generators + can however rely on the most basic kernel functionality to be + available, including a mounted <filename>/sys</filename>, + <filename>/proc</filename>, <filename>/dev</filename>, + <filename>/usr</filename>. </para> </listitem> diff --git a/shell-completion/bash/journalctl b/shell-completion/bash/journalctl index 321d439f0c..7c8a9ce361 100644 --- a/shell-completion/bash/journalctl +++ b/shell-completion/bash/journalctl @@ -24,6 +24,12 @@ __contains_word () { done } +__get_machines() { + local a b + (machinectl list-images --no-legend --no-pager; machinectl list --no-legend --no-pager; echo ".host") | \ + { while read a b; do echo " $a"; done; } | sort -u; +} + __journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC} ERRNO SYSLOG_{FACILITY,IDENTIFIER,PID} COREDUMP_EXE _{P,U,G}ID _COMM _EXE _CMDLINE @@ -49,11 +55,11 @@ _journalctl() { --utc -x --catalog --no-full --force --dump-catalog --flush --rotate --sync' [ARG]='-b --boot --this-boot -D --directory --file -F --field - -o --output -u --unit --user-unit -p --priority + -M --machine -o --output -u --unit --user-unit -p --priority --vacuum-size --vacuum-time' [ARGUNKNOWN]='-c --cursor --interval -n --lines -S --since -U --until --after-cursor --verify-key -t --identifier - --root -M --machine' + --root' ) if __contains_word "$prev" ${OPTS[ARG]} ${OPTS[ARGUNKNOWN]}; then @@ -74,6 +80,9 @@ _journalctl() { ;; --field|-F) comps=${__journal_fields[*]} + ;; + --machine|-M) + comps=$( __get_machines ) ;; --priority|-p) comps=${__syslog_priorities[*]} diff --git a/shell-completion/zsh/_busctl b/shell-completion/zsh/_busctl index ef790e558f..a425b8c700 100644 --- a/shell-completion/zsh/_busctl +++ b/shell-completion/zsh/_busctl @@ -1,6 +1,6 @@ #compdef busctl -# hostnamectl(1) completion -*- shell-script -*- +# busctl(1) completion -*- shell-script -*- # # This file is part of systemd. # diff --git a/src/basic/time-util.c b/src/basic/time-util.c index 17352a7a96..3f3863910b 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -188,9 +188,11 @@ struct timeval *timeval_store(struct timeval *tv, usec_t u) { return tv; } -static char *format_timestamp_internal(char *buf, size_t l, usec_t t, bool utc) { +static char *format_timestamp_internal(char *buf, size_t l, usec_t t, + bool utc, bool us) { struct tm tm; time_t sec; + int k; assert(buf); assert(l > 0); @@ -201,48 +203,36 @@ static char *format_timestamp_internal(char *buf, size_t l, usec_t t, bool utc) sec = (time_t) (t / USEC_PER_SEC); localtime_or_gmtime_r(&sec, &tm, utc); - if (strftime(buf, l, "%a %Y-%m-%d %H:%M:%S %Z", &tm) <= 0) + if (us) + k = strftime(buf, l, "%a %Y-%m-%d %H:%M:%S", &tm); + else + k = strftime(buf, l, "%a %Y-%m-%d %H:%M:%S %Z", &tm); + + if (k <= 0) return NULL; + if (us) { + snprintf(buf + strlen(buf), l - strlen(buf), ".%06llu", (unsigned long long) (t % USEC_PER_SEC)); + if (strftime(buf + strlen(buf), l - strlen(buf), " %Z", &tm) <= 0) + return NULL; + } return buf; } char *format_timestamp(char *buf, size_t l, usec_t t) { - return format_timestamp_internal(buf, l, t, false); + return format_timestamp_internal(buf, l, t, false, false); } char *format_timestamp_utc(char *buf, size_t l, usec_t t) { - return format_timestamp_internal(buf, l, t, true); -} - -static char *format_timestamp_internal_us(char *buf, size_t l, usec_t t, bool utc) { - struct tm tm; - time_t sec; - - assert(buf); - assert(l > 0); - - if (t <= 0 || t == USEC_INFINITY) - return NULL; - - sec = (time_t) (t / USEC_PER_SEC); - localtime_or_gmtime_r(&sec, &tm, utc); - - if (strftime(buf, l, "%a %Y-%m-%d %H:%M:%S", &tm) <= 0) - return NULL; - snprintf(buf + strlen(buf), l - strlen(buf), ".%06llu", (unsigned long long) (t % USEC_PER_SEC)); - if (strftime(buf + strlen(buf), l - strlen(buf), " %Z", &tm) <= 0) - return NULL; - - return buf; + return format_timestamp_internal(buf, l, t, true, false); } char *format_timestamp_us(char *buf, size_t l, usec_t t) { - return format_timestamp_internal_us(buf, l, t, false); + return format_timestamp_internal(buf, l, t, false, true); } char *format_timestamp_us_utc(char *buf, size_t l, usec_t t) { - return format_timestamp_internal_us(buf, l, t, true); + return format_timestamp_internal(buf, l, t, true, true); } char *format_timestamp_relative(char *buf, size_t l, usec_t t) { diff --git a/src/random-seed/random-seed.c b/src/random-seed/random-seed.c index d857ade36a..0041258d41 100644 --- a/src/random-seed/random-seed.c +++ b/src/random-seed/random-seed.c @@ -40,7 +40,7 @@ int main(int argc, char *argv[]) { _cleanup_free_ void* buf = NULL; size_t buf_size = 0; ssize_t k; - int r; + int r, open_rw_error; FILE *f; bool refresh_seed_file = true; @@ -87,14 +87,23 @@ int main(int argc, char *argv[]) { if (streq(argv[1], "load")) { seed_fd = open(RANDOM_SEED, O_RDWR|O_CLOEXEC|O_NOCTTY|O_CREAT, 0600); + open_rw_error = -errno; if (seed_fd < 0) { + refresh_seed_file = false; + seed_fd = open(RANDOM_SEED, O_RDONLY|O_CLOEXEC|O_NOCTTY); if (seed_fd < 0) { - r = log_error_errno(errno, "Failed to open " RANDOM_SEED ": %m"); + bool missing = errno == ENOENT; + + log_full_errno(missing ? LOG_DEBUG : LOG_ERR, + open_rw_error, "Failed to open " RANDOM_SEED " for writing: %m"); + r = log_full_errno(missing ? LOG_DEBUG : LOG_ERR, + errno, "Failed to open " RANDOM_SEED " for reading: %m"); + if (missing) + r = 0; + goto finish; } - - refresh_seed_file = false; } random_fd = open("/dev/urandom", O_RDWR|O_CLOEXEC|O_NOCTTY, 0600); @@ -109,9 +118,10 @@ int main(int argc, char *argv[]) { k = loop_read(seed_fd, buf, buf_size, false); if (k < 0) r = log_error_errno(k, "Failed to read seed from " RANDOM_SEED ": %m"); - else if (k == 0) + else if (k == 0) { + r = 0; log_debug("Seed file " RANDOM_SEED " not yet initialized, proceeding."); - else { + } else { (void) lseek(seed_fd, 0, SEEK_SET); r = loop_write(random_fd, buf, (size_t) k, false); diff --git a/test/TEST-03-JOBS/test-jobs.sh b/test/TEST-03-JOBS/test-jobs.sh index 4252a9a75d..0c7d4439a2 100755 --- a/test/TEST-03-JOBS/test-jobs.sh +++ b/test/TEST-03-JOBS/test-jobs.sh @@ -50,4 +50,3 @@ systemctl stop --job-mode=replace-irreversibly unstoppable.service || exit 1 systemctl start unstoppable.service || exit 1 touch /testok -exit 0 diff --git a/test/TEST-04-JOURNAL/test-journal.sh b/test/TEST-04-JOURNAL/test-journal.sh index 3a05619ad5..6646eccfa7 100755 --- a/test/TEST-04-JOURNAL/test-journal.sh +++ b/test/TEST-04-JOURNAL/test-journal.sh @@ -60,4 +60,3 @@ systemctl stop forever-print-hola [[ ! -f "/i-lose-my-logs" ]] touch /testok -exit 0 diff --git a/test/TEST-05-RLIMITS/test-rlimits.sh b/test/TEST-05-RLIMITS/test-rlimits.sh index 54000ecefb..ba665c5968 100755 --- a/test/TEST-05-RLIMITS/test-rlimits.sh +++ b/test/TEST-05-RLIMITS/test-rlimits.sh @@ -14,4 +14,3 @@ set -o pipefail [[ "$(ulimit -n -H)" = "16384" ]] touch /testok -exit 0 diff --git a/test/TEST-06-SELINUX/test-selinux-checks.sh b/test/TEST-06-SELINUX/test-selinux-checks.sh index 08d2ddf4f0..153fab3aac 100755 --- a/test/TEST-06-SELINUX/test-selinux-checks.sh +++ b/test/TEST-06-SELINUX/test-selinux-checks.sh @@ -10,4 +10,3 @@ runcon -t systemd_test_reload_t systemctl reload hola runcon -t systemd_test_stop_t systemctl stop hola touch /testok -exit 0 diff --git a/test/sys.tar.xz b/test/sys.tar.xz Binary files differindex 49ee8027b2..052c77d182 100644 --- a/test/sys.tar.xz +++ b/test/sys.tar.xz diff --git a/test/udev-test.pl b/test/udev-test.pl index 0a89303570..638c3e8f4e 100755 --- a/test/udev-test.pl +++ b/test/udev-test.pl @@ -700,7 +700,7 @@ EOF desc => "big major number test", devpath => "/devices/virtual/misc/misc-fake1", exp_name => "node", - exp_majorminor => "4095:1", + exp_majorminor => "511:1", rules => <<EOF KERNEL=="misc-fake1", SYMLINK+="node" EOF @@ -709,7 +709,7 @@ EOF desc => "big major and big minor number test", devpath => "/devices/virtual/misc/misc-fake89999", exp_name => "node", - exp_majorminor => "4095:89999", + exp_majorminor => "511:89999", rules => <<EOF KERNEL=="misc-fake89999", SYMLINK+="node" EOF |