diff options
author | Andrew Bartlett <abartlet@samba.org> | 2017-02-20 13:32:47 +1300 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2017-03-29 02:37:25 +0200 |
commit | 2d6066dbbfe8f10b95675eedd0f47c492cf29029 (patch) | |
tree | 1062c0b6a8465ace06326dabbb27977234203d9f /auth | |
parent | 9e09e68d4777a722759262e877d443d6bb93b592 (diff) | |
download | samba-2d6066dbbfe8f10b95675eedd0f47c492cf29029.tar.gz |
gensec: Add gensec_{get,set}_target_service_description()
This allows a free text description of what the server-side service is for logging
purposes where the various services may be using the same Kerberos service or not
use Kerberos.
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Pair-Programmed-by: Gary Lockyer <gary@catalyst.net.nz>
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Diffstat (limited to 'auth')
-rw-r--r-- | auth/gensec/gensec.c | 29 | ||||
-rw-r--r-- | auth/gensec/gensec.h | 17 |
2 files changed, 46 insertions, 0 deletions
diff --git a/auth/gensec/gensec.c b/auth/gensec/gensec.c index d6236137691..e413fbdfd6f 100644 --- a/auth/gensec/gensec.c +++ b/auth/gensec/gensec.c @@ -574,6 +574,7 @@ _PUBLIC_ struct cli_credentials *gensec_get_credentials(struct gensec_security * /** * Set the target service (such as 'http' or 'host') on a GENSEC context - ensures it is talloc()ed * + * This is used for Kerberos service principal name resolution. */ _PUBLIC_ NTSTATUS gensec_set_target_service(struct gensec_security *gensec_security, const char *service) @@ -595,6 +596,34 @@ _PUBLIC_ const char *gensec_get_target_service(struct gensec_security *gensec_se } /** + * Set the target service (such as 'samr') on an GENSEC context - ensures it is talloc()ed. + * + * This is not the Kerberos service principal, instead this is a + * constant value that can be logged as part of authentication and + * authorization logging + */ +_PUBLIC_ NTSTATUS gensec_set_target_service_description(struct gensec_security *gensec_security, + const char *service) +{ + gensec_security->target.service_description = talloc_strdup(gensec_security, service); + if (!gensec_security->target.service_description) { + return NT_STATUS_NO_MEMORY; + } + return NT_STATUS_OK; +} + +_PUBLIC_ const char *gensec_get_target_service_description(struct gensec_security *gensec_security) +{ + if (gensec_security->target.service_description) { + return gensec_security->target.service_description; + } else if (gensec_security->target.service) { + return gensec_security->target.service; + } + + return NULL; +} + +/** * Set the target hostname (suitable for kerberos resolutation) on a GENSEC context - ensures it is talloc()ed * */ diff --git a/auth/gensec/gensec.h b/auth/gensec/gensec.h index e8bd7b1f22a..0c9fa2661a8 100644 --- a/auth/gensec/gensec.h +++ b/auth/gensec/gensec.h @@ -50,6 +50,7 @@ struct gensec_target { const char *principal; const char *hostname; const char *service; + const char *service_description; }; #define GENSEC_FEATURE_SESSION_KEY 0x00000001 @@ -145,10 +146,26 @@ bool gensec_have_feature(struct gensec_security *gensec_security, uint32_t feature); NTTIME gensec_expire_time(struct gensec_security *gensec_security); NTSTATUS gensec_set_credentials(struct gensec_security *gensec_security, struct cli_credentials *credentials); +/** + * Set the target service (such as 'http' or 'host') on a GENSEC context - ensures it is talloc()ed + * + * This is used for Kerberos service principal name resolution. + */ + NTSTATUS gensec_set_target_service(struct gensec_security *gensec_security, const char *service); const char *gensec_get_target_service(struct gensec_security *gensec_security); NTSTATUS gensec_set_target_hostname(struct gensec_security *gensec_security, const char *hostname); const char *gensec_get_target_hostname(struct gensec_security *gensec_security); +/** + * Set the target service (such as 'samr') on an GENSEC context - ensures it is talloc()ed. + * + * This is not the Kerberos service principal, instead this is a + * constant value that can be logged as part of authentication and + * authorization logging + */ +const char *gensec_get_target_service_description(struct gensec_security *gensec_security); +NTSTATUS gensec_set_target_service_description(struct gensec_security *gensec_security, + const char *service); NTSTATUS gensec_session_key(struct gensec_security *gensec_security, TALLOC_CTX *mem_ctx, DATA_BLOB *session_key); |