From 9579839a00493830c10a856ad1f5e035b6fa3b45 Mon Sep 17 00:00:00 2001 From: Ondrej Kos Date: Fri, 7 Dec 2012 20:44:15 +0100 Subject: PROXY: fix negative cache https://fedorahosted.org/sssd/ticket/1685 The PROXY provider wasn't storing credentials to negative cache due to bad return value. This was delegated from attempt to delete these credentials from local cache. Therefore ENOENT is replaced as EOK. --- src/providers/proxy/proxy_id.c | 44 +++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'src/providers') diff --git a/src/providers/proxy/proxy_id.c b/src/providers/proxy/proxy_id.c index 87eb91b1..060c4723 100644 --- a/src/providers/proxy/proxy_id.c +++ b/src/providers/proxy/proxy_id.c @@ -35,6 +35,9 @@ static int handle_getpw_result(enum nss_status status, struct passwd *pwd, struct sss_domain_info *dom, bool *del_user); +static int +delete_user(struct sysdb_ctx *sysdb, const char *name, uid_t uid); + static int get_pw_name(TALLOC_CTX *mem_ctx, struct proxy_id_ctx *ctx, struct sysdb_ctx *sysdb, @@ -83,10 +86,7 @@ static int get_pw_name(TALLOC_CTX *mem_ctx, } if (del_user) { - DEBUG(SSSDBG_TRACE_FUNC, - ("User %s does not exist (or is invalid) on remote server," - " deleting!\n", name)); - ret = sysdb_delete_user(sysdb, name, 0); + ret = delete_user(sysdb, name, 0); goto done; } @@ -126,10 +126,7 @@ static int get_pw_name(TALLOC_CTX *mem_ctx, } if (del_user) { - DEBUG(SSSDBG_TRACE_FUNC, - ("User %s does not exist (or is invalid) on remote server," - " deleting!\n", name)); - ret = sysdb_delete_user(sysdb, name, uid); + ret = delete_user(sysdb, name, uid); goto done; } @@ -197,6 +194,22 @@ handle_getpw_result(enum nss_status status, struct passwd *pwd, return ret; } +static int +delete_user(struct sysdb_ctx *sysdb, const char *name, uid_t uid) +{ + int ret = EOK; + + DEBUG(SSSDBG_TRACE_FUNC, + ("User %s does not exist (or is invalid) on remote server," + " deleting!\n", name)); + ret = sysdb_delete_user(sysdb, name, uid); + if (ret == ENOENT) { + ret = EOK; + } + + return ret; +} + static int save_user(struct sysdb_ctx *sysdb, bool lowercase, struct passwd *pwd, const char *real_name, const char *alias, uint64_t cache_timeout) @@ -319,10 +332,7 @@ static int get_pw_uid(TALLOC_CTX *mem_ctx, } if (del_user) { - DEBUG(SSSDBG_TRACE_FUNC, - ("User %d does not exist (or is invalid) on remote server," - " deleting!\n", uid)); - ret = sysdb_delete_user(sysdb, NULL, uid); + ret = delete_user(sysdb, NULL, uid); goto done; } @@ -1154,10 +1164,7 @@ static int get_initgr(TALLOC_CTX *mem_ctx, } if (del_user) { - DEBUG(SSSDBG_TRACE_FUNC, - ("User %s does not exist (or is invalid) on remote server," - " deleting!\n", name)); - ret = sysdb_delete_user(sysdb, name, 0); + ret = delete_user(sysdb, name, 0); if (ret) { DEBUG(SSSDBG_OP_FAILURE, ("Could not delete user\n")); goto fail; @@ -1201,10 +1208,7 @@ static int get_initgr(TALLOC_CTX *mem_ctx, } if (del_user) { - DEBUG(SSSDBG_TRACE_FUNC, - ("User %s does not exist (or is invalid) on remote server," - " deleting!\n", name)); - ret = sysdb_delete_user(sysdb, name, uid); + ret = delete_user(sysdb, name, uid); if (ret) { DEBUG(SSSDBG_OP_FAILURE, ("Could not delete user\n")); goto fail; -- cgit