s4:client
[ira/wip.git] / source4 / client / client.c
index 5066df1f544b92b1cca466bb31a129bfe335389d..3fa819c8e7f1f17669bad6969dac1bc350a0649a 100644 (file)
@@ -1221,10 +1221,14 @@ static int cmd_put(struct smbclient_context *ctx, const char **args)
 
        lname = talloc_strdup(ctx, args[1]);
   
-       if (args[2])
-               rname = talloc_strdup(ctx, args[2]);
-       else
+       if (args[2]) {
+               if (args[2][0]=='\\')
+                       rname = talloc_strdup(ctx, args[2]);
+               else
+                       rname = talloc_asprintf(ctx, "%s\\%s", ctx->remote_cur_dir, args[2]);
+       } else {
                rname = talloc_asprintf(ctx, "%s\\%s", ctx->remote_cur_dir, lname);
+       }
        
        dos_clean_name(rname);
 
@@ -2557,7 +2561,7 @@ 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,
-                       struct event_context *ev_ctx,
+                       struct tevent_context *ev_ctx,
                        const char *query_host)
 {
        struct dcerpc_pipe *p;
@@ -3041,7 +3045,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 tevent_context *ev_ctx,
                       struct resolve_context *resolve_ctx,
                       const char *specified_server, const char **ports, 
                       const char *specified_share, 
@@ -3049,7 +3053,8 @@ static bool do_connect(struct smbclient_context *ctx,
                       struct cli_credentials *cred, 
                       struct smbcli_options *options,
                       struct smbcli_session_options *session_options,
-                          struct smb_iconv_convenience *iconv_convenience)
+                          struct smb_iconv_convenience *iconv_convenience,
+                          struct gensec_settings *gensec_settings)
 {
        NTSTATUS status;
        char *server, *share;
@@ -3071,7 +3076,8 @@ static bool do_connect(struct smbclient_context *ctx,
                                        socket_options,
                                        cred, resolve_ctx, 
                                        ev_ctx, options, session_options,
-                                       iconv_convenience);
+                                       iconv_convenience,
+                                       gensec_settings);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("Connection to \\\\%s\\%s failed - %s\n", 
                         server, share, nt_errstr(status));
@@ -3086,7 +3092,7 @@ static bool do_connect(struct smbclient_context *ctx,
 handle a -L query
 ****************************************************************************/
 static int do_host_query(struct loadparm_context *lp_ctx,
-                        struct event_context *ev_ctx,
+                        struct tevent_context *ev_ctx,
                         const char *query_host,
                         const char *workgroup)
 {
@@ -3102,7 +3108,7 @@ 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 event_context *ev_ctx,
+                        struct tevent_context *ev_ctx,
                         struct resolve_context *resolve_ctx,
                         struct smbcli_options *options,
                         struct smb_iconv_convenience *iconv_convenience,
@@ -3158,7 +3164,7 @@ static int do_message_op(const char *netbios_name, const char *desthost,
        int rc = 0;
        int name_type = 0x20;
        TALLOC_CTX *mem_ctx;
-       struct event_context *ev_ctx;
+       struct tevent_context *ev_ctx;
        struct smbclient_context *ctx;
        const char *cmdstr = NULL;
        struct smbcli_options smb_options;
@@ -3188,7 +3194,7 @@ static int do_message_op(const char *netbios_name, const char *desthost,
                exit(1);
        }
 
-       ctx = talloc(mem_ctx, struct smbclient_context);
+       ctx = talloc_zero(mem_ctx, struct smbclient_context);
        ctx->io_bufsize = 64512;
 
        pc = poptGetContext("smbclient", argc, (const char **) argv, long_options, 0);
@@ -3284,18 +3290,22 @@ static int do_message_op(const char *netbios_name, const char *desthost,
                        desthost, lp_smb_ports(cmdline_lp_ctx), service,
                        lp_socket_options(cmdline_lp_ctx),
                        cmdline_credentials, &smb_options, &smb_session_options,
-                       lp_iconv_convenience(cmdline_lp_ctx)))
+                       lp_iconv_convenience(cmdline_lp_ctx),
+                       lp_gensec_settings(ctx, cmdline_lp_ctx)))
                return 1;
 
-       if (base_directory) 
+       if (base_directory) {
                do_cd(ctx, base_directory);
+               free(base_directory);
+       }
        
        if (cmdstr) {
                rc = process_command_string(ctx, cmdstr);
        } else {
                rc = process_stdin(ctx);
        }
-  
+
+       free(desthost);
        talloc_free(mem_ctx);
 
        return rc;