diff options
author | Andreas Schneider <asn@samba.org> | 2021-03-18 10:43:26 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2021-03-24 00:55:32 +0000 |
commit | 7bb70f701e49e11d41583369737522f3db9b9382 (patch) | |
tree | 24df03e82e4b29d7e76b4c5d5b227b4e309834f2 /source3/lib/netapi | |
parent | 517f94f5bff154bb73b46645c0beb74350450cb1 (diff) | |
download | samba-7bb70f701e49e11d41583369737522f3db9b9382.tar.gz |
s3:netapi: Add a cli_credentials pointer to struct libnetapi_ctx
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Diffstat (limited to 'source3/lib/netapi')
-rw-r--r-- | source3/lib/netapi/netapi.c | 17 | ||||
-rw-r--r-- | source3/lib/netapi/netapi_private.h | 3 |
2 files changed, 20 insertions, 0 deletions
diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index 4c8a96e2e70..591523edfe0 100644 --- a/source3/lib/netapi/netapi.c +++ b/source3/lib/netapi/netapi.c @@ -23,6 +23,8 @@ #include "lib/netapi/netapi_private.h" #include "secrets.h" #include "krb5_env.h" +#include "source3/param/loadparm.h" +#include "lib/param/param.h" struct libnetapi_ctx *stat_ctx = NULL; static bool libnetapi_initialized = false; @@ -104,6 +106,7 @@ NET_API_STATUS libnetapi_net_init(struct libnetapi_ctx **context) NET_API_STATUS status; struct libnetapi_ctx *ctx = NULL; TALLOC_CTX *frame = talloc_stackframe(); + struct loadparm_context *lp_ctx = NULL; ctx = talloc_zero(frame, struct libnetapi_ctx); if (!ctx) { @@ -111,8 +114,22 @@ NET_API_STATUS libnetapi_net_init(struct libnetapi_ctx **context) return W_ERROR_V(WERR_NOT_ENOUGH_MEMORY); } + ctx->creds = cli_credentials_init(ctx); + if (ctx->creds == NULL) { + TALLOC_FREE(frame); + return W_ERROR_V(WERR_NOT_ENOUGH_MEMORY); + } + + lp_ctx = loadparm_init_s3(frame, loadparm_s3_helpers()); + if (lp_ctx == NULL) { + TALLOC_FREE(frame); + return W_ERROR_V(WERR_NOT_ENOUGH_MEMORY); + } + BlockSignals(True, SIGPIPE); + cli_credentials_guess(ctx->creds, lp_ctx); + if (getenv("USER")) { ctx->username = talloc_strdup(ctx, getenv("USER")); } else { diff --git a/source3/lib/netapi/netapi_private.h b/source3/lib/netapi/netapi_private.h index 67cf8961e7b..ba2f8bb2651 100644 --- a/source3/lib/netapi/netapi_private.h +++ b/source3/lib/netapi/netapi_private.h @@ -21,6 +21,7 @@ #define __LIB_NETAPI_PRIVATE_H__ #include "lib/netapi/netapi_net.h" +#include "auth/credentials/credentials.h" #define LIBNETAPI_REDIRECT_TO_LOCALHOST(ctx, r, fn) \ DEBUG(10,("redirecting call %s to localhost\n", #fn)); \ @@ -63,6 +64,8 @@ struct libnetapi_ctx { int use_ccache; int disable_policy_handle_cache; + struct cli_credentials *creds; + void *private_data; }; |