dsdb: refactor password attibutes to constant
authorGary Lockyer <gary@catalyst.net.nz>
Tue, 3 Apr 2018 23:55:00 +0000 (11:55 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 10 May 2018 18:02:22 +0000 (20:02 +0200)
The password attributes are defined as literal in two places in the
password_hash code.  They will also be needed to support password change
logging. This patch replaces the individual definitions with a shared
constant.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/common/util.h
source4/dsdb/samdb/ldb_modules/password_hash.c

index ede6d8b0763569b3f8c3791c7c6bcbd36dd2d155..85fabde3c2969ff5fbc8fbd428cc2c8447f66e2d 100644 (file)
@@ -65,6 +65,12 @@ bool is_attr_in_list(const char * const * attrs, const char *attr);
 #define DSDB_SECRET_ATTRIBUTES_COMMA ,
 #define DSDB_SECRET_ATTRIBUTES DSDB_SECRET_ATTRIBUTES_EX(DSDB_SECRET_ATTRIBUTES_COMMA)
 
+#define DSDB_PASSWORD_ATTRIBUTES \
+       "userPassword", \
+       "clearTextPassword", \
+       "unicodePwd", \
+       "dBCSPwd"
+
 struct GUID;
 
 char *NS_GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid);
index 146fb6fa2c35c306e94562201fecc4376848d5c7..2641cb9c064f9bb44ba50d04381a779c5c1cc5dd 100644 (file)
@@ -4008,10 +4008,7 @@ static int password_hash_needed(struct ldb_module *module,
        const struct ldb_message *msg = NULL;
        struct ph_context *ac = NULL;
        const char *passwordAttrs[] = {
-               "userPassword",
-               "clearTextPassword",
-               "unicodePwd",
-               "dBCSPwd",
+               DSDB_PASSWORD_ATTRIBUTES,
                NULL
        };
        const char **a = NULL;
@@ -4242,8 +4239,7 @@ static int password_hash_modify(struct ldb_module *module, struct ldb_request *r
 {
        struct ldb_context *ldb = ldb_module_get_ctx(module);
        struct ph_context *ac = NULL;
-       const char *passwordAttrs[] = { "userPassword", "clearTextPassword",
-               "unicodePwd", "dBCSPwd", NULL }, **l;
+       const char *passwordAttrs[] = {DSDB_PASSWORD_ATTRIBUTES, NULL}, **l;
        unsigned int del_attr_cnt, add_attr_cnt, rep_attr_cnt;
        struct ldb_message_element *passwordAttr;
        struct ldb_message *msg;