Commit graph

32137 commits

Author SHA1 Message Date
Lennart Poettering 972d4398bd update TODO 2018-02-09 19:43:35 +01:00
Lennart Poettering c81a256914 mkosi: no need to determine meson parameters if we don't run meson
Small optimization.
2018-02-09 19:22:40 +01:00
Lennart Poettering cc6271f17d core: turn on memory/cpu/tasks accounting by default for the root slice
The kernel exposes the necessary data in /proc anyway, let's expose it
hence by default.

With this in place "systemctl status -- -.slice" will show accounting
data out-of-the-box now.
2018-02-09 19:07:39 +01:00
Lennart Poettering 1f73aa0021 core: hook up /proc queries for the root slice, too
Do what we already prepped in cgtop for the root slice in PID 1 too:
consult /proc for the data we need.
2018-02-09 19:05:59 +01:00
Lennart Poettering b734a4ff14 cgroup-util: rework cg_get_keyed_attribute() a bit
Let's make sure we don't clobber the return parameter on failure, to
follow our coding style. Also, break the loop early if we have all
attributes we need.

This also changes the keys parameter to a simple char**, so that we can
use STRV_MAKE() for passing the list of attributes to read.

This also makes it possible to distuingish the case when the whole
attribute file doesn't exist from one key in it missing. In the former
case we return -ENOENT, in the latter we now return -ENXIO.
2018-02-09 18:35:52 +01:00
Lennart Poettering 744c39ff7e cgtop: hook up new /proc based emulation code for root cgroup memory/cpu stats
Let's make this work.
2018-02-09 17:34:31 +01:00
Lennart Poettering a04fcf17ba procfs-util: add APIs to get consumed CPU time and used memory from /proc
This is preparation for emulating the "usage_usec" keyed attribute of
the "cpu.stat" property of the root cgroup from data in /proc. Similar,
for emulating the "memory.current" attribute.
2018-02-09 17:32:26 +01:00
Lennart Poettering ba4b1544f2 cgtop: tweak root cgroup detection a bit
Inside a cgroup-namespaced container we shouldn't assume that "/" is
really the root cgroup, because it generally is not.
2018-02-09 17:31:55 +01:00
Lennart Poettering ad078b4181 cgtop: command line parsing improvements
Always output the string we were unable to parse and use
log_error_errno()'s return logic to shorten our code a bit.
2018-02-09 16:59:27 +01:00
Lennart Poettering a7e6de218b cgtop: add helper for checking if we are operating on the root cgroup 2018-02-09 16:58:35 +01:00
Lennart Poettering 4fc9ffab3b cgtop: add "-1" as shortcut for "--iterations=1"
This is most likely the most useful use of --iterations, and such use
for numeric parameters has precedents, let's make this work for cgtop too.
2018-02-09 16:58:01 +01:00
Lennart Poettering 9c6e3e1d3b cgtop: correctly order root cgroup always to the top
Internally, we encode the root cgroup as empty string. However,
path_compare() is allergic to comparing absolute and relative paths.

