From: Gary Lockyer Date: Tue, 3 Apr 2018 23:55:00 +0000 (+1200) Subject: dsdb: refactor password attibutes to constant X-Git-Tag: ldb-1.4.0~374 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=79ba530aaf76be639143530ab6e28d1e3696dfd2;p=thirdparty%2Fsamba.git dsdb: refactor password attibutes to constant 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 Reviewed-by: Andrew Bartlett --- diff --git a/source4/dsdb/common/util.h b/source4/dsdb/common/util.h index ede6d8b0763..85fabde3c29 100644 --- a/source4/dsdb/common/util.h +++ b/source4/dsdb/common/util.h @@ -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); diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c index 146fb6fa2c3..2641cb9c064 100644 --- a/source4/dsdb/samdb/ldb_modules/password_hash.c +++ b/source4/dsdb/samdb/ldb_modules/password_hash.c @@ -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;