1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 09:21:26 +03:00
Commit Graph

37808 Commits

Author SHA1 Message Date
Filipe Brandenburger
dc6bf94d68 lldp: simplify compare_func, using ?: to chain comparisons
The ?: operator is very useful for chaining comparison functions
(strcmp, memcmp, CMP), since its behavior is to return the result
of the comparison function call if non-zero, or continue evaluating
the chain of comparison functions.

This simplifies the code in that using a temporary `r` variable
to store the function results is no longer necessary and the checks
for non-zero to return are no longer needed either, resulting in a
typical three-fold reduction to the number of lines in the code.

Introduce a new memcmp_nn() to compare two memory buffers in
lexicographic order, taking length in consideration.

Tested: $ ninja -C build/ test

All test cases pass. In particular, test_multiple_neighbors_sorted()
in test-lldp would catch regressions introduced by this commit.
2018-12-14 09:18:42 -08:00
Filipe Brandenburger
dd102e4d0c lldp: add test coverage for sd_lldp_get_neighbors() with multiple neighbors
In particular, check that the order of the results is consistent.

This test coverage will be useful in order to refactor the compare_func
used while sorting the results.

Tested: ninja -C build/ test
2018-12-14 09:18:01 -08:00
Chris Down
09818a8893
Merge pull request #11160 from poettering/read-line-more-tests
some tests for read_line() EOL markers that coincide with EOF
2018-12-14 13:00:28 +00:00
Lennart Poettering
6baac700a8 tests: add a test that checks read_line() properly handles line endings at EOF
As requested here: https://github.com/systemd/systemd/pull/11129#discussion_r241588835
2018-12-14 12:57:32 +01:00
Lennart Poettering
31fd02f009 fileio: fail early if we can't return the number of bytes we read anymore in an int
This is mostly paranoia, but let's better be safer than sorry. This of
course means there's always an implicit limit to how much we can read at
a time of 2G. But that should be ample.
2018-12-14 12:56:12 +01:00
Zbigniew Jędrzejewski-Szmek
58d9d89b4b pid1: fix free of uninitialized pointer in unit_fail_if_noncanonical()
https://bugzilla.redhat.com/show_bug.cgi?id=1653068
2018-12-14 11:21:16 +01:00
Zbigniew Jędrzejewski-Szmek
0b57803630 man: add note about systemd-vconsole-setup.service and tty as input/output
Closes #10019.
2018-12-14 11:18:32 +01:00
Zbigniew Jędrzejewski-Szmek
3f9a0a522f tree-wide: s/time-out/timeout/g
From WordNet (r) 3.0 (2006) [wn]:

  time-out
      n 1: a brief suspension of play; "each team has two time-outs left"

From The Free On-line Dictionary of Computing (18 March 2015) [foldoc]:

  timeout

     A period of time after which an error condition is raised if
     some event has not occured.  A common example is sending a
     message.  If the receiver does not acknowledge the message
     within some preset timeout period, a transmission error is
     assumed to have occured.
2018-12-14 11:17:52 +01:00
Thomas Haller
1a35985264 in-addr-util: fix undefined result for in4_addr_netmask_to_prefixlen(<0.0.0.0>)
u32ctz() was undefined for zero due to __builtin_ctz() [1].
Explicitly check for zero to make the behavior defined.

Note that this issue only affected in4_addr_netmask_to_prefixlen()
which is the only caller.

It may seem slightly odd, to return 32 (bits) for utz(0). But that
is what in4_addr_netmask_to_prefixlen() needs, and it probably makes
the most sense here.

[1] https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html

Fixes: ba91431154
2018-12-14 11:15:36 +01:00
Zbigniew Jędrzejewski-Szmek
1d79128121 udev: make udev_rules_new() return a proper error code 2018-12-14 10:20:43 +01:00
Bruce Zhang
0b1093018b add device hwdb for IdeaPad Miix510-12ISK
add ACCEL_MOUNT_MATRIX for IdeaPad Miix510-12ISK

multiple match expressions for Miix510 series

extend comments for miix510 series

Signed-off-by: Bruce Zhang <zttt183525594@gmail.com>

add device hwdb for IdeaPad Miix510-12ISK

Signed-off-by: Bruce Zhang <zttt183525594@gmail.com>
2018-12-14 09:16:36 +01:00
Lennart Poettering
838894b0c6 fileio: make read_line() handle various line endings correctly
This adds support for windows line endings.

