summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-daemon
Commit message (Collapse)AuthorAgeFilesLines
* sd-daemon: add sd_pid_notify_barrier() call and use it in systemd-notifyLennart Poettering2023-05-031-2/+6
| | | | | Previously we'd honour --pid= from the main notification we send, but not from the barrier. This is confusing at best. Let's fix that.
* libsystemd: add missing _public_ attributesYu Watanabe2023-04-291-1/+1
|
* sd-daemon: add sd_pid_notifyf_with_fds()Lennart Poettering2023-04-251-0/+30
| | | | | | | | | | | | I guess it was only a question of time until we need to add the final frontier of notification functions: one that combines the features of all the others: 1. specifiying a source PID 2. taking a list of fds to send along 3. accepting a format string for the status string Hence, let's add it.
* tree-wide: also use CMSG_TYPED_DATA() on writing message headerYu Watanabe2023-04-161-1/+1
|
* sd_notify: support AF_VSOCKLuca Boccassi2023-01-051-7/+60
| | | | | | | | Allow sending notifications via AF_VSOCK, so that VMs can communicate to the hypervisor/VMM that they are finished booting. Note that if the hypervisor does not support SOCK_DGRAM over AF_VSOCK (ie: qemu at the time of writing), SOCK_SEQPACKET will be used instead.
* tree-wide: introduce PIPE_EBADF macroYu Watanabe2022-12-201-1/+1
|
* tree-wide: use -EBADF also in pipe initializersZbigniew Jędrzejewski-Szmek2022-12-191-1/+1
| | | | In some places, initialization is dropped when unnecesary.
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-1/+1
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* basic: rename util.h to logarithm.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+0
| | | | | util.h is now about logarithms only, so we can rename it. Many files included util.h for no apparent reason… Those includes are dropped.
* sd-daemon: remove sd_ prefix from static functionZbigniew Jędrzejewski-Szmek2022-06-301-5/+5
|
* tree-wide: use timestamp_is_set() moreLennart Poettering2022-02-221-1/+1
|
* sd-daemon: use path_join() instead of manual path concatLennart Poettering2022-02-141-3/+4
|
* tree-wide: port various places over to new stat_inode_same() helperLennart Poettering2022-02-141-8/+4
|
* treewide: tighten variable scope in loops (#18372)Susant Sahani2021-01-271-2/+2
| | | | Also use _cleanup_free_ in one more place.
* tree-wide: unsetenv cannot failZbigniew Jędrzejewski-Szmek2020-11-101-7/+6
| | | | | | ... when called with a valid environment variable name. This means that any time we call it with a fixed string, it is guaranteed to return 0. (Also when the variable is not present in the environment block.)
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* Rename strv_split_extract() to strv_split_full()Zbigniew Jędrzejewski-Szmek2020-09-091-1/+1
| | | | | Now that _full() is gone, we can rename _extract() to have the usual suffix we use for the more featureful version.
* tree-wide: port to fd_wait_for_event()Lennart Poettering2020-06-101-10/+2
| | | | | | | | Prompted by the discussion on #16110, let's migrate more code to fd_wait_for_event(). This only leaves 7 places where we call into poll()/poll() directly in our entire codebase. (one of which is fd_wait_for_event() itself)
* tree-wide: check POLLNVAL everywhereLennart Poettering2020-06-101-0/+2
| | | | | | | | | | | | | poll() sets POLLNVAL inside of the poll structures if an invalid fd is passed. So far we generally didn't check for that, thus not taking notice of the error. Given that this specific kind of error is generally indication of a programming error, and given that our code is embedded into our projects via NSS or because people link against our library, let's explicitly check for this and convert it to EBADF. (I ran into a busy loop because of this missing check when some of my test code accidentally closed an fd it shouldn't close, so this is a real thing)
* Introduce sd_notify_barrierKumar Kartikeya Dwivedi2020-05-011-0/+30
| | | | | | | | | | | | | | | This adds the sd_notify_barrier function, to allow users to synchronize against the reception of sd_notify(3) status messages. It acts as a synchronization point, and a successful return gurantees that all previous messages have been consumed by the manager. This can be used to eliminate race conditions where the sending process exits too early for systemd to associate its PID to a cgroup and attribute the status message to a unit correctly. systemd-notify now uses this function for proper notification delivery and be useful for NotifyAccess=all units again in user mode, or in cases where it doesn't have a control process as parent. Fixes: #2739
* tree-wide: use the return value from sockaddr_un_set_path()Zbigniew Jędrzejewski-Szmek2020-03-021-7/+5
| | | | | | | | | It fully initializes the address structure, so no need for pre-initialization, and also returns the length of the address, so no need to recalculate using SOCKADDR_UN_LEN(). socklen_t is unsigned, so let's not use an int for it. (It doesn't matter, but seems cleaner and more portable to not assume anything about the type.)
* tree-wide: drop socket.h when socket-util.h is includedYu Watanabe2019-11-041-1/+0
|
* tree-wide: drop string.h when string-util.h or friends are includedYu Watanabe2019-11-041-1/+0
|
* sd-daemon: make sd_booted() return negative errno on unexpected errorYu Watanabe2019-02-071-1/+7
|
* tree-wide: more IOVEC_MAKE() conversionsLennart Poettering2018-11-281-4/+3
|
* tree-wide: port various users over to sockaddr_un_set_path()Lennart Poettering2018-10-151-18/+6
| | | | | CID 1396140 CID 1396141
* tree-wide: drop empty commentsYu Watanabe2018-06-291-2/+0
|
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-1/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* macro: introduce TAKE_PTR() macroLennart Poettering2018-03-221-2/+1
| | | | | | | | | | | | | | | | This macro will read a pointer of any type, return it, and set the pointer to NULL. This is useful as an explicit concept of passing ownership of a memory area between pointers. This takes inspiration from Rust: https://doc.rust-lang.org/std/option/enum.Option.html#method.take and was suggested by Alan Jenkins (@sourcejedi). It drops ~160 lines of code from our codebase, which makes me like it. Also, I think it clarifies passing of ownership, and thus helps readability a bit (at least for the initiated who know the new macro)
* Merge pull request #7816 from poettering/chase-pidZbigniew Jędrzejewski-Szmek2018-01-151-10/+19
|\ | | | | Make MAINPID= and PIDFile= handling more restrictive (and other stuff)
| * sd-dameon: also sent ucred when our UID differs from EUIDLennart Poettering2018-01-111-10/+19
| | | | | | | | | | | | Let's be explicit, and always send the messages from our UID and never our EUID. Previously this behaviour was conditionalized only on whether the PID was specified, which made this non-obvious.
* | log: minimize includes in log.hLennart Poettering2018-01-111-0/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | log.h really should only include the bare minimum of other headers, as it is really pulled into pretty much everything else and already in itself one of the most basic pieces of code we have. Let's hence drop inclusion of: 1. sd-id128.h because it's entirely unneeded in current log.h 2. errno.h, dito. 3. sys/signalfd.h which we can replace by a simple struct forward declaration 4. process-util.h which was needed for getpid_cached() which we now hide in a funciton log_emergency_level() instead, which nicely abstracts the details away. 5. sys/socket.h which was needed for struct iovec, but a simple struct forward declaration suffices for that too. Ultimately this actually makes our source tree larger (since users of the functionality above must now include it themselves, log.h won't do that for them), but I think it helps to untangle our web of includes a tiny bit. (Background: I'd like to isolate the generic bits of src/basic/ enough so that we can do a git submodule import into casync for it)
* sd-daemon: use sockaddr_port() helperLennart Poettering2017-12-261-9/+5
|
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* libsystemd: use IN_SET macroYu Watanabe2017-09-281-5/+4
|
* tree-wide: make use of getpid_cached() wherever we canLennart Poettering2017-07-201-3/+3
| | | | | | | This moves pretty much all uses of getpid() over to getpid_raw(). I didn't specifically check whether the optimization is worth it for each replacement, but in order to keep things simple and systematic I switched over everything at once.
* build-sys: drop automake supportZbigniew Jędrzejewski-Szmek2017-07-181-1/+0
| | | | | v2: - also mention m4
* Add sd_is_socket_sockaddr (#4885)Zbigniew Jędrzejewski-Szmek2016-12-141-0/+58
| | | Fixes #1188.
* tree-wide: htonl() is weird, let's use htobe32() instead (#3538)Lennart Poettering2016-06-151-2/+2
| | | Super-important change, yeah!
* tree-wide: introduce new SOCKADDR_UN_LEN() macro, and use it everywhereLennart Poettering2016-05-051-3/+1
| | | | | | | | | | The macro determines the right length of a AF_UNIX "struct sockaddr_un" to pass to connect() or bind(). It automatically figures out if the socket refers to an abstract namespace socket, or a socket in the file system, and properly handles the full length of the path field. This macro is not only safer, but also simpler to use, than the usual offsetof() + strlen() logic.
* treewide: fix typos and then/that useTorstein Husebø2016-02-241-1/+1
|
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* Merge pull request #1768 from vcaputo/sd-daemon-listen-fds-overflow-bisLennart Poettering2015-11-041-5/+10
|\ | | | | sd-daemon: fix potential LISTEN_FDS overflow in sd_listen_fds()
| * sd-daemon: fix potential LISTEN_FDS overflow in sd_listen_fds()Vito Caputo2015-11-031-5/+10
| |
* | sd-daemon: explicitly filter out -1 when parsing watchdog timeoutLennart Poettering2015-11-031-1/+1
|/ | | | | | We already filter out 0, and as -1 is usually special (meaning infinity, as in USEC_INFINITY) we should better not accept it either. Better safe than sorry...
* sd-daemon: verify NOTIFY_SOCKET path lengthLennart Poettering2015-11-011-0/+5
| | | | Better generate a real error then simply connect to the wrong socket.
* sd-daemon: increase sd_notify() socket buffer sizeLennart Poettering2015-10-311-0/+4
| | | | | | | | Let's make sure we don't start blocking on sd_notify() earlier than necessary, let's bump the socket buffer sizes to 8M. We already do something similar for our logging socket buffers, hence apply a similar bump here.
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|