summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/bus-kernel.c
Commit message (Collapse)AuthorAgeFilesLines
* util: split out memcmp()/memset() related calls into memory-util.[ch]Lennart Poettering2019-03-131-1/+1
| | | | Just some source rearranging.
* 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.
* sd-bus: get rid of kdbus flags cruftLennart Poettering2018-01-051-46/+0
| | | | | We only need three bits from the old kdbus flags cruft, hence let's make them proper booleans.
* 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.
* build-sys: use #if Y instead of #ifdef Y everywhereZbigniew Jędrzejewski-Szmek2017-10-041-1/+1
| | | | | | | | | | | | | | | The advantage is that is the name is mispellt, cpp will warn us. $ git grep -Ee "conf.set\('(HAVE|ENABLE)_" -l|xargs sed -r -i "s/conf.set\('(HAVE|ENABLE)_/conf.set10('\1_/" $ git grep -Ee '#ifn?def (HAVE|ENABLE)' -l|xargs sed -r -i 's/#ifdef (HAVE|ENABLE)/#if \1/; s/#ifndef (HAVE|ENABLE)/#if ! \1/;' $ git grep -Ee 'if.*defined\(HAVE' -l|xargs sed -i -r 's/defined\((HAVE_[A-Z0-9_]*)\)/\1/g' $ git grep -Ee 'if.*defined\(ENABLE' -l|xargs sed -i -r 's/defined\((ENABLE_[A-Z0-9_]*)\)/\1/g' + manual changes to meson.build squash! build-sys: use #if Y instead of #ifdef Y everywhere v2: - fix incorrect setting of HAVE_LIBIDN2
* Drop kdbus bitsZbigniew Jędrzejewski-Szmek2017-07-231-1671/+2
| | | | | | | | | Some kdbus_flag and memfd related parts are left behind, because they are entangled with the "legacy" dbus support. test-bus-benchmark is switched to "manual". It was already broken before (in the non-kdbus mode) but apparently nobody noticed. Hopefully it can be fixed later.
* sd-bus: silence format warnings in kdbus code (#6072)Zbigniew Jędrzejewski-Szmek2017-06-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | The code is mostly correct, but gcc is trying to outsmart us, and emits a warning for a "llu vs lu" mismatch, even though they are the same size (on alpha): src/libsystemd/sd-bus/bus-control.c: In function ‘kernel_get_list’: src/libsystemd/sd-bus/bus-control.c:267:42: error: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64 {aka long unsigned int}’ [-Werror=format=] if (asprintf(&n, ":1.%llu", name->id) < 0) { ^ src/libsystemd/sd-bus/bus-control.c: In function ‘bus_get_name_creds_kdbus’: src/libsystemd/sd-bus/bus-control.c:714:47: error: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64 {aka long unsigned int}’ [-Werror=format=] if (asprintf(&c->unique_name, ":1.%llu", conn_info->id) < 0) { ^ This is hard to work around properly, because kdbus.h uses __u64 which is defined-differently-despite-being-the-same-size then uint64_t. Thus the simple solution of using %PRIu64 fails on amd64: src/libsystemd/sd-bus/bus-control.c:714:47: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘__u64 {aka long long unsigned int}’ [-Werror=format=] if (asprintf(&c->unique_name, ":1.%"PRIu64, conn_info->id) < 0) { ^~~~~~ Let's just avoid the whole issue for now by silencing the warning. After the next release, we should just get rid of the kdbus code. Fixes #5561.
* tree-wide: drop (llu) casts for kernel's __u64Zbigniew Jędrzejewski-Szmek2016-11-071-9/+7
| | | | | According to comments in <asm/types.h>, __u64 is always defined as unsigned long long. Those casts should be superfluous.
* Rename formats-util.h to format-util.hZbigniew Jędrzejewski-Szmek2016-11-071-1/+1
| | | | | | We don't have plural in the name of any other -util files and this inconsistency trips me up every time I try to type this file name from memory. "formats-util" is even hard to pronounce.
* tree-wide: drop NULL sentinel from strjoinZbigniew Jędrzejewski-Szmek2016-10-231-1/+1
| | | | | | | | | | | | | This makes strjoin and strjoina more similar and avoids the useless final argument. spatch -I . -I ./src -I ./src/basic -I ./src/basic -I ./src/shared -I ./src/shared -I ./src/network -I ./src/locale -I ./src/login -I ./src/journal -I ./src/journal -I ./src/timedate -I ./src/timesync -I ./src/nspawn -I ./src/resolve -I ./src/resolve -I ./src/systemd -I ./src/core -I ./src/core -I ./src/libudev -I ./src/udev -I ./src/udev/net -I ./src/udev -I ./src/libsystemd/sd-bus -I ./src/libsystemd/sd-event -I ./src/libsystemd/sd-login -I ./src/libsystemd/sd-netlink -I ./src/libsystemd/sd-network -I ./src/libsystemd/sd-hwdb -I ./src/libsystemd/sd-device -I ./src/libsystemd/sd-id128 -I ./src/libsystemd-network --sp-file coccinelle/strjoin.cocci --in-place $(git ls-files src/*.c) git grep -e '\bstrjoin\b.*NULL' -l|xargs sed -i -r 's/strjoin\((.*), NULL\)/strjoin(\1)/' This might have missed a few cases (spatch has a really hard time dealing with _cleanup_ macros), but that's no big issue, they can always be fixed later.
* Remove kdbus custom endpoint supportDaniel Mack2016-02-111-44/+0
| | | | | | This feature will not be used anytime soon, so remove a bit of cruft. The BusPolicy= config directive will stay around as compat noop.
* 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.
* bus-kernel: reword assignment of dst_id in bus_message_setup_kmsgZbigniew Jędrzejewski-Szmek2016-01-181-15/+15
| | | | | | | | Setting of dst_id was based on interplay of two booleans, making the logic hard to follow (for humans and compilers alike). gcc was confused and emmitted a warning about an uninitialized variable. Rework the code to make it obvious that dst_id is set properly.
* tree-wide: use xsprintf() where applicableDaniel Mack2016-01-121-2/+5
| | | | Also add a coccinelle receipt to help with such transitions.
* tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering2015-11-271-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GLIB has recently started to officially support the gcc cleanup attribute in its public API, hence let's do the same for our APIs. With this patch we'll define an xyz_unrefp() call for each public xyz_unref() call, to make it easy to use inside a __attribute__((cleanup())) expression. Then, all code is ported over to make use of this. The new calls are also documented in the man pages, with examples how to use them (well, I only added docs where the _unref() call itself already had docs, and the examples, only cover sd_bus_unrefp() and sd_event_unrefp()). This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we tend to call our destructors these days. Note that this defines no public macro that wraps gcc's attribute and makes it easier to use. While I think it's our duty in the library to make our stuff easy to use, I figure it's not our duty to make gcc's own features easy to use on its own. Most likely, client code which wants to make use of this should define its own: #define _cleanup_(function) __attribute__((cleanup(function))) Or similar, to make the gcc feature easier to use. Making this logic public has the benefit that we can remove three header files whose only purpose was to define these functions internally. See #2008.
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* user-util: move UID/GID related macros from macro.h to user-util.hLennart Poettering2015-10-271-0/+1
|
* src/basic: rename audit.[ch] → audit-util.[ch] and capability.[ch] → ↵Lennart Poettering2015-10-271-1/+1
| | | | | | | | | capability-util.[ch] The files are named too generically, so that they might conflict with the upstream project headers. Hence, let's add a "-util" suffix, to clarify that this are just our utility headers and not any official upstream headers.
* util-lib: split string parsing related calls from util.[ch] into parse-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering2015-10-251-1/+2
| | | | | There are more than enough to deserve their own .c file, hence move them over.
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-9/+9
| | | | | | | | | | | | | | string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
* sd-bus: fix error handling of pthread API callsLennart Poettering2015-10-171-6/+6
| | | | | | pthread APIs (unlike the rest of libc) return their errors as positive error codes directly from the functions, rather than using errno. Let's make sure we always handle things that way.
* Revert "sd-bus: do not connect to dbus-1 socket when kdbus is available"David Herrmann2015-08-271-0/+1
| | | | | | | | This reverts commit d4d00020d6ad855d65d31020fefa5003e1bb477f. The idea of the commit is broken and needs to be reworked. We really cannot reduce the bus-addresses to a single address. We always will have systemd with native clients and legacy clients at the same time, so we also need both addresses at the same time.
* sd-bus: rename bloom-tag to arg0-hasDavid Herrmann2015-08-271-2/+2
| | | | | | | | We use dashes in our bloom-tags. Make sure the newly introduced arg0has tag uses the same style. Note that the external dbus-tags don't use dashes, though. They are defined in the spec and we need to keep compatibility there.
* sd-bus: introduce new match type "arg0has=" for matching arrays of stringsLennart Poettering2015-08-251-1/+22
| | | | | | | | | | | | | | | | | | | | Previously, sd-bus inofficially already supported bus matches that tested a string against an array of strings ("as"). This was done via an enhanced way to interpret "arg0=" matches. This is problematic however, since clients have no way to determine if their respective implementation understood strv matches or not, thus allowing invalid matches to be installed without a way to detect that. This patch changes the logic to only allow such matches with a new "arg0has=" syntax. This has the benefit that non-conforming implementations will return a parse error and a client application may thus efficiently detect support for the match type. Matches of this type are useful for "udev"-like systems that "tag" objects with a number of strings, and clients need to be able to match against any of these "tags". The name "has" takes inspiration from Python's ".has_key()" construct.
* sd-bus: do not connect to dbus-1 socket when kdbus is availableKay Sievers2015-08-111-1/+0
| | | | | | | | | | | | We should not fall back to dbus-1 and connect to the proxy when kdbus returns an error that indicates that kdbus is running but just does not accept new connections because of quota limits or something similar. Using is_kdbus_available() in libsystemd/ requires it to move from shared/ to libsystemd/. Based on a patch from David Herrmann: https://github.com/systemd/systemd/pull/886
* sd-bus: ignore BLOOM_FILTER kdbus itemsLennart Poettering2015-08-061-0/+1
| | | | | The kernel nowadays sends these along, and that's OK, hence don't even debug log about it, but completely ignore it.
* tree-wide: fix indentationThomas Hindoe Paaboel Andersen2015-08-061-1/+3
|
* sd-bus: don't treat KDBUS_ITEM_TIMESTAMP as unknown itemDavid Herrmann2015-07-241-2/+1
| | | | | | In bus_kernel_translate_message(), we print a DEBUG message on unknown items. But right now, we also print this message for KDBUS_ITEM_TIMESTAMP despite parsing it properly. Fix this!
* sd-bus: don't leak kdbus notificationsDavid Herrmann2015-07-021-5/+6
| | | | | | | | | | When we get notifications from the kernel, we always turn them into synthetic dbus1 messages. This means, we do *not* consume the kdbus message, and as such have to free the offset. Right now, the translation-helpers told the caller that they consumed the message, which is wrong. Fix this by explicitly releasing all kernel messages that are translated.
* Stop talking about the "XDG" version of basename()Simon McVittie2015-06-171-2/+2
| | | | | | | | | | | | | | | | XDG refers to X Desktop Group, a former name for freedesktop.org. This group is responsible for specifications like basedirs, .desktop files and icon naming, but as far as I know, it has never tried to redefine basename(). I think these references were meant to say XPG (X/Open Portability Guide), a precursor of POSIX. POSIX is better-known and less easily confused with XDG, and is how the basename(3) man page describes the libgen.h version of basename(). The other version of basename() is glibc-specific and is described in basename(3) as "the GNU version"; specifically mention that version, to disambiguate.
* sd-bus: remove ucred parameter from bus_message_from_header() since we don't ↵Lennart Poettering2015-06-101-1/+0
| | | | use it anymore
* bus: don't force send-masks on kdbus busesDavid Herrmann2015-06-051-9/+0
| | | | | | | | | | Right now we always pass KDBUS_ITEM_ATTACH_FLAGS_RECV to KDBUS_CMD_BUS_MAKE, effectively forcing every bus connection to do the same during KDBUS_CMD_HELLO. This used to be a workaround to make sure all metadata is always present. However, we refrained from that approach and intend to make all metadata collection solely rely on /proc access restrictions. Therefore, there is no need to force the send-flags mask on newly created buses.
* kdbus: remove attach_flags_mask module parameter settingKay Sievers2015-06-031-26/+0
|
* treewide: Correct typos and spell plural of bus consistentTorstein Husebø2015-05-111-1/+1
|
* sd-bus: when we get ENOTTY on the HELLO ioctl assume incompatible API versionLennart Poettering2015-04-301-2/+15
| | | | As perparation for future incompatible kdbus kernel API changes.
* sd-bus: properly handle creds that are known but undefined for a processLennart Poettering2015-04-291-8/+7
| | | | | | | | | | | | | | | A number of fields do not apply to all processes, including: there a processes without a controlling tty, without parent process, without service, user services or session. To distuingish these cases from the case where we simply don't have the data, always return ENXIO for them, while returning ENODATA for the case where we really lack the information. Also update the credentials dumping code to show this properly. Fields that are known but do not apply are now shown as "n/a". Note that this also changes some of the calls in process-util.c and cgroup-util.c to return ENXIO for these cases.
* sd-bus: expose ppid fieldLennart Poettering2015-04-211-1/+6
| | | | | kdbus has been passing us the ppid file for a while, actually make use of it.
* shared: add formats-util.hRonny Chevalier2015-04-101-0/+1
|
* tree-wide: there is no ENOTSUP on linuxDavid Herrmann2015-03-131-3/+3
| | | | Replace ENOTSUP by EOPNOTSUPP as this is what linux actually uses.
* sd-bus: sync kdbus.h (ABI break)Daniel Mack2015-03-021-3/+14
| | | | | | | | | | | | | After some reconsideration, we decided to move the binary protocol back to 64-bit wide UIDs and GIDs. After all, it should be possible to redefine [gu]id_t to uint64_t and things should continue to work. As we want to avoid such data types in kdbus.h, let's move back to 64-bit values and be safe. In sd-bus, we have to do a translation between uint64_t and gid_t now for supplementary gids. Some inline comments have also been updated in kdbus upstream.
* sd-bus: sync kdbus.hDaniel Mack2015-02-241-3/+2
| | | | | | | | | | Follow two small changes in the kdbus API: * Flags are now returned in cmd->return_flags by KDBUS_CMD_NAME_ACQUIRE * struct kdbus_item_list has been dropped. The information stored in this struct was redundant since awhile already, as all commands report their returned slice size anyway.
* remove unused includesThomas Hindoe Paaboel Andersen2015-02-231-1/+0
| | | | | | This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
* bus: sync with kdbusDavid Herrmann2015-02-171-5/+2
| | | | | | Pull in new kdbus changes, namely: - EOVERFLOW is replaces by KDBUS_RECV_RETURN_DROPPED_MSGS - ENOMSG is merged with EAGAIN for consistency
* sd-bus: make sure we always serialize the reply cookie as 64bit on dbus2, ↵Lennart Poettering2015-02-161-1/+1
| | | | and 32bit on dbus1
* Revert "Revert "sd-bus: change serialization of kdbus messages to qualify in ↵Lennart Poettering2015-02-161-26/+39
| | | | | | their entirety as gvariant objects"" This reverts commit 954871d8ba15911d014f76ed2c7a9492953cf39d.
* sd-bus: sync kdbus.h (ABI break)Daniel Mack2015-02-131-3/+3
| | | | | Another slice logic rework in kdbus made KDBUS_ITEM_PAYLOAD_OFF items relative to the message header again. Catch up with that in sd-bus.