Commit graph

24334 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 62353f69cc journal: drop _packed_ attribute in a few places
The justification is the safe as for the grandparent commit.
2019-02-04 20:32:44 +01:00
Zbigniew Jędrzejewski-Szmek 6b68c26824 test-util: drop _packed_ attribute
gcc-9 warns:
../src/test/test-util.c:147:19: note: in expansion of macro ‘container_of’
  147 |         assert_se(container_of(&myval.v1, struct mytype, v1) == &myval);
      |                   ^~~~~~~~~~~~

I don't think packing matters here for the test of container_of(), so let's
just remove it.
2019-02-04 20:32:44 +01:00
Zbigniew Jędrzejewski-Szmek e27b9aba30 libsystemd-network: remove _packed_ attribute to appease the compiler
gcc-9 warns whenever the elements of a structure defined with _packed_ are used:

../src/network/networkd-dhcp6.c: In function ‘dhcp6_pd_prefix_assign’:
../src/network/networkd-dhcp6.c:92:53: warning: taking address of packed member of ‘struct <anonymous>’ may result in an unaligned pointer value [-Waddress-of-packed-member]
   92 |         r = manager_dhcp6_prefix_add(link->manager, &p->opt.in6_addr, link);
      |                                                     ^~~~~~~~~~~~~~~~

And the compiler is right, because in principle the alignment could be wrong.
In this particular case it is not, because the structure is carefully defined
not to have holes. Let's remove _packed_ and use compile-time asserts to verify
that the offsets are not changed.
2019-02-04 20:32:44 +01:00
Zbigniew Jędrzejewski-Szmek 00e1adf8b1 journal: avoid buffer overread when locale name is too long
We could potentially create an unterminated string and then call normal string
operations on it. Let's be more careful: first remove the suffix we ignore anyway,
then find if the string is of acceptable length, and possibly ignore it if it
is too long. The code rejects lengths above 31 bytes. Language names that are
actually used are much shorter, so this doesn't matter much.
2019-01-27 18:34:15 +01:00
Zbigniew Jędrzejewski-Szmek cd8c98d7a7 shared/dissect-image: make sure that we don't truncate device name
gcc-9 complains that the string may be truncated when written into the output
structure. This shouldn't happen, but if it did, in principle we could remove a
different structure (with a matching name prefix). Let's just refuse the
operation if the name doesn't fit.
2019-01-27 09:35:36 +01:00
Lennart Poettering a90d944359
Merge pull request #11562 from yuwata/fix-11558
core/mount: do not add Before=local-fs.target or remote-fs.target if nofail mount option is set
2019-01-26 14:46:48 +01:00
Lennart Poettering f2500feadf
Merge pull request #11466 from keszybz/fix-loop-remounts
pid1: fix cleanup of stale implicit deps based on /proc/self/mountinfo
2019-01-26 14:42:02 +01:00
Zbigniew Jędrzejewski-Szmek c52c2dc64f pid1: fix cleanup of stale implicit deps based on /proc/self/mountinfo
The problem was introduced in a37422045fbb68ad68f734e5dc00e0a5b1759773:
we have a unit which has a fragment, and when we'd update it based on
/proc/self/mountinfo, we'd say that e.g. What=/dev/loop8 has origin-fragment.
This commit changes two things:
- origin-fragment is changed to origin-mountinfo-implicit
- when we stop a unit, mountinfo information is flushed and all deps based
  on it are dropped.

The second step is important, because when we restart the unit, we want to
notice that we have "fresh" mountinfo information. We could keep the old info
around and solve this in a different way, but keeping stale information seems
inelegant.

Fixes #11342.
2019-01-26 14:40:50 +01:00
Lennart Poettering 67216ef8f2
Merge pull request #11530 from keszybz/journal-cache-trimming
Journal cache trimming
2019-01-26 13:55:55 +01:00
Lennart Poettering 2949ff2691 nspawn: ignore SIGPIPE for nspawn itself
Let's not abort due to a dead stdout.

