Changeset 746 for vendor/current/libcli


Ignore:
Timestamp:
Nov 27, 2012, 4:56:06 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated vendor to 3.6.9

Location:
vendor/current/libcli
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/libcli/auth/credentials.c

    r740 r746  
    7070        unsigned char zero[4], tmp[16];
    7171        HMACMD5Context ctx;
    72         struct MD5Context md5;
     72        MD5_CTX md5;
    7373
    7474        ZERO_STRUCT(creds->session_key);
  • vendor/current/libcli/auth/ntlm_check.c

    r740 r746  
    8888                                 const DATA_BLOB *sec_blob,
    8989                                 const char *user, const char *domain,
    90                                  bool upper_case_domain, /* should the domain be transformed into upper case? */
    9190                                 DATA_BLOB *user_sess_key)
    9291{
     
    123122        */
    124123
    125         if (!ntv2_owf_gen(part_passwd, user, domain, upper_case_domain, kr)) {
     124        if (!ntv2_owf_gen(part_passwd, user, domain, kr)) {
    126125                return false;
    127126        }
     
    162161                                const DATA_BLOB *sec_blob,
    163162                                const char *user, const char *domain,
    164                                 bool upper_case_domain, /* should the domain be transformed into upper case? */
    165163                                DATA_BLOB *user_sess_key)
    166164{
     
    193191        client_key_data = data_blob_talloc(mem_ctx, ntv2_response->data+16, ntv2_response->length-16);
    194192
    195         if (!ntv2_owf_gen(part_passwd, user, domain, upper_case_domain, kr)) {
     193        if (!ntv2_owf_gen(part_passwd, user, domain, kr)) {
    196194                return false;
    197195        }
     
    298296        const static uint8_t zeros[8];
    299297        DATA_BLOB tmp_sess_key;
     298        const char *upper_client_domain = NULL;
     299
     300        if (client_domain != NULL) {
     301                upper_client_domain = talloc_strdup_upper(mem_ctx, client_domain);
     302                if (upper_client_domain == NULL) {
     303                        return NT_STATUS_NO_MEMORY;
     304                }
     305        }
    300306
    301307        if (stored_nt == NULL) {
     
    349355                   use it
    350356                */
    351                 DEBUG(4,("ntlm_password_check: Checking NTLMv2 password with domain [%s]\n", client_domain));
     357                DEBUG(4,("ntlm_password_check: Checking NTLMv2 password with domain [%s]\n",
     358                        client_domain ? client_domain : "<NULL>"));
    352359                if (smb_pwd_check_ntlmv2(mem_ctx,
    353360                                         nt_response,
     
    355362                                         client_username,
    356363                                         client_domain,
    357                                          false,
    358364                                         user_sess_key)) {
    359365                        if (user_sess_key->length) {
     
    363369                }
    364370
    365                 DEBUG(4,("ntlm_password_check: Checking NTLMv2 password with uppercased version of domain [%s]\n", client_domain));
     371                DEBUG(4,("ntlm_password_check: Checking NTLMv2 password with uppercased version of domain [%s]\n",
     372                        upper_client_domain ? upper_client_domain : "<NULL>"));
    366373                if (smb_pwd_check_ntlmv2(mem_ctx,
    367374                                         nt_response,
    368375                                         stored_nt->hash, challenge,
    369376                                         client_username,
    370                                          client_domain,
    371                                          true,
     377                                         upper_client_domain,
    372378                                         user_sess_key)) {
    373379                        if (user_sess_key->length) {
     
    383389                                         client_username,
    384390                                         "",
    385                                          false,
    386391                                         user_sess_key)) {
    387392                        if (user_sess_key->length) {
     
    471476           - related to Win9X, legacy NAS pass-though authentication
    472477        */
    473         DEBUG(4,("ntlm_password_check: Checking LMv2 password with domain %s\n", client_domain));
     478        DEBUG(4,("ntlm_password_check: Checking LMv2 password with domain %s\n",
     479                client_domain ? client_domain : "<NULL>"));
    474480        if (smb_pwd_check_ntlmv2(mem_ctx,
    475481                                 lm_response,
     
    477483                                 client_username,
    478484                                 client_domain,
    479                                  false,
    480485                                 &tmp_sess_key)) {
    481486                if (nt_response->length > 24) {
     
    489494                                            client_username,
    490495                                            client_domain,
    491                                             false,
    492496                                            user_sess_key);
    493497                } else {
     
    501505        }
    502506
    503         DEBUG(4,("ntlm_password_check: Checking LMv2 password with upper-cased version of domain %s\n", client_domain));
     507        DEBUG(4,("ntlm_password_check: Checking LMv2 password with upper-cased version of domain %s\n",
     508                upper_client_domain ? upper_client_domain : "<NULL>"));
    504509        if (smb_pwd_check_ntlmv2(mem_ctx,
    505510                                 lm_response,
    506511                                 stored_nt->hash, challenge,
    507512                                 client_username,
    508                                  client_domain,
    509                                  true,
     513                                 upper_client_domain,
    510514                                 &tmp_sess_key)) {
    511515                if (nt_response->length > 24) {
     
    518522                                            stored_nt->hash, challenge,
    519523                                            client_username,
    520                                             client_domain,
    521                                             true,
     524                                            upper_client_domain,
    522525                                            user_sess_key);
    523526                } else {
     
    537540                                 client_username,
    538541                                 "",
    539                                  false,
    540542                                 &tmp_sess_key)) {
    541543                if (nt_response->length > 24) {
     
    549551                                            client_username,
    550552                                            "",
    551                                             false,
    552553                                            user_sess_key);
    553554                } else {
  • vendor/current/libcli/auth/ntlmssp_server.c

    r740 r746  
    360360        if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_NTLM2) {
    361361                if (ntlmssp_state->nt_resp.length == 24 && ntlmssp_state->lm_resp.length == 24) {
    362                         struct MD5Context md5_session_nonce_ctx;
     362                        MD5_CTX md5_session_nonce_ctx;
    363363                        state->doing_ntlm2 = true;
    364364
  • vendor/current/libcli/auth/ntlmssp_sign.c

    r740 r746  
    5252                            const char *constant)
    5353{
    54         struct MD5Context ctx3;
     54        MD5_CTX ctx3;
    5555        MD5Init(&ctx3);
    5656        MD5Update(&ctx3, session_key.data, session_key.length);
  • vendor/current/libcli/auth/proto.h

    r740 r746  
    110110bool ntv2_owf_gen(const uint8_t owf[16],
    111111                  const char *user_in, const char *domain_in,
    112                   bool upper_case_domain, /* Transform the domain into UPPER case */
    113112                  uint8_t kr_buf[16]);
    114113void SMBOWFencrypt(const uint8_t passwd[16], const uint8_t *c8, uint8_t p24[24]);
  • vendor/current/libcli/auth/schannel_sign.c

    r740 r746  
    111111        uint8_t packet_digest[16];
    112112        static const uint8_t zeros[4];
    113         struct MD5Context ctx;
     113        MD5_CTX ctx;
    114114
    115115        MD5Init(&ctx);
  • vendor/current/libcli/auth/smbencrypt.c

    r740 r746  
    100100void E_md5hash(const uint8_t salt[16], const uint8_t nthash[16], uint8_t hash_out[16])
    101101{
    102         struct MD5Context tctx;
     102        MD5_CTX tctx;
    103103        MD5Init(&tctx);
    104104        MD5Update(&tctx, salt, 16);
     
    169169bool ntv2_owf_gen(const uint8_t owf[16],
    170170                  const char *user_in, const char *domain_in,
    171                   bool upper_case_domain, /* Transform the domain into UPPER case */
    172171                  uint8_t kr_buf[16])
    173172{
     
    197196                talloc_free(mem_ctx);
    198197                return false;
    199         }
    200 
    201         if (upper_case_domain) {
    202                 domain_in = strupper_talloc(mem_ctx, domain_in);
    203                 if (domain_in == NULL) {
    204                         talloc_free(mem_ctx);
    205                         return false;
    206                 }
    207198        }
    208199
     
    475466           This prevents username swapping during the auth exchange
    476467        */
    477         if (!ntv2_owf_gen(nt_hash, user, domain, true, ntlm_v2_hash)) {
     468        if (!ntv2_owf_gen(nt_hash, user, domain, ntlm_v2_hash)) {
    478469                return false;
    479470        }
     
    624615void encode_or_decode_arc4_passwd_buffer(unsigned char pw_buf[532], const DATA_BLOB *psession_key)
    625616{
    626         struct MD5Context tctx;
     617        MD5_CTX tctx;
    627618        unsigned char key_out[16];
    628619
     
    704695{
    705696        uint8_t buffer[516];
    706         struct MD5Context ctx;
     697        MD5_CTX ctx;
    707698        struct wkssvc_PasswordBuffer *my_pwd_buf = NULL;
    708699        DATA_BLOB confounded_session_key;
     
    742733{
    743734        uint8_t buffer[516];
    744         struct MD5Context ctx;
     735        MD5_CTX ctx;
    745736        size_t pwd_len;
    746737
  • vendor/current/libcli/cldap/cldap.c

    r740 r746  
    274274        DLIST_REMOVE(c->searches.list, search);
    275275
    276         if (!cldap_recvfrom_setup(c)) {
    277                 goto nomem;
    278         }
     276        cldap_recvfrom_setup(c);
    279277
    280278        tevent_req_done(search->req);
    281         talloc_free(in);
    282279        return true;
    283280
     
    287284        status = map_nt_error_from_unix(in->recv_errno);
    288285nterror:
     286        TALLOC_FREE(in);
    289287        /* in connected mode the first pending search gets the error */
    290288        if (!c->connected) {
     
    295293                goto done;
    296294        }
     295        cldap_recvfrom_setup(c);
    297296        tevent_req_nterror(c->searches.list->req, status);
     297        return true;
    298298done:
    299         talloc_free(in);
     299        TALLOC_FREE(in);
    300300        return false;
    301301}
     
    314314        NTSTATUS status;
    315315        int ret;
     316        const char *fam = NULL;
     317
     318        if (local_addr == NULL && remote_addr == NULL) {
     319                return NT_STATUS_INVALID_PARAMETER_MIX;
     320        }
     321
     322        if (remote_addr) {
     323                bool is_ipv4;
     324                bool is_ipv6;
     325
     326                is_ipv4 = tsocket_address_is_inet(remote_addr, "ipv4");
     327                is_ipv6 = tsocket_address_is_inet(remote_addr, "ipv6");
     328
     329                if (is_ipv4) {
     330                        fam = "ipv4";
     331                } else if (is_ipv6) {
     332                        fam = "ipv6";
     333                } else {
     334                        return NT_STATUS_INVALID_ADDRESS;
     335                }
     336        }
    316337
    317338        c = talloc_zero(mem_ctx, struct cldap_socket);
     
    330351
    331352        if (!local_addr) {
    332                 /* we use ipv4 here instead of ip, as otherwise we end
    333                    up with a PF_INET6 socket, and sendto() for ipv4
    334                    addresses will fail. That breaks cldap name
    335                    resolution for winbind to IPv4 hosts. */
    336                 ret = tsocket_address_inet_from_strings(c, "ipv4",
     353                /*
     354                 * Here we know the address family of the remote address.
     355                 */
     356                if (fam == NULL) {
     357                        return NT_STATUS_INVALID_PARAMETER_MIX;
     358                }
     359
     360                ret = tsocket_address_inet_from_strings(c, fam,
    337361                                                        NULL, 0,
    338362                                                        &any);
  • vendor/current/libcli/drsuapi/repl_decrypt.c

    r740 r746  
    4040        DATA_BLOB enc_buffer;
    4141
    42         struct MD5Context md5;
     42        MD5_CTX md5;
    4343        uint8_t _enc_key[16];
    4444        DATA_BLOB enc_key;
     
    199199        DATA_BLOB confounder;
    200200
    201         struct MD5Context md5;
     201        MD5_CTX md5;
    202202        uint8_t _enc_key[16];
    203203        DATA_BLOB enc_key;
  • vendor/current/libcli/netlogon/ndr_netlogon.c

    r740 r746  
    5454                        struct ndr_push *_ndr_sid;
    5555                        uint32_t _flags_save_DATA_BLOB = ndr->flags;
     56                        ndr->flags &= ~LIBNDR_FLAG_NOALIGN;
    5657                        ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4);
    5758                        NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->_pad));
     
    99100                        uint32_t _flags_save_DATA_BLOB = ndr->flags;
    100101                        struct ndr_pull *_ndr_sid;
     102                        ndr->flags &= ~LIBNDR_FLAG_NOALIGN;
    101103                        ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4);
    102104                        NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->_pad));
  • vendor/current/libcli/security/access_check.c

    r740 r746  
    159159        uint32_t i;
    160160        uint32_t bits_remaining;
     161        uint32_t explicitly_denied_bits = 0;
    161162
    162163        *access_granted = access_desired;
     
    178179        }
    179180
    180         /* s3 had this with #if 0 previously. To be sure the merge
    181            doesn't change any behaviour, we have the above #if check
    182            on _SAMBA_BUILD_. */
    183         if (access_desired & SEC_FLAG_SYSTEM_SECURITY) {
     181        /* the owner always gets SEC_STD_WRITE_DAC and SEC_STD_READ_CONTROL */
     182        if ((bits_remaining & (SEC_STD_WRITE_DAC|SEC_STD_READ_CONTROL)) &&
     183            security_token_has_sid(token, sd->owner_sid)) {
     184                bits_remaining &= ~(SEC_STD_WRITE_DAC|SEC_STD_READ_CONTROL);
     185        }
     186
     187        /* a NULL dacl allows access */
     188        if ((sd->type & SEC_DESC_DACL_PRESENT) && sd->dacl == NULL) {
     189                *access_granted = access_desired;
     190                return NT_STATUS_OK;
     191        }
     192
     193        if (sd->dacl == NULL) {
     194                goto done;
     195        }
     196
     197        /* check each ace in turn. */
     198        for (i=0; bits_remaining && i < sd->dacl->num_aces; i++) {
     199                struct security_ace *ace = &sd->dacl->aces[i];
     200
     201                if (ace->flags & SEC_ACE_FLAG_INHERIT_ONLY) {
     202                        continue;
     203                }
     204
     205                if (!security_token_has_sid(token, &ace->trustee)) {
     206                        continue;
     207                }
     208
     209                switch (ace->type) {
     210                case SEC_ACE_TYPE_ACCESS_ALLOWED:
     211                        bits_remaining &= ~ace->access_mask;
     212                        break;
     213                case SEC_ACE_TYPE_ACCESS_DENIED:
     214                case SEC_ACE_TYPE_ACCESS_DENIED_OBJECT:
     215                        explicitly_denied_bits |= (bits_remaining & ace->access_mask);
     216                        break;
     217                default:        /* Other ACE types not handled/supported */
     218                        break;
     219                }
     220        }
     221
     222        bits_remaining |= explicitly_denied_bits;
     223
     224        /*
     225         * We check privileges here because they override even DENY entries.
     226         */
     227
     228        /* Does the user have the privilege to gain SEC_PRIV_SECURITY? */
     229        if (bits_remaining & SEC_FLAG_SYSTEM_SECURITY) {
    184230                if (security_token_has_privilege(token, SEC_PRIV_SECURITY)) {
    185231                        bits_remaining &= ~SEC_FLAG_SYSTEM_SECURITY;
     
    189235        }
    190236
    191         /* the owner always gets SEC_STD_WRITE_DAC and SEC_STD_READ_CONTROL */
    192         if ((bits_remaining & (SEC_STD_WRITE_DAC|SEC_STD_READ_CONTROL)) &&
    193             security_token_has_sid(token, sd->owner_sid)) {
    194                 bits_remaining &= ~(SEC_STD_WRITE_DAC|SEC_STD_READ_CONTROL);
    195         }
    196 
    197237        /* TODO: remove this, as it is file server specific */
    198238        if ((bits_remaining & SEC_RIGHTS_PRIV_RESTORE) &&
     
    205245        }
    206246
    207         /* a NULL dacl allows access */
    208         if ((sd->type & SEC_DESC_DACL_PRESENT) && sd->dacl == NULL) {
    209                 *access_granted = access_desired;
    210                 return NT_STATUS_OK;
    211         }
    212 
    213         if (sd->dacl == NULL) {
    214                 goto done;
    215         }
    216 
    217         /* check each ace in turn. */
    218         for (i=0; bits_remaining && i < sd->dacl->num_aces; i++) {
    219                 struct security_ace *ace = &sd->dacl->aces[i];
    220 
    221                 if (ace->flags & SEC_ACE_FLAG_INHERIT_ONLY) {
    222                         continue;
    223                 }
    224 
    225                 if (!security_token_has_sid(token, &ace->trustee)) {
    226                         continue;
    227                 }
    228 
    229                 switch (ace->type) {
    230                 case SEC_ACE_TYPE_ACCESS_ALLOWED:
    231                         bits_remaining &= ~ace->access_mask;
    232                         break;
    233                 case SEC_ACE_TYPE_ACCESS_DENIED:
    234                 case SEC_ACE_TYPE_ACCESS_DENIED_OBJECT:
    235                         if (bits_remaining & ace->access_mask) {
    236                                 return NT_STATUS_ACCESS_DENIED;
    237                         }
    238                         break;
    239                 default:        /* Other ACE types not handled/supported */
    240                         break;
    241                 }
     247        if ((bits_remaining & SEC_STD_WRITE_OWNER) &&
     248             security_token_has_privilege(token, SEC_PRIV_TAKE_OWNERSHIP)) {
     249                bits_remaining &= ~(SEC_STD_WRITE_OWNER);
    242250        }
    243251
  • vendor/current/libcli/smb/smb2_constants.h

    r740 r746  
    2626#define SMB2_HDR_PROTOCOL_ID    0x00
    2727#define SMB2_HDR_LENGTH         0x04
    28 #define SMB2_HDR_EPOCH          0x06
     28#define SMB2_HDR_CREDIT_CHARGE  0x06
     29#define SMB2_HDR_EPOCH          SMB2_HDR_CREDIT_CHARGE /* TODO: remove this */
    2930#define SMB2_HDR_STATUS         0x08
    3031#define SMB2_HDR_OPCODE         0x0c
  • vendor/current/libcli/smb/smb2_create_blob.c

    r414 r746  
    6060                if ((next & 0x7) != 0 ||
    6161                    next > remaining ||
    62                     name_offset < 16 ||
    63                     name_offset > remaining ||
    64                     name_length != 4 || /* windows enforces this */
     62                    name_offset != 16 ||
     63                    name_length < 4 ||
    6564                    name_offset + name_length > remaining ||
    66                     data_offset < name_offset + name_length ||
    67                     data_offset > remaining ||
    68                     data_offset + (uint64_t)data_length > remaining) {
     65                    (data_offset & 0x7) != 0 ||
     66                    (data_offset && (data_offset < name_offset + name_length)) ||
     67                    (data_offset > remaining) ||
     68                    (data_offset + (uint64_t)data_length > remaining)) {
    6969                        return NT_STATUS_INVALID_PARAMETER;
    7070                }
     
    106106        uint32_t ofs = buffer->length;
    107107        size_t tag_length = strlen(blob->tag);
    108         uint8_t pad = smb2_create_blob_padding(blob->data.length+tag_length, 4);
    109 
    110         if (!data_blob_realloc(mem_ctx, buffer,
    111                                buffer->length + 0x14 + tag_length + blob->data.length + pad))
     108        size_t blob_offset = 0;
     109        size_t blob_pad = 0;
     110        size_t next_offset = 0;
     111        size_t next_pad = 0;
     112        bool ok;
     113
     114        blob_offset = 0x10 + tag_length;
     115        blob_pad = smb2_create_blob_padding(blob_offset, 8);
     116        next_offset = blob_offset + blob_pad + blob->data.length;
     117        if (!last) {
     118                next_pad = smb2_create_blob_padding(next_offset, 8);
     119        }
     120
     121        ok = data_blob_realloc(mem_ctx, buffer,
     122                               buffer->length + next_offset + next_pad);
     123        if (!ok) {
    112124                return NT_STATUS_NO_MEMORY;
     125        }
    113126
    114127        if (last) {
    115128                SIVAL(buffer->data, ofs+0x00, 0);
    116129        } else {
    117                 SIVAL(buffer->data, ofs+0x00, 0x14 + tag_length + blob->data.length + pad);
     130                SIVAL(buffer->data, ofs+0x00, next_offset + next_pad);
    118131        }
    119132        SSVAL(buffer->data, ofs+0x04, 0x10); /* offset of tag */
    120133        SIVAL(buffer->data, ofs+0x06, tag_length); /* tag length */
    121         SSVAL(buffer->data, ofs+0x0A, 0x14 + tag_length); /* offset of data */
     134        SSVAL(buffer->data, ofs+0x0A, blob_offset + blob_pad); /* offset of data */
    122135        SIVAL(buffer->data, ofs+0x0C, blob->data.length);
    123136        memcpy(buffer->data+ofs+0x10, blob->tag, tag_length);
    124         SIVAL(buffer->data, ofs+0x10+tag_length, 0); /* pad? */
    125         memcpy(buffer->data+ofs+0x14+tag_length, blob->data.data, blob->data.length);
    126         memset(buffer->data+ofs+0x14+tag_length+blob->data.length, 0, pad);
     137        if (blob_pad > 0) {
     138                memset(buffer->data+ofs+blob_offset, 0, blob_pad);
     139                blob_offset += blob_pad;
     140        }
     141        memcpy(buffer->data+ofs+blob_offset, blob->data.data, blob->data.length);
     142        if (next_pad > 0) {
     143                memset(buffer->data+ofs+next_offset, 0, next_pad);
     144                next_offset += next_pad;
     145        }
    127146
    128147        return NT_STATUS_OK;
Note: See TracChangeset for help on using the changeset viewer.