s3:libsmb: pass CLI_FULL_CONNECTION_* flags via cli_connect_nb()
authorStefan Metzmacher <metze@samba.org>
Wed, 7 Sep 2011 18:35:51 +0000 (20:35 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 8 Sep 2011 08:21:50 +0000 (10:21 +0200)
metze

Autobuild-User: Stefan Metzmacher <metze@samba.org>
Autobuild-Date: Thu Sep  8 10:21:50 CEST 2011 on sn-devel-104

14 files changed:
source3/auth/auth_server.c
source3/client/client.c
source3/libsmb/cliconnect.c
source3/libsmb/clidfs.c
source3/libsmb/libsmb_server.c
source3/libsmb/passchange.c
source3/libsmb/proto.h
source3/nmbd/nmbd_synclists.c
source3/torture/locktest.c
source3/torture/masktest.c
source3/torture/torture.c
source3/utils/net_rpc.c
source3/utils/net_time.c
source3/web/diagnose.c

index 4582d980c2d46cc9e0cc3a12ed17d3f8c1379e4e..1cc252400b285a94749df5706649812189fd8b30 100644 (file)
@@ -43,6 +43,8 @@ static struct cli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
        bool connected_ok = False;
        struct named_mutex *mutex = NULL;
        NTSTATUS status;
        bool connected_ok = False;
        struct named_mutex *mutex = NULL;
        NTSTATUS status;
+       /* security = server just can't function with spnego */
+       int flags = CLI_FULL_CONNECTION_DONT_SPNEGO;
 
         pserver = talloc_strdup(mem_ctx, lp_passwordserver());
        p = pserver;
 
         pserver = talloc_strdup(mem_ctx, lp_passwordserver());
        p = pserver;
@@ -85,7 +87,7 @@ static struct cli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
                }
 
                status = cli_connect_nb(desthost, &dest_ss, 0, 0x20,
                }
 
                status = cli_connect_nb(desthost, &dest_ss, 0, 0x20,
-                                       lp_netbios_name(), Undefined, &cli);
+                                       lp_netbios_name(), Undefined, flags, &cli);
                if (NT_STATUS_IS_OK(status)) {
                        DEBUG(3,("connected to password server %s\n",desthost));
                        connected_ok = True;
                if (NT_STATUS_IS_OK(status)) {
                        DEBUG(3,("connected to password server %s\n",desthost));
                        connected_ok = True;
@@ -101,9 +103,6 @@ static struct cli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
                return NULL;
        }
 
                return NULL;
        }
 
-       /* security = server just can't function with spnego */
-       cli->use_spnego = False;
-
        DEBUG(3,("got session\n"));
 
        status = cli_negprot(cli);
        DEBUG(3,("got session\n"));
 
        status = cli_negprot(cli);
index 110614ecd22e870996e0ce0e3da56f8b9281289f..30f8b8baf4a4f93742e772722987824bcace0839 100644 (file)
@@ -5230,7 +5230,7 @@ static int do_message_op(struct user_auth_info *a_info)
 
        status = cli_connect_nb(desthost, have_ip ? &dest_ss : NULL,
                                port ? port : 139, name_type,
 
        status = cli_connect_nb(desthost, have_ip ? &dest_ss : NULL,
                                port ? port : 139, name_type,
-                               lp_netbios_name(), Undefined, &cli);
+                               lp_netbios_name(), Undefined, 0, &cli);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("Connection to %s failed. Error %s\n", desthost, nt_errstr(status));
                return 1;
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("Connection to %s failed. Error %s\n", desthost, nt_errstr(status));
                return 1;
