Commit graph

3046 commits

Author SHA1 Message Date
Lennart Poettering fe573a798d fs-util: let's avoid unnecessary strerror()
strerror() is not thread safe. Let's avoid it where it is easy hence.

(Ideally we'd not use it at all anymore, but that's sometimes a bit
nasty, not in this case though, where it is very easy to avoid)

Follow-up for: 27c3112dcb
2019-11-03 22:04:39 +09:00
Zbigniew Jędrzejewski-Szmek 08e82b84ca basic/signal-util: drop unnecessary parens 2019-11-02 11:56:03 +01:00
Lennart Poettering dfaf16ebed static-destruct: add missing closing '(' in comment 2019-11-01 11:31:20 +01:00
Lennart Poettering 0e06a03165 pid1: rework environment block copy logic
This reworks the logic introduced in
a5cede8c24 (#13693).

First of all, let's move this out of util.c, since only PID 1 really
needs this, and there's no real need to have it in util.c.

Then, fix freeing of the variable. It previously relied on
STATIC_DESTRUCTOR_REGISTER() which however relies on static_destruct()
to be called explicitly. Currently only the main-func.h macros do that,
and PID 1 does not. (It might be worth investigating whether to do that,
but it's not trivial.) Hence the freeing wasn't applied.

Finally, an OOM check was missing, add it in.
2019-11-01 11:30:59 +01:00
Lennart Poettering 6e0a388854 user-util: tweak to in_gid()
Let's make this robust towards parallel updates to group lists. This is
not going to happen IRL, but it makes me sleep better at night: let's
iterate a couple of times in case the list is updated while we are at
it.

Follow-up for: f5e0b942af
2019-10-31 20:59:27 +01:00
Yu Watanabe f5947a5e92 tree-wide: drop missing.h 2019-10-31 17:57:03 +09:00
Lennart Poettering a93503e86f
Merge pull request #13866 from keszybz/nspawn-restarts
Make 'machinectl reboot' functional
2019-10-30 10:53:28 +01:00
Susant Sahani 0f5bd7fe24 network: introduce TrafficControl
Add network delay to a interface
2019-10-30 09:33:51 +09:00
Zbigniew Jędrzejewski-Szmek 62a3fc6d27 shared/logs-show: strip trailing carriage returns at EOL/EOF
When showing logs from a container, we would fail to show various lines:
Oct 29 09:50:51 krowka systemd-nspawn[61376]: Detected architecture x86-64.
Oct 29 09:50:51 krowka systemd-nspawn[61376]: [1B blob data]
Oct 29 09:50:51 krowka systemd-nspawn[61376]: Welcome to Fedora 32 (Rawhide)!
Oct 29 09:50:51 krowka systemd-nspawn[61376]: [1B blob data]

Those are only harmless \r characters that trail the line. We already replace
tabs and strip various ansi characters that we deem inconsequential, so let's
also strip trailing carriage returns. Non-trailing ones are different, because
they change what would be displayed.
2019-10-29 10:54:45 +01:00
Franck Bui 21b40f1662 fileio: introduce read_full_virtual_file() for reading virtual files in sysfs, procfs
Virtual filesystems such as sysfs or procfs use kernfs, and kernfs can work
with two sorts of virtual files.

One sort uses "seq_file", and the results of the first read are buffered for
the second read. The other sort uses "raw" reads which always go direct to the
device.

In the later case, the content of the virtual file must be retrieved with a
single read otherwise subsequent read might get the new value instead of
finding EOF immediately. That's the reason why the usage of fread(3) is
prohibited in this case as it always performs a second call to read(2) looking
for EOF which is subject to the race described previously.

Fixes: #13585.
2019-10-25 15:24:49 +02:00
Zbigniew Jędrzejewski-Szmek df7c4eb62a various tools: be more explicit when a glob is passed when not supported
See https://bugzilla.redhat.com/show_bug.cgi?id=1763488: when we say that
'foo@*.service' is not a valid unit name, this is not clear enough. Let's
include the name of the operation that does not support globbing in the
error message:

$ build/systemctl enable 'foo@*.service'
Glob pattern passed to enable, but globs are not supported for this.
Invalid unit name "foo@*.service" escaped as "foo@\x2a.service".
...
2019-10-25 13:41:49 +09:00
Yu Watanabe f2106b1789
Merge pull request #13836 from systemd/assert-cleanups-and-constification
Assert cleanups and constification
2019-10-25 13:36:00 +09:00
Zbigniew Jędrzejewski-Szmek a5648b8094 basic/fs-util: change CHASE_OPEN flag into a separate output parameter
chase_symlinks() would return negative on error, and either a non-negative status
or a non-negative fd when CHASE_OPEN was given. This made the interface quite
complicated, because dependning on the flags used, we would get two different
"types" of return object. Coverity was always confused by this, and flagged
every use of chase_symlinks() without CHASE_OPEN as a resource leak (because it
would this that an fd is returned). This patch uses a saparate output parameter,
so there is no confusion.

(I think it is OK to have functions which return either an error or an fd. It's
only returning *either* an fd or a non-fd that is confusing.)
2019-10-24 22:44:24 +09:00
Zbigniew Jędrzejewski-Szmek 0e7f5ad9d3 Move PLYMOUTH_SOCKET define to def.h and nuke plymouth-util.h
Let's not have a file with a single define.
2019-10-24 11:48:08 +02:00
Zbigniew Jędrzejewski-Szmek 8a2c82ac88 Remove unused plymouth_running() function 2019-10-24 11:48:08 +02:00
Yu Watanabe 882e21c72f format-util: introduce format_ifname_full() 2019-10-24 14:20:48 +09:00
Marko Myllynen de52000695 Remove unprintable non-ASCII char from special glyph ASCII fallback table 2019-10-22 10:31:47 +02:00
Jonas Jelten c4742de6d8 ceph is a network filesystem 2019-10-18 10:03:51 +09:00
Chris Down 959daf9bfc
Merge pull request #13743 from anitazha/dropin_all_the_things
core: support top level drop-ins through -.service.d for service units
2019-10-16 23:10:05 -04:00
Anita Zhang d272467882 shared/dropin: support -.service.d/ top level drop-in for service units
Closes #12830
2019-10-15 11:14:54 -07:00
Susant Sahani c16c780804 network: introduce ip nexthop routing
Used to manipulate entries in the kernel's nexthop tables.
Example:
```
[NextHop]
Id=3
Gateway=192.168.5.1
```
2019-10-14 21:32:48 +09:00
Anita Zhang f18f809c07 basic/set: const-ify set_first()
set_steal_first() is the version that modifies Set so this one should be
const.
2019-10-07 12:02:12 -07:00
Anita Zhang e23d911664 core: disallow using '-.service' as a service name
-.service.d will become a special top level drop in so don't let it be a
usable service name (otherwise the interaction gets complicated).
2019-10-07 12:02:12 -07:00
Franck Bui 27c3112dcb fs-util: introduce inotify_add_watch_and_warn() helper
The default message for ENOSPC is very misleading: it says that the disk is
filled, but in fact the inotify watch limit is the problem.

So let's introduce and use a wrapper that simply calls inotify_add_watch(2) and
which fixes the error message up in case ENOSPC is returned.
2019-10-05 08:08:20 +02:00
Zbigniew Jędrzejewski-Szmek 3509e678f8
Merge pull request #13690 from cdown/cgroup_rework
cgroup: Add support to check systemd-internal cgroup limits against the kernel
2019-10-03 22:09:56 +02:00
Franck Bui a5cede8c24 pid1: restore the original environment passed by the kernel when switching to a new system manager
PID1 may modified the environment passed by the kernel when it starts
running. Commit 9d48671c62 unset $HOME for
example.

In case PID1 is going to switch to a new root and execute a new system manager
which is not systemd, we should restore the original environment as the new
manager might expect some variables to be set by default (more specifically
$HOME).
2019-10-03 22:08:13 +02:00
Chris Down 3a6da69a93 memory-util: Add PAGE_ALIGN_DOWN
For example, cgroup v2 rounds down to the previous page when returning
memory limits.
2019-10-03 14:43:30 +01:00
Zbigniew Jędrzejewski-Szmek 86e94d95d0
Merge pull request #13246 from keszybz/add-SystemdOptions-efi-variable
Add efi variable to augment /proc/cmdline
2019-10-03 12:19:44 +02:00
Frantisek Sumsal 065a74a7d8 basic: fix ASSERT_SIDE_EFFECT Coverity report in assert_se() 2019-10-02 10:43:47 +01:00
Kenneth D'souza ff7d6a740b Consider smb3 as remote filesystem
Currently systemd will treat smb3 as local filesystem and cause
can't boot failures. Add smb3 to the list of remote filesystems
to fix this issue.

Signed-off-by: Kenneth D'souza <kdsouza@redhat.com>
2019-10-01 02:02:00 +09:00
Chris Down 4e1ddb6612 util-lib: Don't propagate EACCES from find_binary PATH lookup to caller
On one of my test machines, test-path-util was failing because the
find_binary("xxxx-xxxx") was returning -EACCES instead of -ENOENT. This
happens because the PATH entry on that host contains a directory which
the user in question doesn't have access to. Typically applications
ignore permission errors when searching through PATH, for example in
bash:

    $ whoami
    cdown
    $ PATH=/root:/bin type sh
    sh is /bin/sh

This behaviour is present on zsh and other shells as well, though. This
patch brings our PATH search behaviour closer to other major Unix tools.
2019-09-26 09:19:20 +01:00
Yu Watanabe 10b843efb0
Merge pull request #13649 from keszybz/arphrd-minimization
Arphrd minimization
2019-09-26 00:12:20 +09:00
Zbigniew Jędrzejewski-Szmek 35bdba2115 basic/arphrd: stop discriminating against NETROM and CISCO
ARPHRD_NETROM was excluded, most likely just because it is protocol No. 0,
and ARPHRD_CISCO was reported under its alias name "HDLC". Let's just
allow defined aliases under the main name.
2019-09-25 12:17:51 +02:00
Zbigniew Jędrzejewski-Szmek 7e833f301e basic: massively reduce the size of arphdr lookup functions
Our biggest object in libsystemd was a table full of zeros, for the arphdr
names. Let's use a switch (which gcc nicely optimizes for us), instead a
table with a gap between 826 and 65534:

$ ls -l build{,2}/src/basic/a6ba3eb@@basic@sta/arphrd-list.c.o
-rw-rw-r--. 1 zbyszek zbyszek 540232 Sep 22 00:29 build/src/basic/a6ba3eb\@\@basic\@sta/arphrd-list.c.o
-rw-rw-r--. 1 zbyszek zbyszek  20512 Sep 25 11:56 build2/src/basic/a6ba3eb\@\@basic\@sta/arphrd-list.c.o

$ ls -l build{,2}/src/shared/libsystemd-shared-243.so
-rwxrwxr-x. 1 zbyszek zbyszek 6774368 Sep 22 00:29 build/src/shared/libsystemd-shared-243.so
-rwxrwxr-x. 1 zbyszek zbyszek 6254808 Sep 25 12:16 build2/src/shared/libsystemd-shared-243.so

No functional change.
2019-09-25 12:17:22 +02:00
Pavel Hrdina 1fbbb526ee cgroup-util: fix obsolete comment about supported controllers
The list might grow so make the comment more generic to not worry about
it if some controller is implemented.
2019-09-24 15:16:11 +02:00
Pavel Hrdina 047f5d63d7 cgroup: introduce support for cgroup v2 CPUSET controller
Introduce support for configuring cpus and mems for processes using
cgroup v2 CPUSET controller.  This allows users to limit which cpus
and memory NUMA nodes can be used by processes to better utilize
system resources.

The cgroup v2 interfaces to control it are cpuset.cpus and cpuset.mems
where the requested configuration is written.  However, it doesn't mean
that the requested configuration will be actually used as parent cgroup
may limit the cpus or mems as well.  In order to reflect the real
configuration cgroup v2 provides read-only files cpuset.cpus.effective
and cpuset.mems.effective which are exported to users as well.
2019-09-24 15:16:07 +02:00
Lennart Poettering 68c2b5ddb1
Merge pull request #13600 from keszybz/ratelimit
Clean up ratelimit functions and disable /dev/kmsg ratelimit
2019-09-23 12:59:09 +02:00
Frantisek Sumsal 38288f0bb8 tree-wide: various code-formatting improvements
Reported/found by Coccinelle
2019-09-22 07:17:27 +02:00
Zbigniew Jędrzejewski-Szmek 78158d134b basic/log: put a ratelimit on our logging to /dev/kmsg
See the inline comment for details.
2019-09-20 16:05:53 +02:00
Zbigniew Jędrzejewski-Szmek 8c227e7f2b Drop RATELIMIT macros
Using plain structure initialization is both shorter _and_ more clearer.
We get type safety for free.
2019-09-20 16:05:53 +02:00
Zbigniew Jędrzejewski-Szmek 53aa0d02ad Add support for SystemdOptions EFI var to augment /proc/cmdline
In various circumstances, overriding the kernel commandline can be inconvenient.
People have different bootloaders, and e.g. the grub config can be pretty scary.
grubby helps, but it isn't always available.

This option adds an alternative mechanism that can quite convenient on EFI
systems. cmdline settings have higher priority, because they can be (usually)
changed on the bootloader prompt.

$SYSTEMD_EFI_OPTIONS can be used to override, same as $SYSTEMD_PROC_CMDLINE.
2019-09-16 18:08:54 +02:00
Zbigniew Jędrzejewski-Szmek 0bb2f0f10e util-lib: split shared/efivars into basic/efivars and shared/efi-loader
I want to use efivars.[ch] in proc-cmdline.c, but most of the efivars stuff is
not needed in basic/. Move the file from shared/ to basic/, but then move back
most of the higher-level functions to the new shared/efi-loader.c file.
2019-09-16 18:08:53 +02:00
Zbigniew Jędrzejewski-Szmek 2bfa8466c0 util-lib: move shall_restore_state() to shared/reboot-util
It's just a small function, but it is higher-level functionality.
I don't see a good place for it, reboot-util.[ch] seems least bad
2019-09-16 18:08:01 +02:00
Zbigniew Jędrzejewski-Szmek da33cba0f8 util-lib: move runlevel_to_target() to shared/unit-file
It if of course related to /proc/cmdline parsing, but is higher-level
functionality built on top of it. It should be in shared/ because it
is something to be used by pid1 and related utilities, not something for
level-level libraries.
2019-09-16 18:08:00 +02:00
Zbigniew Jędrzejewski-Szmek fdb3decaa7 util-lib: move some functions from basic/cgroup-util to shared/cgroup-setup
This way less stuff needs to be in basic. Initially, I wanted to move all the
parts of cgroup-utils.[ch] that depend on efivars.[ch] to shared, because
efivars.[ch] is in shared/. Later on, I decide to split efivars.[ch], so the
move done in this patch is not necessary anymore. Nevertheless, it is still
valid on its own. If at some point we want to expose libbasic, it is better to
to not have stuff that belong in libshared there.
2019-09-16 18:08:00 +02:00
Zbigniew Jędrzejewski-Szmek 55fced5a19 util-lib: move yes_no() and friends to string-util.h 2019-09-16 18:06:20 +02:00
Zbigniew Jędrzejewski-Szmek d4d99bc6e4 basic/cgroup-util: let cgroup_unified_flush() return the detected hierarchy
This avoid the use of the global variable.

Also rename cgroup_unified_update() to cgroup_unified_cached() and
cgroup_unified_flush() to cgroup_unified() to better reflect their new roles.
2019-09-16 18:06:20 +02:00
Yu Watanabe f39fc2d88b
Merge pull request #13354 from keszybz/two-refactoring-patches
Two or more refactoring patches
2019-09-16 21:24:13 +09:00
Zbigniew Jędrzejewski-Szmek 36b12282e1 basic/conf-files: make conf_files_list() take just a single directory
This function had two users (apart from tests), and both only used one
argument. And it seems likely that if we need to pass more directories,
either the _nulstr() or the _strv() form would be used. Let's simplify
the code.
2019-09-16 09:15:05 +02:00
Renaud Métrich f5e0b942af Call getgroups() to know size of supplementary groups array to allocate
Resolves RHBZ #1743230 - journalctl dumps core when stack limit is reduced to 256 KB
2019-09-16 08:51:36 +02:00
Zbigniew Jędrzejewski-Szmek de5ae832f2
Merge pull request #13439 from yuwata/core-support-systemctl-clean-more
core: support systemctl clean more
2019-09-13 16:15:02 +02:00
Yu Watanabe 0f93577647 fileio: update warning message 2019-09-11 21:11:18 +09:00
Yu Watanabe 6bc536fc94
Merge pull request #13436 from systemd/hidden-units-are-good-units
Hidden units are good units
2019-08-31 02:53:54 +09:00
Zbigniew Jędrzejewski-Szmek a86cbb0fa3 shared/virt: update link to vmware article
As suggested in https://github.com/systemd/systemd/pull/13430#issuecomment-526551085.
2019-08-31 00:24:56 +09:00
Zbigniew Jędrzejewski-Szmek 890befcf47 shared/unit-files: only put valid unit paths and dropin dirs in the cache 2019-08-30 14:10:42 +02:00
Zbigniew Jędrzejewski-Szmek f6301bdc81 environment-d-generator: output logs in debug mode
Those codepaths is only used by that generator, so simply adding a few debug
log lines should be OK.

Fixes #12259.
2019-08-30 13:17:37 +02:00
Jan Losinski 87bc4b40fc basic/virt: Fix current virtualbox detection
In a current VirtualBox installation the board_vendor is set to "Oracle
Corporation". So we need to add this to the dmi_vendor_table for a
relieable detection.

This fixes #13429

Signed-off-by: Jan Losinski <losinski@wh2.tu-dresden.de>
2019-08-30 12:20:38 +02:00
Yu Watanabe 4b259b3c63
Merge pull request #13244 from keszybz/allow-dots-in-usernames
Allow dots in usernames
2019-08-29 00:03:19 +09:00
Yu Watanabe a8b689b7d0 core/swap: support "systemctl clean" for swap units 2019-08-28 23:09:54 +09:00
Yu Watanabe 17e9d53d87 core/mount: support "systemctl clean" for mount units 2019-08-28 23:09:54 +09:00
Yu Watanabe c968d76a38 core/socket: support "systemctl clean" for socket units 2019-08-28 23:09:54 +09:00
Zbigniew Jędrzejewski-Szmek 88e2ed0b5b shared/user-util: emit a warning on names with dots 2019-08-28 12:05:52 +02:00
Zbigniew Jędrzejewski-Szmek db11487d10 manager: put bin before sbin for user instances
Traditionally, user logins had a $PATH in which /bin was before /sbin, while
root logins had a $PATH with /sbin first. This allows the tricks that
consolehelper is doing to work. But even if we ignore consolehelper, having the
path in this order might have been used by admins for other purposes, and
keeping the order in user sessions will make it easier the adoption of systemd
user sessions a bit easier.

Fixes #733.
https://bugzilla.redhat.com/show_bug.cgi?id=1744059

OOM handling in manager_default_environment wasn't really correct.
Now the (theorertical) malloc failure in strv_new() is handled.

Please note that this has no effect on:
- systems with merged /bin-/sbin (e.g. arch)

- when there are no binaries that differ between the two locations.

  E.g. on my F30 laptop there is exactly one program that is affected:
  /usr/bin/setup -> consolehelper.

  There is less and less stuff that relies on consolehelper, but there's still
  some.

So for "clean" systems this makes no difference, but helps with legacy setups.

$ dnf repoquery --releasever=31 --qf %{name} --whatrequires usermode
anaconda-live
audit-viewer
beesu
chkrootkit
driftnet
drobo-utils-gui
hddtemp
mate-system-log
mock
pure-ftpd
setuptool
subscription-manager
system-config-httpd
system-config-rootpassword
system-switch-java
system-switch-mail
usermode-gtk
vpnc-consoleuser
wifi-radar
xawtv
2019-08-27 18:24:44 +02:00
Zbigniew Jędrzejewski-Szmek d0696f3b75
Merge pull request #13365 from keszybz/fix-commits-from-pr-13246
Fix commits from #13246
2019-08-22 09:13:25 +02:00
Lennart Poettering d5a1c99b25 log: don't invalidate open console fd if we can't open a new one 2019-08-20 17:32:17 +02:00
Lennart Poettering 9281e70375 terminal-util: add fallback logic to make_console_stdio()
If /dev/console can't be opened, let's use /dev/null instead.

Inspired by: #13332
2019-08-20 17:30:17 +02:00
Lennart Poettering e11a5c72ba log: cast various log_open() calls to (void) 2019-08-20 17:29:49 +02:00
Zbigniew Jędrzejewski-Szmek 9fc879d415 basic/build.h: fix typo 2019-08-20 12:01:23 +02:00
Zbigniew Jędrzejewski-Szmek 1a29610f5f shared/user-util: add compat forms of user name checking functions
New functions are called valid_user_group_name_compat() and
valid_user_group_name_or_id_compat() and accept dots in the user
or group name. No functional change except the tests.
2019-08-19 21:04:57 +02:00
Zbigniew Jędrzejewski-Szmek adfafd88b2 Revert "shared/conf-parser,networkd: EXTRACT_UNQUOTE|EXTRACT_RETAIN_ESCAPE → EXTRACT_UNQUOTE"
This reverts commit 8a07b4033e.
The tests are kept. test-networkd-conf is adjusted to pass.

This fixes #13276. I think current rules are extremely confusing, as the
case in test-networkd-conf shows. We apply some kinds of unescaping (relating
to quoting), but not others (related to escaping of special characters).
But fixing this is hard, because people have adjusted quoting to match
our rules, and if we make the rules "better", things might break in unexpected
places.
2019-08-19 09:54:06 +02:00
Topi Miettinen cda5ccdb34 cgroup-util: update comment to reflect stable kernel fixes 2019-08-19 09:46:50 +02:00
Dan Streetman 9841802955 src/basic/missing_syscall: add comment lines for PR 13319 changes
Add a comment line explaining that the syscall defines might be
defined to invalid negative numbers, as libseccomp redefines them
to negative numbers if not defined by the kernel headers, which is
not obvious just from reading the code checking for defined && > 0
2019-08-15 19:36:50 +02:00
Dan Streetman 59b657296a src/basic/missing_syscall: change #ifndef to #if ! (defined && > 0)
The #ifndef check used to work for missing __NR_* syscall defines, but
unfortunately libseccomp now redefines missing syscall number to negative
numbers, in their public header file, e.g.:
https://github.com/seccomp/libseccomp/blob/master/include/seccomp.h.in#L801

When systemd is built, since it includes <seccomp.h>, it pulls in the
incorrect negative value for any __NR_* syscall define that's included in
the seccomp.h header (for those syscalls that the kernel headers don't
yet define, e.g. when built with older/stable-distro kernels).  This leads
to bugs like:
https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1821625

This changes the check so that it can override the negative number that
libseccomp defines, instead of trying to use the negative syscall number.
To avoid gcc warnings (which are failures with meson --werror), this checks
without generating a redefinition gcc warning.

I have no idea why libseccomp decided to define missing syscalls
to negative numbers inside their *public* header file, causing
problems like this.
2019-08-14 18:09:47 +02:00
Dan Streetman 4f6d0cf807 src/basic/missing_syscall: add s390 syscall number for __NR_pkey_mprotect
The syscall number for s390 was added to the kernel at:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b41c51c8e194c0bdfb4b1778a137aea8246c86cd
2019-08-13 15:40:29 -04:00
Miroslav Lichvar bca5a0eacc time-util: improve detection of synchronized clock
Instead of checking for the STA_UNSYNC flag in the timex status, check
the maximum error. It is updated by the kernel, increasing at a rate of
500 ppm. The maximum value is 16 seconds, which triggers the STA_UNSYNC
flag.

This follows timedatex and allows timedated to correctly detect a clock
synchronized by chronyd when configured to not synchronize the RTC.
2019-08-01 17:32:36 +02:00
Yu Watanabe 77372afbe0 time-util: introduce jiffies_to_usec() 2019-07-29 23:52:37 +09:00
Thomas Haller 6fd79cca68 errno-util: return const string from strerror_safe()
C's strerror() function does not return a "const char *" pointer
for the string. That has historic reasons and C99 even comments
that "[t]he array pointed to shall not be modified by the program".

Make the strerror_safe() wrapper correct this and be more strict
in this regard.
2019-07-26 18:42:49 +02:00
Lennart Poettering 17f8fd9cf7
Merge pull request #13194 from keszybz/chase-symlinks-testing
Chase symlinks testing
2019-07-26 18:42:31 +02:00
Zbigniew Jędrzejewski-Szmek 22f62b1274 fs-util: CHASE_NOFOLLOW is not limited to CHASE_OPEN
$ build/test-chase-symlinks /etc/os-release
/etc/os-release → /usr/lib/os-release

$ build/test-chase-symlinks --nofollow /etc/os-release /etc/../etc/os-release /etc/../etc/./././os-release
/etc/os-release → /etc/os-release
/etc/../etc/os-release → /etc/os-release
/etc/../etc/./././os-release → /etc/os-release
2019-07-26 15:29:11 +02:00
Lennart Poettering 3e155eba43 random-seed: move pool size determination to random-util.[ch]
That way we can reuse it elsewhere.
2019-07-25 18:16:46 +02:00
Lennart Poettering 5373172e80 xattr-util: document that we NUL suffix 2019-07-25 17:10:51 +02:00
Lennart Poettering 63d59b8dcf fs-util: add fsync_full() helper
We usually combine an fsync() with fsync_directory_of_file() hence let's
add a helper that does both in one.
2019-07-25 17:10:51 +02:00
Yu Watanabe 8f815e8b03 tree-wide: drop netinet/ether.h from socket-util.h and sd-netlink.h 2019-07-24 18:23:08 +09:00
Lennart Poettering ad3f86e6a4
Merge pull request #13109 from poettering/revert-kbd-mode
Revert of #12378 ("VT kbd reset check")
2019-07-23 14:58:37 +02:00
Zbigniew Jędrzejewski-Szmek 5f4a882395 pid1: make sure we look at /proc/1/cmdline when parsing config
In recent systemd-nspawn we wouldn't parse init args like systemd.log-level=debug.
This is because we wouldn't even look at /proc/1/cmdline.

$ systemd-nspawn -n cat /proc/1/stat
1 (cat) R 0 1 1 34816 ....
                ^^^^^
34816 is 136:0 a.k.a. /dev/pts/0.
2019-07-22 09:06:22 +02:00
Zbigniew Jędrzejewski-Szmek a505166845
Merge pull request #13096 from keszybz/unit-loading
Preparatory work for the unit loading rework
2019-07-19 21:47:10 +02:00
Zbigniew Jędrzejewski-Szmek 4293c32b0e fs-util: adjust punctuation in comments 2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek b47aa73a9a basic/path-util: move two path_simplify* functions to be adjacent
No functional change.
2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek 3c4e303136 basic/set: constify operations which don't modify Set
No functional change, but it's nicer to the reader.
2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek 87da87846d basic/hashmap: add hashops variant that does strdup/freeing on its own
So far, we'd use hashmap_free_free to free both keys and values along with
the hashmap. I think it's better to make this more encapsulated: in this variant
the way contents are freed can be decided when the hashmap is created, and
users of the hashmap can always use hashmap_free.
2019-07-19 16:50:36 +02:00
Zbigniew Jędrzejewski-Szmek cde7910993 sysusers,strv: export the hash ops to map char* → strv
Also make string_strv_hashmap_put return 0 only if the entry already existed.
2019-07-19 16:49:41 +02:00
Zbigniew Jędrzejewski-Szmek b124d3f2ce basic/unit-name: allow unit_name_to_instance() to be used to classify units
This could already be done by calling unit_name_is_*(), but if we don't know
if the argument is a valid unit name, it is more convenient to have a single
function which returns the type or possibly an error if the unit name is not
valid.

The values in the enum are sorted "by length". Not really important, but it
seems more natural to me.
2019-07-19 16:49:41 +02:00
Zbigniew Jędrzejewski-Szmek 69de5c16ff basic/unit-name: drop unused function 2019-07-19 16:49:41 +02:00
Zbigniew Jędrzejewski-Szmek cc4d7d818d path-util: add path_startswith_strv() 2019-07-19 16:49:41 +02:00
Zbigniew Jędrzejewski-Szmek f4c961169c
Merge pull request #13102 from mbiebl/nologin-path
meson: make nologin path build time configurable
2019-07-18 17:17:23 +02:00
Lennart Poettering 26382cab1b Revert "Move verify_vc_kbmode() to terminal-util.c as vt_verify_kbmode()"
This reverts commit bb5ac84d79.
2019-07-18 16:21:02 +02:00
Lennart Poettering 15bba61325 Revert "Add check to switch VTs only between K_XLATE or K_UNICODE"
This reverts commit 13a43c73d8.
2019-07-18 16:21:02 +02:00
Michael Biebl 6db904625d meson: make nologin path build time configurable
Some distros install nologin as /usr/sbin/nologin, others as
/sbin/nologin.
Since we can't really on merged-usr everywhere (where the path wouldn't
matter), make the path build time configurable via -Dnologin-path=.

Closes #13028
2019-07-18 12:46:35 +02:00
Michael Olbrich fcfc7e1137 basic: reorder UnitType enum
The enum order will be used to order jobs in the job queue.
Make sure that unit types that fork aditional processes come first to
maximize parallelism.
2019-07-18 09:54:03 +02:00
Frantisek Sumsal c087dc0c35
Merge pull request #13093 from keszybz/two-assert-cc-cleanups
Two assert_cc cleanups
2019-07-17 15:53:35 +00:00
Lennart Poettering 81c07a9555
Merge pull request #13080 from keszybz/firstboot-fixes
Firstboot fixes
2019-07-17 14:43:15 +02:00
Zbigniew Jędrzejewski-Szmek d268ab389c Rewrite IN_SET()
This restores proper speed with asan builds with gcc 9.1.1.
Fixes #12997.

$ rpm -q gcc
gcc-9.1.1-2.fc31.x86_64

$ time ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1 UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1 build-rawhide-sanitize/test-conf-parser

(old) 86.99s user 20.22s system 361% cpu 29.635 total
(new)  3.05s user  0.29s system  99% cpu  3.377 total

Size is increased a bit:

$ size build/systemd
(old) 1683421	 246100	   1208	1930729	 1d75e9	build/systemd
(new) 1688237	 246100	   1208	1935545	 1d88b9	build/systemd

... but that's <0.1%, so we don't really care.
2019-07-17 14:22:53 +02:00
Lennart Poettering 76c887fdaa
Merge pull request #13092 from keszybz/coverity-fixes
Coverity fixes
2019-07-17 14:18:49 +02:00
Lennart Poettering 5f3626bb13
Merge pull request #13091 from poettering/nspawn-copy
nspawn: allow nspawn's copy operation to be abortable via C-c
2019-07-17 14:10:06 +02:00
Zbigniew Jędrzejewski-Szmek ab1a1ba5dc Drop trailing slash from assert_cc() definition
We use assert_cc(...); almost everywhere. Let's always require that.

https://github.com/systemd/systemd/issues/12997#issuecomment-510103988
2019-07-17 12:57:20 +02:00
Zbigniew Jędrzejewski-Szmek cfec3117d4 basic/macro: drop do {} while(0) from assert_not_reached
log_assert_failed_unreachable is just a normal function call, no need to wrap
it.

https://github.com/systemd/systemd/issues/12997#issuecomment-510103988
2019-07-17 12:27:33 +02:00
Zbigniew Jędrzejewski-Szmek 03d9429468 firstboot: actually accept empty input to mean skip
We'd loop if the input was empty. We need to return to the caller.
2019-07-17 12:07:19 +02:00
Zbigniew Jędrzejewski-Szmek ee41670ffb firstboot: fix hang waiting for second Enter on input
The comment explains the reason: we'd wait for the second \n
and then ungetc() it. Then the buffered \n would cause a problem
when the next prompt was issued, so in effect it wasn't possible
to answer the second question.
2019-07-17 12:07:19 +02:00
Zbigniew Jędrzejewski-Szmek 8a07b4033e shared/conf-parser,networkd: EXTRACT_UNQUOTE|EXTRACT_RETAIN_ESCAPE → EXTRACT_UNQUOTE
It's hard to even say what exactly this combination means. Escaping is
necessary when quoting to have quotes within the string. So the escaping of
quote characters is inherently tied to quoting. When unquoting, it seems
natural to remove escaping which was done for the quoting purposes. But with
both flags we would be expected to re-add this escaping after unqouting? Or
maybe keep the escaping which is not necessary for quoting but otherwise
present? This all seems too complicated, let's just forbid such usage and
always fully unescape when unquoting.
2019-07-17 11:35:04 +02:00
Zbigniew Jędrzejewski-Szmek ba5d26ccb2 shared: voidify call to loop_write() and trim duplicate code
Coverity CID#1402375.
2019-07-17 11:35:04 +02:00
Anita Zhang 31cd5f63ce core: ExecCondition= for services
Closes #10596
2019-07-17 11:35:02 +02:00
Lennart Poettering 07a30bb18a btrfs-util: expose SIGINT behaviour in snapshot copy fallback, too 2019-07-17 11:14:11 +02:00
Lennart Poettering 85559592a6 copy: optionally check for SIGINT regularly, and abort operation safely 2019-07-17 11:14:11 +02:00
Lennart Poettering f200a3564c
Merge pull request #13063 from keszybz/cgroup-path-fixes
Cgroup path fixes
2019-07-16 11:53:31 +02:00
Yu Watanabe 8cec0a5c32 tree-wide: drop duplicated blank lines
```
$ for i in */*.[ch] */*/*.[ch]; do sed -e '/^$/ {N; s/\n$//g}' -i $i; done
$ git checkout HEAD -- basic/linux shared/linux
```
2019-07-15 18:41:27 +02:00
Zbigniew Jędrzejewski-Szmek 95b21cff0e Apply empty_to_root() in three more spots for safety 2019-07-15 18:39:26 +02:00
Lennart Poettering a7d9fccd0e locale-util: suppress non-UTF-8 locales when enumerating them
Let's hide non-UTF-8 locales by default. It's 2019 after all.

Let's add an undocumented env var to reenable listing them though.

This should substantially shorten the list of choices we offer users,
and only show realistic choices.

note that only firstboot and localectl make use of this information, and
both allow configuration of values outside of these lists, hence all
this change does is hide legacy options, but they are still available if
you know what you do, and that's how it should be.
2019-07-14 11:05:34 +02:00
Lennart Poettering 13f4580626 locale-util: normalize UTF-8 locale names
Let's generate out lists in the format people expect.
2019-07-14 11:05:34 +02:00
Yu Watanabe 94e016650d
Merge pull request #13043 from poettering/strip-tab-ansi-no-static-size
util-lib: [static] array argument sizes are apparently not OK for NUL…
2019-07-13 18:12:39 +09:00
Lennart Poettering b65011dad0 alloc-util: drop _alloc_ decorator from memdup_suffix0()
Fixes: https://github.com/systemd/systemd/pull/13034#issuecomment-510801671
2019-07-13 11:04:20 +02:00
Lennart Poettering 6fb0569065 util-lib: [static] array argument sizes are apparently not OK for NULL parameters
Let's drop the 'static' logic when a parameter can be NULL.

I think asan/ubsan are right here, judging by the C99 spec language:

"A declaration of a parameter as ‘‘array of type’’ shall be adjusted to
‘‘qualified pointer to type’’, where the type qualifiers (if any) are
those specified within the [ and ] of the array type derivation. If the
keyword static also appears within the [ and ] of the array type
derivation, then for each call to the function, the value of the
corresponding actual argument shall provide access to the first element
of an array with at least as many elements as specified by the size
expression."

If we specify NULL, then we certainly don't pvode access to any valid
array.

Fixes: #13039
2019-07-12 16:40:10 +02:00
Lennart Poettering 5978345750
Merge pull request #13034 from poettering/memdup-suffix0-multiply-fixo
memdup_suffix0_multiply fix
2019-07-12 14:11:31 +02:00
Lennart Poettering bf21be1050 util-lib: fix comment
As suggested by @ralt.

Fixes: #12896
2019-07-12 09:37:49 +02:00
Lennart Poettering 7d025debfa alloc-util: drop _alloc_(2, 3) decorator from memdup_suffix0_multiply()
This decorator tells compilers that the memory we return is shorter than
it actually is, thus triggering misleading bad memory access complaints.

Fixes: #13026
2019-07-12 09:11:40 +02:00
Lennart Poettering b910cc72c0 tree-wide: get rid of strappend()
It's a special case of strjoin(), so no need to keep both. In particular
as typing strjoin() is even shoert than strappend().
2019-07-12 14:31:12 +09:00
Yu Watanabe 6fa0524133
Merge pull request #12971 from yuwata/network-reassign-static-routes
network: reassign static routes and process reply address messages
2019-07-12 09:36:16 +09:00
Lennart Poettering 66855de739 tree-wide: make use of errno_or_else() everywhere 2019-07-11 23:20:31 +02:00
Lennart Poettering fed813778f errno-util: add new errno_or_else() helper 2019-07-11 23:20:31 +02:00
Yu Watanabe 9a897e22d4 util: introduce in4_addr_equal() 2019-07-11 22:37:00 +09:00
Lennart Poettering 4c2f584230 core: hook up service unit type with the new clean operation
The implementation is pretty straight-foward: when we get a request to
clean some type of resources we fork off a process doing that, and while
it is running we are in the "cleaning" state.
2019-07-11 12:18:51 +02:00
Lennart Poettering 380dc8b0a2 core: add generic "clean" operation to units
This adds basic infrastructure to implement a "clean" operation for unit
types. This "clean" operation is supposed to remove on-disk resources of
units, and is supposed to be used in a later commit to clean our
RuntimeDirectory=, StateDirectory= and so on of service units.

Later commits will open this up to the bus, and hook up service units
with this.

This also adds a new generic ActiveState called UNIT_MAINTENANCE. It's
supposed to cover all kinds of "maintainance" state of units.
Specifically, this is supposed to cover the "cleaning" operations later
added for service units which might take a bit of time. This high-level,
generic, abstract state is called UNIT_MAINTENANCE instead of the
more specific "UNIT_CLEANING", since I think this should be kept open
for different operations possibly later on that could be nicely subsumed
under this (for example, maybe a recursive chown()ing operation could be
covered by this, and similar).
2019-07-11 12:18:51 +02:00
Lennart Poettering c0228b4fa3 rm-rf: introduce new flag REMOVE_MISSING_OK
This new flag suppresses error if the top-level path specified doesn't
exist. This is useful since suppressing this on the caller side isn't
easy, since ENOENT migh be propagate for some reason from further inside
and we can't distuingish that.

While we are at it, also be a bit more careful witht the various
combinations of flags.

(Note that in some cases rm_rf() was already ignoring ENOENT from
unlink() or rmdir(), however that was pretty useless, since we always
open() the top-level path with O_DIRECTORY and if that hit ENOENT we
didn't ignore the failure).
2019-07-11 12:18:51 +02:00
Lennart Poettering 8e27167cc9
Merge pull request #13011 from keszybz/auto-erase
Remove string_erase and friends
2019-07-11 01:05:01 +02:00
Lennart Poettering 08945b59d1
Merge pull request #12926 from keszybz/urlify-logs
Urlify CONFIG_FILE and improve SYSTEMD_LOG_LOCATION
2019-07-11 00:00:34 +02:00
Lennart Poettering 6f209cb01d
Merge pull request #12965 from keszybz/auto-erase
_cleanup_(erase_and_freep)
2019-07-10 16:20:50 +02:00
Lennart Poettering ba40f0399e
Merge pull request #12939 from yuwata/lgtm-fixes
make LGTM quiet
2019-07-10 14:57:14 +02:00
Zbigniew Jędrzejewski-Szmek 309c6b19a7 Remove string_erase 2019-07-10 14:43:44 +02:00
Zbigniew Jędrzejewski-Szmek 9ae4ef49cd Remove string_free_erase 2019-07-10 13:48:55 +02:00
Zbigniew Jędrzejewski-Szmek 44c786f04a test: add _cleanup_(erase_and_freep)
Based on the macro and test case by Lennart Poettering and
Topi Miettinen suggestion.
2019-07-10 11:39:03 +02:00
Yu Watanabe 8164e30603 util: fix sign-compare warning 2019-07-09 09:54:13 +02:00
Ivan Shapovalov df2452c553 basic/log: fix SYSTEMD_LOG_* parsing error messages
(likely a copy-paste gone wrong)
2019-07-06 13:47:06 +03:00
Yu Watanabe 4bbccb02ea tree-wide: introduce strerror_safe() 2019-07-05 02:43:56 +09:00
Zbigniew Jędrzejewski-Szmek 1f65fd4926 basic/time-util: add helper function to check if timestamp is set
No functional change.
2019-07-04 19:12:47 +02:00
Zbigniew Jędrzejewski-Szmek bdc3426870 basic/log: omit ":0" from message when line number is not specified
And obviously CONFIG_LINE=0 is also not logged.

The way that log_syntax_internal now looks is becoming a bit crazy, but we
can't easily conditionalize on both unit and config_file, and we have different
types, so it's not easy to make this more compact.
2019-07-04 10:36:24 +02:00
Zbigniew Jędrzejewski-Szmek 62c6bbbc09 tree-wide: use PROJECT_FILE instead of __FILE__
This replaces the internal uses of __FILE__ with the new macro.
2019-07-04 10:36:00 +02:00
Zbigniew Jędrzejewski-Szmek a0b15b4177 basic/log: add a define for path relative to source root
When using build/ directory inside of the source directory:
__FILE__: ../src/test/test-log.c
RELATIVE_SOURCE_PATH: ..
PROJECT_FILE: src/test/test-log.c

When using a build directory outside of the source directory:
__FILE__: ../../../home/zbyszek/src/systemd-work/src/test/test-log.c
RELATIVE_SOURCE_PATH: ../../../home/zbyszek/src/systemd-work
PROJECT_FILE: src/test/test-log.c
2019-07-04 10:27:19 +02:00
Lennart Poettering a0ea1dee7b blockdev-util: let us know if block_get_whole_disk() did anything 2019-07-04 00:01:09 +02:00
Lennart Poettering 51f14fa111 blockdev: filter out invalid block devices early 2019-07-04 00:00:54 +02:00
Lennart Poettering d18b300933 blockdev-util: propagate actual error 2019-07-04 00:00:44 +02:00
Zbigniew Jędrzejewski-Szmek d35305fe83 basic/log: put location in a dark shade of yellow
It is different then the other colors we use. Tested on gnome-terminal,
urxvt, urxvt -rv, xterm, linux console.
2019-07-02 09:34:12 +02:00
Zbigniew Jędrzejewski-Szmek 1ad023e770 basic/log: drop parens from around file location information
There's really no risk of confusion, and shorter is better.
2019-07-01 14:32:45 +02:00
Yu Watanabe 539bcc831b
Merge pull request #12903 from keszybz/condition-quoting
Condition quoting
2019-06-30 04:10:40 +09:00
Zbigniew Jędrzejewski-Szmek f8bab19674
Merge pull request #12887 from fbuihuu/coredump-cleanup-part-1
Coredump cleanup part 1
2019-06-28 16:25:46 +02:00
Zbigniew Jędrzejewski-Szmek 4ec8514142 Rename EXTRACT_QUOTES to EXTRACT_UNQUOTE
Whenever I see EXTRACT_QUOTES, I'm always confused whether it means to
leave the quotes in or to take them out. Let's say "unquote", like we
say "cunescape".
2019-06-28 11:35:05 +02:00
Franck Bui ae41fdb66a io-util: introduce iovw_put_string_field() helper 2019-06-27 19:14:27 +02:00
Franck Bui 11e6d9714e journal-import: extract helpers for handling arrays of iovec and make them available for others 2019-06-27 19:14:23 +02:00
Franck Bui 30a0554ebd coredump: rename set_iovec_field_free() into set_iovec_string_field_free()
It's more in line with its counterpart set_iovec_string_field().

Also move the definition to io-util next to set_iovec_string_field().
2019-06-27 19:01:28 +02:00
Yu Watanabe 71d7a8218d util,test: rename variable non_iec -> si 2019-06-27 10:17:20 +09:00
Lennart Poettering 05b2ace147
Merge pull request #12870 from yuwata/tree-wide-further-path-join-cleanups
tree-wide: further path_join() and path_joina() cleanups
2019-06-25 09:27:01 +02:00
Yu Watanabe 2d9b74ba87 tree-wide: replace strjoin() with path_join() 2019-06-24 23:59:38 +09:00
Michal Sekletar b070c7c0e1 core: introduce NUMAPolicy and NUMAMask options
Make possible to set NUMA allocation policy for manager. Manager's
policy is by default inherited to all forked off processes. However, it
is possible to override the policy on per-service basis. Currently we
support, these policies: default, prefer, bind, interleave, local.
See man 2 set_mempolicy for details on each policy.

Overall NUMA policy actually consists of two parts. Policy itself and
bitmask representing NUMA nodes where is policy effective. Node mask can
be specified using related option, NUMAMask. Default mask can be
overwritten on per-service level.
2019-06-24 16:58:54 +02:00
Yu Watanabe 95bbf19e2f path-util: fix an issue when the path argument of prefix_roota() is not absolute
When the first argument is '/' and the second argument is not absolute,
the return value was not prefixed with '/'. This fixes the issue.
2019-06-24 23:37:11 +09:00
Yu Watanabe 6abdec98f3 tree-wide: use _cleanup_ attribute and strv_consume() + TAKE_PTR() 2019-06-24 14:57:58 +09:00
Lennart Poettering cee97d5768
Merge pull request #12836 from yuwata/tree-wide-replace-strjoin
tree-wide: replace strjoin() with path_join()
2019-06-22 20:02:46 +02:00
Topi Miettinen e48fcfef06 cgroup-util: kill also threads
It's possible for a zombie process to have live threads. These are not listed
in /sys in "cgroup.procs" for cgroupsv2, but they show up in
"cgroup.threads" (cgroupv2) or "tasks" (cgroupv1) nodes. When killing a
cgroup (v2 only) with SIGKILL, let's also kill threads after killing processes,
so the live threads of a zombie get killed too.

Closes #12262.
2019-06-22 18:35:48 +02:00
Lennart Poettering c6134d3e2f path-util: get rid of prefix_root()
prefix_root() is equivalent to path_join() in almost all ways, hence
let's remove it.

There are subtle differences though: prefix_root() will try shorten
multiple "/" before and after the prefix. path_join() doesn't do that.
This means prefix_root() might return a string shorter than both its
inputs combined, while path_join() never does that. I like the
path_join() semantics better, hence I think dropping prefix_root() is
totally OK. In the end the strings generated by both functon should
always be identical in terms of path_equal() if not streq().

This leaves prefix_roota() in place. Ideally we'd have path_joina(), but
I don't think we can reasonably implement that as a macro. or maybe we
can? (if so, sounds like something for a later PR)

Also add in a few missing OOM checks
2019-06-21 08:42:55 +09:00
Anita Zhang f66ad46066 nspawn: don't hard fail when setting capabilities
The OCI changes in #9762 broke a use case in which we use nspawn from
inside a container that has dropped capabilities from the bounding set
that nspawn expected to retain. In an attempt to keep OCI compliance
and support our use case, I made hard failing on setting capabilities
not in the bounding set optional (hard fail if using OCI and log only
if using nspawn cmdline).

Fixes #12539
2019-06-20 21:46:36 +02:00
Yu Watanabe 657ee2d82b tree-wide: replace strjoin() with path_join() 2019-06-21 03:26:16 +09:00
Lennart Poettering 4a33a02e99 capability: fix loops for cap_last_cap()
cap_last_cap() returns the last valid cap (instead of the number of
valid caps). to iterate through all known caps we hence need to use a <=
check, and not a < check like for all other cases. We got this right
usually, but in three cases we did not.
2019-06-20 14:55:24 +02:00
Lennart Poettering 64ef83139c
Merge pull request #12837 from yuwata/tree-wide-lgtm-fixes
tree-wide: fix issues found by lgtm
2019-06-20 12:35:34 +02:00
Yu Watanabe b19eab1f74
Merge pull request #12806 from yuwata/networkctl-ethtool-12657
networkctl: show speed, duplex, auto negotiation, and port
2019-06-20 06:56:37 +09:00
Yu Watanabe 31a9be2372 util: use extract_first_word() instead of strsep() 2019-06-20 06:51:34 +09:00
Yu Watanabe b7de125bba util: make format_bytes() support e.g. 3.0E 2019-06-19 23:15:19 +09:00
Yu Watanabe aa89266900 util: introduce format_bytes_full()
And move it into format-util.c.
2019-06-19 23:15:19 +09:00
Yu Watanabe f3f0d873e2 util: introduce siphash24_compress_boolean() 2019-06-19 21:03:16 +09:00
Frantisek Sumsal 31c9d74d50 hashmap: avoid using TLS in a destructor
Using C11 thread-local storage in destructors causes uninitialized
read. Let's avoid that using a direct comparison instead of using
the cached values. As this code path is taken only when compiled
with -DVALGRIND=1, the performance cost shouldn't matter too much.

Fixes #12814
2019-06-18 13:59:12 +02:00
Franck Bui ae1d13db05 terminal-util: introduce openpt_allocate()
Allocating a pty is done in a couple of places so let's introduce a new helper
which does the job.

Also the new function, as well as openpt_in_namespace(), returns both pty
master and slave so the callers don't need to know about the pty slave
allocation details.

For the same reasons machine_openpt() prototype has also been changed to return
both pty master and slave so callers don't need to allocate a pty slave which
might be in a different namespace.

Finally openpt_in_namespace() has been renamed into
openpt_allocate_in_namespace().
2019-06-18 09:26:31 +02:00
Franck Bui 04c84cd173 namespace-util: make use of TAKE_FD()
No functional changes.
2019-06-18 07:54:51 +02:00
Franck Bui 71ec74d193 fs-util: no need for fchmod_and_chown() to access /proc/self/fd directly
fstat(2) is fine with O_PATH fds.

For changing owership of a file opened with O_PATH, there's fchownat(2).

Only changing permissions is problematic but we introduced fchmod_opath() for
that purpose.
2019-06-18 07:54:51 +02:00
Zbigniew Jędrzejewski-Szmek 2bb24885de
Merge pull request #12700 from yuwata/udev-propagate-critical-errors
udev: modernize code and propagate critical errors
2019-06-03 15:29:40 +02:00
Zbigniew Jędrzejewski-Szmek 3135369cff basic/memory-util: do not "return" anything from memzero() macro
The macro is not used in expressions, so we don't need the ternary statement.
2019-05-30 22:55:32 +02:00
Yu Watanabe 7e4831d296 util: introduce strnpcpy() and strnscpy() 2019-05-30 21:08:51 +09:00
Yu Watanabe 961189af2a util: introduce PTR_TO_MODE and MODE_TO_PTR macros 2019-05-30 21:08:51 +09:00
Michal Sekletar 3f09629c22
Merge pull request #12628 from keszybz/dbus-execute
Rework cpu affinity parsing
2019-05-30 12:32:53 +02:00
Zbigniew Jędrzejewski-Szmek f44b3035d4 Move cpus_in_affinity_mask() to cpu-set-util.[ch]
It just seems to fit better there and it's always better to have things
in shared/ rather than basic/.
2019-05-29 10:26:00 +02:00
Yu Watanabe 518a66ec08 tree-wide: replace if_indextoname() with format_ifname() 2019-05-29 14:21:19 +09:00
Yu Watanabe 7f686722f7 util: introduce format_ifname() 2019-05-29 14:21:19 +09:00
Yu Watanabe f5072281ba util: add assertions 2019-05-29 13:21:51 +09:00
Yu Watanabe 88465a4ee7 util: introduce parse_ifindex_or_ifname() 2019-05-29 13:21:18 +09:00
Zbigniew Jędrzejewski-Szmek 6bf901a9b5
Merge pull request #12437 from poettering/chmod-and-chown-rewrite
chmod_and_chown() rewrite
2019-05-28 15:12:20 +02:00
Zbigniew Jędrzejewski-Szmek 127c167cdb
Merge pull request #12390 from poettering/string-file-mkdir
fileio: add a WRITE_STRING_FILE_MKDIR_0755 flag to write_string_file() that creates parent directories if needed
2019-05-28 14:42:55 +02:00
Zbigniew Jędrzejewski-Szmek 365939fc9f
Merge pull request #12392 from poettering/firstboot-salt
generalize crypt_r() salt generation code
2019-05-28 14:36:54 +02:00
Lennart Poettering 1c99d2e0c5
Merge pull request #12597 from keszybz/analyze-timestamp
Analyze timestamps
2019-05-28 14:34:53 +02:00
Lennart Poettering 7345109e61 capability-util: be more careful with types 2019-05-28 14:23:20 +02:00
Lennart Poettering 1802d5f2cf terminal-util: reset access mode in vt_restore(), too
Only changing ownership back to root is not enough we also need to
change the access mode, otherwise the user might have set 666 first, and
thus allow everyone access before and after the chown().
2019-05-24 15:07:55 +02:00
Lennart Poettering 4b3b5bc71b tree-wide: port various places over to use chmod_and_chown()
Doing this properly is hard, hence let's unify the code.
2019-05-24 15:07:55 +02:00
Lennart Poettering f8a8579e84 tmpfile-util: simplify umask reset declaration 2019-05-24 15:07:55 +02:00
Lennart Poettering 2dbb7e94af fs-util: rewrite chmod_and_chown()
Inspired by #12431 let's also rework chmod_and_chown() and make sure we
never add more rights to a file not owned by the right user.

Also, let's make chmod_and_chown() just a wrapper arond
fchmod_and_chown().

let's also change strategy: instead of chown()ing first and stating
after on failure and supressing errors, let's avoid the chown in the
firts place, in the interest on keeping things minimal.
2019-05-24 15:07:55 +02:00
Lennart Poettering d631a760e0
Merge pull request #12601 from keszybz/two-log-color-adjustments
Two log color adjustments
2019-05-24 10:43:07 +02:00
Zbigniew Jędrzejewski-Szmek 4c6d51390c basic/utf8: reduce memory usage 2019-05-22 10:22:20 +02:00