]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:libsmb: Pass cli_credentials to cli_cm_open()
authorAndreas Schneider <asn@samba.org>
Tue, 18 Aug 2020 15:26:54 +0000 (17:26 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 9 Oct 2020 19:16:46 +0000 (19:16 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/client/client.c
source3/lib/netapi/cm.c
source3/libsmb/clidfs.c
source3/libsmb/proto.h

index d5d5e157b29d2b041bbd3a6fb31f1e2a010f9b01..8575ef40904eab8131922d4aa18e52f353b89b31 100644 (file)
@@ -5545,6 +5545,8 @@ static int process_command_string(const char *cmd_in)
        TALLOC_CTX *ctx = talloc_tos();
        char *cmd = talloc_strdup(ctx, cmd_in);
        int rc = 0;
+       struct cli_credentials *creds =
+               get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
 
        if (!cmd) {
                return 1;
@@ -5556,7 +5558,8 @@ static int process_command_string(const char *cmd_in)
 
                status = cli_cm_open(talloc_tos(), NULL,
                                     desthost,
-                                    service, popt_get_cmdline_auth_info(),
+                                    service,
+                                    creds,
                                     max_protocol,
                                     have_ip ? &dest_ss : NULL, port,
                                     name_type,
@@ -5997,10 +6000,13 @@ static int process(const char *base_directory)
 {
        int rc = 0;
        NTSTATUS status;
+       struct cli_credentials *creds =
+               get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
 
        status = cli_cm_open(talloc_tos(), NULL,
                             desthost,
-                            service, popt_get_cmdline_auth_info(),
+                            service,
+                            creds,
                             max_protocol,
                             have_ip ? &dest_ss : NULL, port,
                             name_type, &cli);
@@ -6035,10 +6041,13 @@ static int process(const char *base_directory)
 static int do_host_query(const char *query_host)
 {
        NTSTATUS status;
+       struct cli_credentials *creds =
+               get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
 
        status = cli_cm_open(talloc_tos(), NULL,
                             query_host,
-                            "IPC$", popt_get_cmdline_auth_info(),
+                            "IPC$",
+                            creds,
                             max_protocol,
                             have_ip ? &dest_ss : NULL, port,
                             name_type, &cli);
@@ -6085,7 +6094,8 @@ static int do_host_query(const char *query_host)
                d_printf("Reconnecting with SMB1 for workgroup listing.\n");
                status = cli_cm_open(talloc_tos(), NULL,
                                     query_host,
-                                    "IPC$", popt_get_cmdline_auth_info(),
+                                    "IPC$",
+                                    creds,
                                     max_proto,
                                     have_ip ? &dest_ss : NULL, NBT_SMB_PORT,
                                     name_type, &cli);
@@ -6112,6 +6122,8 @@ static int do_tar_op(const char *base_directory)
 {
        struct tar *tar_ctx = tar_get_ctx();
        int ret = 0;
+       struct cli_credentials *creds =
+               get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
 
        /* do we already have a connection? */
        if (!cli) {
@@ -6119,7 +6131,8 @@ static int do_tar_op(const char *base_directory)
 
                status = cli_cm_open(talloc_tos(), NULL,
                                     desthost,
-                                    service, popt_get_cmdline_auth_info(),
+                                    service,
+                                    creds,
                                     max_protocol,
                                     have_ip ? &dest_ss : NULL, port,
                                     name_type, &cli);
index 0fd31ef3d5a3adf1a4c9eab777423f27d4dbb3ca..943f7498e8c8b6c641a413646ff8632db93177d4 100644 (file)
@@ -71,6 +71,7 @@ static WERROR libnetapi_open_ipc_connection(struct libnetapi_ctx *ctx,
        struct cli_state *cli_ipc = NULL;
        struct client_ipc_connection *p;
        NTSTATUS status;
+       struct cli_credentials *creds = NULL;
 
        if (!ctx || !pp || !server_name) {
                return WERR_INVALID_PARAMETER;
@@ -106,10 +107,11 @@ static WERROR libnetapi_open_ipc_connection(struct libnetapi_ctx *ctx,
        if (ctx->use_ccache) {
                set_cmdline_auth_info_use_ccache(auth_info, true);
        }
+       creds = get_cmdline_auth_info_creds(auth_info);
 
        status = cli_cm_open(ctx, NULL,
                             server_name, "IPC$",
-                            auth_info,
+                            creds,
                             lp_client_ipc_max_protocol(),
                             NULL, 0, 0x20, &cli_ipc);
        if (!NT_STATUS_IS_OK(status)) {
index a2c6f5fe5eca18ac9fe92b043d1cc50347ec731b..ef75fb36a45c5048888a2fd99b35f595c2b9666e 100644 (file)
@@ -384,19 +384,18 @@ static struct cli_state *cli_cm_find(struct cli_state *cli,
 ****************************************************************************/
 
 NTSTATUS cli_cm_open(TALLOC_CTX *ctx,
-                               struct cli_state *referring_cli,
-                               const char *server,
-                               const char *share,
-                               const struct user_auth_info *auth_info,
-                               int max_protocol,
-                               const struct sockaddr_storage *dest_ss,
-                               int port,
-                               int name_type,
-                               struct cli_state **pcli)
+                    struct cli_state *referring_cli,
+                    const char *server,
+                    const char *share,
+                    struct cli_credentials *creds,
+                    int max_protocol,
+                    const struct sockaddr_storage *dest_ss,
+                    int port,
+                    int name_type,
+                    struct cli_state **pcli)
 {
        /* Try to reuse an existing connection in this list. */
        struct cli_state *c = cli_cm_find(referring_cli, server, share);
-       struct cli_credentials *creds = get_cmdline_auth_info_creds(auth_info);
        NTSTATUS status;
 
        if (c) {
@@ -404,11 +403,11 @@ NTSTATUS cli_cm_open(TALLOC_CTX *ctx,
                return NT_STATUS_OK;
        }
 
-       if (auth_info == NULL) {
+       if (creds == NULL) {
                /* Can't do a new connection
                 * without auth info. */
                d_printf("cli_cm_open() Unable to open connection [\\%s\\%s] "
-                       "without auth info\n",
+                       "without client credentials\n",
                        server, share );
                return NT_STATUS_INVALID_PARAMETER;
        }
@@ -966,7 +965,7 @@ NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
                             rootcli,
                             smbXcli_conn_remote_name(rootcli->conn),
                             "IPC$",
-                            dfs_auth_info,
+                            creds,
                             smbXcli_conn_protocol(rootcli->conn),
                             NULL, /* dest_ss not needed, we reuse the transport */
                             0,
index e636fc96f501a18ecc204b1bb598c89ec6714ed3..c8b81a37c086f574c2b63bb359c889f3cf40bdc7 100644 (file)
@@ -124,15 +124,15 @@ struct cli_state *get_ipc_connect_master_ip(TALLOC_CTX *ctx,
 /* The following definitions come from libsmb/clidfs.c  */
 
 NTSTATUS cli_cm_open(TALLOC_CTX *ctx,
-                               struct cli_state *referring_cli,
-                               const char *server,
-                               const char *share,
-                               const struct user_auth_info *auth_info,
-                               int max_protocol,
-                               const struct sockaddr_storage *dest_ss,
-                               int port,
-                               int name_type,
-                               struct cli_state **pcli);
+                    struct cli_state *referring_cli,
+                    const char *server,
+                    const char *share,
+                    struct cli_credentials *creds,
+                    int max_protocol,
+                    const struct sockaddr_storage *dest_ss,
+                    int port,
+                    int name_type,
+                    struct cli_state **pcli);
 void cli_cm_display(struct cli_state *c);
 struct client_dfs_referral;
 NTSTATUS cli_dfs_get_referral_ex(TALLOC_CTX *ctx,