summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Zeleny <jzeleny@redhat.com>2011-04-11 09:46:30 -0400
committerStephen Gallagher <sgallagh@redhat.com>2011-05-04 10:46:55 -0400
commit46b78b8ab809a099480747253eefa5eb128c2a9f (patch)
tree947bd4a819a7e18863173d7ee48e30a7d2b270a6 /src
parentc737e1444fb186e349e59bfa9dac4995b720b4b1 (diff)
downloadsssd-46b78b8ab809a099480747253eefa5eb128c2a9f.tar.gz
sssd-46b78b8ab809a099480747253eefa5eb128c2a9f.tar.xz
sssd-46b78b8ab809a099480747253eefa5eb128c2a9f.zip
Some minor fixes and changes in sysdb_ops
Diffstat (limited to 'src')
-rw-r--r--src/db/sysdb_ops.c57
1 files changed, 40 insertions, 17 deletions
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index 7eb4b48c9..d6260b97c 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -486,6 +486,10 @@ int sysdb_set_user_attr(TALLOC_CTX *mem_ctx,
{
struct ldb_dn *dn;
+ if (!domain) {
+ domain = ctx->domain;
+ }
+
dn = sysdb_user_dn(ctx, mem_ctx, domain->name, name);
if (!dn) {
return ENOMEM;
@@ -531,6 +535,10 @@ int sysdb_set_netgroup_attr(struct sysdb_ctx *ctx,
return ENOMEM;
}
+ if (domain == NULL) {
+ domain = ctx->domain;
+ }
+
dn = sysdb_netgroup_dn(ctx, tmp_ctx, domain->name, name);
if (!dn) {
ret = ENOMEM;
@@ -1383,6 +1391,18 @@ int sysdb_store_user(TALLOC_CTX *mem_ctx,
return ENOMEM;
}
+ if (!domain) {
+ domain = ctx->domain;
+ }
+
+ if (!attrs) {
+ attrs = sysdb_new_attrs(tmpctx);
+ if (!attrs) {
+ ret = ENOMEM;
+ goto done;
+ }
+ }
+
if (pwd && (domain->legacy_passwords || !*pwd)) {
ret = sysdb_attrs_add_string(attrs, SYSDB_PWD, pwd);
if (ret) goto done;
@@ -1407,14 +1427,6 @@ int sysdb_store_user(TALLOC_CTX *mem_ctx,
}
/* the user exists, let's just replace attributes when set */
- if (!attrs) {
- attrs = sysdb_new_attrs(tmpctx);
- if (!attrs) {
- ret = ENOMEM;
- goto done;
- }
- }
-
if (uid) {
ret = sysdb_attrs_add_uint32(attrs, SYSDB_UIDNUM, uid);
if (ret) goto done;
@@ -1516,6 +1528,10 @@ int sysdb_store_group(TALLOC_CTX *mem_ctx,
return ENOMEM;
}
+ if (!domain) {
+ domain = ctx->domain;
+ }
+
ret = sysdb_search_group_by_name(tmpctx, ctx,
domain, name, src_attrs, &msg);
if (ret && ret != ENOENT) {
@@ -1525,6 +1541,14 @@ int sysdb_store_group(TALLOC_CTX *mem_ctx,
new_group = true;
}
+ if (!attrs) {
+ attrs = sysdb_new_attrs(tmpctx);
+ if (!attrs) {
+ ret = ENOMEM;
+ goto done;
+ }
+ }
+
/* FIXME: use the remote modification timestamp to know if the
* group needs any update */
@@ -1536,15 +1560,6 @@ int sysdb_store_group(TALLOC_CTX *mem_ctx,
}
/* the group exists, let's just replace attributes when set */
-
- if (!attrs) {
- attrs = sysdb_new_attrs(tmpctx);
- if (!attrs) {
- ret = ENOMEM;
- goto done;
- }
- }
-
if (gid) {
ret = sysdb_attrs_add_uint32(attrs, SYSDB_GIDNUM, gid);
if (ret) goto done;
@@ -2088,6 +2103,10 @@ int sysdb_search_users(TALLOC_CTX *mem_ctx,
return ENOMEM;
}
+ if (!domain) {
+ domain = sysdb->domain;
+ }
+
basedn = ldb_dn_new_fmt(tmpctx, sysdb->ldb,
SYSDB_TMPL_USER_BASE, domain->name);
if (!basedn) {
@@ -2202,6 +2221,10 @@ int sysdb_search_groups(TALLOC_CTX *mem_ctx,
return ENOMEM;
}
+ if (!domain) {
+ domain = sysdb->domain;
+ }
+
basedn = ldb_dn_new_fmt(tmpctx, sysdb->ldb,
SYSDB_TMPL_GROUP_BASE, domain->name);
if (!basedn) {