# sd_bus_query_sender_creds

## NAME



           sd_bus_query_sender_creds, sd_bus_query_sender_privilege - Query
           bus message sender credentials/privileges
    


## SYNOPSIS



           **#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_pid(3) 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 and the caller specified the **SD_BUS_CREDS_AUGMENT** flag,
           this function tries to figure out the missing credentials via
           other means (starting from the pid). If the PID is not available
           but the message has a sender, this function calls
           sd_bus_get_name_creds(3) to get the requested credentials. If the
           message has no sender (when a direct connection is used), this
           function calls sd_bus_get_owner_creds(3) 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_unref(3).
    
           **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 capabilities(7) 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**.
    
               Added in version 246.
    
           **-ENOTCONN**
               The bus of _m_ is not connected.
    
               Added in version 246.
    
           **-ECHILD**
               The bus of _m_ was created in a different process, library or
               module instance.
    
               Added in version 246.
    
           **-EPERM**
               The message _m_ is not sealed.
    
               Added in version 246.
    


## NOTES



           Functions described here are available as a shared library, which
           can be compiled against and linked to with the
           **libsystemd pkg-config**(1) file.
    
           The code described here uses getenv(3), which is declared to be
           not multi-thread-safe. This means that the code calling the
           functions described here must not call setenv(3) from a parallel
           thread. It is recommended to only do calls to **setenv()** from an
           early phase of the program when no other threads have been
           started.
    


* * *