extern bool AllowDebugChange;
extern bool override_logfile;
extern char tar_type;
-extern bool in_client;
static int port = 0;
static char *service;
static char *calling_name;
static bool grepable = false;
static char *cmdstr = NULL;
-static const char *cmd_ptr = NULL;
+const char *cmd_ptr = NULL;
static int io_bufsize = 524288;
/* create absolute filename for cli_nt_create() FIXME */
afname = talloc_asprintf(ctx,
"%s%s%s",
- client_get_cwd(),
+ dir,
CLI_DIRSEP_STR,
finfo->name);
if (!afname) {
return;
}
/* print file meta date header */
- d_printf( "FILENAME:%s\n", afname);
+ d_printf( "FILENAME:%s\n", finfo->name);
d_printf( "MODE:%s\n", attrib_string(finfo->mode));
d_printf( "SIZE:%.0f\n", (double)finfo->size);
d_printf( "MTIME:%s", time_to_asc(t));
uint16 attr;
SMB_OFF_T size;
off_t start = 0;
- ssize_t nread = 0;
+ SMB_OFF_T nread = 0;
int rc = 0;
struct cli_state *targetcli = NULL;
char *targetname = NULL;
NTSTATUS status;
struct rpc_pipe_client *pipe_hnd;
TALLOC_CTX *frame = talloc_stackframe();
- ENUM_HND enum_hnd;
WERROR werr;
- SRV_SHARE_INFO_CTR ctr;
+ struct srvsvc_NetShareInfoCtr info_ctr;
+ struct srvsvc_NetShareCtr1 ctr1;
+ uint32_t resume_handle = 0;
+ uint32_t total_entries = 0;
int i;
- init_enum_hnd(&enum_hnd, 0);
-
pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC, &status);
if (pipe_hnd == NULL) {
return false;
}
- werr = rpccli_srvsvc_net_share_enum(pipe_hnd, frame, 1, &ctr,
- 0xffffffff, &enum_hnd);
+ ZERO_STRUCT(info_ctr);
+ ZERO_STRUCT(ctr1);
+
+ info_ctr.level = 1;
+ info_ctr.ctr.ctr1 = &ctr1;
- if (!W_ERROR_IS_OK(werr)) {
+ status = rpccli_srvsvc_NetShareEnumAll(pipe_hnd, frame,
+ pipe_hnd->cli->desthost,
+ &info_ctr,
+ 0xffffffff,
+ &total_entries,
+ &resume_handle,
+ &werr);
+
+ if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(werr)) {
cli_rpc_pipe_close(pipe_hnd);
TALLOC_FREE(frame);
return false;
}
- 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(
- frame, &info->info_1_str.uni_netname);
- comment = rpcstr_pull_unistr2_talloc(
- frame, &info->info_1_str.uni_remark);
- browse_fn(name, info->info_1.type, comment, NULL);
+ for (i=0; i < info_ctr.ctr.ctr1->count; i++) {
+ struct srvsvc_NetShareInfo1 info = info_ctr.ctr.ctr1->array[i];
+ browse_fn(info.name, info.type, info.comment, NULL);
}
cli_rpc_pipe_close(pipe_hnd);
TALLOC_CTX *ctx = talloc_stackframe();
char *tmp;
- if (info->dirmask && info->dirmask[0] != 0) {
- tmp = talloc_strdup(ctx,info->dirmask);
- } else {
- tmp = talloc_strdup(ctx,"");
- }
+ tmp = talloc_strdup(ctx,info->dirmask);
if (!tmp) {
TALLOC_FREE(ctx);
return;
set_smb_read_error(&cli->smb_rw_error, SMB_READ_OK);
- status = receive_smb_raw(cli->fd, cli->inbuf, 0, 0, &len);
+ status = receive_smb_raw(cli->fd, cli->inbuf, cli->bufsize, 0, 0, &len);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Read from server failed, maybe it closed "
static int do_host_query(const char *query_host)
{
+ struct sockaddr_storage ss;
+
cli = cli_cm_open(talloc_tos(), NULL,
query_host, "IPC$", true, smb_encrypt);
if (!cli)
browse_host(true);
+ if (interpret_string_addr(&ss, query_host, 0) && (ss.ss_family != AF_INET)) {
+ d_printf("%s is an IPv6 address -- no workgroup available\n",
+ query_host);
+ return 1;
+ }
+
if (port != 139) {
/* Workgroups simply don't make sense over anything
pc = poptGetContext("smbclient", argc, (const char **) argv, long_options, 0);
poptSetOtherOptionHelp(pc, "service <password>");
- in_client = true; /* Make sure that we tell lp_load we are */
+ lp_set_in_client(true); /* Make sure that we tell lp_load we are */
while ((opt = poptGetNextOpt(pc)) != -1) {
argv[0], get_dyn_CONFIGFILE());
}
+ if (get_cmdline_auth_info_use_machine_account() &&
+ !set_cmdline_auth_info_machine_account_creds()) {
+ exit(-1);
+ }
+
load_interfaces();
if (service_opt && service) {
}
smb_encrypt = get_cmdline_auth_info_smb_encrypt();
- init_names();
+ if (!init_names()) {
+ fprintf(stderr, "init_names() failed\n");
+ exit(1);
+ }
if(new_name_resolve_order)
lp_set_name_resolve_order(new_name_resolve_order);