From: Stefan Metzmacher Date: Mon, 22 May 2017 10:10:45 +0000 (+0200) Subject: s3:secrets: split out a domain_guid_keystr() function X-Git-Tag: tdb-1.3.14~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d37e30cef7906b7b2b14351ad81d0d884811557b;p=thirdparty%2Fsamba.git s3:secrets: split out a domain_guid_keystr() function BUG: https://bugzilla.samba.org/show_bug.cgi?id=12782 Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- diff --git a/source3/passdb/machine_account_secrets.c b/source3/passdb/machine_account_secrets.c index 114bed64d5f..060babf4828 100644 --- a/source3/passdb/machine_account_secrets.c +++ b/source3/passdb/machine_account_secrets.c @@ -51,6 +51,16 @@ static const char *domain_sid_keystr(const char *domain) return keystr; } +static const char *domain_guid_keystr(const char *domain) +{ + char *keystr; + + keystr = talloc_asprintf_strupper_m(talloc_tos(), "%s/%s", + SECRETS_DOMAIN_GUID, domain); + SMB_ASSERT(keystr != NULL); + return keystr; +} + static const char *protect_ids_keystr(const char *domain) { char *keystr; @@ -139,7 +149,7 @@ bool secrets_fetch_domain_sid(const char *domain, struct dom_sid *sid) bool secrets_store_domain_guid(const char *domain, struct GUID *guid) { char *protect_ids; - fstring key; + const char *key; protect_ids = secrets_fetch(protect_ids_keystr(domain), NULL); if (protect_ids) { @@ -152,24 +162,18 @@ bool secrets_store_domain_guid(const char *domain, struct GUID *guid) } SAFE_FREE(protect_ids); - slprintf(key, sizeof(key)-1, "%s/%s", SECRETS_DOMAIN_GUID, domain); - if (!strupper_m(key)) { - return false; - } + key = domain_guid_keystr(domain); return secrets_store(key, guid, sizeof(struct GUID)); } bool secrets_fetch_domain_guid(const char *domain, struct GUID *guid) { struct GUID *dyn_guid; - fstring key; + const char *key; size_t size = 0; struct GUID new_guid; - slprintf(key, sizeof(key)-1, "%s/%s", SECRETS_DOMAIN_GUID, domain); - if (!strupper_m(key)) { - return false; - } + key = domain_guid_keystr(domain); dyn_guid = (struct GUID *)secrets_fetch(key, &size); if (!dyn_guid) {