Fixes: #11533
2019-01-26 13:54:44 +01:00
Michal Sekletar eb1ec489ee process-util: don't use overly large buffer to store process command line
Allocate new string as a return value and free our "scratch pad"
buffer that is potentially much larger than needed (up to
_SC_ARG_MAX).

Fixes #11502
2019-01-26 13:54:29 +01:00
Zbigniew Jędrzejewski-Szmek 91714a7f42 journald: periodically drop cache for all dead PIDs
In normal use, this allow us to drop dead entries from the cache and reduces
the cache size so that we don't evict entries unnecessarily. The time limit is
there mostly to serve as a guard against malicious logging from many different
PIDs.
2019-01-26 12:43:27 +01:00
Zbigniew Jędrzejewski-Szmek b12a480829 journal: limit the number of entries in the cache based on available memory
This is far from perfect, but should give mostly reasonable values. My
assumption is that if somebody has a few hundred MB of memory, they are
unlikely to have thousands of processes logging. A hundred would already be a
lot. So let's scale the cache size propritionally to the total memory size,
with clamping on both ends.

The formula gives 64 cache entries for each GB of RAM.
2019-01-26 12:42:52 +01:00
Zbigniew Jędrzejewski-Szmek ef21b3b5bf basic/prioq: add prioq_peek_item() 2019-01-26 12:42:46 +01:00
Yu Watanabe 8c8203db90 core/mount: do not add Before=local-fs.target or remote-fs.target if nofail mount option is set
Follow-up for d54bab90e6.

Fixes #11558.
2019-01-26 12:00:18 +01:00
Thomas Haller 01dab40ba5 dhcp/trivial: fix spelling error in comment 2019-01-25 20:29:39 +09:00
Lennart Poettering 42a1491503
Merge pull request #11547 from yuwata/network-cosmetic-fixes
network: trivial fix and cleanup
2019-01-25 00:18:45 +01:00
Niklas Hambüchen 3a1e46f7ae timesyncd: Improve sync log message. Fixes #11548.
This makes it clear that the user should not expect more log messages
each time the time is synchronised.
2019-01-24 23:52:24 +01:00
Lennart Poettering 3dffcfc78b test-bpf: check if we can mlock() before trying bpf 2019-01-24 23:50:26 +01:00
Yu Watanabe 15cdaeee2e network: fix an error log 2019-01-24 14:33:58 +09:00
Yu Watanabe 1cc84f3bb9 network: make link_up() static 2019-01-24 12:07:41 +09:00
Lennart Poettering 8499b2c26d
Merge pull request #11536 from yuwata/fix-11529
sd-device-monitor: use SO_DETACH_FILTER to remove BPF program
2019-01-23 23:35:38 +01:00
Chris Lamb 4605de118d Correct more spelling errors. 2019-01-23 23:34:52 +01:00
Yu Watanabe aa6c83e60e test: add test for sd_device_monitor_filter_remove() 2019-01-23 15:11:53 +09:00
Yu Watanabe b07571735a sd-device-monitor: use SO_DETACH_FILTER to remove BPF program
Fixes #11529.
2019-01-23 15:11:47 +09:00
Zbigniew Jędrzejewski-Szmek c482724aa5 procfs-util: expose functionality to query total memory
procfs_memory_get_current is renamed to procfs_memory_get_used, because
"current" can mean anything, including total memory, used memory, and free
memory, as long as the value is up to date.

No functional change.
2019-01-22 17:43:13 +01:00
Louis Taylor d1084aa2f8 meson: make version a dependency and use it in libbasic
This should hopefully ensure it gets generated before basic build
happens.

