/*
SSSD
SSSD Configuration DB
Copyright (C) Simo Sorce <ssorce@redhat.com> 2008
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 _CONF_DB_H
#define _CONF_DB_H
#include <stdbool.h>
#include <talloc.h>
#include <tevent.h>
#include <ldb.h>
#include <ldb_errors.h>
#include "config.h"
/**
* @defgroup sss_confdb The ConfDB API
* The ConfDB is an interface for data providers to
* access the configuration information provided in
* the sssd.conf
* @{
*/
/* Configuration options */
/* Services */
/* Monitor */
/* Both monitor and domains */
/* Responders */
/* NSS */
/* PAM */
#define CONFDB_DEFAULT_PAM_FAILED_LOGIN_ATTEMPTS 0
/* SUDO */
#define CONFDB_DEFAULT_SUDO_TIMED false
#define CONFDB_DEFAULT_SUDO_INVERSE_ORDER false
/* autofs */
/* SSH */
#define CONFDB_DEFAULT_SSH_HASH_KNOWN_HOSTS true
/* PAC */
/* InfoPipe */
/* Session Recording */
/* Domains */
#define CONFDB_DOMAIN_CACHE_CREDS_MIN_FF_LENGTH \
"cache_credentials_minimal_first_factor_length"
/* Local Provider */
/* Proxy Provider */
/* Files Provider */
/* Secrets Service */
/* KCM Service */
struct confdb_ctx;
struct config_file_ctx;
/** sssd domain state */
enum sss_domain_state {
/** Domain is usable by both responders and providers. This
* is the default state after creating a new domain
*/
/** Domain was removed, should not be used be neither responders
* not providers.
*/
/** Domain cannot be contacted. Providers return an offline error code
* when receiving request for inactive domain, but responders should
* return cached data
*/
/** Domain is being updated. Responders should ignore cached data and
* always contact the DP
*/
};
/** Whether the domain only supports looking up POSIX entries */
enum sss_domain_type {
/** This is the default domain type. It resolves only entries
* with the full POSIX set of attributes
*/
/** In this mode, entries are typically resolved only by name */
};
/**
* Data structure storing all of the basic features
* of a domain.
*/
struct sss_domain_info {
char *name;
char *conn_name;
char *provider;
int timeout;
bool enumerate;
char **sd_enumerate;
bool fqnames;
bool mpg;
bool ignore_group_members;
const char *pwfield;
bool cache_credentials;
bool legacy_passwords;
bool case_sensitive;
bool case_preserve;
const char *override_homedir;
const char *fallback_homedir;
const char *subdomain_homedir;
const char *homedir_substr;
const char *override_shell;
const char *default_shell;
char *realm;
char *flat_name;
char *domain_id;
bool has_views;
const char *view_name;
char **sd_inherit;
/* Do not use the forest pointer directly in new code, but rather the
* forest_root pointer. sss_domain_info will be more opaque in the future
*/
char *forest;
const char **upn_suffixes;
bool user_name_hint;
/* Do not use the _output_fqnames property directly in new code, but rather
* use sss_domain_info_{get,set}_output_fqnames(). */
bool output_fqnames;
};
/**
* Initialize the connection to the ConfDB
*
* @param[in] mem_ctx The parent memory context for the confdb_ctx
* @param[out] cdb_ctx The newly-created connection object
* @param[in] confdb_location The absolute path to the ConfDB file on the
* filesystem
*
* @return 0 - Connection succeeded and cdb_ctx was populated
* @return ENOMEM - There was not enough memory to create the cdb_ctx
* @return EIO - There was an I/O error communicating with the ConfDB file
*/
struct confdb_ctx **cdb_ctx,
const char *confdb_location);
/**
* Get a domain object for the named domain
*
* @param[in] cdb The connection object to the confdb
* @param[in] name The name of the domain to retrieve
* @param[out] domain A pointer to a domain object for the domain given by
* name
*
* @return 0 - Lookup succeeded and domain was populated
* @return ENOMEM - There was insufficient memory to complete the operation
* @return ENOENT - The named domain does not exist or is not set active
*/
const char *name,
struct sss_domain_info **domain);
/**
* Get a null-terminated linked-list of active domain objects
* @param[in] cdb The connection object to the confdb
* @param[out] domains A pointer to the first entry of a linked-list of domain
* objects
*
* @return 0 - Lookup succeeded and all active domains are in the list
* @return ENOMEM - There was insufficient memory to complete the operation
* @return ENOENT - No active domains are configured
*/
struct sss_domain_info **domains);
const char *implicit_files_dom_name);
/**
* Get a null-terminated linked-list of all domain names
* @param[in] mem_ctx The parent memory context for the value list
* @param[in] cdb The connection object to the confdb
* @param[out] _names Output list
*
* @return 0 - Lookup succeeded and all domain names are in the list
* @return ENOMEM - There was insufficient memory to complete the operation
* @return ENOENT - No active domains are configured
* @return EIO - There was an I/O error communicating with the ConfDB file
* @return EINVAL - Corrupted confdb object
*/
struct confdb_ctx *cdb,
char ***_names);
/**
* @brief Add an arbitrary parameter to the confdb.
*
* This is mostly useful
* for testing, as they will not persist between SSSD restarts. For
* persistence, make changes to the sssd.conf file.
*
* @param[in] cdb The connection object to the confdb
* @param[in] replace If replace is set to true, pre-existing values will be
* overwritten.
* If it is false, the provided values will be added to the
* attribute.
* @param[in] section The ConfDB section to update. This is constructed from
* the format of the sssd.conf file. All sections start
* with 'config/'. Subsections are separated by slashes.
* @param[in] attribute The name of the attribute to update
* @param[in] values A null-terminated array of values to add to the attribute
*
* @return 0 - Successfully added the provided value(s)
* @return ENOMEM - There was insufficient memory to complete the operation
* @return EINVAL - The section could not be parsed
* @return EIO - An I/O error occurred communicating with the ConfDB
*/
bool replace,
const char *section,
const char *attribute,
const char **values);
/**
* @brief Retrieve all values for an attribute
*
* @param[in] cdb The connection object to the confdb
* @param[in] mem_ctx The parent memory context for the value list
* @param[in] section The ConfDB section to update. This is constructed from
* the format of the sssd.conf file. All sections start
* with 'config/'. Subsections are separated by slashes.
* @param[in] attribute The name of the attribute to update
* @param[out] values A null-terminated array of cstrings containing all
* values for this attribute
*
* @return 0 - Successfully retrieved the value(s)
* @return ENOMEM - There was insufficient memory to complete the operation
* @return EINVAL - The section could not be parsed
* @return EIO - An I/O error occurred while communicating with the ConfDB
*/
const char *section,
const char *attribute,
char ***values);
/**
* @brief Convenience function to retrieve a single-valued attribute as a
* string
*
* @param[in] cdb The connection object to the confdb
* @param[in] ctx The parent memory context for the returned string
* @param[in] section The ConfDB section to update. This is constructed from
* the format of the sssd.conf file. All sections start
* with 'config/'. Subsections are separated by slashes.
* @param[in] attribute The name of the attribute to update
* @param[in] defstr If not NULL, the string to use if the attribute does not
* exist in the ConfDB
* @param[out] result A pointer to the retrieved (or default) string
*
* @return 0 - Successfully retrieved the entry (or used the default)
* @return ENOMEM - There was insufficient memory to complete the operation
* @return EINVAL - The section could not be parsed, or the attribute was not
* single-valued.
* @return EIO - An I/O error occurred while communicating with the ConfDB
*/
/**
* @brief Convenience function to retrieve a single-valued attribute as an
* integer
*
* @param[in] cdb The connection object to the confdb
* @param[in] section The ConfDB section to update. This is constructed from
* the format of the sssd.conf file. All sections start
* with 'config/'. Subsections are separated by slashes.
* @param[in] attribute The name of the attribute to update
* @param[in] defval If not NULL, the integer to use if the attribute does not
* exist in the ConfDB
* @param[out] result A pointer to the retrieved (or default) integer
*
* @return 0 - Successfully retrieved the entry (or used the default)
* @return ENOMEM - There was insufficient memory to complete the operation
* @return EINVAL - The section could not be parsed, or the attribute was not
* single-valued.
* @return EIO - An I/O error occurred while communicating with the ConfDB
* @return ERANGE - The value stored in the ConfDB was outside the range
* [INT_MIN..INT_MAX]
*/
/**
* @brief Convenience function to retrieve a single-valued attribute as a
* boolean
*
* This function will read (in a case-insensitive manner) a "true" or "false"
* value from the ConfDB and convert it to an integral bool value.
*
* @param[in] cdb The connection object to the confdb
* @param[in] section The ConfDB section to update. This is constructed from
* the format of the sssd.conf file. All sections start
* with 'config/'. Subsections are separated by slashes.
* @param[in] attribute The name of the attribute to update
* @param[in] defval If not NULL, the boolean state to use if the attribute
* does not exist in the ConfDB
* @param[out] result A pointer to the retrieved (or default) bool
*
* @return 0 - Successfully retrieved the entry (or used the default)
* @return ENOMEM - There was insufficient memory to complete the operation
* @return EINVAL - The section could not be parsed, the attribute was not
* single-valued, or the value was not a boolean.
* @return EIO - An I/O error occurred while communicating with the ConfDB
*/
/**
* @brief Convenience function to set a single-valued attribute as a string
*
* @param[in] cdb The connection object to the confdb
* @param[in] section The ConfDB section to update. This is constructed from
* the format of the sssd.conf file. All sections start
* with 'config/'. Subsections are separated by slashes.
* @param[in] attribute The name of the attribute to update
* @param[in] val New value of the attribute.
*
* @return 0 - Successfully retrieved the entry (or used the default)
* @return ENOMEM - There was insufficient memory to complete the operation
* @return EINVAL - The section could not be parsed
* @return EIO - An I/O error occurred while communicating with the ConfDB
*/
const char *section,
const char *attribute,
const char *val);
/**
* @brief Convenience function to retrieve a single-valued attribute as a
* null-terminated array of strings
*
* This function will automatically split a comma-separated string in an
* attribute into a null-terminated array of strings. This is useful for
* storing and retrieving ordered lists, as ConfDB multivalued attributes do
* not guarantee retrieval order.
*
* @param[in] cdb The connection object to the confdb
* @param[in] ctx The parent memory context for the returned string
* @param[in] section The ConfDB section to update. This is constructed from
* the format of the sssd.conf file. All sections start
* with 'config/'. Subsections are separated by slashes.
* @param[in] attribute The name of the attribute to update
* @param[out] result A pointer to the retrieved array of strings
*
* @return 0 - Successfully retrieved the entry (or used the default)
* @return ENOMEM - There was insufficient memory to complete the operation
* @return EINVAL - The section could not be parsed, or the attribute was not
* single-valued.
* @return ENOENT - The attribute was not found.
* @return EIO - An I/O error occurred while communicating with the ConfDB
*/
char ***result);
/**
* @brief Convenience function to retrieve a list of subsections given a
* configuration section name
*
* @param[in] mem_ctx The parent memory context for the returned list
* @param[in] cdb The connection object to the confdb
* @param[in] section The ConfDB section to look for.
* All sections should start with 'config/'.
* Subsections are separated by slashes.
* @param[out] sections Names of the subsections relative to the section
* requested. If "a/b" is requested then "c/d" is
* returned for the section named [a/b/c/d]
* @param[out] num_sections Number of section names returned
*
* @return 0 - Successfully retrieved the entry (or used the default)
* @return ENOMEM - There was insufficient memory to complete the operation
* @return EINVAL - The section could not be parsed.
* @return ENOENT - No section was found.
* @return EIO - An I/O error occurred while communicating with the ConfDB
*/
struct confdb_ctx *cdb,
const char *section,
char ***sections,
int *num_sections);
/**
* @}
*/
#endif