1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-13 13:18:06 +03:00

s3-netapi: allow to use default krb5 credential cache for libnetapi users.

Guenther
This commit is contained in:
Günther Deschner 2011-09-21 17:28:02 +02:00
parent 39dcf4bf02
commit a9a81648e9
2 changed files with 23 additions and 8 deletions

View File

@ -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,12 +268,29 @@ 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;
return NET_API_STATUS_SUCCESS;
}
/****************************************************************
****************************************************************/
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
****************************************************************/

View File

@ -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;
@ -1410,6 +1411,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
****************************************************************/