Changeset 232 for branches/samba-3.2.x/source/libsmb
- Timestamp:
- May 27, 2009, 9:09:42 AM (16 years ago)
- Location:
- branches/samba-3.2.x/source/libsmb
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.2.x/source/libsmb/async_smb.c
r204 r232 319 319 { 320 320 struct cli_state *cli = (struct cli_state *)p; 321 struct cli_request *req ;321 struct cli_request *req, *next; 322 322 NTSTATUS status; 323 323 … … 422 422 423 423 sock_error: 424 for (req = cli->outstanding_requests; req; req = req->next) { 424 for (req = cli->outstanding_requests; req; req = next) { 425 next = req; 425 426 async_req_error(req->async, status); 426 427 } -
branches/samba-3.2.x/source/libsmb/cliconnect.c
r228 r232 537 537 #define BASE_SESSSETUP_BLOB_PACKET_SIZE (35 + 24 + 22) 538 538 539 static bool cli_session_setup_blob(struct cli_state *cli, DATA_BLOB blob , DATA_BLOB session_key_krb5)539 static bool cli_session_setup_blob(struct cli_state *cli, DATA_BLOB blob) 540 540 { 541 541 int32 remaining = blob.length; … … 561 561 remaining -= max_blob_size; 562 562 } else { 563 DATA_BLOB null_blob = data_blob_null;564 565 563 send_blob.length = remaining; 566 564 remaining = 0; 567 568 /* This is the last packet in the sequence - turn signing on. */569 cli_simple_set_signing(cli, session_key_krb5, null_blob);570 565 } 571 566 … … 615 610 DATA_BLOB negTokenTarg; 616 611 DATA_BLOB session_key_krb5; 612 NTSTATUS nt_status; 617 613 int rc; 614 615 cli_temp_set_signing(cli); 618 616 619 617 DEBUG(2,("Doing kerberos session setup\n")); … … 632 630 #endif 633 631 634 if (!cli_session_setup_blob(cli, negTokenTarg, session_key_krb5)) { 635 data_blob_free(&negTokenTarg); 636 data_blob_free(&session_key_krb5); 637 return ADS_ERROR_NT(cli_nt_error(cli)); 632 if (!cli_session_setup_blob(cli, negTokenTarg)) { 633 nt_status = cli_nt_error(cli); 634 goto nt_error; 635 } 636 637 if (cli_is_error(cli)) { 638 nt_status = cli_nt_error(cli); 639 if (NT_STATUS_IS_OK(nt_status)) { 640 nt_status = NT_STATUS_UNSUCCESSFUL; 641 } 642 goto nt_error; 638 643 } 639 644 640 645 cli_set_session_key(cli, session_key_krb5); 646 647 if (cli_simple_set_signing( 648 cli, session_key_krb5, data_blob_null)) { 649 650 /* 'resign' the last message, so we get the right sequence numbers 651 for checking the first reply from the server */ 652 cli_calculate_sign_mac(cli, cli->outbuf); 653 654 if (!cli_check_sign_mac(cli, cli->inbuf)) { 655 nt_status = NT_STATUS_ACCESS_DENIED; 656 goto nt_error; 657 } 658 } 641 659 642 660 data_blob_free(&negTokenTarg); 643 661 data_blob_free(&session_key_krb5); 644 662 645 if (cli_is_error(cli)) { 646 if (NT_STATUS_IS_OK(cli_nt_error(cli))) { 647 return ADS_ERROR_NT(NT_STATUS_UNSUCCESSFUL); 648 } 649 } 650 return ADS_ERROR_NT(cli_nt_error(cli)); 663 return ADS_ERROR_NT(NT_STATUS_OK); 664 665 nt_error: 666 data_blob_free(&negTokenTarg); 667 data_blob_free(&session_key_krb5); 668 cli->vuid = 0; 669 return ADS_ERROR_NT(nt_status); 651 670 } 652 671 #endif /* HAVE_KRB5 */ -
branches/samba-3.2.x/source/libsmb/clidfs.c
r228 r232 307 307 308 308 if (p) { 309 char *name = clean_name(NULL, p->mount);309 char *name = clean_name(NULL, mnt); 310 310 if (!name) { 311 311 return; 312 312 } 313 TALLOC_FREE(p->mount); 313 314 p->mount = talloc_strdup(p, name); 314 315 TALLOC_FREE(name); -
branches/samba-3.2.x/source/libsmb/clientgen.c
r141 r232 316 316 size_t len = SVAL(cli->outbuf,smb_vwv11) + 4; 317 317 size_t nwritten=0; 318 s size_t ret;318 struct iovec iov[2]; 319 319 320 320 /* fd == -1 causes segfaults -- Tom (tom@ninja.nl) */ … … 328 328 } 329 329 330 while (nwritten < len) { 331 ret = write_socket(cli->fd,cli->outbuf+nwritten,len - nwritten); 332 if (ret <= 0) { 333 close(cli->fd); 334 cli->fd = -1; 335 cli->smb_rw_error = SMB_WRITE_ERROR; 336 DEBUG(0,("Error writing %d bytes to client. %d (%s)\n", 337 (int)len,(int)ret, strerror(errno) )); 338 return false; 339 } 340 nwritten += ret; 341 } 342 343 /* Now write the extra data. */ 344 nwritten=0; 345 while (nwritten < extradata) { 346 ret = write_socket(cli->fd,p+nwritten,extradata - nwritten); 347 if (ret <= 0) { 348 close(cli->fd); 349 cli->fd = -1; 350 cli->smb_rw_error = SMB_WRITE_ERROR; 351 DEBUG(0,("Error writing %d extradata " 352 "bytes to client. %d (%s)\n", 353 (int)extradata,(int)ret, strerror(errno) )); 354 return false; 355 } 356 nwritten += ret; 330 iov[0].iov_base = cli->outbuf; 331 iov[0].iov_len = len; 332 iov[1].iov_base = CONST_DISCARD(char *, p); 333 iov[1].iov_len = extradata; 334 335 nwritten = write_data_iov(cli->fd, iov, 2); 336 if (nwritten < (len + extradata)) { 337 close(cli->fd); 338 cli->fd = -1; 339 cli->smb_rw_error = SMB_WRITE_ERROR; 340 DEBUG(0,("Error writing %d bytes to client. (%s)\n", 341 (int)(len+extradata), strerror(errno))); 342 return false; 357 343 } 358 344 -
branches/samba-3.2.x/source/libsmb/clilist.c
r228 r232 80 80 p += clistr_align_in(cli, p, 0); 81 81 82 /* We can safely use +1 here (which is required by OS/2) 83 * instead of +2 as the STR_TERMINATE flag below is 82 /* We can safely use len here (which is required by OS/2) 83 * and the NAS-BASIC server instead of +2 or +1 as the 84 * STR_TERMINATE flag below is 84 85 * actually used as the length calculation. 85 * The len +2is merely an upper bound.86 * The len is merely an upper bound. 86 87 * Due to the explicit 2 byte null termination 87 88 * in cli_receive_trans/cli_receive_nt_trans … … 89 90 */ 90 91 91 if (p + len + 1> pdata_end) {92 if (p + len > pdata_end) { 92 93 return pdata_end - base; 93 94 } -
branches/samba-3.2.x/source/libsmb/dsgetdcname.c
r228 r232 1384 1384 } 1385 1385 1386 static bool is_closest_site(struct netr_DsRGetDCNameInfo *info) 1387 { 1388 if (info->dc_flags & DS_SERVER_CLOSEST) { 1389 return true; 1390 } 1391 1392 if (!info->client_site_name) { 1393 return true; 1394 } 1395 1396 if (!info->dc_site_name) { 1397 return false; 1398 } 1399 1400 if (strcmp(info->client_site_name, info->dc_site_name) == 0) { 1401 return true; 1402 } 1403 1404 return false; 1405 } 1406 1386 1407 /******************************************************************** 1387 1408 dsgetdcname. … … 1401 1422 struct netr_DsRGetDCNameInfo *myinfo = NULL; 1402 1423 char *query_site = NULL; 1424 bool first = true; 1425 struct netr_DsRGetDCNameInfo *first_info = NULL; 1403 1426 1404 1427 DEBUG(10,("dsgetdcname: domain_name: %s, " … … 1428 1451 flags, query_site, &myinfo); 1429 1452 if (NT_STATUS_IS_OK(status)) { 1430 *info = myinfo;1431 1453 goto done; 1432 1454 } … … 1441 1463 &myinfo); 1442 1464 1443 if (NT_STATUS_IS_OK(status)) {1444 *info = myinfo;1445 }1446 1447 1465 done: 1448 1466 SAFE_FREE(query_site); 1449 1467 1450 return status; 1451 } 1468 if (!NT_STATUS_IS_OK(status)) { 1469 if (!first) { 1470 *info = first_info; 1471 return NT_STATUS_OK; 1472 } 1473 return status; 1474 } 1475 1476 if (!first) { 1477 TALLOC_FREE(first_info); 1478 } else if (!is_closest_site(myinfo)) { 1479 first = false; 1480 first_info = myinfo; 1481 /* TODO: may use the next_closest_site here */ 1482 query_site = SMB_STRDUP(myinfo->client_site_name); 1483 goto rediscover; 1484 } 1485 1486 *info = myinfo; 1487 return NT_STATUS_OK; 1488 } -
branches/samba-3.2.x/source/libsmb/libsmb_context.c
r149 r232 70 70 smbc_setOptionOpenShareMode(context, SMBC_SHAREMODE_DENY_NONE); 71 71 smbc_setOptionSmbEncryptionLevel(context, SMBC_ENCRYPTLEVEL_NONE); 72 smbc_setOptionCaseSensitive(context, False); 72 73 smbc_setOptionBrowseMaxLmbCount(context, 3); /* # LMBs to query */ 73 74 smbc_setOptionUrlEncodeReaddirEntries(context, False); -
branches/samba-3.2.x/source/libsmb/libsmb_dir.c
r149 r232 896 896 /* url-encode the name. get back remaining buffer space */ 897 897 max_namebuf_len = 898 SMBC_urlencode(dest->name, src->name, max_namebuf_len);898 smbc_urlencode(dest->name, src->name, max_namebuf_len); 899 899 900 900 /* We now know the name length */ … … 978 978 } 979 979 980 dirp = (struct smbc_dirent *)context->internal->dirent; 981 maxlen = (sizeof(context->internal->dirent) - 982 sizeof(struct smbc_dirent)); 980 dirp = &context->internal->dirent; 981 maxlen = sizeof(context->internal->_dirent_name); 983 982 984 983 smbc_readdir_internal(context, dirp, dirent, maxlen); … … 1052 1051 1053 1052 /* Do urlencoding of next entry, if so selected */ 1054 dirent = (struct smbc_dirent *)context->internal->dirent; 1055 maxlen = (sizeof(context->internal->dirent) - 1056 sizeof(struct smbc_dirent)); 1053 dirent = &context->internal->dirent; 1054 maxlen = sizeof(context->internal->_dirent_name); 1057 1055 smbc_readdir_internal(context, dirent, 1058 1056 dirlist->dirent, maxlen); -
branches/samba-3.2.x/source/libsmb/libsmb_path.c
r133 r232 42 42 43 43 /* 44 * SMBC_urldecode()44 * smbc_urldecode() 45 45 * and urldecode_talloc() (internal fn.) 46 46 * … … 123 123 124 124 int 125 SMBC_urldecode(char *dest,125 smbc_urldecode(char *dest, 126 126 char *src, 127 127 size_t max_dest_len) … … 139 139 140 140 /* 141 * SMBC_urlencode()141 * smbc_urlencode() 142 142 * 143 143 * Convert any characters not specifically allowed in a URL into their %xx … … 147 147 */ 148 148 int 149 SMBC_urlencode(char *dest,149 smbc_urlencode(char *dest, 150 150 char *src, 151 151 int max_dest_len) … … 287 287 288 288 /* Copy the options */ 289 if ( *pp_options != NULL) {289 if (pp_options && *pp_options != NULL) { 290 290 TALLOC_FREE(*pp_options); 291 291 *pp_options = talloc_strdup(ctx, q); -
branches/samba-3.2.x/source/libsmb/libsmb_server.c
r228 r232 246 246 int port_try_first; 247 247 int port_try_next; 248 int is_ipc = (share != NULL && strcmp(share, "IPC$") == 0); 249 uint32 fs_attrs = 0; 248 250 const char *username_used; 249 251 NTSTATUS status; … … 311 313 } 312 314 315 /* Determine if this share supports case sensitivity */ 316 if (is_ipc) { 317 DEBUG(4, 318 ("IPC$ so ignore case sensitivity\n")); 319 } else if (!cli_get_fs_attr_info(c, &fs_attrs)) { 320 DEBUG(4, ("Could not retrieve " 321 "case sensitivity flag: %s.\n", 322 cli_errstr(c))); 323 324 /* 325 * We can't determine the case sensitivity of 326 * the share. We have no choice but to use the 327 * user-specified case sensitivity setting. 328 */ 329 if (smbc_getOptionCaseSensitive(context)) { 330 cli_set_case_sensitive(c, True); 331 } else { 332 cli_set_case_sensitive(c, False); 333 } 334 } else { 335 DEBUG(4, 336 ("Case sensitive: %s\n", 337 (fs_attrs & FILE_CASE_SENSITIVE_SEARCH 338 ? "True" 339 : "False"))); 340 cli_set_case_sensitive( 341 c, 342 (fs_attrs & FILE_CASE_SENSITIVE_SEARCH 343 ? True 344 : False)); 345 } 346 313 347 /* 314 348 * Regenerate the dev value since it's based on both … … 356 390 return NULL; 357 391 } 358 392 359 393 if (smbc_getOptionUseKerberos(context)) { 360 394 c->use_kerberos = True; … … 371 405 * null, so browse lists can work 372 406 */ 373 if (share == NULL || *share == '\0' || strcmp(share, "IPC$") == 0) {407 if (share == NULL || *share == '\0' || is_ipc) { 374 408 port_try_first = 139; 375 409 port_try_next = 445; … … 475 509 DEBUG(4,(" tconx ok\n")); 476 510 511 /* Determine if this share supports case sensitivity */ 512 if (is_ipc) { 513 DEBUG(4, ("IPC$ so ignore case sensitivity\n")); 514 } else if (!cli_get_fs_attr_info(c, &fs_attrs)) { 515 DEBUG(4, ("Could not retrieve case sensitivity flag: %s.\n", 516 cli_errstr(c))); 517 518 /* 519 * We can't determine the case sensitivity of the share. We 520 * have no choice but to use the user-specified case 521 * sensitivity setting. 522 */ 523 if (smbc_getOptionCaseSensitive(context)) { 524 cli_set_case_sensitive(c, True); 525 } else { 526 cli_set_case_sensitive(c, False); 527 } 528 } else { 529 DEBUG(4, ("Case sensitive: %s\n", 530 (fs_attrs & FILE_CASE_SENSITIVE_SEARCH 531 ? "True" 532 : "False"))); 533 cli_set_case_sensitive(c, 534 (fs_attrs & FILE_CASE_SENSITIVE_SEARCH 535 ? True 536 : False)); 537 } 538 477 539 if (context->internal->smb_encryption_level) { 478 540 /* Attempt UNIX smb encryption. */ -
branches/samba-3.2.x/source/libsmb/libsmb_setget.c
r133 r232 195 195 196 196 /** 197 * Get whether to treat file names as case-sensitive if we can't determine 198 * when connecting to the remote share whether the file system is case 199 * sensitive. This defaults to FALSE since it's most likely that if we can't 200 * retrieve the file system attributes, it's a very old file system that does 201 * not support case sensitivity. 202 */ 203 smbc_bool 204 smbc_getOptionCaseSensitive(SMBCCTX *c) 205 { 206 return c->internal->case_sensitive; 207 } 208 209 /** 210 * Set whether to treat file names as case-sensitive if we can't determine 211 * when connecting to the remote share whether the file system is case 212 * sensitive. This defaults to FALSE since it's most likely that if we can't 213 * retrieve the file system attributes, it's a very old file system that does 214 * not support case sensitivity. 215 */ 216 void 217 smbc_setOptionCaseSensitive(SMBCCTX *c, smbc_bool b) 218 { 219 c->internal->case_sensitive = b; 220 } 221 222 /** 197 223 * Get from how many local master browsers should the list of workgroups be 198 224 * retrieved. It can take up to 12 minutes or longer after a server becomes a -
branches/samba-3.2.x/source/libsmb/libsmb_xattr.c
r204 r232 199 199 } 200 200 201 TALLOC_FREE(ctx);202 201 /* Converted OK */ 203 202 … … 205 204 domains[0], lp_winbind_separator(), 206 205 names[0]); 206 207 TALLOC_FREE(ctx); 207 208 } 208 209 -
branches/samba-3.2.x/source/libsmb/namequery.c
r228 r232 35 35 #define SAFKEY_FMT "SAF/DOMAIN/%s" 36 36 #define SAF_TTL 900 37 #define SAFJOINKEY_FMT "SAFJOIN/DOMAIN/%s" 38 #define SAFJOIN_TTL 3600 37 39 38 40 static char *saf_key(const char *domain) … … 41 43 42 44 asprintf_strupper_m(&keystr, SAFKEY_FMT, domain); 45 46 return keystr; 47 } 48 49 static char *saf_join_key(const char *domain) 50 { 51 char *keystr; 52 53 asprintf_strupper_m(&keystr, SAFJOINKEY_FMT, domain); 43 54 44 55 return keystr; … … 70 81 71 82 key = saf_key( domain ); 72 expire = time( NULL ) + SAF_TTL;83 expire = time( NULL ) + lp_parm_int(-1, "saf","ttl", SAF_TTL); 73 84 74 85 DEBUG(10,("saf_store: domain = [%s], server = [%s], expire = [%u]\n", 86 domain, servername, (unsigned int)expire )); 87 88 ret = gencache_set( key, servername, expire ); 89 90 SAFE_FREE( key ); 91 92 return ret; 93 } 94 95 bool saf_join_store( const char *domain, const char *servername ) 96 { 97 char *key; 98 time_t expire; 99 bool ret = False; 100 101 if ( !domain || !servername ) { 102 DEBUG(2,("saf_join_store: Refusing to store empty domain or servername!\n")); 103 return False; 104 } 105 106 if ( (strlen(domain) == 0) || (strlen(servername) == 0) ) { 107 DEBUG(0,("saf_join_store: refusing to store 0 length domain or servername!\n")); 108 return False; 109 } 110 111 if ( !gencache_init() ) 112 return False; 113 114 key = saf_join_key( domain ); 115 expire = time( NULL ) + lp_parm_int(-1, "saf","join ttl", SAFJOIN_TTL); 116 117 DEBUG(10,("saf_join_store: domain = [%s], server = [%s], expire = [%u]\n", 75 118 domain, servername, (unsigned int)expire )); 76 119 … … 95 138 return False; 96 139 140 key = saf_join_key(domain); 141 ret = gencache_del(key); 142 SAFE_FREE(key); 143 144 if (ret) { 145 DEBUG(10,("saf_delete[join]: domain = [%s]\n", domain )); 146 } 147 97 148 key = saf_key(domain); 98 149 ret = gencache_del(key); 150 SAFE_FREE(key); 99 151 100 152 if (ret) { 101 153 DEBUG(10,("saf_delete: domain = [%s]\n", domain )); 102 154 } 103 104 SAFE_FREE( key );105 155 106 156 return ret; … … 124 174 if ( !gencache_init() ) 125 175 return False; 176 177 key = saf_join_key( domain ); 178 179 ret = gencache_get( key, &server, &timeout ); 180 181 SAFE_FREE( key ); 182 183 if ( ret ) { 184 DEBUG(5,("saf_fetch[join]: Returning \"%s\" for \"%s\" domain\n", 185 server, domain )); 186 return server; 187 } 126 188 127 189 key = saf_key( domain ); … … 2099 2161 status = get_dc_list(domain, sitename, ip_list, 2100 2162 count, lookup_type, &ordered); 2163 if (NT_STATUS_EQUAL(status, NT_STATUS_NO_LOGON_SERVERS) 2164 && sitename) { 2165 DEBUG(3,("get_sorted_dc_list: no server for name %s available" 2166 " in site %s, fallback to all servers\n", 2167 domain, sitename)); 2168 status = get_dc_list(domain, NULL, ip_list, 2169 count, lookup_type, &ordered); 2170 } 2171 2101 2172 if (!NT_STATUS_IS_OK(status)) { 2102 2173 SAFE_FREE(*ip_list);
Note:
See TracChangeset
for help on using the changeset viewer.