s3:netapi: Get rid of set_cmdline_auth_info_*()
authorAndreas Schneider <asn@samba.org>
Thu, 18 Mar 2021 12:49:27 +0000 (13:49 +0100)
committerGünther Deschner <gd@samba.org>
Wed, 24 Mar 2021 00:55:32 +0000 (00:55 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
source3/lib/netapi/cm.c
source3/wscript_build

index 29b35af7d3d8ae3d2e77d307550ce3cbf3156641..a2468de4ccccdb37d61dc97c1ee5ba1cf9f97edc 100644 (file)
@@ -25,7 +25,6 @@
 #include "libsmb/libsmb.h"
 #include "rpc_client/cli_pipe.h"
 #include "../libcli/smb/smbXcli_base.h"
-#include "auth/gensec/gensec.h"
 
 /********************************************************************
 ********************************************************************/
@@ -68,16 +67,13 @@ static WERROR libnetapi_open_ipc_connection(struct libnetapi_ctx *ctx,
                                            struct client_ipc_connection **pp)
 {
        struct libnetapi_private_ctx *priv_ctx;
-       struct user_auth_info *auth_info = NULL;
        struct cli_state *cli_ipc = NULL;
        struct client_ipc_connection *p;
        NTSTATUS status;
-       struct cli_credentials *creds = NULL;
        const char *username = NULL;
        const char *password = NULL;
        NET_API_STATUS rc;
        enum credentials_use_kerberos krb5_state;
-       uint32_t gensec_features;
 
        if (!ctx || !pp || !server_name) {
                return WERR_INVALID_PARAMETER;
@@ -91,54 +87,35 @@ static WERROR libnetapi_open_ipc_connection(struct libnetapi_ctx *ctx,
                return WERR_OK;
        }
 
-       auth_info = user_auth_info_init(ctx);
-       if (!auth_info) {
-               return WERR_NOT_ENOUGH_MEMORY;
-       }
-
        rc = libnetapi_get_username(ctx, &username);
        if (rc != 0) {
-               TALLOC_FREE(auth_info);
                return WERR_INTERNAL_ERROR;
        }
 
        rc = libnetapi_get_password(ctx, &password);
        if (rc != 0) {
-               TALLOC_FREE(auth_info);
                return WERR_INTERNAL_ERROR;
        }
 
-       krb5_state = cli_credentials_get_kerberos_state(ctx->creds);
-       gensec_features = cli_credentials_get_gensec_features(ctx->creds);
-
-       set_cmdline_auth_info_signing_state_raw(auth_info, SMB_SIGNING_IPC_DEFAULT);
-       set_cmdline_auth_info_use_kerberos(auth_info, krb5_state == CRED_USE_KERBEROS_REQUIRED);
-       set_cmdline_auth_info_username(auth_info, username);
-       if (password != NULL) {
-               set_cmdline_auth_info_password(auth_info, password);
-       } else {
-               set_cmdline_auth_info_getpass(auth_info);
+       if (password == NULL) {
+               cli_credentials_set_cmdline_callbacks(ctx->creds);
        }
 
-       if (username && username[0] &&
-           password && password[0] &&
-           krb5_state == CRED_USE_KERBEROS_REQUIRED) {
-               set_cmdline_auth_info_fallback_after_kerberos(auth_info, true);
-       }
+       krb5_state = cli_credentials_get_kerberos_state(ctx->creds);
 
-       if (gensec_features & GENSEC_FEATURE_NTLM_CCACHE) {
-               set_cmdline_auth_info_use_ccache(auth_info, true);
+       if (username != NULL && username[0] != '\0' &&
+           password != NULL && password[0] != '\0' &&
+           krb5_state == CRED_USE_KERBEROS_REQUIRED) {
+               cli_credentials_set_kerberos_state(ctx->creds, CRED_USE_KERBEROS_DESIRED);
        }
-       creds = get_cmdline_auth_info_creds(auth_info);
 
        status = cli_cm_open(ctx, NULL,
                             server_name, "IPC$",
-                            creds,
+                            ctx->creds,
                             NULL, 0, 0x20, &cli_ipc);
        if (!NT_STATUS_IS_OK(status)) {
                cli_ipc = NULL;
        }
-       TALLOC_FREE(auth_info);
 
        if (!cli_ipc) {
                libnetapi_set_error_string(ctx,
index fcf5c1e164ee1854392fe3c4b323ee21d0f1c3c9..9cd351b2b5d2592fa0b812897fbd86cd3371d30c 100644 (file)
@@ -27,9 +27,9 @@ bld.SAMBA3_LIBRARY('netapi',
                     lib/netapi/file.c
                     lib/netapi/shutdown.c
                     lib/netapi/netlogon.c''',
+                    deps='CREDENTIALS_CMDLINE',
                     public_deps='''
                     talloc
-                    util_cmdline
                     msrpc3
                     ads
                     NDR_LIBNETAPI