diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2012-01-28 10:34:02 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2012-01-31 09:37:40 -0500 |
commit | e299638926171e0e92a36122aeff6611cd52418d (patch) | |
tree | e091b058ba862bc80ad5e6b8bbfb86955a796f15 /src/db | |
parent | f660877b38e563c4aa0cb1431624069808873fec (diff) | |
download | sssd-e299638926171e0e92a36122aeff6611cd52418d.tar.gz sssd-e299638926171e0e92a36122aeff6611cd52418d.tar.bz2 sssd-e299638926171e0e92a36122aeff6611cd52418d.zip |
SYSDB: extend sysdb_store_service() to accept additional attributes
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/sysdb.h | 3 | ||||
-rw-r--r-- | src/db/sysdb_ops.c | 26 | ||||
-rw-r--r-- | src/db/sysdb_services.c | 27 | ||||
-rw-r--r-- | src/db/sysdb_services.h | 2 |
4 files changed, 41 insertions, 17 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h index c4d64be1..5863afc9 100644 --- a/src/db/sysdb.h +++ b/src/db/sysdb.h @@ -553,7 +553,8 @@ int sysdb_store_group(struct sysdb_ctx *sysdb, enum sysdb_member_type { SYSDB_MEMBER_USER, - SYSDB_MEMBER_GROUP + SYSDB_MEMBER_GROUP, + SYSDB_MEMBER_SERVICE }; int sysdb_add_group_member(struct sysdb_ctx *sysdb, diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c index 4c4bc5ce..6573dcf9 100644 --- a/src/db/sysdb_ops.c +++ b/src/db/sysdb_ops.c @@ -21,6 +21,7 @@ #include "util/util.h" #include "db/sysdb_private.h" +#include "db/sysdb_services.h" #include "util/crypto/sss_crypto.h" #include <time.h> @@ -2949,20 +2950,21 @@ errno_t sysdb_remove_attrs(struct sysdb_ctx *sysdb, msg = ldb_msg_new(NULL); if (!msg) return ENOMEM; - if (type == SYSDB_MEMBER_USER) { + switch(type) { + case SYSDB_MEMBER_USER: msg->dn = sysdb_user_dn(sysdb, msg, sysdb->domain->name, name); - if (!msg->dn) { - ret = ENOMEM; - goto done; - } - } else if (type == SYSDB_MEMBER_GROUP) { + break; + + case SYSDB_MEMBER_GROUP: msg->dn = sysdb_group_dn(sysdb, msg, sysdb->domain->name, name); - if (!msg->dn) { - ret = ENOMEM; - goto done; - } - } else { - ret = EINVAL; + break; + + case SYSDB_MEMBER_SERVICE: + msg->dn = sysdb_svc_dn(sysdb, msg, sysdb->domain->name, name); + break; + } + if (!msg->dn) { + ret = ENOMEM; goto done; } diff --git a/src/db/sysdb_services.c b/src/db/sysdb_services.c index 55a0c438..425e9ed7 100644 --- a/src/db/sysdb_services.c +++ b/src/db/sysdb_services.c @@ -183,6 +183,8 @@ sysdb_store_service(struct sysdb_ctx *sysdb, int port, const char **aliases, const char **protocols, + struct sysdb_attrs *extra_attrs, + char **remove_attrs, uint64_t cache_timeout, time_t now) { @@ -367,11 +369,16 @@ sysdb_store_service(struct sysdb_ctx *sysdb, if (ret != EOK) goto done; /* Set the cache timeout */ - attrs = sysdb_new_attrs(tmp_ctx); - if (!attrs) { - ret = ENOMEM; - goto done; + if (!extra_attrs) { + attrs = sysdb_new_attrs(tmp_ctx); + if (!attrs) { + ret = ENOMEM; + goto done; + } + } else { + attrs = extra_attrs; } + ret = sysdb_attrs_add_time_t(attrs, SYSDB_LAST_UPDATE, now); if (ret) goto done; @@ -383,6 +390,18 @@ sysdb_store_service(struct sysdb_ctx *sysdb, ret = sysdb_set_entry_attr(sysdb, update_dn, attrs, SYSDB_MOD_REP); if (ret != EOK) goto done; + if (remove_attrs) { + ret = sysdb_remove_attrs(sysdb, primary_name, + SYSDB_MEMBER_SERVICE, + remove_attrs); + if (ret != EOK) { + DEBUG(SSSDBG_MINOR_FAILURE, + ("Could not remove missing attributes: [%s]\n", + strerror(ret))); + goto done; + } + } + ret = sysdb_transaction_commit(sysdb); if (ret == EOK) in_transaction = false; diff --git a/src/db/sysdb_services.h b/src/db/sysdb_services.h index c4ad1d34..97817d88 100644 --- a/src/db/sysdb_services.h +++ b/src/db/sysdb_services.h @@ -70,6 +70,8 @@ sysdb_store_service(struct sysdb_ctx *sysdb, int port, const char **aliases, const char **protocols, + struct sysdb_attrs *extra_attrs, + char **remove_attrs, uint64_t cache_timeout, time_t now); |