Ignore:
Timestamp:
Jul 2, 2011, 4:01:14 PM (14 years ago)
Author:
Herwig Bauernfeind
Message:

Samba 3.5: Update vendor to version 3.5.9

Location:
vendor/current/source3/lib
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/lib/access.c

    r414 r597  
    179179{
    180180        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        }
    181197
    182198        /*
     
    185201         */
    186202
    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;
    202205        }
    203206
  • vendor/current/source3/lib/charcnv.c

    r414 r597  
    574574                return false;
    575575        }
     576
    576577        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);
    578588                if (ob == NULL) {
    579589                        errno = ENOMEM;
    580590                        return false;
    581591                }
     592                *converted_size = destlen;
    582593                *dest = ob;
    583                 *converted_size = 0;
    584594                return true;
    585595        }
     
    678688        ob[destlen+1] = '\0';
    679689
     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
    680700        *converted_size = destlen;
    681701        return true;
     
    13431363{
    13441364        size_t ret;
     1365        size_t ucs2_align_len = 0;
    13451366
    13461367        if (dest_len == (size_t)-1) {
     
    13601381                if (src_len != (size_t)-1)
    13611382                        src_len--;
     1383                ucs2_align_len = 1;
    13621384        }
    13631385
     
    13951417        }
    13961418
    1397         return src_len;
     1419        return src_len + ucs2_align_len;
    13981420}
    13991421
     
    14211443        char *dest;
    14221444        size_t dest_len;
     1445        size_t ucs2_align_len = 0;
    14231446
    14241447        *ppdest = NULL;
     
    14391462                if (src_len != (size_t)-1)
    14401463                        src_len--;
     1464                ucs2_align_len = 1;
    14411465        }
    14421466
     
    15041528
    15051529        *ppdest = dest;
    1506         return src_len;
     1530        return src_len + ucs2_align_len;
    15071531}
    15081532
  • vendor/current/source3/lib/system_smbd.c

    r414 r597  
    2828#ifndef HAVE_GETGROUPLIST
    2929
     30#ifdef HAVE_GETGRSET
     31static 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
    3080/*
    3181  This is a *much* faster way of getting the list of groups for a user
     
    113163        return ret;
    114164}
    115 #endif
     165#endif /* HAVE_GETGRSET */
     166#endif /* HAVE_GETGROUPLIST */
    116167
    117168static int sys_getgrouplist(const char *user, gid_t gid, gid_t *groups, int *grpcnt)
     
    131182        retval = getgrouplist(user, gid, groups, grpcnt);
    132183#else
     184#ifdef HAVE_GETGRSET
     185        retval = getgrouplist_getgrset(user, gid, groups, grpcnt);
     186#else
    133187        become_root();
    134188        retval = getgrouplist_internals(user, gid, groups, grpcnt);
    135189        unbecome_root();
    136 #endif
     190#endif /* HAVE_GETGRSET */
     191#endif /* HAVE_GETGROUPLIST */
    137192
    138193        /* allow winbindd lookups, but only if they were not already disabled */
  • vendor/current/source3/lib/util.c

    r594 r597  
    13131313                                        strlen(user_name), &nis_result,
    13141314                                        &nis_result_len)) == 0) {
     1315                if (nis_result_len > 0 && nis_result[nis_result_len] == '\n') {
     1316                        nis_result[nis_result_len] = '\0';
     1317                }
    13151318                value = talloc_strdup(ctx, nis_result);
    13161319                if (!value) {
     
    19982001int str_checksum(const char *s)
    19992002{
    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);
    20112005}
    20122006
  • vendor/current/source3/lib/util_seaccess.c

    r594 r597  
    113113
    114114        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;
    118116        }
    119117
     
    172170                access_desired &= ~SEC_FLAG_MAXIMUM_ALLOWED;
    173171                *access_granted = access_desired;
    174                 bits_remaining = access_desired & ~SEC_STD_DELETE;
     172                bits_remaining = access_desired;
    175173
    176174                DEBUG(10,("se_access_check: MAX desired = 0x%x, granted = 0x%x, remaining = 0x%x\n",
     
    188186        }
    189187
     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
    190198        /* a NULL dacl allows access */
    191199        if ((sd->type & SEC_DESC_DACL_PRESENT) && sd->dacl == NULL) {
    192200                *access_granted = access_desired;
    193201                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;
    204202        }
    205203
  • vendor/current/source3/lib/util_sock.c

    r591 r597  
    18401840
    18411841/************************************************************
     1842 Is this my ip address ?
     1843************************************************************/
     1844
     1845static 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/************************************************************
    18421876 Is this my name ?
    18431877************************************************************/
     
    18461880{
    18471881        TALLOC_CTX *ctx = talloc_tos();
    1848         char addr[INET6_ADDRSTRLEN];
    18491882        char *name = NULL;
    18501883        const char *dnsname;
     
    18941927        }
    18951928
    1896         /* Handle possible CNAME records - convert to an IP addr. */
     1929        /* Handle possible CNAME records - convert to an IP addr. list. */
    18971930        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);
    19011947                        print_sockaddr(addr,
    19021948                                        sizeof(addr),
    19031949                                        &ss);
    1904                         servername = addr;
    1905                 }
     1950                        if (is_my_ipaddr(addr)) {
     1951                                freeaddrinfo(res);
     1952                                return true;
     1953                        }
     1954                }
     1955                freeaddrinfo(res);
    19061956        }
    19071957
    19081958        /* Maybe its an IP address? */
    19091959        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);
    19351961        }
    19361962
  • vendor/current/source3/lib/util_str.c

    r594 r597  
    587587 zero. Strips out all but 'a-Z0-9' and the character in other_safe_chars
    588588 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).
    590592**/
    591593
     
    623625        for(i = 0; i < len; i++) {
    624626                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))
    627633                        dest[i] = src[i];
    628634                else
Note: See TracChangeset for help on using the changeset viewer.