sysdb.h revision 5153e8b9793dea1e212ca08af0f77ea1d023cbb7
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen Gallagher System Database Header
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen Gallagher Copyright (C) Simo Sorce <ssorce@redhat.com> 2008
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen Gallagher This program is free software; you can redistribute it and/or modify
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen Gallagher it under the terms of the GNU General Public License as published by
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen Gallagher the Free Software Foundation; either version 3 of the License, or
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen Gallagher (at your option) any later version.
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen Gallagher This program is distributed in the hope that it will be useful,
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen Gallagher but WITHOUT ANY WARRANTY; without even the implied warranty of
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen Gallagher MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen Gallagher GNU General Public License for more details.
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen Gallagher You should have received a copy of the GNU General Public License
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen Gallagher along with this program. If not, see <http://www.gnu.org/licenses/>.
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_TMPL_USER_BASE SYSDB_USERS_CONTAINER","SYSDB_DOM_BASE
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_TMPL_GROUP_BASE SYSDB_GROUPS_CONTAINER","SYSDB_DOM_BASE
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_TMPL_CUSTOM_BASE SYSDB_CUSTOM_CONTAINER","SYSDB_DOM_BASE
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_TMPL_NETGROUP_BASE SYSDB_NETGROUP_CONTAINER","SYSDB_DOM_BASE
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_TMPL_RANGE_BASE SYSDB_RANGE_CONTAINER","SYSDB_BASE
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_SELINUX_USERMAP_CLASS "selinuxusermap"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_DOMAIN_ID_RANGE_CLASS "domainIDRange"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_TRUSTED_AD_DOMAIN_RANGE_CLASS "TrustedADDomainRange"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_LAST_FAILED_LOGIN "lastFailedLogin"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_FAILED_LOGIN_ATTEMPTS "failedLoginAttempts"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_CACHE_EXPIRE "dataExpireTimestamp"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_INITGR_EXPIRE "initgrExpireTimestamp"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_AUTHORIZED_SERVICE "authorizedService"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_ORIG_NETGROUP_MEMBER "originalMemberNisNetgroup"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_ORIG_NETGROUP_EXTERNAL_HOST "originalExternalHost"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_NETGROUP_MEMBER "memberNisNetgroup"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_PRIMARY_GROUP_GIDNUM "origPrimaryGroupGidNumber"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_CANONICAL_UPN "canonicalUserPrincipalName"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_ORIG_MODSTAMP "originalModifyTimestamp"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_ORIG_MEMBER_USER "originalMemberUser"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_ORIG_MEMBER_HOST "originalMemberHost"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_SECONDARY_BASE_RID "secondaryBaseRID"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_NEXTID_FILTER "("SYSDB_NEXTID"=*)"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_GC "objectclass="SYSDB_GROUP_CLASS
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_NC "objectclass="SYSDB_NETGROUP_CLASS
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_PWNAM_FILTER "(&("SYSDB_UC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_PWUID_FILTER "(&("SYSDB_UC")("SYSDB_UIDNUM"=%lu))"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_PWSID_FILTER "(&("SYSDB_UC")("SYSDB_SID_STR"=%s))"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_PWUPN_FILTER "(&("SYSDB_UC")(|("SYSDB_UPN"=%s)("SYSDB_CANONICAL_UPN"=%s)))"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_GRNAM_FILTER "(&("SYSDB_GC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_GRGID_FILTER "(&("SYSDB_GC")("SYSDB_GIDNUM"=%lu))"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_GRSID_FILTER "(&("SYSDB_GC")("SYSDB_SID_STR"=%s))"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_GRNAM_MPG_FILTER "(&("SYSDB_MPGC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_GRGID_MPG_FILTER "(&("SYSDB_MPGC")("SYSDB_GIDNUM"=%lu))"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_INITGR_FILTER "(&("SYSDB_GC")("SYSDB_GIDNUM"=*))"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_NETGR_FILTER "(&("SYSDB_NC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_NETGR_TRIPLES_FILTER "(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_MEMBEROF"=%s))"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_SID_FILTER "(&(|("SYSDB_UC")("SYSDB_GC"))("SYSDB_SID_STR"=%s))"
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_DEFAULT_ATTRS SYSDB_LAST_UPDATE, \
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_PW_ATTRS {SYSDB_NAME, SYSDB_UIDNUM, \
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_GRSRC_ATTRS {SYSDB_NAME, SYSDB_GIDNUM, \
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_NETGR_ATTRS {SYSDB_NAME, SYSDB_NETGROUP_TRIPLE, \
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_INITGR_ATTRS {SYSDB_GIDNUM, SYSDB_POSIX, \
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_TMPL_USER SYSDB_NAME"=%s,"SYSDB_TMPL_USER_BASE
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_TMPL_GROUP SYSDB_NAME"=%s,"SYSDB_TMPL_GROUP_BASE
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_TMPL_NETGROUP SYSDB_NAME"=%s,"SYSDB_TMPL_NETGROUP_BASE
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_TMPL_CUSTOM_SUBTREE "cn=%s,"SYSDB_TMPL_CUSTOM_BASE
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_TMPL_CUSTOM SYSDB_NAME"=%s,cn=%s,"SYSDB_TMPL_CUSTOM_BASE
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek#define SYSDB_TMPL_RANGE SYSDB_NAME"=%s,"SYSDB_TMPL_RANGE_BASE
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek/* sysdb version check macros */
03abdaa21ecf562b714f204ca42379ff08626f75Simo Sorce ERROR("Removing cache files in "DB_PATH" should fix the issue, " \
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek "but note that removing cache files will also remove all of your " \
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek "cached credentials.\n")
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen Gallagher ERROR("Lower version of database is expected!\n"); \
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen Gallagher#define SYSDB_VERSION_HIGHER_ERROR(ret) do { \
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek ERROR("Higher version of database is expected!\n"); \
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek ERROR("In order to upgrade the database, you must run SSSD.\n"); \
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek/* use this in daemons */
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek/* use this in tools */
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek/* sysdb_attrs helper functions */
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozekstruct sysdb_attrs *sysdb_new_attrs(TALLOC_CTX *mem_ctx);
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek/* values are copied in the structure, allocated on "attrs" */
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozekint sysdb_attrs_add_val(struct sysdb_attrs *attrs,
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozekint sysdb_attrs_add_string(struct sysdb_attrs *attrs,
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozekint sysdb_attrs_add_lower_case_string(struct sysdb_attrs *attrs,
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozekint sysdb_attrs_add_mem(struct sysdb_attrs *attrs, const char *name,
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozekint sysdb_attrs_add_bool(struct sysdb_attrs *attrs,
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozekint sysdb_attrs_add_long(struct sysdb_attrs *attrs,
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozekint sysdb_attrs_add_uint32(struct sysdb_attrs *attrs,
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozekint sysdb_attrs_add_time_t(struct sysdb_attrs *attrs,
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozekint sysdb_attrs_add_lc_name_alias(struct sysdb_attrs *attrs,
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek const char *value);
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozekint sysdb_attrs_copy_values(struct sysdb_attrs *src,
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek const char *name);
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozekint sysdb_attrs_get_el(struct sysdb_attrs *attrs, const char *name,
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozekint sysdb_attrs_get_el_ext(struct sysdb_attrs *attrs, const char *name,
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozekint sysdb_attrs_steal_string(struct sysdb_attrs *attrs,
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozekint sysdb_attrs_get_string(struct sysdb_attrs *attrs, const char *name,
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozek const char **string);
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozekconst char **sss_ldb_el_to_string_list(TALLOC_CTX *mem_ctx,
5546876b121d674077e93fe908f3a602de8ec31fJakub Hrozekint sysdb_attrs_get_string_array(struct sysdb_attrs *attrs, const char *name,
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen Gallaghererrno_t sysdb_attrs_get_bool(struct sysdb_attrs *attrs, const char *name,
e523233315f44b8f77ab9c5143a3d80364ebf955Ondrej Kosint sysdb_attrs_get_uint16_t(struct sysdb_attrs *attrs, const char *name,
e523233315f44b8f77ab9c5143a3d80364ebf955Ondrej Kosint sysdb_attrs_get_int32_t(struct sysdb_attrs *attrs, const char *name,
03abdaa21ecf562b714f204ca42379ff08626f75Simo Sorceint sysdb_attrs_get_uint32_t(struct sysdb_attrs *attrs, const char *name,
03abdaa21ecf562b714f204ca42379ff08626f75Simo Sorceint sysdb_attrs_replace_name(struct sysdb_attrs *attrs, const char *oldname,
e523233315f44b8f77ab9c5143a3d80364ebf955Ondrej Kos const char *newname);
e523233315f44b8f77ab9c5143a3d80364ebf955Ondrej Kosint sysdb_attrs_users_from_str_list(struct sysdb_attrs *attrs,
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 *name,
const char **_cname);
const char *name);
const char *name);
const char *object_name,
const char *subtree_name);
const char *subtree_name);
const char* forest);
bool allow_upgrade);
const char *db_path,
const char *name,
const char *name,
struct sysdb_netgroup_ctx {
char *hostname;
char *username;
char *domainname;
} triple;
char *groupname;
} value;
const char *netgroup,
const char *name,
const char *name,
const char **attributes,
const char *netgrname,
const char **attributes,
bool ignore_not_found);
bool ignore_not_found);
const char *filter,
const char **attrs,
const char *name,
const char **attrs,
const char **attrs,
const char *sid_str,
const char **attrs,
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,
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,
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,
enum sysdb_member_type {
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 *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 *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);
#define SYSDB_IDMAP_ATTRS { \
SYSDB_NAME, \
NULL }
const char *dom_name,
const char *dom_sid,
const char *sid_str,
const char **attrs,