Changeset 297
- Timestamp:
- Jul 2, 2009, 2:07:00 PM (16 years ago)
- Location:
- branches/client-1.6/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/client-1.6/src/Makefile.kmk
r293 r297 45 45 $(SAMBA)/source/popt \ 46 46 $(SAMBA)/source/lib/talloc \ 47 $(SAMBA)/source/lib /pc \47 $(SAMBA)/source/librpc \ 48 48 $(SAMBA)/source/lib/tdb/include \ 49 $(SAMBA)/source/lib/tdb/common \50 $(SAMBA)/source/lib/compression \51 $(SAMBA)/source/lib/ldb/include \52 $(SAMBA)/source/lib/ldb/ldb_tdb \53 $(SAMBA)/source/lib/ldb/modules \54 $(SAMBA)/source/lib/ldb/nssldb \55 $(SAMBA)/source/lib/ldb/tools \56 $(SAMBA)/source/lib/netapi \57 $(SAMBA)/source/lib/nss_wrapper \58 $(SAMBA)/source/lib/smbconf \59 $(SAMBA)/source/lib/socket_wrapper \60 49 $(GCC_INC) 61 50 -
branches/client-1.6/src/smbwrp.c
r189 r297 33 33 { 34 34 int i; 35 WERROR result;36 ENUM_HND enum_hnd;37 uint32 info_level = 1;38 uint32 preferred_len = 0xffffffff;39 uint32 type;40 SRV_SHARE_INFO_CTR ctr;35 NTSTATUS status; 36 WERROR werr; 37 uint32_t resume_handle = 0; 38 uint32_t total_entries = 0; 39 struct srvsvc_NetShareInfoCtr info_ctr; 40 struct srvsvc_NetShareCtr1 ctr1; 41 41 fstring name = ""; 42 42 fstring comment = ""; 43 43 void *mem_ctx; 44 44 struct rpc_pipe_client *pipe_hnd; 45 NTSTATUS nt_status;46 45 47 46 /* Open the server service pipe */ 48 pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC, &nt_status);49 if (! pipe_hnd) {47 status = cli_rpc_pipe_open_noauth(cli, &ndr_table_srvsvc.syntax_id, &pipe_hnd); 48 if (!NT_STATUS_IS_OK(status)) { 50 49 DEBUG(1, ("net_share_enum_rpc pipe open fail!\n")); 51 50 return -1; … … 56 55 if (mem_ctx == NULL) { 57 56 DEBUG(0, ("out of memory for net_share_enum_rpc!\n")); 58 cli_rpc_pipe_close(pipe_hnd);57 TALLOC_FREE(pipe_hnd); 59 58 return -1; 60 59 } 61 60 62 61 /* Issue the NetShareEnum RPC call and retrieve the response */ 63 init_enum_hnd(&enum_hnd, 0); 64 result = rpccli_srvsvc_net_share_enum(pipe_hnd, 65 mem_ctx, 66 info_level, 67 &ctr, 68 preferred_len, 69 &enum_hnd); 62 ZERO_STRUCT(info_ctr); 63 ZERO_STRUCT(ctr1); 64 info_ctr.level = 1; 65 info_ctr.ctr.ctr1 = &ctr1; 66 status = rpccli_srvsvc_NetShareEnumAll(pipe_hnd, mem_ctx, 67 pipe_hnd->desthost, 68 &info_ctr, 69 0xffffffff, 70 &total_entries, 71 &resume_handle, 72 &werr); 70 73 71 74 /* Was it successful? */ 72 if (! W_ERROR_IS_OK(result) || ctr.num_entries== 0) {75 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(werr) || info_ctr.ctr.ctr1->count == 0) { 73 76 /* Nope. Go clean up. */ 74 77 goto done; … … 76 79 77 80 /* For each returned entry... */ 78 for (i = 0; i < ctr.num_entries; i++) { 79 80 /* pull out the share name */ 81 rpcstr_pull_unistr2_fstring( 82 name, &ctr.share.info1[i].info_1_str.uni_netname); 83 84 /* pull out the share's comment */ 85 rpcstr_pull_unistr2_fstring( 86 comment, &ctr.share.info1[i].info_1_str.uni_remark); 87 88 /* Get the type value */ 89 type = ctr.share.info1[i].info_1.type; 81 for (i = 0; i < info_ctr.ctr.ctr1->count; i++) { 82 struct srvsvc_NetShareInfo1 info = info_ctr.ctr.ctr1->array[i]; 90 83 91 84 /* Add this share to the list */ 92 (*fn)( name, type,comment, state);85 (*fn)(info.name, info.type, info.comment, state); 93 86 } 94 87 95 88 done: 96 89 /* Close the server service pipe */ 97 cli_rpc_pipe_close(pipe_hnd);90 TALLOC_FREE(pipe_hnd); 98 91 99 92 /* Free all memory which was allocated for this request */ … … 101 94 102 95 /* Tell 'em if it worked */ 103 return W_ERROR_IS_OK( result) ? 0 : -1;96 return W_ERROR_IS_OK(status) ? 0 : -1; 104 97 } 105 98 … … 129 122 static int initialised = 0; 130 123 char *p; 131 pstring line;132 124 133 125 if (initialised) … … 137 129 initialised = 1; 138 130 131 lp_set_in_client(true); /* Make sure that we tell lp_load we are client */ 132 139 133 load_case_tables(); 140 134 141 init_globals( True); 135 if (!lp_load(get_dyn_CONFIGFILE(),true,false,false,true)) { 136 debuglocal(0,("The initial smb.conf is missing, please reinstall the plugin!")); 137 } 138 142 139 143 140 load_interfaces(); … … 254 251 send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level 255 252 ****************************************************************************/ 256 BOOLcli_qpathinfo3(struct cli_state *cli, const char *fname,253 bool cli_qpathinfo3(struct cli_state *cli, const char *fname, 257 254 time_t *c_time, time_t *a_time, time_t *m_time, 258 255 time_t *w_time, off_t *size, uint16 *mode, … … 262 259 unsigned int param_len = 0; 263 260 uint16 setup = TRANSACT2_QPATHINFO; 264 pstring param; 261 char *param; 262 size_t nlen = 2*(strlen(fname)+1); 265 263 char *rparam=NULL, *rdata=NULL; 266 264 char *p; 265 266 param = SMB_MALLOC_ARRAY(char, 6+nlen+2); 267 if (!param) { 268 return false; 269 } 267 270 268 271 p = param; 269 memset(p, 0, 6);272 memset(p, '\0', 6); 270 273 SSVAL(p, 0, SMB_QUERY_FILE_ALL_INFO); 271 274 p += 6; 272 p += clistr_push(cli, p, fname, sizeof(pstring)-6, STR_TERMINATE);275 p += clistr_push(cli, p, fname, nlen, STR_TERMINATE); 273 276 274 277 param_len = PTR_DIFF(p, param); … … 284 287 } 285 288 289 SAFE_FREE(param); 286 290 if (!cli_receive_trans(cli, SMBtrans2, 287 291 &rparam, ¶m_len, … … 324 328 send a qfileinfo call 325 329 ****************************************************************************/ 326 BOOLcli_qfileinfo3(struct cli_state *cli, int fnum,330 bool cli_qfileinfo3(struct cli_state *cli, int fnum, 327 331 uint16 *mode, off_t *size, 328 332 time_t *c_time, time_t *a_time, time_t *m_time, … … 332 336 unsigned int param_len = 0; 333 337 uint16 setup = TRANSACT2_QFILEINFO; 334 pstring param;338 char param[4]; 335 339 char *rparam=NULL, *rdata=NULL; 336 340 … … 341 345 param_len = 4; 342 346 343 memset(param, 0, param_len);344 347 SSVAL(param, 0, fnum); 345 348 SSVAL(param, 2, SMB_QUERY_FILE_ALL_INFO); … … 404 407 char *p, *server_n = server; 405 408 fstring group; 406 struct in_addr ip;409 struct sockaddr_storage ss; 407 410 NTSTATUS rc; 408 411 struct cli_state * c; … … 410 413 int loginerror = 0; 411 414 412 zero_ ip(&ip);415 zero_sockaddr(&ss); 413 416 414 417 debuglocal(1,"Connecting to \\\\%s:*********@%s:%s\\%s. Master %s:%d\n", srv->username, workgroup, server, share, srv->master, srv->ifmastergroup); 415 418 416 419 if (!*server) { 417 struct in_addrsip;420 struct sockaddr_storage sip; 418 421 419 422 if (*workgroup) … … 422 425 return 1; 423 426 } 424 fstrcpy(group, inet_ntoa(sip ));427 fstrcpy(group, inet_ntoa(sip.sin_addr)); 425 428 server_n = group; 426 429 } else … … 432 435 return 11; 433 436 } 434 strncpy(srv->master, inet_ntoa(sip ), sizeof(srv->master) - 1);437 strncpy(srv->master, inet_ntoa(sip.sin_addr), sizeof(srv->master) - 1); 435 438 srv->ifmastergroup = 0; 436 439 } … … 447 450 448 451 again: 449 zero_ ip(&ip);452 zero_sockaddr(&ss); 450 453 451 454 /* have to open a new connection */ … … 455 458 } 456 459 457 if (!NT_STATUS_IS_OK(cli_connect(c, server_n, & ip)))460 if (!NT_STATUS_IS_OK(cli_connect(c, server_n, &ss))) 458 461 { 459 462 return 3; … … 666 669 unsigned int param_len = 6; 667 670 uint16 setup = TRANSACT2_SETFILEINFO; 668 pstring param; 671 char param[6]; 672 unsigned char data[8]; 669 673 char *rparam=NULL, *rdata=NULL; 670 674 671 memset(param, 0, param_len);672 675 SSVAL(param,0,fnum); 673 676 SSVAL(param,2,SMB_SET_FILE_END_OF_FILE_INFO); 677 SSVAL(param,4,0); 678 679 SBVAL(data, 0, newsize); 674 680 675 681 if (!cli_send_trans(cli, SMBtrans2, … … 678 684 &setup, 1, 0, /* setup, length, max */ 679 685 param, param_len, 2, /* param, length, max */ 680 (char *)&newsize, sizeof(newsize), cli->max_xmit /* data, length, max */ 686 (char *)&data, data_len, /* data, length */ 687 cli->max_xmit /* max */ 681 688 )) { 682 689 return False; … … 1033 1040 ****************************************************************************/ 1034 1041 // YD from libsmb\clilist.c 1042 // @todo def_finfo is not available anymore, probably the complete function needs more work 1043 // in the longrun we have to switch to file_info struct instead of our own smbwrp_fileinfo 1044 1035 1045 static size_t _os2_interpret_long_filename(struct cli_state *cli, 1036 1046 int level,char *p, smbwrp_fileinfo *finfo, … … 1178 1188 #endif 1179 1189 int info_level; 1180 char *p, *p2 ;1181 pstring mask;1190 char *p, *p2, *rdata_end; 1191 char *mask=NULL; 1182 1192 smbwrp_fileinfo finfo; 1183 1193 int i; … … 1185 1195 int dirlist_len = 0; 1186 1196 int total_received = -1; 1187 BOOLFirst = True;1197 bool First = True; 1188 1198 int ff_searchcount=0; 1189 1199 int ff_eos=0; … … 1193 1203 unsigned int param_len, data_len; 1194 1204 uint16 setup; 1195 pstringparam;1205 char *param; 1196 1206 const char *mnt; 1197 1207 uint32 resume_key = 0; 1198 1208 uint32 last_name_raw_len = 0; 1199 DATA_BLOB last_name_raw = data_blob(NULL, 2*sizeof(pstring));1209 DATA_BLOB last_name_raw = data_blob(NULL, 0); 1200 1210 1201 1211 /* NT uses 260, OS/2 uses 2. Both accept 1. */ 1202 1212 info_level = (cli->capabilities&CAP_NT_SMBS)?260:2; 1203 1204 debuglocal(4,"list_files level %d. mask <%s>\n", info_level, mask);1213 1214 debuglocal(4,"list_files level %d. mask <%s>\n", info_level, Mask); 1205 1215 1206 1216 /* when getting a directory listing from a 2k dfs root share, 1207 1217 we have to include the full path (\server\share\mask) here */ 1208 1218 1209 if ( cli->dfsroot ) 1210 pstr_sprintf( mask, "\\%s\\%s\\%s", cli->desthost, cli->share, Mask ); 1211 else 1212 pstrcpy(mask,Mask); 1219 if ( cli->dfsroot ) { 1220 mask = talloc_asprintf(mask, "\\%s\\%s\\%s", cli->desthost, cli->share, Mask ); 1221 } else { 1222 mask = SMB_STRDUP(Mask); 1223 if (!mask) { 1224 return -1; 1225 } 1226 } 1213 1227 1214 1228 while (ff_eos == 0) { … … 1216 1230 if (loop_count > 200) { 1217 1231 debuglocal(0,"Error: Looping in FIND_NEXT??\n"); 1232 break; 1233 } 1234 1235 size_t nlen = 2*(strlen(mask)+1); 1236 param = SMB_MALLOC_ARRAY(char, 12+nlen+last_name_raw.length+2); 1237 if (!param) { 1218 1238 break; 1219 1239 } … … 1227 1247 SIVAL(param,8,0); 1228 1248 p = param+12; 1229 p += clistr_push(cli, param+12, mask, sizeof(param)-12,1249 p += clistr_push(cli, param+12, mask, nlen, 1230 1250 STR_TERMINATE); 1231 1251 } else { … … 1241 1261 SSVAL(param,10,(FLAG_TRANS2_FIND_REQUIRE_RESUME|FLAG_TRANS2_FIND_CLOSE_IF_END)); /* resume required + close on end */ 1242 1262 p = param+12; 1243 if (last_name_raw _len && (last_name_raw_len < (sizeof(param)-12))) {1244 memcpy(p, last_name_raw.data, last_name_raw _len);1245 p += last_name_raw _len;1263 if (last_name_raw.length) { 1264 memcpy(p, last_name_raw.data, last_name_raw.length); 1265 p += last_name_raw.length; 1246 1266 } else { 1247 p += clistr_push(cli, param+12, mask, sizeof(param)-12, STR_TERMINATE);1267 p += clistr_push(cli, param+12, mask, nlen, STR_TERMINATE); 1248 1268 } 1249 1269 } … … 1264 1284 #endif 1265 1285 )) { 1286 SAFE_FREE(param); 1266 1287 break; 1267 1288 } 1289 1290 SAFE_FREE(param); 1268 1291 1269 1292 if (!cli_receive_trans(cli, SMBtrans2, … … 1337 1360 /* point to the data bytes */ 1338 1361 p = rdata; 1339 1340 memset(&finfo, 0, sizeof(finfo)); 1362 rdata_end = rdata + data_len; 1363 1364 memset(&finfo, 0, sizeof(finfo)); 1341 1365 finfo.easize = -1; 1342 1366 /* we might need the lastname for continuations */ 1343 for (p2=p,i=0;i<ff_searchcount ;i++) {1367 for (p2=p,i=0;i<ff_searchcount && p2 < rdata_end;i++) { 1344 1368 if ((info_level == 260) && (i == ff_searchcount-1)) { 1345 1369 /* Last entry - fixup the last offset length. */ … … 1347 1371 } 1348 1372 p2 += _os2_interpret_long_filename(cli,info_level,p2,&finfo, 1349 &resume_key,&last_name_raw,&last_name_raw_len); 1373 &resume_key,&last_name_raw,&last_name_raw.length); 1374 1375 if (!finfo.fname) { 1376 debuglocal(0,("Error: unable to parse name from info level %d\n", 1377 info_level)); 1378 ff_eos = 1; 1379 break; 1380 } 1350 1381 1351 1382 if (!First && *mask && strcsequal(finfo.fname, mask)) { … … 1357 1388 } 1358 1389 1390 SAFE_FREE(mask); 1359 1391 if (ff_searchcount > 0) { 1360 pstrcpy(mask,finfo.fname);1392 mask = SMB_STRDUP(finfo.fname); 1361 1393 } else { 1362 pstrcpy(mask,""); 1394 mask = SMB_STRDUP(""); 1395 } 1396 if (!mask) { 1397 SAFE_FREE(rdata); 1398 SAFE_FREE(rparam); 1399 break; 1363 1400 } 1364 1401 … … 1407 1444 /* free up the dirlist buffer and last name raw blob */ 1408 1445 SAFE_FREE(dirlist); 1446 SAFE_FREE(mask); 1409 1447 data_blob_free(&last_name_raw); 1410 1448 return(total_received); … … 1721 1759 return 0; 1722 1760 } 1723
Note:
See TracChangeset
for help on using the changeset viewer.