summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/db/sysdb.h32
-rw-r--r--src/db/sysdb_ops.c123
-rw-r--r--src/tests/sysdb-tests.c264
3 files changed, 0 insertions, 419 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 9db83145..b8aafdfa 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -725,38 +725,6 @@ errno_t sysdb_update_members(struct sysdb_ctx *sysdb,
const char *const *add_groups,
const char *const *del_groups);
-errno_t sysdb_add_netgroup_tuple(struct sysdb_ctx *sysdb,
- const char *netgroup,
- const char *hostname,
- const char *username,
- const char *domainname);
-
-errno_t sysdb_remove_netgroup_tuple(struct sysdb_ctx *sysdb,
- const char *netgroup,
- const char *hostname,
- const char *username,
- const char *domainname);
-
-errno_t sysdb_mod_netgroup_tuple(struct sysdb_ctx *sysdb,
- const char *netgroup,
- const char *hostname,
- const char *username,
- const char *domainname,
- int mod_op);
-
-errno_t sysdb_add_netgroup_member(struct sysdb_ctx *sysdb,
- const char *netgroup,
- const char *member_netgroup);
-
-errno_t sysdb_remove_netgroup_member(struct sysdb_ctx *sysdb,
- const char *netgroup,
- const char *member_netgroup);
-
-errno_t sysdb_mod_netgroup_member(struct sysdb_ctx *sysdb,
- const char *netgroup,
- const char *member_netgroup,
- int mod_op);
-
/* Password caching function.
* If you are in a transaction ignore sysdb and pass in the handle.
* If you are not in a transaction pass NULL in handle and provide sysdb,
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index ea11cf3c..e1201f44 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -3039,129 +3039,6 @@ done:
return ret;
}
-errno_t sysdb_add_netgroup_tuple(struct sysdb_ctx *sysdb,
- const char *netgroup,
- const char *hostname,
- const char *username,
- const char *domainname)
-{
- return sysdb_mod_netgroup_tuple(sysdb, netgroup, hostname,
- username, domainname, SYSDB_MOD_ADD);
-}
-
-errno_t sysdb_remove_netgroup_tuple(struct sysdb_ctx *sysdb,
- const char *netgroup,
- const char *hostname,
- const char *username,
- const char *domainname)
-{
- return sysdb_mod_netgroup_tuple(sysdb, netgroup, hostname,
- username, domainname, SYSDB_MOD_DEL);
-}
-
-errno_t sysdb_mod_netgroup_tuple(struct sysdb_ctx *sysdb,
- const char *netgroup,
- const char *hostname,
- const char *username,
- const char *domainname,
- int mod_op)
-{
- errno_t ret;
- int lret;
- struct ldb_message *msg;
- char *triple;
-
- msg = ldb_msg_new(NULL);
- if (!msg) {
- ERROR_OUT(ret, ENOMEM, done);
- }
-
- msg->dn = sysdb_netgroup_dn(sysdb, msg, netgroup);
- if (!msg->dn) {
- ERROR_OUT(ret, ENOMEM, done);
- }
-
- triple = talloc_asprintf(msg, "(%s,%s,%s)",
- hostname, username, domainname);
- if (!triple) {
- ERROR_OUT(ret, ENOMEM, done);
- }
-
- ret = add_string(msg, mod_op, SYSDB_NETGROUP_TRIPLE, triple);
- if (ret != EOK) {
- goto done;
- }
-
- lret = ldb_modify(sysdb->ldb, msg);
- ret = sysdb_error_to_errno(lret);
-
-done:
- if (ret) {
- DEBUG(3, ("Error: %d (%s)\n", ret, strerror(ret)));
- }
- talloc_free(msg);
- return ret;
-}
-
-errno_t sysdb_add_netgroup_member(struct sysdb_ctx *sysdb,
- const char *netgroup,
- const char *member_netgroup)
-{
- return sysdb_mod_netgroup_member(sysdb, netgroup,
- member_netgroup, SYSDB_MOD_ADD);
-}
-
-errno_t sysdb_remove_netgroup_member(struct sysdb_ctx *sysdb,
- const char *netgroup,
- const char *member_netgroup)
-{
- return sysdb_mod_netgroup_member(sysdb, netgroup,
- member_netgroup, SYSDB_MOD_DEL);
-}
-
-errno_t sysdb_mod_netgroup_member(struct sysdb_ctx *sysdb,
- const char *netgroup,
- const char *member_netgroup,
- int mod_op)
-{
- errno_t ret;
- int lret;
- struct ldb_message *msg;
- char *member;
-
- msg = ldb_msg_new(NULL);
- if (!msg) {
- ERROR_OUT(ret, ENOMEM, done);
- }
-
- msg->dn = sysdb_netgroup_dn(sysdb, msg, netgroup);
- if (!msg->dn) {
- ERROR_OUT(ret, ENOMEM, done);
- }
-
- member = talloc_asprintf(msg, SYSDB_TMPL_NETGROUP,
- member_netgroup, sysdb->domain->name);
- if (!member) {
- ret = ENOMEM;
- goto done;
- }
-
- ret = add_string(msg, mod_op, SYSDB_MEMBER, member);
- if (ret != EOK) {
- goto done;
- }
-
- lret = ldb_modify(sysdb->ldb, msg);
- ret = sysdb_error_to_errno(lret);
-
-done:
- if (ret) {
- DEBUG(3, ("Error: %d (%s)\n", ret, strerror(ret)));
- }
- talloc_free(msg);
- return ret;
-}
-
errno_t sysdb_remove_attrs(struct sysdb_ctx *sysdb,
const char *name,
enum sysdb_member_type type,
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index 1db907b5..a79d8d6c 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -3643,258 +3643,6 @@ START_TEST (test_sysdb_get_netgroup_attr)
}
END_TEST
-START_TEST(test_sysdb_add_netgroup_tuple)
-{
- errno_t ret;
- struct sysdb_test_ctx *test_ctx;
- const char *netgrname;
- const char *hostname;
- const char *username;
- const char *domainname;
- struct ldb_result *res;
- struct sysdb_netgroup_ctx **entries;
-
- /* Setup */
- ret = setup_sysdb_tests(&test_ctx);
- if (ret != EOK) {
- fail("Could not set up the test");
- return;
- }
-
- netgrname = talloc_asprintf(test_ctx, "testnetgr%d", _i);
- fail_if(netgrname == NULL, "Out of memory");
-
- hostname = talloc_asprintf(test_ctx, "hostname%d", _i);
- fail_if(hostname == NULL, "Out of memory");
-
- username = talloc_asprintf(test_ctx, "username%d", _i);
- fail_if(username == NULL, "Out of memory");
-
- domainname = talloc_asprintf(test_ctx, "domainname%d", _i);
- fail_if(domainname == NULL, "Out of memory");
-
- ret = sysdb_add_netgroup_tuple(test_ctx->sysdb,
- netgrname, hostname,
- username, domainname);
- fail_unless(ret == EOK, "Failed to add netgr tuple");
-
- ret = sysdb_getnetgr(test_ctx, test_ctx->sysdb,
- netgrname, &res);
- fail_unless(ret == EOK, "Failed to retrieve netgr information");
-
- ret = sysdb_netgr_to_entries(test_ctx, res, &entries);
- fail_unless(ret == EOK, "Failed to convert entries");
-
- fail_unless(entries && entries[0] && !entries[1],
- "Got more than one triple back");
-
- fail_unless(strcmp(entries[0]->value.triple.hostname, hostname) == 0,
- "Got [%s], expected [%s] for hostname",
- entries[0]->value.triple.hostname, hostname);
-
- fail_unless(strcmp(entries[0]->value.triple.username, username) == 0,
- "Got [%s], expected [%s] for username",
- entries[0]->value.triple.username, username);
-
- fail_unless(strcmp(entries[0]->value.triple.domainname, domainname) == 0,
- "Got [%s], expected [%s] for domainname",
- entries[0]->value.triple.domainname, domainname);
-
- talloc_free(test_ctx);
-}
-END_TEST
-
-START_TEST(test_sysdb_remove_netgroup_tuple)
-{
- errno_t ret;
- struct sysdb_test_ctx *test_ctx;
- const char *netgrname;
- const char *hostname;
- const char *username;
- const char *domainname;
- struct ldb_result *res;
- struct sysdb_netgroup_ctx **entries;
-
- /* Setup */
- ret = setup_sysdb_tests(&test_ctx);
- if (ret != EOK) {
- fail("Could not set up the test");
- return;
- }
-
- netgrname = talloc_asprintf(test_ctx, "testnetgr%d", _i);
- fail_if(netgrname == NULL, "Out of memory");
-
- hostname = talloc_asprintf(test_ctx, "hostname%d", _i);
- fail_if(hostname == NULL, "Out of memory");
-
- username = talloc_asprintf(test_ctx, "username%d", _i);
- fail_if(username == NULL, "Out of memory");
-
- domainname = talloc_asprintf(test_ctx, "domainname%d", _i);
- fail_if(domainname == NULL, "Out of memory");
-
- ret = sysdb_remove_netgroup_tuple(test_ctx->sysdb,
- netgrname, hostname,
- username, domainname);
- fail_unless(ret == EOK, "Failed to remove netgr tuple");
-
- ret = sysdb_getnetgr(test_ctx, test_ctx->sysdb,
- netgrname, &res);
- fail_unless(ret == EOK, "Failed to retrieve netgr information");
-
- ret = sysdb_netgr_to_entries(test_ctx, res, &entries);
- fail_unless(ret == EOK, "Failed to convert entries");
-
- fail_unless(entries && !entries[0],"Found entries unexpectedly");
-
- talloc_free(test_ctx);
-}
-END_TEST
-
-START_TEST(test_sysdb_add_netgroup_member)
-{
- errno_t ret;
- struct sysdb_test_ctx *test_ctx;
- const char *netgrname;
- const char *membername;
- struct ldb_result *res;
- struct sysdb_netgroup_ctx **entries;
-
- char *hostname1;
- char *username1;
- char *domainname1;
-
- char *hostname2;
- char *username2;
- char *domainname2;
-
- /* Setup */
- ret = setup_sysdb_tests(&test_ctx);
- if (ret != EOK) {
- fail("Could not set up the test");
- return;
- }
-
- netgrname = talloc_asprintf(test_ctx, "testnetgr%d", _i);
- fail_if(netgrname == NULL, "Out of memory");
-
- membername = talloc_asprintf(test_ctx, "testnetgr%d", _i+1);
- fail_if(membername == NULL, "Out of memory");
-
- hostname1 = talloc_asprintf(test_ctx, "hostname%d", _i);
- hostname2 = talloc_asprintf(test_ctx, "hostname%d", _i+1);
-
- username1 = talloc_asprintf(test_ctx, "username%d", _i);
- username2 = talloc_asprintf(test_ctx, "username%d", _i+1);
-
- domainname1 = talloc_asprintf(test_ctx, "domainname%d", _i);
- domainname2 = talloc_asprintf(test_ctx, "domainname%d", _i+1);
-
- ret = sysdb_add_netgroup_member(test_ctx->sysdb, netgrname, membername);
- fail_unless(ret == EOK, "Failed to add netgr member");
-
- ret = sysdb_getnetgr(test_ctx, test_ctx->sysdb,
- netgrname, &res);
- fail_unless(ret == EOK, "Failed to retrieve netgr information");
-
- ret = sysdb_netgr_to_entries(test_ctx, res, &entries);
- fail_unless(ret == EOK, "Failed to convert entries");
-
- fail_if(!entries, "Received a NULL triple");
- fail_if(!entries[0], "Did not get any responses");
- fail_unless(entries[0] && entries[1] && !entries[2],
- "Did not get exactly two responses");
-
- fail_unless(strcmp(entries[0]->value.triple.hostname, hostname1) == 0,
- "Got [%s], expected [%s] for hostname",
- entries[0]->value.triple.hostname, hostname1);
-
- fail_unless(strcmp(entries[0]->value.triple.username, username1) == 0,
- "Got [%s], expected [%s] for username",
- entries[0]->value.triple.username, username1);
-
- fail_unless(strcmp(entries[0]->value.triple.domainname, domainname1) == 0,
- "Got [%s], expected [%s] for domainname",
- entries[0]->value.triple.domainname, domainname1);
-
- fail_unless(strcmp(entries[1]->value.triple.hostname, hostname2) == 0,
- "Got [%s], expected [%s] for hostname",
- entries[0]->value.triple.hostname, hostname2);
-
- fail_unless(strcmp(entries[1]->value.triple.username, username2) == 0,
- "Got [%s], expected [%s] for username",
- entries[0]->value.triple.username, username2);
-
- fail_unless(strcmp(entries[1]->value.triple.domainname, domainname2) == 0,
- "Got [%s], expected [%s] for domainname",
- entries[0]->value.triple.domainname, domainname2);
-
- talloc_free(test_ctx);
-}
-END_TEST
-
-START_TEST(test_sysdb_remove_netgroup_member)
-{
- errno_t ret;
- struct sysdb_test_ctx *test_ctx;
- const char *netgrname;
- const char *membername;
- struct ldb_result *res;
- struct sysdb_netgroup_ctx **entries;
-
- char *hostname;
- char *username;
- char *domainname;
-
- /* Setup */
- ret = setup_sysdb_tests(&test_ctx);
- if (ret != EOK) {
- fail("Could not set up the test");
- return;
- }
-
- netgrname = talloc_asprintf(test_ctx, "testnetgr%d", _i);
- fail_if(netgrname == NULL, "Out of memory");
-
- membername = talloc_asprintf(test_ctx, "testnetgr%d", _i+1);
- fail_if(membername == NULL, "Out of memory");
-
- hostname = talloc_asprintf(test_ctx, "hostname%d", _i);
- username = talloc_asprintf(test_ctx, "username%d", _i);
- domainname = talloc_asprintf(test_ctx, "domainname%d", _i);
-
- ret = sysdb_remove_netgroup_member(test_ctx->sysdb, netgrname, membername);
- fail_unless(ret == EOK, "Failed to add netgr member");
-
- ret = sysdb_getnetgr(test_ctx, test_ctx->sysdb,
- netgrname, &res);
- fail_unless(ret == EOK, "Failed to retrieve netgr information");
-
- ret = sysdb_netgr_to_entries(test_ctx, res, &entries);
- fail_unless(ret == EOK, "Failed to convert entries");
-
- fail_if(!entries, "Received a NULL triple");
- fail_if(!entries[0], "Did not get any responses");
- fail_unless(entries[0] && !entries[1],
- "Did not get exactly one response");
-
- fail_unless(strcmp(entries[0]->value.triple.hostname, hostname) == 0,
- "Got [%s], expected [%s] for hostname",
- entries[0]->value.triple.hostname, hostname);
-
- fail_unless(strcmp(entries[0]->value.triple.username, username) == 0,
- "Got [%s], expected [%s] for username",
- entries[0]->value.triple.username, username);
-
- fail_unless(strcmp(entries[0]->value.triple.domainname, domainname) == 0,
- "Got [%s], expected [%s] for domainname",
- entries[0]->value.triple.domainname, domainname);
-
- talloc_free(test_ctx);
-}
-END_TEST
-
START_TEST(test_odd_characters)
{
errno_t ret;
@@ -5045,18 +4793,6 @@ Suite *create_sysdb_suite(void)
/* Verify they have been changed */
tcase_add_loop_test(tc_sysdb, test_sysdb_get_netgroup_attr, 27000, 27010);
- /* Add some tuples */
- tcase_add_loop_test(tc_sysdb, test_sysdb_add_netgroup_tuple, 27000, 27010);
-
- /* Add a nested netgroup */
- tcase_add_loop_test(tc_sysdb, test_sysdb_add_netgroup_member, 27000, 27009);
-
- /* Remove the nested netgroup */
- tcase_add_loop_test(tc_sysdb, test_sysdb_remove_netgroup_member, 27000, 27009);
-
- /* Remove the tuples */
- tcase_add_loop_test(tc_sysdb, test_sysdb_remove_netgroup_tuple, 27000, 27010);
-
/* Remove half of them by name */
tcase_add_loop_test(tc_sysdb, test_sysdb_remove_netgroup_by_name, 27000, 27005);