summaryrefslogtreecommitdiff
path: root/src/db/sysdb_ops.c
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2010-09-29 22:15:20 +0200
committerStephen Gallagher <sgallagh@redhat.com>2010-10-15 09:03:07 -0400
commit7e15d2ed3c01ab3c1f5f882fe8fa974058097bc6 (patch)
tree860f60d776890cf2b4c100053832b552cdef54d1 /src/db/sysdb_ops.c
parent8c08a5e11f19cfe39695ee80793b72e2034c5aa4 (diff)
downloadsssd-7e15d2ed3c01ab3c1f5f882fe8fa974058097bc6.tar.gz
sssd-7e15d2ed3c01ab3c1f5f882fe8fa974058097bc6.tar.bz2
sssd-7e15d2ed3c01ab3c1f5f882fe8fa974058097bc6.zip
sysdb interface for adding incomplete groups
Useful for optimizing the initgroups operation.
Diffstat (limited to 'src/db/sysdb_ops.c')
-rw-r--r--src/db/sysdb_ops.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index 68f4e88b..f8e1fbd5 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -1075,6 +1075,50 @@ done:
return ret;
}
+int sysdb_add_incomplete_group(struct sysdb_ctx *ctx,
+ struct sss_domain_info *domain,
+ const char *name,
+ gid_t gid)
+{
+ TALLOC_CTX *tmpctx;
+ time_t now;
+ int ret;
+ struct sysdb_attrs *attrs;
+
+ tmpctx = talloc_new(NULL);
+ if (!tmpctx) {
+ return ENOMEM;
+ }
+
+ /* try to add the group */
+ ret = sysdb_add_basic_group(tmpctx, ctx, domain, name, gid);
+ if (ret) goto done;
+
+ attrs = sysdb_new_attrs(tmpctx);
+ if (!attrs) {
+ ret = ENOMEM;
+ goto done;
+ }
+
+ now = time(NULL);
+
+ ret = sysdb_attrs_add_time_t(attrs, SYSDB_LAST_UPDATE, now);
+ if (ret) goto done;
+
+ ret = sysdb_attrs_add_time_t(attrs, SYSDB_CACHE_EXPIRE,
+ now-1);
+ if (ret) goto done;
+
+ ret = sysdb_set_group_attr(tmpctx, ctx,
+ domain, name, attrs, SYSDB_MOD_REP);
+
+done:
+ if (ret != EOK) {
+ DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret)));
+ }
+ talloc_zfree(tmpctx);
+ return ret;
+}
/* =Add-Or-Remove-Group-Memeber=========================================== */