Just hardcode workgroup to empty string, to avoid use of
[kai/samba.git] / source4 / libcli / raw / clitree.c
index cae93bdbe2fb6960dfb70d8ab439c571e2f322a8..ccfb28b84dba9b42fcc896388652443e23204d50 100644 (file)
@@ -8,7 +8,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
 #include "libcli/raw/libcliraw.h"
-#include "libcli/composite/composite.h"
+#include "libcli/raw/raw_proto.h"
 #include "libcli/smb_composite/smb_composite.h"
+#include "param/param.h"
 
 #define SETUP_REQUEST_TREE(cmd, wct, buflen) do { \
        req = smbcli_request_setup(tree, cmd, wct, buflen); \
@@ -34,8 +34,8 @@
 /****************************************************************************
  Initialize the tree context
 ****************************************************************************/
-struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session,
-                                    TALLOC_CTX *parent_ctx, BOOL primary)
+_PUBLIC_ struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session,
+                                    TALLOC_CTX *parent_ctx, bool primary)
 {
        struct smbcli_tree *tree;
 
@@ -80,6 +80,9 @@ struct smbcli_request *smb_raw_tcon_send(struct smbcli_tree *tree,
                smbcli_req_append_string(req, parms->tconx.in.path,   STR_TERMINATE | STR_UPPER);
                smbcli_req_append_string(req, parms->tconx.in.device, STR_TERMINATE | STR_ASCII);
                break;
+
+       case RAW_TCON_SMB2:
+               return NULL;
        }
 
        if (!smbcli_request_send(req)) {
@@ -121,11 +124,15 @@ NTSTATUS smb_raw_tcon_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx,
                p = req->in.data;
                if (!p) break;
 
-               p += smbcli_req_pull_string(req, mem_ctx, &parms->tconx.out.dev_type, 
-                                        p, -1, STR_ASCII | STR_TERMINATE);
-               p += smbcli_req_pull_string(req, mem_ctx, &parms->tconx.out.fs_type, 
+               p += smbcli_req_pull_string(&req->in.bufinfo, mem_ctx, &parms->tconx.out.dev_type, 
+                                           p, -1, STR_ASCII | STR_TERMINATE);
+               p += smbcli_req_pull_string(&req->in.bufinfo, mem_ctx, &parms->tconx.out.fs_type, 
                                         p, -1, STR_TERMINATE);
                break;
+
+       case RAW_TCON_SMB2:
+               req->status = NT_STATUS_INTERNAL_ERROR;
+               break;
        }
 
 failed:
@@ -135,7 +142,7 @@ failed:
 /****************************************************************************
  Send a tconX (sync interface)
 ****************************************************************************/
-NTSTATUS smb_raw_tcon(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, 
+_PUBLIC_ NTSTATUS smb_raw_tcon(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, 
                      union smb_tcon *parms)
 {
        struct smbcli_request *req = smb_raw_tcon_send(tree, parms);
@@ -146,7 +153,7 @@ NTSTATUS smb_raw_tcon(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx,
 /****************************************************************************
  Send a tree disconnect.
 ****************************************************************************/
-NTSTATUS smb_tree_disconnect(struct smbcli_tree *tree)
+_PUBLIC_ NTSTATUS smb_tree_disconnect(struct smbcli_tree *tree)
 {
        struct smbcli_request *req;
 
@@ -165,26 +172,40 @@ NTSTATUS smb_tree_disconnect(struct smbcli_tree *tree)
 */
 NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx,
                                     struct smbcli_tree **ret_tree, 
-                                    const char *dest_host, int port,
+                                    const char *dest_host, const char **dest_ports,
                                     const char *service, const char *service_type,
                                     struct cli_credentials *credentials,
-                                    struct event_context *ev)
+                                    struct resolve_context *resolve_ctx,
+                                    struct event_context *ev,
+                                    struct smbcli_options *options,
+                                    struct smbcli_session_options *session_options)
 {
        struct smb_composite_connect io;
        NTSTATUS status;
+       TALLOC_CTX *tmp_ctx = talloc_new(parent_ctx);
+       if (!tmp_ctx) {
+               return NT_STATUS_NO_MEMORY;
+       }
 
        io.in.dest_host = dest_host;
-       io.in.port = port;
-       io.in.called_name = strupper_talloc(parent_ctx, dest_host);
+       io.in.dest_ports = dest_ports;
+       io.in.called_name = strupper_talloc(tmp_ctx, dest_host);
        io.in.service = service;
        io.in.service_type = service_type;
        io.in.credentials = credentials;
-       io.in.workgroup = lp_workgroup();
+       io.in.fallback_to_anonymous = false;
+
+       /* This workgroup gets sent out by the SPNEGO session setup.
+        * I don't know of any servers that look at it, so we 
+        * hardcode it to "". */
+       io.in.workgroup = "";
+       io.in.options = *options;
+       io.in.session_options = *session_options;
        
-       status = smb_composite_connect(&io, parent_ctx, ev);
+       status = smb_composite_connect(&io, parent_ctx, resolve_ctx, ev);
        if (NT_STATUS_IS_OK(status)) {
                *ret_tree = io.out.tree;
        }
-
+       talloc_free(tmp_ctx);
        return status;
 }