summaryrefslogtreecommitdiffstats
path: root/src/db/sysdb_ops.c
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2015-03-24 15:35:01 +0100
committerSumit Bose <sbose@redhat.com>2015-05-08 09:14:15 +0200
commit55b7fdd837a780ab0f71cbfaa2403f4626993922 (patch)
tree292be2e43b783569cbe956b6bc564111473d0035 /src/db/sysdb_ops.c
parent932c3e22e3c59a9c33f30dcc09e6bef257e14320 (diff)
downloadsssd-55b7fdd837a780ab0f71cbfaa2403f4626993922.tar.gz
sssd-55b7fdd837a780ab0f71cbfaa2403f4626993922.tar.xz
sssd-55b7fdd837a780ab0f71cbfaa2403f4626993922.zip
sysdb: add sysdb_cache_password_ex()
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
Diffstat (limited to 'src/db/sysdb_ops.c')
-rw-r--r--src/db/sysdb_ops.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index 54cd714a4..f7ed4df72 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -2223,9 +2223,11 @@ int sysdb_remove_group_member(struct sss_domain_info *domain,
/* =Password-Caching====================================================== */
-int sysdb_cache_password(struct sss_domain_info *domain,
- const char *username,
- const char *password)
+int sysdb_cache_password_ex(struct sss_domain_info *domain,
+ const char *username,
+ const char *password,
+ enum sss_authtok_type authtok_type,
+ size_t second_factor_len)
{
TALLOC_CTX *tmp_ctx;
struct sysdb_attrs *attrs;
@@ -2258,6 +2260,15 @@ int sysdb_cache_password(struct sss_domain_info *domain,
ret = sysdb_attrs_add_string(attrs, SYSDB_CACHEDPWD, hash);
if (ret) goto fail;
+ ret = sysdb_attrs_add_long(attrs, SYSDB_CACHEDPWD_TYPE, authtok_type);
+ if (ret) goto fail;
+
+ if (authtok_type == SSS_AUTHTOK_TYPE_2FA && second_factor_len > 0) {
+ ret = sysdb_attrs_add_long(attrs, SYSDB_CACHEDPWD_FA2_LEN,
+ second_factor_len);
+ if (ret) goto fail;
+ }
+
/* FIXME: should we use a different attribute for chache passwords ?? */
ret = sysdb_attrs_add_long(attrs, "lastCachedPasswordChange",
(long)time(NULL));
@@ -2282,6 +2293,14 @@ fail:
return ret;
}
+int sysdb_cache_password(struct sss_domain_info *domain,
+ const char *username,
+ const char *password)
+{
+ return sysdb_cache_password_ex(domain, username, password,
+ SSS_AUTHTOK_TYPE_PASSWORD, 0);
+}
+
/* =Custom Search================== */
int sysdb_search_custom(TALLOC_CTX *mem_ctx,