From 57a3f07fd9ff149156078caacb22aab9fd634f43 Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Tue, 18 Dec 2012 14:09:05 +0100 Subject: PAC responder: check if existing user differs If some of the Posix attributes of an user existing in the cache differ from the data given in the current PAC the old user entry is drop and a new one is created with the data from the PAC. --- src/responder/pac/pacsrv_utils.c | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/responder/pac/pacsrv_utils.c') diff --git a/src/responder/pac/pacsrv_utils.c b/src/responder/pac/pacsrv_utils.c index 4c3ecb2ac..8328d6fbc 100644 --- a/src/responder/pac/pacsrv_utils.c +++ b/src/responder/pac/pacsrv_utils.c @@ -963,3 +963,45 @@ done: return ret; } + +static bool compare_string_with_attr(const char *val, struct ldb_message *msg, + const char *attr) +{ + const char *str; + + str = ldb_msg_find_attr_as_string(msg, attr, NULL); + if ((str == NULL && val == NULL) || + (str != NULL && val != NULL && strcmp(str, val) == 0)) { + return true; + } + + return false; +} + +bool new_and_cached_user_differs(struct passwd *pwd, struct ldb_message *msg) +{ + if (pwd == NULL || msg == NULL) { + return true; + } + + if (!compare_string_with_attr(pwd->pw_name, msg, SYSDB_NAME)) { + DEBUG(SSSDBG_TRACE_FUNC, ("Names differ.")); + return true; + } + if (!compare_string_with_attr(pwd->pw_gecos, msg, SYSDB_GECOS)) { + DEBUG(SSSDBG_TRACE_FUNC, ("Gecos fields differ.")); + return true; + } + + if (!compare_string_with_attr(pwd->pw_dir, msg, SYSDB_HOMEDIR)) { + DEBUG(SSSDBG_TRACE_FUNC, ("Home directories differ.")); + return true; + } + + if (!compare_string_with_attr(pwd->pw_shell, msg, SYSDB_SHELL)) { + DEBUG(SSSDBG_TRACE_FUNC, ("Shells differ.")); + return true; + } + + return false; +} -- cgit