diff options
Diffstat (limited to 'src')
43 files changed, 372 insertions, 490 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h index 8d5de3ffc..31122e2eb 100644 --- a/src/db/sysdb.h +++ b/src/db/sysdb.h @@ -564,20 +564,17 @@ int sysdb_set_group_attr(struct sss_domain_info *domain, int mod_op); /* Replace netgroup attrs */ -int sysdb_set_netgroup_attr(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_set_netgroup_attr(struct sss_domain_info *domain, const char *name, struct sysdb_attrs *attrs, int mod_op); /* Allocate a new id */ -int sysdb_get_new_id(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_get_new_id(struct sss_domain_info *domain, uint32_t *id); /* Add user (only basic attrs and w/o checks) */ -int sysdb_add_basic_user(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_add_basic_user(struct sss_domain_info *domain, const char *name, uid_t uid, gid_t gid, const char *gecos, @@ -585,8 +582,7 @@ int sysdb_add_basic_user(struct sysdb_ctx *sysdb, const char *shell); /* Add user (all checks) */ -int sysdb_add_user(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_add_user(struct sss_domain_info *domain, const char *name, uid_t uid, gid_t gid, const char *gecos, @@ -598,20 +594,17 @@ int sysdb_add_user(struct sysdb_ctx *sysdb, time_t now); /* Add group (only basic attrs and w/o checks) */ -int sysdb_add_basic_group(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_add_basic_group(struct sss_domain_info *domain, const char *name, gid_t gid); /* Add group (all checks) */ -int sysdb_add_group(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_add_group(struct sss_domain_info *domain, const char *name, gid_t gid, struct sysdb_attrs *attrs, int cache_timeout, time_t now); -int sysdb_add_incomplete_group(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_add_incomplete_group(struct sss_domain_info *domain, const char *name, gid_t gid, const char *original_dn, @@ -620,12 +613,10 @@ int sysdb_add_incomplete_group(struct sysdb_ctx *sysdb, time_t now); /* Add netgroup (only basic attrs and w/o checks) */ -int sysdb_add_basic_netgroup(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_add_basic_netgroup(struct sss_domain_info *domain, const char *name, const char *description); -int sysdb_add_netgroup(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_add_netgroup(struct sss_domain_info *domain, const char *name, const char *description, struct sysdb_attrs *attrs, @@ -634,13 +625,12 @@ int sysdb_add_netgroup(struct sysdb_ctx *sysdb, time_t now); /* mod_op must be either LDB_FLAG_MOD_ADD or LDB_FLAG_MOD_DELETE */ -int sysdb_mod_group_member(struct sysdb_ctx *sysdb, +int sysdb_mod_group_member(struct sss_domain_info *domain, struct ldb_dn *member_dn, struct ldb_dn *group_dn, int mod_op); -int sysdb_store_user(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_store_user(struct sss_domain_info *domain, const char *name, const char *pwd, uid_t uid, gid_t gid, @@ -653,8 +643,7 @@ int sysdb_store_user(struct sysdb_ctx *sysdb, uint64_t cache_timeout, time_t now); -int sysdb_store_group(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_store_group(struct sss_domain_info *domain, const char *name, gid_t gid, struct sysdb_attrs *attrs, @@ -668,29 +657,25 @@ enum sysdb_member_type { SYSDB_MEMBER_SERVICE, }; -int sysdb_add_group_member(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_add_group_member(struct sss_domain_info *domain, const char *group, const char *member, enum sysdb_member_type type, bool is_dn); -int sysdb_remove_group_member(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_remove_group_member(struct sss_domain_info *domain, const char *group, const char *member, enum sysdb_member_type type, bool is_dn); -errno_t sysdb_update_members(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +errno_t sysdb_update_members(struct sss_domain_info *domain, const char *member, enum sysdb_member_type type, const char *const *add_groups, const char *const *del_groups); -errno_t sysdb_update_members_dn(struct sysdb_ctx *sysdb, - struct sss_domain_info *member_domain, +errno_t sysdb_update_members_dn(struct sss_domain_info *member_domain, const char *member, enum sysdb_member_type type, const char *const *add_groups, @@ -701,8 +686,7 @@ errno_t sysdb_update_members_dn(struct sysdb_ctx *sysdb, * 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 */ -int sysdb_cache_password(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_cache_password(struct sss_domain_info *domain, const char *username, const char *password); @@ -710,8 +694,7 @@ errno_t check_failed_login_attempts(struct confdb_ctx *cdb, struct ldb_message *ldb_msg, uint32_t *failed_login_attempts, time_t *delayed_until); -int sysdb_cache_auth(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_cache_auth(struct sss_domain_info *domain, const char *name, const char *password, struct confdb_ctx *cdb, @@ -719,14 +702,12 @@ int sysdb_cache_auth(struct sysdb_ctx *sysdb, time_t *_expire_date, time_t *_delayed_until); -int sysdb_store_custom(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_store_custom(struct sss_domain_info *domain, const char *object_name, const char *subtree_name, struct sysdb_attrs *attrs); int sysdb_search_custom(TALLOC_CTX *mem_ctx, - struct sysdb_ctx *sysdb, struct sss_domain_info *domain, const char *filter, const char *subtree_name, @@ -735,7 +716,6 @@ int sysdb_search_custom(TALLOC_CTX *mem_ctx, struct ldb_message ***msgs); int sysdb_search_custom_by_name(TALLOC_CTX *mem_ctx, - struct sysdb_ctx *sysdb, struct sss_domain_info *domain, const char *object_name, const char *subtree_name, @@ -743,13 +723,12 @@ int sysdb_search_custom_by_name(TALLOC_CTX *mem_ctx, size_t *_count, struct ldb_message ***_msgs); -int sysdb_delete_custom(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_delete_custom(struct sss_domain_info *domain, const char *object_name, const char *subtree_name); int sysdb_asq_search(TALLOC_CTX *mem_ctx, - struct sysdb_ctx *sysdb, + struct sss_domain_info *domain, struct ldb_dn *base_dn, const char *expression, const char *asq_attribute, @@ -758,39 +737,33 @@ int sysdb_asq_search(TALLOC_CTX *mem_ctx, struct ldb_message ***msgs); int sysdb_search_users(TALLOC_CTX *mem_ctx, - struct sysdb_ctx *sysdb, struct sss_domain_info *domain, const char *sub_filter, const char **attrs, size_t *msgs_count, struct ldb_message ***msgs); -int sysdb_delete_user(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_delete_user(struct sss_domain_info *domain, const char *name, uid_t uid); int sysdb_search_groups(TALLOC_CTX *mem_ctx, - struct sysdb_ctx *sysdb, struct sss_domain_info *domain, const char *sub_filter, const char **attrs, size_t *msgs_count, struct ldb_message ***msgs); -int sysdb_delete_group(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_delete_group(struct sss_domain_info *domain, const char *name, gid_t gid); int sysdb_search_netgroups(TALLOC_CTX *mem_ctx, - struct sysdb_ctx *sysdb, struct sss_domain_info *domain, const char *sub_filter, const char **attrs, size_t *msgs_count, struct ldb_message ***msgs); -int sysdb_delete_netgroup(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_delete_netgroup(struct sss_domain_info *domain, const char *name); int sysdb_delete_by_sid(struct sysdb_ctx *sysdb, @@ -829,8 +802,7 @@ errno_t sysdb_set_enumerated(struct sysdb_ctx *sysdb, struct sss_domain_info *domain, bool enumerated); -errno_t sysdb_remove_attrs(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +errno_t sysdb_remove_attrs(struct sss_domain_info *domain, const char *name, enum sysdb_member_type type, char **remove_attrs); @@ -870,7 +842,6 @@ errno_t sysdb_idmap_get_mappings(TALLOC_CTX *mem_ctx, struct ldb_result **_result); errno_t sysdb_search_object_by_sid(TALLOC_CTX *mem_ctx, - struct sysdb_ctx *sysdb, struct sss_domain_info *domain, const char *sid_str, const char **attrs, diff --git a/src/db/sysdb_autofs.c b/src/db/sysdb_autofs.c index d297002f6..2706fdc42 100644 --- a/src/db/sysdb_autofs.c +++ b/src/db/sysdb_autofs.c @@ -160,8 +160,7 @@ sysdb_save_autofsmap(struct sss_domain_info *domain, goto done; } - ret = sysdb_store_custom(domain->sysdb, domain, name, - AUTOFS_MAP_SUBDIR, attrs); + ret = sysdb_store_custom(domain, name, AUTOFS_MAP_SUBDIR, attrs); if (ret != EOK) { DEBUG(SSSDBG_OP_FAILURE, ("sysdb_store_custom failed [%d]: %s\n", ret, strerror(ret))); @@ -179,7 +178,7 @@ sysdb_delete_autofsmap(struct sss_domain_info *domain, const char *name) { DEBUG(SSSDBG_TRACE_FUNC, ("Deleting autofs map %s\n", name)); - return sysdb_delete_custom(domain->sysdb, domain, name, AUTOFS_MAP_SUBDIR); + return sysdb_delete_custom(domain, name, AUTOFS_MAP_SUBDIR); } errno_t @@ -219,7 +218,7 @@ sysdb_get_map_byname(TALLOC_CTX *mem_ctx, goto done; } - ret = sysdb_search_custom(tmp_ctx, domain->sysdb, domain, filter, + ret = sysdb_search_custom(tmp_ctx, domain, filter, AUTOFS_MAP_SUBDIR, attrs, &count, &msgs); if (ret != EOK && ret != ENOENT) { @@ -464,7 +463,7 @@ sysdb_invalidate_autofs_maps(struct sss_domain_info *domain) goto done; } - ret = sysdb_search_custom(tmp_ctx, domain->sysdb, domain, filter, + ret = sysdb_search_custom(tmp_ctx, domain, filter, AUTOFS_MAP_SUBDIR, attrs, &count, &msgs); if (ret != EOK && ret != ENOENT) { diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c index 8dc4edf15..afc29b973 100644 --- a/src/db/sysdb_ops.c +++ b/src/db/sysdb_ops.c @@ -715,8 +715,7 @@ done: /* =Replace-Attributes-On-Netgroup=========================================== */ -int sysdb_set_netgroup_attr(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_set_netgroup_attr(struct sss_domain_info *domain, const char *name, struct sysdb_attrs *attrs, int mod_op) @@ -730,13 +729,13 @@ int sysdb_set_netgroup_attr(struct sysdb_ctx *sysdb, return ENOMEM; } - dn = sysdb_netgroup_dn(sysdb, tmp_ctx, domain, name); + dn = sysdb_netgroup_dn(domain->sysdb, tmp_ctx, domain, name); if (!dn) { ret = ENOMEM; goto done; } - ret = sysdb_set_entry_attr(sysdb, dn, attrs, mod_op); + ret = sysdb_set_entry_attr(domain->sysdb, dn, attrs, mod_op); done: talloc_free(tmp_ctx); @@ -745,8 +744,7 @@ done: /* =Get-New-ID============================================================ */ -int sysdb_get_new_id(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_get_new_id(struct sss_domain_info *domain, uint32_t *_id) { TALLOC_CTX *tmp_ctx; @@ -767,20 +765,20 @@ int sysdb_get_new_id(struct sysdb_ctx *sysdb, return ENOMEM; } - base_dn = sysdb_domain_dn(sysdb, tmp_ctx, domain); + base_dn = sysdb_domain_dn(domain->sysdb, tmp_ctx, domain); if (!base_dn) { talloc_zfree(tmp_ctx); return ENOMEM; } - ret = ldb_transaction_start(sysdb->ldb); + ret = ldb_transaction_start(domain->sysdb->ldb); if (ret) { talloc_zfree(tmp_ctx); ret = sysdb_error_to_errno(ret); return ret; } - ret = sysdb_search_entry(tmp_ctx, sysdb, base_dn, LDB_SCOPE_BASE, + ret = sysdb_search_entry(tmp_ctx, domain->sysdb, base_dn, LDB_SCOPE_BASE, SYSDB_NEXTID_FILTER, attrs_1, &count, &msgs); switch (ret) { case EOK: @@ -836,7 +834,7 @@ int sysdb_get_new_id(struct sysdb_ctx *sysdb, goto done; } - ret = sysdb_search_entry(tmp_ctx, sysdb, base_dn, LDB_SCOPE_SUBTREE, + ret = sysdb_search_entry(tmp_ctx, domain->sysdb, base_dn, LDB_SCOPE_SUBTREE, filter, attrs_2, &count, &msgs); switch (ret) { /* if anything was found, find the maximum and increment past it */ @@ -888,17 +886,17 @@ int sysdb_get_new_id(struct sysdb_ctx *sysdb, goto done; } - ret = ldb_modify(sysdb->ldb, msg); + ret = ldb_modify(domain->sysdb->ldb, msg); ret = sysdb_error_to_errno(ret); *_id = new_id; done: if (ret == EOK) { - ret = ldb_transaction_commit(sysdb->ldb); + ret = ldb_transaction_commit(domain->sysdb->ldb); ret = sysdb_error_to_errno(ret); } else { - ldb_transaction_cancel(sysdb->ldb); + ldb_transaction_cancel(domain->sysdb->ldb); } if (ret) { DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret))); @@ -910,8 +908,7 @@ done: /* =Add-Basic-User-NO-CHECKS============================================== */ -int sysdb_add_basic_user(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_add_basic_user(struct sss_domain_info *domain, const char *name, uid_t uid, gid_t gid, const char *gecos, @@ -934,7 +931,7 @@ int sysdb_add_basic_user(struct sysdb_ctx *sysdb, } /* user dn */ - msg->dn = sysdb_user_dn(sysdb, msg, domain, name); + msg->dn = sysdb_user_dn(domain->sysdb, msg, domain, name); if (!msg->dn) { ERROR_OUT(ret, ENOMEM, done); } @@ -977,7 +974,7 @@ int sysdb_add_basic_user(struct sysdb_ctx *sysdb, (unsigned long)time(NULL)); if (ret) goto done; - ret = ldb_add(sysdb->ldb, msg); + ret = ldb_add(domain->sysdb->ldb, msg); ret = sysdb_error_to_errno(ret); done: @@ -989,7 +986,7 @@ done: } static errno_t -sysdb_remove_ghost_from_group(struct sysdb_ctx *sysdb, +sysdb_remove_ghost_from_group(struct sss_domain_info *dom, struct ldb_message *group, struct ldb_message_element *alias_el, const char *name, @@ -1059,7 +1056,7 @@ sysdb_remove_ghost_from_group(struct sysdb_ctx *sysdb, } - ret = sss_ldb_modify_permissive(sysdb->ldb, msg); + ret = sss_ldb_modify_permissive(dom->sysdb->ldb, msg); ret = sysdb_error_to_errno(ret); if (ret != EOK) { goto done; @@ -1074,8 +1071,7 @@ done: } static errno_t -sysdb_remove_ghostattr_from_groups(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +sysdb_remove_ghostattr_from_groups(struct sss_domain_info *domain, const char *orig_dn, struct sysdb_attrs *attrs, const char *name) @@ -1124,7 +1120,7 @@ sysdb_remove_ghostattr_from_groups(struct sysdb_ctx *sysdb, goto done; } - tmpdn = sysdb_user_dn(sysdb, tmp_ctx, domain, name); + tmpdn = sysdb_user_dn(domain->sysdb, tmp_ctx, domain, name); if (!tmpdn) { ERROR_OUT(ret, ENOMEM, done); } @@ -1134,7 +1130,7 @@ sysdb_remove_ghostattr_from_groups(struct sysdb_ctx *sysdb, ERROR_OUT(ret, EINVAL, done); } - tmpdn = ldb_dn_new_fmt(tmp_ctx, sysdb->ldb, + tmpdn = ldb_dn_new_fmt(tmp_ctx, domain->sysdb->ldb, SYSDB_TMPL_GROUP_BASE, domain->name); if (!tmpdn) { ret = ENOMEM; @@ -1146,14 +1142,15 @@ sysdb_remove_ghostattr_from_groups(struct sysdb_ctx *sysdb, * Note that this object can be referred to either by its name or any * of its aliases */ - ret = sysdb_search_entry(tmp_ctx, sysdb, tmpdn, LDB_SCOPE_SUBTREE, filter, - group_attrs, &group_count, &groups); + ret = sysdb_search_entry(tmp_ctx, domain->sysdb, tmpdn, LDB_SCOPE_SUBTREE, + filter, group_attrs, &group_count, &groups); if (ret != EOK && ret != ENOENT) { goto done; } for (i = 0; i < group_count; i++) { - sysdb_remove_ghost_from_group(sysdb, groups[i], alias_el, name, orig_dn, userdn); + sysdb_remove_ghost_from_group(domain, groups[i], alias_el, name, + orig_dn, userdn); } ret = EOK; @@ -1165,8 +1162,7 @@ done: /* =Add-User-Function===================================================== */ -int sysdb_add_user(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_add_user(struct sss_domain_info *domain, const char *name, uid_t uid, gid_t gid, const char *gecos, @@ -1212,7 +1208,7 @@ int sysdb_add_user(struct sysdb_ctx *sysdb, return ENOMEM; } - ret = ldb_transaction_start(sysdb->ldb); + ret = ldb_transaction_start(domain->sysdb->ldb); if (ret) { ret = sysdb_error_to_errno(ret); talloc_free(tmp_ctx); @@ -1242,12 +1238,11 @@ int sysdb_add_user(struct sysdb_ctx *sysdb, } /* try to add the user */ - ret = sysdb_add_basic_user(sysdb, domain, name, - uid, gid, gecos, homedir, shell); + ret = sysdb_add_basic_user(domain, name, uid, gid, gecos, homedir, shell); if (ret) goto done; if (uid == 0) { - ret = sysdb_get_new_id(sysdb, domain, &id); + ret = sysdb_get_new_id(domain, &id); if (ret) goto done; id_attrs = sysdb_new_attrs(tmp_ctx); @@ -1295,8 +1290,8 @@ int sysdb_add_user(struct sysdb_ctx *sysdb, * have stored ghost users into the cache, so we need to link them * with the newly-created user entry */ - ret = sysdb_remove_ghostattr_from_groups(sysdb, domain, - orig_dn, attrs, name); + ret = sysdb_remove_ghostattr_from_groups(domain, orig_dn, attrs, + name); if (ret) goto done; } @@ -1304,11 +1299,11 @@ int sysdb_add_user(struct sysdb_ctx *sysdb, done: if (ret == EOK) { - ret = ldb_transaction_commit(sysdb->ldb); + ret = ldb_transaction_commit(domain->sysdb->ldb); ret = sysdb_error_to_errno(ret); } else { DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret))); - ldb_transaction_cancel(sysdb->ldb); + ldb_transaction_cancel(domain->sysdb->ldb); } talloc_zfree(tmp_ctx); return ret; @@ -1316,8 +1311,7 @@ done: /* =Add-Basic-Group-NO-CHECKS============================================= */ -int sysdb_add_basic_group(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_add_basic_group(struct sss_domain_info *domain, const char *name, gid_t gid) { struct ldb_message *msg; @@ -1336,7 +1330,7 @@ int sysdb_add_basic_group(struct sysdb_ctx *sysdb, } /* group dn */ - msg->dn = sysdb_group_dn(sysdb, msg, domain, name); + msg->dn = sysdb_group_dn(domain->sysdb, msg, domain, name); if (!msg->dn) { ERROR_OUT(ret, ENOMEM, done); } @@ -1355,7 +1349,7 @@ int sysdb_add_basic_group(struct sysdb_ctx *sysdb, (unsigned long)time(NULL)); if (ret) goto done; - ret = ldb_add(sysdb->ldb, msg); + ret = ldb_add(domain->sysdb->ldb, msg); ret = sysdb_error_to_errno(ret); done: @@ -1369,8 +1363,7 @@ done: /* =Add-Group-Function==================================================== */ -int sysdb_add_group(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_add_group(struct sss_domain_info *domain, const char *name, gid_t gid, struct sysdb_attrs *attrs, int cache_timeout, @@ -1395,7 +1388,7 @@ int sysdb_add_group(struct sysdb_ctx *sysdb, return ENOMEM; } - ret = ldb_transaction_start(sysdb->ldb); + ret = ldb_transaction_start(domain->sysdb->ldb); if (ret) { ret = sysdb_error_to_errno(ret); talloc_free(tmp_ctx); @@ -1425,7 +1418,7 @@ int sysdb_add_group(struct sysdb_ctx *sysdb, } /* try to add the group */ - ret = sysdb_add_basic_group(sysdb, domain, name, gid); + ret = sysdb_add_basic_group(domain, name, gid); if (ret) goto done; if (!attrs) { @@ -1446,7 +1439,7 @@ int sysdb_add_group(struct sysdb_ctx *sysdb, } if (posix && gid == 0) { - ret = sysdb_get_new_id(sysdb, domain, &id); + ret = sysdb_get_new_id(domain, &id); if (ret) goto done; ret = sysdb_attrs_add_uint32(attrs, SYSDB_GIDNUM, id); @@ -1469,18 +1462,17 @@ int sysdb_add_group(struct sysdb_ctx *sysdb, done: if (ret == EOK) { - ret = ldb_transaction_commit(sysdb->ldb); + ret = ldb_transaction_commit(domain->sysdb->ldb); ret = sysdb_error_to_errno(ret); } else { DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret))); - ldb_transaction_cancel(sysdb->ldb); + ldb_transaction_cancel(domain->sysdb->ldb); } talloc_zfree(tmp_ctx); return ret; } -int sysdb_add_incomplete_group(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_add_incomplete_group(struct sss_domain_info *domain, const char *name, gid_t gid, const char *original_dn, @@ -1498,7 +1490,7 @@ int sysdb_add_incomplete_group(struct sysdb_ctx *sysdb, } /* try to add the group */ - ret = sysdb_add_basic_group(sysdb, domain, name, gid); + ret = sysdb_add_basic_group(domain, name, gid); if (ret) goto done; attrs = sysdb_new_attrs(tmp_ctx); @@ -1544,7 +1536,7 @@ done: /* =Add-Or-Remove-Group-Memeber=========================================== */ /* mod_op must be either SYSDB_MOD_ADD or SYSDB_MOD_DEL */ -int sysdb_mod_group_member(struct sysdb_ctx *sysdb, +int sysdb_mod_group_member(struct sss_domain_info *domain, struct ldb_dn *member_dn, struct ldb_dn *group_dn, int mod_op) @@ -1574,7 +1566,7 @@ int sysdb_mod_group_member(struct sysdb_ctx *sysdb, ERROR_OUT(ret, EINVAL, fail); } - ret = ldb_modify(sysdb->ldb, msg); + ret = ldb_modify(domain->sysdb->ldb, msg); ret = sysdb_error_to_errno(ret); fail: @@ -1587,8 +1579,7 @@ fail: /* =Add-Basic-Netgroup-NO-CHECKS============================================= */ -int sysdb_add_basic_netgroup(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_add_basic_netgroup(struct sss_domain_info *domain, const char *name, const char *description) { struct ldb_message *msg; @@ -1600,7 +1591,7 @@ int sysdb_add_basic_netgroup(struct sysdb_ctx *sysdb, } /* netgroup dn */ - msg->dn = sysdb_netgroup_dn(sysdb, msg, domain, name); + msg->dn = sysdb_netgroup_dn(domain->sysdb, msg, domain, name); if (!msg->dn) { ERROR_OUT(ret, ENOMEM, done); } @@ -1623,7 +1614,7 @@ int sysdb_add_basic_netgroup(struct sysdb_ctx *sysdb, (unsigned long) time(NULL)); if (ret) goto done; - ret = ldb_add(sysdb->ldb, msg); + ret = ldb_add(domain->sysdb->ldb, msg); ret = sysdb_error_to_errno(ret); done: @@ -1637,8 +1628,7 @@ done: /* =Add-Netgroup-Function==================================================== */ -int sysdb_add_netgroup(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_add_netgroup(struct sss_domain_info *domain, const char *name, const char *description, struct sysdb_attrs *attrs, @@ -1654,7 +1644,7 @@ int sysdb_add_netgroup(struct sysdb_ctx *sysdb, return ENOMEM; } - ret = ldb_transaction_start(sysdb->ldb); + ret = ldb_transaction_start(domain->sysdb->ldb); if (ret) { ret = sysdb_error_to_errno(ret); talloc_free(tmp_ctx); @@ -1662,7 +1652,7 @@ int sysdb_add_netgroup(struct sysdb_ctx *sysdb, } /* try to add the netgroup */ - ret = sysdb_add_basic_netgroup(sysdb, domain, name, description); + ret = sysdb_add_basic_netgroup(domain, name, description); if (ret && ret != EEXIST) goto done; if (!attrs) { @@ -1685,10 +1675,10 @@ int sysdb_add_netgroup(struct sysdb_ctx *sysdb, (now + cache_timeout) : 0)); if (ret) goto done; - ret = sysdb_set_netgroup_attr(sysdb, domain, name, attrs, SYSDB_MOD_REP); + ret = sysdb_set_netgroup_attr(domain, name, attrs, SYSDB_MOD_REP); if (missing) { - ret = sysdb_remove_attrs(sysdb, domain, name, + ret = sysdb_remove_attrs(domain, name, SYSDB_MEMBER_NETGROUP, missing); if (ret != EOK) { @@ -1698,13 +1688,13 @@ int sysdb_add_netgroup(struct sysdb_ctx *sysdb, done: if (ret == EOK) { - ret = ldb_transaction_commit(sysdb->ldb); + ret = ldb_transaction_commit(domain->sysdb->ldb); ret = sysdb_error_to_errno(ret); } if (ret != EOK) { DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret))); - ldb_transaction_cancel(sysdb->ldb); + ldb_transaction_cancel(domain->sysdb->ldb); } talloc_zfree(tmp_ctx); return ret; @@ -1715,8 +1705,7 @@ done: /* if one of the basic attributes is empty ("") as opposed to NULL, * this will just remove it */ -int sysdb_store_user(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_store_user(struct sss_domain_info *domain, const char *name, const char *pwd, uid_t uid, gid_t gid, @@ -1753,7 +1742,7 @@ int sysdb_store_user(struct sysdb_ctx *sysdb, if (ret) goto fail; } - ret = sysdb_transaction_start(sysdb); + ret = sysdb_transaction_start(domain->sysdb); if (ret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to start transaction\n")); goto fail; @@ -1773,13 +1762,13 @@ int sysdb_store_user(struct sysdb_ctx *sysdb, if (ret == ENOENT) { /* users doesn't exist, turn into adding a user */ - ret = sysdb_add_user(sysdb, domain, name, uid, gid, gecos, homedir, + ret = sysdb_add_user(domain, name, uid, gid, gecos, homedir, shell, orig_dn, attrs, cache_timeout, now); if (ret == EEXIST) { /* This may be a user rename. If there is a user with the * same UID, remove it and try to add the basic user again */ - ret = sysdb_delete_user(sysdb, domain, NULL, uid); + ret = sysdb_delete_user(domain, NULL, uid); if (ret == ENOENT) { /* Not found by UID, return the original EEXIST, * this may be a conflict in MPG domain or something @@ -1792,7 +1781,7 @@ int sysdb_store_user(struct sysdb_ctx *sysdb, DEBUG(SSSDBG_MINOR_FAILURE, ("A user with the same UID [%llu] was removed from the " "cache\n", (unsigned long long) uid)); - ret = sysdb_add_user(sysdb, domain, name, uid, gid, gecos, homedir, + ret = sysdb_add_user(domain, name, uid, gid, gecos, homedir, shell, orig_dn, attrs, cache_timeout, now); } @@ -1848,16 +1837,16 @@ int sysdb_store_user(struct sysdb_ctx *sysdb, if (ret != EOK) goto fail; if (remove_attrs) { - ret = sysdb_remove_attrs(sysdb, domain, name, - SYSDB_MEMBER_USER, - remove_attrs); + ret = sysdb_remove_attrs(domain, name, + SYSDB_MEMBER_USER, + remove_attrs); if (ret != EOK) { DEBUG(4, ("Could not remove missing attributes\n")); } } done: - ret = sysdb_transaction_commit(sysdb); + ret = sysdb_transaction_commit(domain->sysdb); if (ret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to commit transaction\n")); goto fail; @@ -1867,7 +1856,7 @@ done: fail: if (in_transaction) { - sret = sysdb_transaction_cancel(sysdb); + sret = sysdb_transaction_cancel(domain->sysdb); if (sret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, ("Could not cancel transaction\n")); } @@ -1884,8 +1873,7 @@ fail: /* this function does not check that all user members are actually present */ -int sysdb_store_group(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_store_group(struct sss_domain_info *domain, const char *name, gid_t gid, struct sysdb_attrs *attrs, @@ -1930,13 +1918,13 @@ int sysdb_store_group(struct sysdb_ctx *sysdb, if (new_group) { /* group doesn't exist, turn into adding a group */ - ret = sysdb_add_group(sysdb, domain, name, gid, - attrs, cache_timeout, now); + ret = sysdb_add_group(domain, name, gid, attrs, cache_timeout, + now); if (ret == EEXIST) { /* This may be a group rename. If there is a group with the * same GID, remove it and try to add the basic group again */ - ret = sysdb_delete_group(sysdb, domain, NULL, gid); + ret = sysdb_delete_group(domain, NULL, gid); if (ret == ENOENT) { /* Not found by GID, return the original EEXIST, * this may be a conflict in MPG domain or something @@ -1948,8 +1936,8 @@ int sysdb_store_group(struct sysdb_ctx *sysdb, DEBUG(SSSDBG_MINOR_FAILURE, ("A group with the same GID [%llu] was removed from the " "cache\n", (unsigned long long) gid)); - ret = sysdb_add_group(sysdb, domain, name, gid, - attrs, cache_timeout, now); + ret = sysdb_add_group(domain, name, gid, attrs, cache_timeout, + now); } goto done; } @@ -1981,8 +1969,7 @@ done: /* =Add-User-to-Group(Native/Legacy)====================================== */ static int -sysdb_group_membership_mod(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +sysdb_group_membership_mod(struct sss_domain_info *domain, const char *group, const char *member, enum sysdb_member_type type, @@ -1998,9 +1985,9 @@ sysdb_group_membership_mod(struct sysdb_ctx *sysdb, } if (type == SYSDB_MEMBER_USER) { - member_dn = sysdb_user_dn(sysdb, tmp_ctx, domain, member); + member_dn = sysdb_user_dn(domain->sysdb, tmp_ctx, domain, member); } else if (type == SYSDB_MEMBER_GROUP) { - member_dn = sysdb_group_dn(sysdb, tmp_ctx, domain, member); + member_dn = sysdb_group_dn(domain->sysdb, tmp_ctx, domain, member); } else { ret = EINVAL; goto done; @@ -2012,9 +1999,9 @@ sysdb_group_membership_mod(struct sysdb_ctx *sysdb, } if (!is_dn) { - group_dn = sysdb_group_dn(sysdb, tmp_ctx, domain, group); + group_dn = sysdb_group_dn(domain->sysdb, tmp_ctx, domain, group); } else { - group_dn = ldb_dn_new(tmp_ctx, sysdb->ldb, group); + group_dn = ldb_dn_new(tmp_ctx, domain->sysdb->ldb, group); } if (!group_dn) { @@ -2022,43 +2009,40 @@ sysdb_group_membership_mod(struct sysdb_ctx *sysdb, goto done; } - ret = sysdb_mod_group_member(sysdb, member_dn, group_dn, modify_op); + ret = sysdb_mod_group_member(domain, member_dn, group_dn, modify_op); done: talloc_free(tmp_ctx); return ret; } -int sysdb_add_group_member(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_add_group_member(struct sss_domain_info *domain, const char *group, const char *member, enum sysdb_member_type type, bool is_dn) { - return sysdb_group_membership_mod(sysdb, domain, group, member, - type, SYSDB_MOD_ADD, is_dn); + return sysdb_group_membership_mod(domain, group, member, type, + SYSDB_MOD_ADD, is_dn); } /* =Remove-member-from-Group(Native/Legacy)=============================== */ -int sysdb_remove_group_member(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_remove_group_member(struct sss_domain_info *domain, const char *group, const char *member, enum sysdb_member_type type, bool is_dn) { - return sysdb_group_membership_mod(sysdb, domain, group, member, - type, SYSDB_MOD_DEL, is_dn); + return sysdb_group_membership_mod(domain, group, member, type, + SYSDB_MOD_DEL, is_dn); } /* =Password-Caching====================================================== */ -int sysdb_cache_password(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_cache_password(struct sss_domain_info *domain, const char *username, const char *password) { @@ -2120,7 +2104,6 @@ fail: /* =Custom Search================== */ int sysdb_search_custom(TALLOC_CTX *mem_ctx, - struct sysdb_ctx *sysdb, struct sss_domain_info *domain, const char *filter, const char *subtree_name, @@ -2135,7 +2118,8 @@ int sysdb_search_custom(TALLOC_CTX *mem_ctx, return EINVAL; } - basedn = sysdb_custom_subtree_dn(sysdb, mem_ctx, domain, subtree_name); + basedn = sysdb_custom_subtree_dn(domain->sysdb, mem_ctx, domain, + subtree_name); if (basedn == NULL) { DEBUG(1, ("sysdb_custom_subtree_dn failed.\n")); return ENOMEM; @@ -2145,14 +2129,13 @@ int sysdb_search_custom(TALLOC_CTX *mem_ctx, return EINVAL; } - ret = sysdb_search_entry(mem_ctx, sysdb, basedn, + ret = sysdb_search_entry(mem_ctx, domain->sysdb, basedn, LDB_SCOPE_SUBTREE, filter, attrs, msgs_count, msgs); return ret; } int sysdb_search_custom_by_name(TALLOC_CTX *mem_ctx, - struct sysdb_ctx *sysdb, struct sss_domain_info *domain, const char *object_name, const char *subtree_name, @@ -2175,7 +2158,7 @@ int sysdb_search_custom_by_name(TALLOC_CTX *mem_ctx, return ENOMEM; } - basedn = sysdb_custom_dn(sysdb, tmp_ctx, + basedn = sysdb_custom_dn(domain->sysdb, tmp_ctx, domain, object_name, subtree_name); if (basedn == NULL) { DEBUG(1, ("sysdb_custom_dn failed.\n")); @@ -2188,7 +2171,7 @@ int sysdb_search_custom_by_name(TALLOC_CTX *mem_ctx, goto done; } - ret = sysdb_search_entry(tmp_ctx, sysdb, basedn, + ret = sysdb_search_entry(tmp_ctx, domain->sysdb, basedn, LDB_SCOPE_BASE, NULL, attrs, &count, &msgs); if (ret) { goto done; @@ -2211,8 +2194,7 @@ done: /* =Custom Store (replaces-existing-data)================== */ -int sysdb_store_custom(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_store_custom(struct sss_domain_info *domain, const char *object_name, const char *subtree_name, struct sysdb_attrs *attrs) @@ -2231,7 +2213,7 @@ int sysdb_store_custom(struct sysdb_ctx *sysdb, return EINVAL; } - ret = ldb_transaction_start(sysdb->ldb); + ret = ldb_transaction_start(domain->sysdb->ldb); if (ret) { return sysdb_error_to_errno(ret); } @@ -2242,7 +2224,7 @@ int sysdb_store_custom(struct sysdb_ctx *sysdb, goto done; } - ret = sysdb_search_custom_by_name(tmp_ctx, sysdb, domain, + ret = sysdb_search_custom_by_name(tmp_ctx, domain, object_name, subtree_name, search_attrs, &resp_count, &resp); if (ret != EOK && ret != ENOENT) { @@ -2259,7 +2241,7 @@ int sysdb_store_custom(struct sysdb_ctx *sysdb, goto done; } - msg->dn = sysdb_custom_dn(sysdb, tmp_ctx, + msg->dn = sysdb_custom_dn(domain->sysdb, tmp_ctx, domain, object_name, subtree_name); if (!msg->dn) { DEBUG(1, ("sysdb_custom_dn failed.\n")); @@ -2289,22 +2271,22 @@ int sysdb_store_custom(struct sysdb_ctx *sysdb, msg->num_elements = attrs->num; if (add_object) { - ret = ldb_add(sysdb->ldb, msg); + ret = ldb_add(domain->sysdb->ldb, msg); } else { - ret = ldb_modify(sysdb->ldb, msg); + ret = ldb_modify(domain->sysdb->ldb, msg); } if (ret != LDB_SUCCESS) { DEBUG(1, ("Failed to store custom entry: %s(%d)[%s]\n", - ldb_strerror(ret), ret, ldb_errstring(sysdb->ldb))); + ldb_strerror(ret), ret, ldb_errstring(domain->sysdb->ldb))); ret = sysdb_error_to_errno(ret); } done: if (ret) { DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret))); - ldb_transaction_cancel(sysdb->ldb); + ldb_transaction_cancel(domain->sysdb->ldb); } else { - ret = ldb_transaction_commit(sysdb->ldb); + ret = ldb_transaction_commit(domain->sysdb->ldb); ret = sysdb_error_to_errno(ret); } talloc_zfree(tmp_ctx); @@ -2313,8 +2295,7 @@ done: /* = Custom Delete======================================= */ -int sysdb_delete_custom(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_delete_custom(struct sss_domain_info *domain, const char *object_name, const char *subtree_name) { @@ -2331,7 +2312,7 @@ int sysdb_delete_custom(struct sysdb_ctx *sysdb, return ENOMEM; } - dn = sysdb_custom_dn(sysdb, tmp_ctx, + dn = sysdb_custom_dn(domain->sysdb, tmp_ctx, domain, object_name, subtree_name); if (dn == NULL) { DEBUG(1, ("sysdb_custom_dn failed.\n")); @@ -2339,7 +2320,7 @@ int sysdb_delete_custom(struct sysdb_ctx *sysdb, goto done; } - ret = ldb_delete(sysdb->ldb, dn); + ret = ldb_delete(domain->sysdb->ldb, dn); switch (ret) { case LDB_SUCCESS: @@ -2349,7 +2330,7 @@ int sysdb_delete_custom(struct sysdb_ctx *sysdb, default: DEBUG(1, ("LDB Error: %s(%d)\nError Message: [%s]\n", - ldb_strerror(ret), ret, ldb_errstring(sysdb->ldb))); + ldb_strerror(ret), ret, ldb_errstring(domain->sysdb->ldb))); ret = sysdb_error_to_errno(ret); break; } @@ -2362,7 +2343,7 @@ done: /* = ASQ search request ======================================== */ int sysdb_asq_search(TALLOC_CTX *mem_ctx, - struct sysdb_ctx *sysdb, + struct sss_domain_info *domain, struct ldb_dn *base_dn, const char *expression, const char *asq_attribute, @@ -2419,7 +2400,7 @@ int sysdb_asq_search(TALLOC_CTX *mem_ctx, goto fail; } - ret = ldb_build_search_req(&ldb_req, sysdb->ldb, tmp_ctx, + ret = ldb_build_search_req(&ldb_req, domain->sysdb->ldb, tmp_ctx, base_dn, LDB_SCOPE_BASE, expression, attrs, ctrl, res, ldb_search_default_callback, NULL); @@ -2428,7 +2409,7 @@ int sysdb_asq_search(TALLOC_CTX *mem_ctx, goto fail; } - ret = ldb_request(sysdb->ldb, ldb_req); + ret = ldb_request(domain->sysdb->ldb, ldb_req); if (ret == LDB_SUCCESS) { ret = ldb_wait(ldb_req->handle, LDB_WAIT_ALL); } @@ -2457,7 +2438,6 @@ fail: /* =Search-Users-with-Custom-Filter====================================== */ int sysdb_search_users(TALLOC_CTX *mem_ctx, - struct sysdb_ctx *sysdb, struct sss_domain_info *domain, const char *sub_filter, const char **attrs, @@ -2474,7 +2454,7 @@ int sysdb_search_users(TALLOC_CTX *mem_ctx, return ENOMEM; } - basedn = ldb_dn_new_fmt(tmp_ctx, sysdb->ldb, + basedn = ldb_dn_new_fmt(tmp_ctx, domain->sysdb->ldb, SYSDB_TMPL_USER_BASE, domain->name); if (!basedn) { DEBUG(2, ("Failed to build base dn\n")); @@ -2492,7 +2472,7 @@ int sysdb_search_users(TALLOC_CTX *mem_ctx, DEBUG(SSSDBG_TRACE_INTERNAL, ("Search users with filter: %s\n", filter)); - ret = sysdb_search_entry(mem_ctx, sysdb, basedn, + ret = sysdb_search_entry(mem_ctx, domain->sysdb, basedn, LDB_SCOPE_SUBTREE, filter, attrs, msgs_count, msgs); if (ret) { @@ -2515,8 +2495,7 @@ fail: /* =Delete-User-by-Name-OR-uid============================================ */ -int sysdb_delete_user(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_delete_user(struct sss_domain_info *domain, const char *name, uid_t uid) { TALLOC_CTX *tmp_ctx; @@ -2558,7 +2537,7 @@ int sysdb_delete_user(struct sysdb_ctx *sysdb, } } - ret = sysdb_delete_entry(sysdb, msg->dn, false); + ret = sysdb_delete_entry(domain->sysdb, msg->dn, false); if (ret) { goto fail; } @@ -2570,8 +2549,8 @@ int sysdb_delete_user(struct sysdb_ctx *sysdb, goto fail; } - ret = sysdb_search_groups(tmp_ctx, sysdb, domain, - filter, attrs, &msg_count, &msgs); + ret = sysdb_search_groups(tmp_ctx, domain, filter, attrs, + &msg_count, &msgs); if (ret != EOK) { goto fail; } @@ -2587,7 +2566,7 @@ int sysdb_delete_user(struct sysdb_ctx *sysdb, ret = add_string(msg, LDB_FLAG_MOD_DELETE, SYSDB_GHOST, name); if (ret) goto fail; - ret = ldb_modify(sysdb->ldb, msg); + ret = ldb_modify(domain->sysdb->ldb, msg); ret = sysdb_error_to_errno(ret); if (ret != EOK) { goto fail; @@ -2613,7 +2592,6 @@ fail: /* =Search-Groups-with-Custom-Filter===================================== */ int sysdb_search_groups(TALLOC_CTX *mem_ctx, - struct sysdb_ctx *sysdb, struct sss_domain_info *domain, const char *sub_filter, const char **attrs, @@ -2630,7 +2608,7 @@ int sysdb_search_groups(TALLOC_CTX *mem_ctx, return ENOMEM; } - basedn = ldb_dn_new_fmt(tmp_ctx, sysdb->ldb, + basedn = ldb_dn_new_fmt(tmp_ctx, domain->sysdb->ldb, SYSDB_TMPL_GROUP_BASE, domain->name); if (!basedn) { DEBUG(2, ("Failed to build base dn\n")); @@ -2648,7 +2626,7 @@ int sysdb_search_groups(TALLOC_CTX *mem_ctx, DEBUG(SSSDBG_TRACE_INTERNAL, ("Search groups with filter: %s\n", filter)); - ret = sysdb_search_entry(mem_ctx, sysdb, basedn, + ret = sysdb_search_entry(mem_ctx, domain->sysdb, basedn, LDB_SCOPE_SUBTREE, filter, attrs, msgs_count, msgs); if (ret) { @@ -2671,8 +2649,7 @@ fail: /* =Delete-Group-by-Name-OR-gid=========================================== */ -int sysdb_delete_group(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_delete_group(struct sss_domain_info *domain, const char *name, gid_t gid) { TALLOC_CTX *tmp_ctx; @@ -2712,7 +2689,7 @@ int sysdb_delete_group(struct sysdb_ctx *sysdb, } } - ret = sysdb_delete_entry(sysdb, msg->dn, false); + ret = sysdb_delete_entry(domain->sysdb, msg->dn, false); if (ret) { goto fail; } @@ -2729,7 +2706,6 @@ fail: /* =Search-Netgroups-with-Custom-Filter===================================== */ int sysdb_search_netgroups(TALLOC_CTX *mem_ctx, - struct sysdb_ctx *sysdb, struct sss_domain_info *domain, const char *sub_filter, const char **attrs, @@ -2746,7 +2722,7 @@ int sysdb_search_netgroups(TALLOC_CTX *mem_ctx, return ENOMEM; } - basedn = ldb_dn_new_fmt(tmp_ctx, sysdb->ldb, + basedn = ldb_dn_new_fmt(tmp_ctx, domain->sysdb->ldb, SYSDB_TMPL_NETGROUP_BASE, domain->name); if (!basedn) { DEBUG(2, ("Failed to build base dn\n")); @@ -2763,7 +2739,7 @@ int sysdb_search_netgroups(TALLOC_CTX *mem_ctx, DEBUG(6, ("Search netgroups with filter: %s\n", filter)); - ret = sysdb_search_entry(mem_ctx, sysdb, basedn, + ret = sysdb_search_entry(mem_ctx, domain->sysdb, basedn, LDB_SCOPE_SUBTREE, filter, attrs, msgs_count, msgs); if (ret) { @@ -2785,8 +2761,7 @@ fail: /* =Delete-Netgroup-by-Name============================================== */ -int sysdb_delete_netgroup(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_delete_netgroup(struct sss_domain_info *domain, const char *name) { TALLOC_CTX *tmp_ctx; @@ -2811,7 +2786,7 @@ int sysdb_delete_netgroup(struct sysdb_ctx *sysdb, goto done; } - ret = sysdb_delete_entry(sysdb, msg->dn, false); + ret = sysdb_delete_entry(domain->sysdb, msg->dn, false); if (ret != EOK) { goto done; } @@ -2839,8 +2814,7 @@ int sysdb_delete_by_sid(struct sysdb_ctx *sysdb, return ENOMEM; } - ret = sysdb_search_object_by_sid(tmp_ctx, sysdb, domain, - sid_str, NULL, &res); + ret = sysdb_search_object_by_sid(tmp_ctx, domain, sid_str, NULL, &res); if (ret != EOK) { DEBUG(SSSDBG_OP_FAILURE, ("search by sid failed: %d (%s)\n", ret, strerror(ret))); @@ -2949,8 +2923,7 @@ done: return ret; } -int sysdb_cache_auth(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +int sysdb_cache_auth(struct sss_domain_info *domain, const char *name, const char *password, struct confdb_ctx *cdb, @@ -2986,7 +2959,7 @@ int sysdb_cache_auth(struct sysdb_ctx *sysdb, return EINVAL; } - if (sysdb == NULL) { + if (domain->sysdb == NULL) { DEBUG(1, ("Missing sysdb db context.\n")); return EINVAL; } @@ -3001,7 +2974,7 @@ int sysdb_cache_auth(struct sysdb_ctx *sysdb, return ENOMEM; } - ret = ldb_transaction_start(sysdb->ldb); + ret = ldb_transaction_start(domain->sysdb->ldb); if (ret) { talloc_zfree(tmp_ctx); ret = sysdb_error_to_errno(ret); @@ -3136,9 +3109,9 @@ done: *_delayed_until = delayed_until; } if (ret) { - ldb_transaction_cancel(sysdb->ldb); + ldb_transaction_cancel(domain->sysdb->ldb); } else { - ret = ldb_transaction_commit(sysdb->ldb); + ret = ldb_transaction_commit(domain->sysdb->ldb); ret = sysdb_error_to_errno(ret); if (ret) { DEBUG(2, ("Failed to commit transaction!\n")); @@ -3155,8 +3128,7 @@ done: return ret; } -static errno_t sysdb_update_members_ex(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +static errno_t sysdb_update_members_ex(struct sss_domain_info *domain, const char *member, enum sysdb_member_type type, const char *const *add_groups, @@ -3173,7 +3145,7 @@ static errno_t sysdb_update_members_ex(struct sysdb_ctx *sysdb, return ENOMEM; } - ret = sysdb_transaction_start(sysdb); + ret = sysdb_transaction_start(domain->sysdb); if (ret != EOK) { DEBUG(0, ("Failed to start update transaction\n")); goto done; @@ -3184,7 +3156,7 @@ static errno_t sysdb_update_members_ex(struct sysdb_ctx *sysdb, if (add_groups) { /* Add the user to all add_groups */ for (i = 0; add_groups[i]; i++) { - ret = sysdb_add_group_member(sysdb, domain, add_groups[i], + ret = sysdb_add_group_member(domain, add_groups[i], member, type, is_dn); if (ret != EOK) { DEBUG(1, ("Could not add member [%s] to group [%s]. " @@ -3197,7 +3169,7 @@ static errno_t sysdb_update_members_ex(struct sysdb_ctx *sysdb, if (del_groups) { /* Remove the user from all del_groups */ for (i = 0; del_groups[i]; i++) { - ret = sysdb_remove_group_member(sysdb, domain, del_groups[i], + ret = sysdb_remove_group_member(domain, del_groups[i], member, type, is_dn); if (ret != EOK) { DEBUG(1, ("Could not remove member [%s] from group [%s]. " @@ -3207,7 +3179,7 @@ static errno_t sysdb_update_members_ex(struct sysdb_ctx *sysdb, } } - ret = sysdb_transaction_commit(sysdb); + ret = sysdb_transaction_commit(domain->sysdb); if (ret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to commit transaction\n")); goto done; @@ -3217,7 +3189,7 @@ static errno_t sysdb_update_members_ex(struct sysdb_ctx *sysdb, done: if (in_transaction) { - sret = sysdb_transaction_cancel(sysdb); + sret = sysdb_transaction_cancel(domain->sysdb); if (sret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, ("Could not cancel transaction\n")); } @@ -3226,30 +3198,27 @@ done: return ret; } -errno_t sysdb_update_members(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +errno_t sysdb_update_members(struct sss_domain_info *domain, const char *member, enum sysdb_member_type type, const char *const *add_groups, const char *const *del_groups) { - return sysdb_update_members_ex(sysdb, domain, member, type, + return sysdb_update_members_ex(domain, member, type, add_groups, del_groups, false); } -errno_t sysdb_update_members_dn(struct sysdb_ctx *sysdb, - struct sss_domain_info *member_domain, +errno_t sysdb_update_members_dn(struct sss_domain_info *member_domain, const char *member, enum sysdb_member_type type, const char *const *add_groups, const char *const *del_groups) { - return sysdb_update_members_ex(sysdb, member_domain, member, type, + return sysdb_update_members_ex(member_domain, member, type, add_groups, del_groups, true); } -errno_t sysdb_remove_attrs(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, +errno_t sysdb_remove_attrs(struct sss_domain_info *domain, const char *name, enum sysdb_member_type type, char **remove_attrs) @@ -3266,19 +3235,19 @@ errno_t sysdb_remove_attrs(struct sysdb_ctx *sysdb, switch(type) { case SYSDB_MEMBER_USER: - msg->dn = sysdb_user_dn(sysdb, msg, domain, name); + msg->dn = sysdb_user_dn(domain->sysdb, msg, domain, name); break; case SYSDB_MEMBER_GROUP: - msg->dn = sysdb_group_dn(sysdb, msg, domain, name); + msg->dn = sysdb_group_dn(domain->sysdb, msg, domain, name); break; case SYSDB_MEMBER_NETGROUP: - msg->dn = sysdb_netgroup_dn(sysdb, msg, domain, name); + msg->dn = sysdb_netgroup_dn(domain->sysdb, msg, domain, name); break; case SYSDB_MEMBER_SERVICE: - msg->dn = sysdb_svc_dn(sysdb, msg, domain->name, name); + msg->dn = sysdb_svc_dn(domain->sysdb, msg, domain->name, name); break; } if (!msg->dn) { @@ -3286,7 +3255,7 @@ errno_t sysdb_remove_attrs(struct sysdb_ctx *sysdb, goto done; } - ret = sysdb_transaction_start(sysdb); + ret = sysdb_transaction_start(domain->sysdb); if (ret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to start transaction\n")); goto done; @@ -3313,7 +3282,7 @@ errno_t sysdb_remove_attrs(struct sysdb_ctx *sysdb, * attribute in the sysdb will cause other removals to * fail. */ - lret = ldb_modify(sysdb->ldb, msg); + lret = ldb_modify(domain->sysdb->ldb, msg); if (lret != LDB_SUCCESS && lret != LDB_ERR_NO_SUCH_ATTRIBUTE) { ret = sysdb_error_to_errno(lret); goto done; @@ -3323,7 +3292,7 @@ errno_t sysdb_remove_attrs(struct sysdb_ctx *sysdb, ldb_msg_remove_attr(msg, remove_attrs[i]); } - ret = sysdb_transaction_commit(sysdb); + ret = sysdb_transaction_commit(domain->sysdb); if (ret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to commit transaction\n")); goto done; @@ -3334,7 +3303,7 @@ errno_t sysdb_remove_attrs(struct sysdb_ctx *sysdb, ret = EOK; done: if (in_transaction) { - sret = sysdb_transaction_cancel(sysdb); + sret = sysdb_transaction_cancel(domain->sysdb); if (sret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, ("Could not cancel transaction\n")); } @@ -3344,7 +3313,6 @@ done: } errno_t sysdb_search_object_by_sid(TALLOC_CTX *mem_ctx, - struct sysdb_ctx *sysdb, struct sss_domain_info *domain, const char *sid_str, const char **attrs, @@ -3362,14 +3330,14 @@ errno_t sysdb_search_object_by_sid(TALLOC_CTX *mem_ctx, return ENOMEM; } - basedn = ldb_dn_new_fmt(tmp_ctx, sysdb->ldb, SYSDB_DOM_BASE, domain->name); + basedn = ldb_dn_new_fmt(tmp_ctx, domain->sysdb->ldb, SYSDB_DOM_BASE, domain->name); if (basedn == NULL) { DEBUG(SSSDBG_OP_FAILURE, ("ldb_dn_new_fmt failed.\n")); ret = ENOMEM; goto done; } - ret = ldb_search(sysdb->ldb, tmp_ctx, &res, + ret = ldb_search(domain->sysdb->ldb, tmp_ctx, &res, basedn, LDB_SCOPE_SUBTREE, attrs?attrs:def_attrs, SYSDB_SID_FILTER, sid_str); if (ret != EOK) { diff --git a/src/db/sysdb_services.c b/src/db/sysdb_services.c index b202456ab..089389ff9 100644 --- a/src/db/sysdb_services.c +++ b/src/db/sysdb_services.c @@ -379,7 +379,7 @@ sysdb_store_service(struct sss_domain_info *domain, if (ret != EOK) goto done; if (remove_attrs) { - ret = sysdb_remove_attrs(sysdb, domain, primary_name, + ret = sysdb_remove_attrs(domain, primary_name, SYSDB_MEMBER_SERVICE, remove_attrs); if (ret != EOK) { diff --git a/src/db/sysdb_ssh.c b/src/db/sysdb_ssh.c index af66644b9..daa4067c7 100644 --- a/src/db/sysdb_ssh.c +++ b/src/db/sysdb_ssh.c @@ -30,7 +30,7 @@ sysdb_update_ssh_host(struct sss_domain_info *domain, { errno_t ret; - ret = sysdb_store_custom(domain->sysdb, domain, name, SSH_HOSTS_SUBDIR, + ret = sysdb_store_custom(domain, name, SSH_HOSTS_SUBDIR, attrs); if (ret != EOK) { DEBUG(SSSDBG_OP_FAILURE, @@ -226,7 +226,7 @@ sysdb_delete_ssh_host(struct sss_domain_info *domain, const char *name) { DEBUG(SSSDBG_TRACE_FUNC, ("Deleting host %s\n", name)); - return sysdb_delete_custom(domain->sysdb, domain, name, SSH_HOSTS_SUBDIR); + return sysdb_delete_custom(domain, name, SSH_HOSTS_SUBDIR); } static errno_t @@ -247,7 +247,7 @@ sysdb_search_ssh_hosts(TALLOC_CTX *mem_ctx, return ENOMEM; } - ret = sysdb_search_custom(tmp_ctx, domain->sysdb, domain, filter, + ret = sysdb_search_custom(tmp_ctx, domain, filter, SSH_HOSTS_SUBDIR, attrs, &num_results, &results); if (ret != EOK && ret != ENOENT) { diff --git a/src/db/sysdb_sudo.c b/src/db/sysdb_sudo.c index b56fdd6cb..fdeeec877 100644 --- a/src/db/sysdb_sudo.c +++ b/src/db/sysdb_sudo.c @@ -438,7 +438,7 @@ sysdb_save_sudorule(struct sss_domain_info *domain, return ret; } - ret = sysdb_store_custom(domain->sysdb, domain, rule_name, + ret = sysdb_store_custom(domain, rule_name, SUDORULE_SUBDIR, attrs); if (ret != EOK) { DEBUG(SSSDBG_OP_FAILURE, ("sysdb_store_custom failed [%d]: %s\n", @@ -625,7 +625,7 @@ errno_t sysdb_sudo_purge_byname(struct sss_domain_info *domain, const char *name) { DEBUG(SSSDBG_TRACE_INTERNAL, ("Deleting sudo rule %s\n", name)); - return sysdb_delete_custom(domain->sysdb, domain, name, SUDORULE_SUBDIR); + return sysdb_delete_custom(domain, name, SUDORULE_SUBDIR); } errno_t sysdb_sudo_purge_byfilter(struct sss_domain_info *domain, @@ -653,7 +653,7 @@ errno_t sysdb_sudo_purge_byfilter(struct sss_domain_info *domain, NULL_CHECK(tmp_ctx, ret, done); /* match entries based on the filter and remove them one by one */ - ret = sysdb_search_custom(tmp_ctx, domain->sysdb, domain, filter, + ret = sysdb_search_custom(tmp_ctx, domain, filter, SUDORULE_SUBDIR, attrs, &count, &msgs); if (ret == ENOENT) { diff --git a/src/providers/ipa/ipa_access.c b/src/providers/ipa/ipa_access.c index f067b7021..d1574e642 100644 --- a/src/providers/ipa/ipa_access.c +++ b/src/providers/ipa/ipa_access.c @@ -704,7 +704,7 @@ errno_t hbac_get_cached_rules(TALLOC_CTX *mem_ctx, goto done; } - ret = sysdb_search_custom(tmp_ctx, domain->sysdb, domain, filter, + ret = sysdb_search_custom(tmp_ctx, domain, filter, HBAC_RULES_SUBDIR, attrs, &rule_count, &msgs); if (ret != EOK && ret != ENOENT) { diff --git a/src/providers/ipa/ipa_hbac_common.c b/src/providers/ipa/ipa_hbac_common.c index e539b29d2..a37db7554 100644 --- a/src/providers/ipa/ipa_hbac_common.c +++ b/src/providers/ipa/ipa_hbac_common.c @@ -78,8 +78,7 @@ ipa_hbac_save_list(struct sss_domain_info *domain, } DEBUG(9, ("Object name: [%s].\n", object_name)); - ret = sysdb_store_custom(domain->sysdb, domain, - object_name, subdir, list[c]); + ret = sysdb_store_custom(domain, object_name, subdir, list[c]); if (ret != EOK) { DEBUG(1, ("sysdb_store_custom failed.\n")); goto done; diff --git a/src/providers/ipa/ipa_hbac_hosts.c b/src/providers/ipa/ipa_hbac_hosts.c index e85206e8f..dbc02b865 100644 --- a/src/providers/ipa/ipa_hbac_hosts.c +++ b/src/providers/ipa/ipa_hbac_hosts.c @@ -114,7 +114,7 @@ static errno_t hbac_host_attrs_to_rule(TALLOC_CTX *mem_ctx, } /* First check if this is a specific host */ - ret = sysdb_search_custom(tmp_ctx, domain->sysdb, domain, filter, + ret = sysdb_search_custom(tmp_ctx, domain, filter, HBAC_HOSTS_SUBDIR, attrs, &count, &msgs); if (ret != EOK && ret != ENOENT) goto done; @@ -150,7 +150,7 @@ static errno_t hbac_host_attrs_to_rule(TALLOC_CTX *mem_ctx, num_hosts++; } else { /* ret == ENOENT */ /* Check if this is a hostgroup */ - ret = sysdb_search_custom(tmp_ctx, domain->sysdb, domain, filter, + ret = sysdb_search_custom(tmp_ctx, domain, filter, HBAC_HOSTGROUPS_SUBDIR, attrs, &count, &msgs); if (ret != EOK && ret != ENOENT) goto done; diff --git a/src/providers/ipa/ipa_hbac_services.c b/src/providers/ipa/ipa_hbac_services.c index ace01fae2..b1cc524da 100644 --- a/src/providers/ipa/ipa_hbac_services.c +++ b/src/providers/ipa/ipa_hbac_services.c @@ -465,7 +465,7 @@ hbac_service_attrs_to_rule(TALLOC_CTX *mem_ctx, } /* First check if this is a specific service */ - ret = sysdb_search_custom(tmp_ctx, domain->sysdb, domain, filter, + ret = sysdb_search_custom(tmp_ctx, domain, filter, HBAC_SERVICES_SUBDIR, attrs, &count, &msgs); if (ret != EOK && ret != ENOENT) goto done; @@ -500,7 +500,7 @@ hbac_service_attrs_to_rule(TALLOC_CTX *mem_ctx, num_services++; } else { /* ret == ENOENT */ /* Check if this is a service group */ - ret = sysdb_search_custom(tmp_ctx, domain->sysdb, domain, filter, + ret = sysdb_search_custom(tmp_ctx, domain, filter, HBAC_SERVICEGROUPS_SUBDIR, attrs, &count, &msgs); if (ret != EOK && ret != ENOENT) goto done; diff --git a/src/providers/ipa/ipa_hbac_users.c b/src/providers/ipa/ipa_hbac_users.c index a5fcaad4e..cd56e1913 100644 --- a/src/providers/ipa/ipa_hbac_users.c +++ b/src/providers/ipa/ipa_hbac_users.c @@ -225,7 +225,7 @@ hbac_user_attrs_to_rule(TALLOC_CTX *mem_ctx, } /* First check if this is a user */ - ret = sysdb_search_users(tmp_ctx, domain->sysdb, domain, + ret = sysdb_search_users(tmp_ctx, domain, filter, attrs, &count, &msgs); if (ret != EOK && ret != ENOENT) goto done; if (ret == EOK && count == 0) { @@ -258,8 +258,8 @@ hbac_user_attrs_to_rule(TALLOC_CTX *mem_ctx, num_users++; } else { /* Check if it is a group instead */ - ret = sysdb_search_groups(tmp_ctx, domain->sysdb, domain, - filter, attrs, &count, &msgs); + ret = sysdb_search_groups(tmp_ctx, domain, filter, attrs, + &count, &msgs); if (ret != EOK && ret != ENOENT) goto done; if (ret == EOK && count == 0) { ret = ENOENT; diff --git a/src/providers/ipa/ipa_id.c b/src/providers/ipa/ipa_id.c index 6e0964400..56b8c9f05 100644 --- a/src/providers/ipa/ipa_id.c +++ b/src/providers/ipa/ipa_id.c @@ -309,7 +309,7 @@ static void ipa_id_get_netgroup_done(struct tevent_req *subreq) } if (ret == ENOENT) { - ret = sysdb_delete_netgroup(state->sysdb, state->domain, state->name); + ret = sysdb_delete_netgroup(state->domain, state->name); if (ret != EOK && ret != ENOENT) { tevent_req_error(req, ret); return; diff --git a/src/providers/ipa/ipa_netgroups.c b/src/providers/ipa/ipa_netgroups.c index 0deb3944e..245930b10 100644 --- a/src/providers/ipa/ipa_netgroups.c +++ b/src/providers/ipa/ipa_netgroups.c @@ -171,7 +171,7 @@ static errno_t ipa_save_netgroup(TALLOC_CTX *mem_ctx, DEBUG(6, ("Storing info for netgroup %s\n", name)); - ret = sysdb_add_netgroup(ctx, dom, name, NULL, netgroup_attrs, NULL, + ret = sysdb_add_netgroup(dom, name, NULL, netgroup_attrs, NULL, dom->netgroup_timeout, 0); if (ret) goto fail; diff --git a/src/providers/ipa/ipa_s2n_exop.c b/src/providers/ipa/ipa_s2n_exop.c index e7dbeb459..7379b99e5 100644 --- a/src/providers/ipa/ipa_s2n_exop.c +++ b/src/providers/ipa/ipa_s2n_exop.c @@ -830,7 +830,7 @@ static void ipa_s2n_get_user_done(struct tevent_req *subreq) gid = attrs->a.user.pw_gid; } - ret = sysdb_store_user(state->dom->sysdb, state->dom, name, NULL, + ret = sysdb_store_user(state->dom, name, NULL, attrs->a.user.pw_uid, gid, NULL, /* gecos */ homedir, NULL, NULL, user_attrs, NULL, @@ -886,9 +886,8 @@ static void ipa_s2n_get_user_done(struct tevent_req *subreq) } } - ret = sysdb_store_group(state->dom->sysdb, state->dom, name, - attrs->a.group.gr_gid, group_attrs, - timeout, now); + ret = sysdb_store_group(state->dom, name, attrs->a.group.gr_gid, + group_attrs, timeout, now); break; default: DEBUG(SSSDBG_OP_FAILURE, ("Unexpected response type [%d].\n", diff --git a/src/providers/ipa/ipa_subdomains_ext_groups.c b/src/providers/ipa/ipa_subdomains_ext_groups.c index 24f691bdf..7a65c1181 100644 --- a/src/providers/ipa/ipa_subdomains_ext_groups.c +++ b/src/providers/ipa/ipa_subdomains_ext_groups.c @@ -340,8 +340,8 @@ static errno_t add_ad_user_to_cached_groups(struct ldb_dn *user_dn, goto done; } - ret = sysdb_search_groups(tmp_ctx, group_dom->sysdb, group_dom, - subfilter, NULL, &msgs_count, &msgs); + ret = sysdb_search_groups(tmp_ctx, group_dom, subfilter, NULL, + &msgs_count, &msgs); if (ret != EOK) { if (ret == ENOENT) { DEBUG(SSSDBG_TRACE_ALL, ("Group [%s] not in the cache.\n", @@ -357,7 +357,7 @@ static errno_t add_ad_user_to_cached_groups(struct ldb_dn *user_dn, /* TODO? Do we have to remove members as well? I think not because the AD * query before removes all memberships. */ - ret = sysdb_mod_group_member(group_dom->sysdb, user_dn, msgs[0]->dn, + ret = sysdb_mod_group_member(group_dom, user_dn, msgs[0]->dn, LDB_FLAG_MOD_ADD); if (ret != EOK && ret != EEXIST) { DEBUG(SSSDBG_OP_FAILURE, ("sysdb_mod_group_member failed.\n")); diff --git a/src/providers/krb5/krb5_auth.c b/src/providers/krb5/krb5_auth.c index a1774ba05..fc7c79c6c 100644 --- a/src/providers/krb5/krb5_auth.c +++ b/src/providers/krb5/krb5_auth.c @@ -270,7 +270,7 @@ static void krb5_auth_cache_creds(struct krb5_ctx *krb5_ctx, return; } - ret = sysdb_cache_auth(sysdb, domain, pd->user, + ret = sysdb_cache_auth(domain, pd->user, password, cdb, true, NULL, NULL); if (ret != EOK) { DEBUG(1, ("Offline authentication failed\n")); @@ -373,7 +373,7 @@ static void krb5_auth_store_creds(struct sysdb_ctx *sysdb, return; } - ret = sysdb_cache_password(sysdb, domain, pd->user, password); + ret = sysdb_cache_password(domain, pd->user, password); if (ret) { DEBUG(2, ("Failed to cache password, offline auth may not work." " (%d)[%s]!?\n", ret, strerror(ret))); diff --git a/src/providers/ldap/ldap_auth.c b/src/providers/ldap/ldap_auth.c index b88f7db33..7cf17376f 100644 --- a/src/providers/ldap/ldap_auth.c +++ b/src/providers/ldap/ldap_auth.c @@ -1121,8 +1121,8 @@ static void sdap_pam_auth_done(struct tevent_req *req) ret = sss_authtok_get_password(state->pd->authtok, &password, NULL); if (ret == EOK) { - ret = sysdb_cache_password(be_ctx->domain->sysdb, be_ctx->domain, - state->pd->user, password); + ret = sysdb_cache_password(be_ctx->domain, state->pd->user, + password); } /* password caching failures are not fatal errors */ diff --git a/src/providers/ldap/ldap_id.c b/src/providers/ldap/ldap_id.c index 793bc99eb..b92f07dd0 100644 --- a/src/providers/ldap/ldap_id.c +++ b/src/providers/ldap/ldap_id.c @@ -345,8 +345,7 @@ static void users_get_done(struct tevent_req *subreq) tevent_req_error(req, ret); return; case BE_FILTER_NAME: - ret = sysdb_delete_user(state->sysdb, - state->domain, state->name, 0); + ret = sysdb_delete_user(state->domain, state->name, 0); if (ret != EOK && ret != ENOENT) { tevent_req_error(req, ret); return; @@ -360,7 +359,7 @@ static void users_get_done(struct tevent_req *subreq) return; } - ret = sysdb_delete_user(state->sysdb, state->domain, NULL, uid); + ret = sysdb_delete_user(state->domain, NULL, uid); if (ret != EOK && ret != ENOENT) { tevent_req_error(req, ret); return; @@ -680,8 +679,7 @@ static void groups_get_done(struct tevent_req *subreq) tevent_req_error(req, ret); return; case BE_FILTER_NAME: - ret = sysdb_delete_group(state->sysdb, - state->domain, state->name, 0); + ret = sysdb_delete_group(state->domain, state->name, 0); if (ret != EOK && ret != ENOENT) { tevent_req_error(req, ret); return; @@ -695,8 +693,7 @@ static void groups_get_done(struct tevent_req *subreq) return; } - ret = sysdb_delete_group(state->sysdb, - state->domain, NULL, gid); + ret = sysdb_delete_group(state->domain, NULL, gid); if (ret != EOK && ret != ENOENT) { tevent_req_error(req, ret); return; @@ -891,8 +888,7 @@ static void groups_by_user_done(struct tevent_req *subreq) } if (ret == ENOENT && state->noexist_delete == true) { - ret = sysdb_delete_user(state->ctx->be->domain->sysdb, - state->ctx->be->domain, state->name, 0); + ret = sysdb_delete_user(state->ctx->be->domain, state->name, 0); if (ret != EOK && ret != ENOENT) { tevent_req_error(req, ret); return; diff --git a/src/providers/ldap/ldap_id_cleanup.c b/src/providers/ldap/ldap_id_cleanup.c index 36ef6f420..513ad9545 100644 --- a/src/providers/ldap/ldap_id_cleanup.c +++ b/src/providers/ldap/ldap_id_cleanup.c @@ -172,7 +172,6 @@ static int cleanup_users(struct sdap_options *opts, struct sss_domain_info *dom) { TALLOC_CTX *tmpctx; - struct sysdb_ctx *sysdb = dom->sysdb; const char *attrs[] = { SYSDB_NAME, SYSDB_UIDNUM, NULL }; time_t now = time(NULL); char *subfilter = NULL; @@ -216,8 +215,7 @@ static int cleanup_users(struct sdap_options *opts, goto done; } - ret = sysdb_search_users(tmpctx, sysdb, dom, - subfilter, attrs, &count, &msgs); + ret = sysdb_search_users(tmpctx, dom, subfilter, attrs, &count, &msgs); if (ret) { if (ret == ENOENT) { ret = EOK; @@ -263,7 +261,7 @@ static int cleanup_users(struct sdap_options *opts, /* If not logged in or cannot check the table, delete him */ DEBUG(9, ("About to delete user %s\n", name)); - ret = sysdb_delete_user(sysdb, dom, name, 0); + ret = sysdb_delete_user(dom, name, 0); if (ret) { goto done; } @@ -338,8 +336,7 @@ static int cleanup_groups(TALLOC_CTX *memctx, goto done; } - ret = sysdb_search_groups(tmpctx, sysdb, domain, - subfilter, attrs, &count, &msgs); + ret = sysdb_search_groups(tmpctx, domain, subfilter, attrs, &count, &msgs); if (ret) { if (ret == ENOENT) { ret = EOK; @@ -403,7 +400,7 @@ static int cleanup_groups(TALLOC_CTX *memctx, } DEBUG(8, ("About to delete group %s\n", name)); - ret = sysdb_delete_group(sysdb, domain, name, 0); + ret = sysdb_delete_group(domain, name, 0); if (ret) { DEBUG(2, ("Group delete returned %d (%s)\n", ret, strerror(ret))); diff --git a/src/providers/ldap/ldap_id_netgroup.c b/src/providers/ldap/ldap_id_netgroup.c index e48a7da6c..3f40d89e6 100644 --- a/src/providers/ldap/ldap_id_netgroup.c +++ b/src/providers/ldap/ldap_id_netgroup.c @@ -215,7 +215,7 @@ static void ldap_netgroup_get_done(struct tevent_req *subreq) } if (ret == ENOENT && state->noexist_delete == true) { - ret = sysdb_delete_netgroup(state->sysdb, state->domain, state->name); + ret = sysdb_delete_netgroup(state->domain, state->name); if (ret != EOK && ret != ENOENT) { tevent_req_error(req, ret); return; diff --git a/src/providers/ldap/sdap_async_groups.c b/src/providers/ldap/sdap_async_groups.c index 1f008e20f..a943663ec 100644 --- a/src/providers/ldap/sdap_async_groups.c +++ b/src/providers/ldap/sdap_async_groups.c @@ -114,7 +114,7 @@ sdap_get_members_with_primary_gid(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb, return ENOMEM; } - ret = sysdb_search_users(mem_ctx, sysdb, domain, filter, + ret = sysdb_search_users(mem_ctx, domain, filter, search_attrs, &count, &msgs); talloc_free(filter); if (ret == ENOENT) { @@ -301,8 +301,8 @@ sdap_store_group_with_gid(struct sysdb_ctx *ctx, } } - ret = sysdb_store_group(ctx, domain, name, gid, - group_attrs, cache_timeout, now); + ret = sysdb_store_group(domain, name, gid, group_attrs, + cache_timeout, now); if (ret) { DEBUG(2, ("Could not store group %s\n", name)); return ret; @@ -743,7 +743,7 @@ static int sdap_save_grpmem(TALLOC_CTX *memctx, } } - ret = sysdb_store_group(ctx, dom, group_name, 0, group_attrs, + ret = sysdb_store_group(dom, group_name, 0, group_attrs, dom->group_timeout, now); if (ret) goto fail; @@ -1252,7 +1252,7 @@ sdap_process_missing_member_2307(struct sdap_process_group_state *state, goto done; } - ret = sysdb_search_users(tmp_ctx, state->sysdb, state->dom, filter, + ret = sysdb_search_users(tmp_ctx, state->dom, filter, attrs, &count, &msgs); if (ret == EOK && count > 0) { /* Entry exists but the group references it with an alias. */ @@ -2111,7 +2111,7 @@ static errno_t sdap_nested_group_populate_users(TALLOC_CTX *mem_ctx, ret = ENOMEM; goto done; } - ret = sysdb_search_users(tmp_ctx, user_dom->sysdb, user_dom, filter, + ret = sysdb_search_users(tmp_ctx, domain, filter, search_attrs, &count, &msgs); talloc_zfree(filter); talloc_zfree(clean_orig_dn); diff --git a/src/providers/ldap/sdap_async_initgroups.c b/src/providers/ldap/sdap_async_initgroups.c index a3c879f2f..e869ea016 100644 --- a/src/providers/ldap/sdap_async_initgroups.c +++ b/src/providers/ldap/sdap_async_initgroups.c @@ -195,7 +195,7 @@ static errno_t sdap_add_incomplete_groups(struct sysdb_ctx *sysdb, DEBUG(SSSDBG_TRACE_INTERNAL, ("Adding fake group %s to sysdb\n", groupname)); - ret = sysdb_add_incomplete_group(sysdb, domain, groupname, gid, + ret = sysdb_add_incomplete_group(domain, groupname, gid, original_dn, sid_str, posix, now); if (ret != EOK) { @@ -297,7 +297,7 @@ int sdap_initgr_common_store(struct sysdb_ctx *sysdb, } DEBUG(8, ("Updating memberships for %s\n", name)); - ret = sysdb_update_members(sysdb, domain, name, type, + ret = sysdb_update_members(domain, name, type, (const char *const *) add_groups, (const char *const *) del_groups); if (ret != EOK) { @@ -1118,7 +1118,7 @@ sdap_initgr_store_group_memberships(struct sdap_initgr_nested_state *state) in_transaction = true; DLIST_FOR_EACH(miter, memberships) { - ret = sysdb_update_members(state->sysdb, state->dom, miter->name, + ret = sysdb_update_members(state->dom, miter->name, SYSDB_MEMBER_GROUP, (const char *const *) miter->add, (const char *const *) miter->del); @@ -1245,8 +1245,7 @@ sdap_initgr_store_user_memberships(struct sdap_initgr_nested_state *state) in_transaction = true; DEBUG(8, ("Updating memberships for %s\n", state->username)); - ret = sysdb_update_members(state->sysdb, state->dom, - state->username, SYSDB_MEMBER_USER, + ret = sysdb_update_members(state->dom, state->username, SYSDB_MEMBER_USER, (const char *const *) add_groups, (const char *const *) del_groups); if (ret != EOK) { @@ -1923,7 +1922,7 @@ save_rfc2307bis_group_memberships(struct sdap_initgr_rfc2307bis_state *state) } else { add[num_added] = NULL; } - ret = sysdb_update_members(state->sysdb, state->dom, iter->name, + ret = sysdb_update_members(state->dom, iter->name, SYSDB_MEMBER_GROUP, (const char *const *) add, (const char *const *) iter->del); @@ -2083,8 +2082,7 @@ errno_t save_rfc2307bis_user_memberships( } DEBUG(8, ("Updating memberships for %s\n", state->name)); - ret = sysdb_update_members(state->sysdb, state->dom, - state->name, SYSDB_MEMBER_USER, + ret = sysdb_update_members(state->dom, state->name, SYSDB_MEMBER_USER, (const char *const *)add_groups, (const char *const *)del_groups); if (ret != EOK) { diff --git a/src/providers/ldap/sdap_async_initgroups_ad.c b/src/providers/ldap/sdap_async_initgroups_ad.c index d23cbd7cd..7824f0b98 100644 --- a/src/providers/ldap/sdap_async_initgroups_ad.c +++ b/src/providers/ldap/sdap_async_initgroups_ad.c @@ -504,8 +504,7 @@ sdap_get_ad_tokengroups_initgroups_lookup_done(struct tevent_req *subreq) */ group_name = sid_str; - ret = sysdb_add_incomplete_group(group_domain->sysdb, - group_domain, + ret = sysdb_add_incomplete_group(group_domain, group_name, gid, NULL, sid_str, false, now); if (ret != EOK) { @@ -573,7 +572,7 @@ sdap_get_ad_tokengroups_initgroups_lookup_done(struct tevent_req *subreq) DEBUG(SSSDBG_TRACE_LIBS, ("Updating memberships for [%s]\n", state->username)); - ret = sysdb_update_members_dn(state->sysdb, state->domain, + ret = sysdb_update_members_dn(state->domain, state->username, SYSDB_MEMBER_USER, (const char *const *) add_groups, (const char *const *) del_groups); diff --git a/src/providers/ldap/sdap_async_nested_groups.c b/src/providers/ldap/sdap_async_nested_groups.c index 3338d173e..2ff1ecb7b 100644 --- a/src/providers/ldap/sdap_async_nested_groups.c +++ b/src/providers/ldap/sdap_async_nested_groups.c @@ -286,10 +286,10 @@ static errno_t sdap_nested_group_sysdb_search(struct sss_domain_info *domain, errno_t ret; if (user) { - ret = sysdb_search_users(NULL, domain->sysdb, domain, filter, attrs, + ret = sysdb_search_users(NULL, domain, filter, attrs, &count, &msgs); } else { - ret = sysdb_search_groups(NULL, domain->sysdb, domain, filter, attrs, + ret = sysdb_search_groups(NULL, domain, filter, attrs, &count, &msgs); } if (ret != EOK) { diff --git a/src/providers/ldap/sdap_async_netgroups.c b/src/providers/ldap/sdap_async_netgroups.c index b47b3e590..19bcc3f48 100644 --- a/src/providers/ldap/sdap_async_netgroups.c +++ b/src/providers/ldap/sdap_async_netgroups.c @@ -138,7 +138,7 @@ static errno_t sdap_save_netgroup(TALLOC_CTX *memctx, goto fail; } - ret = sysdb_add_netgroup(ctx, dom, name, NULL, netgroup_attrs, missing, + ret = sysdb_add_netgroup(dom, name, NULL, netgroup_attrs, missing, dom->netgroup_timeout, now); if (ret) goto fail; diff --git a/src/providers/ldap/sdap_async_users.c b/src/providers/ldap/sdap_async_users.c index 9cfe21748..488df5120 100644 --- a/src/providers/ldap/sdap_async_users.c +++ b/src/providers/ldap/sdap_async_users.c @@ -464,7 +464,7 @@ int sdap_save_user(TALLOC_CTX *memctx, DEBUG(SSSDBG_TRACE_FUNC, ("Storing info for user %s\n", user_name)); - ret = sysdb_store_user(ctx, dom, user_name, pwd, uid, gid, + ret = sysdb_store_user(dom, user_name, pwd, uid, gid, gecos, homedir, shell, orig_dn, user_attrs, missing, cache_timeout, now); if (ret) goto done; diff --git a/src/providers/ldap/sdap_reinit.c b/src/providers/ldap/sdap_reinit.c index 66d73102e..51da8128d 100644 --- a/src/providers/ldap/sdap_reinit.c +++ b/src/providers/ldap/sdap_reinit.c @@ -144,7 +144,7 @@ static errno_t sdap_reinit_clear_usn(struct sysdb_ctx *sysdb, in_transaction = true; /* reset users' usn */ - ret = sysdb_search_users(tmp_ctx, sysdb, domain, + ret = sysdb_search_users(tmp_ctx, domain, "", attrs, &msgs_num, &msgs); if (ret != EOK) { goto done; @@ -154,8 +154,7 @@ static errno_t sdap_reinit_clear_usn(struct sysdb_ctx *sysdb, msgs_num = 0; /* reset groups' usn */ - ret = sysdb_search_groups(tmp_ctx, sysdb, domain, - "", attrs, &msgs_num, &msgs); + ret = sysdb_search_groups(tmp_ctx, domain, "", attrs, &msgs_num, &msgs); if (ret != EOK) { goto done; } @@ -276,7 +275,7 @@ static errno_t sdap_reinit_delete_records(struct sss_domain_info *domain) in_transaction = true; /* purge untouched users */ - ret = sysdb_search_users(tmp_ctx, sysdb, domain, "(!("SYSDB_USN"=*))", + ret = sysdb_search_users(tmp_ctx, domain, "(!("SYSDB_USN"=*))", attrs, &msgs_num, &msgs); if (ret != EOK) { goto done; @@ -286,7 +285,7 @@ static errno_t sdap_reinit_delete_records(struct sss_domain_info *domain) msgs_num = 0; /* purge untouched groups */ - ret = sysdb_search_groups(tmp_ctx, sysdb, domain, "(!("SYSDB_USN"=*))", + ret = sysdb_search_groups(tmp_ctx, domain, "(!("SYSDB_USN"=*))", attrs, &msgs_num, &msgs); if (ret != EOK) { goto done; diff --git a/src/providers/proxy/proxy_auth.c b/src/providers/proxy/proxy_auth.c index 61fec63aa..fa766dc4e 100644 --- a/src/providers/proxy/proxy_auth.c +++ b/src/providers/proxy/proxy_auth.c @@ -757,8 +757,7 @@ static void proxy_child_done(struct tevent_req *req) goto done; } - ret = sysdb_cache_password(be_ctx->domain->sysdb, be_ctx->domain, - pd->user, password); + ret = sysdb_cache_password(be_ctx->domain, pd->user, password); /* password caching failures are not fatal errors */ /* so we just log it any return */ diff --git a/src/providers/proxy/proxy_id.c b/src/providers/proxy/proxy_id.c index 998b161db..503e325a4 100644 --- a/src/providers/proxy/proxy_id.c +++ b/src/providers/proxy/proxy_id.c @@ -209,7 +209,7 @@ delete_user(struct sysdb_ctx *sysdb, DEBUG(SSSDBG_TRACE_FUNC, ("User %s does not exist (or is invalid) on remote server," " deleting!\n", name)); - ret = sysdb_delete_user(sysdb, domain, name, uid); + ret = sysdb_delete_user(domain, name, uid); if (ret == ENOENT) { ret = EOK; } @@ -279,7 +279,7 @@ static int save_user(struct sysdb_ctx *sysdb, struct sss_domain_info *domain, } } - ret = sysdb_store_user(sysdb, domain, + ret = sysdb_store_user(domain, real_name, pwd->pw_passwd, pwd->pw_uid, @@ -626,7 +626,7 @@ static int save_group(struct sysdb_ctx *sysdb, struct sss_domain_info *dom, } } - ret = sysdb_store_group(sysdb, dom, + ret = sysdb_store_group(dom, real_name, grp->gr_gid, attrs, @@ -883,7 +883,7 @@ static int get_gr_name(TALLOC_CTX *mem_ctx, ("Group %s does not exist (or is invalid) on remote server," " deleting!\n", name)); - ret = sysdb_delete_group(sysdb, dom, NULL, gid); + ret = sysdb_delete_group(dom, NULL, gid); if (ret == ENOENT) { ret = EOK; } @@ -961,7 +961,7 @@ static int get_gr_gid(TALLOC_CTX *mem_ctx, ("Group %"SPRIgid" does not exist (or is invalid) on remote " "server, deleting!\n", gid)); - ret = sysdb_delete_group(sysdb, dom, NULL, gid); + ret = sysdb_delete_group(dom, NULL, gid); if (ret == ENOENT) { ret = EOK; } diff --git a/src/providers/proxy/proxy_netgroup.c b/src/providers/proxy/proxy_netgroup.c index 04a0b18d7..a201b2607 100644 --- a/src/providers/proxy/proxy_netgroup.c +++ b/src/providers/proxy/proxy_netgroup.c @@ -91,8 +91,8 @@ static errno_t save_netgroup(struct sysdb_ctx *sysdb, } } - ret = sysdb_add_netgroup(sysdb, domain, name, NULL, - attrs, NULL, cache_timeout, 0); + ret = sysdb_add_netgroup(domain, name, NULL, attrs, NULL, + cache_timeout, 0); if (ret != EOK) { DEBUG(SSSDBG_OP_FAILURE, ("sysdb_add_netgroup failed.\n")); return ret; @@ -101,7 +101,7 @@ static errno_t save_netgroup(struct sysdb_ctx *sysdb, return EOK; } -static errno_t handle_error(enum nss_status status, struct sysdb_ctx *sysdb, +static errno_t handle_error(enum nss_status status, struct sss_domain_info *domain, const char *name) { errno_t ret; @@ -114,7 +114,7 @@ static errno_t handle_error(enum nss_status status, struct sysdb_ctx *sysdb, case NSS_STATUS_NOTFOUND: DEBUG(SSSDBG_MINOR_FAILURE, ("The netgroup was not found\n")); - ret = sysdb_delete_netgroup(sysdb, domain, name); + ret = sysdb_delete_netgroup(domain, name); if (ret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, ("Cannot delete netgroup: %d\n", ret)); ret = EIO; @@ -153,7 +153,7 @@ errno_t get_netgroup(struct proxy_id_ctx *ctx, if (status != NSS_STATUS_SUCCESS) { DEBUG(SSSDBG_OP_FAILURE, ("setnetgrent failed for netgroup [%s].\n", name)); - ret = handle_error(status, sysdb, dom, name); + ret = handle_error(status, dom, name); goto done; } @@ -176,7 +176,7 @@ errno_t get_netgroup(struct proxy_id_ctx *ctx, if (status != NSS_STATUS_SUCCESS && status != NSS_STATUS_RETURN && status != NSS_STATUS_NOTFOUND) { - ret = handle_error(status, sysdb, dom, name); + ret = handle_error(status, dom, name); DEBUG(SSSDBG_OP_FAILURE, ("getnetgrent_r failed for netgroup [%s]: [%d][%s].\n", name, ret, strerror(ret))); @@ -195,7 +195,7 @@ errno_t get_netgroup(struct proxy_id_ctx *ctx, status = ctx->ops.endnetgrent(&result); if (status != NSS_STATUS_SUCCESS) { DEBUG(SSSDBG_OP_FAILURE, ("endnetgrent failed.\n")); - ret = handle_error(status, sysdb, dom, name); + ret = handle_error(status, dom, name); goto done; } @@ -203,7 +203,7 @@ errno_t get_netgroup(struct proxy_id_ctx *ctx, !dom->case_sensitive, dom->netgroup_timeout); if (ret != EOK) { - DEBUG(SSSDBG_OP_FAILURE, ("sysdb_add_netgroup failed.\n")); + DEBUG(SSSDBG_OP_FAILURE, ("save_netgroup failed.\n")); goto done; } diff --git a/src/providers/simple/simple_access_check.c b/src/providers/simple/simple_access_check.c index 1decbcb98..912350de2 100644 --- a/src/providers/simple/simple_access_check.c +++ b/src/providers/simple/simple_access_check.c @@ -437,7 +437,7 @@ simple_check_get_groups_send(TALLOC_CTX *mem_ctx, goto done; } - ret = sysdb_asq_search(state, state->domain->sysdb, + ret = sysdb_asq_search(state, state->domain, user->dn, NULL, SYSDB_MEMBEROF, attrs, &group_count, &groups); if (ret != EOK) { diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c index 00a67aa9f..d9fc7155b 100644 --- a/src/responder/nss/nsssrv_cmd.c +++ b/src/responder/nss/nsssrv_cmd.c @@ -4008,7 +4008,7 @@ static errno_t nss_cmd_getbysid_search(struct nss_dom_ctx *dctx) return EIO; } - ret = sysdb_search_object_by_sid(cmdctx, sysdb, dom, cmdctx->secid, NULL, + ret = sysdb_search_object_by_sid(cmdctx, dom, cmdctx->secid, NULL, &dctx->res); if (ret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to make request to our cache!\n")); diff --git a/src/responder/pac/pacsrv_cmd.c b/src/responder/pac/pacsrv_cmd.c index fbfaaafca..40ce46bbd 100644 --- a/src/responder/pac/pacsrv_cmd.c +++ b/src/responder/pac/pacsrv_cmd.c @@ -287,8 +287,8 @@ static void pac_lookup_sids_done(struct tevent_req *req) } msg = NULL; - ret = sysdb_search_object_by_sid(pr_ctx, dom->sysdb, dom, - entries[c].key.str, NULL, &msg); + ret = sysdb_search_object_by_sid(pr_ctx, dom, entries[c].key.str, + NULL, &msg); if (ret != EOK) { DEBUG(SSSDBG_OP_FAILURE, ("sysdb_search_object_by_sid " \ "failed.\n")); @@ -589,7 +589,7 @@ static errno_t save_pac_user(struct pac_req_ctx *pr_ctx) goto done; } - ret = sysdb_store_user(sysdb, pr_ctx->dom, pwd->pw_name, NULL, + ret = sysdb_store_user(pr_ctx->dom, pwd->pw_name, NULL, pwd->pw_uid, pwd->pw_gid, pwd->pw_gecos, pwd->pw_dir, pwd->pw_shell, NULL, user_attrs, NULL, @@ -714,7 +714,7 @@ pac_save_memberships_delete(struct pac_save_memberships_state *state) for (c = 0; c < pr_ctx->del_grp_count; c++) { /* If there is a failure for one group we still try to remove the * remaining groups. */ - ret = sysdb_mod_group_member(pr_ctx->dom->sysdb, state->user_dn, + ret = sysdb_mod_group_member(pr_ctx->dom, state->user_dn, pr_ctx->del_grp_list[c].dn, LDB_FLAG_MOD_DELETE); if (ret != EOK) { @@ -901,8 +901,8 @@ pac_store_membership(struct pac_req_ctx *pr_ctx, return ENOMEM; } - ret = sysdb_search_object_by_sid(tmp_ctx, grp_dom->sysdb, grp_dom, - grp_sid_str, group_attrs, &group); + ret = sysdb_search_object_by_sid(tmp_ctx, grp_dom, grp_sid_str, + group_attrs, &group); if (ret != EOK) { DEBUG(SSSDBG_TRACE_INTERNAL, ("sysdb_search_object_by_sid " \ "for SID [%s] failed [%d][%s].\n", @@ -927,7 +927,7 @@ pac_store_membership(struct pac_req_ctx *pr_ctx, DEBUG(SSSDBG_TRACE_ALL, ("Adding user [%s] to group [%s][%s].\n", ldb_dn_get_linearized(user_dn), grp_sid_str, ldb_dn_get_linearized(group->msgs[0]->dn))); - ret = sysdb_mod_group_member(grp_dom->sysdb, user_dn, group->msgs[0]->dn, + ret = sysdb_mod_group_member(grp_dom, user_dn, group->msgs[0]->dn, LDB_FLAG_MOD_ADD); if (ret != EOK) { DEBUG(SSSDBG_OP_FAILURE, ("sysdb_mod_group_member failed user [%s] " \ diff --git a/src/responder/pac/pacsrv_utils.c b/src/responder/pac/pacsrv_utils.c index 30055a134..3e5204720 100644 --- a/src/responder/pac/pacsrv_utils.c +++ b/src/responder/pac/pacsrv_utils.c @@ -149,8 +149,7 @@ errno_t get_sids_from_pac(TALLOC_CTX *mem_ctx, key.str = sid_str; value.ul = 0; - ret = sysdb_search_object_by_sid(mem_ctx, user_dom->sysdb, user_dom, - sid_str, NULL, &msg); + ret = sysdb_search_object_by_sid(mem_ctx, user_dom, sid_str, NULL, &msg); if (ret == EOK && msg->count == 1) { value.ul = ldb_msg_find_attr_as_uint64(msg->msgs[0], SYSDB_UIDNUM, 0); talloc_free(msg); @@ -184,8 +183,7 @@ errno_t get_sids_from_pac(TALLOC_CTX *mem_ctx, key.str = sid_str; value.ul = 0; - ret = sysdb_search_object_by_sid(mem_ctx, user_dom->sysdb, user_dom, - sid_str, NULL, &msg); + ret = sysdb_search_object_by_sid(mem_ctx, user_dom, sid_str, NULL, &msg); if (ret == EOK && msg->count == 1) { value.ul = ldb_msg_find_attr_as_uint64(msg->msgs[0], SYSDB_GIDNUM, 0); talloc_free(msg); @@ -213,8 +211,8 @@ errno_t get_sids_from_pac(TALLOC_CTX *mem_ctx, key.str = sid_str; value.ul = 0; - ret = sysdb_search_object_by_sid(mem_ctx, user_dom->sysdb, user_dom, - sid_str, NULL, &msg); + ret = sysdb_search_object_by_sid(mem_ctx, user_dom, sid_str, + NULL, &msg); if (ret == EOK && msg->count == 1) { value.ul = ldb_msg_find_attr_as_uint64(msg->msgs[0], SYSDB_GIDNUM, 0); @@ -247,8 +245,8 @@ errno_t get_sids_from_pac(TALLOC_CTX *mem_ctx, ret = responder_get_domain_by_id(pac_ctx->rctx, sid_str, &group_dom); if (ret == EOK) { - ret = sysdb_search_object_by_sid(mem_ctx, group_dom->sysdb, - group_dom, sid_str, NULL, &msg); + ret = sysdb_search_object_by_sid(mem_ctx, group_dom, sid_str, + NULL, &msg); if (ret == EOK && msg->count == 1 ) { value.ul = ldb_msg_find_attr_as_uint64(msg->msgs[0], SYSDB_GIDNUM, 0); diff --git a/src/responder/pam/pamsrv_cmd.c b/src/responder/pam/pamsrv_cmd.c index f8d7a091a..94c72cf35 100644 --- a/src/responder/pam/pamsrv_cmd.c +++ b/src/responder/pam/pamsrv_cmd.c @@ -499,7 +499,7 @@ static void pam_reply(struct pam_auth_req *preq) goto done; } - ret = sysdb_cache_auth(preq->domain->sysdb, preq->domain, + ret = sysdb_cache_auth(preq->domain, pd->user, password, pctx->rctx->cdb, false, &exp_date, &delay_until); diff --git a/src/responder/sudo/sudosrv_get_sudorules.c b/src/responder/sudo/sudosrv_get_sudorules.c index 0738233d1..16349d567 100644 --- a/src/responder/sudo/sudosrv_get_sudorules.c +++ b/src/responder/sudo/sudosrv_get_sudorules.c @@ -645,7 +645,7 @@ static errno_t sudosrv_get_sudorules_query_cache(TALLOC_CTX *mem_ctx, domain = domain->parent; } - ret = sysdb_search_custom(tmp_ctx, sysdb, domain, filter, + ret = sysdb_search_custom(tmp_ctx, domain, filter, SUDORULE_SUBDIR, attrs, &count, &msgs); if (ret != EOK && ret != ENOENT) { diff --git a/src/tests/cmocka/test_nss_srv.c b/src/tests/cmocka/test_nss_srv.c index 61625b022..741d6c581 100644 --- a/src/tests/cmocka/test_nss_srv.c +++ b/src/tests/cmocka/test_nss_srv.c @@ -269,8 +269,7 @@ void test_nss_getpwnam(void **state) errno_t ret; /* Prime the cache with a valid user */ - ret = sysdb_add_user(nss_test_ctx->tctx->sysdb, - nss_test_ctx->tctx->dom, + ret = sysdb_add_user(nss_test_ctx->tctx->dom, "testuser", 123, 456, "test user", "/home/testuser", "/bin/sh", NULL, NULL, 300, 0); @@ -335,8 +334,7 @@ static int test_nss_getpwnam_search_acct_cb(void *pvt) errno_t ret; struct nss_test_ctx *ctx = talloc_get_type(pvt, struct nss_test_ctx); - ret = sysdb_add_user(ctx->tctx->sysdb, - ctx->tctx->dom, + ret = sysdb_add_user(ctx->tctx->dom, "testuser_search", 567, 890, "test search", "/home/testsearch", "/bin/sh", NULL, NULL, 300, 0); @@ -401,8 +399,7 @@ static int test_nss_getpwnam_update_acct_cb(void *pvt) errno_t ret; struct nss_test_ctx *ctx = talloc_get_type(pvt, struct nss_test_ctx); - ret = sysdb_store_user(ctx->tctx->sysdb, - ctx->tctx->dom, + ret = sysdb_store_user(ctx->tctx->dom, "testuser_update", NULL, 10, 11, "test user", "/home/testuser", "/bin/ksh", NULL, NULL, NULL, 300, 0); @@ -433,8 +430,7 @@ void test_nss_getpwnam_update(void **state) const char *shell; /* Prime the cache with a valid but expired user */ - ret = sysdb_add_user(nss_test_ctx->tctx->sysdb, - nss_test_ctx->tctx->dom, + ret = sysdb_add_user(nss_test_ctx->tctx->dom, "testuser_update", 10, 11, "test user", "/home/testuser", "/bin/sh", NULL, NULL, 1, 1); @@ -495,8 +491,7 @@ void test_nss_getpwnam_fqdn(void **state) errno_t ret; /* Prime the cache with a valid user */ - ret = sysdb_add_user(nss_test_ctx->tctx->sysdb, - nss_test_ctx->tctx->dom, + ret = sysdb_add_user(nss_test_ctx->tctx->dom, "testuser_fqdn", 124, 457, "test user", "/home/testuser", "/bin/sh", NULL, NULL, 300, 0); @@ -544,8 +539,7 @@ void test_nss_getpwnam_fqdn_resize(void **state) errno_t ret; /* Prime the cache with a valid user */ - ret = sysdb_add_user(nss_test_ctx->tctx->sysdb, - nss_test_ctx->tctx->dom, + ret = sysdb_add_user(nss_test_ctx->tctx->dom, "testuser_fqdn_resize", 125, 458, "test user", "/home/testuser", "/bin/sh", NULL, NULL, 300, 0); @@ -649,8 +643,7 @@ void test_nss_getgrnam_no_members(void **state) errno_t ret; /* Prime the cache with a valid group */ - ret = sysdb_add_group(nss_test_ctx->tctx->sysdb, - nss_test_ctx->tctx->dom, + ret = sysdb_add_group(nss_test_ctx->tctx->dom, "testgroup", 1123, NULL, 300, 0); assert_int_equal(ret, EOK); @@ -701,34 +694,29 @@ void test_nss_getgrnam_members(void **state) errno_t ret; /* Prime the cache with a valid group and some members */ - ret = sysdb_add_group(nss_test_ctx->tctx->sysdb, - nss_test_ctx->tctx->dom, + ret = sysdb_add_group(nss_test_ctx->tctx->dom, "testgroup_members", 1124, NULL, 300, 0); assert_int_equal(ret, EOK); - ret = sysdb_add_user(nss_test_ctx->tctx->sysdb, - nss_test_ctx->tctx->dom, + ret = sysdb_add_user(nss_test_ctx->tctx->dom, "testmember1", 2001, 456, "test member1", "/home/testmember2", "/bin/sh", NULL, NULL, 300, 0); assert_int_equal(ret, EOK); - ret = sysdb_add_user(nss_test_ctx->tctx->sysdb, - nss_test_ctx->tctx->dom, + ret = sysdb_add_user(nss_test_ctx->tctx->dom, "testmember2", 2002, 456, "test member2", "/home/testmember2", "/bin/sh", NULL, NULL, 300, 0); assert_int_equal(ret, EOK); - ret = sysdb_add_group_member(nss_test_ctx->tctx->sysdb, - nss_test_ctx->tctx->dom, + ret = sysdb_add_group_member(nss_test_ctx->tctx->dom, "testgroup_members", "testmember1", SYSDB_MEMBER_USER, false); assert_int_equal(ret, EOK); - ret = sysdb_add_group_member(nss_test_ctx->tctx->sysdb, - nss_test_ctx->tctx->dom, + ret = sysdb_add_group_member(nss_test_ctx->tctx->dom, "testgroup_members", "testmember2", SYSDB_MEMBER_USER, false); assert_int_equal(ret, EOK); @@ -834,37 +822,32 @@ void test_nss_getgrnam_members_subdom(void **state) /* Add a group from a subdomain and two members from the same subdomain */ - ret = sysdb_add_group(nss_test_ctx->tctx->sysdb, - nss_test_ctx->subdom, + ret = sysdb_add_group(nss_test_ctx->subdom, "testsubdomgroup@"TEST_SUBDOM_NAME, 2124, NULL, 300, 0); assert_int_equal(ret, EOK); - ret = sysdb_add_user(nss_test_ctx->tctx->sysdb, - nss_test_ctx->subdom, + ret = sysdb_add_user(nss_test_ctx->subdom, "submember1@"TEST_SUBDOM_NAME, 4001, 456, "test subdomain member1", "/home/submember1", "/bin/sh", NULL, NULL, 300, 0); assert_int_equal(ret, EOK); - ret = sysdb_add_user(nss_test_ctx->tctx->sysdb, - nss_test_ctx->subdom, + ret = sysdb_add_user(nss_test_ctx->subdom, "submember2@"TEST_SUBDOM_NAME, 2002, 456, "test subdomain member2", "/home/submember2", "/bin/sh", NULL, NULL, 300, 0); assert_int_equal(ret, EOK); - ret = sysdb_add_group_member(nss_test_ctx->tctx->sysdb, - nss_test_ctx->subdom, + ret = sysdb_add_group_member(nss_test_ctx->subdom, "testsubdomgroup@"TEST_SUBDOM_NAME, "submember1@"TEST_SUBDOM_NAME, SYSDB_MEMBER_USER, false); assert_int_equal(ret, EOK); - ret = sysdb_add_group_member(nss_test_ctx->tctx->sysdb, - nss_test_ctx->subdom, + ret = sysdb_add_group_member(nss_test_ctx->subdom, "testsubdomgroup@"TEST_SUBDOM_NAME, "submember2@"TEST_SUBDOM_NAME, SYSDB_MEMBER_USER, false); @@ -927,8 +910,7 @@ void test_nss_getgrnam_mix_dom(void **state) assert_non_null(group_strdn); add_groups[0] = group_strdn; - ret = sysdb_update_members_dn(nss_test_ctx->tctx->sysdb, - nss_test_ctx->subdom, + ret = sysdb_update_members_dn(nss_test_ctx->subdom, "submember1@"TEST_SUBDOM_NAME, SYSDB_MEMBER_USER, add_groups, NULL); @@ -1036,8 +1018,7 @@ void test_nss_getgrnam_mix_subdom(void **state) assert_non_null(group_strdn); add_groups[0] = group_strdn; - ret = sysdb_update_members_dn(nss_test_ctx->tctx->sysdb, - nss_test_ctx->tctx->dom, + ret = sysdb_update_members_dn(nss_test_ctx->tctx->dom, "testmember1", SYSDB_MEMBER_USER, add_groups, NULL); diff --git a/src/tests/simple_access-tests.c b/src/tests/simple_access-tests.c index 6d214dc7e..17026091f 100644 --- a/src/tests/simple_access-tests.c +++ b/src/tests/simple_access-tests.c @@ -161,38 +161,35 @@ void setup_simple_group(void) /* Add test users u1 and u2 that would be members of test groups * g1 and g2 respectively */ - ret = sysdb_add_group(test_ctx->sysdb, test_ctx->ctx->domain, - "pvt", 999, NULL, 0, 0); + ret = sysdb_add_group(test_ctx->ctx->domain, "pvt", 999, NULL, 0, 0); fail_if(ret != EOK, "Could not add private group %s", strerror(ret)); - ret = sysdb_store_user(test_ctx->sysdb, test_ctx->ctx->domain, + ret = sysdb_store_user(test_ctx->ctx->domain, "u1", NULL, 123, 999, "u1", "/home/u1", "/bin/bash", NULL, NULL, NULL, -1, 0); fail_if(ret != EOK, "Could not add u1"); - ret = sysdb_store_user(test_ctx->sysdb, test_ctx->ctx->domain, + ret = sysdb_store_user(test_ctx->ctx->domain, "u2", NULL, 456, 999, "u1", "/home/u1", "/bin/bash", NULL, NULL, NULL, -1, 0); fail_if(ret != EOK, "Could not add u2"); - ret = sysdb_store_user(test_ctx->sysdb, test_ctx->ctx->domain, + ret = sysdb_store_user(test_ctx->ctx->domain, "u3", NULL, 789, 999, "u1", "/home/u1", "/bin/bash", NULL, NULL, NULL, -1, 0); fail_if(ret != EOK, "Could not add u3"); - ret = sysdb_add_group(test_ctx->sysdb, test_ctx->ctx->domain, - "g1", 321, NULL, 0, 0); + ret = sysdb_add_group(test_ctx->ctx->domain, "g1", 321, NULL, 0, 0); fail_if(ret != EOK, "Could not add g1"); - ret = sysdb_add_group(test_ctx->sysdb, test_ctx->ctx->domain, - "g2", 654, NULL, 0, 0); + ret = sysdb_add_group(test_ctx->ctx->domain, "g2", 654, NULL, 0, 0); fail_if(ret != EOK, "Could not add g2"); - ret = sysdb_add_group_member(test_ctx->sysdb, test_ctx->ctx->domain, + ret = sysdb_add_group_member(test_ctx->ctx->domain, "g1", "u1", SYSDB_MEMBER_USER, false); fail_if(ret != EOK, "Could not add u1 to g1"); - ret = sysdb_add_group_member(test_ctx->sysdb, test_ctx->ctx->domain, + ret = sysdb_add_group_member(test_ctx->ctx->domain, "g2", "u2", SYSDB_MEMBER_USER, false); fail_if(ret != EOK, "Could not add u2 to g2"); } @@ -201,17 +198,17 @@ void teardown_simple_group(void) { errno_t ret; - ret = sysdb_delete_user(test_ctx->sysdb, test_ctx->ctx->domain, "u1", 0); + ret = sysdb_delete_user(test_ctx->ctx->domain, "u1", 0); fail_if(ret != EOK, "Could not delete u1"); - ret = sysdb_delete_user(test_ctx->sysdb, test_ctx->ctx->domain, "u2", 0); + ret = sysdb_delete_user(test_ctx->ctx->domain, "u2", 0); fail_if(ret != EOK, "Could not delete u2"); - ret = sysdb_delete_user(test_ctx->sysdb, test_ctx->ctx->domain, "u3", 0); + ret = sysdb_delete_user(test_ctx->ctx->domain, "u3", 0); fail_if(ret != EOK, "Could not delete u3"); - ret = sysdb_delete_group(test_ctx->sysdb, test_ctx->ctx->domain, "g1", 0); + ret = sysdb_delete_group(test_ctx->ctx->domain, "g1", 0); fail_if(ret != EOK, "Could not delete g1"); - ret = sysdb_delete_group(test_ctx->sysdb, test_ctx->ctx->domain, "g2", 0); + ret = sysdb_delete_group(test_ctx->ctx->domain, "g2", 0); fail_if(ret != EOK, "Could not delete g2"); - ret = sysdb_delete_group(test_ctx->sysdb, test_ctx->ctx->domain, "pvt", 0); + ret = sysdb_delete_group(test_ctx->ctx->domain, "pvt", 0); fail_if(ret != EOK, "Could not delete pvt"); teardown_simple(); diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c index 67125b7fe..3602fb45f 100644 --- a/src/tests/sysdb-tests.c +++ b/src/tests/sysdb-tests.c @@ -193,7 +193,7 @@ static int test_add_user(struct test_data *data) homedir = talloc_asprintf(data, "/home/testuser%d", data->uid); gecos = talloc_asprintf(data, "Test User %d", data->uid); - ret = sysdb_add_user(data->ctx->sysdb, data->ctx->domain, data->username, + ret = sysdb_add_user(data->ctx->domain, data->username, data->uid, 0, gecos, homedir, "/bin/bash", NULL, NULL, 0, 0); return ret; @@ -208,7 +208,7 @@ static int test_store_user(struct test_data *data) homedir = talloc_asprintf(data, "/home/testuser%d", data->uid); gecos = talloc_asprintf(data, "Test User %d", data->uid); - ret = sysdb_store_user(data->ctx->sysdb, data->ctx->domain, + ret = sysdb_store_user(data->ctx->domain, data->username, "x", data->uid, 0, gecos, homedir, data->shell ? data->shell : "/bin/bash", @@ -233,8 +233,7 @@ static int test_remove_user_by_uid(struct test_data *data) { int ret; - ret = sysdb_delete_user(data->ctx->sysdb, - data->ctx->domain, NULL, data->uid); + ret = sysdb_delete_user(data->ctx->domain, NULL, data->uid); return ret; } @@ -242,8 +241,7 @@ static int test_remove_nonexistent_group(struct test_data *data) { int ret; - ret = sysdb_delete_group(data->ctx->sysdb, - data->ctx->domain, NULL, data->uid); + ret = sysdb_delete_group(data->ctx->domain, NULL, data->uid); return ret; } @@ -251,8 +249,7 @@ static int test_remove_nonexistent_user(struct test_data *data) { int ret; - ret = sysdb_delete_user(data->ctx->sysdb, - data->ctx->domain, NULL, data->uid); + ret = sysdb_delete_user(data->ctx->domain, NULL, data->uid); return ret; } @@ -260,8 +257,8 @@ static int test_add_group(struct test_data *data) { int ret; - ret = sysdb_add_group(data->ctx->sysdb, data->ctx->domain, - data->groupname, data->gid, data->attrs, 0, 0); + ret = sysdb_add_group(data->ctx->domain, data->groupname, data->gid, + data->attrs, 0, 0); return ret; } @@ -269,8 +266,7 @@ static int test_add_incomplete_group(struct test_data *data) { int ret; - ret = sysdb_add_incomplete_group(data->ctx->sysdb, - data->ctx->domain, data->groupname, + ret = sysdb_add_incomplete_group(data->ctx->domain, data->groupname, data->gid, NULL, NULL, true, 0); return ret; } @@ -279,7 +275,7 @@ static int test_store_group(struct test_data *data) { int ret; - ret = sysdb_store_group(data->ctx->sysdb, data->ctx->domain, + ret = sysdb_store_group(data->ctx->domain, data->groupname, data->gid, data->attrs, -1, 0); return ret; } @@ -301,8 +297,7 @@ static int test_remove_group_by_gid(struct test_data *data) { int ret; - ret = sysdb_delete_group(data->ctx->sysdb, - data->ctx->domain, NULL, data->gid); + ret = sysdb_delete_group(data->ctx->domain, NULL, data->gid); if (ret == ENOENT) { ret = EOK; } @@ -328,7 +323,7 @@ static int test_add_group_member(struct test_data *data) return ENOMEM; } - ret = sysdb_add_group_member(data->ctx->sysdb, data->ctx->domain, + ret = sysdb_add_group_member(data->ctx->domain, data->groupname, username, SYSDB_MEMBER_USER, false); return ret; @@ -344,7 +339,7 @@ static int test_remove_group_member(struct test_data *data) return ENOMEM; } - ret = sysdb_remove_group_member(data->ctx->sysdb, data->ctx->domain, + ret = sysdb_remove_group_member(data->ctx->domain, data->groupname, username, SYSDB_MEMBER_USER, false); return ret; @@ -360,7 +355,7 @@ static int test_store_custom(struct test_data *data) return ENOMEM; } - ret = sysdb_store_custom(data->ctx->sysdb, data->ctx->domain, object_name, + ret = sysdb_store_custom(data->ctx->domain, object_name, CUSTOM_TEST_CONTAINER, data->attrs); return ret; } @@ -369,8 +364,8 @@ static int test_delete_custom(struct test_data *data) { int ret; - ret = sysdb_delete_custom(data->ctx->sysdb, data->ctx->domain, - CUSTOM_TEST_OBJECT, CUSTOM_TEST_CONTAINER); + ret = sysdb_delete_custom(data->ctx->domain, CUSTOM_TEST_OBJECT, + CUSTOM_TEST_CONTAINER); return ret; } @@ -430,7 +425,7 @@ static int test_memberof_store_group(struct test_data *data) } } - ret = sysdb_store_group(data->ctx->sysdb, data->ctx->domain, + ret = sysdb_store_group(data->ctx->domain, data->groupname, data->gid, attrs, -1, 0); return ret; } @@ -467,7 +462,7 @@ static int test_memberof_store_group_with_ghosts(struct test_data *data) } } - ret = sysdb_store_group(data->ctx->sysdb, data->ctx->domain, + ret = sysdb_store_group(data->ctx->domain, data->groupname, data->gid, attrs, -1, 0); return ret; } @@ -479,8 +474,8 @@ static int test_add_basic_netgroup(struct test_data *data) description = talloc_asprintf(data, "Test Netgroup %d", data->uid); - ret = sysdb_add_basic_netgroup(data->ctx->sysdb, data->ctx->domain, - data->netgrname, description); + ret = sysdb_add_basic_netgroup(data->ctx->domain, data->netgrname, + description); return ret; } @@ -501,8 +496,7 @@ static int test_remove_netgroup_by_name(struct test_data *data) { int ret; - ret = sysdb_delete_netgroup(data->ctx->sysdb, - data->ctx->domain, data->netgrname); + ret = sysdb_delete_netgroup(data->ctx->domain, data->netgrname); return ret; } @@ -524,8 +518,8 @@ static int test_set_netgroup_attr(struct test_data *data) return ret; } - ret = sysdb_set_netgroup_attr(data->ctx->sysdb, data->ctx->domain, - data->netgrname, attrs, SYSDB_MOD_REP); + ret = sysdb_set_netgroup_attr(data->ctx->domain, data->netgrname, + attrs, SYSDB_MOD_REP); return ret; } @@ -1004,7 +998,7 @@ START_TEST (test_sysdb_search_groups) filter = talloc_asprintf(test_ctx, "("SYSDB_GIDNUM"=%d)", _i); fail_if(filter == NULL, "OOM"); - ret = sysdb_search_groups(test_ctx, test_ctx->sysdb, test_ctx->domain, + ret = sysdb_search_groups(test_ctx, test_ctx->domain, filter, attrs, &count, &msgs); talloc_free(filter); fail_if(ret != EOK, "Search failed: %d", ret); @@ -1169,7 +1163,7 @@ START_TEST (test_sysdb_search_users) _i); fail_if(filter == NULL, "OOM"); - ret = sysdb_search_users(test_ctx, test_ctx->sysdb, test_ctx->domain, + ret = sysdb_search_users(test_ctx, test_ctx->domain, filter, attrs, &count, &msgs); talloc_free(filter); fail_if(ret != EOK, "Search failed: %d", ret); @@ -1205,8 +1199,8 @@ START_TEST (test_sysdb_remove_attrs) rmattrs[0] = discard_const(SYSDB_SHELL); rmattrs[1] = NULL; - ret = sysdb_remove_attrs(test_ctx->sysdb, test_ctx->domain, - username, SYSDB_MEMBER_USER, rmattrs); + ret = sysdb_remove_attrs(test_ctx->domain, username, SYSDB_MEMBER_USER, + rmattrs); fail_if(ret != EOK, "Removing attributes failed: %d", ret); ret = sysdb_getpwnam(test_ctx, @@ -1410,7 +1404,7 @@ START_TEST (test_sysdb_get_new_id) ret = setup_sysdb_tests(&test_ctx); fail_if(ret != EOK, "Cannot setup sysdb tests\n"); - ret = sysdb_get_new_id(test_ctx->sysdb, test_ctx->domain, &id); + ret = sysdb_get_new_id(test_ctx->domain, &id); fail_if(ret != EOK, "Cannot get new ID\n"); fail_if(id != test_ctx->domain->id_min); } @@ -1480,7 +1474,7 @@ START_TEST (test_sysdb_search_custom_by_name) object_name = talloc_asprintf(data, "%s_%d", CUSTOM_TEST_OBJECT, 29010); fail_unless(object_name != NULL, "talloc_asprintf failed"); - ret = sysdb_search_custom_by_name(data, data->ctx->sysdb, + ret = sysdb_search_custom_by_name(data, data->ctx->domain, object_name, CUSTOM_TEST_CONTAINER, @@ -1583,7 +1577,7 @@ START_TEST (test_sysdb_search_custom_update) object_name = talloc_asprintf(data, "%s_%d", CUSTOM_TEST_OBJECT, 29010); fail_unless(object_name != NULL, "talloc_asprintf failed"); - ret = sysdb_search_custom_by_name(data, data->ctx->sysdb, + ret = sysdb_search_custom_by_name(data, data->ctx->domain, object_name, CUSTOM_TEST_CONTAINER, @@ -1649,8 +1643,7 @@ START_TEST (test_sysdb_search_custom) data->attrlist[1] = TEST_ATTR_ADD_NAME; data->attrlist[2] = NULL; - ret = sysdb_search_custom(data, data->ctx->sysdb, - data->ctx->domain, filter, + ret = sysdb_search_custom(data, data->ctx->domain, filter, CUSTOM_TEST_CONTAINER, data->attrlist, &data->msgs_count, @@ -1705,8 +1698,8 @@ START_TEST (test_sysdb_cache_password) data->ev = test_ctx->ev; data->username = talloc_asprintf(data, "testuser%d", _i); - ret = sysdb_cache_password(test_ctx->sysdb, test_ctx->domain, - data->username, data->username); + ret = sysdb_cache_password(test_ctx->domain, data->username, + data->username); fail_unless(ret == EOK, "sysdb_cache_password request failed [%d].", ret); @@ -1744,8 +1737,7 @@ static void cached_authentication_without_expiration(const char *username, return; } - ret = sysdb_cache_auth(test_ctx->sysdb, - test_ctx->domain, data->username, + ret = sysdb_cache_auth(test_ctx->domain, data->username, password, test_ctx->confdb, false, &expire_date, &delayed_until); @@ -1805,8 +1797,7 @@ static void cached_authentication_with_expiration(const char *username, SYSDB_MOD_REP); fail_unless(ret == EOK, "Could not modify user %s", data->username); - ret = sysdb_cache_auth(test_ctx->sysdb, - data->ctx->domain, data->username, + ret = sysdb_cache_auth(data->ctx->domain, data->username, password, test_ctx->confdb, false, &expire_date, &delayed_until); @@ -1942,7 +1933,7 @@ START_TEST (test_sysdb_asq_search) data->ctx->domain, ASQ_TEST_USER); fail_unless(user_dn != NULL, "sysdb_user_dn failed"); - ret = sysdb_asq_search(data, test_ctx->sysdb, + ret = sysdb_asq_search(data, test_ctx->domain, user_dn, NULL, "memberof", data->attrlist, &msgs_count, &msgs); @@ -2931,7 +2922,7 @@ START_TEST (test_sysdb_memberof_remove_child_group_and_check_ghost) 2, data->msg->elements[0].num_values); /* Remove the parent */ - ret = sysdb_delete_group(data->ctx->sysdb, data->ctx->domain, NULL, delgid); + ret = sysdb_delete_group(data->ctx->domain, NULL, delgid); fail_if(ret != EOK, "Cannot delete group %llu [%d]: %s\n", (unsigned long long) data->gid, ret, strerror(ret)); @@ -3430,7 +3421,7 @@ START_TEST(test_group_rename) fail_unless(ret == EOK, "Could not set up the test"); /* Store and verify the first group */ - ret = sysdb_store_group(test_ctx->sysdb, test_ctx->domain, + ret = sysdb_store_group(test_ctx->domain, fromname, grgid, NULL, 0, 0); fail_unless(ret == EOK, "Could not add first group"); @@ -3451,11 +3442,10 @@ START_TEST(test_group_rename) name, fromname); /* Perform rename and check that GID is the same, but name changed */ - ret = sysdb_add_group(test_ctx->sysdb, test_ctx->domain, - toname, grgid, NULL, 0, 0); + ret = sysdb_add_group(test_ctx->domain, toname, grgid, NULL, 0, 0); fail_unless(ret == EEXIST, "Group renamed with a low level call?"); - ret = sysdb_store_group(test_ctx->sysdb, test_ctx->domain, + ret = sysdb_store_group(test_ctx->domain, toname, grgid, NULL, 0, 0); fail_unless(ret == EOK, "Could not add first group"); @@ -3501,7 +3491,7 @@ START_TEST(test_user_rename) fail_unless(ret == EOK, "Could not set up the test"); /* Store and verify the first user */ - ret = sysdb_store_user(test_ctx->sysdb, test_ctx->domain, + ret = sysdb_store_user(test_ctx->domain, fromname, NULL, userid, 0, fromname, "/", "/bin/sh", NULL, NULL, NULL, 0, 0); @@ -3524,11 +3514,11 @@ START_TEST(test_user_rename) name, fromname); /* Perform rename and check that GID is the same, but name changed */ - ret = sysdb_add_user(test_ctx->sysdb, test_ctx->domain, toname, userid, 0, + ret = sysdb_add_user(test_ctx->domain, toname, userid, 0, fromname, "/", "/bin/sh", NULL, NULL, 0, 0); fail_unless(ret == EEXIST, "A second user added with low level call?"); - ret = sysdb_store_user(test_ctx->sysdb, test_ctx->domain, toname, NULL, + ret = sysdb_store_user(test_ctx->domain, toname, NULL, userid, 0, fromname, "/", "/bin/sh", NULL, NULL, NULL, 0, 0); fail_unless(ret == EOK, "Could not add second user"); @@ -3577,8 +3567,7 @@ START_TEST (test_sysdb_update_members) add_groups[1] = talloc_strdup(add_groups, "testgroup28002"); add_groups[2] = NULL; - ret = sysdb_update_members(test_ctx->sysdb, test_ctx->domain, - user, SYSDB_MEMBER_USER, + ret = sysdb_update_members(test_ctx->domain, user, SYSDB_MEMBER_USER, (const char *const *)add_groups, NULL); fail_unless(ret == EOK, "Could not add groups"); talloc_zfree(add_groups); @@ -3591,8 +3580,7 @@ START_TEST (test_sysdb_update_members) add_groups[0] = talloc_strdup(add_groups, "testgroup28003"); add_groups[1] = NULL; - ret = sysdb_update_members(test_ctx->sysdb, test_ctx->domain, - user, SYSDB_MEMBER_USER, + ret = sysdb_update_members(test_ctx->domain, user, SYSDB_MEMBER_USER, (const char *const *)add_groups, (const char *const *)del_groups); fail_unless(ret == EOK, "Group replace failed"); @@ -3605,8 +3593,7 @@ START_TEST (test_sysdb_update_members) del_groups[1] = talloc_strdup(del_groups, "testgroup28003"); del_groups[2] = NULL; - ret = sysdb_update_members(test_ctx->sysdb, test_ctx->domain, - user, SYSDB_MEMBER_USER, + ret = sysdb_update_members(test_ctx->domain, user, SYSDB_MEMBER_USER, NULL, (const char *const *)del_groups); fail_unless(ret == EOK, "Could not remove groups"); @@ -3859,7 +3846,7 @@ START_TEST(test_odd_characters) /* ===== Groups ===== */ /* Add */ - ret = sysdb_add_incomplete_group(test_ctx->sysdb, test_ctx->domain, + ret = sysdb_add_incomplete_group(test_ctx->domain, odd_groupname, 20000, NULL, NULL, true, 0); fail_unless(ret == EOK, "sysdb_add_incomplete_group error [%d][%s]", ret, strerror(ret)); @@ -3886,8 +3873,7 @@ START_TEST(test_odd_characters) /* ===== Users ===== */ /* Add */ - ret = sysdb_add_basic_user(test_ctx->sysdb, - test_ctx->domain, + ret = sysdb_add_basic_user(test_ctx->domain, odd_username, 10000, 10000, "","",""); @@ -3907,7 +3893,7 @@ START_TEST(test_odd_characters) talloc_zfree(msg); /* Add to the group */ - ret = sysdb_add_group_member(test_ctx->sysdb, test_ctx->domain, + ret = sysdb_add_group_member(test_ctx->domain, odd_groupname, odd_username, SYSDB_MEMBER_USER, false); fail_unless(ret == EOK, "sysdb_add_group_member error [%d][%s]", @@ -3932,21 +3918,19 @@ START_TEST(test_odd_characters) talloc_free(res); /* Delete User */ - ret = sysdb_delete_user(test_ctx->sysdb, test_ctx->domain, - odd_username, 10000); + ret = sysdb_delete_user(test_ctx->domain, odd_username, 10000); fail_unless(ret == EOK, "sysdb_delete_user error [%d][%s]", ret, strerror(ret)); /* Delete Group */ - ret = sysdb_delete_group(test_ctx->sysdb, test_ctx->domain, - odd_groupname, 20000); + ret = sysdb_delete_group(test_ctx->domain, odd_groupname, 20000); fail_unless(ret == EOK, "sysdb_delete_group error [%d][%s]", ret, strerror(ret)); /* ===== Netgroups ===== */ /* Add */ - ret = sysdb_add_netgroup(test_ctx->sysdb, test_ctx->domain, + ret = sysdb_add_netgroup(test_ctx->domain, odd_netgroupname, "No description", NULL, NULL, 30, 0); fail_unless(ret == EOK, "sysdb_add_netgroup error [%d][%s]", @@ -4378,14 +4362,14 @@ START_TEST(test_sysdb_original_dn_case_insensitive) ret = setup_sysdb_tests(&test_ctx); fail_if(ret != EOK, "Could not set up the test"); - ret = sysdb_add_incomplete_group(test_ctx->sysdb, test_ctx->domain, + ret = sysdb_add_incomplete_group(test_ctx->domain, "case_sensitive_group1", 29000, "cn=case_sensitive_group1,cn=example,cn=com", NULL, true, 0); fail_unless(ret == EOK, "sysdb_add_incomplete_group error [%d][%s]", ret, strerror(ret)); - ret = sysdb_add_incomplete_group(test_ctx->sysdb, test_ctx->domain, + ret = sysdb_add_incomplete_group(test_ctx->domain, "case_sensitive_group2", 29001, "cn=CASE_SENSITIVE_GROUP1,cn=EXAMPLE,cn=COM", NULL, true, 0); @@ -4421,7 +4405,7 @@ START_TEST(test_sysdb_search_sid_str) ret = setup_sysdb_tests(&test_ctx); fail_if(ret != EOK, "Could not set up the test"); - ret = sysdb_add_incomplete_group(test_ctx->sysdb, test_ctx->domain, + ret = sysdb_add_incomplete_group(test_ctx->domain, "group", 29000, "cn=group,cn=example,cn=com", "S-1-2-3-4", true, 0); @@ -4454,7 +4438,7 @@ START_TEST(test_sysdb_search_sid_str) fail_unless(ret == EOK, "sysdb_attrs_add_string failed with [%d][%s].", ret, strerror(ret)); - ret = sysdb_add_user(test_ctx->sysdb, test_ctx->domain, "SIDuser", + ret = sysdb_add_user(test_ctx->domain, "SIDuser", 12345, 0, "SID user", "/home/siduser", "/bin/bash", NULL, attrs, 0, 0); fail_unless(ret == EOK, "sysdb_add_user failed with [%d][%s].", @@ -4558,7 +4542,7 @@ START_TEST(test_sysdb_subdomain_store_user) ret = sysdb_attrs_add_string(user_attrs, SYSDB_NAME_ALIAS, "subdomuser"); fail_unless(ret == EOK, "sysdb_store_user failed."); - ret = sysdb_store_user(subdomain->sysdb, subdomain, "SubDomUser", + ret = sysdb_store_user(subdomain, "SubDomUser", NULL, 12345, 0, "Sub Domain User", "/home/subdomuser", "/bin/bash", NULL, user_attrs, NULL, -1, 0); @@ -4586,7 +4570,7 @@ START_TEST(test_sysdb_subdomain_store_user) &msg); fail_unless(ret == EOK, "sysdb_search_user_by_name failed."); - ret = sysdb_delete_user(subdomain->sysdb, subdomain, "subdomuser", 0); + ret = sysdb_delete_user(subdomain, "subdomuser", 0); fail_unless(ret == EOK, "sysdb_delete_user failed [%d][%s].", ret, strerror(ret)); @@ -4623,7 +4607,7 @@ START_TEST(test_sysdb_subdomain_user_ops) fail_unless(ret == EOK, "sysdb_update_subdomains failed with [%d][%s]", ret, strerror(ret)); - ret = sysdb_store_user(subdomain->sysdb, subdomain, "subdomuser", + ret = sysdb_store_user(subdomain, "subdomuser", NULL, 12345, 0, "Sub Domain User", "/home/subdomuser", "/bin/bash", NULL, NULL, NULL, -1, 0); @@ -4646,7 +4630,7 @@ START_TEST(test_sysdb_subdomain_user_ops) fail_unless(ldb_dn_compare(msg->dn, check_dn) == 0, "Unexpedted DN returned"); - ret = sysdb_delete_user(subdomain->sysdb, subdomain, "subdomuser", 12345); + ret = sysdb_delete_user(subdomain, "subdomuser", 12345); fail_unless(ret == EOK, "sysdb_delete_domuser failed with [%d][%s].", ret, strerror(ret)); @@ -4677,7 +4661,7 @@ START_TEST(test_sysdb_subdomain_group_ops) fail_unless(ret == EOK, "sysdb_update_subdomains failed with [%d][%s]", ret, strerror(ret)); - ret = sysdb_store_group(subdomain->sysdb, subdomain, + ret = sysdb_store_group(subdomain, "subdomgroup", 12345, NULL, -1, 0); fail_unless(ret == EOK, "sysdb_store_domgroup failed."); @@ -4698,7 +4682,7 @@ START_TEST(test_sysdb_subdomain_group_ops) fail_unless(ldb_dn_compare(msg->dn, check_dn) == 0, "Unexpedted DN returned"); - ret = sysdb_delete_group(subdomain->sysdb, subdomain, "subdomgroup", 12345); + ret = sysdb_delete_group(subdomain, "subdomgroup", 12345); fail_unless(ret == EOK, "sysdb_delete_domgroup failed with [%d][%s].", ret, strerror(ret)); diff --git a/src/tools/sss_cache.c b/src/tools/sss_cache.c index c6d2508ce..8a232b788 100644 --- a/src/tools/sss_cache.c +++ b/src/tools/sss_cache.c @@ -354,17 +354,17 @@ static bool invalidate_entries(TALLOC_CTX *ctx, switch (entry_type) { case TYPE_USER: type_string = "user"; - ret = sysdb_search_users(ctx, sysdb, dinfo, + ret = sysdb_search_users(ctx, dinfo, filter, attrs, &msg_count, &msgs); break; case TYPE_GROUP: type_string = "group"; - ret = sysdb_search_groups(ctx, sysdb, dinfo, + ret = sysdb_search_groups(ctx, dinfo, filter, attrs, &msg_count, &msgs); break; case TYPE_NETGROUP: type_string = "netgroup"; - ret = sysdb_search_netgroups(ctx, sysdb, dinfo, + ret = sysdb_search_netgroups(ctx, dinfo, filter, attrs, &msg_count, &msgs); break; case TYPE_SERVICE: @@ -435,8 +435,8 @@ static errno_t invalidate_entry(TALLOC_CTX *ctx, struct sysdb_ctx *sysdb, SYSDB_MOD_REP); break; case TYPE_NETGROUP: - ret = sysdb_set_netgroup_attr(sysdb, domain, name, - sys_attrs, SYSDB_MOD_REP); + ret = sysdb_set_netgroup_attr(domain, name, sys_attrs, + SYSDB_MOD_REP); break; case TYPE_SERVICE: ret = sysdb_set_service_attr(domain, name, @@ -701,7 +701,7 @@ search_autofsmaps(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb, size_t *msgs_count, struct ldb_message ***msgs) { #ifdef BUILD_AUTOFS - return sysdb_search_custom(mem_ctx, sysdb, domain, sub_filter, + return sysdb_search_custom(mem_ctx, domain, sub_filter, AUTOFS_MAP_SUBDIR, attrs, msgs_count, msgs); #else diff --git a/src/tools/sss_groupshow.c b/src/tools/sss_groupshow.c index d52f800c5..59b8eff59 100644 --- a/src/tools/sss_groupshow.c +++ b/src/tools/sss_groupshow.c @@ -437,7 +437,7 @@ static int group_show_trim_memberof(TALLOC_CTX *mem_ctx, return ENOMEM; } - ret = sysdb_search_groups(mem_ctx, sysdb, domain, + ret = sysdb_search_groups(mem_ctx, domain, filter, NULL, &count, &msgs); /* ENOENT is OK, the group is just not a direct parent */ if (ret != EOK && ret != ENOENT) { diff --git a/src/tools/sss_seed.c b/src/tools/sss_seed.c index 38a1bba8e..cb5a0bfc4 100644 --- a/src/tools/sss_seed.c +++ b/src/tools/sss_seed.c @@ -740,7 +740,7 @@ static int seed_cache_user(struct seed_ctx *sctx) in_transaction = true; if (sctx->user_cached == false) { - ret = sysdb_add_user(sctx->sysdb, sctx->domain, sctx->uctx->name, + ret = sysdb_add_user(sctx->domain, sctx->uctx->name, sctx->uctx->uid, sctx->uctx->gid, sctx->uctx->gecos, sctx->uctx->home, sctx->uctx->shell, NULL, NULL, 0, 0); @@ -753,7 +753,7 @@ static int seed_cache_user(struct seed_ctx *sctx) } } - ret = sysdb_cache_password(sctx->sysdb, sctx->domain, sctx->uctx->name, + ret = sysdb_cache_password(sctx->domain, sctx->uctx->name, sctx->uctx->password); if (ret != EOK) { DEBUG(SSSDBG_OP_FAILURE, ("Failed to cache password. (%d)[%s]\n", diff --git a/src/tools/sss_sync_ops.c b/src/tools/sss_sync_ops.c index 1c93efcaf..c815de80e 100644 --- a/src/tools/sss_sync_ops.c +++ b/src/tools/sss_sync_ops.c @@ -77,7 +77,7 @@ static int mod_groups_member(struct sysdb_ctx *sysdb, goto done; } - ret = sysdb_mod_group_member(sysdb, member_dn, parent_dn, optype); + ret = sysdb_mod_group_member(dom, member_dn, parent_dn, optype); if (ret) { goto done; } @@ -468,8 +468,7 @@ int useradd(TALLOC_CTX *mem_ctx, { int ret; - ret = sysdb_add_user(sysdb, - data->domain, data->name, data->uid, data->gid, + ret = sysdb_add_user(data->domain, data->name, data->uid, data->gid, data->gecos, data->home, data->shell, NULL, NULL, 0, 0); if (ret) { @@ -533,8 +532,7 @@ int groupadd(struct sysdb_ctx *sysdb, { int ret; - ret = sysdb_add_group(sysdb, data->domain, - data->name, data->gid, NULL, 0, 0); + ret = sysdb_add_group(data->domain, data->name, data->gid, NULL, 0, 0); if (ret == EOK) { flush_nscd_cache(NSCD_DB_GROUP); } |