Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

Location:
vendor/current/libcli/auth
Files:
10 added
3 deleted
14 edited

Legend:

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

    r587 r740  
    250250                                                                              const uint8_t session_key[16])
    251251{
    252         struct netlogon_creds_CredentialState *creds = talloc(mem_ctx, struct netlogon_creds_CredentialState);
    253        
     252        struct netlogon_creds_CredentialState *creds;
     253
     254        creds = talloc_zero(mem_ctx, struct netlogon_creds_CredentialState);
    254255        if (!creds) {
    255256                return NULL;
  • vendor/current/libcli/auth/credentials.h

    r414 r740  
    6969#define NETLOGON_NEG_AUTH2_ADS_FLAGS (0x200fbffb | NETLOGON_NEG_ARCFOUR | NETLOGON_NEG_128BIT | NETLOGON_NEG_SCHANNEL)
    7070
     71#define NETLOGON_NEG_AUTH2_RODC_FLAGS (NETLOGON_NEG_AUTH2_ADS_FLAGS | NETLOGON_NEG_RODC_PASSTHROUGH)
    7172
  • vendor/current/libcli/auth/msrpc_parse.c

    r414 r740  
    4141  C = constant ascii string
    4242 */
    43 bool msrpc_gen(TALLOC_CTX *mem_ctx,
     43NTSTATUS msrpc_gen(TALLOC_CTX *mem_ctx,
    4444               DATA_BLOB *blob,
    4545               const char *format, ...)
     
    5858
    5959        pointers = talloc_array(mem_ctx, DATA_BLOB, strlen(format));
     60        if (!pointers) {
     61                return NT_STATUS_NO_MEMORY;
     62        }
    6063        intargs = talloc_array(pointers, int, strlen(format));
     64        if (!intargs) {
     65                return NT_STATUS_NO_MEMORY;
     66        }
    6167
    6268        /* first scan the format to work out the header and body size */
     
    7379                        if (!ret) {
    7480                                va_end(ap);
    75                                 return false;
     81                                return map_nt_error_from_unix(errno);
    7682                        }
    7783                        pointers[i].length = n;
     
    8793                        if (!ret) {
    8894                                va_end(ap);
    89                                 return false;
     95                                return map_nt_error_from_unix(errno);
    9096                        }
    9197                        pointers[i].length = n;
     
    103109                        if (!ret) {
    104110                                va_end(ap);
    105                                 return false;
     111                                return map_nt_error_from_unix(errno);
    106112                        }
    107113                        pointers[i].length = n;
     
    133139                        head_size += pointers[i].length;
    134140                        break;
     141                default:
     142                        va_end(ap);
     143                        return NT_STATUS_INVALID_PARAMETER;
    135144                }
    136145        }
    137146        va_end(ap);
     147
     148        if (head_size + data_size == 0) {
     149                return NT_STATUS_INVALID_PARAMETER;
     150        }
    138151
    139152        /* allocate the space, then scan the format again to fill in the values */
    140153        *blob = data_blob_talloc(mem_ctx, NULL, head_size + data_size);
    141 
     154        if (!blob->data) {
     155                return NT_STATUS_NO_MEMORY;
     156        }
    142157        head_ofs = 0;
    143158        data_ofs = head_size;
     
    175190                case 'b':
    176191                        n = pointers[i].length;
    177                         memcpy(blob->data + head_ofs, pointers[i].data, n);
     192                        if (pointers[i].data && n) {
     193                                /* don't follow null pointers... */
     194                                memcpy(blob->data + head_ofs, pointers[i].data, n);
     195                        }
    178196                        head_ofs += n;
    179197                        break;
     
    183201                        head_ofs += n;
    184202                        break;
     203                default:
     204                        va_end(ap);
     205                        return NT_STATUS_INVALID_PARAMETER;
    185206                }
    186207        }
     
    189210        talloc_free(pointers);
    190211
    191         return true;
     212        return NT_STATUS_OK;
    192213}
    193214
     
    229250        bool ret = true;
    230251
     252        if (!p) {
     253                return false;
     254        }
     255
    231256        va_start(ap, format);
    232257        for (i=0; format[i]; i++) {
     
    334359                case 'b':
    335360                        b = (DATA_BLOB *)va_arg(ap, void *);
    336                         len1 = va_arg(ap, uint_t);
     361                        len1 = va_arg(ap, unsigned int);
    337362                        /* make sure its in the right format - be strict */
    338363                        NEED_DATA(len1);
  • vendor/current/libcli/auth/msrpc_parse.h

    r414 r740  
     1/*
     2   Unix SMB/CIFS implementation.
     3   simple kerberos5/SPNEGO routines
     4   Copyright (C) Andrew Tridgell 2001
     5   Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002
     6   Copyright (C) Andrew Bartlett 2002-2003
     7
     8   This program is free software; you can redistribute it and/or modify
     9   it under the terms of the GNU General Public License as published by
     10   the Free Software Foundation; either version 3 of the License, or
     11   (at your option) any later version.
     12
     13   This program is distributed in the hope that it will be useful,
     14   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16   GNU General Public License for more details.
     17
     18   You should have received a copy of the GNU General Public License
     19   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     20*/
     21
    122#ifndef _LIBCLI_AUTH_MSRPC_PARSE_H__
    223#define _LIBCLI_AUTH_MSRPC_PARSE_H__
     
    1233/* The following definitions come from /home/jeremy/src/samba/git/master/source3/../source4/../libcli/auth/msrpc_parse.c  */
    1334
    14 bool msrpc_gen(TALLOC_CTX *mem_ctx,
     35NTSTATUS msrpc_gen(TALLOC_CTX *mem_ctx,
    1536               DATA_BLOB *blob,
    1637               const char *format, ...);
  • vendor/current/libcli/auth/ntlm_check.c

    r414 r740  
    55   Copyright (C) Gerald Carter                             2003
    66   Copyright (C) Luke Kenneth Casson Leighton         1996-2000
    7    
     7
    88   This program is free software; you can redistribute it and/or modify
    99   it under the terms of the GNU General Public License as published by
    1010   the Free Software Foundation; either version 3 of the License, or
    1111   (at your option) any later version.
    12    
     12
    1313   This program is distributed in the hope that it will be useful,
    1414   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1616   GNU General Public License for more details.
    17    
     17
    1818   You should have received a copy of the GNU General Public License
    1919   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    3737        /* Finish the encryption of part_passwd. */
    3838        uint8_t p24[24];
    39        
     39
    4040        if (part_passwd == NULL) {
    4141                DEBUG(10,("No password set - DISALLOWING access\n"));
     
    4343                return false;
    4444        }
    45        
     45
    4646        if (sec_blob->length != 8) {
    4747                DEBUG(0, ("smb_pwd_check_ntlmv1: incorrect challenge size (%lu)\n",
     
    4949                return false;
    5050        }
    51        
     51
    5252        if (nt_response->length != 24) {
    5353                DEBUG(0, ("smb_pwd_check_ntlmv1: incorrect password length (%lu)\n",
     
    5757
    5858        SMBOWFencrypt(part_passwd, sec_blob->data, p24);
    59        
     59
    6060#if DEBUG_PASSWORD
    6161        DEBUG(100,("Part password (P16) was |\n"));
     
    107107                return false;
    108108        }
    109        
     109
    110110        if (ntv2_response->length < 24) {
    111111                /* We MUST have more than 16 bytes, or the stuff below will go
     
    181181                return false;
    182182        }
    183        
     183
    184184        if (ntv2_response->length < 24) {
    185185                /* We MUST have more than 16 bytes, or the stuff below will go
     
    219219
    220220NTSTATUS hash_password_check(TALLOC_CTX *mem_ctx,
    221                                 bool lanman_auth,
     221                            bool lanman_auth,
    222222                             const struct samr_Password *client_lanman,
    223223                             const struct samr_Password *client_nt,
     
    282282
    283283NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
    284                                 bool lanman_auth,
    285                                 bool ntlm_auth,
     284                            bool lanman_auth,
     285                            bool ntlm_auth,
    286286                             uint32_t logon_parameters,
    287287                             const DATA_BLOB *challenge,
     
    319319                         username));
    320320                mdfour(client_nt.hash, nt_response->data, nt_response->length);
    321                
     321
    322322                if (lm_response->length &&
    323323                    (convert_string_talloc(mem_ctx, CH_DOS, CH_UNIX,
     
    344344                         (unsigned long)nt_response->length, username));               
    345345        }
    346        
     346
    347347        if (nt_response->length > 24 && stored_nt) {
    348348                /* We have the NT MD4 hash challenge available - see if we can
     
    362362                        return NT_STATUS_OK;
    363363                }
    364                
     364
    365365                DEBUG(4,("ntlm_password_check: Checking NTLMv2 password with uppercased version of domain [%s]\n", client_domain));
    366366                if (smb_pwd_check_ntlmv2(mem_ctx,
     
    376376                        return NT_STATUS_OK;
    377377                }
    378                
     378
    379379                DEBUG(4,("ntlm_password_check: Checking NTLMv2 password without a domain\n"));
    380380                if (smb_pwd_check_ntlmv2(mem_ctx,
     
    404404                                /* The LM session key for this response is not very secure,
    405405                                   so use it only if we otherwise allow LM authentication */
    406                                
     406
    407407                                if (lanman_auth && stored_lanman) {
    408408                                        *lm_sess_key = data_blob_talloc(mem_ctx, stored_lanman->hash, MIN(8, user_sess_key->length));
     
    417417                        DEBUG(2,("ntlm_password_check: NTLMv1 passwords NOT PERMITTED for user %s\n",
    418418                                 username));                   
    419                         /* no return, becouse we might pick up LMv2 in the LM field */
    420                 }
    421         }
    422        
     419                        /* no return, because we might pick up LMv2 in the LM field */
     420                }
     421        }
     422
    423423        if (lm_response->length == 0) {
    424424                DEBUG(3,("ntlm_password_check: NEITHER LanMan nor NT password supplied for user %s\n",
     
    426426                return NT_STATUS_WRONG_PASSWORD;
    427427        }
    428        
     428
    429429        if (lm_response->length < 24) {
    430430                DEBUG(2,("ntlm_password_check: invalid LanMan password length (%lu) for user %s\n",
     
    432432                return NT_STATUS_WRONG_PASSWORD;
    433433        }
    434                
     434
    435435        if (!lanman_auth) {
    436436                DEBUG(3,("ntlm_password_check: Lanman passwords NOT PERMITTED for user %s\n",
     
    462462                }
    463463        }
    464        
     464
    465465        if (!stored_nt) {
    466466                DEBUG(4,("ntlm_password_check: LM password check failed for user, no NT password %s\n",username));
    467467                return NT_STATUS_WRONG_PASSWORD;
    468468        }
    469        
     469
    470470        /* This is for 'LMv2' authentication.  almost NTLMv2 but limited to 24 bytes.
    471471           - related to Win9X, legacy NAS pass-though authentication
     
    500500                return NT_STATUS_OK;
    501501        }
    502        
     502
    503503        DEBUG(4,("ntlm_password_check: Checking LMv2 password with upper-cased version of domain %s\n", client_domain));
    504504        if (smb_pwd_check_ntlmv2(mem_ctx,
     
    530530                return NT_STATUS_OK;
    531531        }
    532        
     532
    533533        DEBUG(4,("ntlm_password_check: Checking LMv2 password without a domain\n"));
    534534        if (smb_pwd_check_ntlmv2(mem_ctx,
  • vendor/current/libcli/auth/proto.h

    r587 r740  
    195195void des_crypt64(uint8_t out[8], const uint8_t in[8], const uint8_t key[8], int forw);
    196196void des_crypt112(uint8_t out[8], const uint8_t in[8], const uint8_t key[14], int forw);
    197 void des_crypt112_16(uint8_t out[16], uint8_t in[16], const uint8_t key[14], int forw);
    198 void sam_rid_crypt(uint_t rid, const uint8_t *in, uint8_t *out, int forw);
     197void des_crypt112_16(uint8_t out[16], const uint8_t in[16], const uint8_t key[14], int forw);
     198void sam_rid_crypt(unsigned int rid, const uint8_t *in, uint8_t *out, int forw);
    199199#undef _PRINTF_ATTRIBUTE
    200200#define _PRINTF_ATTRIBUTE(a1, a2)
  • vendor/current/libcli/auth/schannel_proto.h

    r414 r740  
    2424#define _LIBCLI_AUTH_SCHANNEL_PROTO_H__
    2525
     26struct schannel_state;
     27
     28struct tdb_wrap *open_schannel_session_store(TALLOC_CTX *mem_ctx,
     29                                             const char *private_dir);
     30
    2631NTSTATUS netsec_incoming_packet(struct schannel_state *state,
    2732                                TALLOC_CTX *mem_ctx,
     
    2934                                uint8_t *data, size_t length,
    3035                                const DATA_BLOB *sig);
     36uint32_t netsec_outgoing_sig_size(struct schannel_state *state);
    3137NTSTATUS netsec_outgoing_packet(struct schannel_state *state,
    3238                                TALLOC_CTX *mem_ctx,
  • vendor/current/libcli/auth/schannel_sign.c

    r414 r740  
    205205}
    206206
     207uint32_t netsec_outgoing_sig_size(struct schannel_state *state)
     208{
     209        uint32_t sig_size = 0;
     210
     211        netsec_offset_and_sizes(state,
     212                                true,
     213                                NULL,
     214                                &sig_size,
     215                                NULL,
     216                                NULL);
     217
     218        return sig_size;
     219}
     220
    207221NTSTATUS netsec_outgoing_packet(struct schannel_state *state,
    208222                                TALLOC_CTX *mem_ctx,
  • vendor/current/libcli/auth/schannel_state.h

    r414 r740  
    1 /* 
     1/*
    22   Unix SMB/CIFS implementation.
    33
     
    1111   the Free Software Foundation; either version 3 of the License, or
    1212   (at your option) any later version.
    13    
     13
    1414   This program is distributed in the hope that it will be useful,
    1515   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1616   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1717   GNU General Public License for more details.
    18    
     18
    1919   You should have received a copy of the GNU General Public License
    2020   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    2121*/
    2222
    23 struct ldb_context;
    24 struct tdb_context;
    25 #include "libcli/auth/schannel_state_proto.h"
     23#ifndef _LIBCLI_AUTH_SCHANNEL_STATE_H__
     24#define _LIBCLI_AUTH_SCHANNEL_STATE_H__
     25
     26NTSTATUS schannel_get_creds_state(TALLOC_CTX *mem_ctx,
     27                                  const char *db_priv_dir,
     28                                  const char *computer_name,
     29                                  struct netlogon_creds_CredentialState **creds);
     30
     31NTSTATUS schannel_save_creds_state(TALLOC_CTX *mem_ctx,
     32                                   const char *db_priv_dir,
     33                                   struct netlogon_creds_CredentialState *creds);
     34
     35NTSTATUS schannel_check_creds_state(TALLOC_CTX *mem_ctx,
     36                                    const char *db_priv_dir,
     37                                    const char *computer_name,
     38                                    struct netr_Authenticator *received_authenticator,
     39                                    struct netr_Authenticator *return_authenticator,
     40                                    struct netlogon_creds_CredentialState **creds_out);
     41
     42#endif
  • vendor/current/libcli/auth/schannel_state_tdb.c

    r414 r740  
    2323
    2424#include "includes.h"
    25 #include "../libcli/auth/libcli_auth.h"
    26 #include "../libcli/auth/schannel_state.h"
     25#include "system/filesys.h"
     26#include <tdb.h>
     27#include "../lib/util/util_tdb.h"
     28#include "../libcli/auth/schannel.h"
    2729#include "../librpc/gen_ndr/ndr_schannel.h"
     30#include "lib/util/tdb_wrap.h"
     31
     32#define SECRETS_SCHANNEL_STATE "SECRETS/SCHANNEL"
     33
     34/******************************************************************************
     35 Open or create the schannel session store tdb.  Non-static so it can
     36 be called from parent processes to corectly handle TDB_CLEAR_IF_FIRST
     37*******************************************************************************/
     38
     39struct tdb_wrap *open_schannel_session_store(TALLOC_CTX *mem_ctx,
     40                                             const char *private_dir)
     41{
     42        struct tdb_wrap *tdb_sc = NULL;
     43        char *fname = talloc_asprintf(mem_ctx, "%s/schannel_store.tdb", private_dir);
     44
     45        if (!fname) {
     46                return NULL;
     47        }
     48
     49        tdb_sc = tdb_wrap_open(mem_ctx, fname, 0, TDB_CLEAR_IF_FIRST|TDB_NOSYNC, O_RDWR|O_CREAT, 0600);
     50
     51        if (!tdb_sc) {
     52                DEBUG(0,("open_schannel_session_store: Failed to open %s - %s\n",
     53                         fname, strerror(errno)));
     54                TALLOC_FREE(fname);
     55                return NULL;
     56        }
     57
     58        TALLOC_FREE(fname);
     59
     60        return tdb_sc;
     61}
    2862
    2963/********************************************************************
    3064 ********************************************************************/
    3165
    32 NTSTATUS schannel_store_session_key_tdb(struct tdb_context *tdb,
     66static
     67NTSTATUS schannel_store_session_key_tdb(struct tdb_wrap *tdb_sc,
    3368                                        TALLOC_CTX *mem_ctx,
    3469                                        struct netlogon_creds_CredentialState *creds)
     
    3974        int ret;
    4075        char *keystr;
    41 
    42         keystr = talloc_asprintf_strupper_m(mem_ctx, "%s/%s",
    43                                             SECRETS_SCHANNEL_STATE,
    44                                             creds->computer_name);
     76        char *name_upper;
     77
     78        name_upper = strupper_talloc(mem_ctx, creds->computer_name);
     79        if (!name_upper) {
     80                return NT_STATUS_NO_MEMORY;
     81        }
     82
     83        keystr = talloc_asprintf(mem_ctx, "%s/%s",
     84                                 SECRETS_SCHANNEL_STATE, name_upper);
     85        TALLOC_FREE(name_upper);
    4586        if (!keystr) {
    4687                return NT_STATUS_NO_MEMORY;
    4788        }
    4889
    49         ndr_err = ndr_push_struct_blob(&blob, mem_ctx, NULL, creds,
     90        ndr_err = ndr_push_struct_blob(&blob, mem_ctx, creds,
    5091                        (ndr_push_flags_fn_t)ndr_push_netlogon_creds_CredentialState);
    5192        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    5798        value.dsize = blob.length;
    5899
    59         ret = tdb_store_bystring(tdb, keystr, value, TDB_REPLACE);
     100        ret = tdb_store_bystring(tdb_sc->tdb, keystr, value, TDB_REPLACE);
    60101        if (ret != TDB_SUCCESS) {
    61102                DEBUG(0,("Unable to add %s to session key db - %s\n",
    62                          keystr, tdb_errorstr(tdb)));
     103                         keystr, tdb_errorstr(tdb_sc->tdb)));
    63104                talloc_free(keystr);
    64105                return NT_STATUS_INTERNAL_DB_CORRUPTION;
     
    80121 ********************************************************************/
    81122
    82 NTSTATUS schannel_fetch_session_key_tdb(struct tdb_context *tdb,
     123static
     124NTSTATUS schannel_fetch_session_key_tdb(struct tdb_wrap *tdb_sc,
    83125                                        TALLOC_CTX *mem_ctx,
    84126                                        const char *computer_name,
     
    91133        struct netlogon_creds_CredentialState *creds = NULL;
    92134        char *keystr = NULL;
     135        char *name_upper;
    93136
    94137        *pcreds = NULL;
    95138
    96         keystr = talloc_asprintf_strupper_m(mem_ctx, "%s/%s",
    97                                             SECRETS_SCHANNEL_STATE,
    98                                             computer_name);
     139        name_upper = strupper_talloc(mem_ctx, computer_name);
     140        if (!name_upper) {
     141                return NT_STATUS_NO_MEMORY;
     142        }
     143
     144        keystr = talloc_asprintf(mem_ctx, "%s/%s",
     145                                 SECRETS_SCHANNEL_STATE, name_upper);
     146        TALLOC_FREE(name_upper);
    99147        if (!keystr) {
    100                 status = NT_STATUS_NO_MEMORY;
    101                 goto done;
    102         }
    103 
    104         value = tdb_fetch_bystring(tdb, keystr);
     148                return NT_STATUS_NO_MEMORY;
     149        }
     150
     151        value = tdb_fetch_bystring(tdb_sc->tdb, keystr);
    105152        if (!value.dptr) {
    106                 DEBUG(0,("schannel_fetch_session_key_tdb: Failed to find entry with key %s\n",
     153                DEBUG(10,("schannel_fetch_session_key_tdb: Failed to find entry with key %s\n",
    107154                        keystr ));
    108155                status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
     
    118165        blob = data_blob_const(value.dptr, value.dsize);
    119166
    120         ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, NULL, creds,
     167        ndr_err = ndr_pull_struct_blob(&blob, creds, creds,
    121168                        (ndr_pull_flags_fn_t)ndr_pull_netlogon_creds_CredentialState);
    122169        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    137184
    138185        talloc_free(keystr);
     186        SAFE_FREE(value.dptr);
    139187
    140188        if (!NT_STATUS_IS_OK(status)) {
     
    148196}
    149197
     198/******************************************************************************
     199 Wrapper around schannel_fetch_session_key_tdb()
     200 Note we must be root here.
     201*******************************************************************************/
     202
     203NTSTATUS schannel_get_creds_state(TALLOC_CTX *mem_ctx,
     204                                  const char *db_priv_dir,
     205                                  const char *computer_name,
     206                                  struct netlogon_creds_CredentialState **_creds)
     207{
     208        TALLOC_CTX *tmpctx;
     209        struct tdb_wrap *tdb_sc;
     210        struct netlogon_creds_CredentialState *creds;
     211        NTSTATUS status;
     212
     213        tmpctx = talloc_named(mem_ctx, 0, "schannel_get_creds_state");
     214        if (!tmpctx) {
     215                return NT_STATUS_NO_MEMORY;
     216        }
     217
     218        tdb_sc = open_schannel_session_store(tmpctx, db_priv_dir);
     219        if (!tdb_sc) {
     220                return NT_STATUS_ACCESS_DENIED;
     221        }
     222
     223        status = schannel_fetch_session_key_tdb(tdb_sc, tmpctx,
     224                                                computer_name, &creds);
     225        if (NT_STATUS_IS_OK(status)) {
     226                *_creds = talloc_steal(mem_ctx, creds);
     227                if (!*_creds) {
     228                        status = NT_STATUS_NO_MEMORY;
     229                }
     230        }
     231
     232        talloc_free(tmpctx);
     233        return status;
     234}
     235
     236/******************************************************************************
     237 Wrapper around schannel_store_session_key_tdb()
     238 Note we must be root here.
     239*******************************************************************************/
     240
     241NTSTATUS schannel_save_creds_state(TALLOC_CTX *mem_ctx,
     242                                   const char *db_priv_dir,
     243                                   struct netlogon_creds_CredentialState *creds)
     244{
     245        TALLOC_CTX *tmpctx;
     246        struct tdb_wrap *tdb_sc;
     247        NTSTATUS status;
     248
     249        tmpctx = talloc_named(mem_ctx, 0, "schannel_save_creds_state");
     250        if (!tmpctx) {
     251                return NT_STATUS_NO_MEMORY;
     252        }
     253
     254        tdb_sc = open_schannel_session_store(tmpctx, db_priv_dir);
     255        if (!tdb_sc) {
     256                return NT_STATUS_ACCESS_DENIED;
     257        }
     258
     259        status = schannel_store_session_key_tdb(tdb_sc, tmpctx, creds);
     260
     261        talloc_free(tmpctx);
     262        return status;
     263}
     264
    150265/********************************************************************
    151 
    152   Validate an incoming authenticator against the credentials for the remote
    153   machine.
    154 
    155   The credentials are (re)read and from the schannel database, and
    156   written back after the caclulations are performed.
    157 
    158   The creds_out parameter (if not NULL) returns the credentials, if
    159   the caller needs some of that information.
    160 
     266 Validate an incoming authenticator against the credentials for the
     267 remote machine stored in the schannel database.
     268
     269 The credentials are (re)read and from the schannel database, and
     270 written back after the caclulations are performed.
     271
     272 If the creds_out parameter is not NULL returns the credentials.
    161273 ********************************************************************/
    162274
    163 NTSTATUS schannel_creds_server_step_check_tdb(struct tdb_context *tdb,
    164                                               TALLOC_CTX *mem_ctx,
    165                                               const char *computer_name,
    166                                               bool schannel_required_for_call,
    167                                               bool schannel_in_use,
    168                                               struct netr_Authenticator *received_authenticator,
    169                                               struct netr_Authenticator *return_authenticator,
    170                                               struct netlogon_creds_CredentialState **creds_out)
    171 {
     275NTSTATUS schannel_check_creds_state(TALLOC_CTX *mem_ctx,
     276                                    const char *db_priv_dir,
     277                                    const char *computer_name,
     278                                    struct netr_Authenticator *received_authenticator,
     279                                    struct netr_Authenticator *return_authenticator,
     280                                    struct netlogon_creds_CredentialState **creds_out)
     281{
     282        TALLOC_CTX *tmpctx;
     283        struct tdb_wrap *tdb_sc;
    172284        struct netlogon_creds_CredentialState *creds;
    173285        NTSTATUS status;
    174286        int ret;
    175287
    176         ret = tdb_transaction_start(tdb);
     288        tmpctx = talloc_named(mem_ctx, 0, "schannel_check_creds_state");
     289        if (!tmpctx) {
     290                return NT_STATUS_NO_MEMORY;
     291        }
     292
     293        tdb_sc = open_schannel_session_store(tmpctx, db_priv_dir);
     294        if (!tdb_sc) {
     295                status = NT_STATUS_ACCESS_DENIED;
     296                goto done;
     297        }
     298
     299        ret = tdb_transaction_start(tdb_sc->tdb);
    177300        if (ret != 0) {
    178                 return NT_STATUS_INTERNAL_DB_CORRUPTION;
     301                status = NT_STATUS_INTERNAL_DB_CORRUPTION;
     302                goto done;
    179303        }
    180304
     
    183307         * update the structure */
    184308
    185         status = schannel_fetch_session_key_tdb(tdb, mem_ctx, computer_name,
    186                                                 &creds);
    187 
    188         /* If we are flaged that schannel is required for a call, and
    189          * it is not in use, then make this an error */
    190 
    191         /* It would be good to make this mandatory once schannel is
    192          * negotiated, but this is not what windows does */
    193         if (schannel_required_for_call && !schannel_in_use) {
    194                 DEBUG(0,("schannel_creds_server_step_check_tdb: "
    195                         "client %s not using schannel for netlogon, despite negotiating it\n",
    196                         creds->computer_name ));
    197                 tdb_transaction_cancel(tdb);
    198                 return NT_STATUS_ACCESS_DENIED;
    199         }
    200 
    201         if (NT_STATUS_IS_OK(status)) {
    202                 status = netlogon_creds_server_step_check(creds,
    203                                                           received_authenticator,
    204                                                           return_authenticator);
    205         }
    206 
    207         if (NT_STATUS_IS_OK(status)) {
    208                 status = schannel_store_session_key_tdb(tdb, mem_ctx, creds);
    209         }
    210 
    211         if (NT_STATUS_IS_OK(status)) {
    212                 tdb_transaction_commit(tdb);
    213                 if (creds_out) {
    214                         *creds_out = creds;
    215                         talloc_steal(mem_ctx, creds);
     309        status = schannel_fetch_session_key_tdb(tdb_sc, tmpctx,
     310                                                computer_name, &creds);
     311        if (!NT_STATUS_IS_OK(status)) {
     312                tdb_transaction_cancel(tdb_sc->tdb);
     313                goto done;
     314        }
     315
     316        status = netlogon_creds_server_step_check(creds,
     317                                                  received_authenticator,
     318                                                  return_authenticator);
     319        if (!NT_STATUS_IS_OK(status)) {
     320                tdb_transaction_cancel(tdb_sc->tdb);
     321                goto done;
     322        }
     323
     324        status = schannel_store_session_key_tdb(tdb_sc, tmpctx, creds);
     325        if (!NT_STATUS_IS_OK(status)) {
     326                tdb_transaction_cancel(tdb_sc->tdb);
     327                goto done;
     328        }
     329
     330        tdb_transaction_commit(tdb_sc->tdb);
     331
     332        if (creds_out) {
     333                *creds_out = talloc_steal(mem_ctx, creds);
     334                if (!*creds_out) {
     335                        status = NT_STATUS_NO_MEMORY;
     336                        goto done;
    216337                }
    217         } else {
    218                 tdb_transaction_cancel(tdb);
    219         }
    220 
     338        }
     339
     340        status = NT_STATUS_OK;
     341
     342done:
     343        talloc_free(tmpctx);
    221344        return status;
    222345}
     346
  • vendor/current/libcli/auth/smbdes.c

    r414 r740  
    359359
    360360/* des encryption of a 16 byte lump of data with a 112 bit key */
    361 void des_crypt112_16(uint8_t out[16], uint8_t in[16], const uint8_t key[14], int forw)
     361void des_crypt112_16(uint8_t out[16], const uint8_t in[16], const uint8_t key[14], int forw)
    362362{
    363363        des_crypt56(out, in, key, forw);
     
    368368   same method used to store passwords in the NT registry.  The DES key
    369369   used is based on the RID of the user. */
    370 void sam_rid_crypt(uint_t rid, const uint8_t *in, uint8_t *out, int forw)
     370void sam_rid_crypt(unsigned int rid, const uint8_t *in, uint8_t *out, int forw)
    371371{
    372372        uint8_t s[14];
  • vendor/current/libcli/auth/smbencrypt.c

    r414 r740  
    364364        DATA_BLOB names_blob = data_blob_talloc(mem_ctx, NULL, 0);
    365365
    366         msrpc_gen(mem_ctx, &names_blob,
     366        /* Deliberately ignore return here.. */
     367        (void)msrpc_gen(mem_ctx, &names_blob,
    367368                  "aaa",
    368369                  MsvAvNbDomainName, domain,
     
    387388        /* See http://www.ubiqx.org/cifs/SMB.html#SMB.8.5 */
    388389
    389         msrpc_gen(mem_ctx, &response, "ddbbdb",
     390        /* Deliberately ignore return here.. */
     391        (void)msrpc_gen(mem_ctx, &response, "ddbbdb",
    390392                  0x00000101,     /* Header  */
    391393                  0,              /* 'Reserved'  */
     
    530532{
    531533        uint8_t new_pw[512];
    532         size_t new_pw_len;
     534        ssize_t new_pw_len;
    533535
    534536        /* the incoming buffer can be any alignment. */
     
    538540                                 password,
    539541                                 sizeof(new_pw), string_flags);
     542        if (new_pw_len == -1) {
     543                return false;
     544        }
    540545
    541546        memcpy(&buffer[512 - new_pw_len], new_pw, new_pw_len);
  • vendor/current/libcli/auth/spnego.h

    r414 r740  
    2626#define OID_KERBEROS5 "1.2.840.113554.1.2.2"
    2727
     28#define ADS_IGNORE_PRINCIPAL "not_defined_in_RFC4178@please_ignore"
     29
    2830#define SPNEGO_DELEG_FLAG    0x01
    2931#define SPNEGO_MUTUAL_FLAG   0x02
     
    3335#define SPNEGO_CONF_FLAG     0x20
    3436#define SPNEGO_INTEG_FLAG    0x40
     37
     38#define TOK_ID_KRB_AP_REQ       ((const uint8_t *)"\x01\x00")
     39#define TOK_ID_KRB_AP_REP       ((const uint8_t *)"\x02\x00")
     40#define TOK_ID_KRB_ERROR        ((const uint8_t *)"\x03\x00")
     41#define TOK_ID_GSS_GETMIC       ((const uint8_t *)"\x01\x01")
     42#define TOK_ID_GSS_WRAP         ((const uint8_t *)"\x02\x01")
    3543
    3644enum spnego_negResult {
  • vendor/current/libcli/auth/spnego_parse.c

    r478 r740  
    5050                        for (i = 0; !asn1->has_error &&
    5151                                     0 < asn1_tag_remaining(asn1); i++) {
     52                                char *oid;
    5253                                token->mechTypes = talloc_realloc(NULL,
    5354                                                                  token->mechTypes,
    5455                                                                  const char *, i+2);
    55                                 asn1_read_OID(asn1, token->mechTypes, token->mechTypes + i);
     56                                asn1_read_OID(asn1, token->mechTypes, &oid);
     57                                token->mechTypes[i] = oid;
    5658                        }
    5759                        token->mechTypes[i] = NULL;
     
    185187        while (!asn1->has_error && 0 < asn1_tag_remaining(asn1)) {
    186188                uint8_t context;
     189                char *oid;
    187190                if (!asn1_peek_uint8(asn1, &context)) {
    188191                        asn1->has_error = true;
     
    200203                case ASN1_CONTEXT(1):
    201204                        asn1_start_tag(asn1, ASN1_CONTEXT(1));
    202                         asn1_read_OID(asn1, mem_ctx, &token->supportedMech);
     205                        asn1_read_OID(asn1, mem_ctx, &oid);
     206                        token->supportedMech = oid;
    203207                        asn1_end_tag(asn1);
    204208                        break;
     
    381385        struct asn1_data *asn1 = asn1_init(mem_ctx);
    382386
     387        if (asn1 == NULL) {
     388                return false;
     389        }
     390
    383391        /* Write mechTypes */
    384392        if (mech_types && *mech_types) {
Note: See TracChangeset for help on using the changeset viewer.