summaryrefslogtreecommitdiff
path: root/src/basic
AgeCommit message (Collapse)Author
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
2016-12-27core: implicitly order units with PrivateTmp= after ↵Lennart Poettering
systemd-tmpfiles-setup.service Preparation for fixing #4401.
2016-12-27util-lib: add a comment explaining the user name rules we enforceLennart Poettering
2016-12-21util-lib: rework path_check_fstype() and path_is_temporary_fs() to use O_PATHLennart Poettering
Also, add tests to make sure this actually works as intended.
2016-12-21util-lib: be stricter when decoding hex stringsLennart Poettering
If a hex string has an uneven length, generate an error instead of silently assuming a trailing '0' was in place.
2016-12-21util-lib: various improvements to kernel command line parsingLennart Poettering
This improves kernel command line parsing in a number of ways: a) An kernel option "foo_bar=xyz" is now considered equivalent to "foo-bar-xyz", i.e. when comparing kernel command line option names "-" and "_" are now considered equivalent (this only applies to the option names though, not the option values!). Most of our kernel options used "-" as word separator in kernel command line options so far, but some used "_". With this change, which was a source of confusion for users (well, at least of one user: myself, I just couldn't remember that it's systemd.debug-shell, not systemd.debug_shell). Considering both as equivalent is inspired how modern kernel module loading normalizes all kernel module names to use underscores now too. b) All options previously using a dash for separating words in kernel command line options now use an underscore instead, in all documentation and in code. Since a) has been implemented this should not create any compatibility problems, but normalizes our documentation and our code. c) All kernel command line options which take booleans (or are boolean-like) have been reworked so that "foobar" (without argument) is now equivalent to "foobar=1" (but not "foobar=0"), thus normalizing the handling of our boolean arguments. Specifically this means systemd.debug-shell and systemd_debug_shell=1 are now entirely equivalent. d) All kernel command line options which take an argument, and where no argument is specified will now result in a log message. e.g. passing just "systemd.unit" will no result in a complain that it needs an argument. This is implemented in the proc_cmdline_missing_value() function. e) There's now a call proc_cmdline_get_bool() similar to proc_cmdline_get_key() that parses booleans (following the logic explained in c). f) The proc_cmdline_parse() call's boolean argument has been replaced by a new flags argument that takes a common set of bits with proc_cmdline_get_key(). g) All kernel command line APIs now begin with the same "proc_cmdline_" prefix. h) There are now tests for much of this. Yay!
2016-12-21util-lib: read $SYSTEMD_PROC_CMDLINE if set when looking for the kernel cmdlineLennart Poettering
if we want to parse the kernel command line, let's check the $SYSTEMD_PROC_CMDLINE environment variable first. This is useful for debugging purposes.
2016-12-20calendarspec: minor refactoring and style fixDouglas Christman
2016-12-20calendarspec: improve overflow handlingDouglas Christman
Check if the parsed seconds value fits in an integer *after* multiplying by USEC_PER_SEC, otherwise a large value can trigger modulo by zero during normalization.
2016-12-20util-lib: make verbose_mount() grok MS_MOVELennart Poettering
Let's print a proper message if we see MS_MOVE.
2016-12-20util-lib: add new path_is_temporary_fs() APILennart Poettering
As simple wrapper around fd_is_temporary_fs().
2016-12-20util-lib: make sure fd_check_fstype() opens files with O_CLOEXECLennart Poettering
Also, O_NOCTTY is a safer bet, let's add that too.
2016-12-20util-lib: beef path_is_os_tree() up a bitLennart Poettering
Let's use chase_symlinks() when looking for /etc/os-release and /usr/lib/os-release as these files might be symlinks (and actually are IRL on some distros).
2016-12-20util-lib: accept invoking chase_symlinks() with a NULL return parameterLennart Poettering
Let's permit invoking chase_symlinks() with a NULL return parameter. If so, the resolved name is not returned, and call is useful for checking for existance of a file, without actually returning its ultimate path.
2016-12-20Merge pull request #4904 from dobyrch/calendar-range-stepLennart Poettering
calendarspec: allow repetition values with ranges
2016-12-17basic/log: use IN_SETZbigniew Jędrzejewski-Szmek
2016-12-17Modify mount_propagation_flags_from_string to return a normal int codeZbigniew Jędrzejewski-Szmek
This means that callers can distiguish an error from flags==0, and don't have to special-case the empty string.
2016-12-17Merge pull request #4845 from poettering/various-smaller-fixesZbigniew Jędrzejewski-Szmek
Various smaller fixes
2016-12-16calendarspec: remove superfluous variablesDouglas Christman
2016-12-16calendarspec: rename fields of CalendarComponentDouglas Christman
value/range_end -> start/stop
2016-12-16calendarspec: allow repetition values with rangesDouglas Christman
"Every other hour from 9 until 5" can be written as `9..17/2:00` instead of `9,11,13,15,17:00`
2016-12-14calendarspec: free memory when parsing fails (#4890)Doug Christman
This prevents memory leaks on strings like `*~*-*`. Fixes #4887
2016-12-14util-lib: rework rename_process() to be able to make use of PR_SET_MM_ARG_STARTLennart Poettering
PR_SET_MM_ARG_START allows us to relatively cleanly implement process renaming. However, it's only available with privileges. Hence, let's try to make use of it, and if we can't fall back to the traditional way of overriding argv[0]. This removes size restrictions on the process name shown in argv[] at least for privileged processes.