Fixes #11483.
2019-01-22 14:39:38 +01:00
Lennart Poettering 04ba6ed167
Merge pull request #11501 from yuwata/fix-9426
sd-device: do not save e.g., DEVPATH or INTERFACE properties to udev database
2019-01-22 11:57:06 +01:00
Taro Yamada 0bf05f0122 Fixes #11128 2019-01-22 11:14:51 +01:00
Zbigniew Jędrzejewski-Szmek 3a57413c26
Merge pull request #11448 from poettering/rlimit-pid1-fixo
RLIMIT_MEMLOCK fixes
2019-01-22 10:07:52 +01:00
Lennart Poettering fea46786ce resolved: preferably route single-label lookups to unicast DNS scopes with search domains (#11485)
Fixes: #11391
2019-01-22 09:57:49 +01:00
Yu Watanabe 2277e84560 udevadm info: make --export-prefix imply --export
Setting --export without --export-prefix is meaningless.
2019-01-22 15:07:27 +09:00
Yu Watanabe 302ddcdc0a core/device: fix log message 2019-01-22 14:51:02 +09:00
Yu Watanabe a3ce813697 sd-device: do not save e.g., DEVPATH or INTERFACE properties to udev database
Previously, device_copy_properties() copies all properties to both
sd_device::properties and ::properties_db. Thus, on move uevent,
also tentative properties, e.g. DEVPATH or INTERFACE, are stored to
::properties_db, and saved to udev database.

This makes such tentative properties be copied to only ::properties,
and thus not saved to udev database.

Fixes #9426.
2019-01-22 14:51:02 +09:00
Yu Watanabe 61a38e0265 wait-online: do not fail if we receive invalid messages
Fixes #11486.
2019-01-21 15:54:50 +01:00
Yu Watanabe 838b2f7a30 network: unset Network::manager when loading .network file fails
Otherwise, LIST_REMOVE() in network_free() fails.

This fixes the following assertion:
```
systemd-networkd[2595]: Bus bus-api-network: changing state UNSET → OPENING
systemd-networkd[2595]: Bus bus-api-network: changing state OPENING → AUTHENTICATING
systemd-networkd[2595]: timestamp of '/etc/systemd/network' changed
systemd-networkd[2595]: /etc/systemd/network/10-hoge.network:1: Invalid section header '[Network]Address=192.168.0.1'
systemd-networkd[2595]: /etc/systemd/network/10-hoge.network:1: Failed to parse file: Bad message
systemd-networkd[2595]: Assertion '*_head == _item' failed at ../../home/watanabe/git/systemd/src/network/networkd-network.c:378, function network_free(). Aborting.
valgrind[2595]: ==2595==
valgrind[2595]: ==2595== Process terminating with default action of signal 6 (SIGABRT): dumping core
valgrind[2595]: ==2595==    at 0x4BCA53F: raise (in /usr/lib64/libc-2.28.so)
valgrind[2595]: ==2595==    by 0x4BB4894: abort (in /usr/lib64/libc-2.28.so)
valgrind[2595]: ==2595==    by 0x4955F09: log_assert_failed_realm (log.c:795)
valgrind[2595]: ==2595==    by 0x417101: network_free (networkd-network.c:378)
valgrind[2595]: ==2595==    by 0x415E99: network_freep (networkd-network.h:282)
valgrind[2595]: ==2595==    by 0x416AB2: network_load_one (networkd-network.c:101)
valgrind[2595]: ==2595==    by 0x416C39: network_load (networkd-network.c:293)
valgrind[2595]: ==2595==    by 0x414031: manager_load_config (networkd-manager.c:1502)
valgrind[2595]: ==2595==    by 0x40B258: run (networkd.c:82)
valgrind[2595]: ==2595==    by 0x40B74A: main (networkd.c:117)
valgrind[2595]: ==2595==
valgrind[2595]: ==2595== HEAP SUMMARY:
valgrind[2595]: ==2595==     in use at exit: 32,621 bytes in 201 blocks
valgrind[2595]: ==2595==   total heap usage: 746 allocs, 545 frees, 241,027 bytes allocated
valgrind[2595]: ==2595==
valgrind[2595]: ==2595== LEAK SUMMARY:
valgrind[2595]: ==2595==    definitely lost: 0 bytes in 0 blocks
valgrind[2595]: ==2595==    indirectly lost: 0 bytes in 0 blocks
valgrind[2595]: ==2595==      possibly lost: 0 bytes in 0 blocks
valgrind[2595]: ==2595==    still reachable: 32,621 bytes in 201 blocks
valgrind[2595]: ==2595==         suppressed: 0 bytes in 0 blocks
valgrind[2595]: ==2595== Reachable blocks (those to which a pointer was found) are not shown.
valgrind[2595]: ==2595== To see them, rerun with: --leak-check=full --show-leak-kinds=all
valgrind[2595]: ==2595==
valgrind[2595]: ==2595== For counts of detected and suppressed errors, rerun with: -v
valgrind[2595]: ==2595== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
systemd-coredump[2600]: Process 2595 (memcheck-amd64-) of user 192 dumped core.
```
2019-01-21 15:53:12 +01:00
Mike Gilbert f356aabe98 test-process-util: do not assume PID 1 has UID=0
Gentoo's Portage package manager uses a PID namespace for process
isolation and cleanup. In this namespace, PID 1 has UID=250 (portage).

Bug: https://bugs.gentoo.org/674458
2019-01-21 11:41:37 +01:00
Jonathon Kowalski 78218e6243 Enable some more debug logging for transaction building 2019-01-21 11:39:06 +01:00
Lennart Poettering 0efa18d636
Merge pull request #11424 from yuwata/fix-11420
timedate: refuse setting time when unit is in 'activating' or friends
2019-01-18 17:58:20 +01:00
Zbigniew Jędrzejewski-Szmek b0a28c2956
Merge pull request #11349 from yuwata/udevadm-control-ping
Add 'udevadm control --ping'
2019-01-18 17:41:00 +01:00
Lennart Poettering ce932d2d33 execute: make sure to call into PAM after initializing resource limits
We want that pam_limits takes precedence over our settings, after all.

Fixes: #11386
2019-01-18 17:31:36 +01:00
Lennart Poettering 498e265df1 fd-util: rework how we determine highest possible fd 2019-01-18 17:31:36 +01:00
Lennart Poettering 99a2fd3bca main: when generating the resource limit to pass to children, take FD_SETSIZE into consideration
When we synthesize a "struct rlimit" structure to pass on for
RLIMIT_NOFILE to our children, let's explicitly make sure that the soft
limit is not above FD_SETSIZE, for compat reason with select().

Note this only applies when we derive the "struct rlimit" from what we
inherited. If the user configures something explicitly it always takes
precedence.
2019-01-18 17:31:36 +01:00
Lennart Poettering cda7faa9a5 main: don't bump resource limits if they are higher than we need them anyway
This matters in particular in the case of --user, since there we lack
the privs to bump the limits up again later on when invoking children.
2019-01-18 17:31:36 +01:00
Lennart Poettering ddfa8b0b3b main: add commenting, clean up handling of saved resource limits
This doesn't really change behaviour, but adds comments and uses more
symbolic names for everything, to make this more readable.
2019-01-18 17:31:36 +01:00
Lennart Poettering c0d7695908 main: when bumping RLIMIT_MEMLOCK, save the previous value to pass to children
Let's make sure that the bumping of RLIMIT_MEMLOCK does not leak into
our children.
2019-01-18 17:31:36 +01:00
Yu Watanabe d30f43eec5 udevd: rename control command SYNC -> PING in log message 2019-01-18 16:10:01 +01:00
Yu Watanabe 2001622c58 udevadm: add --wait-daemon option to 'trigger' command 2019-01-18 16:10:01 +01:00
Yu Watanabe a82340cc03 udevadm: add --ping option to 'control' command
This exposes `udev_ctrl_send_ping()`.
2019-01-18 16:10:01 +01:00
Zbigniew Jędrzejewski-Szmek b7bbf89025 core/mount: move static function earlier in file
No functional change.
2019-01-18 14:04:26 +01:00