confdb.h revision e44e99804519b37852ee9ea24d18d2d2710110ce
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht NSS Configuratoin DB
da4b55f4795a4b585f513eaceb67cda10485febfChristian Maeder Copyright (C) Simo Sorce <ssorce@redhat.com> 2008
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht This program is free software; you can redistribute it and/or modify
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht it under the terms of the GNU General Public License as published by
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht the Free Software Foundation; either version 3 of the License, or
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht (at your option) any later version.
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht This program is distributed in the hope that it will be useful,
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht but WITHOUT ANY WARRANTY; without even the implied warranty of
4bf72807172000becf65e11bd225efc1dfd99713Simon Ulbricht MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht GNU General Public License for more details.
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht You should have received a copy of the GNU General Public License
e46d78f7c6324ed9f1a191d46b6e5732e61e1835Simon Ulbricht along with this program. If not, see <http://www.gnu.org/licenses/>.
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder * @defgroup sss_confdb The ConfDB API
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * The ConfDB is an interface for data providers to
1a088ae6e5ab1e717d720da7b517233286665073Christian Maeder * access the configuration information provided in
e4d1479434761dc3eb8d17b6c75de4eb24866f0bSimon Ulbricht#define CONFDB_DEFAULT_CONFIG_FILE SSSD_CONF_DIR"/sssd.conf"
036b2c3b35fbb0ad74a7490d6d23de606e88a841Simon Ulbricht/* Configuration options */
fcc4b0f2dadf063ebb8022737cb6e40fb9c4baa8Simon Ulbricht/* Services */
fcc4b0f2dadf063ebb8022737cb6e40fb9c4baa8Simon Ulbricht#define CONFDB_SERVICE_DEBUG_LEVEL "debug_level"
fcc4b0f2dadf063ebb8022737cb6e40fb9c4baa8Simon Ulbricht#define CONFDB_SERVICE_DEBUG_TIMESTAMPS "debug_timestamps"
fcc4b0f2dadf063ebb8022737cb6e40fb9c4baa8Simon Ulbricht#define CONFDB_SERVICE_DEBUG_TO_FILES "debug_to_files"
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbricht#define CONFDB_SERVICE_RECON_RETRIES "reconnection_retries"
e90b8ee3fac5c932d83af2061579c6b57d528885Christian Maeder#define CONFDB_MONITOR_CONF_ENTRY "config/sssd"
ce07f3639c04fc3457da387c0dfd9ec01dbf05c4Christian Maeder#define CONFDB_MONITOR_SBUS_TIMEOUT "sbus_timeout"
ce07f3639c04fc3457da387c0dfd9ec01dbf05c4Christian Maeder#define CONFDB_MONITOR_ACTIVE_SERVICES "services"
036b2c3b35fbb0ad74a7490d6d23de606e88a841Simon Ulbricht#define CONFDB_MONITOR_ACTIVE_DOMAINS "domains"
036b2c3b35fbb0ad74a7490d6d23de606e88a841Simon Ulbricht#define CONFDB_MONITOR_NAME_REGEX "re_expression"
036b2c3b35fbb0ad74a7490d6d23de606e88a841Simon Ulbricht#define CONFDB_MONITOR_FULL_NAME_FORMAT "full_name_format"
036b2c3b35fbb0ad74a7490d6d23de606e88a841Simon Ulbricht#define CONFDB_MONITOR_TRY_INOTIFY "try_inotify"
8221f726d2e0ca6f0df32ef8f88063b7a85b1cfeSimon Ulbricht#define CONFDB_NSS_ENUM_CACHE_TIMEOUT "enum_cache_timeout"
8221f726d2e0ca6f0df32ef8f88063b7a85b1cfeSimon Ulbricht#define CONFDB_NSS_ENTRY_CACHE_NOWAIT_PERCENTAGE "entry_cache_nowait_percentage"
8221f726d2e0ca6f0df32ef8f88063b7a85b1cfeSimon Ulbricht#define CONFDB_NSS_ENTRY_NEG_TIMEOUT "entry_negative_timeout"
8600e22385bce13c5d1048f7b955f9394a5d94d6Simon Ulbricht#define CONFDB_NSS_FILTER_USERS_IN_GROUPS "filter_users_in_groups"
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht#define CONFDB_NSS_FILTER_USERS "filter_users"
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht#define CONFDB_NSS_FILTER_GROUPS "filter_groups"
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder#define CONFDB_PAM_CRED_TIMEOUT "offline_credentials_expiration"
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder#define CONFDB_PAM_FAILED_LOGIN_ATTEMPTS "offline_failed_login_attempts"
8221f726d2e0ca6f0df32ef8f88063b7a85b1cfeSimon Ulbricht#define CONFDB_DEFAULT_PAM_FAILED_LOGIN_ATTEMPTS 0
9b59de1ee08232aa26d9d21d3bf99f8d1f68c45dChristian Maeder#define CONFDB_PAM_FAILED_LOGIN_DELAY "offline_failed_login_delay"
857ab542e0b0bdf90e5a484ffe8df5a9c9c3e38fChristian Maeder#define CONFDB_DEFAULT_PAM_FAILED_LOGIN_DELAY 5
9b59de1ee08232aa26d9d21d3bf99f8d1f68c45dChristian Maeder/* Data Provider */
a9ad67574dd71144680f8dedc285f6c4498a79f8Christian Maeder#define CONFDB_DOMAIN_PATH_TMPL "config/domain/%s"
8221f726d2e0ca6f0df32ef8f88063b7a85b1cfeSimon Ulbricht#define CONFDB_DOMAIN_BASEDN "cn=domain,cn=config"
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht#define CONFDB_DOMAIN_ID_PROVIDER "id_provider"
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht#define CONFDB_DOMAIN_AUTH_PROVIDER "auth_provider"
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht#define CONFDB_DOMAIN_ACCESS_PROVIDER "access_provider"
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht#define CONFDB_DOMAIN_CHPASS_PROVIDER "chpass_provider"
fcc4b0f2dadf063ebb8022737cb6e40fb9c4baa8Simon Ulbricht#define CONFDB_DOMAIN_CACHE_CREDS "cache_credentials"
0e62ba92d48fb6b8251a0707d0c7e8358ac00a02Simon Ulbricht#define CONFDB_DOMAIN_LEGACY_PASS "store_legacy_passwords"
0e62ba92d48fb6b8251a0707d0c7e8358ac00a02Simon Ulbricht#define CONFDB_DOMAIN_MPG "magic_private_groups"
0e62ba92d48fb6b8251a0707d0c7e8358ac00a02Simon Ulbricht#define CONFDB_DOMAIN_FQ "use_fully_qualified_names"
0e62ba92d48fb6b8251a0707d0c7e8358ac00a02Simon Ulbricht#define CONFDB_DOMAIN_ENTRY_CACHE_TIMEOUT "entry_cache_timeout"
0e62ba92d48fb6b8251a0707d0c7e8358ac00a02Simon Ulbricht#define CONFDB_DOMAIN_RESOLV_TIMEOUT "dns_resolver_timeout"
a2cf22f16e226fcc85aa0801f001923ab2db49ddSimon Ulbricht#define CONFDB_DOMAIN_DNS_DISCOVERY_NAME "dns_discovery_domain"
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder#define CONFDB_DOMAIN_FAMILY_ORDER "lookup_family_order"
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder#define CONFDB_DOMAIN_ACCOUNT_CACHE_EXPIRATION "account_cache_expiration"
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder/* Local Provider */
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder#define CONFDB_LOCAL_DEFAULT_SHELL "default_shell"
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder#define CONFDB_LOCAL_DEFAULT_BASEDIR "base_directory"
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder#define CONFDB_LOCAL_CREATE_HOMEDIR "create_homedir"
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder#define CONFDB_LOCAL_REMOVE_HOMEDIR "remove_homedir"
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder#define CONFDB_LOCAL_USERDEL_CMD "userdel_cmd"
08913787eb7dc05172d505d02b11545ffc7e1256Simon Ulbricht/* Proxy Provider */
fe6a19b07759bc4190e88dda76a211d86bf32062Simon Ulbricht#define CONFDB_PROXY_PAM_TARGET "proxy_pam_target"
f665662391cc4b8fdc03e8bd082936cfedbce1a2Simon Ulbricht * Data structure storing all of the basic features
f665662391cc4b8fdc03e8bd082936cfedbce1a2Simon Ulbricht * of a domain.
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * Initialize the connection to the ConfDB
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * @param[in] mem_ctx The parent memory context for the confdb_ctx
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * @param[out] cdb_ctx The newly-created connection object
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder * @param[in] confdb_location The absolute path to the ConfDB file on the
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder * @return 0 - Connection succeeded and cdb_ctx was populated
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder * @return ENOMEM - There was not enough memory to create the cdb_ctx
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder * @return EIO - There was an I/O error communicating with the ConfDB file
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * Get a domain object for the named domain
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * @param[in] cdb The connection object to the confdb
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbricht * @param[in] name The name of the domain to retrieve
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbricht * @param[out] domain A pointer to a domain object for the domain given by
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbricht * @return 0 - Lookup succeeded and domain was populated
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbricht * @return ENOMEM - There was insufficient memory to complete the operation
c044cefcba5a9db7f8948b3778266971742b3dc6Simon Ulbricht * @return ENOENT - The named domain does not exist or is not set active
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbricht * Get a null-terminated linked-list of active domain objects
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbricht * @param[in] cdb The connection object to the confdb
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * @param[out] domains A pointer to the first entry of a linked-list of domain
f665662391cc4b8fdc03e8bd082936cfedbce1a2Simon Ulbricht * @return 0 - Lookup succeeded and all active domains are in the list
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbricht * @return ENOMEM - There was insufficient memory to complete the operation
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * @return ENOENT - No active domains are configured
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbrichtint confdb_get_domains(struct confdb_ctx *cdb,
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbricht * @brief Add an arbitrary parameter to the confdb.
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbricht * This is mostly useful
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbricht * for testing, as they will not persist between SSSD restarts. For
e46d78f7c6324ed9f1a191d46b6e5732e61e1835Simon Ulbricht * persistence, make changes to the sssd.conf file.
08913787eb7dc05172d505d02b11545ffc7e1256Simon Ulbricht * @param[in] cdb The connection object to the confdb
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbricht * @param[in] replace If replace is set to true, pre-existing values will be
ca172aacea0c647b83274a7206288866faaec401Simon Ulbricht * overwritten.
a2cf22f16e226fcc85aa0801f001923ab2db49ddSimon Ulbricht * If it is false, the provided values will be added to the
857ab542e0b0bdf90e5a484ffe8df5a9c9c3e38fChristian Maeder * @param[in] section The ConfDB section to update. This is constructed from
a2cf22f16e226fcc85aa0801f001923ab2db49ddSimon Ulbricht * the format of the sssd.conf file. All sections start
a2cf22f16e226fcc85aa0801f001923ab2db49ddSimon Ulbricht * with 'config/'. Subsections are separated by slashes.
a2cf22f16e226fcc85aa0801f001923ab2db49ddSimon Ulbricht * e.g. [domain/LDAP] in sssd.conf would translate to
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * @param[in] attribute The name of the attribute to update
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * @param[in] values A null-terminated array of values to add to the attribute
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * @return 0 - Successfully added the provided value(s)
5f662be3a5a327b763dbc53e28836a04cfc3bd3aChristian Maeder * @return ENOMEM - There was insufficient memory to complete the operation
5f662be3a5a327b763dbc53e28836a04cfc3bd3aChristian Maeder * @return EINVAL - The section could not be parsed
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * @return EIO - An I/O error occurred communicating with the ConfDB
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht const char **values);
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * @brief Retrieve all values for an attribute
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * @param[in] cdb The connection object to the confdb
454e349ad409df6c5fa9ba2b485243b8222dec41Simon Ulbricht * @param[in] mem_ctx The parent memory context for the value list
d3d09eed06d615a26a9c930966f29cf2c149b876Simon Ulbricht * @param[in] section The ConfDB section to update. This is constructed from
d3d09eed06d615a26a9c930966f29cf2c149b876Simon Ulbricht * the format of the sssd.conf file. All sections start
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * with 'config/'. Subsections are separated by slashes.
454e349ad409df6c5fa9ba2b485243b8222dec41Simon Ulbricht * e.g. [domain/LDAP] in sssd.conf would translate to
1a088ae6e5ab1e717d720da7b517233286665073Christian Maeder * @param[in] attribute The name of the attribute to update
1a088ae6e5ab1e717d720da7b517233286665073Christian Maeder * @param[out] values A null-terminated array of cstrings containing all
454e349ad409df6c5fa9ba2b485243b8222dec41Simon Ulbricht * values for this attribute
454e349ad409df6c5fa9ba2b485243b8222dec41Simon Ulbricht * @return 0 - Successfully retrieved the value(s)
454e349ad409df6c5fa9ba2b485243b8222dec41Simon Ulbricht * @return ENOMEM - There was insufficient memory to complete the operation
9deba6a2981f6b73fc57f27d525cabbb4f8bf484Simon Ulbricht * @return EINVAL - The section could not be parsed
2fa75b8879de8c878475f16ab43161e0580f5430Simon Ulbricht * @return EIO - An I/O error occurred while communicating with the ConfDB
857ab542e0b0bdf90e5a484ffe8df5a9c9c3e38fChristian Maederint confdb_get_param(struct confdb_ctx *cdb,
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * @brief Convenience function to retrieve a single-valued attribute as a
e46d78f7c6324ed9f1a191d46b6e5732e61e1835Simon Ulbricht * @param[in] cdb The connection object to the confdb
e46d78f7c6324ed9f1a191d46b6e5732e61e1835Simon Ulbricht * @param[in] ctx The parent memory context for the returned string
9deba6a2981f6b73fc57f27d525cabbb4f8bf484Simon Ulbricht * @param[in] section The ConfDB section to update. This is constructed from
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * the format of the sssd.conf file. All sections start
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * with 'config/'. Subsections are separated by slashes.
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * e.g. [domain/LDAP] in sssd.conf would translate to
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * @param[in] attribute The name of the attribute to update
9deba6a2981f6b73fc57f27d525cabbb4f8bf484Simon Ulbricht * @param[in] defstr If not NULL, the string to use if the attribute does not
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbricht * exist in the ConfDB
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbricht * @param[out] result A pointer to the retrieved (or default) string
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbricht * @return 0 - Successfully retrieved the entry (or used the default)
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbricht * @return ENOMEM - There was insufficient memory to complete the operation
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbricht * @return EINVAL - The section could not be parsed, or the attribute was not
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbricht * single-valued.
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbricht * @return EIO - An I/O error occurred while communicating with the ConfDB
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbrichtint confdb_get_string(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbricht * @brief Convenience function to retrieve a single-valued attribute as an
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbricht * @param[in] cdb The connection object to the confdb
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbricht * @param[in] ctx The parent memory context for the returned string
5f662be3a5a327b763dbc53e28836a04cfc3bd3aChristian Maeder * @param[in] section The ConfDB section to update. This is constructed from
5f662be3a5a327b763dbc53e28836a04cfc3bd3aChristian Maeder * the format of the sssd.conf file. All sections start
5f662be3a5a327b763dbc53e28836a04cfc3bd3aChristian Maeder * with 'config/'. Subsections are separated by slashes.
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbricht * e.g. [domain/LDAP] in sssd.conf would translate to
* the format of the sssd.conf file. All sections start
* the format of the sssd.conf file. All sections start
char ***result);