More importantly though with this change a newline followed by EOF is
considered a single line end.
2018-12-14 09:12:17 +01:00
Zbigniew Jędrzejewski-Szmek
57db447ebf
Merge pull request #11147 from yuwata/bash-completion-machinectl
bash-completion: adds import-fs for machinectl and suggest more
2018-12-14 08:57:03 +01:00
Yu Watanabe
f675a1f005 bash-completion: busctl: support --json and -j option 2018-12-14 08:55:38 +01:00
Zbigniew Jędrzejewski-Szmek
58493c6671
Merge pull request #11145 from yuwata/bash-completion-bootctl
bash-completion: bootctl: support set-default and set-oneshot
2018-12-14 08:54:44 +01:00
Yu Watanabe
5cd6711621 sd-netlink: set destroy_callback only if asynchronous call succeeds 2018-12-14 08:50:51 +01:00
Zbigniew Jędrzejewski-Szmek
40d70ca07c
Merge pull request #11152 from keszybz/meson-user-unit-symlinks
Fix future installation of user unit symlinks by meson
2018-12-14 08:31:50 +01:00
Lennart Poettering
9a6f746fb6 locale-util: prefix special glyph enum values with SPECIAL_GLYPH_
This has been irritating me for quite a while: let's prefix these enum
values with a common prefix, like we do for almost all other enums.

No change in behaviour, just some renaming.
2018-12-14 08:22:54 +01:00
Yu Watanabe
903893237a sd-device: do not change buffer size if the socket is already bound
From the results of CIs in #11076, changing buffer size may cause
issue #10754. So, let's prohibit to change the size if it is already
bound.

This also reverts commit 986ab0d2dc.
2018-12-14 09:33:06 +09:00
Yu Watanabe
c821e84ac7 sd-device: do not modify socket option(s) if socket is passed by PID1
If the socket fd is passed by PID1, then it is created by .socket unit
and we have already set sufficient option(s) for the socket.
So, let's not touch the passed socket.
2018-12-14 09:28:33 +09:00
Yu Watanabe
a153a1de75 Revert "sd-device: do not call device_monitor_enable_receiving() for passed fd from pid1"
This reverts commit 916707cca5.

As the CI results on #11076, #10754 is not fixed by the commit,
but by 986ab0d2dc. So, let's revert the
commit.
2018-12-14 09:24:31 +09:00
Lennart Poettering
fd0ec39d38
Merge pull request #11046 from keszybz/generator-mains
Macroify generators a bit more
2018-12-13 22:39:23 +01:00
Lennart Poettering
ffd1a3f688 man: substantially update the docs regarding hooking sd-bus objects up with external event loops
Prompted by https://lists.freedesktop.org/archives/systemd-devel/2018-December/041817.html

This also drops all references to select() from our manpages. It's 2018
after all, people should use poll(), or ppoll() or epoll().
2018-12-13 22:33:47 +01:00
Michael Scherer
41fc3fab1c man: Use the proper option name in documentation 2018-12-13 20:30:58 +01:00
Zbigniew Jędrzejewski-Szmek
634cc94f47 units: replace symlinks in units/user/ by real files
We already *install* those as real files since de78fa9ba0.
Meson will start to copy symlinks as-is, so we would get dangling symlinks in
/usr/lib/systemd/user/.

I considered the layout in our sources to match the layout in the installation
filesystem (i.e. creating units/system/ and moving all files from units/ to
units/system/), but that seems overkill. By using normal files for both we get
some duplication, but those files change rarely, so it's not a big downside in
practice.