Let's clean this up, by always uses "/" as path for the root cgroup when
comparing.
2018-02-09 16:53:09 +01:00
Lennart Poettering af77d6f8da
Merge pull request #8083 from shawnl/close-ssh
sd-bus: cleanup ssh sessions (Closes: #8076)
2018-02-09 12:17:26 +01:00
Lennart Poettering 8c2dbc8779
Merge pull request #8142 from yuwata/sd-bus-memleak
Fix potential memory leaks and several code style updates
2018-02-09 11:39:26 +01:00
Yu Watanabe f2e18ef1a3 core: remove unnecessary initialization 2018-02-09 16:36:37 +09:00
Yu Watanabe 43beb0cf68 udev: use "#pragma once" 2018-02-09 16:33:30 +09:00
Yu Watanabe e5c8029e13 sd-bus: explicitly convert int to bool 2018-02-09 16:22:00 +09:00
Yu Watanabe cad4fb19c8 sd-bus: use free_and_replace() 2018-02-09 16:21:51 +09:00
Yu Watanabe b4ca3f45dc sd-bus: avoid potential memory leaks 2018-02-09 16:21:29 +09:00
Lucas Werkmeister 3c84514d07 man: fix capability name in man:systemd-tmpfiles(8) (#8139)
CAP_ADMIN does not exist (the closest existing capability name would be
CAP_SYS_ADMIN), and according to man:open(2) and man:capabilities(7),
the capability required to specify O_NOATIME is actually CAP_FOWNER.
2018-02-09 11:05:49 +09:00
Peter Portante 992149c07e Periodically call sd_journal_process in journalctl
If `journalctl` take a long time to process messages, and during that
time journal file rotation occurs, a `journalctl` client will keep
those rotated files open until it calls `sd_journal_process()`, which
typically happens as a result of calling `sd_journal_wait()` below in
the "following" case.  By periodically calling `sd_journal_process()`
during the processing loop we shrink the window of time a client
instance has open file descriptors for rotated (deleted) journal
files.

**Warning**

This change does not appear to solve the case of a "paused" output
stream. If somebody is using `journalctl | less` and pauses the
output, then without a background thread periodically listening for
inotify delete events and cleaning up, journal logs will eventually
stop flowing in cases where a journal client with enough open files
causes the "free" disk space threshold to be crossed.
2018-02-08 20:04:18 +01:00
Shawn Landden 392cf1d05d sd-bus: cleanup ssh sessions (Closes: #8076)
we still invoke ssh unnecessarily when there in incompatible or erreneous input
The fallow-up to finish that would make the code a bit more verbose,
as it would require repeating this bit:
```
        r = bus_connect_transport(arg_transport, arg_host, false, &bus);
        if (r < 0) {
                log_error_errno(r, "Failed to create bus connection: %m");
                goto finish;
        }

        sd_bus_set_allow_interactive_authorization(bus, arg_ask_password);
```
in every verb, after parsing.

v2: add waitpid() to avoid a zombie process, switch to SIGTERM from SIGKILL
v3: refactor, wait in bus_start_address()
2018-02-08 10:14:48 -08:00
Shawn Landden ade681a861 machine: add some missing asserts 2018-02-08 10:10:40 -08:00
Susant Sahani bf443be995 networkd: vxlan require Remote= to be a non multicast address (#8117)
Remote= must be a non multicast address. ip-link(8) says:
> remote IPADDR - specifies the unicast destination IP address to
>                      use in outgoing packets when the destination link layer address
>                      is not known in the VXLAN device forwarding database.

Closes #8088.
2018-02-08 10:22:46 +01:00
Faalagorn ed10715af2 man: .service <filename> to <literal> (#8126)
Changed <filename>.service</filename> to <literal>.service</literal> to match style in other manual pages: man 5 systemd.socket, device, mount, automount, swap, target path, timer, slice and scope.
2018-02-08 09:14:55 +01:00
Alan Jenkins b36003461a journal: avoid code that relies on LOG_KERN == 0 (#8110)
LOG_FAC() is the general way to extract the logging facility (when it has
been combined with the logging priority).

LOG_FACMASK can be used to mask off the priority so you only have the
logging facility bits... but to get the logging facility e.g. LOG_USER,
you also have to bitshift it as well.  (The priority is in the low bits,
and so only requires masking).

((priority & LOG_FACMASK) == LOG_KERN) happens to work only because
LOG_KERN is 0, and hence has the same value with or without the bitshift.

Code that relies on weird assumptions like this could make it harder to
realize how the logging values are treated.
2018-02-08 09:14:32 +01:00
Zbigniew Jędrzejewski-Szmek 3b8f29fd93
Merge pull request #8042 from zx2c4-forks/jd/networkctl-type
networkd: fixup networkctl type display
2018-02-08 09:12:31 +01:00
Faalagorn 6d5bd10230 man: "reboot" to "power off" in poweroff.target (#8124)
Changed "reboot" to "power off" in poweroff.target description. It was most likely copied and pasted from the reboot.target below, compare with e.g. halt.target
2018-02-07 10:10:41 -08:00
Franck Bui 9ea3a0e702 core: use id unit when retrieving unit file state (#8038)
Previous code was using the basename(id->fragment_path) which returned
incorrect result if the unit was an instance.

For example, assuming that no instances of "template" have been created so far:

 $ systemctl enable template@1
 Created symlink from /etc/systemd/system/multi-user.target.wants/template@1.service to /usr/lib/systemd/system/template@.service.

 $ systemctl is-enabled template@3.service
 disabled

 $ systemctl status template@3.servicetemplate@3.service - openQA Worker #3
    Loaded: loaded (/usr/lib/systemd/system/template@.service; enabled; vendor preset: disabled)
    [...]

Here the unit file states reported by "status" and "is-enabled" were different.
2018-02-07 14:08:02 +01:00
Lennart Poettering a166e13771
Merge pull request #8104 from keszybz/tmpfiles-allow-overrides
tmpfiles allow overrides
2018-02-07 12:12:52 +01:00
Lennart Poettering 996def17f9 process-util: use raw_getpid() in getpid_cache() internally (#8115)
We have the raw_getpid() definition in place anyway, and it's certainly
beneficial to expose the same semantics on pre glibc 2.24 and after it
too, hence always bypass glibc for this, and always cache things on our
side.

Fixes: #8113
2018-02-07 11:10:09 +09:00
Andrei Gherzan 3f602115b7 core: Avoid empty directory warning when we are bind-mounting a file (#8069) 2018-02-06 16:35:52 +01:00
Zbigniew Jędrzejewski-Szmek 9b4453b6ee
Merge pull request #8044 from yuwata/fix-7790
core: make ExecRuntime be manager managed object
2018-02-06 11:03:02 +01:00
Zbigniew Jędrzejewski-Szmek 81e19fa8c0
Merge pull request #8107 from sourcejedi/pedant
core: a couple of tidyups to synthesized units
2018-02-06 10:17:05 +01:00
Neal Gompa (ニール・ゴンパ) 32a00a9c09 Add more file triggers to handle more aspects of systemd (#8090)
For quite a while now, there have been file triggers to handle
automatically setting up service units in upstream systemd. However,
most of the actions being done by these macros upon files can be set up
as RPM file triggers.

In fact, in Mageia, we had been doing this for most of these. In particular,
we have file triggers in place for sysusers, tmpfiles, hwdb, and the journal.

This change adds Lua versions of the original file triggers used in Mageia,
based on the existing Lua-based file triggers for service units.

In addition, we can also have useful file triggers for udev rules, sysctl
directives, and binfmt directives. These are based on the other existing
file triggers.
2018-02-06 10:11:36 +01:00
Zbigniew Jędrzejewski-Szmek 9207564756
Merge pull request #8112 from yuwata/gcc-warning
Fix gcc warnings
2018-02-06 10:09:29 +01:00
Yu Watanabe 3e75a1bb43 nss-mymachines: add work-around to silence gcc warning
This is similar to 3c3d384ae9 and
a workaround for the following warning.
```
In file included from ../src/basic/in-addr-util.h:28,
                 from ../src/nss-mymachines/nss-mymachines.c:31:
../src/nss-mymachines/nss-mymachines.c: In function '_nss_mymachines_getgrnam_r':
../src/nss-mymachines/nss-mymachines.c:653:32: warning: argument to 'sizeof' in 'memset' call is the same pointer type 'char *' as the destination; expected 'char' or an explicit length [-Wsizeof-pointer-memaccess]
         memzero(buffer, sizeof(char*));
                                ^~~~
../src/basic/util.h:118:39: note: in definition of macro 'memzero'
 #define memzero(x,l) (memset((x), 0, (l)))
                                       ^
../src/nss-mymachines/nss-mymachines.c: In function '_nss_mymachines_getgrgid_r':
../src/nss-mymachines/nss-mymachines.c:730:32: warning: argument to 'sizeof' in 'memset' call is the same pointer type 'char *' as the destination; expected 'char' or an explicit length [-Wsizeof-pointer-memaccess]
         memzero(buffer, sizeof(char*));
                                ^~~~
../src/basic/util.h:118:39: note: in definition of macro 'memzero'
 #define memzero(x,l) (memset((x), 0, (l)))
                                       ^
```
2018-02-06 17:08:42 +09:00
Yu Watanabe aa18944d39 networkd: fix dhcp6_prefixes_compare_func()
Found by the following warning by gcc.
```
../src/network/networkd-manager.c: In function 'dhcp6_prefixes_compare_func':
../src/network/networkd-manager.c:1383:16: warning: 'memcmp' reading 16 bytes from a region of size 8 [-Wstringop-overflow=]
         return memcmp(&a, &b, sizeof(*a));
                ^
```
2018-02-06 17:06:01 +09:00
Yu Watanabe 34cf6c4340 core/execute: make arguments constant if possible
Also make functions static if possible.
2018-02-06 16:00:50 +09:00
Yu Watanabe e8a565cb66 core: make ExecRuntime be manager managed object
Before this, each ExecRuntime object is owned by a unit. However,
it may be shared with other units which enable JoinsNamespaceOf=.
Thus, by the serialization/deserialization process, its sharing
information, more specifically, reference counter is lost, and
causes issue #7790.

This makes ExecRuntime objects be managed by manager, and changes
the serialization/deserialization process.

Fixes #7790.
2018-02-06 16:00:34 +09:00
Lennart Poettering 960c7c2791
Merge pull request #8101 from keszybz/two-gcc-workarounds
Two gcc workarounds
2018-02-05 18:59:52 +01:00
Alan Jenkins fe16729868 journal: include kmsg lines from the systemd process which exec()d us (#8078)
Let the journal capture messages emitted by systemd, before it ran
exec("/usr/lib/systemd/systemd-journald").  Usually such messages will only
appear with `systemd.log_level=debug`.  kmsg lines written after the exec()
will be ignored as before.

In other words, we are avoiding reading our own lines, which start
"systemd-journald[100]: " assuming we are PID 100.  But now we will start
allowing ourself to read lines which start "systemd[100]: ", or any other
prefix which is not "systemd-journald[100]: ".

So this can't help you see messages when we fail to exec() journald :). But,
it makes it easier to see what the pre-exec() messages look like in
the successful case.  Comparing messages like this can be useful when
debugging.  Noticing weird omissions of messages, otoh, makes me anxious.
2018-02-05 17:53:40 +01:00
CuBiC 0e3c6bf0ce hwdb: fix mute microphone button on TravelMate P645-S (#8105) 2018-02-05 17:43:23 +01:00
Zbigniew Jędrzejewski-Szmek 3c3d384ae9 nss-systemd: add work-around to silence gcc warning
In file included from ../src/basic/fs-util.h:32,
                 from ../src/nss-systemd/nss-systemd.c:28:
../src/nss-systemd/nss-systemd.c: In function '_nss_systemd_getgrnam_r':
../src/nss-systemd/nss-systemd.c:416:32: warning: argument to 'sizeof' in 'memset' call is the same pointer type 'char *' as the destination; expected 'char' or an explicit length [-Wsizeof-pointer-memaccess]
         memzero(buffer, sizeof(char*));
                                ^~~~
../src/basic/util.h:118:39: note: in definition of macro 'memzero'
 #define memzero(x,l) (memset((x), 0, (l)))
                                       ^

gcc is trying to be helpful, and it's not far from being right. It _looks_ like
sizeof(char*) is an error, but in this case we're really leaving a space empty
for a pointer, and our calculation is correct. Since this is a short file,
let's just use simplest option and turn off the warning above the two functions
that trigger it.
2018-02-05 15:21:07 +01:00
Zbigniew Jędrzejewski-Szmek 1fe101747c basic/glob-util: add closedir wrapper to silence gcc
../src/test/test-glob-util.c: In function 'test_glob_no_dot':
../src/test/test-glob-util.c:61:32: warning: cast between incompatible function types from 'int (*)(DIR *)' {aka 'int (*)(struct __dirstream *)'} to 'void (*)(void *)' [-Wcast-function-type]
                 .gl_closedir = (void (*)(void *)) closedir,
                                ^
2018-02-05 15:20:46 +01:00
Zbigniew Jędrzejewski-Szmek 0f78fee8d0 rpm macros: add %tmpfiles_create_package
I expect that this will be mostly obsoleted by transfiletriggers that
(I hope) we will soon add. But let's do this for completeness anyway.
I'm keeping the description of the macro a bit vague, since I expect
that it'll be changed when transfiletriggers are added.
2018-02-05 15:04:54 +01:00
Zbigniew Jędrzejewski-Szmek a6d8474f39 tmpfiles: allow admin/runtime overrides to runtime config
This is very similar to d16a1c1bb6. For tmpfiles this is much less useful
compared to sysusers, but let's add this anyway for consistency.
2018-02-05 15:04:52 +01:00
Lennart Poettering cb51f86af8
Merge pull request #8077 from sourcejedi/seccomp_cosmetic
seccomp: allow x86-64 syscalls on x32, used by the VDSO (fix #8060)
2018-02-05 13:52:23 +01:00
Lennart Poettering da4ec1411e
Merge pull request #8100 from keszybz/free-gcrypt-context
Free gcrypt contexts properly
2018-02-05 13:47:29 +01:00
Olof Mogren 82cb27cf33 hwdb: added Cube i7 Book rotation info (#8103) 2018-02-05 11:52:43 +01:00