a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina System Database Header
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina Copyright (C) Simo Sorce <ssorce@redhat.com> 2008
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina This program is free software; you can redistribute it and/or modify
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina it under the terms of the GNU General Public License as published by
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina the Free Software Foundation; either version 3 of the License, or
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina (at your option) any later version.
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina This program is distributed in the hope that it will be useful,
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina but WITHOUT ANY WARRANTY; without even the implied warranty of
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina GNU General Public License for more details.
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina You should have received a copy of the GNU General Public License
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina along with this program. If not, see <http://www.gnu.org/licenses/>.
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define CACHE_TIMESTAMPS_FILE "timestamps_%s.ldb"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_TMPL_USER_BASE SYSDB_USERS_CONTAINER","SYSDB_DOM_BASE
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_TMPL_GROUP_BASE SYSDB_GROUPS_CONTAINER","SYSDB_DOM_BASE
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_TMPL_CUSTOM_BASE SYSDB_CUSTOM_CONTAINER","SYSDB_DOM_BASE
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_TMPL_NETGROUP_BASE SYSDB_NETGROUP_CONTAINER","SYSDB_DOM_BASE
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_TMPL_RANGE_BASE SYSDB_RANGE_CONTAINER","SYSDB_BASE
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_TMPL_VIEW_BASE SYSDB_VIEW_CONTAINER","SYSDB_BASE
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_TMPL_VIEW_SEARCH_BASE "cn=%s,"SYSDB_TMPL_VIEW_BASE
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_TMPL_CERTMAP_BASE SYSDB_CERTMAP_CONTAINER","SYSDB_BASE
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_SELINUX_USERMAP_CLASS "selinuxusermap"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_DOMAIN_ID_RANGE_CLASS "domainIDRange"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_TRUSTED_AD_DOMAIN_RANGE_CLASS "TrustedADDomainRange"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_CERTMAP_CLASS "certificateMappingRule"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_LAST_ONLINE_AUTH "lastOnlineAuth"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_LAST_FAILED_LOGIN "lastFailedLogin"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_FAILED_LOGIN_ATTEMPTS "failedLoginAttempts"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_LAST_ONLINE_AUTH_WITH_CURR_TOKEN "lastOnlineAuthWithCurrentToken"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_CACHE_EXPIRE "dataExpireTimestamp"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_INITGR_EXPIRE "initgrExpireTimestamp"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_AUTHORIZED_SERVICE "authorizedService"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_AUTHORIZED_RHOST "authorizedRHost"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_ORIG_NETGROUP_MEMBER "originalMemberNisNetgroup"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_ORIG_NETGROUP_EXTERNAL_HOST "originalExternalHost"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_NETGROUP_MEMBER "memberNisNetgroup"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_CACHEDPWD_TYPE "cachedPasswordType"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_CACHEDPWD_FA2_LEN "cachedPasswordSecondFactorLen"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_PRIMARY_GROUP_GIDNUM "origPrimaryGroupGidNumber"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_PAC_BLOB_EXPIRE "pacBlobExpireTimestamp"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_CANONICAL_UPN "canonicalUserPrincipalName"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_ORIG_MODSTAMP "originalModifyTimestamp"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_ORIG_MEMBER_USER "originalMemberUser"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_ORIG_MEMBER_HOST "originalMemberHost"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_USER_MAPPED_CERT "userMappedCertificate"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_SUBDOMAIN_FOREST "memberOfForest"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_SUBDOMAIN_TRUST_DIRECTION "trustDirection"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_SECONDARY_BASE_RID "secondaryBaseRID"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_CERTMAP_MATCHING_RULE "matchingRule"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_CERTMAP_MAPPING_RULE "mappingRule"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_CERTMAP_USER_NAME_HINT "userNameHint"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_DEFAULT_OVERRIDE_NAME "defaultOverrideName"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_AD_ACCOUNT_EXPIRES "adAccountExpires"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_AD_USER_ACCOUNT_CONTROL "adUserAccountControl"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_LOCAL_VIEW_NAME "LOCAL" /* reserved for client-side overrides */
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_OVERRIDE_ANCHOR_UUID "overrideAnchorUUID"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_OVERRIDE_USER_CLASS "userOverride"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_OVERRIDE_GROUP_CLASS "groupOverride"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_OVERRIDE_OBJECT_DN "overrideObjectDN"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_USE_DOMAIN_RESOLUTION_ORDER "useDomainResolutionOrder"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_DOMAIN_RESOLUTION_ORDER "domainResolutionOrder"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_SESSION_RECORDING "sessionRecording"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_NEXTID_FILTER "("SYSDB_NEXTID"=*)"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_UC SYSDB_OBJECTCATEGORY"="SYSDB_USER_CLASS
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_GC SYSDB_OBJECTCATEGORY"="SYSDB_GROUP_CLASS
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_NC SYSDB_OBJECTCLASS"="SYSDB_NETGROUP_CLASS
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_PWNAM_FILTER "(&("SYSDB_UC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_PWUID_FILTER "(&("SYSDB_UC")("SYSDB_UIDNUM"=%lu))"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_PWSID_FILTER "(&("SYSDB_UC")("SYSDB_SID_STR"=%s))"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_PWUPN_FILTER "(&("SYSDB_UC")(|("SYSDB_UPN"=%s)("SYSDB_CANONICAL_UPN"=%s)("SYSDB_USER_EMAIL"=%s)))"
1b5d6b1afc9c3dc696b7b45f2d73b2634f42800aSumit Bose#define SYSDB_GRNAM_FILTER "(&("SYSDB_GC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_GRGID_FILTER "(&("SYSDB_GC")("SYSDB_GIDNUM"=%lu))"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_GRSID_FILTER "(&("SYSDB_GC")("SYSDB_SID_STR"=%s))"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_GRNAM_MPG_FILTER "(&("SYSDB_MPGC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_GRGID_MPG_FILTER "(&("SYSDB_MPGC")("SYSDB_GIDNUM"=%lu))"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_GRENT_MPG_FILTER "("SYSDB_MPGC")"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_INITGR_FILTER "(&("SYSDB_GC")("SYSDB_GIDNUM"=*))"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_NETGR_FILTER "(&("SYSDB_NC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_NETGR_TRIPLES_FILTER "(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_MEMBEROF"=%s))"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_SID_FILTER "(&(|("SYSDB_UC")("SYSDB_GC"))("SYSDB_SID_STR"=%s))"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_UUID_FILTER "(&(|("SYSDB_UC")("SYSDB_GC"))("SYSDB_UUID"=%s))"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_NAME_FILTER "(&(|("SYSDB_UC")("SYSDB_GC"))(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_ID_FILTER "(|(&("SYSDB_UC")("SYSDB_UIDNUM"=%u))(&("SYSDB_GC")("SYSDB_GIDNUM"=%u)))"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_USER_CERT_FILTER "(&("SYSDB_UC")%s)"
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_DEFAULT_ATTRS SYSDB_LAST_UPDATE, \
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_PW_ATTRS {SYSDB_NAME, SYSDB_UIDNUM, \
1b5d6b1afc9c3dc696b7b45f2d73b2634f42800aSumit Bose#define SYSDB_GRSRC_ATTRS {SYSDB_NAME, SYSDB_GIDNUM, \
1b5d6b1afc9c3dc696b7b45f2d73b2634f42800aSumit Bose#define SYSDB_NETGR_ATTRS {SYSDB_NAME, SYSDB_NETGROUP_TRIPLE, \
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_INITGR_ATTRS {SYSDB_GIDNUM, SYSDB_POSIX, \
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_TMPL_USER SYSDB_NAME"=%s,"SYSDB_TMPL_USER_BASE
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_TMPL_GROUP SYSDB_NAME"=%s,"SYSDB_TMPL_GROUP_BASE
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_TMPL_NETGROUP SYSDB_NAME"=%s,"SYSDB_TMPL_NETGROUP_BASE
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_TMPL_CUSTOM_SUBTREE "cn=%s,"SYSDB_TMPL_CUSTOM_BASE
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_TMPL_CUSTOM SYSDB_NAME"=%s,cn=%s,"SYSDB_TMPL_CUSTOM_BASE
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_TMPL_RANGE SYSDB_NAME"=%s,"SYSDB_TMPL_RANGE_BASE
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_TMPL_OVERRIDE SYSDB_OVERRIDE_ANCHOR_UUID"=%s,"SYSDB_TMPL_VIEW_SEARCH_BASE
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina#define SYSDB_TMPL_CERTMAP SYSDB_NAME"=%s,"SYSDB_TMPL_CERTMAP_BASE
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina/* sysdb version check macros */
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina ERROR("Removing cache files in "DB_PATH" should fix the issue, " \
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina "but note that removing cache files will also remove all of your " \
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina "cached credentials.\n")
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina ERROR("Lower version of database is expected!\n"); \
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina ERROR("Higher version of database is expected!\n"); \
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina ERROR("In order to upgrade the database, you must run SSSD.\n"); \
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina/* use this in daemons */
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina/* use this in tools */
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina/* sysdb_attrs helper functions */
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březinastruct sysdb_attrs *sysdb_new_attrs(TALLOC_CTX *mem_ctx);
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březina/* These attributes are stored in the timestamp cache */
a8191ce7ad5364801ad9458c3194075a7ca77b8aPavel Březinaextern const char *sysdb_ts_cache_attrs[];
const char *base64_str);
const char *value);
const char *value);
const char *name);
const char **string);
bool *value);
const char *newname);
const char *attr_name,
const char *domain,
const char *const *list);
const char *ldap_attr,
const char **_primary);
const char *primary,
bool lowercase,
const char ***_aliases);
const char *ldap_attr,
char ***name_list);
const char *ldap_attr,
char ***name_list);
const char *name_or_upn,
const char **_cname);
int sysdb_compare_usn(const char *a, const char *b);
char **_usn);
const char *name);
const char *name);
const char *object_name,
const char *subtree_name);
const char *subtree_name);
const char *domain_name,
const char **_domain_resolution_order);
const char *domain_name,
const char *domain_resolution_order);
const char **_site);
const char *site);
const char *realm,
const char *flat,
const char *id,
const char *forest,
char **view_name);
const char *domain_resolution_order);
const char **_domain_resolution_order);
const char *member_dn,
const char **attrs,
const char *name,
const char **attrs,
const char *name,
const char **attrs,
const char *name,
const char *name,
const char *cert,
const char **attrs,
const char **req_attrs);
bool expect_override_dn);
const char *name,
const char *name,
struct ldb_message_element *
const char *attr_name);
const char *attr_name,
const char * default_value);
const char *attr_name,
bool user_name_hint);
bool *user_name_hint);
bool chown_dbfile,
const char *db_path,
const char *name,
bool domain_scope,
const char *upn,
const char *name_filter,
const char *addtl_filter,
const char *name_filter,
const char *addtl_filter,
const char *name,
const char *name_filter,
const char *addtl_filter,
const char *name_filter,
const char *addtl_filter,
const char *netgroup,
const char *name,
const char *upn,
const char *name,
const char *name,
const char **attributes,
const char *name,
const char **attributes,
const char *cert,
const char *netgrname,
const char **attributes,
bool ignore_not_found);
bool ignore_not_found);
const char *filter,
const char **attrs,
exp_fmt, ...) do { \
int _sls_lret; \
const char *name,
const char **attrs,
const char **attrs,
const char *sid_str,
const char **attrs,
bool domain_scope,
const char *upn,
const char **attrs,
bool domain_scope,
const char *sid_str,
const char **attrs,
const char *name,
const char **attrs,
const char **attrs,
const char *sid_str,
const char **attrs,
const char *name,
const char **attrs,
int mod_op);
const char *name,
bool is_user);
const char *name,
int mod_op);
const char *name,
int mod_op);
const char *name,
int mod_op);
const char *name,
const char *gecos,
const char *homedir,
const char *shell);
const char *name,
const char *gecos,
const char *homedir,
const char *shell,
const char *orig_dn,
int cache_timeout,
int cache_timeout,
const char *name,
const char *original_dn,
const char *sid_str,
const char *uuid,
bool posix,
const char *name,
const char *description,
char **missing,
int cache_timeout,
int mod_op);
const char *name,
const char *pwd,
const char *gecos,
const char *homedir,
const char *shell,
const char *orig_dn,
char **remove_attrs,
const char *name,
const char *group,
const char *member,
bool is_dn);
const char *group,
const char *member,
bool is_dn);
const char *member,
const char *const *add_groups,
const char *const *del_groups);
const char *member,
const char *const *add_groups,
const char *const *del_groups);
const char *view_name,
const char *username,
const char *password);
const char *username,
const char *password,
const char *name,
const char *password,
bool just_check,
const char *object_name,
const char *subtree_name,
const char *filter,
const char *subtree_name,
const char **attrs,
const char *object_name,
const char *subtree_name,
const char **attrs,
const char *object_name,
const char *subtree_name);
const char *expression,
const char *asq_attribute,
const char **attrs,
const char *sub_filter,
const char **attrs,
const char *sub_filter,
const char **attrs,
const char *sub_filter,
const char **attrs,
const char *sub_filter,
const char **attrs,
const char *sub_filter,
const char **attrs,
const char *name);
const char *sid_str);
int attr_count,
const char *attr_name,
char ***_list);
char **sanitized);
const char *attr_name,
bool *value);
const char *cn_value,
const char *attr_name,
bool value);
bool *has_enumerated);
bool enumerated);
const char *name,
char **remove_attrs);
const char *name,
char ***_direct_parents);
SYSDB_NAME, \
NULL }
const char *dom_name,
const char *dom_sid,
const char **attrs,
const char *name,
const char **attrs,
const char *sid_str,
const char **attrs,
const char *uuid_str,
const char **attrs,
const char *cert,
const char **attrs,
const char *cert,
const char *cert);
SYSDB_NAME, \
NULL }
const char *gpo_guid,
int gpo_version,
int cache_timeout,
const char *gpo_guid,
const char *policy_setting_key,
const char *policy_setting_value);
const char *policy_setting_key,
const char **policy_setting_value);
const char *group_name,
const char ***_sids,
const char ***_dns,
const char *src_name,
const char *dest_name);