summaryrefslogtreecommitdiff
path: root/src/basic
AgeCommit message (Collapse)Author
2017-02-20core: make hybrid cgroup unified mode keep compat /sys/fs/cgroup/systemd ↵Tejun Heo
hierarchy Currently the hybrid mode mounts cgroup v2 on /sys/fs/cgroup instead of the v1 name=systemd hierarchy. While this works fine for systemd itself, it breaks tools which expect cgroup v1 hierarchy on /sys/fs/cgroup/systemd. This patch updates the hybrid mode so that it mounts v2 hierarchy on /sys/fs/cgroup/unified and keeps v1 "name=systemd" hierarchy on /sys/fs/cgroup/systemd for compatibility. systemd itself doesn't depend on the "name=systemd" hierarchy at all. All operations take place on the v2 hierarchy as before but the v1 hierarchy is kept in sync so that any tools which expect it to be there can keep doing so. This allows systemd to take advantage of cgroup v2 process management without requiring other tools to be aware of the hybrid mode. The hybrid mode is implemented by mapping the special systemd controller to /sys/fs/cgroup/unified and making the basic cgroup utility operations - cg_attach(), cg_create(), cg_rmdir() and cg_trim() - also operate on the /sys/fs/cgroup/systemd hierarchy whenever the cgroup2 hierarchy is updated. While a bit messy, this will allow dropping complications from using cgroup v1 for process management a lot sooner than otherwise possible which should make it a net gain in terms of maintainability. v2: Fixed !cgns breakage reported by @evverx and renamed the unified mount point to /sys/fs/cgroup/unified as suggested by @brauner. v3: chown the compat hierarchy too on delegation. Suggested by @evverx. v4: [zj] - drop the change to default, full "legacy" is still the default.
2017-02-20cgroup-util: fix the reversed return value of ↵Zbigniew Jędrzejewski-Szmek
cg_is_unified_systemd_contoller_wanted 1d84ad944520fc3e062ef518c4db4e1 reversed the meaning of the option. The kernel command line option has the opposite meaning to the function, i.e. specifying "legacy=yes" means "unifed systemd controller=no".
2017-02-18core: make SYSTEMD_CGROUP_CONTROLLER a special stringTejun Heo
SYSTEMD_CGROUP_CONTROLLER is currently defined as "name=systemd" which cgroup utility functions interpret as a named cgroup hierarchy with the specified named. With the planned cgroup hybrid mode changes, SYSTEMD_CGROUP_CONTROLLER would map to different hierarchy names. This patch makes SYSTEMD_CGROUP_CONTROLLER a special string "_systemd" which is substituted to "name=systemd" by the cgroup utility functions. This allows the callers to address the systemd hierarchy without actually specifying the hierarchy name allowing the cgroup utility functions to map it to whatever is appropriate. Note that SYSTEMD_CGROUP_CONTROLLER was already special on full unified cgroup hierarchy even before this patch.
2017-02-18core: simplify cg_[all_]unified()Tejun Heo
cg_[all_]unified() test whether a specific controller or all controllers are on the unified hierarchy. While what's being asked is a simple binary question, the callers must assume that the functions may fail any time, which unnecessarily complicates their usages. This complication is unnecessary. Internally, the test result is cached anyway and there are only a few places where the test actually needs to be performed. This patch simplifies cg_[all_]unified(). * cg_[all_]unified() are updated to return bool. If the result can't be decided, assertion failure is triggered. Error handlings from their callers are dropped. * cg_unified_flush() is updated to calculate the new result synchrnously and return whether it succeeded or not. Places which need to flush the test result are updated to test for failure. This ensures that all the following cg_[all_]unified() tests succeed. * Places which expected possible cg_[all_]unified() failures are updated to call and test cg_unified_flush() before calling cg_[all_]unified(). This includes functions used while setting up mounts during boot and manager_setup_cgroup().
2017-02-17missing: add renameat2() definition for 64bit arm (#5378)Lennart Poettering
Following a similar commit in casync: https://github.com/systemd/casync/pull/10
2017-02-17Merge pull request #5333 from poettering/machined-copy-files-usernsLennart Poettering
machined userns fixes
2017-02-17machined: when copying files from/to userns containers chown to rootLennart Poettering
This changes the file copy logic of machined to set the UID/GID of all copied files to 0 if the host and container do not share the same user namespace. Fixes: #4078
2017-02-17copy: change the various copy_xyz() calls to take a unified flags parameterLennart Poettering
This adds a unified "copy_flags" parameter to all copy_xyz() function calls, replacing the various boolean flags so far used. This should make many invocations more readable as it is clear what behaviour is precisely requested. This also prepares ground for adding support for more modes later on.
2017-02-17hostname-util: default to the compile time default hostname in ↵Lennart Poettering
gethostname_malloc() Currently, if the hostname is not set gethostname_malloc() defaults to the "sysname", which is "linux" on Linux. Let's change that to also honour the compile-time fallback hostname as specified on the configure command line.
2017-02-17virt: Update cache if the detected vm is virtualbox (#5364)Benjamin Robin
2017-02-16Merge pull request #4526 from keszybz/coredump-pythonLennart Poettering
Collect interpreter backtraces in systemd-coredump
2017-02-15virt: swap order of cpuid and dmi again, but properly detect oracle (#5355)Christian Hesse
This breaks again, this time for setups where Qemu is not reported via DMI for whatever reason. So swap order of cpuid and dmi again, but properly detect oracle. See issue #5318.
2017-02-15tree-wide: add SD_ID128_MAKE_STR, remove LOG_MESSAGE_IDZbigniew Jędrzejewski-Szmek
Embedding sd_id128_t's in constant strings was rather cumbersome. We had SD_ID128_CONST_STR which returned a const char[], but it had two problems: - it wasn't possible to statically concatanate this array with a normal string - gcc wasn't really able to optimize this, and generated code to perform the "conversion" at runtime. Because of this, even our own code in coredumpctl wasn't using SD_ID128_CONST_STR. Add a new macro to generate a constant string: SD_ID128_MAKE_STR. It is not as elegant as SD_ID128_CONST_STR, because it requires a repetition of the numbers, but in practice it is more convenient to use, and allows gcc to generate smarter code: $ size .libs/systemd{,-logind,-journald}{.old,} text data bss dec hex filename 1265204 149564 4808 1419576 15a938 .libs/systemd.old 1260268 149564 4808 1414640 1595f0 .libs/systemd 246805 13852 209 260866 3fb02 .libs/systemd-logind.old 240973 13852 209 255034 3e43a .libs/systemd-logind 146839 4984 34 151857 25131 .libs/systemd-journald.old 146391 4984 34 151409 24f71 .libs/systemd-journald It is also much easier to check if a certain binary uses a certain MESSAGE_ID: $ strings .libs/systemd.old|grep MESSAGE_ID MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x $ strings .libs/systemd|grep MESSAGE_ID MESSAGE_ID=c7a787079b354eaaa9e77b371893cd27 MESSAGE_ID=b07a249cd024414a82dd00cd181378ff MESSAGE_ID=641257651c1b4ec9a8624d7a40a9e1e7 MESSAGE_ID=de5b426a63be47a7b6ac3eaac82e2f6f MESSAGE_ID=d34d037fff1847e6ae669a370e694725 MESSAGE_ID=7d4958e842da4a758f6c1cdc7b36dcc5 MESSAGE_ID=1dee0369c7fc4736b7099b38ecb46ee7 MESSAGE_ID=39f53479d3a045ac8e11786248231fbf MESSAGE_ID=be02cf6855d2428ba40df7e9d022f03d MESSAGE_ID=7b05ebc668384222baa8881179cfda54 MESSAGE_ID=9d1aaa27d60140bd96365438aad20286
2017-02-14Move export format parsing from src/journal-remote/ to src/basic/Zbigniew Jędrzejewski-Szmek
No functional change.
2017-02-14virt: detect qemu/kvm as 'kvm'Christian Hesse
In commit 050e65a we swapped order of detect_vm_{cpuid,dmi}(). That fixed Virtualbox but broke qemu with kvm, which is expected to return 'kvm'. So check for qemu/kvm first, then DMI, CPUID last. This fixes #5318. Signed-off-by: Christian Hesse <mail@eworm.de>
2017-02-12calendarspec: fix duplicate detection (#5310)Doug Christman
a2eb5ea79c added a new field to `CalendarComponent`; update `normalize_chain` to compare all fields when dropping duplicates
2017-02-10basic/architecture: adjust Risc-V ifdef (#5304)Zbigniew Jędrzejewski-Szmek
https://lists.freedesktop.org/archives/systemd-devel/2017-February/038286.html Let's keep both the old and new for now, so systemd builds correctly in either environment. Later on we should drop the old.
2017-02-08seccomp: on s390 the clone() parameters are reversedLennart Poettering
Add a bit of code that tries to get the right parameter order in place for some of the better known architectures, and skips restrict_namespaces for other archs. This also bypasses the test on archs where we don't know the right order. In this case I didn't bother with testing the case where no filter is applied, since that is hopefully just an issue for now, as there's nothing stopping us from supporting more archs, we just need to know which order is right. Fixes: #5241
2017-02-08Merge pull request #5231 from keszybz/mask-wantsLennart Poettering
Mask individual .wants/.requires symlinks
2017-02-07basic/dirent-util: allow suffix to be omitted for dirent_is_file_with_suffixZbigniew Jędrzejewski-Szmek
2017-02-05treewide: replace homegrown memory_erase with explicit_bzeroZbigniew Jędrzejewski-Szmek
explicit_bzero was added in glibc 2.25. Make use of it. explicit_bzero is hardcoded to zero the memory, so string erase now truncates the string, instead of overwriting it with 'x'. This causes a visible difference only in the journalctl case.
2017-02-03time-util: Fix overflow check introduce in commit f977849 (#5216)Benjamin Robin
2017-02-02time-util: add overflow checking to monotonic timestamp specificationsLennart Poettering
2017-02-02time-util: when formatting usec_t as raw integers use PRIu64Lennart Poettering
After all, usec_t is defined as uint64_t, and not as unsigned long long.
2017-02-02time-util: when converting to time_t do something useful in 2038Lennart Poettering
On systems where time_t is 32bit we should invalidate the timeval/timespec instead of proceeding with a potentially overflown value.
2017-02-02time-util: refuse formatting/parsing times that we can't storeLennart Poettering
usec_t is always 64bit, which means it can cover quite a number of years. However, 4 digit year display and glibc limitations around time_t limit what we can actually parse and format. Let's make this explicit, so that we never end up formatting dates we can#t parse and vice versa. Note that this is really just about formatting/parsing. Internal calculations with times outside of the formattable range are not affected.
2017-02-02time: time_t is signed, and mktime() is happy to return negative timeLennart Poettering
Passing a year such as 1960 to mktime() will result in a negative return value. This is quite confusing, as the man page claims that on failure the call will return -1... Given that our own usec_t type is unsigned, and we can't express times before 1970 hence, let's consider all negative times returned by mktime() as invalid, regardless if just -1, or anything else negative.
2017-02-02hexdecoct: use typesafe new() instead of malloc()Lennart Poettering
2017-02-02fs-util: unify code we use to check if dirent's d_name is "." or ".."Lennart Poettering
We use different idioms at different places. Let's replace this is the one true new idiom, that is even a bit faster...
2017-02-01Merge pull request #5166 from keszybz/gcc7Evgeny Vereshchagin
Fixes for gcc 7 and new µhttpd & glibc warnings
2017-01-31Merge pull request #5146 from ssahani/ifname-aliasZbigniew Jędrzejewski-Szmek
networkd: Allow ':' in label This reverts a341dfe563 and takes a slightly different approach: anything is allowed in network interface labels, but network interface names are verified as before (i.e. amongst other things, no colons are allowed there).
2017-01-31nss-util: silence warning about deprecated RES_USE_INET6Zbigniew Jędrzejewski-Szmek
src/nss-resolve/nss-resolve.c: In function ‘_nss_resolve_gethostbyname_r’: src/nss-resolve/nss-resolve.c:680:13: warning: RES_USE_INET6 is deprecated NSS_GETHOSTBYNAME_FALLBACKS(resolve); ^~~~~~~~~~~~~~~~~~~~~~~~~ In glibc bz #19582, RES_USE_INET6 was deprecated. This might make sense for clients, but they didn't take into account nss module implementations which *must* continue to support the option. glibc internally defines DEPRECATED_RES_USE_INET6 which can be used without emitting a warning, but it's not exported publicly. Let's do the same, and just copy the definition to our header.
2017-01-31MurmurHash: all /* fall through */ commentsZbigniew Jędrzejewski-Szmek
2017-01-31tree-wide: adjust fall through comments so that gcc is happyZbigniew Jędrzejewski-Szmek
gcc 7 adds -Wimplicit-fallthrough=3 to -Wextra. There are a few ways we could deal with that. After we take into account the need to stay compatible with older versions of the compiler (and other compilers), I don't think adding __attribute__((fallthrough)), even as a macro, is worth the trouble. It sticks out too much, a comment is just as good. But gcc has some very specific requiremnts how the comment should look. Adjust it the specific form that it likes. I don't think the extra stuff we had in those comments was adding much value. (Note: the documentation seems to be wrong, and seems to describe a different pattern from the one that is actually used. I guess either the docs or the code will have to change before gcc 7 is finalized.)
2017-01-31util-lib: Fix chase_symlinks() with absolute symlinks (#5185)3chas3
If chase_symlinks() encouters an absolute symlink, it resets the todo buffer to just the newly discovered symlink and discards any of the remaining previous symlink path. Regardless of whether or not the symlink is absolute or relative, we need to preserve the remainder of the path that has not yet been resolved.
2017-01-31basic: check strdup result in khash_dup (#5176)Evgeny Vereshchagin
Fixes CID #1368249
2017-01-24tree-wide: remove consecutive duplicate words in comments (#5148)Stefan Schweter
2017-01-24virt: update url to hypervisor top-level functional specification (#5149)Stefan Schweter
2017-01-24socket-utils: revert f1811313f42dc7ddaed3c47edc834c2bfd1309b2Susant Sahani
':' in not a a valid interface name.
2017-01-23network: accept colons in network interface names, normally used for alias ↵peoronoob
interfaces (#5117)
2017-01-15process-util: rename char *r to ans and add commentZbigniew Jędrzejewski-Szmek
Add a comment about the return value and rename r to ans. r is nowadays reserved for the integer return value, and char *r is confusing.
2017-01-14Merge pull request #4879 from poettering/systemdZbigniew Jędrzejewski-Szmek
2017-01-11socket-util: drop _pure_ from a function with an output parameterZbigniew Jędrzejewski-Szmek
If it writes to memory, it's not pure, by definition. Fixup for 882ac6e769c5c.
2017-01-11Merge pull request #5046 from stefanha/vsockLennart Poettering
Add AF_VSOCK socket activation support
2017-01-11sparse: avoid clash with __bitwise and __force from 4.10 linux/types.h (#5061)Lubomir Rintel
It also used __bitwise and __force. It seems easier to rename our versions since they are local to this one single header. Also, undefine them afteerwards, so that we don't pollute the preprocessor macro namespace.
2017-01-10socket-util: add AF_VSOCK address familyStefan Hajnoczi
The AF_VSOCK address family facilitates guest<->host communication on VMware and KVM (virtio-vsock). Adding support to systemd allows guest agents to be launched through .socket unit files. Today guest agents are stand-alone daemons running inside guests that do not take advantage of systemd socket activation.
2017-01-10socket-util: introduce port argument in sockaddr_port()Stefan Hajnoczi
sockaddr_port() either returns a >= 0 port number or a negative errno. This works for AF_INET and AF_INET6 because port ranges are only 16-bit. In AF_VSOCK ports are 32-bit so an int cannot represent all port number and negative errnos. Separate the port and the return code.
2017-01-10missing.h: add AF_VSOCK bitsStefan Hajnoczi
Ubuntu 14.04 (Trusty) kernel header packages ship without <linux/vm_sockets.h>. Only struct sockaddr_vm and VMADDR_CID_ANY will be needed by systemd and they are simple enough to go in missing.h. CentOS 7 <sys/socket.h> does not define AF_VSOCK. Define it so the code can compile although actual socket(2) calls may fail at runtime if the address family isn't available.
2017-01-10build-sys: add check for gperf lookup function signature (#5055)Mike Gilbert
gperf-3.1 generates lookup functions that take a size_t length parameter instead of unsigned int. Test for this at configure time. Fixes: https://github.com/systemd/systemd/issues/5039
2016-12-29Merge pull request #4994 from poettering/private-tmp-tmpfilesMartin Pitt
automatically clean up PrivateTmp= left-overs in /var/tmp on next boot