]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3-netapi: allow to use default krb5 credential cache for libnetapi users.
authorGünther Deschner <gd@samba.org>
Mon, 26 Sep 2011 14:25:12 +0000 (16:25 +0200)
committerKarolin Seeger <kseeger@samba.org>
Mon, 26 Sep 2011 18:30:25 +0000 (20:30 +0200)
Guenther

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

index c04ca70249371c06e47372d3de8fb89188dbe3fb..dc42049b2424abf71aa31e1e79d269bcd783f822 100644 (file)
@@ -103,7 +103,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;
 
        frame = talloc_stackframe();
 
@@ -115,12 +114,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(frame, "MEMORY:libnetapi");
-               setenv(KRB5_ENV_CCNAME, ctx->krb5_cc_env, 1);
-       }
-
        if (getenv("USER")) {
                ctx->username = talloc_strdup(frame, getenv("USER"));
        } else {
@@ -266,6 +259,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 9e1549df0eb3ed0551bb618272917dd8c35abe8c..a55dc5e0b9bee8e38a7509274fc0a2199403e05f 100644 (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;
@@ -1408,6 +1409,11 @@ NET_API_STATUS libnetapi_set_use_kerberos(struct libnetapi_ctx *ctx);
 /****************************************************************
 ****************************************************************/
 
+NET_API_STATUS libnetapi_set_use_memory_krb5_ccache(struct libnetapi_ctx *ctx);
+
+/****************************************************************
+****************************************************************/
+
 NET_API_STATUS libnetapi_set_use_ccache(struct libnetapi_ctx *ctx);
 
 /****************************************************************