Changeset 988 for vendor/current/source4/client
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- Location:
- vendor/current/source4/client
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source4/client/cifsdd.c
r740 r988 153 153 break; 154 154 case ARG_SIZE: 155 if (!conv_str_size (val, &arg->arg_val.nval)) {155 if (!conv_str_size_error(val, &arg->arg_val.nval)) { 156 156 goto fail; 157 157 } … … 449 449 &session_options, 450 450 lpcfg_gensec_settings(lp_ctx, lp_ctx)))) { 451 SAFE_FREE(iobuf); 451 452 return(FILESYS_EXIT_CODE); 452 453 } … … 457 458 &session_options, 458 459 lpcfg_gensec_settings(lp_ctx, lp_ctx)))) { 460 SAFE_FREE(iobuf); 459 461 return(FILESYS_EXIT_CODE); 460 462 } … … 488 490 if (!dd_flush_block(ofile, iobuf, 489 491 &data_size, obs)) { 492 SAFE_FREE(iobuf); 490 493 return(IOERROR_EXIT_CODE); 491 494 } … … 498 501 */ 499 502 if (!dd_fill_block(ifile, iobuf, &data_size, obs, ibs)) { 503 SAFE_FREE(iobuf); 500 504 return(IOERROR_EXIT_CODE); 501 505 } … … 521 525 if (data_size && 522 526 !dd_flush_block(ofile, iobuf, &data_size, obs)) { 527 SAFE_FREE(iobuf); 523 528 return(IOERROR_EXIT_CODE); 524 529 } … … 526 531 527 532 done: 533 SAFE_FREE(iobuf); 528 534 print_transfer_stats(); 529 535 return(0); … … 566 572 set_arg_val("count", (uint64_t)-1); 567 573 set_arg_val("seek", (uint64_t)0); 568 set_arg_val("s eek", (uint64_t)0);574 set_arg_val("skip", (uint64_t)0); 569 575 /* Files. */ 570 576 set_arg_val("if", NULL); … … 598 604 ev = s4_event_context_init(talloc_autofree_context()); 599 605 600 gensec_init( cmdline_lp_ctx);606 gensec_init(); 601 607 dump_args(); 602 608 -
vendor/current/source4/client/client.c
r740 r988 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" 38 40 #include "libcli/util/clilsa.h" 39 41 #include "system/dir.h" … … 310 312 311 313 if (is_case_sensitive) 312 return ms_fnmatch (pattern, string,314 return ms_fnmatch_protocol(pattern, string, 313 315 c->transport->negotiate.protocol) == 0; 314 316 315 317 p2 = strlower_talloc(NULL, pattern); 316 318 s2 = strlower_talloc(NULL, string); 317 ret = ms_fnmatch (p2, s2, c->transport->negotiate.protocol) == 0;319 ret = ms_fnmatch_protocol(p2, s2, c->transport->negotiate.protocol) == 0; 318 320 talloc_free(p2); 319 321 talloc_free(s2); … … 453 455 { 454 456 char *dlq; 455 long new_end = do_list_queue_end + ((long)strlen(entry)) + 1; 457 long new_end; 458 459 if (entry == NULL) { 460 entry = ""; 461 } 462 463 new_end = do_list_queue_end + ((long)strlen(entry)) + 1; 456 464 while (new_end > do_list_queue_size) 457 465 { … … 474 482 if (do_list_queue) 475 483 { 476 s afe_strcpy(do_list_queue + do_list_queue_end, entry,477 do_list_queue_size - do_list_queue_end - 1);484 strlcpy(do_list_queue + do_list_queue_end, entry, 485 do_list_queue_size - do_list_queue_end); 478 486 do_list_queue_end = new_end; 479 487 DEBUG(4,("added %s to do_list_queue (start=%d, end=%d)\n", … … 697 705 698 706 699 lname = talloc_strdup(ctx, p_lname);700 707 GetTimeOfDay(&tp_start); 701 708 702 709 if (ctx->lowercase) { 703 strlower(lname); 710 lname = strlower_talloc(ctx, p_lname); 711 } else { 712 lname = talloc_strdup(ctx, p_lname); 704 713 } 705 714 … … 720 729 if (start == -1) { 721 730 d_printf("Error seeking local file\n"); 731 close(handle); 722 732 return 1; 723 733 } … … 739 749 &attr, &size, NULL, NULL, NULL))) { 740 750 d_printf("getattrib: %s\n",smbcli_errstr(ctx->cli->tree)); 751 if (newhandle) { 752 close(handle); 753 } 741 754 return 1; 742 755 } … … 748 761 d_printf("malloc fail for size %d\n", read_size); 749 762 smbcli_close(ctx->cli->tree, fnum); 763 if (newhandle) { 764 close(handle); 765 } 750 766 return 1; 751 767 } … … 885 901 ctx->remote_cur_dir = talloc_asprintf_append_buffer(NULL, "%s\\", finfo->name); 886 902 887 l_fname = talloc_strdup(ctx, finfo->name); 888 903 if (ctx->lowercase) { 904 l_fname = strlower_talloc(ctx, finfo->name); 905 } else { 906 l_fname = talloc_strdup(ctx, finfo->name); 907 } 908 889 909 string_replace(l_fname, '\\', '/'); 890 if (ctx->lowercase) { 891 strlower(l_fname); 892 } 893 910 894 911 if (!directory_exist(l_fname) && 895 912 mkdir(l_fname, 0777) != 0) { … … 924 941 int fd; 925 942 int rc = 0; 943 mode_t mask; 926 944 927 945 lname = talloc_asprintf(ctx, "%s/smbmore.XXXXXX",tmpdir()); 946 mask = umask(S_IRWXO | S_IRWXG); 928 947 fd = mkstemp(lname); 948 umask(mask); 929 949 if (fd == -1) { 930 950 d_printf("failed to create temporary file for more\n"); … … 1058 1078 static int cmd_altname(struct smbclient_context *ctx, const char **args) 1059 1079 { 1060 const char *altname; 1080 const char *p; 1081 char *altname; 1061 1082 char *name; 1062 1083 … … 1068 1089 name = talloc_asprintf(ctx, "%s%s", ctx->remote_cur_dir, args[1]); 1069 1090 1070 if (!NT_STATUS_IS_OK(smbcli_qpathinfo_alt_name(ctx->cli->tree, name, & altname))) {1091 if (!NT_STATUS_IS_OK(smbcli_qpathinfo_alt_name(ctx->cli->tree, name, &p))) { 1071 1092 d_printf("%s getting alt name for %s\n", 1072 1093 smbcli_errstr(ctx->cli->tree),name); 1073 1094 return(false); 1074 1095 } 1096 altname = discard_const_p(char, p); 1075 1097 d_printf("%s\n", altname); 1098 1099 SAFE_FREE(altname); 1076 1100 1077 1101 return 0; … … 1127 1151 if (x_tseek(f, start, SEEK_SET) == -1) { 1128 1152 d_printf("Error seeking local file\n"); 1153 x_fclose(f); 1129 1154 return 1; 1130 1155 } … … 1144 1169 if (!buf) { 1145 1170 d_printf("ERROR: Not enough memory!\n"); 1171 x_fclose(f); 1146 1172 return 1; 1147 1173 } … … 1595 1621 {"fullsize-information", RAW_QFS_FULL_SIZE_INFORMATION}, 1596 1622 {"objectid", RAW_QFS_OBJECTID_INFORMATION}, 1623 {"sector-size-info", RAW_QFS_SECTOR_SIZE_INFORMATION}, 1597 1624 {NULL, RAW_QFS_GENERIC} 1598 1625 }; … … 1738 1765 (unsigned long long) fsinfo.objectid_information.out.unknown[5] ); 1739 1766 break; 1767 case RAW_QFS_SECTOR_SIZE_INFORMATION: 1768 d_printf("\tlogical_bytes_per_sector: %u\n", 1769 (unsigned)fsinfo.sector_size_info.out.logical_bytes_per_sector); 1770 d_printf("\tphys_bytes_per_sector_atomic: %u\n", 1771 (unsigned)fsinfo.sector_size_info.out.phys_bytes_per_sector_atomic); 1772 d_printf("\tphys_bytes_per_sector_perf: %u\n", 1773 (unsigned)fsinfo.sector_size_info.out.phys_bytes_per_sector_perf); 1774 d_printf("\tfs_effective_phys_bytes_per_sector_atomic: %u\n", 1775 (unsigned)fsinfo.sector_size_info.out.fs_effective_phys_bytes_per_sector_atomic); 1776 d_printf("\tflags: 0x%x\n", 1777 (unsigned)fsinfo.sector_size_info.out.flags); 1778 d_printf("\tbyte_off_sector_align: %u\n", 1779 (unsigned)fsinfo.sector_size_info.out.byte_off_sector_align); 1780 d_printf("\tbyte_off_partition_align: %u\n", 1781 (unsigned)fsinfo.sector_size_info.out.byte_off_partition_align); 1782 break; 1740 1783 case RAW_QFS_GENERIC: 1741 1784 d_printf("\twrong level returned\n"); … … 2130 2173 2131 2174 /**************************************************************************** 2175 open a file 2132 2176 ****************************************************************************/ 2133 2177 static int cmd_open(struct smbclient_context *ctx, const char **args) 2134 2178 { 2135 char *mask; 2136 2179 char *filename; 2180 union smb_open io; 2181 NTSTATUS status; 2182 TALLOC_CTX *tmp_ctx; 2183 2137 2184 if (!args[1]) { 2138 2185 d_printf("open <filename>\n"); 2139 2186 return 1; 2140 2187 } 2141 mask = talloc_asprintf(ctx, "%s%s", ctx->remote_cur_dir, args[1]); 2142 2143 smbcli_open(ctx->cli->tree, mask, O_RDWR, DENY_ALL); 2188 tmp_ctx = talloc_new(ctx); 2189 2190 filename = talloc_asprintf(tmp_ctx, "%s%s", ctx->remote_cur_dir, args[1]); 2191 2192 io.generic.level = RAW_OPEN_NTCREATEX; 2193 io.ntcreatex.in.root_fid.fnum = 0; 2194 io.ntcreatex.in.flags = 0; 2195 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 2196 io.ntcreatex.in.create_options = 0; 2197 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 2198 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ; 2199 io.ntcreatex.in.alloc_size = 0; 2200 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; 2201 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; 2202 io.ntcreatex.in.security_flags = 0; 2203 io.ntcreatex.in.fname = filename; 2204 2205 status = smb_raw_open(ctx->cli->tree, tmp_ctx, &io); 2206 talloc_free(tmp_ctx); 2207 2208 if (NT_STATUS_IS_OK(status)) { 2209 d_printf("Opened file with fnum %u\n", (unsigned)io.ntcreatex.out.file.fnum); 2210 } else { 2211 d_printf("Opened failed: %s\n", nt_errstr(status)); 2212 } 2213 2214 return 0; 2215 } 2216 2217 /**************************************************************************** 2218 close a file 2219 ****************************************************************************/ 2220 static int cmd_close(struct smbclient_context *ctx, const char **args) 2221 { 2222 union smb_close io; 2223 NTSTATUS status; 2224 uint16_t fnum; 2225 2226 if (!args[1]) { 2227 d_printf("close <fnum>\n"); 2228 return 1; 2229 } 2230 2231 fnum = atoi(args[1]); 2232 2233 ZERO_STRUCT(io); 2234 io.generic.level = RAW_CLOSE_CLOSE; 2235 io.close.in.file.fnum = fnum; 2236 2237 status = smb_raw_close(ctx->cli->tree, &io); 2238 2239 if (NT_STATUS_IS_OK(status)) { 2240 d_printf("Closed file OK\n"); 2241 } else { 2242 d_printf("Close failed: %s\n", nt_errstr(status)); 2243 } 2144 2244 2145 2245 return 0; … … 2693 2793 {"newer",cmd_newer,"<file> only mget files newer than the specified local file",{COMPL_LOCAL,COMPL_NONE}}, 2694 2794 {"open",cmd_open,"<mask> open a file",{COMPL_REMOTE,COMPL_NONE}}, 2795 {"close",cmd_close,"<fnum> close a file",{COMPL_NONE,COMPL_NONE}}, 2695 2796 {"privileges",cmd_privileges,"<user> show privileges for a user",{COMPL_NONE,COMPL_NONE}}, 2696 2797 {"print",cmd_print,"<file name> print a file",{COMPL_NONE,COMPL_NONE}}, … … 2840 2941 info.text = text; 2841 2942 info.len = len; 2842 2943 info.count = 0; 2944 2843 2945 if (len >= PATH_MAX) 2844 2946 return(NULL); … … 2999 3101 static int process_line(struct smbclient_context *ctx, const char *cline) 3000 3102 { 3001 c onst char **args;3103 char **args; 3002 3104 int i; 3003 3105 3004 3106 /* and get the first part of the command */ 3005 args = (const char **)str_list_make_shell(ctx, cline, NULL);3107 args = str_list_make_shell(ctx, cline, NULL); 3006 3108 if (!args || !args[0]) 3007 3109 return 0; 3008 3110 3009 3111 if ((i = process_tok(args[0])) >= 0) { 3010 i = commands[i].fn(ctx, args); 3112 const char **a = discard_const_p(const char *, args); 3113 i = commands[i].fn(ctx, a); 3011 3114 } else if (i == -2) { 3012 3115 d_printf("%s: command abbreviation ambiguous\n",args[0]); … … 3071 3174 if (strncmp(specified_share, "\\\\", 2) == 0 || 3072 3175 strncmp(specified_share, "//", 2) == 0) { 3073 smbcli_parse_unc(specified_share, ctx, &server, &share); 3176 bool ok; 3177 3178 ok = smbcli_parse_unc(specified_share, ctx, &server, &share); 3179 if (!ok) { 3180 d_printf("Failed to parse UNC\n"); 3181 talloc_free(ctx); 3182 return false; 3183 } 3074 3184 } else { 3075 3185 share = talloc_strdup(ctx, specified_share); 3076 3186 server = talloc_strdup(ctx, specified_server); 3187 if (share == NULL || server == NULL) { 3188 d_printf("Failed to allocate memory for server and share\n"); 3189 talloc_free(ctx); 3190 return false; 3191 } 3077 3192 } 3078 3193 3079 3194 ctx->remote_cur_dir = talloc_strdup(ctx, "\\"); 3080 3195 if (ctx->remote_cur_dir == NULL) { 3196 talloc_free(ctx); 3197 return false; 3198 } 3199 3081 3200 status = smbcli_full_connection(ctx, &ctx->cli, server, ports, 3082 3201 share, NULL, … … 3123 3242 const char *server_name; 3124 3243 struct smbcli_state *cli; 3244 bool ok; 3125 3245 3126 3246 make_nbt_name_client(&calling, netbios_name); … … 3130 3250 server_name = destip ? destip : desthost; 3131 3251 3132 if (!(cli = smbcli_state_init(NULL)) || 3133 !smbcli_socket_connect(cli, server_name, destports, 3252 cli = smbcli_state_init(NULL); 3253 if (cli == NULL) { 3254 d_printf("smbcli_state_init() failed\n"); 3255 return 1; 3256 } 3257 3258 ok = smbcli_socket_connect(cli, server_name, destports, 3134 3259 ev_ctx, resolve_ctx, options, 3135 socket_options)) { 3260 socket_options, 3261 &calling, &called); 3262 if (!ok) { 3136 3263 d_printf("Connection to %s failed\n", server_name); 3137 return 1;3138 }3139 3140 if (!smbcli_transport_establish(cli, &calling, &called)) {3141 d_printf("session request failed\n");3142 talloc_free(cli);3143 3264 return 1; 3144 3265 } … … 3154 3275 main program 3155 3276 ****************************************************************************/ 3156 int main(int argc, char *argv[])3277 int main(int argc, const char *argv[]) 3157 3278 { 3158 3279 char *base_directory = NULL; … … 3202 3323 ctx->io_bufsize = 64512; 3203 3324 3204 pc = poptGetContext("smbclient", argc, (const char **)argv, long_options, 0);3325 pc = poptGetContext("smbclient", argc, argv, long_options, 0); 3205 3326 poptSetOtherOptionHelp(pc, "[OPTIONS] service <password>"); 3206 3327 … … 3232 3353 } 3233 3354 3234 gensec_init( cmdline_lp_ctx);3355 gensec_init(); 3235 3356 3236 3357 if(poptPeekArg(pc)) { -
vendor/current/source4/client/tests/test_cifsdd.sh
r414 r988 17 17 . `dirname $0`/../../../testprogs/blackbox/subunit.sh 18 18 19 samba4bindir="$B UILDDIR/bin"20 DD="$samba4bindir/cifsdd $EXEEXT"19 samba4bindir="$BINDIR" 20 DD="$samba4bindir/cifsdd" 21 21 22 22 SHARE=tmp -
vendor/current/source4/client/tests/test_smbclient.sh
r740 r988 6 6 if [ $# -lt 5 ]; then 7 7 cat <<EOF 8 Usage: test_smbclient.sh SERVER USERNAME PASSWORD DOMAIN PREFIX 8 Usage: test_smbclient.sh SERVER USERNAME PASSWORD DOMAIN PREFIX SMBCLIENT 9 9 EOF 10 10 exit 1; … … 16 16 DOMAIN=$4 17 17 PREFIX=$5 18 shift 5 18 smbclient=$6 19 shift 6 19 20 failed=0 20 21 samba4bindir="$BUILDDIR/bin"22 smbclient="$samba4bindir/smbclient$EXEEXT"23 21 24 22 . `dirname $0`/../../../testprogs/blackbox/subunit.sh
Note:
See TracChangeset
for help on using the changeset viewer.