summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorJan Zeleny <jzeleny@redhat.com>2011-05-18 10:06:19 -0400
committerStephen Gallagher <sgallagh@redhat.com>2011-08-15 09:16:38 -0400
commit8a1738f9379a1b8fb5c95c3df649e014ff5a1434 (patch)
treedd5a59e95b88d1edb7b21a5035692571422b454c /src/tools
parent237ade4114ae88f87c814d447dfd5aebdbdf72ef (diff)
downloadsssd-8a1738f9379a1b8fb5c95c3df649e014ff5a1434.tar.gz
sssd-8a1738f9379a1b8fb5c95c3df649e014ff5a1434.tar.xz
sssd-8a1738f9379a1b8fb5c95c3df649e014ff5a1434.zip
sysdb refactoring: deleted domain variables in sysdb API
The patch also updates code using modified functions. Tests have also been adjusted.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/sss_cache.c10
-rw-r--r--src/tools/sss_groupdel.c4
-rw-r--r--src/tools/sss_groupmod.c4
-rw-r--r--src/tools/sss_groupshow.c13
-rw-r--r--src/tools/sss_sync_ops.c28
-rw-r--r--src/tools/sss_sync_ops.h2
-rw-r--r--src/tools/sss_useradd.c1
-rw-r--r--src/tools/sss_userdel.c1
-rw-r--r--src/tools/sss_usermod.c4
-rw-r--r--src/tools/tools_util.c1
10 files changed, 23 insertions, 45 deletions
diff --git a/src/tools/sss_cache.c b/src/tools/sss_cache.c
index 0b086523..67fe2df5 100644
--- a/src/tools/sss_cache.c
+++ b/src/tools/sss_cache.c
@@ -39,7 +39,7 @@
#define TYPE_NETGROUP 2
struct entry_type_t {
const char *type_string;
- int (* search_fn)(TALLOC_CTX *, struct sysdb_ctx *, struct sss_domain_info *,
+ int (* search_fn)(TALLOC_CTX *, struct sysdb_ctx *,
const char *, const char **, size_t *, struct ldb_message ***);
};
static struct entry_type_t entry_types[] = {
@@ -116,7 +116,7 @@ void invalidate_entries(TALLOC_CTX *ctx, struct sysdb_ctx *sysdb,
type_rec = entry_types[entry_type];
if (filter) {
- ret = type_rec.search_fn(ctx, sysdb, NULL, filter, attrs,
+ ret = type_rec.search_fn(ctx, sysdb, filter, attrs,
&msg_count, &msgs);
if (ret != EOK) {
DEBUG(3, ("Searching for %s with filter %s failed\n",
@@ -157,15 +157,15 @@ errno_t invalidate_entry(TALLOC_CTX *ctx, struct sysdb_ctx *sysdb,
if (ret == EOK) {
switch (entry_type) {
case TYPE_USER:
- ret = sysdb_set_user_attr(ctx, sysdb, NULL, name,
+ ret = sysdb_set_user_attr(ctx, sysdb, name,
sys_attrs, SYSDB_MOD_REP);
break;
case TYPE_GROUP:
- ret = sysdb_set_group_attr(ctx, sysdb, NULL, name,
+ ret = sysdb_set_group_attr(ctx, sysdb, name,
sys_attrs, SYSDB_MOD_REP);
break;
case TYPE_NETGROUP:
- ret = sysdb_set_netgroup_attr(sysdb, NULL, name,
+ ret = sysdb_set_netgroup_attr(sysdb, name,
sys_attrs, SYSDB_MOD_REP);
break;
default:
diff --git a/src/tools/sss_groupdel.c b/src/tools/sss_groupdel.c
index 99b69086..c9af565c 100644
--- a/src/tools/sss_groupdel.c
+++ b/src/tools/sss_groupdel.c
@@ -90,9 +90,7 @@ int main(int argc, const char **argv)
goto fini;
}
- ret = sysdb_getgrnam_sync(tctx, tctx->sysdb,
- tctx->octx->name, tctx->local,
- tctx->octx);
+ ret = sysdb_getgrnam_sync(tctx, tctx->sysdb, tctx->octx->name, tctx->octx);
if (ret != EOK) {
/* Error message will be printed in the switch */
goto done;
diff --git a/src/tools/sss_groupmod.c b/src/tools/sss_groupmod.c
index 59ec10ba..48701adf 100644
--- a/src/tools/sss_groupmod.c
+++ b/src/tools/sss_groupmod.c
@@ -121,9 +121,7 @@ int main(int argc, const char **argv)
goto fini;
}
/* check the username to be able to give sensible error message */
- ret = sysdb_getgrnam_sync(tctx, tctx->sysdb,
- tctx->octx->name, tctx->local,
- tctx->octx);
+ ret = sysdb_getgrnam_sync(tctx, tctx->sysdb, tctx->octx->name, tctx->octx);
if (ret != EOK) {
ERROR("Cannot find group in local domain, "
"modifying groups is allowed only in local domain\n");
diff --git a/src/tools/sss_groupshow.c b/src/tools/sss_groupshow.c
index 15324855..a5702b58 100644
--- a/src/tools/sss_groupshow.c
+++ b/src/tools/sss_groupshow.c
@@ -297,8 +297,7 @@ int group_show(TALLOC_CTX *mem_ctx,
int i;
/* First, search for the root group */
- ret = sysdb_search_group_by_name(mem_ctx, sysdb,
- domain, name, attrs, &msg);
+ ret = sysdb_search_group_by_name(mem_ctx, sysdb, name, attrs, &msg);
if (ret) {
DEBUG(2, ("Search failed: %s (%d)\n", strerror(ret), ret));
goto done;
@@ -402,9 +401,7 @@ static int group_show_trim_memberof(TALLOC_CTX *mem_ctx,
return ENOMEM;
}
- ret = sysdb_search_groups(mem_ctx, sysdb,
- domain, filter, NULL,
- &count, &msgs);
+ ret = sysdb_search_groups(mem_ctx, sysdb, filter, NULL, &count, &msgs);
/* ENOENT is OK, the group is just not a direct parent */
if (ret != EOK && ret != ENOENT) {
return ret;
@@ -472,8 +469,7 @@ int group_show_recurse(TALLOC_CTX *mem_ctx,
continue;
}
- ret = sysdb_search_group_by_name(mem_ctx, sysdb,
- domain, group_members[i],
+ ret = sysdb_search_group_by_name(mem_ctx, sysdb, group_members[i],
attrs, &msg);
if (ret) {
DEBUG(2, ("Search failed: %s (%d)\n", strerror(ret), ret));
@@ -527,8 +523,7 @@ static int group_show_mpg(TALLOC_CTX *mem_ctx,
goto fail;
}
- ret = sysdb_search_user_by_name(info, sysdb,
- domain, name, attrs, &msg);
+ ret = sysdb_search_user_by_name(info, sysdb, name, attrs, &msg);
if (ret) {
DEBUG(2, ("Search failed: %s (%d)\n", strerror(ret), ret));
goto fail;
diff --git a/src/tools/sss_sync_ops.c b/src/tools/sss_sync_ops.c
index 2553ead8..d3cbb9d9 100644
--- a/src/tools/sss_sync_ops.c
+++ b/src/tools/sss_sync_ops.c
@@ -54,7 +54,6 @@ struct sync_op_res {
*/
static int mod_groups_member(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
- struct sss_domain_info *domain,
char **grouplist,
struct ldb_dn *member_dn,
int optype)
@@ -63,6 +62,7 @@ static int mod_groups_member(TALLOC_CTX *mem_ctx,
struct ldb_dn *parent_dn;
int ret;
int i;
+ struct sss_domain_info *domain = sysdb_ctx_get_domain(sysdb);
tmpctx = talloc_new(NULL);
if (!tmpctx) {
@@ -95,11 +95,11 @@ done:
}
#define add_to_groups(memctx, sysdb, data, member_dn) \
- mod_groups_member(memctx, sysdb, data->domain, \
- data->addgroups, member_dn, LDB_FLAG_MOD_ADD)
+ mod_groups_member(memctx, sysdb, data->addgroups, member_dn, \
+ LDB_FLAG_MOD_ADD)
#define remove_from_groups(memctx, sysdb, data, member_dn) \
- mod_groups_member(memctx, sysdb, data->domain, \
- data->rmgroups, member_dn, LDB_FLAG_MOD_DELETE)
+ mod_groups_member(memctx, sysdb, data->rmgroups, member_dn, \
+ LDB_FLAG_MOD_DELETE)
/*
* Modify a user
@@ -223,8 +223,7 @@ int usermod(TALLOC_CTX *mem_ctx,
}
if (attrs->num != 0) {
- ret = sysdb_set_user_attr(mem_ctx, sysdb,
- data->domain, data->name,
+ ret = sysdb_set_user_attr(mem_ctx, sysdb, data->name,
attrs, SYSDB_MOD_REP);
if (ret) {
return ret;
@@ -280,8 +279,7 @@ int groupmod(TALLOC_CTX *mem_ctx,
return ret;
}
- ret = sysdb_set_group_attr(mem_ctx, sysdb,
- data->domain, data->name,
+ ret = sysdb_set_group_attr(mem_ctx, sysdb, data->name,
attrs, SYSDB_MOD_REP);
if (ret) {
return ret;
@@ -476,8 +474,7 @@ int useradd(TALLOC_CTX *mem_ctx,
{
int ret;
- ret = sysdb_add_user(mem_ctx, sysdb,
- data->domain, data->name, data->uid, data->gid,
+ ret = sysdb_add_user(mem_ctx, sysdb, data->name, data->uid, data->gid,
data->gecos, data->home, data->shell, NULL, 0);
if (ret) {
goto done;
@@ -543,8 +540,7 @@ int groupadd(TALLOC_CTX *mem_ctx,
{
int ret;
- ret = sysdb_add_group(mem_ctx, sysdb,
- data->domain, data->name,
+ ret = sysdb_add_group(mem_ctx, sysdb, data->name,
data->gid, NULL, 0);
if (ret == EOK) {
flush_nscd_cache(mem_ctx, NSCD_DB_GROUP);
@@ -585,14 +581,13 @@ int groupdel(TALLOC_CTX *mem_ctx,
int sysdb_getpwnam_sync(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
const char *name,
- struct sss_domain_info *domain,
struct ops_ctx *out)
{
struct ldb_result *res;
const char *str;
int ret;
- ret = sysdb_getpwnam(mem_ctx, sysdb, domain, name, &res);
+ ret = sysdb_getpwnam(mem_ctx, sysdb, name, &res);
if (ret) {
return ret;
}
@@ -659,14 +654,13 @@ int sysdb_getpwnam_sync(TALLOC_CTX *mem_ctx,
int sysdb_getgrnam_sync(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
const char *name,
- struct sss_domain_info *domain,
struct ops_ctx *out)
{
struct ldb_result *res;
const char *str;
int ret;
- ret = sysdb_getgrnam(mem_ctx, sysdb, domain, name, &res);
+ ret = sysdb_getgrnam(mem_ctx, sysdb, name, &res);
if (ret) {
return ret;
}
diff --git a/src/tools/sss_sync_ops.h b/src/tools/sss_sync_ops.h
index f0faae94..fcf7e223 100644
--- a/src/tools/sss_sync_ops.h
+++ b/src/tools/sss_sync_ops.h
@@ -95,13 +95,11 @@ int groupmod(TALLOC_CTX *mem_ctx,
int sysdb_getpwnam_sync(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
const char *name,
- struct sss_domain_info *domain,
struct ops_ctx *out);
int sysdb_getgrnam_sync(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
const char *name,
- struct sss_domain_info *domain,
struct ops_ctx *out);
#endif /* __SSS_OPS_H__ */
diff --git a/src/tools/sss_useradd.c b/src/tools/sss_useradd.c
index edff6e14..8de4816f 100644
--- a/src/tools/sss_useradd.c
+++ b/src/tools/sss_useradd.c
@@ -212,7 +212,6 @@ int main(int argc, const char **argv)
ret = sysdb_getpwnam_sync(tctx,
tctx->sysdb,
tctx->octx->name,
- tctx->local,
tctx->octx);
if (ret != EOK) {
ERROR("Cannot get info about the user\n");
diff --git a/src/tools/sss_userdel.c b/src/tools/sss_userdel.c
index 1d0cb12b..c5010e34 100644
--- a/src/tools/sss_userdel.c
+++ b/src/tools/sss_userdel.c
@@ -219,7 +219,6 @@ int main(int argc, const char **argv)
ret = sysdb_getpwnam_sync(tctx,
tctx->sysdb,
tctx->octx->name,
- tctx->local,
tctx->octx);
if (ret != EOK) {
/* Error message will be printed in the switch */
diff --git a/src/tools/sss_usermod.c b/src/tools/sss_usermod.c
index bcf2b3a2..e6d54d58 100644
--- a/src/tools/sss_usermod.c
+++ b/src/tools/sss_usermod.c
@@ -139,9 +139,7 @@ int main(int argc, const char **argv)
goto fini;
}
/* check the username to be able to give sensible error message */
- ret = sysdb_getpwnam_sync(tctx, tctx->sysdb,
- tctx->octx->name, tctx->local,
- tctx->octx);
+ ret = sysdb_getpwnam_sync(tctx, tctx->sysdb, tctx->octx->name, tctx->octx);
if (ret != EOK) {
ERROR("Cannot find user in local domain, "
"modifying users is allowed only in local domain\n");
diff --git a/src/tools/tools_util.c b/src/tools/tools_util.c
index 96ca5843..fb4c4ef7 100644
--- a/src/tools/tools_util.c
+++ b/src/tools/tools_util.c
@@ -211,7 +211,6 @@ int check_group_names(struct tools_ctx *tctx,
ret = sysdb_getgrnam_sync(tctx,
tctx->sysdb,
grouplist[i],
- tctx->local,
groupinfo);
if (ret) {
DEBUG(6, ("Cannot find group %s, ret: %d\n", grouplist[i], ret));