/*
SSSD
System Database Header
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 __SYS_DB_H__
#define __SYS_DB_H__
#include "sss_client/sss_cli.h"
#include <tevent.h>
#define SYSDB_PWNAM_FILTER "(&("SYSDB_UC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
#define SYSDB_PWUPN_FILTER "(&("SYSDB_UC")(|("SYSDB_UPN"=%s)("SYSDB_CANONICAL_UPN"=%s)("SYSDB_USER_EMAIL"=%s)))"
#define SYSDB_GRNAM_FILTER "(&("SYSDB_GC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
#define SYSDB_GRNAM_MPG_FILTER "(&("SYSDB_MPGC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
#define SYSDB_NETGR_FILTER "(&("SYSDB_NC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
#define SYSDB_NETGR_TRIPLES_FILTER "(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_MEMBEROF"=%s))"
SYSDB_UPN, \
SYSDB_UUID, \
NULL}
SYSDB_MEMBER, \
SYSDB_GHOST, \
SYSDB_UUID, \
NULL}
NULL}
SYSDB_NAME, \
NULL}
/* sysdb version check macros */
#define SYSDB_VERSION_ERROR_HINT \
"but note that removing cache files will also remove all of your " \
"cached credentials.\n")
if (ret == ERR_SYSDB_VERSION_TOO_NEW) { \
ERROR("Lower version of database is expected!\n"); \
} \
} while(0)
if (ret == ERR_SYSDB_VERSION_TOO_OLD) { \
ERROR("Higher version of database is expected!\n"); \
ERROR("In order to upgrade the database, you must run SSSD.\n"); \
} \
} while(0)
/* use this in daemons */
/* use this in tools */
struct confdb_ctx;
struct sysdb_ctx;
struct sysdb_attrs {
int num;
struct ldb_message_element *a;
};
/* sysdb_attrs helper functions */
struct range_info {
char *name;
char *trusted_dom_sid;
char *range_type;
};
/* These attributes are stored in the timestamp cache */
extern const char *sysdb_ts_cache_attrs[];
/* values are copied in the structure, allocated on "attrs" */
const char *base64_str);
const char *value);
const char *value);
struct sysdb_attrs *dst,
const char *name);
struct ldb_message_element **el);
const char **string);
struct ldb_message_element *el);
bool *value);
const char *newname);
const char *attr_name,
const char *domain,
const char *const *list);
struct sysdb_attrs *attrs,
const char *ldap_attr,
const char **_primary);
struct sysdb_attrs *attrs,
const char *primary,
bool lowercase,
const char ***_aliases);
struct sysdb_attrs **attr_list,
const char *ldap_attr,
char ***name_list);
struct sysdb_attrs **attr_list,
const char *ldap_attr,
char ***name_list);
struct sss_domain_info *domain,
const char *name_or_upn,
const char **_cname);
struct ldb_message **msgs,
struct sysdb_attrs ***attrs);
int sysdb_compare_usn(const char *a, const char *b);
struct sysdb_attrs **attrs,
char **_usn);
/* convert an ldb error into an errno error */
int sysdb_error_to_errno(int ldberr);
/* DNs related helper functions */
const char *name);
struct sss_domain_info *dom);
const char *name);
struct sss_domain_info *dom);
struct sss_domain_info *dom);
struct sss_domain_info *dom);
struct sss_domain_info *dom,
const char *object_name,
const char *subtree_name);
struct sss_domain_info *dom,
const char *subtree_name);
/* functions to start and finish transactions */
/* functions related to subdomains */
struct ldb_message_element *upn_suffixes);
const char *realm,
const char *flat,
const char *id,
const char *forest,
struct ldb_message_element *alt_dom_suf);
struct range_info ***range_list);
struct range_info **ranges);
char **view_name);
{
/* NULL is treated as default */
return true;
} else {
return false;
}
}
{
/* NULL is treated as default */
return true;
} else {
return false;
}
}
struct sysdb_attrs *override_attrs,
struct sss_domain_info *domain,
const char *name,
const char **attrs,
struct ldb_result **override_obj,
struct ldb_result **orig_obj);
struct sss_domain_info *domain,
const char *name,
const char **attrs,
struct ldb_result **override_obj,
struct ldb_result **orig_obj);
struct sss_domain_info *domain,
const char *name,
struct ldb_result **override_obj,
struct ldb_result **orig_obj);
struct sss_domain_info *domain,
const char *name,
struct ldb_result **override_obj,
struct ldb_result **orig_obj);
struct sss_domain_info *domain,
struct ldb_result **override_obj,
struct ldb_result **orig_obj);
struct sss_domain_info *domain,
struct ldb_result **override_obj,
struct ldb_result **orig_obj);
struct sss_domain_info *domain,
const char *cert,
const char **attrs,
struct ldb_result **override_obj,
struct ldb_result **orig_obj);
struct ldb_message *obj,
struct ldb_message *override_obj,
const char **req_attrs);
struct ldb_message *obj,
bool expect_override_dn);
struct sss_domain_info *domain,
const char *name,
struct ldb_result **res);
struct sss_domain_info *domain,
struct ldb_result **res);
struct sss_domain_info *domain,
const char *name,
struct ldb_result **res);
struct sss_domain_info *domain,
struct ldb_result **res);
struct ldb_message_element *
const struct ldb_message *msg,
const char *attr_name);
const struct ldb_message *msg,
const char *attr_name,
const char * default_value);
const struct ldb_message *msg,
const char *attr_name,
/* Sysdb initialization.
* call this function *only* once to initialize the database and get
* the sysdb ctx */
struct sss_domain_info *domains);
/* Same as sysdb_init, but additionally allows to change
* file ownership of the sysdb databases and allow the
* upgrade via passing a context. */
struct sysdb_upgrade_ctx {
};
struct sss_domain_info *domains,
struct sysdb_upgrade_ctx *upgrade_ctx,
bool chown_dbfile,
/* used to initialize only one domain database.
* Do NOT use if sysdb_init has already been called */
struct sss_domain_info *domain,
const char *db_path,
/* functions to retrieve information from sysdb
* These functions automatically starts an operation
* therefore they cannot be called within a transaction */
struct sss_domain_info *domain,
const char *name,
struct ldb_result **res);
struct sss_domain_info *domain,
struct ldb_result **res);
struct sss_domain_info *domain,
const char *upn,
struct ldb_result **res);
struct sss_domain_info *domain,
struct ldb_result **res);
struct sss_domain_info *domain,
const char *name_filter,
const char *addtl_filter,
struct ldb_result **res);
struct sss_domain_info *domain,
struct ldb_result **res);
struct sss_domain_info *domain,
const char *name_filter,
const char *addtl_filter,
struct ldb_result **res);
struct sss_domain_info *domain,
const char *name,
struct ldb_result **res);
struct sss_domain_info *domain,
struct ldb_result **res);
struct sss_domain_info *domain,
struct ldb_result **res);
struct sss_domain_info *domain,
const char *name_filter,
const char *addtl_filter,
struct ldb_result **res);
struct sss_domain_info *domain,
struct ldb_result **res);
struct sss_domain_info *domain,
const char *name_filter,
const char *addtl_filter,
struct ldb_result **res);
struct sysdb_netgroup_ctx {
union {
struct {
char *hostname;
char *username;
char *domainname;
} triple;
char *groupname;
} value;
};
struct sss_domain_info *domain,
const char *netgroup,
struct ldb_result **res);
struct sss_domain_info *domain,
const char *name,
struct ldb_result **res);
struct sss_domain_info *domain,
const char *upn,
struct ldb_result **res);
struct sss_domain_info *domain,
const char *name,
struct ldb_result **res);
struct sss_domain_info *domain,
const char *name,
const char **attributes,
struct ldb_result **res);
struct sss_domain_info *domain,
const char *name,
const char **attributes,
struct ldb_result **res);
struct sss_domain_info *domain,
const char *cert,
struct ldb_result **res);
struct sss_domain_info *domain,
const char *netgrname,
const char **attributes,
struct ldb_result **res);
/* functions that modify the databse
* they have to be called within a transaction
* See sysdb_transaction_send()/_recv() */
/* Permissive modify */
struct ldb_message *msg);
/* Delete Entry */
bool ignore_not_found);
bool ignore_not_found);
/* Mark entry as expired */
/* Search Entry */
const char *filter,
const char **attrs,
struct ldb_message ***_msgs);
exp_fmt, ...) do { \
int _sls_lret; \
\
exp_fmt, ##__VA_ARGS__); \
} \
} while(0)
/* Search User (by uid, sid or name) */
struct sss_domain_info *domain,
const char *name,
const char **attrs,
struct ldb_message **msg);
struct sss_domain_info *domain,
const char **attrs,
struct ldb_message **msg);
struct sss_domain_info *domain,
const char *sid_str,
const char **attrs,
struct ldb_message **msg);
struct sss_domain_info *domain,
const char *upn,
const char **attrs,
struct ldb_result **out_res);
struct sss_domain_info *domain,
const char *sid_str,
const char **attrs,
struct ldb_message **msg);
/* Search Group (by gid, sid or name) */
struct sss_domain_info *domain,
const char *name,
const char **attrs,
struct ldb_message **msg);
struct sss_domain_info *domain,
const char **attrs,
struct ldb_message **msg);
struct sss_domain_info *domain,
const char *sid_str,
const char **attrs,
struct ldb_message **msg);
/* Search Netgroup (by name) */
struct sss_domain_info *domain,
const char *name,
const char **attrs,
struct ldb_message **msg);
/* Replace entry attrs */
struct sysdb_attrs *attrs,
int mod_op);
/* Replace user attrs */
const char *name,
struct sysdb_attrs *attrs,
int mod_op);
/* Replace group attrs */
const char *name,
struct sysdb_attrs *attrs,
int mod_op);
/* Replace netgroup attrs */
const char *name,
struct sysdb_attrs *attrs,
int mod_op);
/* Allocate a new id */
/* Add user (only basic attrs and w/o checks) */
const char *name,
const char *gecos,
const char *homedir,
const char *shell);
/* Add user (all checks) */
const char *name,
const char *gecos,
const char *homedir,
const char *shell,
const char *orig_dn,
struct sysdb_attrs *attrs,
int cache_timeout,
/* Add group (only basic attrs and w/o checks) */
/* Add group (all checks) */
struct sysdb_attrs *attrs,
int cache_timeout,
const char *name,
const char *original_dn,
const char *sid_str,
const char *uuid,
bool posix,
/* Add netgroup (only basic attrs and w/o checks) */
const char *name, const char *description);
const char *name,
const char *description,
struct sysdb_attrs *attrs,
char **missing,
int cache_timeout,
/* mod_op must be either LDB_FLAG_MOD_ADD or LDB_FLAG_MOD_DELETE */
int mod_op);
const char *name,
const char *pwd,
const char *gecos,
const char *homedir,
const char *shell,
const char *orig_dn,
struct sysdb_attrs *attrs,
char **remove_attrs,
const char *name,
struct sysdb_attrs *attrs,
enum sysdb_member_type {
};
const char *group,
const char *member,
enum sysdb_member_type type,
bool is_dn);
const char *group,
const char *member,
enum sysdb_member_type type,
bool is_dn);
const char *member,
enum sysdb_member_type type,
const char *const *add_groups,
const char *const *del_groups);
const char *member,
enum sysdb_member_type type,
const char *const *add_groups,
const char *const *del_groups);
const char *view_name,
enum sysdb_member_type type,
/* Password caching function.
* If you are in a transaction ignore sysdb and pass in the handle.
* If you are not in a transaction pass NULL in handle and provide sysdb,
* in this case a transaction will be automatically started and the
* function will be completely wrapped in it's own sysdb transaction */
const char *username,
const char *password);
const char *username,
const char *password,
enum sss_authtok_type authtok_type,
struct ldb_message *ldb_msg,
const char *name,
const char *password,
struct confdb_ctx *cdb,
bool just_check,
const char *object_name,
const char *subtree_name,
struct sysdb_attrs *attrs);
struct sss_domain_info *domain,
const char *filter,
const char *subtree_name,
const char **attrs,
struct ldb_message ***msgs);
struct sss_domain_info *domain,
const char *object_name,
const char *subtree_name,
const char **attrs,
struct ldb_message ***_msgs);
const char *object_name,
const char *subtree_name);
struct sss_domain_info *domain,
const char *expression,
const char *asq_attribute,
const char **attrs,
struct ldb_message ***msgs);
struct sss_domain_info *domain,
const char *sub_filter,
const char **attrs,
struct ldb_message ***msgs);
struct sss_domain_info *domain,
const char *sub_filter,
const char **attrs,
struct ldb_message ***msgs);
struct sss_domain_info *domain,
const char *sub_filter,
const char **attrs,
struct ldb_message ***msgs);
const char *name);
struct sss_domain_info *domain,
const char *sid_str);
struct sysdb_attrs **attrs,
int attr_count,
const char *attr_name,
char ***_list);
struct ldb_result *res,
struct sysdb_netgroup_ctx ***entries);
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,
enum sysdb_member_type type,
char **remove_attrs);
/**
* @brief Return direct parents of an object in the cache
*
* @param[in] mem_ctx Memory context the result should be allocated
* on
* @param[in] dom domain the object is in
* @param[in] parent_dom domain which should be searched for direct
* parents if NULL all domains in the given cache
* are searched
* @param[in] mtype Type of the object, SYSDB_MEMBER_USER or
* SYSDB_MEMBER_GROUP
* @param[in] name Name of the object
* @param[out] _direct_parents List of names of the direct parent groups
*
*
* @return
* - EOK: success
* - EINVAL: wrong mtype
* - ENOMEM: Memory allocation failed
*/
struct sss_domain_info *dom,
struct sss_domain_info *parent_dom,
enum sysdb_member_type mtype,
const char *name,
char ***_direct_parents);
/* === Functions related to ID-mapping === */
#define SYSDB_IDMAP_ATTRS { \
SYSDB_NAME, \
NULL }
const char *dom_name,
const char *dom_sid,
struct sss_domain_info *domain,
struct ldb_result **_result);
struct sss_domain_info *domain,
const char *sid_str,
const char **attrs,
struct ldb_result **res);
struct sss_domain_info *domain,
const char *uuid_str,
const char **attrs,
struct ldb_result **res);
struct sss_domain_info *domain,
const char *cert,
const char **attrs,
struct ldb_result **res);
struct sss_domain_info *domain,
const char *cert,
struct ldb_result **res);
const char *cert);
/* === Functions related to GPOs === */
/* === Functions related to GPO entries === */
#define SYSDB_GPO_ATTRS { \
SYSDB_NAME, \
NULL }
const char *gpo_guid,
int gpo_version,
int cache_timeout,
struct sss_domain_info *domain,
const char *gpo_guid,
struct ldb_result **_result);
struct sss_domain_info *domain,
struct ldb_result **_result);
/* === Functions related to GPO Result object === */
struct sss_domain_info *domain);
const char *policy_setting_key,
const char *policy_setting_value);
struct sss_domain_info *domain,
const char *policy_setting_key,
const char **policy_setting_value);
struct sss_domain_info *dom,
const char *group_name,
const char ***_sids,
const char ***_dns,
struct sss_domain_info *dom,
struct ldb_result **members);
struct sysdb_attrs *src_attrs,
const char *src_name,
struct sysdb_attrs *dest_attrs,
const char *dest_name);
const char *domain_component_name,
const char *ldap_search_base,
struct sysdb_attrs **usr_attrs,
struct sysdb_attrs **exp_usr);
#endif /* __SYS_DB_H__ */