Fixes #9906.
2018-12-13 20:23:43 +01:00
Zbigniew Jędrzejewski-Szmek
df13444339 units: drop units/user/busnames.target
It seems this was missed in 0ba8987337.
2018-12-13 20:23:43 +01:00
Yu Watanabe
ff1cf894d2 bash-completion: nspawn: support recently added options 2018-12-14 03:18:33 +09:00
Yu Watanabe
223f58ba8d bash-completion: run: support recently added options 2018-12-14 03:18:33 +09:00
Yu Watanabe
2e68a49dc8 bash-completion: systemctl: use --output=help to show suggestions 2018-12-14 02:33:21 +09:00
Yu Watanabe
fdc33681ae bash-completion: journalctl: use --output=help to show suggestions 2018-12-14 02:33:21 +09:00
Yu Watanabe
d104486ab6 bash-completion: journalctl: drop deprecated --new-id128 option 2018-12-14 02:33:21 +09:00
Yu Watanabe
3b59e2cbed bash-completion: loginctl: suggest argument for --machine option 2018-12-14 02:22:40 +09:00
Yu Watanabe
dfeebf55d9 bash-completion: loginctl: suggest argument for --output option 2018-12-14 02:18:35 +09:00
Yu Watanabe
fad73e9deb bash-completion: machinectl: suggest arguments for --verify and --format
This also changes to use '--output=help' for suggesting arguments of
--output option.
2018-12-14 02:18:24 +09:00
Yu Watanabe
0e5bea97e9 bash-completion: machinectl: support import-fs 2018-12-14 01:52:48 +09:00
Yu Watanabe
a73b2f4ab3 bash-completion: bootctl: support set-default and set-oneshot 2018-12-14 01:26:52 +09:00
Yu Watanabe
ed0c5a6f89 bash-completion: bootctl: suggest argument for --path option 2018-12-14 01:26:25 +09:00
Yu Watanabe
8ed22786aa bash-completion: bootctl: add one missing option 2018-12-14 01:25:31 +09:00
Zbigniew Jędrzejewski-Szmek
421e3b45f0 NEWS: typos and wording adjustments 2018-12-13 11:10:07 +01:00
Zbigniew Jędrzejewski-Szmek
4b37c89f06 shared/install: ignore symlinks which have lower priority than the unit file
In #10583, a unit file lives in ~/.config/systemd/user, and
'systemctl --runtime --user mask' is used to create a symlink in /run.
This symlink has lower priority than the config file, so
'systemctl --user' will happily load the unit file, and does't care about
the symlink at all.

But when asked if the unit is enabled, we'd look for all symlinks, find the
symlink in the runtime directory, and report that the unit is runtime-enabled.
In this particular case the fact that the symlink points at /dev/null, creates
additional confusion, but it doesn't really matter: *any* symlink (or regular
file) that is lower in the priority order is "covered" by the unit fragment,
and should be ignored.

Fixes #10583.
2018-12-13 10:46:27 +01:00
Zbigniew Jędrzejewski-Szmek
3e8d06d951 shared/install: add some more debugging info
Just to make it easier to understand what is going on.
2018-12-13 08:40:38 +01:00
Franck Bui
d610d20125 vconsole-setup: fonts copy will fail if the current terminal is in graphical mode
If the terminal is in graphical mode, the kernel will refuse to copy the fonts
and will return -EINVAL.

Also having the graphical mode in effect probably indicates that the terminal
is in used by another application and we shouldn't interfer in such cases.
2018-12-13 08:30:20 +01:00
Zbigniew Jędrzejewski-Szmek
2eded6cb2c shared/install: remove two conditionals which are always false
The name argument in UnitFileInstallInfo (i->name) should always be a unit
file name, so the conditional always takes the 'else' branch.

The only call chain that links to find_symlinks_fd() is unit_file_lookup_state
→ find_symlinks_in_scope → find_symlinks → find_symlinks_fd. But
unit_file_lookup_state calls unit_name_is_valid(name), and then name is used
to construct the UnitFileInstallInfo object in install_info_discover, which just
uses the name it was given.
2018-12-13 00:58:27 +01:00
Chris Down
0c17c00433
Merge pull request #11131 from poettering/make-lucab-happy
optionally relabel additional files/dirs for selinux after loading policy
2018-12-12 23:17:39 +00:00
Zbigniew Jędrzejewski-Szmek
a3e7ea0282 fstab-generator: fix check for /sys
It would work when the generator was run by systemd, since generators
are always started in "/", but when running the generator for debugging
purposes the result would be ... different.
2018-12-12 21:58:00 +01:00
Zbigniew Jędrzejewski-Szmek
9d22f97b87 getty-generator: use the new main function definer
I changed the nulstr loop to a normal FOREACH_STRING loop. It seems clearer
this way.
2018-12-12 21:58:00 +01:00
Zbigniew Jędrzejewski-Szmek
ec6e959750 gpt-auto-generator: use the new main function definer
The first error is now returned.
2018-12-12 21:58:00 +01:00
Zbigniew Jędrzejewski-Szmek
bd020018f2 system-update-generator: use the new main function definer 2018-12-12 21:58:00 +01:00
Zbigniew Jędrzejewski-Szmek
7a44c7e31f generators: define custom main func definer and use it where applicable
There should be no functional difference, except that the error message
is changd from "three or no arguments" to "zero or three arguments". Somehow
the inverted form always seemed strange.

umask() call is also dropped from run-generator. I think it wasn't dropped in
053254e3cb because the run generator was merged
around the same time.
2018-12-12 21:58:00 +01:00
Lennart Poettering
6b1ab752c2 NEWS: initialy version of NEWS
Needs lots of updates still, but let's get the party started.
2018-12-12 21:31:01 +01:00