sss_sifp.h revision 0bb98b7700b1b61f5b0a20b93279d5c2c391007f
/*
Authors:
Pavel Březina <pbrezina@redhat.com>
Copyright (C) 2014 Red Hat
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SSS_SIFP_H_
#define SSS_SIFP_H_
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
#include <dhash.h>
/**
* @defgroup sss_simpleifp Simple interface to SSSD InfoPipe responder.
* Libsss_simpleifp provides a synchronous interface to simplify basic
* communication with SSSD InfoPipe responder.
*
* This interface is not a full replacement for the complete D-Bus API and it
* provides only access to the most common tasks like fetching attributes
* of SSSD objects.
*
* If there is a need for a more sophisticated communication with the SSSD
* InfoPipe responder a D-Bus API of your choice should be used.
*
* @{
*/
/** SSSD InfoPipe bus address */
#define SSS_SIFP_IFP "org.freedesktop.sssd.infopipe"
/** SSSD InfoPipe interface */
#define SSS_SIFP_IFACE_IFP SSS_SIFP_IFP
#define SSS_SIFP_IFACE_COMPONENTS "org.freedesktop.sssd.infopipe.Components"
#define SSS_SIFP_IFACE_SERVICES "org.freedesktop.sssd.infopipe.Services"
#define SSS_SIFP_IFACE_DOMAINS "org.freedesktop.sssd.infopipe.Domains"
#define SSS_SIFP_IFACE_USERS "org.freedesktop.sssd.infopipe.Users"
#define SSS_SIFP_IFACE_GROUPS "org.freedesktop.sssd.infopipe.Groups"
/**
* Opaque libsss_sifp context. One context shall not be used by multiple
* threads. Each thread needs to create and use its own context.
*
* @see sss_sifp_init
* @see sss_sifp_init_ex
*/
typedef struct sss_sifp_ctx sss_sifp_ctx;
/**
* Typedef for memory allocation functions
*/
/**
* Error codes used by libsss_sifp
*/
typedef enum sss_sifp_error {
/** Success */
SSS_SIFP_OK = 0,
/** Ran out of memory during processing */
/** Invalid argument */
/**
*
* @see sss_sifp_get_last_io_error() to get more information
*/
/** Internal error */
/** Operation not supported */
/** Attribute does not exist */
/** Attribute does not have any value set */
/** Incorrect attribute type */
/** Always last */
/**
* D-Bus object attribute
*/
typedef struct sss_sifp_attr sss_sifp_attr;
/**
* D-Bus object
*/
typedef struct sss_sifp_object {
char *name;
char *object_path;
char *interface;
/**
* @brief Initialize sss_sifp context using default allocator (malloc)
*
* @param[out] _ctx sss_sifp context
*/
/**
* @brief Initialize sss_sifp context
*
* @param[in] alloc_pvt Private data for allocation routine
* @param[in] alloc_func Function to allocate memory for the context, if
* NULL malloc() is used
* @param[in] free_func Function to free the memory of the context, if
* NULL free() is used
* @param[out] _ctx sss_sifp context
*/
sss_sifp_init_ex(void *alloc_pvt,
sss_sifp_ctx **_ctx);
/**
* @brief Return last error name from underlying D-Bus communication
*
* @param[in] ctx sss_sifp context
* @return Error message or NULL if no error occurred during last D-Bus call.
*/
const char *
/**
* @brief Return last error message from underlying D-Bus communication
*
* @param[in] ctx sss_sifp context
* @return Error message or NULL if no error occurred during last D-Bus call.
*/
const char *
/**
* @brief Fetch selected attributes of given object.
*
* @param[in] ctx sss_sifp context
* @param[in] object_path D-Bus object path
* @param[in] interface D-Bus interface
* @param[in] name Name of desired attribute
* @param[out] _attrs List of acquired attributes
*/
const char *object_path,
const char *interface,
const char *name,
sss_sifp_attr ***_attrs);
/**
* @brief Fetch all attributes of given object.
*
* @param[in] ctx sss_sifp context
* @param[in] object_path D-Bus object path
* @param[in] interface D-Bus interface
* @param[out] _attrs Acquired attributes
*/
const char *object_path,
const char *interface,
sss_sifp_attr ***_attrs);
/**
* @brief Fetch D-Bus object.
*
* @param[in] ctx sss_sifp context
* @param[in] object_path D-Bus object path
* @param[in] interface D-Bus interface
* @param[out] _object Object and its attributes
*/
const char *object_path,
const char *interface,
/**
* @brief Find attribute in list and return its value.
*
* @param[in] attrs Attributes
* @param[in] name Name of the attribute to find
* @param[out] _value Output value
*/
const char *name,
bool *_value);
/**
* @brief Find attribute in list and return its value.
*
* @param[in] attrs Attributes
* @param[in] name Name of the attribute to find
* @param[out] _value Output value
*/
const char *name,
/**
* @brief Find attribute in list and return its value.
*
* @param[in] attrs Attributes
* @param[in] name Name of the attribute to find
* @param[out] _value Output value
*/
const char *name,
/**
* @brief Find attribute in list and return its value.
*
* @param[in] attrs Attributes
* @param[in] name Name of the attribute to find
* @param[out] _value Output value
*/
const char *name,
/**
* @brief Find attribute in list and return its value.
*
* @param[in] attrs Attributes
* @param[in] name Name of the attribute to find
* @param[out] _value Output value
*/
const char *name,
/**
* @brief Find attribute in list and return its value.
*
* @param[in] attrs Attributes
* @param[in] name Name of the attribute to find
* @param[out] _value Output value
*/
const char *name,
/**
* @brief Find attribute in list and return its value.
*
* @param[in] attrs Attributes
* @param[in] name Name of the attribute to find
* @param[out] _value Output value
*/
const char *name,
/**
* @brief Find attribute in list and return its value.
*
* @param[in] attrs Attributes
* @param[in] name Name of the attribute to find
* @param[out] _value Output value
*/
const char *name,
const char **_value);
/**
* @brief Find attribute in list and return its value.
*
* The dictionary is stored in dhash table, the values
* are pointers to NULL-terminated string array.
*
* @param[in] attrs Attributes
* @param[in] name Name of the attribute to find
* @param[out] _value Output value
*/
const char *name,
hash_table_t **_value);
/**
* @brief Find attribute in list and return its values.
*
* @param[in] attrs Attributes
* @param[in] name Name of the attribute to find
* @param[out] _num_values Number of values in the array
* @param[out] _value Output array
*/
const char *name,
unsigned int *_num_values,
bool **_value);
/**
* @brief Find attribute in list and return its values.
*
* @param[in] attrs Attributes
* @param[in] name Name of the attribute to find
* @param[out] _num_values Number of values in the array
* @param[out] _value Output array
*/
const char *name,
unsigned int *_num_values,
/**
* @brief Find attribute in list and return its values.
*
* @param[in] attrs Attributes
* @param[in] name Name of the attribute to find
* @param[out] _num_values Number of values in the array
* @param[out] _value Output array
*/
const char *name,
unsigned int *_num_values,
/**
* @brief Find attribute in list and return its values.
*
* @param[in] attrs Attributes
* @param[in] name Name of the attribute to find
* @param[out] _num_values Number of values in the array
* @param[out] _value Output array
*/
const char *name,
unsigned int *_num_values,
/**
* @brief Find attribute in list and return its values.
*
* @param[in] attrs Attributes
* @param[in] name Name of the attribute to find
* @param[out] _num_values Number of values in the array
* @param[out] _value Output array
*/
const char *name,
unsigned int *_num_values,
/**
* @brief Find attribute in list and return its values.
*
* @param[in] attrs Attributes
* @param[in] name Name of the attribute to find
* @param[out] _num_values Number of values in the array
* @param[out] _value Output array
*/
const char *name,
unsigned int *_num_values,
/**
* @brief Find attribute in list and return its values.
*
* @param[in] attrs Attributes
* @param[in] name Name of the attribute to find
* @param[out] _num_values Number of values in the array
* @param[out] _value Output array
*/
const char *name,
unsigned int *_num_values,
/**
* @brief Find attribute in list and return its values.
*
* @param[in] attrs Attributes
* @param[in] name Name of the attribute to find
* @param[out] _num_values Number of values in the array
* @param[out] _value Output array
*/
const char *name,
unsigned int *_num_values,
const char * const **_value);
/**
* @brief Free sss_sifp context and set it to NULL.
*
* @param[in,out] _ctx sss_sifp context
*/
void
/**
* @brief Free attribute list and set it to NULL.
*
* @param[in] ctx sss_sifp context
* @param[in,out] _attrs Attributes
*/
void
sss_sifp_attr ***_attrs);
/**
* @brief Free sss_sifp object and set it to NULL.
*
* @param[in] ctx sss_sifp context
* @param[in,out] _object Object
*/
void
/**
* @brief Free string and set it to NULL.
*
* @param[in] ctx sss_sifp context
* @param[in,out] _str String
*/
void
char **_str);
/**
* @brief Free array of strings and set it to NULL.
*
* @param[in] ctx sss_sifp context
* @param[in,out] _str_array Array of strings
*/
void
char ***_str_array);
/**
* @}
*/
/**
* @defgroup common Most common use cases of SSSD InfoPipe responder.
* @{
*/
/**
* @brief List names of available domains.
*
* @param[in] ctx sss_sifp context
* @param[out] _domains List of domain names
*/
char ***_domains);
/**
* @brief Fetch all information about domain by name.
*
* @param[in] ctx sss_sifp context
* @param[in] name Domain name
* @param[out] _domain Domain object
*/
const char *name,
/**
* @brief Fetch all information about user by uid.
*
* @param[in] ctx sss_sifp context
* @param[in] uid User ID
* @param[out] _user User object
*/
sss_sifp_object **_user);
/**
* @brief Fetch all information about user by name.
*
* @param[in] ctx sss_sifp context
* @param[in] name User name
* @param[out] _user User object
*/
const char *name,
sss_sifp_object **_user);
/**
* @}
*/
#endif /* SSS_SIFP_H_ */