From: Daan De Meyer Date: Tue, 28 Apr 2020 17:29:46 +0000 (+0200) Subject: sd-bus: Add sd_bus_query_sender_creds/privilege docs X-Git-Tag: v246-rc1~480 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bac1b832178a92345c7f857db1be0f1dd4c2ba39;p=thirdparty%2Fsystemd.git sd-bus: Add sd_bus_query_sender_creds/privilege docs --- diff --git a/man/rules/meson.build b/man/rules/meson.build index a59b004ebe3..84f0442b1e2 100644 --- a/man/rules/meson.build +++ b/man/rules/meson.build @@ -378,6 +378,7 @@ manpages = [ ['sd_bus_path_decode', 'sd_bus_path_decode_many', 'sd_bus_path_encode_many'], ''], ['sd_bus_process', '3', [], ''], + ['sd_bus_query_sender_creds', '3', ['sd_bus_query_sender_privilege'], ''], ['sd_bus_reply_method_error', '3', ['sd_bus_reply_method_errno', diff --git a/man/sd-bus.xml b/man/sd-bus.xml index b6be54fa96b..24999337c8f 100644 --- a/man/sd-bus.xml +++ b/man/sd-bus.xml @@ -139,6 +139,8 @@ sd_bus_new3, sd_bus_path_encode3, sd_bus_process3, +sd_bus_query_sender_creds3, +sd_bus_query_sender_privilege3, sd_bus_reply_method_return3, sd_bus_reply_method_error3, sd_bus_request_name3, diff --git a/man/sd_bus_query_sender_creds.xml b/man/sd_bus_query_sender_creds.xml new file mode 100644 index 00000000000..54cd8177173 --- /dev/null +++ b/man/sd_bus_query_sender_creds.xml @@ -0,0 +1,133 @@ + + + + + + + + sd_bus_query_sender_creds + systemd + + + + sd_bus_query_sender_creds + 3 + + + + sd_bus_query_sender_creds + sd_bus_query_sender_privilege + + Query bus message sender credentials/privileges + + + + + #include <systemd/sd-bus.h> + + + int sd_bus_query_sender_creds + sd_bus_message *m + uint64_t mask + sd_bus_creds **creds + + + + sd_bus_error* sd_bus_query_sender_privilege + sd_bus_message *m + int capability + + + + + + Description + + sd_bus_query_sender_creds() returns the credentials of the message + m. The mask parameter is a combo of + SD_BUS_CREDS_* flags that indicate which credential info the caller is + interested in. See + sd_bus_creds_new_from_pid3 + for a list of possible flags. First, this message checks if the requested credentials are attached to the + message itself. If not but the message contains the pid of the sender, this function tries to figure out + the missing credentials via other means (starting from the pid). If the pid isn't available but the + message has a sender, this function calls + sd_bus_get_name_creds3 + to get the requested credentials. If the message has no sender (when a direct connection is used), this + function calls + sd_bus_get_owner_creds3 + to get the requested credentials. On success, the requested credentials are stored in + creds. Ownership of the credentials object in creds is + transferred to the caller and should be freed by calling + sd_bus_creds_unref3. + + + sd_bus_query_sender_privilege() checks if the message m + has the requested privileges. If capability is a non-negative integer, this + function checks if the message has the capability with the same value. See + capabilities7 + for a list of capabilities. If capability is a negative integer, this function + returns whether the sender of the message runs as the same user as the receiver of the message, or if the + sender of the message runs as root and the receiver of the message does not run as root. On success and + if the message has the requested privileges, this function returns a positive integer. If the message + does not have the requested privileges, this function returns zero. + + + + Return Value + + On success, these functions return a non-negative integer. On failure, they return a negative + errno-style error code. + + + Errors + + Returned errors may indicate the following problems: + + + + -EINVAL + + The message m or an output parameter is + NULL. + + + + -ENOTCONN + + The bus of m is not connected. + + + + -ECHILD + + The bus of m was created in a different process. + + + + + -EPERM + + The message m is not sealed. + + + + + + + + + See Also + + + systemd1, + sd-bus3, + sd_bus_creds_new_from_pid3, + sd_bus_get_name_creds3, + sd_bus_get_owner_creds3, + sd_bus_creds_unref3, + capabilities7 + + + diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h index 31dd421250c..61b5a493c7c 100644 --- a/src/systemd/sd-bus.h +++ b/src/systemd/sd-bus.h @@ -385,8 +385,8 @@ int sd_bus_emit_interfaces_added(sd_bus *bus, const char *path, const char *inte int sd_bus_emit_interfaces_removed_strv(sd_bus *bus, const char *path, char **interfaces); int sd_bus_emit_interfaces_removed(sd_bus *bus, const char *path, const char *interface, ...) _sd_sentinel_; -int sd_bus_query_sender_creds(sd_bus_message *call, uint64_t mask, sd_bus_creds **creds); -int sd_bus_query_sender_privilege(sd_bus_message *call, int capability); +int sd_bus_query_sender_creds(sd_bus_message *m, uint64_t mask, sd_bus_creds **creds); +int sd_bus_query_sender_privilege(sd_bus_message *m, int capability); int sd_bus_match_signal(sd_bus *bus, sd_bus_slot **ret, const char *sender, const char *path, const char *interface, const char *member, sd_bus_message_handler_t callback, void *userdata); int sd_bus_match_signal_async(sd_bus *bus, sd_bus_slot **ret, const char *sender, const char *path, const char *interface, const char *member, sd_bus_message_handler_t match_callback, sd_bus_message_handler_t add_callback, void *userdata);