static bool recurse = false;
static bool showacls = false;
bool lowercase = false;
+static bool backup_intent = false;
static struct sockaddr_storage dest_ss;
static char dest_ss_str[INET6_ADDRSTRLEN];
/* Use a trans2_qpathinfo to test directories for modern servers.
Except Win9x doesn't support the qpathinfo_basic() call..... */
- if (targetcli->protocol > PROTOCOL_LANMAN2 && !targetcli->win95) {
+ if (cli_state_protocol(targetcli) > PROTOCOL_LANMAN2 && !targetcli->win95) {
status = cli_qpathinfo_basic(targetcli, targetpath, &sbuf,
&attributes);
afname, nt_errstr(status)));
} else {
struct security_descriptor *sd = NULL;
- sd = cli_query_secdesc(cli_state, fnum, ctx);
- if (!sd) {
- status = cli_nt_error(cli_state);
+ status = cli_query_secdesc(cli_state, fnum,
+ ctx, &sd);
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG( 0, ("display_finfo() failed to "
- "get security descriptor: %s",
- nt_errstr(status)));
+ "get security descriptor: %s",
+ nt_errstr(status)));
} else {
display_sec_desc(sd);
}
if (f == x_stdin) {
cli_shutdown(cli);
- exit(0);
+ exit(rc);
}
return rc;
return 0;
}
+/****************************************************************************
+ Toggle the backup_intent state.
+****************************************************************************/
+
+static int cmd_backup(void)
+{
+ backup_intent = !backup_intent;
+ cli_set_backup_intent(cli, backup_intent);
+ DEBUG(2,("backup intent is now %s\n",backup_intent?"on":"off"));
+ return 1;
+}
+
/****************************************************************************
Toggle the lowercaseflag.
****************************************************************************/
char *buf;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
- d_printf("Current VUID is %d\n", cli->vuid);
+ d_printf("Current VUID is %d\n",
+ cli_state_get_uid(cli));
return 0;
}
- cli->vuid = atoi(buf);
+ cli_state_set_uid(cli, atoi(buf));
return 0;
}
return -1;
}
- d_printf("Current VUID is %d\n", cli->vuid);
+ d_printf("Current VUID is %d\n", cli_state_get_uid(cli));
+ return 0;
+}
+
+/**
+ * close the session
+ */
+
+static int cmd_logoff(void)
+{
+ NTSTATUS status;
+
+ status = cli_ulogoff(cli);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("logoff failed: %s\n", nt_errstr(status));
+ return -1;
+ }
+
+ d_printf("logoff successful\n");
+ return 0;
+}
+
+
+/**
+ * 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_tree_connect(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;
+}
+
+/**
+ * tree disconnect (disconnect from a share)
+ */
+
+static int cmd_tdis(void)
+{
+ NTSTATUS status;
+
+ status = cli_tdis(cli);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("tdis failed: %s\n", nt_errstr(status));
+ return -1;
+ }
+
+ d_printf("tdis successful\n");
+ return 0;
+}
+
+
+/**
+ * get or set tid
+ */
+
+static int cmd_tid(void)
+{
+ TALLOC_CTX *ctx = talloc_tos();
+ char *tid_str;
+
+ if (!next_token_talloc(ctx, &cmd_ptr, &tid_str, NULL)) {
+ if (cli_state_has_tcon(cli)) {
+ d_printf("current tid is %d\n", cli_state_get_tid(cli));
+ } else {
+ d_printf("no tcon currently\n");
+ }
+ } else {
+ uint16_t tid = atoi(tid_str);
+ cli_state_set_tid(cli, tid);
+ }
+
return 0;
}
return 1;
}
- d_printf("//%s/%s\n", targetcli->desthost, targetcli->share);
+ d_printf("//%s/%s\n", cli_state_remote_name(targetcli), targetcli->share);
return 0;
}
{COMPL_NONE,COMPL_NONE}},
{"altname",cmd_altname,"<file> show alt name",{COMPL_NONE,COMPL_NONE}},
{"archive",cmd_archive,"<level>\n0=ignore archive bit\n1=only get archive files\n2=only get archive files and reset archive bit\n3=get all files and reset archive bit",{COMPL_NONE,COMPL_NONE}},
+ {"backup",cmd_backup,"toggle backup intent state",{COMPL_NONE,COMPL_NONE}},
{"blocksize",cmd_block,"blocksize <number> (default 20)",{COMPL_NONE,COMPL_NONE}},
{"cancel",cmd_cancel,"<jobid> cancel a print queue entry",{COMPL_NONE,COMPL_NONE}},
{"case_sensitive",cmd_setcase,"toggle the case sensitive flag to server",{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}},
+ {"tdis",cmd_tdis,"disconnect from a share",{COMPL_NONE,COMPL_NONE}},
+ {"tid",cmd_tid,"show or set the current tid (tree-id)",{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}},
/* Yes, this must be here, see crh's comment above. */
static time_t last_t;
struct timespec now;
time_t t;
- int ret, revents;
+ NTSTATUS status;
+ unsigned char garbage[16];
clock_gettime_mono(&now);
t = now.tv_sec;
last_t = t;
- again:
-
- if (cli->fd == -1)
- return;
-
- /* We deliberately use receive_smb_raw instead of
- client_receive_smb as we want to receive
- session keepalives and then drop them here.
- */
-
- ret = poll_intr_one_fd(cli->fd, POLLIN|POLLHUP, 0, &revents);
-
- if ((ret > 0) && (revents & (POLLIN|POLLHUP|POLLERR))) {
- char inbuf[CLI_SAMBA_MAX_LARGE_READX_SIZE + LARGE_WRITEX_HDR_SIZE];
- NTSTATUS status;
- size_t len;
-
- status = receive_smb_raw(cli->fd, inbuf, sizeof(inbuf), 0, 0, &len);
-
- if (!NT_STATUS_IS_OK(status)) {
- if (cli->fd != -1) {
- close(cli->fd);
- cli->fd = -1;
- }
-
- DEBUG(0, ("Read from server failed, maybe it closed "
- "the connection: %s\n", nt_errstr(status)));
-
- finished = true;
- smb_readline_done();
- return;
- }
- if(CVAL(inbuf,0) != SMBkeepalive) {
- DEBUG(0, ("Read from server "
- "returned unexpected packet!\n"));
- return;
- }
-
- goto again;
- }
-
/* Ping the server to keep the connection alive using SMBecho. */
- {
- NTSTATUS status;
- unsigned char garbage[16];
- memset(garbage, 0xf0, sizeof(garbage));
- status = cli_echo(cli, 1, data_blob_const(garbage, sizeof(garbage)));
-
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("SMBecho failed. Maybe server has closed "
- "the connection\n"));
- finished = true;
- smb_readline_done();
- }
+ memset(garbage, 0xf0, sizeof(garbage));
+ status = cli_echo(cli, 1, data_blob_const(garbage, sizeof(garbage)));
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("SMBecho failed (%s). Maybe server has closed "
+ "the connection\n", nt_errstr(status)));
+ finished = true;
+ smb_readline_done();
}
}
status = cli_connect_nb(desthost, have_ip ? &dest_ss : NULL,
port ? port : 139, name_type,
- lp_netbios_name(), Undefined, &cli);
+ lp_netbios_name(), SMB_SIGNING_DEFAULT, 0, &cli);
if (!NT_STATUS_IS_OK(status)) {
d_printf("Connection to %s failed. Error %s\n", desthost, nt_errstr(status));
return 1;
pc = poptGetContext("smbclient", argc, (const char **) argv, long_options, 0);
poptSetOtherOptionHelp(pc, "service <password>");
- lp_set_in_client(true); /* Make sure that we tell lp_load we are */
-
while ((opt = poptGetNextOpt(pc)) != -1) {
/* if the tar option has been called previouslt, now we need to eat out the leftovers */
if ( override_logfile )
setup_logging( lp_logfile(), DEBUG_FILE );
- if (!lp_load(get_dyn_CONFIGFILE(),true,false,false,true)) {
+ if (!lp_load_client(get_dyn_CONFIGFILE())) {
fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n",
argv[0], get_dyn_CONFIGFILE());
}