Changeset 745 for trunk/server/source4/client/client.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source4/client/client.c
r414 r745 36 36 #include "lib/cmdline/popt_common.h" 37 37 #include "librpc/gen_ndr/ndr_srvsvc_c.h" 38 #include "librpc/gen_ndr/ndr_lsa.h"39 #include "librpc/gen_ndr/ndr_security.h"40 #include "libcli/raw/libcliraw.h"41 38 #include "libcli/util/clilsa.h" 42 39 #include "system/dir.h" … … 49 46 #include "libcli/resolve/resolve.h" 50 47 #include "libcli/security/security.h" 51 #include " lib/smbreadline/smbreadline.h"48 #include "../libcli/smbreadline/smbreadline.h" 52 49 #include "librpc/gen_ndr/ndr_nbt.h" 53 50 #include "param/param.h" 54 #include "librpc/rpc/dcerpc.h"55 51 #include "libcli/raw/raw_proto.h" 56 52 … … 77 73 /* timing globals */ 78 74 static uint64_t get_total_size = 0; 79 static u int_t get_total_time_ms = 0;75 static unsigned int get_total_time_ms = 0; 80 76 static uint64_t put_total_size = 0; 81 static u int_t put_total_time_ms = 0;77 static unsigned int put_total_time_ms = 0; 82 78 83 79 /* Unfortunately, there is no way to pass the a context to the completion function as an argument */ … … 265 261 new directory is invalid */ 266 262 if (newdir[0] == '\\') 267 dname = talloc_strdup( NULL, newdir);263 dname = talloc_strdup(ctx, newdir); 268 264 else 269 dname = talloc_asprintf( NULL, "%s\\%s", ctx->remote_cur_dir, newdir);265 dname = talloc_asprintf(ctx, "%s\\%s", ctx->remote_cur_dir, newdir); 270 266 271 267 dos_format(dname); … … 686 682 get a file from rname to lname 687 683 ****************************************************************************/ 688 static int do_get(struct smbclient_context *ctx, char *rname, const char * lname, bool reget)684 static int do_get(struct smbclient_context *ctx, char *rname, const char *p_lname, bool reget) 689 685 { 690 686 int handle = 0, fnum; … … 698 694 off_t nread = 0; 699 695 int rc = 0; 700 696 char *lname; 697 698 699 lname = talloc_strdup(ctx, p_lname); 701 700 GetTimeOfDay(&tp_start); 702 701 703 702 if (ctx->lowercase) { 704 strlower( discard_const_p(char, lname));703 strlower(lname); 705 704 } 706 705 … … 859 858 char *mget_mask; 860 859 char *saved_curdir; 860 char *l_fname; 861 861 862 862 if (ISDOT(finfo->name) || ISDOTDOT(finfo->name)) … … 864 864 865 865 if (finfo->attrib & FILE_ATTRIBUTE_DIRECTORY) 866 asprintf(&quest, "Get directory %s? ",finfo->name);866 quest = talloc_asprintf(ctx, "Get directory %s? ",finfo->name); 867 867 else 868 asprintf(&quest, "Get file %s? ",finfo->name);868 quest = talloc_asprintf(ctx, "Get file %s? ",finfo->name); 869 869 870 870 if (ctx->prompt && !yesno(quest)) return; 871 871 872 SAFE_FREE(quest);872 talloc_free(quest); 873 873 874 874 if (!(finfo->attrib & FILE_ATTRIBUTE_DIRECTORY)) { 875 asprintf(&rname, "%s%s",ctx->remote_cur_dir,finfo->name); 875 rname = talloc_asprintf(ctx, "%s%s",ctx->remote_cur_dir, 876 finfo->name); 876 877 do_get(ctx, rname, finfo->name, false); 877 SAFE_FREE(rname);878 talloc_free(rname); 878 879 return; 879 880 } 880 881 881 882 /* handle directories */ 882 saved_curdir = talloc_strdup( NULL, ctx->remote_cur_dir);883 saved_curdir = talloc_strdup(ctx, ctx->remote_cur_dir); 883 884 884 885 ctx->remote_cur_dir = talloc_asprintf_append_buffer(NULL, "%s\\", finfo->name); 885 886 886 string_replace(discard_const_p(char, finfo->name), '\\', '/'); 887 l_fname = talloc_strdup(ctx, finfo->name); 888 889 string_replace(l_fname, '\\', '/'); 887 890 if (ctx->lowercase) { 888 strlower( discard_const_p(char, finfo->name));889 } 890 891 if (!directory_exist( finfo->name) &&892 mkdir( finfo->name,0777) != 0) {893 d_printf("failed to create directory %s\n", finfo->name);891 strlower(l_fname); 892 } 893 894 if (!directory_exist(l_fname) && 895 mkdir(l_fname, 0777) != 0) { 896 d_printf("failed to create directory %s\n", l_fname); 894 897 return; 895 898 } 896 899 897 if (chdir( finfo->name) != 0) {898 d_printf("failed to chdir to directory %s\n", finfo->name);900 if (chdir(l_fname) != 0) { 901 d_printf("failed to chdir to directory %s\n", l_fname); 899 902 return; 900 903 } 901 904 902 mget_mask = talloc_asprintf( NULL, "%s*", ctx->remote_cur_dir);905 mget_mask = talloc_asprintf(ctx, "%s*", ctx->remote_cur_dir); 903 906 904 907 do_list(ctx, mget_mask, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY,do_mget,false, true); … … 964 967 965 968 for (i = 1; args[i]; i++) { 966 mget_mask = talloc_strdup(ctx, ctx->remote_cur_dir);969 mget_mask = talloc_strdup(ctx, ctx->remote_cur_dir); 967 970 if(mget_mask[strlen(mget_mask)-1]!='\\') 968 971 mget_mask = talloc_append_string(ctx, mget_mask, "\\"); … … 1293 1296 { 1294 1297 talloc_free(ctx->fileselection); 1295 ctx->fileselection = talloc_strdup( NULL, args[1]);1298 ctx->fileselection = talloc_strdup(ctx, args[1]); 1296 1299 1297 1300 return 0; … … 1534 1537 return 1; 1535 1538 } 1536 mask = talloc_asprintf(ctx, "%s%s", ctx->remote_cur_dir, args[1]);1539 mask = talloc_asprintf(ctx, "%s%s", ctx->remote_cur_dir, args[1]); 1537 1540 1538 1541 if (NT_STATUS_IS_ERR(smbcli_unlink(ctx->cli->tree, mask))) { … … 2249 2252 if (NT_STATUS_IS_ERR(smbcli_unix_chmod(ctx->cli->tree, src, mode))) { 2250 2253 d_printf("%s chmod file %s 0%o\n", 2251 smbcli_errstr(ctx->cli->tree), src, ( mode_t)mode);2254 smbcli_errstr(ctx->cli->tree), src, (unsigned)mode); 2252 2255 return 1; 2253 2256 } … … 2604 2607 do { 2605 2608 ZERO_STRUCT(ctr1); 2606 status = dcerpc_srvsvc_NetShareEnumAll (p, mem_ctx, &r);2609 status = dcerpc_srvsvc_NetShareEnumAll_r(p->binding_handle, mem_ctx, &r); 2607 2610 2608 2611 if (NT_STATUS_IS_OK(status) && … … 2831 2834 { 2832 2835 char *dirmask; 2833 int i ;2836 int i, ret; 2834 2837 completion_remote_t info; 2835 2838 … … 2854 2857 info.dirmask = talloc_strndup(NULL, text, i+1); 2855 2858 info.dirmask[i+1] = 0; 2856 asprintf(&dirmask, "%s%*s*", rl_ctx->remote_cur_dir, i-1, text); 2857 } else 2858 asprintf(&dirmask, "%s*", rl_ctx->remote_cur_dir); 2859 ret = asprintf(&dirmask, "%s%*s*", rl_ctx->remote_cur_dir, i-1, 2860 text); 2861 } else { 2862 ret = asprintf(&dirmask, "%s*", rl_ctx->remote_cur_dir); 2863 } 2864 if (ret < 0) { 2865 goto cleanup; 2866 } 2859 2867 2860 2868 if (smbcli_list(rl_ctx->cli->tree, dirmask, … … 2995 3003 2996 3004 /* and get the first part of the command */ 2997 args = str_list_make_shell(ctx, cline, NULL);3005 args = (const char **) str_list_make_shell(ctx, cline, NULL); 2998 3006 if (!args || !args[0]) 2999 3007 return 0; … … 3054 3062 struct smbcli_options *options, 3055 3063 struct smbcli_session_options *session_options, 3056 struct smb_iconv_convenience *iconv_convenience,3057 3064 struct gensec_settings *gensec_settings) 3058 3065 { … … 3077 3084 cred, resolve_ctx, 3078 3085 ev_ctx, options, session_options, 3079 iconv_convenience,3080 3086 gensec_settings); 3081 3087 if (!NT_STATUS_IS_OK(status)) { … … 3083 3089 server, share, nt_errstr(status)); 3084 3090 talloc_free(ctx); 3085 return NULL;3086 } 3087 3088 return ctx;3091 return false; 3092 } 3093 3094 return true; 3089 3095 } 3090 3096 … … 3112 3118 struct resolve_context *resolve_ctx, 3113 3119 struct smbcli_options *options, 3114 struct smb_iconv_convenience *iconv_convenience,3115 3120 const char *socket_options) 3116 3121 { … … 3128 3133 !smbcli_socket_connect(cli, server_name, destports, 3129 3134 ev_ctx, resolve_ctx, options, 3130 iconv_convenience,3131 3135 socket_options)) { 3132 3136 d_printf("Connection to %s failed\n", server_name); … … 3152 3156 int main(int argc,char *argv[]) 3153 3157 { 3154 c onst char *base_directory = NULL;3158 char *base_directory = NULL; 3155 3159 const char *dest_ip = NULL; 3156 3160 int opt; 3157 3161 const char *query_host = NULL; 3158 3162 bool message = false; 3159 c onst char *desthost = NULL;3163 char *desthost = NULL; 3160 3164 poptContext pc; 3161 3165 const char *service = NULL; … … 3258 3262 poptFreeContext(pc); 3259 3263 3260 lp _smbcli_options(cmdline_lp_ctx, &smb_options);3261 lp _smbcli_session_options(cmdline_lp_ctx, &smb_session_options);3264 lpcfg_smbcli_options(cmdline_lp_ctx, &smb_options); 3265 lpcfg_smbcli_session_options(cmdline_lp_ctx, &smb_session_options); 3262 3266 3263 3267 ev_ctx = s4_event_context_init(talloc_autofree_context()); … … 3273 3277 if (query_host) { 3274 3278 rc = do_host_query(cmdline_lp_ctx, ev_ctx, query_host, 3275 lp _workgroup(cmdline_lp_ctx));3279 lpcfg_workgroup(cmdline_lp_ctx)); 3276 3280 return rc; 3277 3281 } 3278 3282 3279 3283 if (message) { 3280 rc = do_message_op(lp _netbios_name(cmdline_lp_ctx), desthost,3281 lp _smb_ports(cmdline_lp_ctx), dest_ip,3284 rc = do_message_op(lpcfg_netbios_name(cmdline_lp_ctx), desthost, 3285 lpcfg_smb_ports(cmdline_lp_ctx), dest_ip, 3282 3286 name_type, ev_ctx, 3283 lp _resolve_context(cmdline_lp_ctx),3284 &smb_options, lp_iconv_convenience(cmdline_lp_ctx),3285 lp _socket_options(cmdline_lp_ctx));3287 lpcfg_resolve_context(cmdline_lp_ctx), 3288 &smb_options, 3289 lpcfg_socket_options(cmdline_lp_ctx)); 3286 3290 return rc; 3287 3291 } 3288 3292 3289 if (!do_connect(ctx, ev_ctx, lp _resolve_context(cmdline_lp_ctx),3290 desthost, lp _smb_ports(cmdline_lp_ctx), service,3291 lp _socket_options(cmdline_lp_ctx),3293 if (!do_connect(ctx, ev_ctx, lpcfg_resolve_context(cmdline_lp_ctx), 3294 desthost, lpcfg_smb_ports(cmdline_lp_ctx), service, 3295 lpcfg_socket_options(cmdline_lp_ctx), 3292 3296 cmdline_credentials, &smb_options, &smb_session_options, 3293 lp_iconv_convenience(cmdline_lp_ctx), 3294 lp_gensec_settings(ctx, cmdline_lp_ctx))) 3297 lpcfg_gensec_settings(ctx, cmdline_lp_ctx))) 3295 3298 return 1; 3296 3299
Note:
See TracChangeset
for help on using the changeset viewer.