s3:smbclient: add a "tcon" command to do a tree connect (connect to a share)
authorMichael Adam <obnox@samba.org>
Fri, 22 Jul 2011 12:10:38 +0000 (14:10 +0200)
committerMichael Adam <obnox@samba.org>
Fri, 22 Jul 2011 13:42:16 +0000 (15:42 +0200)
source3/client/client.c

index a5bee39f0a4023b73dfc438356f26a674c690521..e3a72041183722bde11a447fa058cac12e9e3ec3 100644 (file)
@@ -4327,6 +4327,39 @@ static int cmd_logoff(void)
 }
 
 
 }
 
 
+/**
+ * tree connect (connect to a share)
+ */
+
+static int cmd_tcon(void)
+{
+       TALLOC_CTX *ctx = talloc_tos();
+       char *sharename;
+       NTSTATUS status;
+
+       if (!next_token_talloc(ctx, &cmd_ptr, &sharename, NULL)) {
+               d_printf("tcon <sharename>\n");
+               return 0;
+       }
+
+       if (!sharename) {
+               return 1;
+       }
+
+       status = cli_tcon_andx(cli, sharename, "?????", "", 0);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("tcon failed: %s\n", nt_errstr(status));
+               return -1;
+       }
+
+       talloc_free(sharename);
+
+       d_printf("tcon to %s successful, tid: %u\n", sharename,
+                cli_state_get_tid(cli));
+       return 0;
+}
+
+
 /****************************************************************************
  list active connections
 ****************************************************************************/
 /****************************************************************************
  list active connections
 ****************************************************************************/
@@ -4515,6 +4548,7 @@ static struct {
   {"logon",cmd_logon,"establish new logon",{COMPL_NONE,COMPL_NONE}},
   {"listconnect",cmd_list_connect,"list open connections",{COMPL_NONE,COMPL_NONE}},
   {"showconnect",cmd_show_connect,"display the current active connection",{COMPL_NONE,COMPL_NONE}},
   {"logon",cmd_logon,"establish new logon",{COMPL_NONE,COMPL_NONE}},
   {"listconnect",cmd_list_connect,"list open connections",{COMPL_NONE,COMPL_NONE}},
   {"showconnect",cmd_show_connect,"display the current active connection",{COMPL_NONE,COMPL_NONE}},
+  {"tcon",cmd_tcon,"connect to a share" ,{COMPL_NONE,COMPL_NONE}},
   {"logoff",cmd_logoff,"log off (close the session)",{COMPL_NONE,COMPL_NONE}},
   {"..",cmd_cd_oneup,"change the remote directory (up one level)",{COMPL_REMOTE,COMPL_NONE}},
 
   {"logoff",cmd_logoff,"log off (close the session)",{COMPL_NONE,COMPL_NONE}},
   {"..",cmd_cd_oneup,"change the remote directory (up one level)",{COMPL_REMOTE,COMPL_NONE}},