diff options
author | Günther Deschner <gd@samba.org> | 2011-09-21 17:28:02 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2011-09-21 17:39:08 +0200 |
commit | a9a81648e974b62e67fe42313ab32024d72d9007 (patch) | |
tree | a2180b5e57b8bba665d992990703c47ca69697e1 | |
parent | 39dcf4bf02d13201b2da11f4b9fd3b972da87c80 (diff) | |
download | samba-a9a81648e974b62e67fe42313ab32024d72d9007.tar.gz samba-a9a81648e974b62e67fe42313ab32024d72d9007.tar.bz2 samba-a9a81648e974b62e67fe42313ab32024d72d9007.zip |
s3-netapi: allow to use default krb5 credential cache for libnetapi users.
Guenther
-rw-r--r-- | source3/lib/netapi/netapi.c | 25 | ||||
-rw-r--r-- | source3/lib/netapi/netapi.h | 6 |
2 files changed, 23 insertions, 8 deletions
diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index a4a8e447c1..9ed13fcc71 100644 --- a/source3/lib/netapi/netapi.c +++ b/source3/lib/netapi/netapi.c @@ -106,8 +106,6 @@ NET_API_STATUS libnetapi_net_init(struct libnetapi_ctx **context) { NET_API_STATUS status; struct libnetapi_ctx *ctx = NULL; - char *krb5_cc_env = NULL; - TALLOC_CTX *frame = talloc_stackframe(); ctx = talloc_zero(frame, struct libnetapi_ctx); @@ -118,12 +116,6 @@ NET_API_STATUS libnetapi_net_init(struct libnetapi_ctx **context) BlockSignals(True, SIGPIPE); - krb5_cc_env = getenv(KRB5_ENV_CCNAME); - if (!krb5_cc_env || (strlen(krb5_cc_env) == 0)) { - ctx->krb5_cc_env = talloc_strdup(ctx, "MEMORY:libnetapi"); - setenv(KRB5_ENV_CCNAME, ctx->krb5_cc_env, 1); - } - if (getenv("USER")) { ctx->username = talloc_strdup(ctx, getenv("USER")); } else { @@ -276,6 +268,9 @@ NET_API_STATUS libnetapi_set_use_kerberos(struct libnetapi_ctx *ctx) return NET_API_STATUS_SUCCESS; } +/**************************************************************** +****************************************************************/ + NET_API_STATUS libnetapi_set_use_ccache(struct libnetapi_ctx *ctx) { ctx->use_ccache = true; @@ -283,6 +278,20 @@ NET_API_STATUS libnetapi_set_use_ccache(struct libnetapi_ctx *ctx) } /**************************************************************** +****************************************************************/ + +NET_API_STATUS libnetapi_set_use_memory_krb5_ccache(struct libnetapi_ctx *ctx) +{ + ctx->krb5_cc_env = talloc_strdup(ctx, "MEMORY:libnetapi"); + if (!ctx->krb5_cc_env) { + return W_ERROR_V(WERR_NOMEM); + } + setenv(KRB5_ENV_CCNAME, ctx->krb5_cc_env, 1); + ctx->use_memory_krb5_ccache = 1; + return NET_API_STATUS_SUCCESS; +} + +/**************************************************************** Return a libnetapi error as a string, caller must free with NetApiBufferFree ****************************************************************/ diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h index 620d8cf591..2a52321415 100644 --- a/source3/lib/netapi/netapi.h +++ b/source3/lib/netapi/netapi.h @@ -1356,6 +1356,7 @@ struct libnetapi_ctx { char *krb5_cc_env; int use_kerberos; int use_ccache; + int use_memory_krb5_ccache; int disable_policy_handle_cache; void *private_data; @@ -1411,6 +1412,11 @@ NET_API_STATUS libnetapi_set_use_kerberos(struct libnetapi_ctx *ctx); NET_API_STATUS libnetapi_set_use_ccache(struct libnetapi_ctx *ctx); /**************************************************************** +****************************************************************/ + +NET_API_STATUS libnetapi_set_use_memory_krb5_ccache(struct libnetapi_ctx *ctx); + +/**************************************************************** Return a specific libnetapi error as a string, caller must free with NetApiBufferFree ****************************************************************/ |