index e3e2bc4e0b50900c7b251b8f65b534fe1c7c40b1..58cf7a8e5856b4772b2cc1c7fe1fb5778007a3b5 100644 (file)
@@ -2846,7 +2846,7 @@ fail:
 
 NTSTATUS cli_connect_nb(const char *host, const struct sockaddr_storage *dest_ss,
                        uint16_t port, int name_type, const char *myname,
 
 NTSTATUS cli_connect_nb(const char *host, const struct sockaddr_storage *dest_ss,
                        uint16_t port, int name_type, const char *myname,
-                       int signing_state, struct cli_state **pcli)
+                       int signing_state, int flags, struct cli_state **pcli)
 {
        TALLOC_CTX *frame = talloc_stackframe();
        struct cli_state *cli;
 {
        TALLOC_CTX *frame = talloc_stackframe();
        struct cli_state *cli;
@@ -2854,7 +2854,6 @@ NTSTATUS cli_connect_nb(const char *host, const struct sockaddr_storage *dest_ss
        int fd = -1;
        char *desthost;
        char *p;
        int fd = -1;
        char *desthost;
        char *p;
-       int flags = 0;
 
        desthost = talloc_strdup(talloc_tos(), host);
        if (desthost == NULL) {
 
        desthost = talloc_strdup(talloc_tos(), host);
        if (desthost == NULL) {
@@ -2905,7 +2904,7 @@ NTSTATUS cli_start_connection(struct cli_state **output_cli,
        struct cli_state *cli;
 
        nt_status = cli_connect_nb(dest_host, dest_ss, port, 0x20, my_name,
        struct cli_state *cli;
 
        nt_status = cli_connect_nb(dest_host, dest_ss, port, 0x20, my_name,
-                                  signing_state, &cli);
+                                  signing_state, flags, &cli);
        if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(10, ("cli_connect_nb failed: %s\n",
                           nt_errstr(nt_status)));
        if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(10, ("cli_connect_nb failed: %s\n",
                           nt_errstr(nt_status)));
index a40ef896e8cabf2fdc8a631f28604327bd7274ff..68a6724d24244cff47da4fcba4f013ef4b3a6282 100644 (file)
@@ -95,6 +95,7 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
        const char *username;
        const char *password;
        NTSTATUS status;
        const char *username;
        const char *password;
        NTSTATUS status;
+       int flags = 0;
 
        /* make a copy so we don't modify the global string 'service' */
        servicename = talloc_strdup(ctx,share);
 
        /* make a copy so we don't modify the global string 'service' */
        servicename = talloc_strdup(ctx,share);
@@ -118,9 +119,20 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
                return NT_STATUS_INVALID_PARAMETER;
        }
 
                return NT_STATUS_INVALID_PARAMETER;
        }
 
+       if (get_cmdline_auth_info_use_kerberos(auth_info)) {
+               flags |= CLI_FULL_CONNECTION_USE_KERBEROS;
+       }
+       if (get_cmdline_auth_info_fallback_after_kerberos(auth_info)) {
+               flags |= CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS;
+       }
+       if (get_cmdline_auth_info_use_ccache(auth_info)) {
+               flags |= CLI_FULL_CONNECTION_USE_CCACHE;
+       }
+
        status = cli_connect_nb(
                server, NULL, port, name_type, NULL,
        status = cli_connect_nb(
                server, NULL, port, name_type, NULL,
-               get_cmdline_auth_info_signing_state(auth_info), &c);
+               get_cmdline_auth_info_signing_state(auth_info),
+               flags, &c);
 
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("Connection to %s failed (Error %s)\n",
 
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("Connection to %s failed (Error %s)\n",
@@ -133,10 +145,6 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
                max_protocol = PROTOCOL_NT1;
        }
        c->protocol = max_protocol;
                max_protocol = PROTOCOL_NT1;
        }
        c->protocol = max_protocol;
-       c->use_kerberos = get_cmdline_auth_info_use_kerberos(auth_info);
-       c->fallback_after_kerberos =
-               get_cmdline_auth_info_fallback_after_kerberos(auth_info);
-       c->use_ccache = get_cmdline_auth_info_use_ccache(auth_info);
 
        DEBUG(4,(" session request ok\n"));
 
 
        DEBUG(4,(" session request ok\n"));
 
index 6446252022fc80315792379044d3c4df82bd9d5f..005f2cdf8e8599d3741ec82894260b100a83c49a 100644 (file)
@@ -253,6 +253,7 @@ SMBC_server_internal(TALLOC_CTX *ctx,
         const char *username_used;
        NTSTATUS status;
        char *newserver, *newshare;
         const char *username_used;
        NTSTATUS status;
        char *newserver, *newshare;
+       int flags = 0;
 
        ZERO_STRUCT(c);
        *in_cache = false;
 
        ZERO_STRUCT(c);
        *in_cache = false;
@@ -401,13 +402,25 @@ SMBC_server_internal(TALLOC_CTX *ctx,
 
        status = NT_STATUS_UNSUCCESSFUL;
 
 
        status = NT_STATUS_UNSUCCESSFUL;
 
+       if (smbc_getOptionUseKerberos(context)) {
+               flags |= CLI_FULL_CONNECTION_USE_KERBEROS;
+       }
+
+       if (smbc_getOptionFallbackAfterKerberos(context)) {
+               flags |= CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS;
+       }
+
+       if (smbc_getOptionUseCCache(context)) {
+               flags |= CLI_FULL_CONNECTION_USE_CCACHE;
+       }
+
         if (share == NULL || *share == '\0' || is_ipc) {
                /*
                 * Try 139 first for IPC$
                 */
                status = cli_connect_nb(server_n, NULL, 139, 0x20,
                                        smbc_getNetbiosName(context),
         if (share == NULL || *share == '\0' || is_ipc) {
                /*
                 * Try 139 first for IPC$
                 */
                status = cli_connect_nb(server_n, NULL, 139, 0x20,
                                        smbc_getNetbiosName(context),
-                                       Undefined, &c);
+                                       Undefined, flags, &c);
        }
 
        if (!NT_STATUS_IS_OK(status)) {
        }
 
        if (!NT_STATUS_IS_OK(status)) {
@@ -416,7 +429,7 @@ SMBC_server_internal(TALLOC_CTX *ctx,
                 */
                status = cli_connect_nb(server_n, NULL, 0, 0x20,
                                        smbc_getNetbiosName(context),
                 */
                status = cli_connect_nb(server_n, NULL, 0, 0x20,
                                        smbc_getNetbiosName(context),
-                                       Undefined, &c);
+                                       Undefined, flags, &c);
        }
 
        if (!NT_STATUS_IS_OK(status)) {
        }
 
        if (!NT_STATUS_IS_OK(status)) {
@@ -424,18 +437,6 @@ SMBC_server_internal(TALLOC_CTX *ctx,
                return NULL;
        }
 
                return NULL;
        }
 
-        if (smbc_getOptionUseKerberos(context)) {
-               c->use_kerberos = True;
-       }
-
-        if (smbc_getOptionFallbackAfterKerberos(context)) {
-               c->fallback_after_kerberos = True;
-       }
-
-        if (smbc_getOptionUseCCache(context)) {
-               c->use_ccache = True;
-       }
-
        cli_set_timeout(c, smbc_getTimeout(context));
 
        status = cli_negprot(c);
        cli_set_timeout(c, smbc_getTimeout(context));
 
        status = cli_negprot(c);
index bf2103db6845179a80e5266d7cacf7db46191ebb..e5c336f8828e2dd9209ae9e6448ae545b4f82e70 100644 (file)
@@ -56,7 +56,7 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
        *err_str = NULL;
 
        result = cli_connect_nb(remote_machine, NULL, 0, 0x20, NULL,
        *err_str = NULL;
 
        result = cli_connect_nb(remote_machine, NULL, 0, 0x20, NULL,
-                               Undefined, &cli);
+                               Undefined, 0, &cli);
        if (!NT_STATUS_IS_OK(result)) {
                if (asprintf(err_str, "Unable to connect to SMB server on "
                         "machine %s. Error was : %s.\n",
        if (!NT_STATUS_IS_OK(result)) {
                if (asprintf(err_str, "Unable to connect to SMB server on "
                         "machine %s. Error was : %s.\n",
index 8ff0a1b2d6a8a5068f8a5fd36d80fdf6c3399916..83da457b53517a209c637b1e2fe525d002997527 100644 (file)
@@ -74,7 +74,7 @@ struct tevent_req *cli_negprot_send(TALLOC_CTX *mem_ctx,
 NTSTATUS cli_negprot_recv(struct tevent_req *req);
 NTSTATUS cli_connect_nb(const char *host, const struct sockaddr_storage *dest_ss,
                        uint16_t port, int name_type, const char *myname,
 NTSTATUS cli_negprot_recv(struct tevent_req *req);
 NTSTATUS cli_connect_nb(const char *host, const struct sockaddr_storage *dest_ss,
                        uint16_t port, int name_type, const char *myname,
-                       int signing_state, struct cli_state **pcli);
+                       int signing_state, int flags, struct cli_state **pcli);
 NTSTATUS cli_start_connection(struct cli_state **output_cli,
                              const char *my_name,
                              const char *dest_host,
 NTSTATUS cli_start_connection(struct cli_state **output_cli,
                              const char *my_name,
                              const char *dest_host,
index 964975e1a525e6d659d9ab940deb8310e459ae21..a5fd35669276526108f7ed3f267808002a0f07ef 100644 (file)
@@ -82,7 +82,7 @@ static void sync_child(char *name, int nm_type,
        in_addr_to_sockaddr_storage(&ss, ip);
 
        status = cli_connect_nb(name, &ss, 139, nm_type,
        in_addr_to_sockaddr_storage(&ss, ip);
 
        status = cli_connect_nb(name, &ss, 139, nm_type,
-                               get_local_machine_name(), Undefined,
+                               get_local_machine_name(), Undefined, 0,
                                &cli);
        if (!NT_STATUS_IS_OK(status)) {
                return;
                                &cli);
        if (!NT_STATUS_IS_OK(status)) {
                return;
index d6c544d8e829bb31cc5467e4e474df29aedb1bfb..da3b9a7cdf8f131ea65217a01202227c1241e519 100644 (file)
@@ -169,6 +169,7 @@ static struct cli_state *connect_one(char *share, int snum)
        fstring myname;
        static int count;
        NTSTATUS status;
        fstring myname;
        static int count;
        NTSTATUS status;
+       int flags = 0;
 
        fstrcpy(server,share+2);
        share = strchr_m(server,'\\');
 
        fstrcpy(server,share+2);
        share = strchr_m(server,'\\');
@@ -182,16 +183,21 @@ static struct cli_state *connect_one(char *share, int snum)
 
        /* have to open a new connection */
 
 
        /* have to open a new connection */
 
-       status = cli_connect_nb(server_n, NULL, 0, 0x20, myname, Undefined,
-                               &c);
+       if (use_kerberos) {
+               flags |= CLI_FULL_CONNECTION_USE_KERBEROS;
+       }
+       if (use_oplocks) {
+               flags |= CLI_FULL_CONNECTION_OPLOCKS;
+       }
+
+       status = cli_connect_nb(server_n, NULL, 0, 0x20, myname,
+                               Undefined, flags, &c);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("Connection to %s failed. Error %s\n", server_n,
                          nt_errstr(status)));
                return NULL;
        }
 
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("Connection to %s failed. Error %s\n", server_n,
                          nt_errstr(status)));
                return NULL;
        }
 
-       c->use_kerberos = use_kerberos;
-
        status = cli_negprot(c);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("protocol negotiation failed: %s\n",
        status = cli_negprot(c);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("protocol negotiation failed: %s\n",
@@ -246,8 +252,6 @@ static struct cli_state *connect_one(char *share, int snum)
 
        DEBUG(4,(" tconx ok\n"));
 
 
        DEBUG(4,(" tconx ok\n"));
 
-       c->use_oplocks = use_oplocks;
-
        return c;
 }
 
        return c;
 }
 
index 05f9c60806a9d0dcc8b0f886973b17f9ff967e7a..6a4bb6e1d1e925bb8c4087da5d162ec8e4590e15 100644 (file)
@@ -179,7 +179,7 @@ static struct cli_state *connect_one(char *share)
 
        server_n = server;
 
 
        server_n = server;
 
-       status = cli_connect_nb(server, NULL, 0, 0x20, "masktest", Undefined,
+       status = cli_connect_nb(server, NULL, 0, 0x20, "masktest", Undefined, 0,
                                &c);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("Connection to %s failed. Error %s\n", server_n,
                                &c);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("Connection to %s failed. Error %s\n", server_n,
index f07026d17ac94a7d7337830e6745b8a83d1fe949..495875b27ac55c92328945bb6edfbaf30738d050 100644 (file)
@@ -181,19 +181,28 @@ static struct cli_state *open_nbt_connection(void)
 {
        struct cli_state *c;
        NTSTATUS status;
 {
        struct cli_state *c;
        NTSTATUS status;
+       int flags = 0;
+
+       if (use_oplocks) {
+               flags |= CLI_FULL_CONNECTION_OPLOCKS;
+       }
+
+       if (use_level_II_oplocks) {
+               flags |= CLI_FULL_CONNECTION_LEVEL_II_OPLOCKS;
+       }
+
+       if (use_kerberos) {
+               flags |= CLI_FULL_CONNECTION_USE_KERBEROS;
+       }
 
        status = cli_connect_nb(host, NULL, port_to_use, 0x20, myname,
 
        status = cli_connect_nb(host, NULL, port_to_use, 0x20, myname,
-                               signing_state, &c);
+                               signing_state, flags, &c);
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to connect with %s. Error %s\n", host, nt_errstr(status) );
                return NULL;
        }
 
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to connect with %s. Error %s\n", host, nt_errstr(status) );
                return NULL;
        }
 
-       c->use_kerberos = use_kerberos;
-
        cli_set_timeout(c, 120000); /* set a really long timeout (2 minutes) */
        cli_set_timeout(c, 120000); /* set a really long timeout (2 minutes) */
-       if (use_oplocks) c->use_oplocks = True;
-       if (use_level_II_oplocks) c->use_level_II_oplocks = True;
 
        return c;
 }
 
        return c;
 }
@@ -3545,18 +3554,12 @@ static bool run_oplock2(int dummy)
                return False;
        }
 
                return False;
        }
 
-       cli1->use_oplocks = True;
-       cli1->use_level_II_oplocks = True;
-
        if (!torture_open_connection(&cli2, 1)) {
                use_level_II_oplocks = False;
                use_oplocks = saved_use_oplocks;
                return False;
        }
 
        if (!torture_open_connection(&cli2, 1)) {
                use_level_II_oplocks = False;
                use_oplocks = saved_use_oplocks;
                return False;
        }
 
-       cli2->use_oplocks = True;
-       cli2->use_level_II_oplocks = True;
-
        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
 
        cli_sockopt(cli1, sockops);
        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
 
        cli_sockopt(cli1, sockops);
index 04e6e687e3e4b2bbc91abcc36bf232f60295eb99..9ed4ead2f2f159190952407628f8885c6b844267 100644 (file)
@@ -7092,7 +7092,7 @@ bool net_rpc_check(struct net_context *c, unsigned flags)
                return false;
 
        status = cli_connect_nb(server_name, &server_ss, 0, 0x20,
                return false;
 
        status = cli_connect_nb(server_name, &server_ss, 0, 0x20,
-                               lp_netbios_name(), Undefined, &cli);
+                               lp_netbios_name(), Undefined, 0, &cli);
        if (!NT_STATUS_IS_OK(status)) {
                return false;
        }
        if (!NT_STATUS_IS_OK(status)) {
                return false;
        }
index cc97412a8d047eeba23160b35b8c19a3f6a00aa7..6fc3f96f65480d529f1d520ea463e83700b4953a 100644 (file)
@@ -33,7 +33,7 @@ static time_t cli_servertime(const char *host,
        NTSTATUS status;
 
        status = cli_connect_nb(host, dest_ss, 0, 0x20, lp_netbios_name(),
        NTSTATUS status;
 
        status = cli_connect_nb(host, dest_ss, 0, 0x20, lp_netbios_name(),
-                               Undefined, &cli);
+                               Undefined, 0, &cli);
        if (!NT_STATUS_IS_OK(status)) {
                fprintf(stderr, _("Can't contact server %s. Error %s\n"),
                        host, nt_errstr(status));
        if (!NT_STATUS_IS_OK(status)) {
                fprintf(stderr, _("Can't contact server %s. Error %s\n"),
                        host, nt_errstr(status));
index abb4d79b9a7a78b8893a9ccb7fe93b9aeb3b0233..d840f2360621749d5aa660e1bef1e40b94719091 100644 (file)
@@ -71,7 +71,7 @@ bool smbd_running(void)
        in_addr_to_sockaddr_storage(&ss, loopback_ip);
 
        status = cli_connect_nb("localhost", &ss, 0, 0x20, lp_netbios_name(),
        in_addr_to_sockaddr_storage(&ss, loopback_ip);
 
        status = cli_connect_nb("localhost", &ss, 0, 0x20, lp_netbios_name(),
-                               Undefined, &cli);
+                               Undefined, 0, &cli);
        if (!NT_STATUS_IS_OK(status)) {
                return false;
        }
        if (!NT_STATUS_IS_OK(status)) {
                return false;
        }