Changeset 597 for vendor/current/source3/lib
- Timestamp:
- Jul 2, 2011, 4:01:14 PM (14 years ago)
- Location:
- vendor/current/source3/lib
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/lib/access.c
r414 r597 179 179 { 180 180 const char **client = (const char **)item; 181 const char *tok_addr = tok; 182 const char *cli_addr = client[ADDR_INDEX]; 183 184 /* 185 * tok and client[ADDR_INDEX] can be an IPv4 mapped to IPv6, 186 * we try and match the IPv4 part of address only. 187 * Bug #5311 and #7383. 188 */ 189 190 if (strnequal(tok_addr, "::ffff:",7)) { 191 tok_addr += 7; 192 } 193 194 if (strnequal(cli_addr,"::ffff:",7)) { 195 cli_addr += 7; 196 } 181 197 182 198 /* … … 185 201 */ 186 202 187 if (string_match(tok, client[ADDR_INDEX])) { 188 return true; 189 } 190 191 if (strnequal(client[ADDR_INDEX],"::ffff:",7) && 192 !strnequal(tok, "::ffff:",7)) { 193 /* client[ADDR_INDEX] is an IPv4 mapped to IPv6, but 194 * the list item is not. Try and match the IPv4 part of 195 * address only. This will happen a lot on IPv6 enabled 196 * systems with IPv4 allow/deny lists in smb.conf. 197 * Bug #5311. JRA. 198 */ 199 if (string_match(tok, (client[ADDR_INDEX])+7)) { 200 return true; 201 } 203 if (string_match(tok_addr, cli_addr)) { 204 return true; 202 205 } 203 206 -
vendor/current/source3/lib/charcnv.c
r414 r597 574 574 return false; 575 575 } 576 576 577 if (srclen == 0) { 577 ob = talloc_strdup(ctx, ""); 578 /* We really should treat this as an error, but 579 there are too many callers that need this to 580 return a NULL terminated string in the correct 581 character set. */ 582 if (to == CH_UTF16LE|| to == CH_UTF16BE || to == CH_UTF16MUNGED) { 583 destlen = 2; 584 } else { 585 destlen = 1; 586 } 587 ob = talloc_zero_array(ctx, char, destlen); 578 588 if (ob == NULL) { 579 589 errno = ENOMEM; 580 590 return false; 581 591 } 592 *converted_size = destlen; 582 593 *dest = ob; 583 *converted_size = 0;584 594 return true; 585 595 } … … 678 688 ob[destlen+1] = '\0'; 679 689 690 /* Ensure we can never return a *converted_size of zero. */ 691 if (destlen == 0) { 692 /* This can happen from a bad iconv "use_as_is:" call. */ 693 if (to == CH_UTF16LE|| to == CH_UTF16BE || to == CH_UTF16MUNGED) { 694 destlen = 2; 695 } else { 696 destlen = 1; 697 } 698 } 699 680 700 *converted_size = destlen; 681 701 return true; … … 1343 1363 { 1344 1364 size_t ret; 1365 size_t ucs2_align_len = 0; 1345 1366 1346 1367 if (dest_len == (size_t)-1) { … … 1360 1381 if (src_len != (size_t)-1) 1361 1382 src_len--; 1383 ucs2_align_len = 1; 1362 1384 } 1363 1385 … … 1395 1417 } 1396 1418 1397 return src_len ;1419 return src_len + ucs2_align_len; 1398 1420 } 1399 1421 … … 1421 1443 char *dest; 1422 1444 size_t dest_len; 1445 size_t ucs2_align_len = 0; 1423 1446 1424 1447 *ppdest = NULL; … … 1439 1462 if (src_len != (size_t)-1) 1440 1463 src_len--; 1464 ucs2_align_len = 1; 1441 1465 } 1442 1466 … … 1504 1528 1505 1529 *ppdest = dest; 1506 return src_len ;1530 return src_len + ucs2_align_len; 1507 1531 } 1508 1532 -
vendor/current/source3/lib/system_smbd.c
r414 r597 28 28 #ifndef HAVE_GETGROUPLIST 29 29 30 #ifdef HAVE_GETGRSET 31 static int getgrouplist_getgrset(const char *user, gid_t gid, gid_t *groups, 32 int *grpcnt) 33 { 34 char *grplist; 35 char *grp; 36 gid_t temp_gid; 37 int num_gids = 1; 38 int ret = 0; 39 long l; 40 41 grplist = getgrset(user); 42 43 DEBUG(10, ("getgrset returned %s\n", grplist)); 44 45 if (grplist == NULL) { 46 return -1; 47 } 48 49 if (*grpcnt > 0) { 50 groups[0] = gid; 51 } 52 53 while ((grp = strsep(&grplist, ",")) != NULL) { 54 l = strtol(grp, NULL, 10); 55 temp_gid = (gid_t) l; 56 if (temp_gid == gid) { 57 continue; 58 } 59 60 if (num_gids + 1 > *grpcnt) { 61 num_gids++; 62 continue; 63 } 64 groups[num_gids++] = temp_gid; 65 } 66 free(grplist); 67 68 if (num_gids > *grpcnt) { 69 ret = -1; 70 } 71 *grpcnt = num_gids; 72 73 DEBUG(10, ("Found %d groups for user %s\n", *grpcnt, user)); 74 75 return ret; 76 } 77 78 #else /* HAVE_GETGRSET */ 79 30 80 /* 31 81 This is a *much* faster way of getting the list of groups for a user … … 113 163 return ret; 114 164 } 115 #endif 165 #endif /* HAVE_GETGRSET */ 166 #endif /* HAVE_GETGROUPLIST */ 116 167 117 168 static int sys_getgrouplist(const char *user, gid_t gid, gid_t *groups, int *grpcnt) … … 131 182 retval = getgrouplist(user, gid, groups, grpcnt); 132 183 #else 184 #ifdef HAVE_GETGRSET 185 retval = getgrouplist_getgrset(user, gid, groups, grpcnt); 186 #else 133 187 become_root(); 134 188 retval = getgrouplist_internals(user, gid, groups, grpcnt); 135 189 unbecome_root(); 136 #endif 190 #endif /* HAVE_GETGRSET */ 191 #endif /* HAVE_GETGROUPLIST */ 137 192 138 193 /* allow winbindd lookups, but only if they were not already disabled */ -
vendor/current/source3/lib/util.c
r594 r597 1313 1313 strlen(user_name), &nis_result, 1314 1314 &nis_result_len)) == 0) { 1315 if (nis_result_len > 0 && nis_result[nis_result_len] == '\n') { 1316 nis_result[nis_result_len] = '\0'; 1317 } 1315 1318 value = talloc_strdup(ctx, nis_result); 1316 1319 if (!value) { … … 1998 2001 int str_checksum(const char *s) 1999 2002 { 2000 int res = 0; 2001 int c; 2002 int i=0; 2003 2004 while(*s) { 2005 c = *s; 2006 res ^= (c << (i % 15)) ^ (c >> (15-(i%15))); 2007 s++; 2008 i++; 2009 } 2010 return(res); 2003 TDB_DATA key = string_tdb_data(s); 2004 return jenkins_hash(&key); 2011 2005 } 2012 2006 -
vendor/current/source3/lib/util_seaccess.c
r594 r597 113 113 114 114 if (is_sid_in_token(token, sd->owner_sid)) { 115 granted |= SEC_STD_WRITE_DAC | SEC_STD_READ_CONTROL | SEC_STD_DELETE; 116 } else if (user_has_privileges(token, &se_restore)) { 117 granted |= SEC_STD_DELETE; 115 granted |= SEC_STD_WRITE_DAC | SEC_STD_READ_CONTROL; 118 116 } 119 117 … … 172 170 access_desired &= ~SEC_FLAG_MAXIMUM_ALLOWED; 173 171 *access_granted = access_desired; 174 bits_remaining = access_desired & ~SEC_STD_DELETE;172 bits_remaining = access_desired; 175 173 176 174 DEBUG(10,("se_access_check: MAX desired = 0x%x, granted = 0x%x, remaining = 0x%x\n", … … 188 186 } 189 187 188 /* the owner always gets SEC_STD_WRITE_DAC and SEC_STD_READ_CONTROL */ 189 if ((bits_remaining & (SEC_STD_WRITE_DAC|SEC_STD_READ_CONTROL)) && 190 is_sid_in_token(token, sd->owner_sid)) { 191 bits_remaining &= ~(SEC_STD_WRITE_DAC|SEC_STD_READ_CONTROL); 192 } 193 if ((bits_remaining & SEC_STD_DELETE) && 194 user_has_privileges(token, &se_restore)) { 195 bits_remaining &= ~SEC_STD_DELETE; 196 } 197 190 198 /* a NULL dacl allows access */ 191 199 if ((sd->type & SEC_DESC_DACL_PRESENT) && sd->dacl == NULL) { 192 200 *access_granted = access_desired; 193 201 return NT_STATUS_OK; 194 }195 196 /* the owner always gets SEC_STD_WRITE_DAC, SEC_STD_READ_CONTROL and SEC_STD_DELETE */197 if ((bits_remaining & (SEC_STD_WRITE_DAC|SEC_STD_READ_CONTROL|SEC_STD_DELETE)) &&198 is_sid_in_token(token, sd->owner_sid)) {199 bits_remaining &= ~(SEC_STD_WRITE_DAC|SEC_STD_READ_CONTROL|SEC_STD_DELETE);200 }201 if ((bits_remaining & SEC_STD_DELETE) &&202 user_has_privileges(token, &se_restore)) {203 bits_remaining &= ~SEC_STD_DELETE;204 202 } 205 203 -
vendor/current/source3/lib/util_sock.c
r591 r597 1840 1840 1841 1841 /************************************************************ 1842 Is this my ip address ? 1843 ************************************************************/ 1844 1845 static bool is_my_ipaddr(const char *ipaddr_str) 1846 { 1847 struct sockaddr_storage ss; 1848 struct iface_struct *nics; 1849 int i, n; 1850 1851 if (!interpret_string_addr(&ss, ipaddr_str, AI_NUMERICHOST)) { 1852 return false; 1853 } 1854 1855 if (ismyaddr((struct sockaddr *)&ss)) { 1856 return true; 1857 } 1858 1859 if (is_zero_addr((struct sockaddr *)&ss) || 1860 is_loopback_addr((struct sockaddr *)&ss)) { 1861 return false; 1862 } 1863 1864 n = get_interfaces(talloc_tos(), &nics); 1865 for (i=0; i<n; i++) { 1866 if (sockaddr_equal((struct sockaddr *)&nics[i].ip, (struct sockaddr *)&ss)) { 1867 TALLOC_FREE(nics); 1868 return true; 1869 } 1870 } 1871 TALLOC_FREE(nics); 1872 return false; 1873 } 1874 1875 /************************************************************ 1842 1876 Is this my name ? 1843 1877 ************************************************************/ … … 1846 1880 { 1847 1881 TALLOC_CTX *ctx = talloc_tos(); 1848 char addr[INET6_ADDRSTRLEN];1849 1882 char *name = NULL; 1850 1883 const char *dnsname; … … 1894 1927 } 1895 1928 1896 /* Handle possible CNAME records - convert to an IP addr. */1929 /* Handle possible CNAME records - convert to an IP addr. list. */ 1897 1930 if (!is_ipaddress(servername)) { 1898 /* Use DNS to resolve the name, but only the first address */ 1899 struct sockaddr_storage ss; 1900 if (interpret_string_addr(&ss, servername, 0)) { 1931 /* Use DNS to resolve the name, check all addresses. */ 1932 struct addrinfo *p = NULL; 1933 struct addrinfo *res = NULL; 1934 1935 if (!interpret_string_addr_internal(&res, 1936 servername, 1937 AI_ADDRCONFIG)) { 1938 return false; 1939 } 1940 1941 for (p = res; p; p = p->ai_next) { 1942 char addr[INET6_ADDRSTRLEN]; 1943 struct sockaddr_storage ss; 1944 1945 ZERO_STRUCT(ss); 1946 memcpy(&ss, p->ai_addr, p->ai_addrlen); 1901 1947 print_sockaddr(addr, 1902 1948 sizeof(addr), 1903 1949 &ss); 1904 servername = addr; 1905 } 1950 if (is_my_ipaddr(addr)) { 1951 freeaddrinfo(res); 1952 return true; 1953 } 1954 } 1955 freeaddrinfo(res); 1906 1956 } 1907 1957 1908 1958 /* Maybe its an IP address? */ 1909 1959 if (is_ipaddress(servername)) { 1910 struct sockaddr_storage ss; 1911 struct iface_struct *nics; 1912 int i, n; 1913 1914 if (!interpret_string_addr(&ss, servername, AI_NUMERICHOST)) { 1915 return false; 1916 } 1917 1918 if (ismyaddr((struct sockaddr *)&ss)) { 1919 return true; 1920 } 1921 1922 if (is_zero_addr((struct sockaddr *)&ss) || 1923 is_loopback_addr((struct sockaddr *)&ss)) { 1924 return false; 1925 } 1926 1927 n = get_interfaces(talloc_tos(), &nics); 1928 for (i=0; i<n; i++) { 1929 if (sockaddr_equal((struct sockaddr *)&nics[i].ip, (struct sockaddr *)&ss)) { 1930 TALLOC_FREE(nics); 1931 return true; 1932 } 1933 } 1934 TALLOC_FREE(nics); 1960 return is_my_ipaddr(servername); 1935 1961 } 1936 1962 -
vendor/current/source3/lib/util_str.c
r594 r597 587 587 zero. Strips out all but 'a-Z0-9' and the character in other_safe_chars 588 588 and replaces with '_'. Deliberately does *NOT* check for multibyte 589 characters. Don't change it ! 589 characters. Treats src as an array of bytes, not as a multibyte 590 string. Any byte >0x7f is automatically converted to '_'. 591 other_safe_chars must also contain an ascii string (bytes<0x7f). 590 592 **/ 591 593 … … 623 625 for(i = 0; i < len; i++) { 624 626 int val = (src[i] & 0xff); 625 if (isupper_ascii(val) || islower_ascii(val) || 626 isdigit(val) || strchr_m(other_safe_chars, val)) 627 if (val > 0x7f) { 628 dest[i] = '_'; 629 continue; 630 } 631 if (isupper(val) || islower(val) || 632 isdigit(val) || strchr(other_safe_chars, val)) 627 633 dest[i] = src[i]; 628 634 else
Note:
See TracChangeset
for help on using the changeset viewer.