diff options
Diffstat (limited to 'source4/client')
-rw-r--r-- | source4/client/cifsdd.c | 17 | ||||
-rw-r--r-- | source4/client/cifsdd.h | 2 | ||||
-rw-r--r-- | source4/client/cifsddio.c | 12 | ||||
-rw-r--r-- | source4/client/client.c | 65 | ||||
-rw-r--r-- | source4/client/config.mk | 4 |
5 files changed, 65 insertions, 35 deletions
diff --git a/source4/client/cifsdd.c b/source4/client/cifsdd.c index 8e25dab927..ce48c7bad1 100644 --- a/source4/client/cifsdd.c +++ b/source4/client/cifsdd.c @@ -24,6 +24,7 @@ #include "lib/cmdline/popt_common.h" #include "libcli/resolve/resolve.h" #include "libcli/raw/libcliraw.h" +#include "lib/events/events.h" #include "cifsdd.h" #include "param/param.h" @@ -354,6 +355,7 @@ static void print_transfer_stats(void) } static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx, + struct event_context *ev, const char * which, const char **ports, struct smbcli_options *smb_options) { @@ -375,13 +377,13 @@ static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx, if (strcmp(which, "if") == 0) { path = check_arg_pathname("if"); - handle = dd_open_path(resolve_ctx, path, ports, + handle = dd_open_path(resolve_ctx, ev, path, ports, check_arg_numeric("ibs"), options, smb_options); } else if (strcmp(which, "of") == 0) { options |= DD_WRITE; path = check_arg_pathname("of"); - handle = dd_open_path(resolve_ctx, path, ports, + handle = dd_open_path(resolve_ctx, ev, path, ports, check_arg_numeric("obs"), options, smb_options); } else { @@ -396,7 +398,7 @@ static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx, return(handle); } -static int copy_files(struct loadparm_context *lp_ctx) +static int copy_files(struct event_context *ev, struct loadparm_context *lp_ctx) { uint8_t * iobuf; /* IO buffer. */ uint64_t iomax; /* Size of the IO buffer. */ @@ -433,12 +435,12 @@ static int copy_files(struct loadparm_context *lp_ctx) DEBUG(4, ("IO buffer size is %llu, max xmit is %d\n", (unsigned long long)iomax, options.max_xmit)); - if (!(ifile = open_file(lp_resolve_context(lp_ctx), "if", + if (!(ifile = open_file(lp_resolve_context(lp_ctx), ev, "if", lp_smb_ports(lp_ctx), &options))) { return(FILESYS_EXIT_CODE); } - if (!(ofile = open_file(lp_resolve_context(lp_ctx), "of", + if (!(ofile = open_file(lp_resolve_context(lp_ctx), ev, "of", lp_smb_ports(lp_ctx), &options))) { return(FILESYS_EXIT_CODE); } @@ -528,6 +530,7 @@ int main(int argc, const char ** argv) { int i; const char ** dd_args; + struct event_context *ev; poptContext pctx; struct poptOption poptions[] = { @@ -578,6 +581,8 @@ int main(int argc, const char ** argv) } } + ev = event_context_init(talloc_autofree_context()); + gensec_init(cmdline_lp_ctx); dump_args(); @@ -599,7 +604,7 @@ int main(int argc, const char ** argv) CatchSignal(SIGINT, dd_handle_signal); CatchSignal(SIGUSR1, dd_handle_signal); - return(copy_files(cmdline_lp_ctx)); + return(copy_files(ev, cmdline_lp_ctx)); } /* vim: set sw=8 sts=8 ts=8 tw=79 : */ diff --git a/source4/client/cifsdd.h b/source4/client/cifsdd.h index 810c882ea9..21a4ad4882 100644 --- a/source4/client/cifsdd.h +++ b/source4/client/cifsdd.h @@ -89,8 +89,10 @@ struct dd_iohandle #define DD_OPLOCK 0x00000008 struct smbcli_options; +struct event_context; struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx, + struct event_context *ev, const char * path, const char **ports, uint64_t io_size, int options, diff --git a/source4/client/cifsddio.c b/source4/client/cifsddio.c index 7028e85078..4297c30012 100644 --- a/source4/client/cifsddio.c +++ b/source4/client/cifsddio.c @@ -221,6 +221,7 @@ static bool smb_write_func(void * handle, uint8_t * buf, uint64_t wanted, } static struct smbcli_state * init_smb_session(struct resolve_context *resolve_ctx, + struct event_context *ev, const char * host, const char **ports, const char * share, @@ -233,8 +234,9 @@ static struct smbcli_state * init_smb_session(struct resolve_context *resolve_ct * each connection, but for now, we just use the same one for both. */ ret = smbcli_full_connection(NULL, &cli, host, ports, share, - NULL /* devtype */, cmdline_credentials, resolve_ctx, - NULL /* events */, options); + NULL /* devtype */, + cmdline_credentials, resolve_ctx, + ev, options); if (!NT_STATUS_IS_OK(ret)) { fprintf(stderr, "%s: connecting to //%s/%s: %s\n", @@ -293,6 +295,7 @@ static int open_smb_file(struct smbcli_state * cli, } static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx, + struct event_context *ev, const char * host, const char **ports, const char * share, @@ -319,7 +322,7 @@ static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx smbh->h.io_write = smb_write_func; smbh->h.io_seek = smb_seek_func; - if ((smbh->cli = init_smb_session(resolve_ctx, host, ports, share, + if ((smbh->cli = init_smb_session(resolve_ctx, ev, host, ports, share, smb_options)) == NULL) { return(NULL); } @@ -336,6 +339,7 @@ static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx /* ------------------------------------------------------------------------- */ struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx, + struct event_context *ev, const char * path, const char **ports, uint64_t io_size, @@ -355,7 +359,7 @@ struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx, /* Skip over leading directory separators. */ while (*remain == '/' || *remain == '\\') { remain++; } - return(open_cifs_handle(resolve_ctx, host, ports, + return(open_cifs_handle(resolve_ctx, ev, host, ports, share, remain, io_size, options, smb_options)); } diff --git a/source4/client/client.c b/source4/client/client.c index 775aa69d37..01197e8a9e 100644 --- a/source4/client/client.c +++ b/source4/client/client.c @@ -32,6 +32,7 @@ #include "includes.h" #include "version.h" #include "libcli/libcli.h" +#include "lib/events/events.h" #include "lib/cmdline/popt_common.h" #include "librpc/gen_ndr/ndr_srvsvc_c.h" #include "librpc/gen_ndr/ndr_lsa.h" @@ -213,15 +214,18 @@ check the space on a device ****************************************************************************/ static int do_dskattr(struct smbclient_context *ctx) { - int total, bsize, avail; + uint32_t bsize; + uint64_t total, avail; if (NT_STATUS_IS_ERR(smbcli_dskattr(ctx->cli->tree, &bsize, &total, &avail))) { d_printf("Error in dskattr: %s\n",smbcli_errstr(ctx->cli->tree)); return 1; } - d_printf("\n\t\t%d blocks of size %d. %d blocks available\n", - total, bsize, avail); + d_printf("\n\t\t%llu blocks of size %u. %llu blocks available\n", + (unsigned long long)total, + (unsigned)bsize, + (unsigned long long)avail); return 0; } @@ -2545,7 +2549,9 @@ static void display_share_result(struct srvsvc_NetShareCtr1 *ctr1) /**************************************************************************** try and browse available shares on a host ****************************************************************************/ -static bool browse_host(struct loadparm_context *lp_ctx, const char *query_host) +static bool browse_host(struct loadparm_context *lp_ctx, + struct event_context *ev_ctx, + const char *query_host) { struct dcerpc_pipe *p; char *binding; @@ -2559,7 +2565,7 @@ static bool browse_host(struct loadparm_context *lp_ctx, const char *query_host) status = dcerpc_pipe_connect(mem_ctx, &p, binding, &ndr_table_srvsvc, - cmdline_credentials, NULL, + cmdline_credentials, ev_ctx, lp_ctx); if (!NT_STATUS_IS_OK(status)) { d_printf("Failed to connect to %s - %s\n", @@ -3021,6 +3027,7 @@ static int process_stdin(struct smbclient_context *ctx) return a connection to a server *******************************************************/ static bool do_connect(struct smbclient_context *ctx, + struct event_context *ev_ctx, struct resolve_context *resolve_ctx, const char *specified_server, const char **ports, const char *specified_share, @@ -3044,8 +3051,7 @@ static bool do_connect(struct smbclient_context *ctx, status = smbcli_full_connection(ctx, &ctx->cli, server, ports, share, NULL, cred, resolve_ctx, - cli_credentials_get_event_context(cred), - options); + ev_ctx, options); if (!NT_STATUS_IS_OK(status)) { d_printf("Connection to \\\\%s\\%s failed - %s\n", server, share, nt_errstr(status)); @@ -3059,9 +3065,12 @@ static bool do_connect(struct smbclient_context *ctx, /**************************************************************************** handle a -L query ****************************************************************************/ -static int do_host_query(struct loadparm_context *lp_ctx, const char *query_host, const char *workgroup) +static int do_host_query(struct loadparm_context *lp_ctx, + struct event_context *ev_ctx, + const char *query_host, + const char *workgroup) { - browse_host(lp_ctx, query_host); + browse_host(lp_ctx, ev_ctx, query_host); list_servers(workgroup); return(0); } @@ -3070,7 +3079,12 @@ static int do_host_query(struct loadparm_context *lp_ctx, const char *query_host /**************************************************************************** handle a message operation ****************************************************************************/ -static int do_message_op(const char *netbios_name, const char *desthost, const char **destports, const char *destip, int name_type, struct resolve_context *resolve_ctx, struct smbcli_options *options) +static int do_message_op(const char *netbios_name, const char *desthost, + const char **destports, const char *destip, + int name_type, + struct event_context *ev_ctx, + struct resolve_context *resolve_ctx, + struct smbcli_options *options) { struct nbt_name called, calling; const char *server_name; @@ -3082,7 +3096,9 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c server_name = destip ? destip : desthost; - if (!(cli=smbcli_state_init(NULL)) || !smbcli_socket_connect(cli, server_name, destports, resolve_ctx, options)) { + if (!(cli = smbcli_state_init(NULL)) || + !smbcli_socket_connect(cli, server_name, destports, + ev_ctx, resolve_ctx, options)) { d_printf("Connection to %s failed\n", server_name); return 1; } @@ -3111,11 +3127,6 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c const char *query_host = NULL; bool message = false; const char *desthost = NULL; -#ifdef KANJI - const char *term_code = KANJI; -#else - const char *term_code = ""; -#endif /* KANJI */ poptContext pc; const char *service = NULL; int port = 0; @@ -3123,6 +3134,7 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c int rc = 0; int name_type = 0x20; TALLOC_CTX *mem_ctx; + struct event_context *ev_ctx; struct smbclient_context *ctx; const char *cmdstr = NULL; struct smbcli_options smb_options; @@ -3134,7 +3146,6 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c { "ip-address", 'I', POPT_ARG_STRING, NULL, 'I', "Use this IP to connect to", "IP" }, { "stderr", 'E', POPT_ARG_NONE, NULL, 'E', "Write messages to stderr instead of stdout" }, { "list", 'L', POPT_ARG_STRING, NULL, 'L', "Get a list of shares available on a host", "HOST" }, - { "terminal", 't', POPT_ARG_STRING, NULL, 't', "Terminal I/O code {sjis|euc|jis7|jis8|junet|hex}", "CODE" }, { "directory", 'D', POPT_ARG_STRING, NULL, 'D', "Start from directory", "DIR" }, { "command", 'c', POPT_ARG_STRING, &cmdstr, 'c', "Execute semicolon separated commands" }, { "send-buffer", 'b', POPT_ARG_INT, NULL, 'b', "Changes the transmit/send buffer", "BYTES" }, @@ -3176,9 +3187,6 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c case 'L': query_host = strdup(poptGetOptArg(pc)); break; - case 't': - term_code = strdup(poptGetOptArg(pc)); - break; case 'D': base_directory = strdup(poptGetOptArg(pc)); break; @@ -3220,6 +3228,8 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c lp_smbcli_options(cmdline_lp_ctx, &smb_options); + ev_ctx = event_context_init(talloc_autofree_context()); + DEBUG( 3, ( "Client started (version %s).\n", SAMBA_VERSION_STRING ) ); if (query_host && (p=strchr_m(query_host,'#'))) { @@ -3229,14 +3239,23 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c } if (query_host) { - return do_host_query(cmdline_lp_ctx, query_host, lp_workgroup(cmdline_lp_ctx)); + rc = do_host_query(cmdline_lp_ctx, ev_ctx, query_host, + lp_workgroup(cmdline_lp_ctx)); + return rc; } if (message) { - return do_message_op(lp_netbios_name(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), dest_ip, name_type, lp_resolve_context(cmdline_lp_ctx), &smb_options); + rc = do_message_op(lp_netbios_name(cmdline_lp_ctx), desthost, + lp_smb_ports(cmdline_lp_ctx), dest_ip, + name_type, ev_ctx, + lp_resolve_context(cmdline_lp_ctx), + &smb_options); + return rc; } - if (!do_connect(ctx, lp_resolve_context(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), service, cmdline_credentials, &smb_options)) + if (!do_connect(ctx, ev_ctx, lp_resolve_context(cmdline_lp_ctx), + desthost, lp_smb_ports(cmdline_lp_ctx), service, + cmdline_credentials, &smb_options)) return 1; if (base_directory) diff --git a/source4/client/config.mk b/source4/client/config.mk index 5cfa542fba..877544a09a 100644 --- a/source4/client/config.mk +++ b/source4/client/config.mk @@ -18,7 +18,7 @@ PRIVATE_DEPENDENCIES = \ # End BINARY smbclient ################################# -smbclient_OBJ_FILES = client/client.o +smbclient_OBJ_FILES = $(clientsrcdir)/client.o ################################# # Start BINARY cifsdd @@ -33,4 +33,4 @@ PRIVATE_DEPENDENCIES = \ # End BINARY sdd ################################# -cifsdd_OBJ_FILES = client/cifsdd.o client/cifsddio.o +cifsdd_OBJ_FILES = $(addprefix $(clientsrcdir)/, cifsdd.o cifsddio.o) |