msg[l] = c;
}
+ if ((total_len > 0) && (strlen(msg) == 0)) {
+ break;
+ }
+
if (!cli_message_text(cli, msg, l, grp_id)) {
d_printf("SMBsendtxt failed (%s)\n",cli_errstr(cli));
return;
return rc;
}
+static int cmd_echo(void)
+{
+ fstring num;
+ pstring data;
+
+ if (!next_token_nr(NULL, num, NULL, sizeof(num))
+ || !next_token_nr(NULL, data, NULL, sizeof(data))) {
+ d_printf("echo <num> <data>\n");
+ return 1;
+ }
+
+ if (!cli_echo(cli, atoi(num), (uint8 *)data, strlen(data))) {
+ d_printf("echo failed: %s\n",
+ nt_errstr(cli_get_nt_error(cli)));
+ return 1;
+ }
+
+ return 0;
+}
+
/****************************************************************************
Get a file from rname to lname
****************************************************************************/
/****************************************************************************
****************************************************************************/
-static int cmd_posix_encrypt(void)
-{
- NTSTATUS status;
-
- if (cli->use_kerberos) {
- status = cli_gss_smb_encryption_start(cli);
- } else {
- fstring buf;
- fstring domain;
- fstring user;
- fstring password;
-
- if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
- d_printf("posix_encrypt domain user password\n");
- return 1;
- }
- fstrcpy(domain,buf);
-
- if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
- d_printf("posix_encrypt domain user password\n");
- return 1;
- }
- fstrcpy(user,buf);
-
- if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
- d_printf("posix_encrypt domain user password\n");
- return 1;
- }
- fstrcpy(password,buf);
-
- status = cli_raw_ntlm_smb_encryption_start(cli,
- user,
- password,
- domain);
- }
-
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("posix_encrypt failed with error %s\n", nt_errstr(status));
- } else {
- d_printf("encryption on\n");
- }
-
- return 0;
-}
-
-/****************************************************************************
-****************************************************************************/
-
static int cmd_posix_open(void)
{
pstring mask;
pstring src,dest;
pstring buf,buf2;
struct cli_state *targetcli;
- pstring targetname;
+ pstring targetsrc;
+ pstring targetdest;
pstrcpy(src,cur_dir);
pstrcpy(dest,cur_dir);
pstrcat(src,buf);
pstrcat(dest,buf2);
- if ( !cli_resolve_path( "", cli, src, &targetcli, targetname ) ) {
- d_printf("chown %s: %s\n", src, cli_errstr(cli));
+ if ( !cli_resolve_path( "", cli, src, &targetcli, targetsrc ) ) {
+ d_printf("rename %s: %s\n", src, cli_errstr(cli));
return 1;
}
- if (!cli_rename(targetcli, targetname, dest)) {
- d_printf("%s renaming files\n",cli_errstr(targetcli));
+ if ( !cli_resolve_path( "", cli, dest, &targetcli, targetdest ) ) {
+ d_printf("rename %s: %s\n", dest, cli_errstr(cli));
+ return 1;
+ }
+
+ if (!cli_rename(targetcli, targetsrc, targetdest)) {
+ d_printf("%s renaming files %s -> %s \n",
+ cli_errstr(targetcli),
+ targetsrc,
+ targetdest);
return 1;
}
NTSTATUS status;
struct rpc_pipe_client *pipe_hnd;
TALLOC_CTX *mem_ctx;
- uint32 enum_hnd = 0;
- struct srvsvc_NetShareCtr1 ctr1;
- union srvsvc_NetShareCtr ctr;
+ ENUM_HND enum_hnd;
+ WERROR werr;
+ SRV_SHARE_INFO_CTR ctr;
int i;
- uint32 level;
- uint32 numentries;
mem_ctx = talloc_new(NULL);
if (mem_ctx == NULL) {
return False;
}
+ init_enum_hnd(&enum_hnd, 0);
+
pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC, &status);
if (pipe_hnd == NULL) {
return False;
}
- ZERO_STRUCT(ctr1);
- level = 1;
- ctr.ctr1 = &ctr1;
-
- status = rpccli_srvsvc_NetShareEnum(pipe_hnd, mem_ctx, "", &level,
- &ctr, 0xffffffff, &numentries,
- &enum_hnd);
+ werr = rpccli_srvsvc_net_share_enum(pipe_hnd, mem_ctx, 1, &ctr,
+ 0xffffffff, &enum_hnd);
- if (!NT_STATUS_IS_OK(status)) {
+ if (!W_ERROR_IS_OK(werr)) {
TALLOC_FREE(mem_ctx);
cli_rpc_pipe_close(pipe_hnd);
return False;
}
- for (i=0; i<numentries; i++) {
- struct srvsvc_NetShareInfo1 *info = &ctr.ctr1->array[i];
- browse_fn(info->name, info->type, info->comment, NULL);
+ for (i=0; i<ctr.num_entries; i++) {
+ SRV_SHARE_INFO_1 *info = &ctr.share.info1[i];
+ char *name, *comment;
+ name = rpcstr_pull_unistr2_talloc(
+ mem_ctx, &info->info_1_str.uni_netname);
+ comment = rpcstr_pull_unistr2_talloc(
+ mem_ctx, &info->info_1_str.uni_remark);
+ browse_fn(name, info->info_1.type, comment, NULL);
}
TALLOC_FREE(mem_ctx);
{"del",cmd_del,"<mask> delete all matching files",{COMPL_REMOTE,COMPL_NONE}},
{"dir",cmd_dir,"<mask> list the contents of the current directory",{COMPL_REMOTE,COMPL_NONE}},
{"du",cmd_du,"<mask> computes the total size of the current directory",{COMPL_REMOTE,COMPL_NONE}},
+ {"echo",cmd_echo,"ping the server",{COMPL_NONE,COMPL_NONE}},
{"exit",cmd_quit,"logoff the server",{COMPL_NONE,COMPL_NONE}},
{"get",cmd_get,"<remote name> [local name] get a file",{COMPL_REMOTE,COMPL_LOCAL}},
{"getfacl",cmd_getfacl,"<file name> get the POSIX ACL on a file (UNIX extensions only)",{COMPL_REMOTE,COMPL_LOCAL}},
{"newer",cmd_newer,"<file> only mget files newer than the specified local file",{COMPL_LOCAL,COMPL_NONE}},
{"open",cmd_open,"<mask> open a file",{COMPL_REMOTE,COMPL_NONE}},
{"posix", cmd_posix, "turn on all POSIX capabilities", {COMPL_REMOTE,COMPL_NONE}},
- {"posix_encrypt",cmd_posix_encrypt,"<domain> <user> <password> start up transport encryption",{COMPL_REMOTE,COMPL_NONE}},
{"posix_open",cmd_posix_open,"<name> 0<mode> open_flags mode open a file using POSIX interface",{COMPL_REMOTE,COMPL_NONE}},
{"posix_mkdir",cmd_posix_mkdir,"<name> 0<mode> creates a directory using POSIX interface",{COMPL_REMOTE,COMPL_NONE}},
{"posix_rmdir",cmd_posix_rmdir,"<name> removes a directory using POSIX interface",{COMPL_REMOTE,COMPL_NONE}},
timeout.tv_usec = 0;
sys_select_intr(cli->fd+1,&fds,NULL,NULL,&timeout);
- /* We deliberately use cli_receive_smb_return_keepalive instead of
+ /* We deliberately use receive_smb instead of
client_receive_smb as we want to receive
session keepalives and then drop them here.
*/
if (FD_ISSET(cli->fd,&fds)) {
- if (!cli_receive_smb_return_keepalive(cli)) {
+ if (!receive_smb(cli->fd,cli->inbuf,0)) {
DEBUG(0, ("Read from server failed, maybe it closed the "
"connection\n"));
return;
{
unsigned char garbage[16];
memset(garbage, 0xf0, sizeof(garbage));
- cli_echo(cli, garbage, sizeof(garbage));
+ cli_echo(cli, 1, garbage, sizeof(garbage));
}
}