diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2016-05-31 17:38:03 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2016-06-23 13:47:16 +0200 |
commit | 3bd9da80f71a6794af0a6b3fbc11bc3a2da64638 (patch) | |
tree | fa60d442f5020d5f7e50a38e1b2ff602c7940ff7 /src/db | |
parent | 4016c7dd288d379118b47ecbe7d8f46cfcb0d400 (diff) | |
download | sssd-3bd9da80f71a6794af0a6b3fbc11bc3a2da64638.tar.gz sssd-3bd9da80f71a6794af0a6b3fbc11bc3a2da64638.tar.xz sssd-3bd9da80f71a6794af0a6b3fbc11bc3a2da64638.zip |
SYSDB: Only update user attributes if needed
Resolves:
https://fedorahosted.org/sssd/ticket/2602
Uses the same logic as previously used for updating group entries to
only update user attributes if the group entry actually changed.
Reviewed-by: Sumit Bose <sbose@redhat.com>
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/sysdb_ops.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c index 7d2a521ec..9ee8f6fd9 100644 --- a/src/db/sysdb_ops.c +++ b/src/db/sysdb_ops.c @@ -1101,6 +1101,16 @@ done: return ret; } +static errno_t sysdb_check_and_update_ts_usr(struct sss_domain_info *domain, + const char *grp_name, + struct sysdb_attrs *attrs, + uint64_t cache_timeout, + time_t now) +{ + return sysdb_check_and_update_ts_obj(domain, SYSDB_USER, grp_name, + attrs, cache_timeout, now); +} + static errno_t sysdb_check_and_update_ts_grp(struct sss_domain_info *domain, const char *grp_name, struct sysdb_attrs *attrs, @@ -1120,6 +1130,15 @@ static errno_t sysdb_create_ts_grp(struct sss_domain_info *domain, cache_timeout, now); } +static errno_t sysdb_create_ts_usr(struct sss_domain_info *domain, + const char *usr_name, + uint64_t cache_timeout, + time_t now) +{ + return sysdb_create_ts_obj(domain, SYSDB_USER, usr_name, + cache_timeout, now); +} + /* =Replace-Attributes-On-Entry=========================================== */ static int sysdb_set_cache_entry_attr(struct ldb_context *ldb, struct ldb_dn *entry_dn, @@ -1862,6 +1881,13 @@ int sysdb_add_user(struct sss_domain_info *domain, ret = sysdb_add_basic_user(domain, name, uid, gid, gecos, homedir, shell); if (ret) goto done; + ret = sysdb_create_ts_usr(domain, name, cache_timeout, now); + if (ret != EOK) { + DEBUG(SSSDBG_MINOR_FAILURE, + "Cannot create user timestamp entry\n"); + /* Not fatal */ + } + if (uid == 0) { ret = sysdb_get_new_id(domain, &id); if (ret) goto done; @@ -2434,6 +2460,15 @@ int sysdb_store_user(struct sss_domain_info *domain, errno_t sret = EOK; bool in_transaction = false; + ret = sysdb_check_and_update_ts_usr(domain, name, attrs, + cache_timeout, now); + if (ret == EOK) { + DEBUG(SSSDBG_TRACE_LIBS, + "The user record of %s did not change, only updated " + "the timestamp cache\n", name); + return EOK; + } + tmp_ctx = talloc_new(NULL); if (!tmp_ctx) { return ENOMEM; |