s3-netapi: allow to use default krb5 credential cache for libnetapi users.
authorGünther Deschner <gd@samba.org>
Wed, 21 Sep 2011 15:47:27 +0000 (17:47 +0200)
committerKarolin Seeger <kseeger@samba.org>
Mon, 26 Sep 2011 18:31:02 +0000 (20:31 +0200)
Guenther

source3/lib/netapi/netapi.c
source3/lib/netapi/netapi.h

index bde6fd823fdd203acf403bc5f64324fb43993c7d..34a88a9de57295423a955e68204f93d04208ca44 100644 (file)
@@ -55,7 +55,6 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
 {
        NET_API_STATUS status;
        struct libnetapi_ctx *ctx = NULL;
-       char *krb5_cc_env = NULL;
 
        if (stat_ctx && libnetapi_initialized) {
                *context = stat_ctx;
@@ -101,12 +100,6 @@ NET_API_STATUS libnetapi_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(frame, "MEMORY:libnetapi");
-               setenv(KRB5_ENV_CCNAME, ctx->krb5_cc_env, 1);
-       }
-
        if (getenv("USER")) {
                ctx->username = talloc_strdup(frame, getenv("USER"));
        } else {
@@ -250,6 +243,23 @@ NET_API_STATUS libnetapi_set_use_kerberos(struct libnetapi_ctx *ctx)
        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;
+}
+
+/****************************************************************
+****************************************************************/
+
 NET_API_STATUS libnetapi_set_use_ccache(struct libnetapi_ctx *ctx)
 {
        ctx->use_ccache = true;
index 8976ebd4ebddc74a13a0e1ea484dde610d14485f..069d526f4b55ce9020f03a5e38576486b47d27a6 100644 (file)
@@ -1319,6 +1319,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;
@@ -1376,6 +1377,11 @@ NET_API_STATUS libnetapi_set_use_ccache(struct libnetapi_ctx *ctx);
 /****************************************************************
 ****************************************************************/
 
+NET_API_STATUS libnetapi_set_use_memory_krb5_ccache(struct libnetapi_ctx *ctx);
+
+/****************************************************************
+****************************************************************/
+
 const char *libnetapi_errstr(NET_API_STATUS status);
 
 /****************************************************************