summaryrefslogtreecommitdiff
path: root/src/libelogind
Commit message (Collapse)AuthorAge
* sd-bus: use free_and_strdup()Yu Watanabe2018-08-24
|
* path-util: introduce empty_to_root() and use it many placesYu Watanabe2018-08-24
|
* sd-bus: use automatic cleanup moreDavid Tardon2018-08-24
|
* meson: add support for building static libsystemd and libudevDavide Cavalca2018-08-24
|
* tree-wide: use strv_free_and_replace() macroYu Watanabe2018-08-24
|
* sd-bus: add bus_freep and use _cleanup_Zbigniew Jędrzejewski-Szmek2018-08-24
|
* sd-bus: use automatic cleanup moreZbigniew Jędrzejewski-Szmek2018-08-24
|
* sd-bus: trivial simplificationZbigniew Jędrzejewski-Szmek2018-08-24
|
* use max. message size allowed by DBus spec (#8936)David Tardon2018-08-24
| | | | C.f. https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages.
* tree-wide: be more careful with the type of array sizesLennart Poettering2018-08-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we were a bit sloppy with the index and size types of arrays, we'd regularly use unsigned. While I don't think this ever resulted in real issues I think we should be more careful there and follow a stricter regime: unless there's a strong reason not to use size_t for array sizes and indexes, size_t it should be. Any allocations we do ultimately will use size_t anyway, and converting forth and back between unsigned and size_t will always be a source of problems. Note that on 32bit machines "unsigned" and "size_t" are equivalent, and on 64bit machines our arrays shouldn't grow that large anyway, and if they do we have a problem, however that kind of overly large allocation we have protections for usually, but for overflows we do not have that so much, hence let's add it. So yeah, it's a story of the current code being already "good enough", but I think some extra type hygiene is better. This patch tries to be comprehensive, but it probably isn't and I missed a few cases. But I guess we can cover that later as we notice it. Among smaller fixes, this changes: 1. strv_length()' return type becomes size_t 2. the unit file changes array size becomes size_t 3. DNS answer and query array sizes become size_t Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=76745
* bus-message: use streq_ptr() (#8786)Yu Watanabe2018-08-24
|
* timedate: move error mapping to bus-common-errors.[ch]Yu Watanabe2018-08-24
|
* tree-wide: drop spurious newlines (#8764)Lennart Poettering2018-08-24
| | | | | | | | | Double newlines (i.e. one empty lines) are great to structure code. But let's avoid triple newlines (i.e. two empty lines), quadruple newlines, quintuple newlines, …, that's just spurious whitespace. It's an easy way to drop 121 lines of code, and keeps the coding style of our sources a bit tigther.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | 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.
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-08-24
|
* sd-bus: allow description to be set for system/user busses (#8594)Zbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | | | sd_bus_open/sd_bus_open_system/sd_bus_open_user are convenient, but don't allow the description to be set. After they return, the bus is is already started, and sd_bus_set_description() fails with -EBUSY. It would be possible to allow sd_bus_set_description() to update the description "live", but messages are already emitted from sd_bus_open functions, so it's better to allow the description to be set in sd_bus_open/sd_bus_open_system/sd_bus_open_user. Fixes message like: Bus n/a: changing state UNSET → OPENING
* sd-event: use _cleanup_ to manage temporary referencesZbigniew Jędrzejewski-Szmek2018-08-24
|
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-08-24
|
* sd-bus: allow description to be set for system/user busses (#8594)Zbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | | | sd_bus_open/sd_bus_open_system/sd_bus_open_user are convenient, but don't allow the description to be set. After they return, the bus is is already started, and sd_bus_set_description() fails with -EBUSY. It would be possible to allow sd_bus_set_description() to update the description "live", but messages are already emitted from sd_bus_open functions, so it's better to allow the description to be set in sd_bus_open/sd_bus_open_system/sd_bus_open_user. Fixes message like: Bus n/a: changing state UNSET → OPENING
* macro: introduce TAKE_PTR() macroLennart Poettering2018-08-24
| | | | | | | | | | | | | | | | 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)
* sd-bus: drop fd_nonblock() calls that are implied by rearrange_stdio() (#8514)Lennart Poettering2018-06-28
| | | | (cherry picked from commit 68b525d1d1e8153cbc2e2354fa650aa165f7a434)
* sd-bus: do not try to close already closed fd (#8392)Yu Watanabe2018-06-28
| | | | | | Fixes #8376, which is introduced by 2b33ab0957f453a06b58e4bee482f2c2d4e100c1. (cherry picked from commit 280029d18f470a64403d68717eef1be5274ff8af)
* Prep v238: Uncomment now needed headers and unmask now needed functions in ↵Sven Eden2018-06-05
| | | | src/libelogind (3/6)
* Prep v238: Remove obsolete sources and add missing new ones.Sven Eden2018-06-05
|
* Prep v238: Applied some upstream updates to src/libelogind (5/5)Sven Eden2018-06-04
|
* sd-bus: let's better not invade stdio territory when duplicating fdsLennart Poettering2018-05-30
|
* tree-wide: port various places over to use new rearrange_stdio()Lennart Poettering2018-05-30
|
* coccinelle: add reallocarray() coccinelle scriptLennart Poettering2018-05-30
| | | | | Let's systematically make use of reallocarray() whereever we invoke realloc() with a product of two values.
* sd-bus: add APIs to query the current read and write queue sizeLennart Poettering2018-05-30
|
* sd-login: make use of _cleanup_close_ where possibleLennart Poettering2018-05-30
|
* tree-wide: use reallocarray instead of our home-grown realloc_multiply (#8279)Zbigniew Jędrzejewski-Szmek2018-05-30
| | | | | | | | There isn't much difference, but in general we prefer to use the standard functions. glibc provides reallocarray since version 2.26. I moved explicit_bzero is configure test to the bottom, so that the two stdlib functions are at the bottom.
* tree-wide: make use of fsync_directory_of_file() all over the placeLennart Poettering2018-05-30
| | | | | | Let's make use this at various places we call fsync(), to make things fully reliable, as the kernel devs suggest to first fsync() files and then fsync() the directories they are located in.
* sd-bus: synthesize a description for user/system bus if otherwise unsetLennart Poettering2018-05-30
| | | | | Let's make debugging easier, by synthesizing a name when we have some indication what kind of bus this is.
* meson: factor out daemon/event/id128 sources into variables (#8170)Davide Cavalca2018-05-30
|
* fd-util: move certain fds above fd #2 (#8129)Lennart Poettering2018-05-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds some paranoia code that moves some of the fds we allocate for longer periods of times to fds > 2 if they are allocated below this boundary. This is a paranoid safety thing, in order to avoid that external code might end up erroneously use our fds under the assumption they were valid stdin/stdout/stderr. Think: some app closes stdin/stdout/stderr and then invokes 'fprintf(stderr, …' which causes writes on our fds. This both adds the helper to do the moving as well as ports over a number of users to this new logic. Since we don't want to litter all our code with invocations of this I tried to strictly focus on fds we keep open for long periods of times only and only in code that is frequently loaded into foreign programs (under the assumptions that in our own codebase we are smart enough to always keep stdin/stdout/stderr allocated to avoid this pitfall). Specifically this means all code used by NSS and our sd-xyz API: 1. our logging APIs 2. sd-event 3. sd-bus 4. sd-resolve 5. sd-netlink This changed was inspired by this: https://github.com/systemd/systemd/issues/8075#issuecomment-363689755 This shows that apparently IRL there are programs that do close stdin/stdout/stderr, and we should accomodate for that. Note that this won't fix any bugs, this just makes sure that buggy programs are less likely to interfere with out own code.
* sd-bus: cleanup ssh sessions (Closes: #8076)Shawn Landden2018-05-30
| | | | | | | | | | | | | | | | | | | 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()
* sd-bus: explicitly convert int to boolYu Watanabe2018-05-30
|
* sd-bus: use free_and_replace()Yu Watanabe2018-05-30
|
* sd-bus: avoid potential memory leaksYu Watanabe2018-05-30
|
* sd-bus: cleanup ssh sessions (Closes: #8076)Shawn Landden2018-05-30
| | | | | | | | | | | | | | | | | | | | 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() (cherry picked from commit 392cf1d05dbfa1395f6d99102e5ea41debb58fec)
* sd-bus: avoid potential memory leaksYu Watanabe2018-05-30
| | | | (cherry picked from commit b4ca3f45dc5742ad76e8feebd363c490f92b804f)
* Add fd close support to sd_event_sourceNathaniel McCallum2018-05-30
| | | | | | | | | | | | | | It is often the case that a file descriptor and its corresponding IO sd_event_source share a life span. When this is the case, developers will have to unref the event source and close the file descriptor. Instead, we can just have the event source take ownership of the file descriptor and close it when the event source is freed. This is especially useful when combined with cleanup attributes and sd_event_source_unrefp(). This patch adds two new public functions: sd_event_source_get_io_fd_own() sd_event_source_set_io_fd_own()
* Add support for SD_BUS_DEFAULT*Nathaniel McCallum2018-05-30
| | | | | | | | | | | | | | | | | | | | | | Currently, sd-bus supports the ability to have thread-local default busses. However, this is less useful than it can be since all functions which require an sd_bus* as input require the caller to pass it. This patch adds a new macro which allows the developer to pass a constant SD_BUS_DEFAULT, SD_BUS_DEFAULT_USER or SD_BUS_DEFAULT_SYSTEM instead. This reduces work for the caller. For example: r = sd_bus_default(&bus); r = sd_bus_call_method(bus, ...); sd_bus_unref(bus); Becomes: r = sd_bus_call_method(SD_BUS_DEFAULT, ...); If the specified thread-local default bus does not exist, the function calls will return -ENOPKG. No bus will ever be implicitly created.
* Add support for SD_EVENT_DEFAULTNathaniel McCallum2018-05-30
| | | | | | | | | | | | | | | | | | | | | Currently, sd-event supports the ability to have a thread-local default event loop. However, this is less useful than it can be since all functions which require an sd_event* as input require the caller to pass it. This patch adds a new macro which allows the developer to pass a constant SD_EVENT_DEFAULT instead. This reduces work for the caller. For example: r = sd_event_default(&e); r = sd_event_add_io(e, ...); sd_event_unref(e); Becomes: r = sd_event_add_io(SD_EVENT_DEFAULT, ...); If no thread-local default event loop exists, the function calls will return -ENOPKG. No event loop will ever be implicitly created.
* bus-message: avoid -Wnull-pointer-arithmetic warning on new clangZbigniew Jędrzejewski-Szmek2018-05-30
| | | | | We just need some pointer, so use alignment directly converted to the right type.
* sd-dameon: also sent ucred when our UID differs from EUIDLennart Poettering2018-05-30
| | | | | | 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-05-30
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-bus: drop bloom stuff, it's not needed anymore since kdbus is goneLennart Poettering2018-05-30
|
* bus-socket: slight simplification in bus_get_peercred()Zbigniew Jędrzejewski-Szmek2018-05-30
|
* sd-netlink: add generic netlink supportJörg Thalheim2018-05-30
| | | | | | This also adds the ability to incorporate arrays into netlink messages and to determine when a netlink message is too big, used by some generic netlink protocols.