confdb.h revision e44e99804519b37852ee9ea24d18d2d2710110ce
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht/*
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht SSSD
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht NSS Configuratoin DB
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht
da4b55f4795a4b585f513eaceb67cda10485febfChristian Maeder Copyright (C) Simo Sorce <ssorce@redhat.com> 2008
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht
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
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.
c208973c890b8f993297720fd0247bc7481d4304Christian Maeder
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/>.
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht*/
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht
4bf72807172000becf65e11bd225efc1dfd99713Simon Ulbricht#ifndef _CONF_DB_H
fcc4b0f2dadf063ebb8022737cb6e40fb9c4baa8Simon Ulbricht#define _CONF_DB_H
846ef0914b29a4806ca0444c116fd3cf267c4fb7Christian Maeder
ce07f3639c04fc3457da387c0dfd9ec01dbf05c4Christian Maeder#include <stdbool.h>
4d1df661384f74cd15d2ceba8a9a3c4760e9ddfbSimon Ulbricht#include "talloc.h"
8600e22385bce13c5d1048f7b955f9394a5d94d6Simon Ulbricht#include "tevent.h"
79eb29c05606f195fe9c6fdca02bcaa458dde17dSimon Ulbricht#include "ldb.h"
e4d1479434761dc3eb8d17b6c75de4eb24866f0bSimon Ulbricht#include "ldb_errors.h"
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht#include "config.h"
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht
4d1df661384f74cd15d2ceba8a9a3c4760e9ddfbSimon Ulbricht/**
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
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht * the sssd.conf
e4d1479434761dc3eb8d17b6c75de4eb24866f0bSimon Ulbricht * @{
4bf72807172000becf65e11bd225efc1dfd99713Simon Ulbricht */
846ef0914b29a4806ca0444c116fd3cf267c4fb7Christian Maeder
e4d1479434761dc3eb8d17b6c75de4eb24866f0bSimon Ulbricht#define CONFDB_FILE "config.ldb"
e4d1479434761dc3eb8d17b6c75de4eb24866f0bSimon Ulbricht#define CONFDB_DEFAULT_CONFIG_FILE SSSD_CONF_DIR"/sssd.conf"
1a088ae6e5ab1e717d720da7b517233286665073Christian Maeder#define SSSD_MIN_ID 1
e4d1479434761dc3eb8d17b6c75de4eb24866f0bSimon Ulbricht#define SSSD_LOCAL_MINID 1000
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht
036b2c3b35fbb0ad74a7490d6d23de606e88a841Simon Ulbricht
036b2c3b35fbb0ad74a7490d6d23de606e88a841Simon Ulbricht/* Configuration options */
fcc4b0f2dadf063ebb8022737cb6e40fb9c4baa8Simon Ulbricht
fcc4b0f2dadf063ebb8022737cb6e40fb9c4baa8Simon Ulbricht/* Services */
fcc4b0f2dadf063ebb8022737cb6e40fb9c4baa8Simon Ulbricht#define CONFDB_SERVICE_PATH_TMPL "config/%s"
59fa2ed5a4936e7e56f7164d8a274df68dd4160cSimon Ulbricht#define CONFDB_SERVICE_COMMAND "command"
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"
fe6a19b07759bc4190e88dda76a211d86bf32062Simon Ulbricht#define CONFDB_SERVICE_TIMEOUT "timeout"
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbricht#define CONFDB_SERVICE_RECON_RETRIES "reconnection_retries"
59fa2ed5a4936e7e56f7164d8a274df68dd4160cSimon Ulbricht
59fa2ed5a4936e7e56f7164d8a274df68dd4160cSimon Ulbricht/* Monitor */
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"
036b2c3b35fbb0ad74a7490d6d23de606e88a841Simon Ulbricht
036b2c3b35fbb0ad74a7490d6d23de606e88a841Simon Ulbricht/* NSS */
8221f726d2e0ca6f0df32ef8f88063b7a85b1cfeSimon Ulbricht#define CONFDB_NSS_CONF_ENTRY "config/nss"
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"
8221f726d2e0ca6f0df32ef8f88063b7a85b1cfeSimon Ulbricht#define CONFDB_NSS_PWFIELD "pwfield"
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht
9b59de1ee08232aa26d9d21d3bf99f8d1f68c45dChristian Maeder/* PAM */
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder#define CONFDB_PAM_CONF_ENTRY "config/pam"
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
3413b54d5439b4a66d6423cc134e1b9abb5bbe2fChristian Maeder
9b59de1ee08232aa26d9d21d3bf99f8d1f68c45dChristian Maeder/* Data Provider */
8221f726d2e0ca6f0df32ef8f88063b7a85b1cfeSimon Ulbricht#define CONFDB_DP_CONF_ENTRY "config/dp"
a9ad67574dd71144680f8dedc285f6c4498a79f8Christian Maeder
a9ad67574dd71144680f8dedc285f6c4498a79f8Christian Maeder/* Domains */
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"
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht#define CONFDB_DOMAIN_COMMAND "command"
2fa75b8879de8c878475f16ab43161e0580f5430Simon Ulbricht#define CONFDB_DOMAIN_TIMEOUT "timeout"
9575d8e9e9211ccd22dbc9b86fa3e8941ee1d021Simon Ulbricht#define CONFDB_DOMAIN_ATTR "cn"
9575d8e9e9211ccd22dbc9b86fa3e8941ee1d021Simon Ulbricht#define CONFDB_DOMAIN_ENUMERATE "enumerate"
0e62ba92d48fb6b8251a0707d0c7e8358ac00a02Simon Ulbricht#define CONFDB_DOMAIN_MINID "min_id"
fcc4b0f2dadf063ebb8022737cb6e40fb9c4baa8Simon Ulbricht#define CONFDB_DOMAIN_MAXID "max_id"
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
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_UMASK "homedir_umask"
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder#define CONFDB_LOCAL_SKEL_DIR "skel_dir"
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder#define CONFDB_LOCAL_MAIL_DIR "mail_dir"
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder#define CONFDB_LOCAL_USERDEL_CMD "userdel_cmd"
0e62ba92d48fb6b8251a0707d0c7e8358ac00a02Simon Ulbricht
08913787eb7dc05172d505d02b11545ffc7e1256Simon Ulbricht/* Proxy Provider */
fe6a19b07759bc4190e88dda76a211d86bf32062Simon Ulbricht#define CONFDB_PROXY_LIBNAME "proxy_lib_name"
fe6a19b07759bc4190e88dda76a211d86bf32062Simon Ulbricht#define CONFDB_PROXY_PAM_TARGET "proxy_pam_target"
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht
f665662391cc4b8fdc03e8bd082936cfedbce1a2Simon Ulbrichtstruct confdb_ctx;
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbrichtstruct config_file_ctx;
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht
f665662391cc4b8fdc03e8bd082936cfedbce1a2Simon Ulbricht/**
f665662391cc4b8fdc03e8bd082936cfedbce1a2Simon Ulbricht * Data structure storing all of the basic features
f665662391cc4b8fdc03e8bd082936cfedbce1a2Simon Ulbricht * of a domain.
f665662391cc4b8fdc03e8bd082936cfedbce1a2Simon Ulbricht */
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbrichtstruct sss_domain_info {
e4d1479434761dc3eb8d17b6c75de4eb24866f0bSimon Ulbricht char *name;
0e62ba92d48fb6b8251a0707d0c7e8358ac00a02Simon Ulbricht char *provider;
0e62ba92d48fb6b8251a0707d0c7e8358ac00a02Simon Ulbricht int timeout;
2fa75b8879de8c878475f16ab43161e0580f5430Simon Ulbricht bool enumerate;
2fa75b8879de8c878475f16ab43161e0580f5430Simon Ulbricht bool fqnames;
2fa75b8879de8c878475f16ab43161e0580f5430Simon Ulbricht uint32_t id_min;
2fa75b8879de8c878475f16ab43161e0580f5430Simon Ulbricht uint32_t id_max;
0e62ba92d48fb6b8251a0707d0c7e8358ac00a02Simon Ulbricht
0e62ba92d48fb6b8251a0707d0c7e8358ac00a02Simon Ulbricht bool cache_credentials;
0e62ba92d48fb6b8251a0707d0c7e8358ac00a02Simon Ulbricht bool legacy_passwords;
0e62ba92d48fb6b8251a0707d0c7e8358ac00a02Simon Ulbricht
0e62ba92d48fb6b8251a0707d0c7e8358ac00a02Simon Ulbricht struct sss_domain_info *next;
0e62ba92d48fb6b8251a0707d0c7e8358ac00a02Simon Ulbricht};
0e62ba92d48fb6b8251a0707d0c7e8358ac00a02Simon Ulbricht
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht/**
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * Initialize the connection to the ConfDB
9575d8e9e9211ccd22dbc9b86fa3e8941ee1d021Simon Ulbricht *
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
9575d8e9e9211ccd22dbc9b86fa3e8941ee1d021Simon Ulbricht * filesystem
08913787eb7dc05172d505d02b11545ffc7e1256Simon Ulbricht *
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
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder */
0223b75560eead55b7bbf11d18117a6819540983Christian Maederint confdb_init(TALLOC_CTX *mem_ctx,
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder struct confdb_ctx **cdb_ctx,
0223b75560eead55b7bbf11d18117a6819540983Christian Maeder const char *confdb_location);
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbricht
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbricht/**
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * Get a domain object for the named domain
f665662391cc4b8fdc03e8bd082936cfedbce1a2Simon Ulbricht *
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
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * name
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht *
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 */
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbrichtint confdb_get_domain(struct confdb_ctx *cdb,
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht const char *name,
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbricht struct sss_domain_info **domain);
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbricht
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbricht/**
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
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * objects
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht *
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 Ulbricht */
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbrichtint confdb_get_domains(struct confdb_ctx *cdb,
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbricht struct sss_domain_info **domains);
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbricht
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbricht
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht/**
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbricht * @brief Add an arbitrary parameter to the confdb.
a9ad67574dd71144680f8dedc285f6c4498a79f8Christian Maeder *
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.
776dc405f11bb5a86787cd05c1e539203e88759bSimon Ulbricht *
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
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * attribute.
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
8221f726d2e0ca6f0df32ef8f88063b7a85b1cfeSimon Ulbricht * config/domain/LDAP
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 *
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
5f662be3a5a327b763dbc53e28836a04cfc3bd3aChristian Maeder */
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbrichtint confdb_add_param(struct confdb_ctx *cdb,
857ab542e0b0bdf90e5a484ffe8df5a9c9c3e38fChristian Maeder bool replace,
9deba6a2981f6b73fc57f27d525cabbb4f8bf484Simon Ulbricht const char *section,
2fa75b8879de8c878475f16ab43161e0580f5430Simon Ulbricht const char *attribute,
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht const char **values);
95f75d053c19b9be988c73b7c866d9db57825efeSimon Ulbricht
e46d78f7c6324ed9f1a191d46b6e5732e61e1835Simon Ulbricht/**
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * @brief Retrieve all values for an attribute
95f75d053c19b9be988c73b7c866d9db57825efeSimon Ulbricht *
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 * config/domain/LDAP
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 *
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 Maeder */
857ab542e0b0bdf90e5a484ffe8df5a9c9c3e38fChristian Maederint confdb_get_param(struct confdb_ctx *cdb,
857ab542e0b0bdf90e5a484ffe8df5a9c9c3e38fChristian Maeder TALLOC_CTX *mem_ctx,
857ab542e0b0bdf90e5a484ffe8df5a9c9c3e38fChristian Maeder const char *section,
857ab542e0b0bdf90e5a484ffe8df5a9c9c3e38fChristian Maeder const char *attribute,
857ab542e0b0bdf90e5a484ffe8df5a9c9c3e38fChristian Maeder char ***values);
e46d78f7c6324ed9f1a191d46b6e5732e61e1835Simon Ulbricht
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht/**
042cf1b6c164c2b06bccafc8db6bf44134f3f0b8Simon Ulbricht * @brief Convenience function to retrieve a single-valued attribute as a
e46d78f7c6324ed9f1a191d46b6e5732e61e1835Simon Ulbricht * string
e46d78f7c6324ed9f1a191d46b6e5732e61e1835Simon Ulbricht *
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
e46d78f7c6324ed9f1a191d46b6e5732e61e1835Simon Ulbricht * config/domain/LDAP
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 *
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 Ulbricht */
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbrichtint confdb_get_string(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbricht const char *section, const char *attribute,
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbricht const char *defstr, char **result);
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbricht
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbricht/**
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbricht * @brief Convenience function to retrieve a single-valued attribute as an
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbricht * integer
bcce4250f8aa524ddc0af7021a238e9fc2b8034aSimon Ulbricht *
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
* config/domain/LDAP
* @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]
*/
int confdb_get_int(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
const char *section, const char *attribute,
int defval, int *result);
/**
* @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] 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.
* e.g. [domain/LDAP] in sssd.conf would translate to
* config/domain/LDAP
* @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
*/
int confdb_get_bool(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
const char *section, const char *attribute,
bool defval, bool *result);
/**
* @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.
* e.g. [domain/LDAP] in sssd.conf would translate to
* config/domain/LDAP
* @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
*/
int confdb_get_string_as_list(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
const char *section, const char *attribute,
char ***result);
/**
* @}
*/
#endif