Changeset 740 for vendor/current/libcli


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
Files:
61 added
16 deleted
49 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) {
  • vendor/current/libcli/cldap/cldap.c

    r414 r740  
    168168}
    169169
    170 static void cldap_socket_recv_dgram(struct cldap_socket *c,
     170static bool cldap_socket_recv_dgram(struct cldap_socket *c,
    171171                                    struct cldap_incoming *in);
    172172
     
    177177        struct cldap_incoming *in = NULL;
    178178        ssize_t ret;
     179        bool setup_done;
    179180
    180181        c->recv_subreq = NULL;
     
    200201
    201202        /* this function should free or steal 'in' */
    202         cldap_socket_recv_dgram(c, in);
     203        setup_done = cldap_socket_recv_dgram(c, in);
    203204        in = NULL;
    204205
    205         if (!cldap_recvfrom_setup(c)) {
     206        if (!setup_done && !cldap_recvfrom_setup(c)) {
    206207                goto nomem;
    207208        }
     
    219220  handle recv events on a cldap socket
    220221*/
    221 static void cldap_socket_recv_dgram(struct cldap_socket *c,
     222static bool cldap_socket_recv_dgram(struct cldap_socket *c,
    222223                                    struct cldap_incoming *in)
    223224{
     
    263264                /* this function should free or steal 'in' */
    264265                c->incoming.handler(c, c->incoming.private_data, in);
    265                 return;
     266                return false;
    266267        }
    267268
     
    271272        search->response.asn1->ofs = 0;
    272273
     274        DLIST_REMOVE(c->searches.list, search);
     275
     276        if (!cldap_recvfrom_setup(c)) {
     277                goto nomem;
     278        }
     279
    273280        tevent_req_done(search->req);
    274         goto done;
     281        talloc_free(in);
     282        return true;
    275283
    276284nomem:
     
    290298done:
    291299        talloc_free(in);
     300        return false;
    292301}
    293302
     
    321330
    322331        if (!local_addr) {
    323                 ret = tsocket_address_inet_from_strings(c, "ip",
     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",
    324337                                                        NULL, 0,
    325338                                                        &any);
     
    947960*/
    948961NTSTATUS cldap_netlogon_recv(struct tevent_req *req,
    949                              struct smb_iconv_convenience *iconv_convenience,
    950962                             TALLOC_CTX *mem_ctx,
    951963                             struct cldap_netlogon *io)
     
    975987
    976988        status = pull_netlogon_samlogon_response(data, mem_ctx,
    977                                                  iconv_convenience,
    978989                                                 &io->out.netlogon);
    979990        if (!NT_STATUS_IS_OK(status)) {
     
    9951006*/
    9961007NTSTATUS cldap_netlogon(struct cldap_socket *cldap,
    997                         struct smb_iconv_convenience *iconv_convenience,
    9981008                        TALLOC_CTX *mem_ctx,
    9991009                        struct cldap_netlogon *io)
     
    10181028        }
    10191029
    1020         status = cldap_netlogon_recv(req, iconv_convenience, mem_ctx, io);
     1030        status = cldap_netlogon_recv(req, mem_ctx, io);
    10211031        talloc_free(req);
    10221032
     
    10821092*/
    10831093NTSTATUS cldap_netlogon_reply(struct cldap_socket *cldap,
    1084                               struct smb_iconv_convenience *iconv_convenience,
    10851094                              uint32_t message_id,
    10861095                              struct tsocket_address *dest,
     
    10961105
    10971106        status = push_netlogon_samlogon_response(&blob, tmp_ctx,
    1098                                                  iconv_convenience,
    10991107                                                 netlogon);
    11001108        if (!NT_STATUS_IS_OK(status)) {
  • vendor/current/libcli/cldap/cldap.h

    r414 r740  
    2020*/
    2121
    22 #include "../libcli/netlogon.h"
     22#include "../libcli/netlogon/netlogon.h"
    2323
    2424struct ldap_message;
     
    117117                                       const struct cldap_netlogon *io);
    118118NTSTATUS cldap_netlogon_recv(struct tevent_req *req,
    119                              struct smb_iconv_convenience *iconv_convenience,
    120119                             TALLOC_CTX *mem_ctx,
    121120                             struct cldap_netlogon *io);
    122121NTSTATUS cldap_netlogon(struct cldap_socket *cldap,
    123                         struct smb_iconv_convenience *iconv_convenience,
    124122                        TALLOC_CTX *mem_ctx,
    125123                        struct cldap_netlogon *io);
    126124
    127125NTSTATUS cldap_netlogon_reply(struct cldap_socket *cldap,
    128                               struct smb_iconv_convenience *iconv_convenience,
    129126                              uint32_t message_id,
    130127                              struct tsocket_address *dst,
  • vendor/current/libcli/drsuapi/repl_decrypt.c

    r414 r740  
    147147
    148148        switch (attr->attid) {
    149         case DRSUAPI_ATTRIBUTE_dBCSPwd:
    150         case DRSUAPI_ATTRIBUTE_unicodePwd:
    151         case DRSUAPI_ATTRIBUTE_ntPwdHistory:
    152         case DRSUAPI_ATTRIBUTE_lmPwdHistory:
     149        case DRSUAPI_ATTID_dBCSPwd:
     150        case DRSUAPI_ATTID_unicodePwd:
     151        case DRSUAPI_ATTID_ntPwdHistory:
     152        case DRSUAPI_ATTID_lmPwdHistory:
    153153                rid_crypt = true;
    154154                break;
    155         case DRSUAPI_ATTRIBUTE_supplementalCredentials:
    156         case DRSUAPI_ATTRIBUTE_priorValue:
    157         case DRSUAPI_ATTRIBUTE_currentValue:
    158         case DRSUAPI_ATTRIBUTE_trustAuthOutgoing:
    159         case DRSUAPI_ATTRIBUTE_trustAuthIncoming:
    160         case DRSUAPI_ATTRIBUTE_initialAuthOutgoing:
    161         case DRSUAPI_ATTRIBUTE_initialAuthIncoming:
     155        case DRSUAPI_ATTID_supplementalCredentials:
     156        case DRSUAPI_ATTID_priorValue:
     157        case DRSUAPI_ATTID_currentValue:
     158        case DRSUAPI_ATTID_trustAuthOutgoing:
     159        case DRSUAPI_ATTID_trustAuthIncoming:
     160        case DRSUAPI_ATTID_initialAuthOutgoing:
     161        case DRSUAPI_ATTID_initialAuthIncoming:
    162162                break;
    163163        default:
     
    309309
    310310        switch (attr->attid) {
    311         case DRSUAPI_ATTRIBUTE_dBCSPwd:
    312         case DRSUAPI_ATTRIBUTE_unicodePwd:
    313         case DRSUAPI_ATTRIBUTE_ntPwdHistory:
    314         case DRSUAPI_ATTRIBUTE_lmPwdHistory:
     311        case DRSUAPI_ATTID_dBCSPwd:
     312        case DRSUAPI_ATTID_unicodePwd:
     313        case DRSUAPI_ATTID_ntPwdHistory:
     314        case DRSUAPI_ATTID_lmPwdHistory:
    315315                rid_crypt = true;
    316316                break;
    317         case DRSUAPI_ATTRIBUTE_supplementalCredentials:
    318         case DRSUAPI_ATTRIBUTE_priorValue:
    319         case DRSUAPI_ATTRIBUTE_currentValue:
    320         case DRSUAPI_ATTRIBUTE_trustAuthOutgoing:
    321         case DRSUAPI_ATTRIBUTE_trustAuthIncoming:
    322         case DRSUAPI_ATTRIBUTE_initialAuthOutgoing:
    323         case DRSUAPI_ATTRIBUTE_initialAuthIncoming:
     317        case DRSUAPI_ATTID_supplementalCredentials:
     318        case DRSUAPI_ATTID_priorValue:
     319        case DRSUAPI_ATTID_currentValue:
     320        case DRSUAPI_ATTID_trustAuthOutgoing:
     321        case DRSUAPI_ATTID_trustAuthIncoming:
     322        case DRSUAPI_ATTID_initialAuthOutgoing:
     323        case DRSUAPI_ATTID_initialAuthIncoming:
    324324                break;
    325325        default:
  • vendor/current/libcli/ldap/ldap_message.c

    r414 r740  
    168168
    169169        for (i = 0; handlers[i].oid != NULL; i++) {
     170                if (!ctrl->oid) {
     171                        /* not encoding this control, the OID has been
     172                         * set to NULL indicating it isn't really
     173                         * here */
     174                        return true;
     175                }
    170176                if (strcmp(handlers[i].oid, ctrl->oid) == 0) {
    171177                        if (!handlers[i].encode) {
     
    435441        case LDAP_TAG_UnbindRequest: {
    436442/*              struct ldap_UnbindRequest *r = &msg->r.UnbindRequest; */
     443                asn1_push_tag(data, ASN1_APPLICATION_SIMPLE(msg->type));
     444                asn1_pop_tag(data);
    437445                break;
    438446        }
     
    669677                                                 control_handlers,
    670678                                                 msg->controls[i])) {
     679                                DEBUG(1,("Unable to encode control %s\n",
     680                                         msg->controls[i]->oid));
    671681                                return false;
    672682                        }
     
    16081618NTSTATUS ldap_full_packet(void *private_data, DATA_BLOB blob, size_t *packet_size)
    16091619{
    1610         return asn1_full_tag(blob, ASN1_SEQUENCE(0), packet_size);
    1611 }
     1620        if (blob.length < 6) {
     1621                /*
     1622                 * We need at least 6 bytes to workout the length
     1623                 * of the pdu.
     1624                 */
     1625                return STATUS_MORE_ENTRIES;
     1626        }
     1627        return asn1_peek_full_tag(blob, ASN1_SEQUENCE(0), packet_size);
     1628}
  • vendor/current/libcli/ldap/ldap_message.h

    r414 r740  
    2323
    2424#include "../libcli/ldap/ldap_errors.h"
    25 #include "lib/ldb/include/ldb.h"
     25#if _SAMBA_BUILD_ == 3
     26#include "lib/ldb_compat.h"
     27#else
     28#include <ldb.h>
     29#endif
    2630
    2731enum ldap_request_tag {
  • vendor/current/libcli/ldap/ldap_ndr.c

    r414 r740  
    2222
    2323#include "includes.h"
    24 #include "lib/ldb/include/ldb.h"
     24#if _SAMBA_BUILD_ == 3
     25#include "lib/ldb_compat.h"
     26#else
     27#include <ldb.h>
     28#endif
    2529#include "librpc/gen_ndr/ndr_security.h"
    2630#include "librpc/gen_ndr/ndr_misc.h"
     
    4852        enum ndr_err_code ndr_err;
    4953        char *ret;
    50         ndr_err = ndr_push_struct_blob(&blob, mem_ctx, NULL, sid,
     54        ndr_err = ndr_push_struct_blob(&blob, mem_ctx, sid,
    5155                                       (ndr_push_flags_fn_t)ndr_push_dom_sid);
    5256        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    6266  encode a NDR GUID as a ldap filter element
    6367*/
    64 char *ldap_encode_ndr_GUID(TALLOC_CTX *mem_ctx, struct GUID *guid)
     68char *ldap_encode_ndr_GUID(TALLOC_CTX *mem_ctx, const struct GUID *guid)
    6569{
    6670        DATA_BLOB blob;
    67         enum ndr_err_code ndr_err;
     71        NTSTATUS status;
    6872        char *ret;
    69         ndr_err = ndr_push_struct_blob(&blob, mem_ctx, NULL, guid,
    70                                        (ndr_push_flags_fn_t)ndr_push_GUID);
    71         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     73        status = GUID_to_ndr_blob(guid, mem_ctx, &blob);
     74        if (!NT_STATUS_IS_OK(status)) {
    7275                return NULL;
    7376        }
     
    8790        blob.data = val.data;
    8891        blob.length = val.length;
    89         ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, NULL, guid,
     92        ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, guid,
    9093                                       (ndr_pull_flags_fn_t)ndr_pull_GUID);
    9194        talloc_free(val.data);
  • vendor/current/libcli/ldap/ldap_ndr.h

    r414 r740  
     1/*
     2   Unix SMB/CIFS mplementation.
     3
     4   wrap/unwrap NDR encoded elements for ldap calls
     5
     6   Copyright (C) Andrew Tridgell  2005
     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*/
     22
    123#ifndef __LIBCLI_LDAP_LDAP_NDR_H__
    224#define __LIBCLI_LDAP_LDAP_NDR_H__
     
    628char *ldap_encode_ndr_uint32(TALLOC_CTX *mem_ctx, uint32_t value);
    729char *ldap_encode_ndr_dom_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
    8 char *ldap_encode_ndr_GUID(TALLOC_CTX *mem_ctx, struct GUID *guid);
     30char *ldap_encode_ndr_GUID(TALLOC_CTX *mem_ctx, const struct GUID *guid);
    931NTSTATUS ldap_decode_ndr_GUID(TALLOC_CTX *mem_ctx, struct ldb_val val, struct GUID *guid);
    1032
  • vendor/current/libcli/named_pipe_auth/npa_tstream.c

    r414 r740  
    2525#include "../librpc/gen_ndr/ndr_named_pipe_auth.h"
    2626#include "../libcli/named_pipe_auth/npa_tstream.h"
     27#if _SAMBA_BUILD_ == 4
    2728#include "libcli/raw/smb.h"
     29#endif
    2830
    2931static const struct tstream_context_ops tstream_npa_ops;
     
    4042        struct {
    4143                struct tevent_context *ev;
    42                 struct smb_iconv_convenience *smb_iconv_c;
    4344        } caller;
    4445
     
    5960
    6061struct tevent_req *tstream_npa_connect_send(TALLOC_CTX *mem_ctx,
    61                                         struct tevent_context *ev,
    62                                         struct smb_iconv_convenience *smb_iconv_c,
    63                                         const char *directory,
    64                                         const char *npipe,
    65                                         const struct tsocket_address *client,
    66                                         const char *client_name_in,
    67                                         const struct tsocket_address *server,
    68                                         const char *server_name,
    69                                         const struct netr_SamInfo3 *sam_info3,
    70                                         DATA_BLOB session_key,
    71                                         DATA_BLOB delegated_creds)
     62                                            struct tevent_context *ev,
     63                                            const char *directory,
     64                                            const char *npipe,
     65                                            const struct tsocket_address *client,
     66                                            const char *client_name_in,
     67                                            const struct tsocket_address *server,
     68                                            const char *server_name,
     69                                            const struct auth_session_info_transport *session_info)
    7270{
    7371        struct tevent_req *req;
     
    7674        int ret;
    7775        enum ndr_err_code ndr_err;
     76        char *lower_case_npipe;
     77        struct named_pipe_auth_req_info4 *info4;
    7878
    7979        req = tevent_req_create(mem_ctx, &state,
     
    8484
    8585        state->caller.ev = ev;
    86         state->caller.smb_iconv_c = smb_iconv_c;
     86
     87        lower_case_npipe = strlower_talloc(state, npipe);
     88        if (tevent_req_nomem(lower_case_npipe, req)) {
     89                goto post;
     90        }
    8791
    8892        state->unix_path = talloc_asprintf(state, "%s/%s",
    8993                                           directory,
    90                                            npipe);
     94                                           lower_case_npipe);
     95        talloc_free(lower_case_npipe);
    9196        if (tevent_req_nomem(state->unix_path, req)) {
    9297                goto post;
     
    110115
    111116        ZERO_STRUCT(state->auth_req);
    112         if (client) {
    113                 struct named_pipe_auth_req_info3 *info3;
    114 
    115                 if (!server) {
    116                         tevent_req_error(req, EINVAL);
    117                         goto post;
    118                 }
    119 
    120                 state->auth_req.level = 3;
    121                 info3 = &state->auth_req.info.info3;
    122 
    123                 info3->client_name = client_name_in;
    124                 info3->client_addr = tsocket_address_inet_addr_string(client, state);
    125                 if (!info3->client_addr) {
    126                         /* errno might be EINVAL */
    127                         tevent_req_error(req, errno);
    128                         goto post;
    129                 }
    130                 info3->client_port = tsocket_address_inet_port(client);
    131                 if (!info3->client_name) {
    132                         info3->client_name = info3->client_addr;
    133                 }
    134 
    135                 info3->server_addr = tsocket_address_inet_addr_string(server, state);
    136                 if (!info3->server_addr) {
    137                         /* errno might be EINVAL */
    138                         tevent_req_error(req, errno);
    139                         goto post;
    140                 }
    141                 info3->server_port = tsocket_address_inet_port(server);
    142                 if (!info3->server_name) {
    143                         info3->server_name = info3->server_addr;
    144                 }
    145 
    146                 info3->sam_info3 = discard_const_p(struct netr_SamInfo3, sam_info3);
    147                 info3->session_key_length = session_key.length;
    148                 info3->session_key = session_key.data;
    149                 info3->gssapi_delegated_creds_length = delegated_creds.length;
    150                 info3->gssapi_delegated_creds = delegated_creds.data;
    151 
    152         } else if (sam_info3) {
    153                 state->auth_req.level = 1;
    154                 state->auth_req.info.info1 = *sam_info3;
    155         } else {
    156                 state->auth_req.level = 0;
    157         }
     117
     118        if (!server) {
     119                tevent_req_error(req, EINVAL);
     120                goto post;
     121        }
     122
     123        state->auth_req.level = 4;
     124        info4 = &state->auth_req.info.info4;
     125
     126        info4->client_name = client_name_in;
     127        info4->client_addr = tsocket_address_inet_addr_string(client, state);
     128        if (!info4->client_addr) {
     129                /* errno might be EINVAL */
     130                tevent_req_error(req, errno);
     131                goto post;
     132        }
     133        info4->client_port = tsocket_address_inet_port(client);
     134        if (!info4->client_name) {
     135                info4->client_name = info4->client_addr;
     136        }
     137
     138        info4->server_addr = tsocket_address_inet_addr_string(server, state);
     139        if (!info4->server_addr) {
     140                /* errno might be EINVAL */
     141                tevent_req_error(req, errno);
     142                goto post;
     143        }
     144        info4->server_port = tsocket_address_inet_port(server);
     145        if (!info4->server_name) {
     146                info4->server_name = info4->server_addr;
     147        }
     148
     149        info4->session_info = discard_const_p(struct auth_session_info_transport, session_info);
    158150
    159151        if (DEBUGLVL(10)) {
     
    162154
    163155        ndr_err = ndr_push_struct_blob(&state->auth_req_blob,
    164                         state, smb_iconv_c, &state->auth_req,
     156                        state, &state->auth_req,
    165157                        (ndr_push_flags_fn_t)ndr_push_named_pipe_auth_req);
    166158        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    169161        }
    170162
    171         state->auth_req_iov.iov_base = state->auth_req_blob.data;
     163        state->auth_req_iov.iov_base = (char *) state->auth_req_blob.data;
    172164        state->auth_req_iov.iov_len = state->auth_req_blob.length;
    173165
     
    310302                return -1;
    311303        }
    312         vector[0].iov_base = state->auth_rep_blob.data + ofs;
     304        vector[0].iov_base = (char *) (state->auth_rep_blob.data + ofs);
    313305        vector[0].iov_len = state->auth_rep_blob.length - ofs;
    314306        count = 1;
     
    344336        ndr_err = ndr_pull_struct_blob(
    345337                &state->auth_rep_blob, state,
    346                 state->caller.smb_iconv_c, &state->auth_rep,
     338                &state->auth_rep,
    347339                (ndr_pull_flags_fn_t)ndr_pull_named_pipe_auth_rep);
    348340
     
    417409                                        location);
    418410        if (!stream) {
     411                *perrno = ENOMEM;
     412                tevent_req_received(req);
    419413                return -1;
    420414        }
     
    423417        npas->unix_stream = talloc_move(stream, &state->unix_stream);
    424418        switch (state->auth_rep.level) {
    425         case 0:
    426         case 1:
    427                 npas->file_type = FILE_TYPE_BYTE_MODE_PIPE;
    428                 device_state = 0x00ff;
    429                 allocation_size = 2048;
    430                 break;
    431         case 2:
    432                 npas->file_type = state->auth_rep.info.info2.file_type;
    433                 device_state = state->auth_rep.info.info2.device_state;
    434                 allocation_size = state->auth_rep.info.info2.allocation_size;
    435                 break;
    436         case 3:
    437                 npas->file_type = state->auth_rep.info.info3.file_type;
    438                 device_state = state->auth_rep.info.info3.device_state;
    439                 allocation_size = state->auth_rep.info.info3.allocation_size;
     419        case 4:
     420                npas->file_type = state->auth_rep.info.info4.file_type;
     421                device_state = state->auth_rep.info.info4.device_state;
     422                allocation_size = state->auth_rep.info.info4.allocation_size;
    440423                break;
    441424        }
     
    570553
    571554                                base += left;
    572                                 state->vector[0].iov_base = base;
     555                                state->vector[0].iov_base = (char *) base;
    573556                                state->vector[0].iov_len -= left;
    574557
     
    595578                if (left > 0) {
    596579                        memmove(pbase, pbase + ofs, left);
    597                         npas->pending.iov_base = pbase;
     580                        npas->pending.iov_base = (char *) pbase;
    598581                        npas->pending.iov_len = left;
    599582                        /*
     
    603586                        pbase = talloc_realloc(npas, pbase, uint8_t, left);
    604587                        if (pbase) {
    605                                 npas->pending.iov_base = pbase;
     588                                npas->pending.iov_base = (char *) pbase;
    606589                        }
    607590                        pbase = NULL;
     
    691674                }
    692675                ZERO_STRUCT(state->hdr);
    693                 vector[0].iov_base = state->hdr;
     676                vector[0].iov_base = (char *) state->hdr;
    694677                vector[0].iov_len = sizeof(state->hdr);
    695678
     
    727710                        uint8_t *base;
    728711                        base = (uint8_t *)state->vector[0].iov_base;
    729                         vector[count].iov_base = base;
     712                        vector[count].iov_base = (char *) base;
    730713                        vector[count].iov_len = left;
    731714                        count++;
    732715                        base += left;
    733                         state->vector[0].iov_base = base;
     716                        state->vector[0].iov_base = (char *) base;
    734717                        state->vector[0].iov_len -= left;
    735718                        break;
     
    744727        if (left > 0) {
    745728                /*
    746                  * if the message if longer than the buffers the caller
     729                 * if the message is longer than the buffers the caller
    747730                 * requested, we need to consume the rest of the message
    748731                 * into the pending buffer, where the next readv can
    749732                 * be served from.
    750733                 */
    751                 npas->pending.iov_base = talloc_array(npas, uint8_t, left);
     734                npas->pending.iov_base = talloc_array(npas, char, left);
    752735                if (!npas->pending.iov_base) {
    753736                        return -1;
     
    809792
    810793        /* the header for message mode */
     794        bool hdr_used;
    811795        uint8_t hdr[2];
    812796
     
    845829        switch (npas->file_type) {
    846830        case FILE_TYPE_BYTE_MODE_PIPE:
     831                state->hdr_used = false;
    847832                state->vector   = vector;
    848833                state->count    = count;
     
    858843                        goto post;
    859844                }
    860                 new_vector[0].iov_base = state->hdr;
     845                new_vector[0].iov_base = (char *) state->hdr;
    861846                new_vector[0].iov_len = sizeof(state->hdr);
    862847                memcpy(new_vector + 1, vector, sizeof(struct iovec)*count);
    863848
     849                state->hdr_used = true;
    864850                state->vector   = new_vector;
    865851                state->count    = count + 1;
     
    910896                tevent_req_error(req, sys_errno);
    911897                return;
     898        }
     899
     900        /*
     901         * in message mode we need to hide the length
     902         * of the hdr from the caller
     903         */
     904        if (state->hdr_used) {
     905                ret -= sizeof(state->hdr);
    912906        }
    913907
     
    10701064}
    10711065
     1066
     1067struct tstream_npa_accept_state {
     1068        struct tevent_context *ev;
     1069        struct tstream_context *plain;
     1070        uint16_t file_type;
     1071        uint16_t device_state;
     1072        uint64_t alloc_size;
     1073
     1074        DATA_BLOB npa_blob;
     1075        struct iovec out_iov;
     1076
     1077        /* results */
     1078        NTSTATUS accept_status;
     1079        struct tsocket_address *client;
     1080        char *client_name;
     1081        struct tsocket_address *server;
     1082        char *server_name;
     1083        struct auth_session_info_transport *session_info;
     1084};
     1085
     1086static int tstream_npa_accept_next_vector(struct tstream_context *unix_stream,
     1087                                          void *private_data,
     1088                                          TALLOC_CTX *mem_ctx,
     1089                                          struct iovec **_vector,
     1090                                          size_t *_count);
     1091static void tstream_npa_accept_existing_reply(struct tevent_req *subreq);
     1092static void tstream_npa_accept_existing_done(struct tevent_req *subreq);
     1093
     1094struct tevent_req *tstream_npa_accept_existing_send(TALLOC_CTX *mem_ctx,
     1095                                        struct tevent_context *ev,
     1096                                        struct tstream_context *plain,
     1097                                        uint16_t file_type,
     1098                                        uint16_t device_state,
     1099                                        uint64_t allocation_size)
     1100{
     1101        struct tstream_npa_accept_state *state;
     1102        struct tevent_req *req, *subreq;
     1103
     1104        req = tevent_req_create(mem_ctx, &state,
     1105                                struct tstream_npa_accept_state);
     1106        if (req == NULL) {
     1107                return NULL;
     1108        }
     1109
     1110        switch (file_type) {
     1111        case FILE_TYPE_BYTE_MODE_PIPE:
     1112                break;
     1113        case FILE_TYPE_MESSAGE_MODE_PIPE:
     1114                break;
     1115        default:
     1116                tevent_req_error(req, EINVAL);
     1117                goto post;
     1118        }
     1119
     1120        ZERO_STRUCTP(state);
     1121
     1122        state->ev = ev;
     1123        state->plain = plain;
     1124        state->file_type = file_type;
     1125        state->device_state = device_state;
     1126        state->alloc_size = allocation_size;
     1127
     1128        /*
     1129         * The named pipe pdu's have the length as 8 byte (initial_read_size),
     1130         * named_pipe_full_request provides the pdu length then.
     1131         */
     1132        subreq = tstream_readv_pdu_send(state, ev, plain,
     1133                                        tstream_npa_accept_next_vector,
     1134                                        state);
     1135        if (tevent_req_nomem(subreq, req)) {
     1136                goto post;
     1137        }
     1138
     1139        tevent_req_set_callback(subreq,
     1140                                tstream_npa_accept_existing_reply, req);
     1141
     1142        return req;
     1143
     1144post:
     1145        tevent_req_post(req, ev);
     1146        return req;
     1147}
     1148
     1149static int tstream_npa_accept_next_vector(struct tstream_context *unix_stream,
     1150                                          void *private_data,
     1151                                          TALLOC_CTX *mem_ctx,
     1152                                          struct iovec **_vector,
     1153                                          size_t *_count)
     1154{
     1155        struct tstream_npa_accept_state *state =
     1156                talloc_get_type_abort(private_data,
     1157                                        struct tstream_npa_accept_state);
     1158        struct iovec *vector;
     1159        size_t count;
     1160        off_t ofs = 0;
     1161
     1162        if (state->npa_blob.length == 0) {
     1163                state->npa_blob = data_blob_talloc(state, NULL, 4);
     1164                if (!state->npa_blob.data) {
     1165                        return -1;
     1166                }
     1167        } else if (state->npa_blob.length == 4) {
     1168                uint32_t msg_len;
     1169
     1170                ofs = 4;
     1171
     1172                msg_len = RIVAL(state->npa_blob.data, 0);
     1173
     1174                if (msg_len > 0x00FFFFFF) {
     1175                        errno = EMSGSIZE;
     1176                        return -1;
     1177                }
     1178
     1179                if (msg_len == 0) {
     1180                        errno = EMSGSIZE;
     1181                        return -1;
     1182                }
     1183
     1184                msg_len += ofs;
     1185
     1186                state->npa_blob.data = talloc_realloc(state,
     1187                                                      state->npa_blob.data,
     1188                                                      uint8_t, msg_len);
     1189                if (!state->npa_blob.data) {
     1190                        return -1;
     1191                }
     1192                state->npa_blob.length = msg_len;
     1193        } else {
     1194                if (memcmp(&state->npa_blob.data[4],
     1195                           NAMED_PIPE_AUTH_MAGIC, 4) != 0) {
     1196                        DEBUG(0, ("Wrong protocol\n"));
     1197#if defined(EPROTONOSUPPORT)
     1198                        errno = EPROTONOSUPPORT;
     1199#elif defined(EPROTO)
     1200                        errno = EPROTO;
     1201#else
     1202                        errno = EINVAL;
     1203#endif
     1204                        return -1;
     1205                }
     1206                *_vector = NULL;
     1207                *_count = 0;
     1208                return 0;
     1209        }
     1210
     1211        /* we need to get a message header */
     1212        vector = talloc_array(mem_ctx, struct iovec, 1);
     1213        if (!vector) {
     1214                return -1;
     1215        }
     1216        vector[0].iov_base = (char *) (state->npa_blob.data + ofs);
     1217        vector[0].iov_len = state->npa_blob.length - ofs;
     1218        count = 1;
     1219
     1220        *_vector = vector;
     1221        *_count = count;
     1222        return 0;
     1223}
     1224
     1225static void tstream_npa_accept_existing_reply(struct tevent_req *subreq)
     1226{
     1227        struct tevent_req *req =
     1228                        tevent_req_callback_data(subreq, struct tevent_req);
     1229        struct tstream_npa_accept_state *state =
     1230                        tevent_req_data(req, struct tstream_npa_accept_state);
     1231        struct named_pipe_auth_req *pipe_request;
     1232        struct named_pipe_auth_rep pipe_reply;
     1233        struct named_pipe_auth_req_info4 i4;
     1234        enum ndr_err_code ndr_err;
     1235        DATA_BLOB out;
     1236        int sys_errno;
     1237        int ret;
     1238
     1239        ret = tstream_readv_pdu_recv(subreq, &sys_errno);
     1240        TALLOC_FREE(subreq);
     1241        if (ret == -1) {
     1242                tevent_req_error(req, sys_errno);
     1243                return;
     1244        }
     1245
     1246        DEBUG(10, ("Received packet of length %lu\n",
     1247                   (long)state->npa_blob.length));
     1248        dump_data(11, state->npa_blob.data, state->npa_blob.length);
     1249
     1250        ZERO_STRUCT(pipe_reply);
     1251        pipe_reply.level = 0;
     1252        pipe_reply.status = NT_STATUS_INTERNAL_ERROR;
     1253        /*
     1254         * TODO: check it's a root (uid == 0) pipe
     1255         */
     1256
     1257        pipe_request = talloc(state, struct named_pipe_auth_req);
     1258        if (!pipe_request) {
     1259                DEBUG(0, ("Out of memory!\n"));
     1260                goto reply;
     1261        }
     1262
     1263        /* parse the passed credentials */
     1264        ndr_err = ndr_pull_struct_blob_all(
     1265                        &state->npa_blob, pipe_request, pipe_request,
     1266                        (ndr_pull_flags_fn_t)ndr_pull_named_pipe_auth_req);
     1267        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     1268                pipe_reply.status = ndr_map_error2ntstatus(ndr_err);
     1269                DEBUG(2, ("Could not unmarshall named_pipe_auth_req: %s\n",
     1270                          nt_errstr(pipe_reply.status)));
     1271                goto reply;
     1272        }
     1273
     1274        if (DEBUGLVL(10)) {
     1275                NDR_PRINT_DEBUG(named_pipe_auth_req, pipe_request);
     1276        }
     1277
     1278        ZERO_STRUCT(i4);
     1279
     1280        if (pipe_request->level != 4) {
     1281                DEBUG(0, ("Unknown level %u\n", pipe_request->level));
     1282                pipe_reply.level = 0;
     1283                pipe_reply.status = NT_STATUS_INVALID_LEVEL;
     1284                goto reply;
     1285        }
     1286
     1287        pipe_reply.level = 4;
     1288        pipe_reply.status = NT_STATUS_OK;
     1289        pipe_reply.info.info4.file_type = state->file_type;
     1290        pipe_reply.info.info4.device_state = state->device_state;
     1291        pipe_reply.info.info4.allocation_size = state->alloc_size;
     1292
     1293        i4 = pipe_request->info.info4;
     1294        if (i4.server_addr == NULL) {
     1295                pipe_reply.status = NT_STATUS_INVALID_ADDRESS;
     1296                DEBUG(2, ("Missing server address\n"));
     1297                goto reply;
     1298        }
     1299        if (i4.client_addr == NULL) {
     1300                pipe_reply.status = NT_STATUS_INVALID_ADDRESS;
     1301                DEBUG(2, ("Missing client address\n"));
     1302                goto reply;
     1303        }
     1304
     1305        state->server_name = discard_const_p(char,
     1306                                             talloc_move(state, &i4.server_name));
     1307        ret = tsocket_address_inet_from_strings(state, "ip",
     1308                                                i4.server_addr,
     1309                                                i4.server_port,
     1310                                                &state->server);
     1311        if (ret != 0) {
     1312                DEBUG(2, ("Invalid server address[%s:%u] - %s\n",
     1313                          i4.server_addr, i4.server_port,
     1314                          strerror(errno)));
     1315                pipe_reply.status = NT_STATUS_INVALID_ADDRESS;
     1316                goto reply;
     1317        }
     1318
     1319        state->client_name = discard_const_p(char,
     1320                                             talloc_move(state, &i4.client_name));
     1321        ret = tsocket_address_inet_from_strings(state, "ip",
     1322                                                i4.client_addr,
     1323                                                i4.client_port,
     1324                                                &state->client);
     1325        if (ret != 0) {
     1326                DEBUG(2, ("Invalid server address[%s:%u] - %s\n",
     1327                          i4.client_addr, i4.client_port,
     1328                          strerror(errno)));
     1329                pipe_reply.status = NT_STATUS_INVALID_ADDRESS;
     1330                goto reply;
     1331        }
     1332
     1333        state->session_info = talloc_move(state, &i4.session_info);
     1334reply:
     1335        /* create the output */
     1336        ndr_err = ndr_push_struct_blob(&out, state, &pipe_reply,
     1337                        (ndr_push_flags_fn_t)ndr_push_named_pipe_auth_rep);
     1338        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     1339                DEBUG(2, ("Error encoding structure: %s",
     1340                          ndr_map_error2string(ndr_err)));
     1341                tevent_req_error(req, EIO);
     1342                return;
     1343        }
     1344
     1345        DEBUG(10, ("named_pipe_auth reply[%u]\n", (unsigned)out.length));
     1346        dump_data(11, out.data, out.length);
     1347
     1348        if (DEBUGLVL(10)) {
     1349                NDR_PRINT_DEBUG(named_pipe_auth_rep, &pipe_reply);
     1350        }
     1351
     1352        state->accept_status = pipe_reply.status;
     1353
     1354        state->out_iov.iov_base = (char *) out.data;
     1355        state->out_iov.iov_len = out.length;
     1356
     1357        subreq = tstream_writev_send(state, state->ev,
     1358                                     state->plain,
     1359                                     &state->out_iov, 1);
     1360        if (tevent_req_nomem(subreq, req)) {
     1361                DEBUG(0, ("no memory for tstream_writev_send"));
     1362                return;
     1363        }
     1364
     1365        tevent_req_set_callback(subreq, tstream_npa_accept_existing_done, req);
     1366}
     1367
     1368static void tstream_npa_accept_existing_done(struct tevent_req *subreq)
     1369{
     1370        struct tevent_req *req =
     1371                        tevent_req_callback_data(subreq, struct tevent_req);
     1372        int sys_errno;
     1373        int ret;
     1374
     1375        ret = tstream_writev_recv(subreq, &sys_errno);
     1376        TALLOC_FREE(subreq);
     1377        if (ret == -1) {
     1378                tevent_req_error(req, sys_errno);
     1379                return;
     1380        }
     1381
     1382        tevent_req_done(req);
     1383}
     1384
     1385int _tstream_npa_accept_existing_recv(struct tevent_req *req,
     1386                                      int *perrno,
     1387                                      TALLOC_CTX *mem_ctx,
     1388                                      struct tstream_context **stream,
     1389                                      struct tsocket_address **client,
     1390                                      char **_client_name,
     1391                                      struct tsocket_address **server,
     1392                                      char **server_name,
     1393                                      struct auth_session_info_transport **session_info,
     1394                                      const char *location)
     1395{
     1396        struct tstream_npa_accept_state *state =
     1397                        tevent_req_data(req, struct tstream_npa_accept_state);
     1398        struct tstream_npa *npas;
     1399        int ret;
     1400
     1401        ret = tsocket_simple_int_recv(req, perrno);
     1402        if (ret != 0) {
     1403                DEBUG(2, ("Failed to accept named pipe conection: %s\n",
     1404                          strerror(*perrno)));
     1405                tevent_req_received(req);
     1406                return -1;
     1407        }
     1408
     1409        if (!NT_STATUS_IS_OK(state->accept_status)) {
     1410#if defined(EPROTONOSUPPORT)
     1411                *perrno = EPROTONOSUPPORT;
     1412#elif defined(EPROTO)
     1413                *perrno = EPROTO;
     1414#else
     1415                *perrno = EINVAL;
     1416#endif
     1417                DEBUG(2, ("Failed to accept named pipe conection: %s => %s\n",
     1418                          nt_errstr(state->accept_status),
     1419                          strerror(*perrno)));
     1420                tevent_req_received(req);
     1421                return -1;
     1422        }
     1423
     1424        *stream = tstream_context_create(mem_ctx,
     1425                                         &tstream_npa_ops,
     1426                                         &npas,
     1427                                         struct tstream_npa,
     1428                                         location);
     1429        if (!*stream) {
     1430                *perrno = ENOMEM;
     1431                tevent_req_received(req);
     1432                return -1;
     1433        }
     1434        ZERO_STRUCTP(npas);
     1435        npas->unix_stream = state->plain;
     1436        npas->file_type = state->file_type;
     1437
     1438        *client = talloc_move(mem_ctx, &state->client);
     1439        *_client_name = talloc_move(mem_ctx, &state->client_name);
     1440        *server = talloc_move(mem_ctx, &state->server);
     1441        *server_name = talloc_move(mem_ctx, &state->server_name);
     1442        *session_info = talloc_move(mem_ctx, &state->session_info);
     1443
     1444        tevent_req_received(req);
     1445        return 0;
     1446}
  • vendor/current/libcli/named_pipe_auth/npa_tstream.h

    r414 r740  
    2323struct tevent_req;
    2424struct tevent_context;
    25 struct netr_SamInfo3;
     25struct auth_session_info_transport;
     26struct tsocket_address;
    2627
    2728struct tevent_req *tstream_npa_connect_send(TALLOC_CTX *mem_ctx,
    28                                         struct tevent_context *ev,
    29                                         struct smb_iconv_convenience *smb_iconv_c,
    30                                         const char *directory,
    31                                         const char *npipe,
    32                                         const struct tsocket_address *client,
    33                                         const char *client_name_in,
    34                                         const struct tsocket_address *server,
    35                                         const char *server_name,
    36                                         const struct netr_SamInfo3 *info3,
    37                                         DATA_BLOB session_key,
    38                                         DATA_BLOB delegated_creds);
     29                                            struct tevent_context *ev,
     30                                            const char *directory,
     31                                            const char *npipe,
     32                                            const struct tsocket_address *client,
     33                                            const char *client_name_in,
     34                                            const struct tsocket_address *server,
     35                                            const char *server_name,
     36                                            const struct auth_session_info_transport *session_info);
    3937int _tstream_npa_connect_recv(struct tevent_req *req,
    4038                              int *perrno,
     
    5856                                     __location__)
    5957
     58
     59/**
     60 * @brief Accepts a connection for authenticated named pipes
     61 *
     62 * @param[in]  mem_ctx          The memory context for the operation
     63 * @param[in]  ev               The tevent_context for the operation
     64 * @param[in]  plain            The plain tstream_context of the bsd unix
     65 *                              domain socket.
     66 *                              This must be valid for the whole life of the
     67 *                              resulting npa tstream_context!
     68 * @param[in]  file_type        The file_type, message mode or byte mode
     69 * @param[in]  device_state     The reported device state
     70 * @param[in]  allocation_size  The reported allocation size
     71 *
     72 * @return the tevent_req handle
     73 */
     74struct tevent_req *tstream_npa_accept_existing_send(TALLOC_CTX *mem_ctx,
     75                                        struct tevent_context *ev,
     76                                        struct tstream_context *plain,
     77                                        uint16_t file_type,
     78                                        uint16_t device_state,
     79                                        uint64_t allocation_size);
     80
     81/**
     82 * @brief The receive end of the previous async function
     83 *
     84 * @param[in]  req              The tevent_req handle
     85 * @param[out] perrno           Pointer to store the errno in case of error
     86 * @param[in]  mem_ctx          The memory context for the results
     87 * @param[out] stream           The resulting stream
     88 * @param[out] client           The resulting client address
     89 * @param[out] client_name      The resulting client name
     90 * @param[out] server           The resulting server address
     91 * @param[out] server_name      The resulting server name
     92 * @param[out] info3            The info3 auth for the connecting user.
     93 * @param[out] session_key      The resulting session key
     94 * @param[out] delegated_creds  Delegated credentials
     95 *
     96 * @return  0 if successful, -1 on failure with *perror filled.
     97 */
     98int _tstream_npa_accept_existing_recv(struct tevent_req *req,
     99                                      int *perrno,
     100                                      TALLOC_CTX *mem_ctx,
     101                                      struct tstream_context **stream,
     102                                      struct tsocket_address **client,
     103                                      char **_client_name,
     104                                      struct tsocket_address **server,
     105                                      char **server_name,
     106                                      struct auth_session_info_transport **session_info,
     107                                      const char *location);
     108#define tstream_npa_accept_existing_recv(req, perrno, \
     109                                         mem_ctx, stream, \
     110                                         client, client_name, \
     111                                         server, server_name, \
     112                                         session_info) \
     113        _tstream_npa_accept_existing_recv(req, perrno, \
     114                                          mem_ctx, stream, \
     115                                          client, client_name, \
     116                                          server, server_name, \
     117                                          session_info, \
     118                                          __location__)
     119
    60120#endif /* NPA_TSTREAM_H */
  • vendor/current/libcli/nbt/libnbt.h

    r414 r740  
    9696        struct socket_context *sock;
    9797        struct tevent_context *event_ctx;
    98         struct smb_iconv_convenience *iconv_convenience;
    9998
    10099        /* a queue of requests pending to be sent */
     
    276275
    277276struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
    278                                              struct tevent_context *event_ctx,
    279                                              struct smb_iconv_convenience *iconv_convenience);
     277                                             struct tevent_context *event_ctx);
    280278void nbt_name_socket_handle_response_packet(struct nbt_name_request *req,
    281279                                            struct nbt_name_packet *packet,
     
    295293
    296294NTSTATUS nbt_name_dup(TALLOC_CTX *mem_ctx, struct nbt_name *name, struct nbt_name *newname);
    297 NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, DATA_BLOB *blob, struct nbt_name *name);
     295NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct nbt_name *name);
    298296NTSTATUS nbt_name_from_blob(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, struct nbt_name *name);
    299297void nbt_choose_called_name(TALLOC_CTX *mem_ctx, struct nbt_name *n, const char *name, int type);
     
    342340NTSTATUS nbt_rcode_to_ntstatus(uint8_t rcode);
    343341
    344 struct composite_context;
    345 struct composite_context *nbt_name_register_bcast_send(struct nbt_name_socket *nbtsock,
    346                                                        struct nbt_name_register_bcast *io);
    347 NTSTATUS nbt_name_register_bcast_recv(struct composite_context *c);
    348 struct composite_context *nbt_name_register_wins_send(struct nbt_name_socket *nbtsock,
    349                                                       struct nbt_name_register_wins *io);
    350 NTSTATUS nbt_name_refresh_wins_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
    351                                      struct nbt_name_refresh_wins *io);
    352 struct composite_context *nbt_name_refresh_wins_send(struct nbt_name_socket *nbtsock,
    353                                                       struct nbt_name_refresh_wins *io);
    354 NTSTATUS nbt_name_register_wins_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
     342struct tevent_context;
     343struct tevent_req;
     344struct tevent_req *nbt_name_register_bcast_send(TALLOC_CTX *mem_ctx,
     345                                        struct tevent_context *ev,
     346                                        struct nbt_name_socket *nbtsock,
     347                                        struct nbt_name_register_bcast *io);
     348NTSTATUS nbt_name_register_bcast_recv(struct tevent_req *req);
     349struct tevent_req *nbt_name_register_wins_send(TALLOC_CTX *mem_ctx,
     350                                               struct tevent_context *ev,
     351                                               struct nbt_name_socket *nbtsock,
     352                                               struct nbt_name_register_wins *io);
     353NTSTATUS nbt_name_register_wins_recv(struct tevent_req *req,
     354                                     TALLOC_CTX *mem_ctx,
    355355                                     struct nbt_name_register_wins *io);
    356 
     356struct tevent_req *nbt_name_refresh_wins_send(TALLOC_CTX *mem_ctx,
     357                                              struct tevent_context *ev,
     358                                              struct nbt_name_socket *nbtsock,
     359                                              struct nbt_name_refresh_wins *io);
     360NTSTATUS nbt_name_refresh_wins_recv(struct tevent_req *req,
     361                                    TALLOC_CTX *mem_ctx,
     362                                    struct nbt_name_refresh_wins *io);
    357363
    358364XFILE *startlmhosts(const char *fname);
     
    361367void endlmhosts(XFILE *fp);
    362368
     369NTSTATUS resolve_lmhosts_file_as_sockaddr(const char *lmhosts_file,
     370                                          const char *name, int name_type,
     371                                          TALLOC_CTX *mem_ctx,
     372                                          struct sockaddr_storage **return_iplist,
     373                                          int *return_count);
     374
     375NTSTATUS resolve_dns_hosts_file_as_sockaddr(const char *dns_hosts_file,
     376                                            const char *name, bool srv_lookup,
     377                                            TALLOC_CTX *mem_ctx,
     378                                            struct sockaddr_storage **return_iplist,
     379                                            int *return_count);
     380
    363381#endif /* __LIBNBT_H__ */
  • vendor/current/libcli/nbt/lmhosts.c

    r414 r740  
    2727#include "system/filesys.h"
    2828#include "system/network.h"
     29#include "../libcli/nbt/libnbt.h"
    2930
    3031/********************************************************
     
    156157}
    157158
     159/********************************************************
     160 Resolve via "lmhosts" method.
     161*********************************************************/
     162
     163NTSTATUS resolve_lmhosts_file_as_sockaddr(const char *lmhosts_file,
     164                                          const char *name, int name_type,
     165                                          TALLOC_CTX *mem_ctx,
     166                                          struct sockaddr_storage **return_iplist,
     167                                          int *return_count)
     168{
     169        /*
     170         * "lmhosts" means parse the local lmhosts file.
     171         */
     172
     173        XFILE *fp;
     174        char *lmhost_name = NULL;
     175        int name_type2;
     176        struct sockaddr_storage return_ss;
     177        NTSTATUS status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
     178        TALLOC_CTX *ctx = NULL;
     179
     180        *return_iplist = NULL;
     181        *return_count = 0;
     182
     183        DEBUG(3,("resolve_lmhosts: "
     184                "Attempting lmhosts lookup for name %s<0x%x>\n",
     185                name, name_type));
     186
     187        fp = startlmhosts(lmhosts_file);
     188
     189        if ( fp == NULL )
     190                return NT_STATUS_NO_SUCH_FILE;
     191
     192        ctx = talloc_new(mem_ctx);
     193        if (!ctx) {
     194                endlmhosts(fp);
     195                return NT_STATUS_NO_MEMORY;
     196        }
     197
     198        while (getlmhostsent(ctx, fp, &lmhost_name, &name_type2, &return_ss)) {
     199
     200                if (!strequal(name, lmhost_name)) {
     201                        TALLOC_FREE(lmhost_name);
     202                        continue;
     203                }
     204
     205                if ((name_type2 != -1) && (name_type != name_type2)) {
     206                        TALLOC_FREE(lmhost_name);
     207                        continue;
     208                }
     209               
     210                *return_iplist = talloc_realloc(ctx, (*return_iplist),
     211                                                struct sockaddr_storage,
     212                                                (*return_count)+1);
     213
     214                if ((*return_iplist) == NULL) {
     215                        TALLOC_FREE(ctx);
     216                        endlmhosts(fp);
     217                        DEBUG(3,("resolve_lmhosts: talloc_realloc fail !\n"));
     218                        return NT_STATUS_NO_MEMORY;
     219                }
     220
     221                (*return_iplist)[*return_count] = return_ss;
     222                *return_count += 1;
     223
     224                /* we found something */
     225                status = NT_STATUS_OK;
     226
     227                /* Multiple names only for DC lookup */
     228                if (name_type != 0x1c)
     229                        break;
     230        }
     231
     232        talloc_steal(mem_ctx, *return_iplist);
     233        TALLOC_FREE(ctx);
     234        endlmhosts(fp);
     235        return status;
     236}
     237
  • vendor/current/libcli/nbt/man/nmblookup.1.xml

    r414 r740  
    11<?xml version="1.0" encoding="iso-8859-1"?>
    2 <!DOCTYPE refentry PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
     2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
    33<refentry id="nmblookup">
    44
     
    107107                </varlistentry>
    108108
    109 
    110 
    111                 &popt.common.connection;
    112                 &stdarg.help;
    113 
    114109                <varlistentry>
    115110                <term>-B &lt;broadcast address&gt;</term>
     
    124119                </varlistentry>
    125120
    126 
    127 
    128121                <varlistentry>
    129122                <term>-U &lt;unicast address&gt;</term>
     
    133126                query a WINS server.</para></listitem>
    134127                </varlistentry>
    135                
    136                 &stdarg.server.debug;   
    137                 &popt.common.samba;
    138128
    139129                <varlistentry>
  • vendor/current/libcli/nbt/namerefresh.c

    r414 r740  
    2121
    2222#include "includes.h"
     23#include <tevent.h>
    2324#include "../libcli/nbt/libnbt.h"
    2425#include "../libcli/nbt/nbt_proto.h"
    25 #include "libcli/composite/composite.h"
    2626#include "lib/socket/socket.h"
     27#include "lib/util/tevent_ntstatus.h"
    2728
    2829/*
     
    143144  reply for each address
    144145*/
    145 struct refresh_wins_state {
     146struct nbt_name_refresh_wins_state {
    146147        struct nbt_name_socket *nbtsock;
    147148        struct nbt_name_refresh *io;
    148         const char **wins_servers;
     149        char **wins_servers;
    149150        uint16_t wins_port;
    150         const char **addresses;
     151        char **addresses;
    151152        int address_idx;
    152         struct nbt_name_request *req;
    153153};
    154154
    155 
    156 /**
    157   state handler for WINS multi-homed multi-server name refresh
    158 */
    159 static void name_refresh_wins_handler(struct nbt_name_request *req)
    160 {
    161         struct composite_context *c = talloc_get_type(req->async.private_data,
    162                                                       struct composite_context);
    163         struct refresh_wins_state *state = talloc_get_type(c->private_data,
    164                                                             struct refresh_wins_state);
    165         NTSTATUS status;
    166 
    167         status = nbt_name_refresh_recv(state->req, state, state->io);
    168         if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
    169                 /* the refresh timed out - try the next WINS server */
    170                 state->wins_servers++;
    171                 state->address_idx = 0;
    172                 if (state->wins_servers[0] == NULL) {
    173                         c->state = COMPOSITE_STATE_ERROR;
    174                         c->status = status;
    175                         goto done;
    176                 }
    177                 state->io->in.dest_addr = state->wins_servers[0];
    178                 state->io->in.dest_port = state->wins_port;
    179                 state->io->in.address   = state->addresses[0];
    180                 state->req = nbt_name_refresh_send(state->nbtsock, state->io);
    181                 if (state->req == NULL) {
    182                         c->state = COMPOSITE_STATE_ERROR;
    183                         c->status = NT_STATUS_NO_MEMORY;
    184                 } else {
    185                         state->req->async.fn      = name_refresh_wins_handler;
    186                         state->req->async.private_data = c;
    187                 }
    188         } else if (!NT_STATUS_IS_OK(status)) {
    189                 c->state = COMPOSITE_STATE_ERROR;
    190                 c->status = status;
    191         } else {
    192                 if (state->io->out.rcode == 0 &&
    193                     state->addresses[state->address_idx+1] != NULL) {
    194                         /* refresh our next address */
    195                         state->io->in.address = state->addresses[++(state->address_idx)];
    196                         state->req = nbt_name_refresh_send(state->nbtsock, state->io);
    197                         if (state->req == NULL) {
    198                                 c->state = COMPOSITE_STATE_ERROR;
    199                                 c->status = NT_STATUS_NO_MEMORY;
    200                         } else {
    201                                 state->req->async.fn      = name_refresh_wins_handler;
    202                                 state->req->async.private_data = c;
    203                         }
    204                 } else {
    205                         c->state = COMPOSITE_STATE_DONE;
    206                         c->status = NT_STATUS_OK;
    207                 }
    208         }
    209 
    210 done:
    211         if (c->state >= COMPOSITE_STATE_DONE &&
    212             c->async.fn) {
    213                 c->async.fn(c);
    214         }
    215 }
     155static void nbt_name_refresh_wins_handler(struct nbt_name_request *subreq);
    216156
    217157/**
    218158  the async send call for a multi-server WINS refresh
    219159*/
    220 _PUBLIC_ struct composite_context *nbt_name_refresh_wins_send(struct nbt_name_socket *nbtsock,
    221                                                       struct nbt_name_refresh_wins *io)
    222 {
    223         struct composite_context *c;
    224         struct refresh_wins_state *state;
    225 
    226         c = talloc_zero(nbtsock, struct composite_context);
    227         if (c == NULL) goto failed;
    228 
    229         state = talloc(c, struct refresh_wins_state);
    230         if (state == NULL) goto failed;
     160_PUBLIC_ struct tevent_req *nbt_name_refresh_wins_send(TALLOC_CTX *mem_ctx,
     161                                                struct tevent_context *ev,
     162                                                struct nbt_name_socket *nbtsock,
     163                                                struct nbt_name_refresh_wins *io)
     164{
     165        struct tevent_req *req;
     166        struct nbt_name_refresh_wins_state *state;
     167        struct nbt_name_request *subreq;
     168
     169        req = tevent_req_create(mem_ctx, &state,
     170                                struct nbt_name_refresh_wins_state);
     171        if (req == NULL) {
     172                return NULL;
     173        }
    231174
    232175        state->io = talloc(state, struct nbt_name_refresh);
    233         if (state->io == NULL) goto failed;
     176        if (tevent_req_nomem(state->io, req)) {
     177                return tevent_req_post(req, ev);
     178        }
     179
     180        if (io->in.wins_servers == NULL) {
     181                tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
     182                return tevent_req_post(req, ev);
     183        }
     184
     185        if (io->in.wins_servers[0] == NULL) {
     186                tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
     187                return tevent_req_post(req, ev);
     188        }
     189
     190        if (io->in.addresses == NULL) {
     191                tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
     192                return tevent_req_post(req, ev);
     193        }
     194
     195        if (io->in.addresses[0] == NULL) {
     196                tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
     197                return tevent_req_post(req, ev);
     198        }
    234199
    235200        state->wins_port = io->in.wins_port;
    236         state->wins_servers = (const char **)str_list_copy(state, io->in.wins_servers);
    237         if (state->wins_servers == NULL ||
    238             state->wins_servers[0] == NULL) goto failed;
    239 
    240         state->addresses = (const char **)str_list_copy(state, io->in.addresses);
    241         if (state->addresses == NULL ||
    242             state->addresses[0] == NULL) goto failed;
     201        state->wins_servers = str_list_copy(state, io->in.wins_servers);
     202        if (tevent_req_nomem(state->wins_servers, req)) {
     203                return tevent_req_post(req, ev);
     204        }
     205
     206        state->addresses = str_list_copy(state, io->in.addresses);
     207        if (tevent_req_nomem(state->addresses, req)) {
     208                return tevent_req_post(req, ev);
     209        }
    243210
    244211        state->io->in.name            = io->in.name;
     
    255222        state->address_idx = 0;
    256223
    257         state->req = nbt_name_refresh_send(nbtsock, state->io);
    258         if (state->req == NULL) goto failed;
    259 
    260         state->req->async.fn      = name_refresh_wins_handler;
    261         state->req->async.private_data = c;
    262 
    263         c->private_data = state;
    264         c->state        = COMPOSITE_STATE_IN_PROGRESS;
    265         c->event_ctx    = nbtsock->event_ctx;
    266 
    267         return c;
    268 
    269 failed:
    270         talloc_free(c);
    271         return NULL;
     224        subreq = nbt_name_refresh_send(nbtsock, state->io);
     225        if (tevent_req_nomem(subreq, req)) {
     226                return tevent_req_post(req, ev);
     227        }
     228
     229        subreq->async.fn = nbt_name_refresh_wins_handler;
     230        subreq->async.private_data = req;
     231
     232        return req;
     233}
     234
     235static void nbt_name_refresh_wins_handler(struct nbt_name_request *subreq)
     236{
     237        struct tevent_req *req =
     238                talloc_get_type_abort(subreq->async.private_data,
     239                struct tevent_req);
     240        struct nbt_name_refresh_wins_state *state =
     241                tevent_req_data(req,
     242                struct nbt_name_refresh_wins_state);
     243        NTSTATUS status;
     244
     245        status = nbt_name_refresh_recv(subreq, state, state->io);
     246        if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
     247                /* the refresh timed out - try the next WINS server */
     248                state->wins_servers++;
     249                if (state->wins_servers[0] == NULL) {
     250                        tevent_req_nterror(req, status);
     251                        return;
     252                }
     253
     254                state->address_idx = 0;
     255                state->io->in.dest_addr = state->wins_servers[0];
     256                state->io->in.dest_port = state->wins_port;
     257                state->io->in.address   = state->addresses[0];
     258
     259                subreq = nbt_name_refresh_send(state->nbtsock, state->io);
     260                if (tevent_req_nomem(subreq, req)) {
     261                        return;
     262                }
     263                subreq->async.fn = nbt_name_refresh_wins_handler;
     264                subreq->async.private_data = req;
     265        } else if (!NT_STATUS_IS_OK(status)) {
     266                tevent_req_nterror(req, status);
     267                return;
     268        }
     269
     270        if (state->io->out.rcode == 0 &&
     271            state->addresses[state->address_idx+1] != NULL) {
     272                /* refresh our next address */
     273                state->io->in.address = state->addresses[++(state->address_idx)];
     274                subreq = nbt_name_refresh_send(state->nbtsock, state->io);
     275                if (tevent_req_nomem(subreq, req)) {
     276                        return;
     277                }
     278                subreq->async.fn = nbt_name_refresh_wins_handler;
     279                subreq->async.private_data = req;
     280                return;
     281        }
     282
     283        tevent_req_done(req);
    272284}
    273285
     
    275287  multi-homed WINS name refresh - recv side
    276288*/
    277 _PUBLIC_ NTSTATUS nbt_name_refresh_wins_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
    278                                      struct nbt_name_refresh_wins *io)
    279 {
     289_PUBLIC_ NTSTATUS nbt_name_refresh_wins_recv(struct tevent_req *req,
     290                                             TALLOC_CTX *mem_ctx,
     291                                             struct nbt_name_refresh_wins *io)
     292{
     293        struct nbt_name_refresh_wins_state *state =
     294                tevent_req_data(req,
     295                struct nbt_name_refresh_wins_state);
    280296        NTSTATUS status;
    281         status = composite_wait(c);
    282         if (NT_STATUS_IS_OK(status)) {
    283                 struct refresh_wins_state *state =
    284                         talloc_get_type(c->private_data, struct refresh_wins_state);
    285                 io->out.wins_server = talloc_steal(mem_ctx, state->wins_servers[0]);
    286                 io->out.rcode = state->io->out.rcode;
    287         }
    288         talloc_free(c);
    289         return status;
     297
     298        if (tevent_req_is_nterror(req, &status)) {
     299                tevent_req_received(req);
     300                return status;
     301        }
     302
     303        io->out.wins_server = talloc_move(mem_ctx, &state->wins_servers[0]);
     304        io->out.rcode = state->io->out.rcode;
     305
     306        tevent_req_received(req);
     307        return NT_STATUS_OK;
    290308}
    291309
     
    294312*/
    295313_PUBLIC_ NTSTATUS nbt_name_refresh_wins(struct nbt_name_socket *nbtsock,
    296                                 TALLOC_CTX *mem_ctx,
    297                                 struct nbt_name_refresh_wins *io)
    298 {
    299         struct composite_context *c = nbt_name_refresh_wins_send(nbtsock, io);
    300         return nbt_name_refresh_wins_recv(c, mem_ctx, io);
    301 }
     314                                        TALLOC_CTX *mem_ctx,
     315                                        struct nbt_name_refresh_wins *io)
     316{
     317        TALLOC_CTX *frame = talloc_stackframe();
     318        struct tevent_context *ev;
     319        struct tevent_req *subreq;
     320        NTSTATUS status;
     321
     322        /*
     323         * TODO: create a temporary event context
     324         */
     325        ev = nbtsock->event_ctx;
     326
     327        subreq = nbt_name_refresh_wins_send(frame, ev, nbtsock, io);
     328        if (subreq == NULL) {
     329                talloc_free(frame);
     330                return NT_STATUS_NO_MEMORY;
     331        }
     332
     333        if (!tevent_req_poll(subreq, ev)) {
     334                status = map_nt_error_from_unix(errno);
     335                talloc_free(frame);
     336                return status;
     337        }
     338
     339        status = nbt_name_refresh_wins_recv(subreq, mem_ctx, io);
     340        if (!NT_STATUS_IS_OK(status)) {
     341                talloc_free(frame);
     342                return status;
     343        }
     344
     345        TALLOC_FREE(frame);
     346        return NT_STATUS_OK;
     347}
  • vendor/current/libcli/nbt/nameregister.c

    r414 r740  
    2121
    2222#include "includes.h"
     23#include <tevent.h>
    2324#include "../libcli/nbt/libnbt.h"
    2425#include "../libcli/nbt/nbt_proto.h"
    25 #include "libcli/composite/composite.h"
    2626#include "lib/socket/socket.h"
    2727#include "librpc/gen_ndr/ndr_nbt.h"
     28#include "../lib/util/tevent_ntstatus.h"
    2829
    2930/*
     
    149150  a name registration demand
    150151*/
    151 struct register_bcast_state {
     152struct nbt_name_register_bcast_state {
    152153        struct nbt_name_socket *nbtsock;
    153         struct nbt_name_register *io;
    154         struct nbt_name_request *req;
     154        struct nbt_name_register io;
    155155};
    156156
    157 
    158 /*
    159   state handler for 4 stage name registration
    160 */
    161 static void name_register_bcast_handler(struct nbt_name_request *req)
    162 {
    163         struct composite_context *c = talloc_get_type(req->async.private_data, struct composite_context);
    164         struct register_bcast_state *state = talloc_get_type(c->private_data, struct register_bcast_state);
    165         NTSTATUS status;
    166 
    167         status = nbt_name_register_recv(state->req, state, state->io);
     157static void nbt_name_register_bcast_handler(struct nbt_name_request *subreq);
     158
     159/*
     160  the async send call for a 4 stage name registration
     161*/
     162_PUBLIC_ struct tevent_req *nbt_name_register_bcast_send(TALLOC_CTX *mem_ctx,
     163                                        struct tevent_context *ev,
     164                                        struct nbt_name_socket *nbtsock,
     165                                        struct nbt_name_register_bcast *io)
     166{
     167        struct tevent_req *req;
     168        struct nbt_name_register_bcast_state *state;
     169        struct nbt_name_request *subreq;
     170
     171        req = tevent_req_create(mem_ctx, &state,
     172                                struct nbt_name_register_bcast_state);
     173        if (req == NULL) {
     174                return NULL;
     175        }
     176
     177        state->io.in.name            = io->in.name;
     178        state->io.in.dest_addr       = io->in.dest_addr;
     179        state->io.in.dest_port       = io->in.dest_port;
     180        state->io.in.address         = io->in.address;
     181        state->io.in.nb_flags        = io->in.nb_flags;
     182        state->io.in.register_demand = false;
     183        state->io.in.broadcast       = true;
     184        state->io.in.multi_homed     = false;
     185        state->io.in.ttl             = io->in.ttl;
     186        state->io.in.timeout         = 1;
     187        state->io.in.retries         = 2;
     188
     189        state->nbtsock = nbtsock;
     190
     191        subreq = nbt_name_register_send(nbtsock, &state->io);
     192        if (tevent_req_nomem(subreq, req)) {
     193                return tevent_req_post(req, ev);
     194        }
     195
     196        subreq->async.fn = nbt_name_register_bcast_handler;
     197        subreq->async.private_data = req;
     198
     199        return req;
     200}
     201
     202static void nbt_name_register_bcast_handler(struct nbt_name_request *subreq)
     203{
     204        struct tevent_req *req =
     205                talloc_get_type_abort(subreq->async.private_data,
     206                struct tevent_req);
     207        struct nbt_name_register_bcast_state *state =
     208                tevent_req_data(req,
     209                struct nbt_name_register_bcast_state);
     210        NTSTATUS status;
     211
     212        status = nbt_name_register_recv(subreq, state, &state->io);
    168213        if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
    169                 if (state->io->in.register_demand == true) {
    170                         /* all done */
    171                         c->state = COMPOSITE_STATE_DONE;
    172                         c->status = NT_STATUS_OK;
    173                         goto done;
     214                if (state->io.in.register_demand == true) {
     215                        tevent_req_done(req);
     216                        return;
    174217                }
    175218
    176219                /* the registration timed out - good, send the demand */
    177                 state->io->in.register_demand = true;
    178                 state->io->in.retries         = 0;
    179                 state->req = nbt_name_register_send(state->nbtsock, state->io);
    180                 if (state->req == NULL) {
    181                         c->state = COMPOSITE_STATE_ERROR;
    182                         c->status = NT_STATUS_NO_MEMORY;
    183                 } else {
    184                         state->req->async.fn      = name_register_bcast_handler;
    185                         state->req->async.private_data = c;
     220                state->io.in.register_demand = true;
     221                state->io.in.retries         = 0;
     222
     223                subreq = nbt_name_register_send(state->nbtsock, &state->io);
     224                if (tevent_req_nomem(subreq, req)) {
     225                        return;
    186226                }
    187         } else if (!NT_STATUS_IS_OK(status)) {
    188                 c->state = COMPOSITE_STATE_ERROR;
    189                 c->status = status;
    190         } else {
    191                 c->state = COMPOSITE_STATE_ERROR;
    192                 c->status = NT_STATUS_CONFLICTING_ADDRESSES;
    193                 DEBUG(3,("Name registration conflict from %s for %s with ip %s - rcode %d\n",
    194                          state->io->out.reply_from,
    195                          nbt_name_string(state, &state->io->out.name),
    196                          state->io->out.reply_addr,
    197                          state->io->out.rcode));
    198         }
    199 
    200 done:
    201         if (c->state >= COMPOSITE_STATE_DONE &&
    202             c->async.fn) {
    203                 c->async.fn(c);
    204         }
    205 }
    206 
    207 /*
    208   the async send call for a 4 stage name registration
    209 */
    210 _PUBLIC_ struct composite_context *nbt_name_register_bcast_send(struct nbt_name_socket *nbtsock,
    211                                                        struct nbt_name_register_bcast *io)
    212 {
    213         struct composite_context *c;
    214         struct register_bcast_state *state;
    215 
    216         c = talloc_zero(nbtsock, struct composite_context);
    217         if (c == NULL) goto failed;
    218 
    219         state = talloc(c, struct register_bcast_state);
    220         if (state == NULL) goto failed;
    221 
    222         state->io = talloc(state, struct nbt_name_register);
    223         if (state->io == NULL) goto failed;
    224 
    225         state->io->in.name            = io->in.name;
    226         state->io->in.dest_addr       = io->in.dest_addr;
    227         state->io->in.dest_port       = io->in.dest_port;
    228         state->io->in.address         = io->in.address;
    229         state->io->in.nb_flags        = io->in.nb_flags;
    230         state->io->in.register_demand = false;
    231         state->io->in.broadcast       = true;
    232         state->io->in.multi_homed     = false;
    233         state->io->in.ttl             = io->in.ttl;
    234         state->io->in.timeout         = 1;
    235         state->io->in.retries         = 2;
    236 
    237         state->nbtsock = nbtsock;
    238 
    239         state->req = nbt_name_register_send(nbtsock, state->io);
    240         if (state->req == NULL) goto failed;
    241 
    242         state->req->async.fn      = name_register_bcast_handler;
    243         state->req->async.private_data = c;
    244 
    245         c->private_data = state;
    246         c->state        = COMPOSITE_STATE_IN_PROGRESS;
    247         c->event_ctx    = nbtsock->event_ctx;
    248 
    249         return c;
    250 
    251 failed:
    252         talloc_free(c);
    253         return NULL;
     227
     228                subreq->async.fn = nbt_name_register_bcast_handler;
     229                subreq->async.private_data = req;
     230                return;
     231        }
     232
     233        if (!NT_STATUS_IS_OK(status)) {
     234                tevent_req_nterror(req, status);
     235                return;
     236        }
     237
     238        DEBUG(3,("Name registration conflict from %s for %s with ip %s - rcode %d\n",
     239                 state->io.out.reply_from,
     240                 nbt_name_string(state, &state->io.out.name),
     241                 state->io.out.reply_addr,
     242                 state->io.out.rcode));
     243
     244        tevent_req_nterror(req, NT_STATUS_CONFLICTING_ADDRESSES);
    254245}
    255246
     
    257248  broadcast 4 part name register - recv
    258249*/
    259 _PUBLIC_ NTSTATUS nbt_name_register_bcast_recv(struct composite_context *c)
    260 {
    261         NTSTATUS status;
    262         status = composite_wait(c);
    263         talloc_free(c);
    264         return status;
     250_PUBLIC_ NTSTATUS nbt_name_register_bcast_recv(struct tevent_req *req)
     251{
     252        NTSTATUS status;
     253
     254        if (tevent_req_is_nterror(req, &status)) {
     255                tevent_req_received(req);
     256                return status;
     257        }
     258
     259        tevent_req_received(req);
     260        return NT_STATUS_OK;
    265261}
    266262
     
    271267                                 struct nbt_name_register_bcast *io)
    272268{
    273         struct composite_context *c = nbt_name_register_bcast_send(nbtsock, io);
    274         return nbt_name_register_bcast_recv(c);
     269        TALLOC_CTX *frame = talloc_stackframe();
     270        struct tevent_context *ev;
     271        struct tevent_req *subreq;
     272        NTSTATUS status;
     273
     274        /*
     275         * TODO: create a temporary event context
     276         */
     277        ev = nbtsock->event_ctx;
     278
     279        subreq = nbt_name_register_bcast_send(frame, ev, nbtsock, io);
     280        if (subreq == NULL) {
     281                talloc_free(frame);
     282                return NT_STATUS_NO_MEMORY;
     283        }
     284
     285        if (!tevent_req_poll(subreq, ev)) {
     286                status = map_nt_error_from_unix(errno);
     287                talloc_free(frame);
     288                return status;
     289        }
     290
     291        status = nbt_name_register_bcast_recv(subreq);
     292        if (!NT_STATUS_IS_OK(status)) {
     293                talloc_free(frame);
     294                return status;
     295        }
     296
     297        TALLOC_FREE(frame);
     298        return NT_STATUS_OK;
    275299}
    276300
     
    281305  reply for each address
    282306*/
    283 struct register_wins_state {
     307struct nbt_name_register_wins_state {
    284308        struct nbt_name_socket *nbtsock;
    285         struct nbt_name_register *io;
    286         const char **wins_servers;
     309        struct nbt_name_register io;
     310        char **wins_servers;
    287311        uint16_t wins_port;
    288         const char **addresses;
    289         int address_idx;
    290         struct nbt_name_request *req;
     312        char **addresses;
     313        uint32_t address_idx;
    291314};
    292315
     316static void nbt_name_register_wins_handler(struct nbt_name_request *subreq);
     317
     318/*
     319  the async send call for a multi-server WINS register
     320*/
     321_PUBLIC_ struct tevent_req *nbt_name_register_wins_send(TALLOC_CTX *mem_ctx,
     322                                                struct tevent_context *ev,
     323                                                struct nbt_name_socket *nbtsock,
     324                                                struct nbt_name_register_wins *io)
     325{
     326        struct tevent_req *req;
     327        struct nbt_name_register_wins_state *state;
     328        struct nbt_name_request *subreq;
     329
     330        req = tevent_req_create(mem_ctx, &state,
     331                                struct nbt_name_register_wins_state);
     332        if (req == NULL) {
     333                return NULL;
     334        }
     335
     336        if (io->in.wins_servers == NULL) {
     337                tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
     338                return tevent_req_post(req, ev);
     339        }
     340
     341        if (io->in.wins_servers[0] == NULL) {
     342                tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
     343                return tevent_req_post(req, ev);
     344        }
     345
     346        if (io->in.addresses == NULL) {
     347                tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
     348                return tevent_req_post(req, ev);
     349        }
     350
     351        if (io->in.addresses[0] == NULL) {
     352                tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
     353                return tevent_req_post(req, ev);
     354        }
     355
     356        state->wins_port = io->in.wins_port;
     357        state->wins_servers = str_list_copy(state, io->in.wins_servers);
     358        if (tevent_req_nomem(state->wins_servers, req)) {
     359                return tevent_req_post(req, ev);
     360        }
     361
     362        state->addresses = str_list_copy(state, io->in.addresses);
     363        if (tevent_req_nomem(state->addresses, req)) {
     364                return tevent_req_post(req, ev);
     365        }
     366
     367        state->io.in.name            = io->in.name;
     368        state->io.in.dest_addr       = state->wins_servers[0];
     369        state->io.in.dest_port       = state->wins_port;
     370        state->io.in.address         = io->in.addresses[0];
     371        state->io.in.nb_flags        = io->in.nb_flags;
     372        state->io.in.broadcast       = false;
     373        state->io.in.register_demand = false;
     374        state->io.in.multi_homed     = (io->in.nb_flags & NBT_NM_GROUP)?false:true;
     375        state->io.in.ttl             = io->in.ttl;
     376        state->io.in.timeout         = 3;
     377        state->io.in.retries         = 2;
     378
     379        state->nbtsock     = nbtsock;
     380        state->address_idx = 0;
     381
     382        subreq = nbt_name_register_send(nbtsock, &state->io);
     383        if (tevent_req_nomem(subreq, req)) {
     384                return tevent_req_post(req, ev);
     385        }
     386
     387        subreq->async.fn = nbt_name_register_wins_handler;
     388        subreq->async.private_data = req;
     389
     390        return req;
     391}
    293392
    294393/*
    295394  state handler for WINS multi-homed multi-server name register
    296395*/
    297 static void name_register_wins_handler(struct nbt_name_request *req)
    298 {
    299         struct composite_context *c = talloc_get_type(req->async.private_data,
    300                                                       struct composite_context);
    301         struct register_wins_state *state = talloc_get_type(c->private_data,
    302                                                             struct register_wins_state);
    303         NTSTATUS status;
    304 
    305         status = nbt_name_register_recv(state->req, state, state->io);
     396static void nbt_name_register_wins_handler(struct nbt_name_request *subreq)
     397{
     398        struct tevent_req *req =
     399                talloc_get_type_abort(subreq->async.private_data,
     400                struct tevent_req);
     401        struct nbt_name_register_wins_state *state =
     402                tevent_req_data(req,
     403                struct nbt_name_register_wins_state);
     404        NTSTATUS status;
     405
     406        status = nbt_name_register_recv(subreq, state, &state->io);
    306407        if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
    307408                /* the register timed out - try the next WINS server */
    308409                state->wins_servers++;
     410                if (state->wins_servers[0] == NULL) {
     411                        tevent_req_nterror(req, status);
     412                        return;
     413                }
     414
    309415                state->address_idx = 0;
    310                 if (state->wins_servers[0] == NULL) {
    311                         c->state = COMPOSITE_STATE_ERROR;
    312                         c->status = status;
    313                         goto done;
     416                state->io.in.dest_addr = state->wins_servers[0];
     417                state->io.in.dest_port = state->wins_port;
     418                state->io.in.address   = state->addresses[0];
     419
     420                subreq = nbt_name_register_send(state->nbtsock, &state->io);
     421                if (tevent_req_nomem(subreq, req)) {
     422                        return;
    314423                }
    315                 state->io->in.dest_addr = state->wins_servers[0];
    316                 state->io->in.dest_port = state->wins_port;
    317                 state->io->in.address   = state->addresses[0];
    318                 state->req = nbt_name_register_send(state->nbtsock, state->io);
    319                 if (state->req == NULL) {
    320                         c->state = COMPOSITE_STATE_ERROR;
    321                         c->status = NT_STATUS_NO_MEMORY;
    322                 } else {
    323                         state->req->async.fn      = name_register_wins_handler;
    324                         state->req->async.private_data = c;
     424
     425                subreq->async.fn = nbt_name_register_wins_handler;
     426                subreq->async.private_data = req;
     427                return;
     428        }
     429
     430        if (!NT_STATUS_IS_OK(status)) {
     431                tevent_req_nterror(req, status);
     432                return;
     433        }
     434
     435        if (state->io.out.rcode == 0 &&
     436            state->addresses[state->address_idx+1] != NULL) {
     437                /* register our next address */
     438                state->io.in.address = state->addresses[++(state->address_idx)];
     439
     440                subreq = nbt_name_register_send(state->nbtsock, &state->io);
     441                if (tevent_req_nomem(subreq, req)) {
     442                        return;
    325443                }
    326         } else if (!NT_STATUS_IS_OK(status)) {
    327                 c->state = COMPOSITE_STATE_ERROR;
    328                 c->status = status;
    329         } else {
    330                 if (state->io->out.rcode == 0 &&
    331                     state->addresses[state->address_idx+1] != NULL) {
    332                         /* register our next address */
    333                         state->io->in.address = state->addresses[++(state->address_idx)];
    334                         state->req = nbt_name_register_send(state->nbtsock, state->io);
    335                         if (state->req == NULL) {
    336                                 c->state = COMPOSITE_STATE_ERROR;
    337                                 c->status = NT_STATUS_NO_MEMORY;
    338                         } else {
    339                                 state->req->async.fn      = name_register_wins_handler;
    340                                 state->req->async.private_data = c;
    341                         }
    342                 } else {
    343                         c->state = COMPOSITE_STATE_DONE;
    344                         c->status = NT_STATUS_OK;
    345                 }
    346         }
    347 
    348 done:
    349         if (c->state >= COMPOSITE_STATE_DONE &&
    350             c->async.fn) {
    351                 c->async.fn(c);
    352         }
    353 }
    354 
    355 /*
    356   the async send call for a multi-server WINS register
    357 */
    358 _PUBLIC_ struct composite_context *nbt_name_register_wins_send(struct nbt_name_socket *nbtsock,
    359                                                       struct nbt_name_register_wins *io)
    360 {
    361         struct composite_context *c;
    362         struct register_wins_state *state;
    363 
    364         c = talloc_zero(nbtsock, struct composite_context);
    365         if (c == NULL) goto failed;
    366 
    367         state = talloc(c, struct register_wins_state);
    368         if (state == NULL) goto failed;
    369 
    370         state->io = talloc(state, struct nbt_name_register);
    371         if (state->io == NULL) goto failed;
    372 
    373         state->wins_port = io->in.wins_port;
    374         state->wins_servers = (const char **)str_list_copy(state, io->in.wins_servers);
    375         if (state->wins_servers == NULL ||
    376             state->wins_servers[0] == NULL) goto failed;
    377 
    378         state->addresses = (const char **)str_list_copy(state, io->in.addresses);
    379         if (state->addresses == NULL ||
    380             state->addresses[0] == NULL) goto failed;
    381 
    382         state->io->in.name            = io->in.name;
    383         state->io->in.dest_addr       = state->wins_servers[0];
    384         state->io->in.dest_port       = state->wins_port;
    385         state->io->in.address         = io->in.addresses[0];
    386         state->io->in.nb_flags        = io->in.nb_flags;
    387         state->io->in.broadcast       = false;
    388         state->io->in.register_demand = false;
    389         state->io->in.multi_homed     = (io->in.nb_flags & NBT_NM_GROUP)?false:true;
    390         state->io->in.ttl             = io->in.ttl;
    391         state->io->in.timeout         = 3;
    392         state->io->in.retries         = 2;
    393 
    394         state->nbtsock     = nbtsock;
    395         state->address_idx = 0;
    396 
    397         state->req = nbt_name_register_send(nbtsock, state->io);
    398         if (state->req == NULL) goto failed;
    399 
    400         state->req->async.fn      = name_register_wins_handler;
    401         state->req->async.private_data = c;
    402 
    403         c->private_data = state;
    404         c->state        = COMPOSITE_STATE_IN_PROGRESS;
    405         c->event_ctx    = nbtsock->event_ctx;
    406 
    407         return c;
    408 
    409 failed:
    410         talloc_free(c);
    411         return NULL;
     444
     445                subreq->async.fn = nbt_name_register_wins_handler;
     446                subreq->async.private_data = req;
     447                return;
     448        }
     449
     450        tevent_req_done(req);
    412451}
    413452
     
    415454  multi-homed WINS name register - recv side
    416455*/
    417 _PUBLIC_ NTSTATUS nbt_name_register_wins_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
    418                                      struct nbt_name_register_wins *io)
    419 {
    420         NTSTATUS status;
    421         status = composite_wait(c);
    422         if (NT_STATUS_IS_OK(status)) {
    423                 struct register_wins_state *state =
    424                         talloc_get_type(c->private_data, struct register_wins_state);
    425                 io->out.wins_server = talloc_steal(mem_ctx, state->wins_servers[0]);
    426                 io->out.rcode = state->io->out.rcode;
    427         }
    428         talloc_free(c);
    429         return status;
     456_PUBLIC_ NTSTATUS nbt_name_register_wins_recv(struct tevent_req *req,
     457                                              TALLOC_CTX *mem_ctx,
     458                                              struct nbt_name_register_wins *io)
     459{
     460        struct nbt_name_register_wins_state *state =
     461                tevent_req_data(req,
     462                struct nbt_name_register_wins_state);
     463        NTSTATUS status;
     464
     465        if (tevent_req_is_nterror(req, &status)) {
     466                tevent_req_received(req);
     467                return status;
     468        }
     469
     470        io->out.wins_server = talloc_move(mem_ctx, &state->wins_servers[0]);
     471        io->out.rcode = state->io.out.rcode;
     472
     473        tevent_req_received(req);
     474        return NT_STATUS_OK;
    430475}
    431476
     
    437482                                struct nbt_name_register_wins *io)
    438483{
    439         struct composite_context *c = nbt_name_register_wins_send(nbtsock, io);
    440         return nbt_name_register_wins_recv(c, mem_ctx, io);
    441 }
     484        TALLOC_CTX *frame = talloc_stackframe();
     485        struct tevent_context *ev;
     486        struct tevent_req *subreq;
     487        NTSTATUS status;
     488
     489        /*
     490         * TODO: create a temporary event context
     491         */
     492        ev = nbtsock->event_ctx;
     493
     494        subreq = nbt_name_register_wins_send(frame, ev, nbtsock, io);
     495        if (subreq == NULL) {
     496                talloc_free(frame);
     497                return NT_STATUS_NO_MEMORY;
     498        }
     499
     500        if (!tevent_req_poll(subreq, ev)) {
     501                status = map_nt_error_from_unix(errno);
     502                talloc_free(frame);
     503                return status;
     504        }
     505
     506        status = nbt_name_register_wins_recv(subreq, mem_ctx, io);
     507        if (!NT_STATUS_IS_OK(status)) {
     508                talloc_free(frame);
     509                return status;
     510        }
     511
     512        TALLOC_FREE(frame);
     513        return NT_STATUS_OK;
     514}
  • vendor/current/libcli/nbt/nbt_proto.h

    r414 r740  
     1/*
     2   Unix SMB/CIFS implementation.
     3
     4   manipulate nbt name structures
     5
     6   Copyright (C) Andrew Tridgell 2005
     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_NBT_NBT_PROTO_H__
    223#define _____LIBCLI_NBT_NBT_PROTO_H__
  • vendor/current/libcli/nbt/nbtname.c

    r594 r740  
    2828#include "librpc/gen_ndr/ndr_misc.h"
    2929#include "system/locale.h"
     30#include "lib/util/util_net.h"
    3031
    3132/* don't allow an unlimited number of name components */
     
    4950{
    5051        uint8_t len;
    51         uint_t loops = 0;
     52        unsigned int loops = 0;
    5253        while (loops < 5) {
    5354                if (*offset >= ndr->data_size) {
     
    176177
    177178                /* we need to make sure the length fits into 6 bytes */
    178                 if (complen >= 0x3F) {
     179                if (complen > 0x3F) {
    179180                        return ndr_push_error(ndr, NDR_ERR_STRING,
    180                                               "component length %u[%08X] > 0x00003F",
     181                                              "component length %u[%08X] > 0x0000003F",
    181182                                              (unsigned)complen, (unsigned)complen);
    182183                }
     
    383384  push a nbt name into a blob
    384385*/
    385 _PUBLIC_ NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, DATA_BLOB *blob, struct nbt_name *name)
     386_PUBLIC_ NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct nbt_name *name)
    386387{
    387388        enum ndr_err_code ndr_err;
    388389
    389         ndr_err = ndr_push_struct_blob(blob, mem_ctx, iconv_convenience, name, (ndr_push_flags_fn_t)ndr_push_nbt_name);
     390        ndr_err = ndr_push_struct_blob(blob, mem_ctx, name, (ndr_push_flags_fn_t)ndr_push_nbt_name);
    390391        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
    391392                return ndr_map_error2ntstatus(ndr_err);
     
    402403        enum ndr_err_code ndr_err;
    403404
    404         ndr_err = ndr_pull_struct_blob(blob, mem_ctx, NULL, name,
     405        ndr_err = ndr_pull_struct_blob(blob, mem_ctx, name,
    405406                                       (ndr_pull_flags_fn_t)ndr_pull_nbt_name);
    406407        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    520521        NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, namebuf, namebuf_len));
    521522
     523        if ((namebuf_len % 4) == 0) {
     524                /*
     525                 * [MS-WINSRA] — v20091104 was wrong
     526                 * regarding section "2.2.10.1 Name Record"
     527                 *
     528                 * If the name buffer is already 4 byte aligned
     529                 * Windows (at least 2003 SP1 and 2008) add 4 extra
     530                 * bytes. This can happen when the name has a scope.
     531                 */
     532                uint32_t pad;
     533                NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &pad));
     534        }
     535
    522536        NDR_PULL_ALLOC(ndr, r);
    523537
     
    548562        if (!r->name) return ndr_pull_error(ndr, NDR_ERR_ALLOC, "out of memory");
    549563
    550         if (namebuf_len > 18) {
    551                 r->scope = talloc_strndup(r, (char *)(namebuf+17), namebuf_len-17);
     564        if (namebuf_len > 17) {
     565                r->scope = talloc_strndup(r, (char *)(namebuf+16), namebuf_len-17);
    552566                if (!r->scope) return ndr_pull_error(ndr, NDR_ERR_ALLOC, "out of memory");
    553567        } else {
     
    617631        NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, namebuf_len));
    618632        NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, namebuf, namebuf_len));
     633
     634        if ((namebuf_len % 4) == 0) {
     635                /*
     636                 * [MS-WINSRA] — v20091104 was wrong
     637                 * regarding section "2.2.10.1 Name Record"
     638                 *
     639                 * If the name buffer is already 4 byte aligned
     640                 * Windows (at least 2003 SP1 and 2008) add 4 extra
     641                 * bytes. This can happen when the name has a scope.
     642                 */
     643                NDR_CHECK(ndr_push_zero(ndr, 4));
     644        }
    619645
    620646        talloc_free(namebuf);
  • vendor/current/libcli/nbt/nbtsocket.c

    r414 r740  
    192192
    193193        /* parse the request */
    194         ndr_err = ndr_pull_struct_blob(&blob, packet, nbtsock->iconv_convenience, packet,
     194        ndr_err = ndr_pull_struct_blob(&blob, packet, packet,
    195195                                       (ndr_pull_flags_fn_t)ndr_pull_nbt_name_packet);
    196196        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    333333*/
    334334_PUBLIC_ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
    335                                              struct tevent_context *event_ctx,
    336                                              struct smb_iconv_convenience *iconv_convenience)
     335                                             struct tevent_context *event_ctx)
    337336{
    338337        struct nbt_name_socket *nbtsock;
     
    342341        if (nbtsock == NULL) goto failed;
    343342
    344         nbtsock->event_ctx = talloc_reference(nbtsock, event_ctx);
     343        nbtsock->event_ctx = event_ctx;
    345344        if (nbtsock->event_ctx == NULL) goto failed;
    346345
     
    359358        nbtsock->incoming.handler = NULL;
    360359        nbtsock->unexpected.handler = NULL;
    361         nbtsock->iconv_convenience = iconv_convenience;
    362360
    363361        nbtsock->fde = event_add_fd(nbtsock->event_ctx, nbtsock,
     
    417415
    418416        ndr_err = ndr_push_struct_blob(&req->encoded, req,
    419                                        req->nbtsock->iconv_convenience,
    420417                                       request,
    421418                                       (ndr_push_flags_fn_t)ndr_push_nbt_name_packet);
     
    466463
    467464        ndr_err = ndr_push_struct_blob(&req->encoded, req,
    468                                        req->nbtsock->iconv_convenience,
    469465                                       request,
    470466                                       (ndr_push_flags_fn_t)ndr_push_nbt_name_packet);
  • vendor/current/libcli/nbt/pynbt.c

    r414 r740  
    1818*/
    1919
     20#include <Python.h>
    2021#include "includes.h"
    21 #include <Python.h>
    2222#include "libcli/util/pyerrors.h"
    2323#include "scripting/python/modules.h"
     
    2525#include "lib/events/events.h"
    2626
     27void initnetbios(void);
     28
    2729#ifndef Py_RETURN_NONE
    2830#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
    2931#endif
    3032
    31 PyAPI_DATA(PyTypeObject) nbt_node_Type;
     33extern PyTypeObject nbt_node_Type;
    3234
    3335typedef struct {
     
    3739} nbt_node_Object;
    3840
    39 static void py_nbt_node_dealloc(PyObject *obj)
    40 {
    41         talloc_free(((nbt_node_Object *)obj)->mem_ctx);
    42         PyObject_Del(obj);
     41static void py_nbt_node_dealloc(nbt_node_Object *self)
     42{
     43        talloc_free(self->mem_ctx);
     44        self->ob_type->tp_free(self);
    4345}
    4446
     
    5355
    5456        ev = s4_event_context_init(ret->mem_ctx);
    55         ret->socket = nbt_name_socket_init(ret->mem_ctx, ev, py_iconv_convenience(ret->mem_ctx));
     57        ret->socket = nbt_name_socket_init(ret->mem_ctx, ev);
    5658        return (PyObject *)ret;
    5759}
     
    125127}
    126128
    127 static PyObject *PyObject_FromNBTName(struct nbt_name_socket *name_socket, struct smb_iconv_convenience *ic,
     129static PyObject *PyObject_FromNBTName(struct nbt_name_socket *name_socket,
    128130                                      struct nbt_name *name)
    129131{
     
    176178        PyTuple_SetItem(ret, 0, PyString_FromString(io.out.reply_from));
    177179
    178         py_name = PyObject_FromNBTName(node->socket, py_iconv_convenience(node->socket), &io.out.name);
     180        py_name = PyObject_FromNBTName(node->socket, &io.out.name);
    179181        if (py_name == NULL)
    180182                return NULL;
     
    234236        PyTuple_SetItem(ret, 0, PyString_FromString(io.out.reply_from));
    235237
    236         py_name = PyObject_FromNBTName(node->socket, py_iconv_convenience(NULL), &io.out.name);
     238        py_name = PyObject_FromNBTName(node->socket, &io.out.name);
    237239        if (py_name == NULL)
    238240                return NULL;
     
    297299        PyTuple_SetItem(ret, 0, PyString_FromString(io.out.reply_from));
    298300
    299         py_name = PyObject_FromNBTName(node->socket, py_iconv_convenience(NULL), &io.out.name);
     301        py_name = PyObject_FromNBTName(node->socket, &io.out.name);
    300302        if (py_name == NULL)
    301303                return NULL;
     
    352354        PyTuple_SetItem(ret, 0, PyString_FromString(io.out.reply_from));
    353355
    354         py_name = PyObject_FromNBTName(node->socket, py_iconv_convenience(NULL), &io.out.name);
     356        py_name = PyObject_FromNBTName(node->socket, &io.out.name);
    355357        if (py_name == NULL)
    356358                return NULL;
     
    394396        .tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
    395397        .tp_new = py_nbt_node_init,
    396         .tp_dealloc = py_nbt_node_dealloc,
     398        .tp_dealloc = (destructor)py_nbt_node_dealloc,
    397399        .tp_methods = py_nbt_methods,
    398400        .tp_doc = "Node()\n"
  • vendor/current/libcli/nbt/tools/nmblookup.c

    r414 r740  
    213213        }
    214214
    215         nbtsock = nbt_name_socket_init(tmp_ctx, ev, lp_iconv_convenience(lp_ctx));
     215        nbtsock = nbt_name_socket_init(tmp_ctx, ev);
    216216       
    217217        if (options.root_port) {
     
    358358        }
    359359
    360         load_interfaces(NULL, lp_interfaces(cmdline_lp_ctx), &ifaces);
     360        load_interfaces(NULL, lpcfg_interfaces(cmdline_lp_ctx), &ifaces);
    361361
    362362        ev = s4_event_context_init(talloc_autofree_context());
     
    365365                const char *name = poptGetArg(pc);
    366366
    367                 ret &= process_one(cmdline_lp_ctx, ev, ifaces, name, lp_nbt_port(cmdline_lp_ctx));
     367                ret &= process_one(cmdline_lp_ctx, ev, ifaces, name, lpcfg_nbt_port(cmdline_lp_ctx));
    368368        }
    369369
  • vendor/current/libcli/samsync/decrypt.c

    r414 r740  
    8080                user->user_private_info.DataLength = data.length;
    8181
    82                 ndr_err = ndr_pull_struct_blob(&data, mem_ctx, NULL, &keys,
     82                ndr_err = ndr_pull_struct_blob(&data, mem_ctx, &keys,
    8383                        (ndr_pull_flags_fn_t)ndr_pull_netr_USER_KEYS);
    8484                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
  • vendor/current/libcli/samsync/samsync.h

    r414 r740  
    2323#define __SAMSYNC_SAMSYNC_H__
    2424
     25struct netlogon_creds_CredentialState;
     26
    2527/**
    2628 * Fix up the delta, dealing with encryption issues so that the final
  • vendor/current/libcli/security/display_sec.c

    r414 r740  
    2020
    2121#include "includes.h"
    22 #include "librpc/gen_ndr/security.h"
    23 #include "libcli/security/secace.h"
    24 #include "libcli/security/dom_sid.h"
     22#include "libcli/security/security.h"
    2523#include "librpc/ndr/libndr.h"
     24#include "libcli/security/display_sec.h"
    2625
    2726/****************************************************************************
     
    160159static void disp_sec_ace_object(struct security_ace_object *object)
    161160{
     161        char *str;
    162162        if (object->flags & SEC_ACE_OBJECT_TYPE_PRESENT) {
     163                str = GUID_string(NULL, &object->type.type);
     164                if (str == NULL) return;
    163165                printf("Object type: SEC_ACE_OBJECT_TYPE_PRESENT\n");
    164                 printf("Object GUID: %s\n", GUID_string(talloc_tos(),
    165                         &object->type.type));
     166                printf("Object GUID: %s\n", str);
     167                talloc_free(str);
    166168        }
    167169        if (object->flags & SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT) {
     170                str = GUID_string(NULL, &object->inherited_type.inherited_type);
     171                if (str == NULL) return;
    168172                printf("Object type: SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT\n");
    169                 printf("Object GUID: %s\n", GUID_string(talloc_tos(),
    170                         &object->inherited_type.inherited_type));
     173                printf("Object GUID: %s\n", str);
     174                talloc_free(str);
    171175        }
    172176}
     
    231235void display_sec_acl(struct security_acl *sec_acl)
    232236{
    233         int i;
    234 
    235         printf("\tACL\tNum ACEs:\t%d\trevision:\t%x\n",
     237        uint32_t i;
     238
     239        printf("\tACL\tNum ACEs:\t%u\trevision:\t%x\n",
    236240                         sec_acl->num_aces, sec_acl->revision);
    237241        printf("\t---\n");
  • vendor/current/libcli/security/dom_sid.c

    r581 r740  
    2929*****************************************************************/
    3030
    31 static int dom_sid_compare_auth(const struct dom_sid *sid1,
    32                                 const struct dom_sid *sid2)
     31int dom_sid_compare_auth(const struct dom_sid *sid1,
     32                         const struct dom_sid *sid2)
    3333{
    3434        int i;
     
    8686}
    8787
    88 /* Yes, I did think about multibyte issues here, and for all I can see there's
    89  * none of those for parsing a SID. */
    90 #undef strncasecmp
     88/*****************************************************************
     89 Add a rid to the end of a sid
     90*****************************************************************/
     91
     92bool sid_append_rid(struct dom_sid *sid, uint32_t rid)
     93{
     94        if (sid->num_auths < ARRAY_SIZE(sid->sub_auths)) {
     95                sid->sub_auths[sid->num_auths++] = rid;
     96                return true;
     97        }
     98        return false;
     99}
     100
     101/*
     102  See if 2 SIDs are in the same domain
     103  this just compares the leading sub-auths
     104*/
     105int dom_sid_compare_domain(const struct dom_sid *sid1,
     106                           const struct dom_sid *sid2)
     107{
     108        int n, i;
     109
     110        n = MIN(sid1->num_auths, sid2->num_auths);
     111
     112        for (i = n-1; i >= 0; --i)
     113                if (sid1->sub_auths[i] != sid2->sub_auths[i])
     114                        return sid1->sub_auths[i] - sid2->sub_auths[i];
     115
     116        return dom_sid_compare_auth(sid1, sid2);
     117}
     118
     119/*****************************************************************
     120 Convert a string to a SID. Returns True on success, False on fail.
     121 Return the first character not parsed in endp.
     122*****************************************************************/
     123
     124bool dom_sid_parse_endp(const char *sidstr,struct dom_sid *sidout,
     125                        const char **endp)
     126{
     127        const char *p;
     128        char *q;
     129        /* BIG NOTE: this function only does SIDS where the identauth is not >= 2^32 */
     130        uint32_t conv;
     131
     132        ZERO_STRUCTP(sidout);
     133
     134        if ((sidstr[0] != 'S' && sidstr[0] != 's') || sidstr[1] != '-') {
     135                goto format_error;
     136        }
     137
     138        /* Get the revision number. */
     139        p = sidstr + 2;
     140
     141        if (!isdigit(*p)) {
     142                goto format_error;
     143        }
     144
     145        conv = (uint32_t) strtoul(p, &q, 10);
     146        if (!q || (*q != '-')) {
     147                goto format_error;
     148        }
     149        sidout->sid_rev_num = (uint8_t) conv;
     150        q++;
     151
     152        if (!isdigit(*q)) {
     153                goto format_error;
     154        }
     155
     156        /* get identauth */
     157        conv = (uint32_t) strtoul(q, &q, 10);
     158        if (!q) {
     159                goto format_error;
     160        }
     161
     162        /* identauth in decimal should be <  2^32 */
     163        /* NOTE - the conv value is in big-endian format. */
     164        sidout->id_auth[0] = 0;
     165        sidout->id_auth[1] = 0;
     166        sidout->id_auth[2] = (conv & 0xff000000) >> 24;
     167        sidout->id_auth[3] = (conv & 0x00ff0000) >> 16;
     168        sidout->id_auth[4] = (conv & 0x0000ff00) >> 8;
     169        sidout->id_auth[5] = (conv & 0x000000ff);
     170
     171        sidout->num_auths = 0;
     172        if (*q != '-') {
     173                /* Just id_auth, no subauths */
     174                return true;
     175        }
     176
     177        q++;
     178
     179        while (true) {
     180                char *end;
     181
     182                if (!isdigit(*q)) {
     183                        goto format_error;
     184                }
     185
     186                conv = strtoul(q, &end, 10);
     187                if (end == q) {
     188                        goto format_error;
     189                }
     190
     191                if (!sid_append_rid(sidout, conv)) {
     192                        DEBUG(3, ("Too many sid auths in %s\n", sidstr));
     193                        return false;
     194                }
     195
     196                q = end;
     197                if (*q != '-') {
     198                        break;
     199                }
     200                q += 1;
     201        }
     202        if (endp != NULL) {
     203                *endp = q;
     204        }
     205        return true;
     206
     207format_error:
     208        DEBUG(3, ("string_to_sid: SID %s is not in a valid format\n", sidstr));
     209        return false;
     210}
     211
     212bool string_to_sid(struct dom_sid *sidout, const char *sidstr)
     213{
     214        return dom_sid_parse(sidstr, sidout);
     215}
    91216
    92217bool dom_sid_parse(const char *sidstr, struct dom_sid *ret)
    93218{
    94         uint_t rev, ia, num_sub_auths, i;
    95         char *p;
    96 
    97         if (strncasecmp(sidstr, "S-", 2)) {
    98                 return false;
    99         }
    100 
    101         sidstr += 2;
    102 
    103         rev = strtol(sidstr, &p, 10);
    104         if (*p != '-') {
    105                 return false;
    106         }
    107         sidstr = p+1;
    108 
    109         ia = strtol(sidstr, &p, 10);
    110         if (p == sidstr) {
    111                 return false;
    112         }
    113         sidstr = p;
    114 
    115         num_sub_auths = 0;
    116         for (i=0;sidstr[i];i++) {
    117                 if (sidstr[i] == '-') num_sub_auths++;
    118         }
    119 
    120         if (num_sub_auths > MAXSUBAUTHS) {
    121                 return false;
    122         }
    123 
    124         ret->sid_rev_num = rev;
    125         ret->id_auth[0] = 0;
    126         ret->id_auth[1] = 0;
    127         ret->id_auth[2] = ia >> 24;
    128         ret->id_auth[3] = ia >> 16;
    129         ret->id_auth[4] = ia >> 8;
    130         ret->id_auth[5] = ia;
    131         ret->num_auths = num_sub_auths;
    132 
    133         for (i=0;i<num_sub_auths;i++) {
    134                 if (sidstr[0] != '-') {
    135                         return false;
    136                 }
    137                 sidstr++;
    138                 ret->sub_auths[i] = strtoul(sidstr, &p, 10);
    139                 if (p == sidstr) {
    140                         return false;
    141                 }
    142                 sidstr = p;
    143         }
    144 
    145         return true;
     219        return dom_sid_parse_endp(sidstr, ret, NULL);
    146220}
    147221
     
    222296        struct dom_sid *sid;
    223297
    224         sid = talloc(mem_ctx, struct dom_sid);
     298        sid = dom_sid_dup(mem_ctx, domain_sid);
    225299        if (!sid) return NULL;
    226300
    227         *sid = *domain_sid;
    228 
    229         sid->sub_auths[sid->num_auths] = rid;
    230         sid->num_auths++;
     301        if (!sid_append_rid(sid, rid)) {
     302                talloc_free(sid);
     303                return NULL;
     304        }
    231305
    232306        return sid;
     
    284358
    285359/*
    286   convert a dom_sid to a string
    287 */
    288 char *dom_sid_string(TALLOC_CTX *mem_ctx, const struct dom_sid *sid)
    289 {
    290         int i, ofs, maxlen;
     360  Convert a dom_sid to a string, printing into a buffer. Return the
     361  string length. If it overflows, return the string length that would
     362  result (buflen needs to be +1 for the terminating 0).
     363*/
     364int dom_sid_string_buf(const struct dom_sid *sid, char *buf, int buflen)
     365{
     366        int i, ofs;
    291367        uint32_t ia;
    292         char *ret;
    293368
    294369        if (!sid) {
    295                 return talloc_strdup(mem_ctx, "(NULL SID)");
    296         }
    297 
    298         maxlen = sid->num_auths * 11 + 25;
    299         ret = talloc_array(mem_ctx, char, maxlen);
    300         if (!ret) return talloc_strdup(mem_ctx, "(SID ERR)");
     370                strlcpy(buf, "(NULL SID)", buflen);
     371                return 10;      /* strlen("(NULL SID)") */
     372        }
    301373
    302374        ia = (sid->id_auth[5]) +
     
    305377                (sid->id_auth[2] << 24);
    306378
    307         ofs = snprintf(ret, maxlen, "S-%u-%lu",
     379        ofs = snprintf(buf, buflen, "S-%u-%lu",
    308380                       (unsigned int)sid->sid_rev_num, (unsigned long)ia);
    309381
    310382        for (i = 0; i < sid->num_auths; i++) {
    311                 ofs += snprintf(ret + ofs, maxlen - ofs, "-%lu",
     383                ofs += snprintf(buf + ofs, MAX(buflen - ofs, 0), "-%lu",
    312384                                (unsigned long)sid->sub_auths[i]);
    313385        }
    314 
    315         return ret;
    316 }
     386        return ofs;
     387}
     388
     389/*
     390  convert a dom_sid to a string
     391*/
     392char *dom_sid_string(TALLOC_CTX *mem_ctx, const struct dom_sid *sid)
     393{
     394        char buf[DOM_SID_STR_BUFLEN];
     395        char *result;
     396        int len;
     397
     398        len = dom_sid_string_buf(sid, buf, sizeof(buf));
     399
     400        if (len+1 > sizeof(buf)) {
     401                return talloc_strdup(mem_ctx, "(SID ERR)");
     402        }
     403
     404        /*
     405         * Avoid calling strlen (via talloc_strdup), we already have
     406         * the length
     407         */
     408        result = (char *)talloc_memdup(mem_ctx, buf, len+1);
     409
     410        /*
     411         * beautify the talloc_report output
     412         */
     413        talloc_set_name_const(result, result);
     414        return result;
     415}
  • vendor/current/libcli/security/dom_sid.h

    r581 r740  
    2626#include "librpc/gen_ndr/security.h"
    2727
     28/* Some well-known SIDs */
     29extern const struct dom_sid global_sid_World_Domain;
     30extern const struct dom_sid global_sid_World;
     31extern const struct dom_sid global_sid_Creator_Owner_Domain;
     32extern const struct dom_sid global_sid_NT_Authority;
     33extern const struct dom_sid global_sid_Enterprise_DCs;
     34extern const struct dom_sid global_sid_System;
     35extern const struct dom_sid global_sid_NULL;
     36extern const struct dom_sid global_sid_Authenticated_Users;
     37extern const struct dom_sid global_sid_Network;
     38extern const struct dom_sid global_sid_Creator_Owner;
     39extern const struct dom_sid global_sid_Creator_Group;
     40extern const struct dom_sid global_sid_Anonymous;
     41extern const struct dom_sid global_sid_Builtin;
     42extern const struct dom_sid global_sid_Builtin_Administrators;
     43extern const struct dom_sid global_sid_Builtin_Users;
     44extern const struct dom_sid global_sid_Builtin_Guests;
     45extern const struct dom_sid global_sid_Builtin_Power_Users;
     46extern const struct dom_sid global_sid_Builtin_Account_Operators;
     47extern const struct dom_sid global_sid_Builtin_Server_Operators;
     48extern const struct dom_sid global_sid_Builtin_Print_Operators;
     49extern const struct dom_sid global_sid_Builtin_Backup_Operators;
     50extern const struct dom_sid global_sid_Builtin_Replicator;
     51extern const struct dom_sid global_sid_Builtin_PreWin2kAccess;
     52extern const struct dom_sid global_sid_Unix_Users;
     53extern const struct dom_sid global_sid_Unix_Groups;
     54
     55int dom_sid_compare_auth(const struct dom_sid *sid1,
     56                         const struct dom_sid *sid2);
    2857int dom_sid_compare(const struct dom_sid *sid1, const struct dom_sid *sid2);
     58int dom_sid_compare_domain(const struct dom_sid *sid1,
     59                           const struct dom_sid *sid2);
    2960bool dom_sid_equal(const struct dom_sid *sid1, const struct dom_sid *sid2);
     61bool sid_append_rid(struct dom_sid *sid, uint32_t rid);
     62bool string_to_sid(struct dom_sid *sidout, const char *sidstr);
     63bool dom_sid_parse_endp(const char *sidstr,struct dom_sid *sidout,
     64                        const char **endp);
    3065bool dom_sid_parse(const char *sidstr, struct dom_sid *ret);
    3166struct dom_sid *dom_sid_parse_talloc(TALLOC_CTX *mem_ctx, const char *sidstr);
     
    3974bool dom_sid_in_domain(const struct dom_sid *domain_sid,
    4075                       const struct dom_sid *sid);
     76
     77#define DOM_SID_STR_BUFLEN (15*11+25)
     78int dom_sid_string_buf(const struct dom_sid *sid, char *buf, int buflen);
    4179char *dom_sid_string(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
    4280
    43 #ifndef MAXSUBAUTHS
    44 #define MAXSUBAUTHS 15 /* max sub authorities in a SID */
    45 #endif
     81
     82const char *sid_type_lookup(uint32_t sid_type);
     83const struct security_token *get_system_token(void);
     84bool sid_compose(struct dom_sid *dst, const struct dom_sid *domain_sid, uint32_t rid);
     85bool sid_split_rid(struct dom_sid *sid, uint32_t *rid);
     86bool sid_peek_rid(const struct dom_sid *sid, uint32_t *rid);
     87bool sid_peek_check_rid(const struct dom_sid *exp_dom_sid, const struct dom_sid *sid, uint32_t *rid);
     88void sid_copy(struct dom_sid *dst, const struct dom_sid *src);
     89bool sid_blob_parse(DATA_BLOB in, struct dom_sid *sid);
     90bool sid_parse(const char *inbuf, size_t len, struct dom_sid *sid);
     91int sid_compare_domain(const struct dom_sid *sid1, const struct dom_sid *sid2);
     92bool sid_equal(const struct dom_sid *sid1, const struct dom_sid *sid2);
     93NTSTATUS add_sid_to_array(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
     94                          struct dom_sid **sids, uint32_t *num);
     95NTSTATUS add_sid_to_array_unique(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
     96                                 struct dom_sid **sids, uint32_t *num_sids);
     97void del_sid_from_array(const struct dom_sid *sid, struct dom_sid **sids,
     98                        uint32_t *num);
     99bool add_rid_to_array_unique(TALLOC_CTX *mem_ctx,
     100                             uint32_t rid, uint32_t **pp_rids, size_t *p_num);
     101bool is_null_sid(const struct dom_sid *sid);
    46102
    47103#endif /*_DOM_SID_H_*/
  • vendor/current/libcli/security/secace.c

    r414 r740  
    2323#include "includes.h"
    2424#include "librpc/gen_ndr/ndr_security.h"
    25 #include "libcli/security/dom_sid.h"
     25#include "libcli/security/security.h"
     26#include "lib/util/tsort.h"
    2627
    2728#define  SEC_ACE_HEADER_SIZE (2 * sizeof(uint8_t) + sizeof(uint16_t) + sizeof(uint32_t))
     
    4445 * copy a struct security_ace structure.
    4546 */
    46 void sec_ace_copy(struct security_ace *ace_dest, struct security_ace *ace_src)
     47void sec_ace_copy(struct security_ace *ace_dest, const struct security_ace *ace_src)
    4748{
    4849        ace_dest->type  = ace_src->type;
     
    6364        t->type = type;
    6465        t->flags = flag;
    65         t->size = ndr_size_dom_sid(sid, NULL, 0) + 8;
     66        t->size = ndr_size_dom_sid(sid, 0) + 8;
    6667        t->access_mask = mask;
    6768
     
    7374********************************************************************/
    7475
    75 NTSTATUS sec_ace_add_sid(TALLOC_CTX *ctx, struct security_ace **pp_new, struct security_ace *old, unsigned *num, struct dom_sid *sid, uint32_t mask)
     76NTSTATUS sec_ace_add_sid(TALLOC_CTX *ctx, struct security_ace **pp_new, struct security_ace *old, unsigned *num, const struct dom_sid *sid, uint32_t mask)
    7677{
    7778        unsigned int i = 0;
     
    8990        (*pp_new)[i].type  = SEC_ACE_TYPE_ACCESS_ALLOWED;
    9091        (*pp_new)[i].flags = 0;
    91         (*pp_new)[i].size  = SEC_ACE_HEADER_SIZE + ndr_size_dom_sid(sid, NULL, 0);
     92        (*pp_new)[i].size  = SEC_ACE_HEADER_SIZE + ndr_size_dom_sid(sid, 0);
    9293        (*pp_new)[i].access_mask = mask;
    9394        (*pp_new)[i].trustee = *sid;
     
    99100********************************************************************/
    100101
    101 NTSTATUS sec_ace_mod_sid(struct security_ace *ace, size_t num, struct dom_sid *sid, uint32_t mask)
     102NTSTATUS sec_ace_mod_sid(struct security_ace *ace, size_t num, const struct dom_sid *sid, uint32_t mask)
    102103{
    103104        unsigned int i = 0;
     
    118119********************************************************************/
    119120
    120 NTSTATUS sec_ace_del_sid(TALLOC_CTX *ctx, struct security_ace **pp_new, struct security_ace *old, uint32_t *num, struct dom_sid *sid)
     121NTSTATUS sec_ace_del_sid(TALLOC_CTX *ctx, struct security_ace **pp_new, struct security_ace *old, uint32_t *num, const struct dom_sid *sid)
    121122{
    122123        unsigned int i     = 0;
     
    150151********************************************************************/
    151152
    152 bool sec_ace_equal(struct security_ace *s1, struct security_ace *s2)
     153bool sec_ace_equal(const struct security_ace *s1, const struct security_ace *s2)
    153154{
    154155        /* Trivial case */
     
    178179}
    179180
    180 int nt_ace_inherit_comp( struct security_ace *a1, struct security_ace *a2)
     181int nt_ace_inherit_comp(const struct security_ace *a1, const struct security_ace *a2)
    181182{
    182183        int a1_inh = a1->flags & SEC_ACE_FLAG_INHERITED_ACE;
     
    195196*******************************************************************/
    196197
    197 int nt_ace_canon_comp( struct security_ace *a1, struct security_ace *a2)
     198int nt_ace_canon_comp( const struct security_ace *a1,  const struct security_ace *a2)
    198199{
    199200        if ((a1->type == SEC_ACE_TYPE_ACCESS_DENIED) &&
     
    258259
    259260        /* Sort so that non-inherited ACE's come first. */
    260         qsort( srclist, num_aces, sizeof(srclist[0]), QSORT_CAST nt_ace_inherit_comp);
     261        TYPESAFE_QSORT(srclist, num_aces, nt_ace_inherit_comp);
    261262
    262263        /* Find the boundary between non-inherited ACEs. */
     
    271272
    272273        /* Sort the non-inherited ACEs. */
    273         if (i)
    274                 qsort( srclist, i, sizeof(srclist[0]), QSORT_CAST nt_ace_canon_comp);
     274        TYPESAFE_QSORT(srclist, i, nt_ace_canon_comp);
    275275
    276276        /* Now sort the inherited ACEs. */
    277         if (num_aces - i)
    278                 qsort( &srclist[i], num_aces - i, sizeof(srclist[0]), QSORT_CAST nt_ace_canon_comp);
    279 }
    280 
    281 
     277        TYPESAFE_QSORT(&srclist[i], num_aces - i, nt_ace_canon_comp);
     278}
     279
     280
  • vendor/current/libcli/security/secace.h

    r414 r740  
    2525
    2626bool sec_ace_object(uint8_t type);
    27 void sec_ace_copy(struct security_ace *ace_dest, struct security_ace *ace_src);
     27void sec_ace_copy(struct security_ace *ace_dest, const struct security_ace *ace_src);
    2828void init_sec_ace(struct security_ace *t, const struct dom_sid *sid, enum security_ace_type type,
    2929                  uint32_t mask, uint8_t flag);
    30 NTSTATUS sec_ace_add_sid(TALLOC_CTX *ctx, struct security_ace **pp_new, struct security_ace *old, unsigned *num, struct dom_sid *sid, uint32_t mask);
    31 NTSTATUS sec_ace_mod_sid(struct security_ace *ace, size_t num, struct dom_sid *sid, uint32_t mask);
    32 NTSTATUS sec_ace_del_sid(TALLOC_CTX *ctx, struct security_ace **pp_new, struct security_ace *old, uint32_t *num, struct dom_sid *sid);
    33 bool sec_ace_equal(struct security_ace *s1, struct security_ace *s2);
    34 int nt_ace_inherit_comp( struct security_ace *a1, struct security_ace *a2);
    35 int nt_ace_canon_comp( struct security_ace *a1, struct security_ace *a2);
     30NTSTATUS sec_ace_add_sid(TALLOC_CTX *ctx, struct security_ace **pp_new, struct security_ace *old, unsigned *num, const struct dom_sid *sid, uint32_t mask);
     31NTSTATUS sec_ace_mod_sid(struct security_ace *ace, size_t num, const struct dom_sid *sid, uint32_t mask);
     32NTSTATUS sec_ace_del_sid(TALLOC_CTX *ctx, struct security_ace **pp_new, struct security_ace *old, uint32_t *num, const struct dom_sid *sid);
     33bool sec_ace_equal(const struct security_ace *s1, const struct security_ace *s2);
     34int nt_ace_inherit_comp( const struct security_ace *a1, const struct security_ace *a2);
     35int nt_ace_canon_comp( const struct security_ace *a1, const struct security_ace *a2);
    3636void dacl_sort_into_canonical_order(struct security_ace *srclist, unsigned int num_aces);
    3737
  • vendor/current/libcli/security/secacl.c

    r414 r740  
    2424#include "librpc/gen_ndr/ndr_security.h"
    2525#include "libcli/security/secace.h"
     26#include "libcli/security/secacl.h"
    2627
    2728#define  SEC_ACL_HEADER_SIZE (2 * sizeof(uint16_t) + sizeof(uint32_t))
     
    7677        return make_sec_acl(ctx, src->revision, src->num_aces, src->aces);
    7778}
    78 
    79 /*******************************************************************
    80  Compares two SEC_ACL structures
    81 ********************************************************************/
    82 
    83 bool sec_acl_equal(struct security_acl *s1, struct security_acl *s2)
    84 {
    85         unsigned int i, j;
    86 
    87         /* Trivial cases */
    88 
    89         if (!s1 && !s2) return true;
    90         if (!s1 || !s2) return false;
    91 
    92         /* Check top level stuff */
    93 
    94         if (s1->revision != s2->revision) {
    95                 DEBUG(10, ("sec_acl_equal(): revision differs (%d != %d)\n",
    96                            s1->revision, s2->revision));
    97                 return false;
    98         }
    99 
    100         if (s1->num_aces != s2->num_aces) {
    101                 DEBUG(10, ("sec_acl_equal(): num_aces differs (%d != %d)\n",
    102                            s1->revision, s2->revision));
    103                 return false;
    104         }
    105 
    106         /* The ACEs could be in any order so check each ACE in s1 against
    107            each ACE in s2. */
    108 
    109         for (i = 0; i < s1->num_aces; i++) {
    110                 bool found = false;
    111 
    112                 for (j = 0; j < s2->num_aces; j++) {
    113                         if (sec_ace_equal(&s1->aces[i], &s2->aces[j])) {
    114                                 found = true;
    115                                 break;
    116                         }
    117                 }
    118 
    119                 if (!found) return false;
    120         }
    121 
    122         return true;
    123 }
  • vendor/current/libcli/security/secacl.h

    r414 r740  
    2727                      int num_aces, struct security_ace *ace_list);
    2828struct security_acl *dup_sec_acl(TALLOC_CTX *ctx, struct security_acl *src);
    29 bool sec_acl_equal(struct security_acl *s1, struct security_acl *s2);
    3029
    3130
  • vendor/current/libcli/security/security_descriptor.c

    r414 r740  
    2121
    2222#include "includes.h"
    23 #include "libcli/security/security_descriptor.h"
    24 #include "libcli/security/dom_sid.h"
     23#include "libcli/security/security.h"
    2524
    2625/*
     
    5655        struct security_acl *nacl;
    5756
     57        if (oacl == NULL) {
     58                return NULL;
     59        }
     60
    5861        nacl = talloc (mem_ctx, struct security_acl);
    5962        if (nacl == NULL) {
     
    8386{
    8487        struct security_acl *nacl;
    85         int i;
     88        uint32_t i;
    8689
    8790        if (!acl1 && !acl2)
     
    268271                                            const struct dom_sid *trustee)
    269272{
    270         int i;
     273        uint32_t i;
    271274        bool found = false;
    272275        struct security_acl *acl = NULL;
     
    362365                        const struct security_acl *acl2)
    363366{
    364         int i;
     367        uint32_t i;
    365368
    366369        if (acl1 == acl2) return true;
  • vendor/current/libcli/security/security_descriptor.h

    r414 r740  
    6969                                              const struct security_acl *acl2);
    7070
     71uint32_t map_generic_rights_ds(uint32_t access_mask);
     72
     73struct security_descriptor *create_security_descriptor(TALLOC_CTX *mem_ctx,
     74                                                       struct security_descriptor *parent_sd,
     75                                                       struct security_descriptor *creator_sd,
     76                                                       bool is_container,
     77                                                       struct GUID *object_list,
     78                                                       uint32_t inherit_flags,
     79                                                       struct security_token *token,
     80                                                       struct dom_sid *default_owner, /* valid only for DS, NULL for the other RSs */
     81                                                       struct dom_sid *default_group, /* valid only for DS, NULL for the other RSs */
     82                                                       uint32_t (*generic_map)(uint32_t access_mask));
     83
    7184#endif /* __SECURITY_DESCRIPTOR_H__ */
  • vendor/current/libcli/smb/smb2_constants.h

    r414 r740  
    2929#define SMB2_HDR_STATUS         0x08
    3030#define SMB2_HDR_OPCODE         0x0c
    31 #define SMB2_HDR_CREDIT         0x0e
     31#define SMB2_HDR_CREDIT         0x0e
    3232#define SMB2_HDR_FLAGS          0x10
    3333#define SMB2_HDR_NEXT_COMMAND   0x14
     
    3838#define SMB2_HDR_SIGNATURE      0x30 /* 16 bytes */
    3939#define SMB2_HDR_BODY           0x40
     40
     41/* offsets into header elements for an async SMB2 request */
     42#define SMB2_HDR_ASYNC_ID       0x20
    4043
    4144/* header flags */
     
    8285#define SMB2_CAP_DFS                     0x00000001
    8386#define SMB2_CAP_LEASING                 0x00000002 /* only in dialect 0x210 */
     87#define SMB2_CAP_LARGE_MTU               0x00000004 /* only in dialect 0x210 */
    8488/* so we can spot new caps as added */
    8589#define SMB2_CAP_ALL                     SMB2_CAP_DFS
     
    8892#define SMB2_SESSION_FLAG_IS_GUEST       0x0001
    8993#define SMB2_SESSION_FLAG_IS_NULL        0x0002
     94
     95/* SMB2 sharetype flags */
     96#define SMB2_SHARE_TYPE_DISK            0x1
     97#define SMB2_SHARE_TYPE_PIPE            0x2
     98#define SMB2_SHARE_TYPE_PRINT           0x3
    9099
    91100/* SMB2 share flags */
     
    101110#define SMB2_SHAREFLAG_ACCESS_BASED_DIRECTORY_ENUM       0x0800
    102111#define SMB2_SHAREFLAG_ALL                               0x0F33
     112
     113/* SMB2 share capafilities */
     114#define SMB2_SHARE_CAP_DFS              0x8
    103115
    104116/* SMB2 create security flags */
     
    173185#define SMB2_GETINFO_QUOTA              0x04
    174186
     187#define SMB2_CLOSE_FLAGS_FULL_INFORMATION (0x01)
     188
    175189#endif
  • vendor/current/libcli/util/doserr.c

    r414 r740  
    127127        { "WERR_DS_PROTOCOL_ERROR", WERR_DS_PROTOCOL_ERROR },
    128128        { "WERR_DS_TIMELIMIT_EXCEEEDED", WERR_DS_TIMELIMIT_EXCEEDED },
    129         { "WERR_DS_SIZE_LIMIT_EXCEEDED", WERR_DS_SIZE_LIMIT_EXCEEDED },
    130129        { "WERR_DS_ADMIN_LIMIT_EXCEEEDED", WERR_DS_ADMIN_LIMIT_EXCEEDED },
    131130        { "WERR_DS_COMPARE_FALSE", WERR_DS_COMPARE_FALSE },
     
    166165        { "WERR_DS_DRA_SOURCE_DISABLED", WERR_DS_DRA_SOURCE_DISABLED },
    167166        { "WERR_DS_DNS_LOOKUP_FAILURE", WERR_DS_DNS_LOOKUP_FAILURE },
    168         { "WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX", WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX },
    169167        { "WERR_DS_NO_MSDS_INTID", WERR_DS_NO_MSDS_INTID },
    170168        { "WERR_DS_DUP_MSDS_INTID", WERR_DS_DUP_MSDS_INTID },
     169        { "WERR_DNS_ERROR_RCODE_FORMAT_ERROR", WERR_DNS_ERROR_RCODE_FORMAT_ERROR },
     170        { "WERR_DNS_ERROR_RCODE_SERVER_FAILURE", WERR_DNS_ERROR_RCODE_SERVER_FAILURE },
     171        { "WERR_DNS_ERROR_RCODE_NAME_ERROR", WERR_DNS_ERROR_RCODE_NAME_ERROR },
     172        { "WERR_DNS_ERROR_RCODE_NOT_IMPLEMENTED", WERR_DNS_ERROR_RCODE_NOT_IMPLEMENTED },
     173        { "WERR_DNS_ERROR_RCODE_REFUSED", WERR_DNS_ERROR_RCODE_REFUSED },
     174        { "WERR_DNS_ERROR_RCODE_YXDOMAIN", WERR_DNS_ERROR_RCODE_YXDOMAIN },
     175        { "WERR_DNS_ERROR_RCODE_YXRRSET", WERR_DNS_ERROR_RCODE_YXRRSET },
     176        { "WERR_DNS_ERROR_RCODE_NXRRSET", WERR_DNS_ERROR_RCODE_NXRRSET },
     177        { "WERR_DNS_ERROR_RCODE_NOTAUTH", WERR_DNS_ERROR_RCODE_NOTAUTH },
     178        { "WERR_DNS_ERROR_RCODE_NOTZONE", WERR_DNS_ERROR_RCODE_NOTZONE },
     179        { "WERR_DNS_ERROR_RCODE_BADSIG", WERR_DNS_ERROR_RCODE_BADSIG },
     180        { "WERR_DNS_ERROR_RCODE_BADKEY", WERR_DNS_ERROR_RCODE_BADKEY },
     181        { "WERR_DNS_ERROR_RCODE_BADTIME", WERR_DNS_ERROR_RCODE_BADTIME },
     182        { "WERR_DNS_INFO_NO_RECORDS", WERR_DNS_INFO_NO_RECORDS },
     183        { "WERR_DNS_ERROR_BAD_PACKET", WERR_DNS_ERROR_BAD_PACKET },
     184        { "WERR_DNS_ERROR_NO_PACKET", WERR_DNS_ERROR_NO_PACKET },
     185        { "WERR_DNS_ERROR_RCODE", WERR_DNS_ERROR_RCODE },
     186        { "WERR_DNS_ERROR_UNSECURE_PACKET", WERR_DNS_ERROR_UNSECURE_PACKET },
     187        { "WERR_DNS_ERROR_INVALID_TYPE", WERR_DNS_ERROR_INVALID_TYPE },
     188        { "WERR_DNS_ERROR_INVALID_IP_ADDRESS", WERR_DNS_ERROR_INVALID_IP_ADDRESS },
     189        { "WERR_DNS_ERROR_INVALID_PROPERTY", WERR_DNS_ERROR_INVALID_PROPERTY },
     190        { "WERR_DNS_ERROR_TRY_AGAIN_LATER", WERR_DNS_ERROR_TRY_AGAIN_LATER },
     191        { "WERR_DNS_ERROR_NOT_UNIQUE", WERR_DNS_ERROR_NOT_UNIQUE },
     192        { "WERR_DNS_ERROR_NON_RFC_NAME", WERR_DNS_ERROR_NON_RFC_NAME },
     193        { "WERR_DNS_STATUS_FQDN", WERR_DNS_STATUS_FQDN },
     194        { "WERR_DNS_STATUS_DOTTED_NAME", WERR_DNS_STATUS_DOTTED_NAME },
     195        { "WERR_DNS_STATUS_SINGLE_PART_NAME", WERR_DNS_STATUS_SINGLE_PART_NAME },
     196        { "WERR_DNS_ERROR_INVALID_NAME_CHAR", WERR_DNS_ERROR_INVALID_NAME_CHAR },
     197        { "WERR_DNS_ERROR_NUMERIC_NAME", WERR_DNS_ERROR_NUMERIC_NAME },
     198        { "WERR_DNS_ERROR_NOT_ALLOWED_ON_ROOT_SERVER", WERR_DNS_ERROR_NOT_ALLOWED_ON_ROOT_SERVER },
     199        { "WERR_DNS_ERROR_NOT_ALLOWED_UNDER_DELEGATION", WERR_DNS_ERROR_NOT_ALLOWED_UNDER_DELEGATION },
     200        { "WERR_DNS_ERROR_CANNOT_FIND_ROOT_HINTS", WERR_DNS_ERROR_CANNOT_FIND_ROOT_HINTS },
     201        { "WERR_DNS_ERROR_INCONSISTENT_ROOT_HINTS", WERR_DNS_ERROR_INCONSISTENT_ROOT_HINTS },
     202        { "WERR_DNS_ERROR_DWORD_VALUE_TOO_SMALL", WERR_DNS_ERROR_DWORD_VALUE_TOO_SMALL },
     203        { "WERR_DNS_ERROR_DWORD_VALUE_TOO_LARGE", WERR_DNS_ERROR_DWORD_VALUE_TOO_LARGE },
     204        { "WERR_DNS_ERROR_BACKGROUND_LOADING", WERR_DNS_ERROR_BACKGROUND_LOADING },
     205        { "WERR_DNS_ERROR_NOT_ALLOWED_ON_RODC", WERR_DNS_ERROR_NOT_ALLOWED_ON_RODC },
     206        { "WERR_DNS_ERROR_ZONE_DOES_NOT_EXIST", WERR_DNS_ERROR_ZONE_DOES_NOT_EXIST },
     207        { "WERR_DNS_ERROR_NO_ZONE_INFO", WERR_DNS_ERROR_NO_ZONE_INFO },
     208        { "WERR_DNS_ERROR_INVALID_ZONE_OPERATION", WERR_DNS_ERROR_INVALID_ZONE_OPERATION },
     209        { "WERR_DNS_ERROR_ZONE_CONFIGURATION_ERROR", WERR_DNS_ERROR_ZONE_CONFIGURATION_ERROR },
     210        { "WERR_DNS_ERROR_ZONE_HAS_NO_SOA_RECORD", WERR_DNS_ERROR_ZONE_HAS_NO_SOA_RECORD },
     211        { "WERR_DNS_ERROR_ZONE_HAS_NO_NS_RECORDS", WERR_DNS_ERROR_ZONE_HAS_NO_NS_RECORDS },
     212        { "WERR_DNS_ERROR_ZONE_LOCKED", WERR_DNS_ERROR_ZONE_LOCKED },
     213        { "WERR_DNS_ERROR_ZONE_CREATION_FAILED", WERR_DNS_ERROR_ZONE_CREATION_FAILED },
     214        { "WERR_DNS_ERROR_ZONE_ALREADY_EXISTS", WERR_DNS_ERROR_ZONE_ALREADY_EXISTS },
     215        { "WERR_DNS_ERROR_AUTOZONE_ALREADY_EXISTS", WERR_DNS_ERROR_AUTOZONE_ALREADY_EXISTS },
     216        { "WERR_DNS_ERROR_INVALID_ZONE_TYPE", WERR_DNS_ERROR_INVALID_ZONE_TYPE },
     217        { "WERR_DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP", WERR_DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP },
     218        { "WERR_DNS_ERROR_ZONE_NOT_SECONDARY", WERR_DNS_ERROR_ZONE_NOT_SECONDARY },
     219        { "WERR_DNS_ERROR_NEED_SECONDARY_ADDRESSES", WERR_DNS_ERROR_NEED_SECONDARY_ADDRESSES },
     220        { "WERR_DNS_ERROR_WINS_INIT_FAILED", WERR_DNS_ERROR_WINS_INIT_FAILED },
     221        { "WERR_DNS_ERROR_NEED_WINS_SERVERS", WERR_DNS_ERROR_NEED_WINS_SERVERS },
     222        { "WERR_DNS_ERROR_NBSTAT_INIT_FAILED", WERR_DNS_ERROR_NBSTAT_INIT_FAILED },
     223        { "WERR_DNS_ERROR_SOA_DELETE_INVALID", WERR_DNS_ERROR_SOA_DELETE_INVALID },
     224        { "WERR_DNS_ERROR_FORWARDER_ALREADY_EXISTS", WERR_DNS_ERROR_FORWARDER_ALREADY_EXISTS },
     225        { "WERR_DNS_ERROR_ZONE_REQUIRES_MASTER_IP", WERR_DNS_ERROR_ZONE_REQUIRES_MASTER_IP },
     226        { "WERR_DNS_ERROR_ZONE_IS_SHUTDOWN", WERR_DNS_ERROR_ZONE_IS_SHUTDOWN },
     227        { "WERR_DNS_ERROR_PRIMARY_REQUIRES_DATAFILE", WERR_DNS_ERROR_PRIMARY_REQUIRES_DATAFILE },
     228        { "WERR_DNS_ERROR_INVALID_DATAFILE_NAME", WERR_DNS_ERROR_INVALID_DATAFILE_NAME },
     229        { "WERR_DNS_ERROR_DATAFILE_OPEN_FAILURE", WERR_DNS_ERROR_DATAFILE_OPEN_FAILURE },
     230        { "WERR_DNS_ERROR_FILE_WRITEBACK_FAILED", WERR_DNS_ERROR_FILE_WRITEBACK_FAILED },
     231        { "WERR_DNS_ERROR_DATAFILE_PARSING", WERR_DNS_ERROR_DATAFILE_PARSING },
     232        { "WERR_DNS_ERROR_RECORD_DOES_NOT_EXIST", WERR_DNS_ERROR_RECORD_DOES_NOT_EXIST },
     233        { "WERR_DNS_ERROR_RECORD_FORMAT", WERR_DNS_ERROR_RECORD_FORMAT },
     234        { "WERR_DNS_ERROR_NODE_CREATION_FAILED", WERR_DNS_ERROR_NODE_CREATION_FAILED },
     235        { "WERR_DNS_ERROR_UNKNOWN_RECORD_TYPE", WERR_DNS_ERROR_UNKNOWN_RECORD_TYPE },
     236        { "WERR_DNS_ERROR_RECORD_TIMED_OUT", WERR_DNS_ERROR_RECORD_TIMED_OUT },
     237        { "WERR_DNS_ERROR_NAME_NOT_IN_ZONE", WERR_DNS_ERROR_NAME_NOT_IN_ZONE },
     238        { "WERR_DNS_ERROR_CNAME_LOOP", WERR_DNS_ERROR_CNAME_LOOP },
     239        { "WERR_DNS_ERROR_NODE_IS_CNAME", WERR_DNS_ERROR_NODE_IS_CNAME },
     240        { "WERR_DNS_ERROR_CNAME_COLLISION", WERR_DNS_ERROR_CNAME_COLLISION },
     241        { "WERR_DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT", WERR_DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT },
     242        { "WERR_DNS_ERROR_RECORD_ALREADY_EXISTS", WERR_DNS_ERROR_RECORD_ALREADY_EXISTS },
     243        { "WERR_DNS_ERROR_SECONDARY_DATA", WERR_DNS_ERROR_SECONDARY_DATA },
     244        { "WERR_DNS_ERROR_NO_CREATE_CACHE_DATA", WERR_DNS_ERROR_NO_CREATE_CACHE_DATA },
     245        { "WERR_DNS_ERROR_NAME_DOES_NOT_EXIST", WERR_DNS_ERROR_NAME_DOES_NOT_EXIST },
     246        { "WERR_DNS_WARNING_PTR_CREATE_FAILED", WERR_DNS_WARNING_PTR_CREATE_FAILED },
     247        { "WERR_DNS_WARNING_DOMAIN_UNDELETED", WERR_DNS_WARNING_DOMAIN_UNDELETED },
     248        { "WERR_DNS_ERROR_DS_UNAVAILABLE", WERR_DNS_ERROR_DS_UNAVAILABLE },
     249        { "WERR_DNS_ERROR_DS_ZONE_ALREADY_EXISTS", WERR_DNS_ERROR_DS_ZONE_ALREADY_EXISTS },
     250        { "WERR_DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE", WERR_DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE },
     251        { "WERR_DNS_INFO_AXFR_COMPLETE", WERR_DNS_INFO_AXFR_COMPLETE },
     252        { "WERR_DNS_ERROR_AXFR", WERR_DNS_ERROR_AXFR },
     253        { "WERR_DNS_INFO_ADDED_LOCAL_WINS", WERR_DNS_INFO_ADDED_LOCAL_WINS },
     254        { "WERR_DNS_STATUS_CONTINUE_NEEDED", WERR_DNS_STATUS_CONTINUE_NEEDED },
     255        { "WERR_DNS_ERROR_NO_TCPIP", WERR_DNS_ERROR_NO_TCPIP },
     256        { "WERR_DNS_ERROR_NO_DNS_SERVERS", WERR_DNS_ERROR_NO_DNS_SERVERS },
     257        { "WERR_DNS_ERROR_DP_DOES_NOT_EXIST", WERR_DNS_ERROR_DP_DOES_NOT_EXIST },
     258        { "WERR_DNS_ERROR_DP_ALREADY_EXISTS", WERR_DNS_ERROR_DP_ALREADY_EXISTS },
     259        { "WERR_DNS_ERROR_DP_NOT_ENLISTED", WERR_DNS_ERROR_DP_NOT_ENLISTED },
     260        { "WERR_DNS_ERROR_DP_ALREADY_ENLISTED", WERR_DNS_ERROR_DP_ALREADY_ENLISTED },
     261        { "WERR_DNS_ERROR_DP_NOT_AVAILABLE", WERR_DNS_ERROR_DP_NOT_AVAILABLE },
     262        { "WERR_DNS_ERROR_DP_FSMO_ERROR", WERR_DNS_ERROR_DP_FSMO_ERROR },
    171263        { "WERR_GENERAL_FAILURE", WERR_GENERAL_FAILURE },
    172264        { "WERR_PRINTQ_FULL", WERR_PRINTQ_FULL },
     
    19632055        { "WERR_DS_NOT_INSTALLED", WERR_DS_NOT_INSTALLED },
    19642056        { "WERR_DS_MEMBERSHIP_EVALUATED_LOCALLY", WERR_DS_MEMBERSHIP_EVALUATED_LOCALLY },
    1965         { "WERR_DS_INVALID_ATTRIBUTE_YNTAX", WERR_DS_INVALID_ATTRIBUTE_YNTAX },
    19662057        { "WERR_DS_NO_RIDS_ALLOCATED", WERR_DS_NO_RIDS_ALLOCATED },
    19672058        { "WERR_DS_NO_MORE_RIDS", WERR_DS_NO_MORE_RIDS },
     
    32593350        { WERR_CONNECTION_INVALID, "An operation was attempted on a nonexistent network connection." },
    32603351        { WERR_CONNECTION_ACTIVE, "An invalid operation was attempted on an active network connection." },
    3261         { WERR_NETWORK_UNREACHABLE, "The network location cannot be reached. For information about network troubleshooting, see Windows Help." },
    3262         { WERR_HOST_UNREACHABLE, "The network location cannot be reached. For information about network troubleshooting, see Windows Help." },
    3263         { WERR_PROTOCOL_UNREACHABLE, "The network location cannot be reached. For information about network troubleshooting, see Windows Help." },
     3352        { WERR_NETWORK_UNREACHABLE, "The network location cannot be reached." },
     3353        { WERR_HOST_UNREACHABLE, "The network location cannot be reached." },
     3354        { WERR_PROTOCOL_UNREACHABLE, "The network location cannot be reached." },
    32643355        { WERR_PORT_UNREACHABLE, "No service is operating at the destination network endpoint on the remote system." },
    32653356        { WERR_REQUEST_ABORTED, "The request was aborted." },
     
    32843375        { WERR_NOT_SUPPORTED_ON_SBS, "This operation is not supported on a computer running Windows Server 2003 for Small Business Server." },
    32853376        { WERR_SERVER_SHUTDOWN_IN_PROGRESS, "The server machine is shutting down." },
    3286         { WERR_HOST_DOWN, "The remote system is not available. For information about network troubleshooting, see Windows Help." },
     3377        { WERR_HOST_DOWN, "The remote system is not available." },
    32873378        { WERR_NON_ACCOUNT_SID, "The security identifier provided is not from an account domain." },
    32883379        { WERR_NON_DOMAIN_SID, "The security identifier provided does not have a domain component." },
     
    44744565        { WERR_DS_MEMBERSHIP_EVALUATED_LOCALLY, "The directory service evaluated group memberships locally." },
    44754566        { WERR_DS_NO_ATTRIBUTE_OR_VALUE, "The specified directory service attribute or value does not exist." },
    4476         { WERR_DS_INVALID_ATTRIBUTE_YNTAX, "The attribute syntax specified to the directory service is invalid." },
     4567        { WERR_DS_INVALID_ATTRIBUTE_SYNTAX, "The attribute syntax specified to the directory service is invalid." },
    44774568        { WERR_DS_ATTRIBUTE_TYPE_UNDEFINED, "The attribute type specified to the directory service is not defined." },
    44784569        { WERR_DS_ATTRIBUTE_OR_VALUE_EXISTS, "The specified directory service attribute or value already exists." },
     
    48544945        { WERR_DS_INVALID_SEARCH_FLAG_SUBTREE, "The search flags for the attribute are invalid. The subtree index bit is valid only on single-valued attributes." },
    48554946        { WERR_DS_INVALID_SEARCH_FLAG_TUPLE, "The search flags for the attribute are invalid. The tuple index bit is valid only on attributes of Unicode strings." },
     4947        { WERR_DNS_ERROR_RCODE_FORMAT_ERROR, "DNS server unable to interpret format." },
     4948        { WERR_DNS_ERROR_RCODE_SERVER_FAILURE, "DNS server failure." },
     4949        { WERR_DNS_ERROR_RCODE_NAME_ERROR, "DNS name does not exist." },
     4950        { WERR_DNS_ERROR_RCODE_NOT_IMPLEMENTED, "DNS request not supported by name server." },
     4951        { WERR_DNS_ERROR_RCODE_REFUSED, "DNS operation refused." },
     4952        { WERR_DNS_ERROR_RCODE_YXDOMAIN, "DNS name that should not exist, does exist." },
     4953        { WERR_DNS_ERROR_RCODE_YXRRSET, "DNS resource record (RR) set that should not exist, does exist." },
     4954        { WERR_DNS_ERROR_RCODE_NXRRSET, "DNS RR set that should to exist, does not exist." },
     4955        { WERR_DNS_ERROR_RCODE_NOTAUTH, "DNS server not authoritative for zone." },
     4956        { WERR_DNS_ERROR_RCODE_NOTZONE, "DNS name in update or prereq is not in zone." },
     4957        { WERR_DNS_ERROR_RCODE_BADSIG, "DNS signature failed to verify." },
     4958        { WERR_DNS_ERROR_RCODE_BADKEY, "DNS bad key." },
     4959        { WERR_DNS_ERROR_RCODE_BADTIME, "DNS signature validity expired." },
     4960        { WERR_DNS_INFO_NO_RECORDS, "No records found for given DNS query." },
     4961        { WERR_DNS_ERROR_BAD_PACKET, "Bad DNS packet." },
     4962        { WERR_DNS_ERROR_NO_PACKET, "No DNS packet." },
     4963        { WERR_DNS_ERROR_RCODE, "DNS error, check rcode." },
     4964        { WERR_DNS_ERROR_UNSECURE_PACKET, "Unsecured DNS packet." },
     4965        { WERR_DNS_ERROR_INVALID_TYPE, "Invalid DNS type." },
     4966        { WERR_DNS_ERROR_INVALID_IP_ADDRESS, "Invalid IP address." },
     4967        { WERR_DNS_ERROR_INVALID_PROPERTY, "Invalid property." },
     4968        { WERR_DNS_ERROR_TRY_AGAIN_LATER, "Try DNS operation again later." },
     4969        { WERR_DNS_ERROR_NOT_UNIQUE, "Record for given name and type is not unique." },
     4970        { WERR_DNS_ERROR_NON_RFC_NAME, "DNS name does not comply with RFC specifications." },
     4971        { WERR_DNS_STATUS_FQDN, "DNS name is a fully qualified DNS name." },
     4972        { WERR_DNS_STATUS_DOTTED_NAME, "DNS name is dotted (multilabel)." },
     4973        { WERR_DNS_STATUS_SINGLE_PART_NAME, "DNS name is a single-part name." },
     4974        { WERR_DNS_ERROR_INVALID_NAME_CHAR, "DNS name contains an invalid character." },
     4975        { WERR_DNS_ERROR_NUMERIC_NAME, "DNS name is entirely numeric." },
     4976        { WERR_DNS_ERROR_NOT_ALLOWED_ON_ROOT_SERVER, "The operation requested is not permitted on a DNS root server." },
     4977        { WERR_DNS_ERROR_NOT_ALLOWED_UNDER_DELEGATION, "The record could not be created because this part of the DNS namespace has been delegated to another server." },
     4978        { WERR_DNS_ERROR_CANNOT_FIND_ROOT_HINTS, "The DNS server could not find a set of root hints." },
     4979        { WERR_DNS_ERROR_INCONSISTENT_ROOT_HINTS, "The DNS server found root hints but they were not consistent across all adapters." },
     4980        { WERR_DNS_ERROR_DWORD_VALUE_TOO_SMALL, "The specified value is too small for this parameter." },
     4981        { WERR_DNS_ERROR_DWORD_VALUE_TOO_LARGE, "The specified value is too large for this parameter." },
     4982        { WERR_DNS_ERROR_BACKGROUND_LOADING, "This operation is not allowed while the DNS server is loading zones in the background. Try again later." },
     4983        { WERR_DNS_ERROR_NOT_ALLOWED_ON_RODC, "The operation requested is not permitted on against a DNS server running on a read-only DC." },
     4984        { WERR_DNS_ERROR_ZONE_DOES_NOT_EXIST, "DNS zone does not exist." },
     4985        { WERR_DNS_ERROR_NO_ZONE_INFO, "DNS zone information not available." },
     4986        { WERR_DNS_ERROR_INVALID_ZONE_OPERATION, "Invalid operation for DNS zone." },
     4987        { WERR_DNS_ERROR_ZONE_CONFIGURATION_ERROR, "Invalid DNS zone configuration." },
     4988        { WERR_DNS_ERROR_ZONE_HAS_NO_SOA_RECORD, "DNS zone has no start of authority (SOA) record." },
     4989        { WERR_DNS_ERROR_ZONE_HAS_NO_NS_RECORDS, "DNS zone has no Name Server (NS) record." },
     4990        { WERR_DNS_ERROR_ZONE_LOCKED, "DNS zone is locked." },
     4991        { WERR_DNS_ERROR_ZONE_CREATION_FAILED, "DNS zone creation failed." },
     4992        { WERR_DNS_ERROR_ZONE_ALREADY_EXISTS, "DNS zone already exists." },
     4993        { WERR_DNS_ERROR_AUTOZONE_ALREADY_EXISTS, "DNS automatic zone already exists." },
     4994        { WERR_DNS_ERROR_INVALID_ZONE_TYPE, "Invalid DNS zone type." },
     4995        { WERR_DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP, "Secondary DNS zone requires master IP address." },
     4996        { WERR_DNS_ERROR_ZONE_NOT_SECONDARY, "DNS zone not secondary." },
     4997        { WERR_DNS_ERROR_NEED_SECONDARY_ADDRESSES, "Need secondary IP address." },
     4998        { WERR_DNS_ERROR_WINS_INIT_FAILED, "WINS initialization failed." },
     4999        { WERR_DNS_ERROR_NEED_WINS_SERVERS, "Need WINS servers." },
     5000        { WERR_DNS_ERROR_NBSTAT_INIT_FAILED, "NBTSTAT initialization call failed." },
     5001        { WERR_DNS_ERROR_SOA_DELETE_INVALID, "Invalid delete of SOA." },
     5002        { WERR_DNS_ERROR_FORWARDER_ALREADY_EXISTS, "A conditional forwarding zone already exists for that name." },
     5003        { WERR_DNS_ERROR_ZONE_REQUIRES_MASTER_IP, "This zone must be configured with one or more master DNS server IP addresses." },
     5004        { WERR_DNS_ERROR_ZONE_IS_SHUTDOWN, "The operation cannot be performed because this zone is shut down." },
     5005        { WERR_DNS_ERROR_PRIMARY_REQUIRES_DATAFILE, "The primary DNS zone requires a data file." },
     5006        { WERR_DNS_ERROR_INVALID_DATAFILE_NAME, "Invalid data file name for the DNS zone." },
     5007        { WERR_DNS_ERROR_DATAFILE_OPEN_FAILURE, "Failed to open the data file for the DNS zone." },
     5008        { WERR_DNS_ERROR_FILE_WRITEBACK_FAILED, "Failed to write the data file for the DNS zone." },
     5009        { WERR_DNS_ERROR_DATAFILE_PARSING, "Failure while reading datafile for DNS zone." },
     5010        { WERR_DNS_ERROR_RECORD_DOES_NOT_EXIST, "DNS record does not exist." },
     5011        { WERR_DNS_ERROR_RECORD_FORMAT, "DNS record format error." },
     5012        { WERR_DNS_ERROR_NODE_CREATION_FAILED, "Node creation failure in DNS." },
     5013        { WERR_DNS_ERROR_UNKNOWN_RECORD_TYPE, "Unknown DNS record type." },
     5014        { WERR_DNS_ERROR_RECORD_TIMED_OUT, "DNS record timed out." },
     5015        { WERR_DNS_ERROR_NAME_NOT_IN_ZONE, "Name not in DNS zone." },
     5016        { WERR_DNS_ERROR_CNAME_LOOP, "CNAME loop detected." },
     5017        { WERR_DNS_ERROR_NODE_IS_CNAME, "Node is a CNAME DNS record." },
     5018        { WERR_DNS_ERROR_CNAME_COLLISION, "A CNAME record already exists for the given name." },
     5019        { WERR_DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT, "Record is only at DNS zone root." },
     5020        { WERR_DNS_ERROR_RECORD_ALREADY_EXISTS, "DNS record already exists." },
     5021        { WERR_DNS_ERROR_SECONDARY_DATA, "Secondary DNS zone data error." },
     5022        { WERR_DNS_ERROR_NO_CREATE_CACHE_DATA, "Could not create DNS cache data." },
     5023        { WERR_DNS_ERROR_NAME_DOES_NOT_EXIST, "DNS name does not exist." },
     5024        { WERR_DNS_WARNING_PTR_CREATE_FAILED, "Could not create pointer (PTR) record." },
     5025        { WERR_DNS_WARNING_DOMAIN_UNDELETED, "DNS domain was undeleted." },
     5026        { WERR_DNS_ERROR_DS_UNAVAILABLE, "The directory service is unavailable." },
     5027        { WERR_DNS_ERROR_DS_ZONE_ALREADY_EXISTS, "DNS zone already exists in the directory service." },
     5028        { WERR_DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE, "DNS server not creating or reading the boot file for the directory service integrated DNS zone." },
     5029        { WERR_DNS_INFO_AXFR_COMPLETE, "DNS AXFR (zone transfer) complete." },
     5030        { WERR_DNS_ERROR_AXFR, "DNS zone transfer failed." },
     5031        { WERR_DNS_INFO_ADDED_LOCAL_WINS, "Added local WINS server." },
     5032        { WERR_DNS_STATUS_CONTINUE_NEEDED, "Secure update call needs to continue update request." },
     5033        { WERR_DNS_ERROR_NO_TCPIP, "TCP/IP network protocol not installed." },
     5034        { WERR_DNS_ERROR_NO_DNS_SERVERS, "No DNS servers configured for local system." },
     5035        { WERR_DNS_ERROR_DP_DOES_NOT_EXIST, "The specified directory partition does not exist." },
     5036        { WERR_DNS_ERROR_DP_ALREADY_EXISTS, "The specified directory partition already exists." },
     5037        { WERR_DNS_ERROR_DP_NOT_ENLISTED, "This DNS server is not enlisted in the specified directory partition." },
     5038        { WERR_DNS_ERROR_DP_ALREADY_ENLISTED, "This DNS server is already enlisted in the specified directory partition." },
     5039        { WERR_DNS_ERROR_DP_NOT_AVAILABLE, "The directory partition is not available at this time. Wait a few minutes and try again." },
     5040        { WERR_DNS_ERROR_DP_FSMO_ERROR, "The application directory partition operation failed. The domain controller holding the domain naming master role is down or unable to service the request or is not running Windows Server 2003." },
    48565041        { WERR_IPSEC_QM_POLICY_EXISTS, "The specified quick mode policy already exists." },
    48575042        { WERR_IPSEC_QM_POLICY_NOT_FOUND, "The specified quick mode policy was not found." },
  • vendor/current/libcli/util/error.h

    r414 r740  
    4747NTSTATUS map_nt_error_from_unix(int unix_error);
    4848
     49/*********************************************************************
     50convert a Unix error code to a WERROR
     51*********************************************************************/
     52WERROR unix_to_werror(int unix_error);
     53
     54NTSTATUS nt_status_squash(NTSTATUS nt_status);
     55
    4956#endif /* _SAMBA_ERROR_H */
  • vendor/current/libcli/util/ntstatus.h

    r414 r740  
    66   Copyright (C) Luke Kenneth Casson Leighton 1996-2000
    77   Copyright (C) Paul Ashton                  1998-2000
    8    
     8
    99   This program is free software; you can redistribute it and/or modify
    1010   it under the terms of the GNU General Public License as published by
    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/>.
     
    602602#define NT_STATUS_NO_SUCH_JOB NT_STATUS(0xC0000000 | 0xEDE) /* scheduler */
    603603#define NT_STATUS_DOWNGRADE_DETECTED NT_STATUS(0xC0000000 | 0x0388)
     604#define NT_STATUS_NO_S4U_PROT_SUPPORT NT_STATUS(0xC0000000 | 0x040A)
     605#define NT_STATUS_CROSSREALM_DELEGATION_FAILURE NT_STATUS(0xC0000000 | 0x040B)
    604606#define NT_STATUS_NO_SUCH_JOB NT_STATUS(0xC0000000 | 0xEDE) /* scheduler */
    605607#define NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED NT_STATUS(0xC0000000 | 0x20004)
    606608#define NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX NT_STATUS(0xC0000000 | 0x20026)
    607 #define NT_STATUS_RPC_NT_CALL_FAILED NT_STATUS(0xC0000000 | 0x2001B)
    608 #define NT_STATUS_RPC_NT_PROTOCOL_ERROR NT_STATUS(0xC0000000 | 0x2001D)
    609 #define NT_STATUS_RPC_NT_PROCNUM_OUT_OF_RANGE NT_STATUS(0xC0000000 | 0x2002E)
     609#define NT_STATUS_RPC_UNKNOWN_IF NT_STATUS(0xC0000000 | 0x20012)
     610#define NT_STATUS_RPC_CALL_FAILED NT_STATUS(0xC0000000 | 0x2001B)
     611#define NT_STATUS_RPC_PROTOCOL_ERROR NT_STATUS(0xC0000000 | 0x2001D)
     612#define NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE NT_STATUS(0xC0000000 | 0x2002E)
     613#define NT_STATUS_RPC_CANNOT_SUPPORT NT_STATUS(0xC0000000 | 0x20041)
     614#define NT_STATUS_RPC_SEC_PKG_ERROR NT_STATUS(0xC0000000 | 0x20057)
     615#define NT_STATUS_RPC_SS_CONTEXT_MISMATCH NT_STATUS(0xC0000000 | 0x30005)
     616#define NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE NT_STATUS(0xC000000 | 0x3000A)
     617#define NT_STATUS_RPC_BAD_STUB_DATA NT_STATUS(0xC0000000 | 0x3000C)
     618#define NT_STATUS_RPC_INVALID_PIPE_OBJECT NT_STATUS(0xC0000000 | 0x3005C)
     619#define NT_STATUS_RPC_INVALID_PIPE_OPERATION NT_STATUS(0xC0000000 | 0x3005D)
     620#define NT_STATUS_RPC_WRONG_PIPE_VERSION NT_STATUS(0xC0000000 | 0x3005E)
     621#define NT_STATUS_RPC_PIPE_CLOSED NT_STATUS(0xC0000000 | 0x3005F)
     622#define NT_STATUS_RPC_PIPE_DISCIPLINE_ERROR NT_STATUS(0xC0000000 | 0x30060)
     623#define NT_STATUS_RPC_PIPE_EMPTY NT_STATUS(0xC0000000 | 0x30061)
    610624#define NT_STATUS_ERROR_DS_OBJ_STRING_NAME_EXISTS NT_STATUS(0xC0000000 | 0x2071)
    611625#define NT_STATUS_ERROR_DS_INCOMPATIBLE_VERSION NT_STATUS(0xC0000000 | 0x00002177)
     
    637651/** Used by ntstatus_dos_equal: */
    638652extern bool ntstatus_check_dos_mapping;
     653
     654/* we need these here for openchange */
     655#ifndef likely
     656#define likely(x) (x)
     657#endif
     658#ifndef unlikely
     659#define unlikely(x) (x)
     660#endif
    639661
    640662#define NT_STATUS_IS_OK(x) (likely(NT_STATUS_V(x) == 0))
     
    675697} while (0)
    676698
     699#define NT_STATUS_NOT_OK_RETURN_AND_FREE(x, ctx) do {   \
     700        if (!NT_STATUS_IS_OK(x)) {\
     701                talloc_free(ctx); \
     702                return x;\
     703        }\
     704} while (0)
     705
    677706#define NT_STATUS_IS_ERR_RETURN(x) do { \
    678707        if (NT_STATUS_IS_ERR(x)) {\
     
    700729#define NT_STATUS_LDAP_CODE(status) (NT_STATUS_V(status) & ~0xFF000000)
    701730
    702 #define NT_STATUS_RPC_CANNOT_SUPPORT NT_STATUS(0xC0000000 | 0x20041)
     731#define NT_STATUS_IS_RPC(status) \
     732        (((NT_STATUS_V(status) & 0xFFFF) == 0xC0020000) || \
     733         ((NT_STATUS_V(status) & 0xFFFF) == 0xC0030000))
    703734
    704735#endif /* _NTSTATUS_H */
  • vendor/current/libcli/util/werror.h

    r414 r740  
    4545#define W_ERROR_HAVE_NO_MEMORY(x) do { \
    4646        if (!(x)) {\
     47                return WERR_NOMEM;\
     48        }\
     49} while (0)
     50
     51#define W_ERROR_HAVE_NO_MEMORY_AND_FREE(x, ctx) do { \
     52        if (!(x)) {\
     53                talloc_free(ctx); \
    4754                return WERR_NOMEM;\
    4855        }\
     
    234241#define WERR_SETUP_DOMAIN_CONTROLLER    W_ERROR(0x00000A85)
    235242#define WERR_DEFAULT_JOIN_REQUIRED      W_ERROR(0x00000A86)
    236 
    237 /* DS errors */
    238 #define WERR_DS_NO_ATTRIBUTE_OR_VALUE W_ERROR(0x0000200A)
    239 #define WERR_DS_INVALID_ATTRIBUTE_SYNTAX W_ERROR(0x0000200B)
    240 #define WERR_DS_ATTRIBUTE_TYPE_UNDEFINED W_ERROR(0x0000200C)
    241 #define WERR_DS_ATTRIBUTE_OR_VALUE_EXISTS W_ERROR(0x0000200D)
    242 #define WERR_DS_BUSY W_ERROR(0x0000200E)
    243 #define WERR_DS_UNAVAILABLE W_ERROR(0x0000200F)
    244 #define WERR_DS_OBJ_CLASS_VIOLATION W_ERROR(0x00002014)
    245 #define WERR_DS_CANT_ON_NON_LEAF W_ERROR(0x00002015)
    246 #define WERR_DS_CANT_ON_RDN W_ERROR(0x00002016)
    247 #define WERR_DS_CANT_MOD_OBJ_CLASS W_ERROR(0x00002017)
    248 #define WERR_DS_OPERATIONS_ERROR W_ERROR(0x00002020)
    249 #define WERR_DS_PROTOCOL_ERROR W_ERROR(0x00002021)
    250 #define WERR_DS_TIMELIMIT_EXCEEDED W_ERROR(0x00002022)
    251 #define WERR_DS_SIZE_LIMIT_EXCEEDED W_ERROR(0x00002023)
    252 #define WERR_DS_ADMIN_LIMIT_EXCEEDED W_ERROR(0x00002024)
    253 #define WERR_DS_COMPARE_FALSE W_ERROR(0x00002025)
    254 #define WERR_DS_COMPARE_TRUE W_ERROR(0x00002026)
    255 #define WERR_DS_AUTH_METHOD_NOT_SUPPORTED W_ERROR(0x00002027)
    256 #define WERR_DS_STRONG_AUTH_REQUIRED W_ERROR(0x00002028)
    257 #define WERR_DS_INAPPROPRIATE_AUTH W_ERROR(0x00002029)
    258 #define WERR_DS_REFERRAL W_ERROR(0x0000202B)
    259 #define WERR_DS_UNAVAILABLE_CRIT_EXTENSION W_ERROR(0x0000202C)
    260 #define WERR_DS_CONFIDENTIALITY_REQUIRED W_ERROR(0x0000202D)
    261 #define WERR_DS_INAPPROPRIATE_MATCHING W_ERROR(0x0000202E)
    262 #define WERR_DS_CONSTRAINT_VIOLATION W_ERROR(0x0000202F)
    263 #define WERR_DS_NO_SUCH_OBJECT W_ERROR(0x00002030)
    264 #define WERR_DS_ALIAS_PROBLEM W_ERROR(0x00002031)
    265 #define WERR_DS_INVALID_DN_SYNTAX W_ERROR(0x00002032)
    266 #define WERR_DS_ALIAS_DEREF_PROBLEM W_ERROR(0x00002034)
    267 #define WERR_DS_UNWILLING_TO_PERFORM W_ERROR(0x00002035)
    268 #define WERR_DS_LOOP_DETECT W_ERROR(0x00002036)
    269 #define WERR_DS_NAMING_VIOLATION W_ERROR(0x00002037)
    270 #define WERR_DS_AFFECTS_MULTIPLE_DSAS W_ERROR(0x00002039)
    271 #define WERR_DS_OBJ_STRING_NAME_EXISTS W_ERROR(0x00002071)
    272 #define WERR_DS_OBJ_NOT_FOUND W_ERROR(0x0000208D)
    273 #define WERR_DS_GENERIC_ERROR W_ERROR(0x00002095)
    274 #define WERR_DS_INSUFF_ACCESS_RIGHTS W_ERROR(0x00002098)
    275 #define WERR_DS_SCHEMA_NOT_LOADED W_ERROR(0x20DE)
    276 #define WERR_DS_SCHEMA_ALLOC_FAILED W_ERROR(0x20DF)
    277 #define WERR_DS_ATT_SCHEMA_REQ_SYNTAX W_ERROR(0x000020E0)
    278 #define WERR_DS_DRA_SCHEMA_MISMATCH W_ERROR(0x000020E2)
    279 #define WERR_DS_DRA_INVALID_PARAMETER W_ERROR(0x000020F5)
    280 #define WERR_DS_DRA_BAD_DN W_ERROR(0x000020F7)
    281 #define WERR_DS_DRA_BAD_NC W_ERROR(0x000020F8)
    282 #define WERR_DS_DRA_INTERNAL_ERROR W_ERROR(0x000020FA)
    283 #define WERR_DS_DRA_OUT_OF_MEM W_ERROR(0x000020FE)
    284 #define WERR_DS_SINGLE_VALUE_CONSTRAINT W_ERROR(0x00002081)
    285 #define WERR_DS_DRA_DB_ERROR W_ERROR(0x00002103)
    286 #define WERR_DS_DRA_NO_REPLICA W_ERROR(0x00002104)
    287 #define WERR_DS_DRA_ACCESS_DENIED W_ERROR(0x00002105)
    288 #define WERR_DS_DRA_SOURCE_DISABLED W_ERROR(0x00002108)
    289 #define WERR_DS_DNS_LOOKUP_FAILURE W_ERROR(0x0000214C)
    290 #define WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX W_ERROR(0x00002150)
    291 #define WERR_DS_NO_MSDS_INTID W_ERROR(0x00002194)
    292 #define WERR_DS_DUP_MSDS_INTID W_ERROR(0x00002195)
    293243
    294244/* FRS errors */
     
    20582008#define WERR_DS_NOT_INSTALLED   W_ERROR(0x00002008)
    20592009#define WERR_DS_MEMBERSHIP_EVALUATED_LOCALLY    W_ERROR(0x00002009)
    2060 #define WERR_DS_INVALID_ATTRIBUTE_YNTAX W_ERROR(0x0000200B)
     2010#define WERR_DS_NO_ATTRIBUTE_OR_VALUE   W_ERROR(0x0000200A)
     2011#define WERR_DS_INVALID_ATTRIBUTE_SYNTAX        W_ERROR(0x0000200B)
     2012#define WERR_DS_ATTRIBUTE_TYPE_UNDEFINED        W_ERROR(0x0000200C)
     2013#define WERR_DS_ATTRIBUTE_OR_VALUE_EXISTS       W_ERROR(0x0000200D)
     2014#define WERR_DS_BUSY    W_ERROR(0x0000200E)
     2015#define WERR_DS_UNAVAILABLE     W_ERROR(0x0000200F)
    20612016#define WERR_DS_NO_RIDS_ALLOCATED       W_ERROR(0x00002010)
    20622017#define WERR_DS_NO_MORE_RIDS    W_ERROR(0x00002011)
    20632018#define WERR_DS_INCORRECT_ROLE_OWNER    W_ERROR(0x00002012)
    20642019#define WERR_DS_RIDMGR_INIT_ERROR       W_ERROR(0x00002013)
     2020#define WERR_DS_OBJ_CLASS_VIOLATION     W_ERROR(0x00002014)
     2021#define WERR_DS_CANT_ON_NON_LEAF        W_ERROR(0x00002015)
     2022#define WERR_DS_CANT_ON_RDN      W_ERROR(0x00002016)
     2023#define WERR_DS_CANT_MOD_OBJ_CLASS      W_ERROR(0x00002017)
    20652024#define WERR_DS_CROSS_DOM_MOVE_ERROR    W_ERROR(0x00002018)
    20662025#define WERR_DS_GC_NOT_AVAILABLE        W_ERROR(0x00002019)
     
    20702029#define WERR_PROMOTION_ACTIVE   W_ERROR(0x0000201D)
    20712030#define WERR_NO_PROMOTION_ACTIVE        W_ERROR(0x0000201E)
     2031#define WERR_DS_OPERATIONS_ERROR        W_ERROR(0x00002020)
     2032#define WERR_DS_PROTOCOL_ERROR  W_ERROR(0x00002021)
     2033#define WERR_DS_TIMELIMIT_EXCEEDED      W_ERROR(0x00002022)
    20722034#define WERR_DS_SIZELIMIT_EXCEEDED      W_ERROR(0x00002023)
     2035#define WERR_DS_ADMIN_LIMIT_EXCEEDED    W_ERROR(0x00002024)
     2036#define WERR_DS_COMPARE_FALSE   W_ERROR(0x00002025)
     2037#define WERR_DS_COMPARE_TRUE    W_ERROR(0x00002026)
     2038#define WERR_DS_AUTH_METHOD_NOT_SUPPORTED       W_ERROR(0x00002027)
     2039#define WERR_DS_STRONG_AUTH_REQUIRED    W_ERROR(0x00002028)
     2040#define WERR_DS_INAPPROPRIATE_AUTH      W_ERROR(0x00002029)
    20732041#define WERR_DS_AUTH_UNKNOWN    W_ERROR(0x0000202A)
     2042#define WERR_DS_REFERRAL        W_ERROR(0x0000202B)
     2043#define WERR_DS_UNAVAILABLE_CRIT_EXTENSION      W_ERROR(0x0000202C)
     2044#define WERR_DS_CONFIDENTIALITY_REQUIRED        W_ERROR(0x0000202D)
     2045#define WERR_DS_INAPPROPRIATE_MATCHING  W_ERROR(0x0000202E)
     2046#define WERR_DS_CONSTRAINT_VIOLATION    W_ERROR(0x0000202F)
     2047#define WERR_DS_NO_SUCH_OBJECT  W_ERROR(0x00002030)
     2048#define WERR_DS_ALIAS_PROBLEM   W_ERROR(0x00002031)
     2049#define WERR_DS_INVALID_DN_SYNTAX       W_ERROR(0x00002032)
    20742050#define WERR_DS_IS_LEAF W_ERROR(0x00002033)
     2051#define WERR_DS_ALIAS_DEREF_PROBLEM     W_ERROR(0x00002034)
     2052#define WERR_DS_UNWILLING_TO_PERFORM    W_ERROR(0x00002035)
     2053#define WERR_DS_LOOP_DETECT     W_ERROR(0x00002036)
     2054#define WERR_DS_NAMING_VIOLATION        W_ERROR(0x00002037)
    20752055#define WERR_DS_OBJECT_RESULTS_TOO_LARGE        W_ERROR(0x00002038)
     2056#define WERR_DS_AFFECTS_MULTIPLE_DSAS   W_ERROR(0x00002039)
    20762057#define WERR_DS_SERVER_DOWN     W_ERROR(0x0000203A)
    20772058#define WERR_DS_LOCAL_ERROR     W_ERROR(0x0000203B)
     
    20912072#define WERR_DS_ATT_NOT_DEF_IN_SCHEMA   W_ERROR(0x0000206F)
    20922073#define WERR_DS_MAX_OBJ_SIZE_EXCEEDED   W_ERROR(0x00002070)
     2074#define WERR_DS_OBJ_STRING_NAME_EXISTS  W_ERROR(0x00002071)
    20932075#define WERR_DS_NO_RDN_DEFINED_IN_SCHEMA        W_ERROR(0x00002072)
    20942076#define WERR_DS_RDN_DOESNT_MATCH_SCHEMA W_ERROR(0x00002073)
     
    21052087#define WERR_DS_ATT_ALREADY_EXISTS      W_ERROR(0x0000207E)
    21062088#define WERR_DS_CANT_ADD_ATT_VALUES     W_ERROR(0x00002080)
     2089#define WERR_DS_SINGLE_VALUE_CONSTRAINT W_ERROR(0x00002081)
    21072090#define WERR_DS_RANGE_CONSTRAINT        W_ERROR(0x00002082)
    21082091#define WERR_DS_ATT_VAL_ALREADY_EXISTS  W_ERROR(0x00002083)
     
    21162099#define WERR_DS_CANT_MIX_MASTER_AND_REPS        W_ERROR(0x0000208B)
    21172100#define WERR_DS_CHILDREN_EXIST  W_ERROR(0x0000208C)
     2101#define WERR_DS_OBJ_NOT_FOUND   W_ERROR(0x0000208D)
    21182102#define WERR_DS_ALIASED_OBJ_MISSING     W_ERROR(0x0000208E)
    21192103#define WERR_DS_BAD_NAME_SYNTAX W_ERROR(0x0000208F)
     
    21232107#define WERR_DS_OBJECT_BEING_REMOVED    W_ERROR(0x00002093)
    21242108#define WERR_DS_CANT_DELETE_DSA_OBJ     W_ERROR(0x00002094)
     2109#define WERR_DS_GENERIC_ERROR   W_ERROR(0x00002095)
    21252110#define WERR_DS_DSA_MUST_BE_INT_MASTER  W_ERROR(0x00002096)
    21262111#define WERR_DS_CLASS_NOT_DSA   W_ERROR(0x00002097)
     2112#define WERR_DS_INSUFF_ACCESS_RIGHTS    W_ERROR(0x00002098)
    21272113#define WERR_DS_ILLEGAL_SUPERIOR        W_ERROR(0x00002099)
    21282114#define WERR_DS_ATTRIBUTE_OWNED_BY_SAM  W_ERROR(0x0000209A)
     
    21932179#define WERR_DS_NCNAME_MISSING_CR_REF   W_ERROR(0x000020DC)
    21942180#define WERR_DS_SECURITY_CHECKING_ERROR W_ERROR(0x000020DD)
     2181#define WERR_DS_SCHEMA_NOT_LOADED       W_ERROR(0x20DE)
     2182#define WERR_DS_SCHEMA_ALLOC_FAILED     W_ERROR(0x20DF)
     2183#define WERR_DS_ATT_SCHEMA_REQ_SYNTAX   W_ERROR(0x000020E0)
    21952184#define WERR_DS_GCVERIFY_ERROR  W_ERROR(0x000020E1)
     2185#define WERR_DS_DRA_SCHEMA_MISMATCH     W_ERROR(0x000020E2)
    21962186#define WERR_DS_CANT_FIND_DSA_OBJ       W_ERROR(0x000020E3)
    21972187#define WERR_DS_CANT_FIND_EXPECTED_NC   W_ERROR(0x000020E4)
     
    22122202#define WERR_DS_UNABLE_TO_SURRENDER_ROLES       W_ERROR(0x000020F3)
    22132203#define WERR_DS_DRA_GENERIC     W_ERROR(0x000020F4)
     2204#define WERR_DS_DRA_INVALID_PARAMETER   W_ERROR(0x000020F5)
    22142205#define WERR_DS_DRA_BUSY        W_ERROR(0x000020F6)
     2206#define WERR_DS_DRA_BAD_DN      W_ERROR(0x000020F7)
     2207#define WERR_DS_DRA_BAD_NC      W_ERROR(0x000020F8)
    22152208#define WERR_DS_DRA_DN_EXISTS   W_ERROR(0x000020F9)
     2209#define WERR_DS_DRA_INTERNAL_ERROR      W_ERROR(0x000020FA)
    22162210#define WERR_DS_DRA_INCONSISTENT_DIT    W_ERROR(0x000020FB)
    22172211#define WERR_DS_DRA_CONNECTION_FAILED   W_ERROR(0x000020FC)
    22182212#define WERR_DS_DRA_BAD_INSTANCE_TYPE   W_ERROR(0x000020FD)
     2213#define WERR_DS_DRA_OUT_OF_MEM  W_ERROR(0x000020FE)
    22192214#define WERR_DS_DRA_MAIL_PROBLEM        W_ERROR(0x000020FF)
    22202215#define WERR_DS_DRA_REF_ALREADY_EXISTS  W_ERROR(0x00002100)
    22212216#define WERR_DS_DRA_REF_NOT_FOUND       W_ERROR(0x00002101)
    22222217#define WERR_DS_DRA_OBJ_IS_REP_SOURCE   W_ERROR(0x00002102)
     2218#define WERR_DS_DRA_DB_ERROR    W_ERROR(0x00002103)
     2219#define WERR_DS_DRA_NO_REPLICA  W_ERROR(0x00002104)
     2220#define WERR_DS_DRA_ACCESS_DENIED       W_ERROR(0x00002105)
    22232221#define WERR_DS_DRA_NOT_SUPPORTED       W_ERROR(0x00002106)
    22242222#define WERR_DS_DRA_RPC_CANCELLED       W_ERROR(0x00002107)
     2223#define WERR_DS_DRA_SOURCE_DISABLED     W_ERROR(0x00002108)
    22252224#define WERR_DS_DRA_SINK_DISABLED       W_ERROR(0x00002109)
    22262225#define WERR_DS_DRA_NAME_COLLISION      W_ERROR(0x0000210A)
     
    22882287#define WERR_DS_STRING_SD_CONVERSION_FAILED     W_ERROR(0x0000214A)
    22892288#define WERR_DS_NAMING_MASTER_GC        W_ERROR(0x0000214B)
     2289#define WERR_DS_DNS_LOOKUP_FAILURE      W_ERROR(0x0000214C)
    22902290#define WERR_DS_COULDNT_UPDATE_SPNS     W_ERROR(0x0000214D)
    22912291#define WERR_DS_CANT_RETRIEVE_SD        W_ERROR(0x0000214E)
     
    23572357#define WERR_DS_DRS_EXTENSIONS_CHANGED  W_ERROR(0x00002192)
    23582358#define WERR_DS_REPLICA_SET_CHANGE_NOT_ALLOWED_ON_DISABLED_CR   W_ERROR(0x00002193)
     2359#define WERR_DS_NO_MSDS_INTID   W_ERROR(0x00002194)
     2360#define WERR_DS_DUP_MSDS_INTID  W_ERROR(0x00002195)
    23592361#define WERR_DS_EXISTS_IN_RDNATTID      W_ERROR(0x00002196)
    23602362#define WERR_DS_AUTHORIZATION_FAILED    W_ERROR(0x00002197)
     
    23872389#define WERR_DS_INVALID_SEARCH_FLAG_SUBTREE     W_ERROR(0x000021B2)
    23882390#define WERR_DS_INVALID_SEARCH_FLAG_TUPLE       W_ERROR(0x000021B3)
     2391#define WERR_DNS_ERROR_RCODE_FORMAT_ERROR       W_ERROR(0x00002329)
     2392#define WERR_DNS_ERROR_RCODE_SERVER_FAILURE     W_ERROR(0x0000232A)
     2393#define WERR_DNS_ERROR_RCODE_NAME_ERROR W_ERROR(0x0000232B)
     2394#define WERR_DNS_ERROR_RCODE_NOT_IMPLEMENTED    W_ERROR(0x0000232C)
     2395#define WERR_DNS_ERROR_RCODE_REFUSED    W_ERROR(0x0000232D)
     2396#define WERR_DNS_ERROR_RCODE_YXDOMAIN   W_ERROR(0x0000232E)
     2397#define WERR_DNS_ERROR_RCODE_YXRRSET    W_ERROR(0x0000232F)
     2398#define WERR_DNS_ERROR_RCODE_NXRRSET    W_ERROR(0x00002330)
     2399#define WERR_DNS_ERROR_RCODE_NOTAUTH    W_ERROR(0x00002331)
     2400#define WERR_DNS_ERROR_RCODE_NOTZONE    W_ERROR(0x00002332)
     2401#define WERR_DNS_ERROR_RCODE_BADSIG     W_ERROR(0x00002338)
     2402#define WERR_DNS_ERROR_RCODE_BADKEY     W_ERROR(0x00002339)
     2403#define WERR_DNS_ERROR_RCODE_BADTIME    W_ERROR(0x0000233A)
     2404#define WERR_DNS_INFO_NO_RECORDS        W_ERROR(0x0000251D)
     2405#define WERR_DNS_ERROR_BAD_PACKET       W_ERROR(0x0000251E)
     2406#define WERR_DNS_ERROR_NO_PACKET        W_ERROR(0x0000251F)
     2407#define WERR_DNS_ERROR_RCODE    W_ERROR(0x00002520)
     2408#define WERR_DNS_ERROR_UNSECURE_PACKET  W_ERROR(0x00002521)
     2409#define WERR_DNS_ERROR_INVALID_TYPE     W_ERROR(0x0000254F)
     2410#define WERR_DNS_ERROR_INVALID_IP_ADDRESS       W_ERROR(0x00002550)
     2411#define WERR_DNS_ERROR_INVALID_PROPERTY W_ERROR(0x00002551)
     2412#define WERR_DNS_ERROR_TRY_AGAIN_LATER  W_ERROR(0x00002552)
     2413#define WERR_DNS_ERROR_NOT_UNIQUE       W_ERROR(0x00002553)
     2414#define WERR_DNS_ERROR_NON_RFC_NAME     W_ERROR(0x00002554)
     2415#define WERR_DNS_STATUS_FQDN    W_ERROR(0x00002555)
     2416#define WERR_DNS_STATUS_DOTTED_NAME     W_ERROR(0x00002556)
     2417#define WERR_DNS_STATUS_SINGLE_PART_NAME        W_ERROR(0x00002557)
     2418#define WERR_DNS_ERROR_INVALID_NAME_CHAR        W_ERROR(0x00002558)
     2419#define WERR_DNS_ERROR_NUMERIC_NAME     W_ERROR(0x00002559)
     2420#define WERR_DNS_ERROR_NOT_ALLOWED_ON_ROOT_SERVER       W_ERROR(0x0000255A)
     2421#define WERR_DNS_ERROR_NOT_ALLOWED_UNDER_DELEGATION     W_ERROR(0x0000255B)
     2422#define WERR_DNS_ERROR_CANNOT_FIND_ROOT_HINTS   W_ERROR(0x0000255C)
     2423#define WERR_DNS_ERROR_INCONSISTENT_ROOT_HINTS  W_ERROR(0x0000255D)
     2424#define WERR_DNS_ERROR_DWORD_VALUE_TOO_SMALL    W_ERROR(0x0000255E)
     2425#define WERR_DNS_ERROR_DWORD_VALUE_TOO_LARGE    W_ERROR(0x0000255F)
     2426#define WERR_DNS_ERROR_BACKGROUND_LOADING       W_ERROR(0x00002560)
     2427#define WERR_DNS_ERROR_NOT_ALLOWED_ON_RODC      W_ERROR(0x00002561)
     2428#define WERR_DNS_ERROR_ZONE_DOES_NOT_EXIST      W_ERROR(0x00002581)
     2429#define WERR_DNS_ERROR_NO_ZONE_INFO     W_ERROR(0x00002582)
     2430#define WERR_DNS_ERROR_INVALID_ZONE_OPERATION   W_ERROR(0x00002583)
     2431#define WERR_DNS_ERROR_ZONE_CONFIGURATION_ERROR W_ERROR(0x00002584)
     2432#define WERR_DNS_ERROR_ZONE_HAS_NO_SOA_RECORD   W_ERROR(0x00002585)
     2433#define WERR_DNS_ERROR_ZONE_HAS_NO_NS_RECORDS   W_ERROR(0x00002586)
     2434#define WERR_DNS_ERROR_ZONE_LOCKED      W_ERROR(0x00002587)
     2435#define WERR_DNS_ERROR_ZONE_CREATION_FAILED     W_ERROR(0x00002588)
     2436#define WERR_DNS_ERROR_ZONE_ALREADY_EXISTS      W_ERROR(0x00002589)
     2437#define WERR_DNS_ERROR_AUTOZONE_ALREADY_EXISTS  W_ERROR(0x0000258A)
     2438#define WERR_DNS_ERROR_INVALID_ZONE_TYPE        W_ERROR(0x0000258B)
     2439#define WERR_DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP     W_ERROR(0x0000258C)
     2440#define WERR_DNS_ERROR_ZONE_NOT_SECONDARY       W_ERROR(0x0000258D)
     2441#define WERR_DNS_ERROR_NEED_SECONDARY_ADDRESSES W_ERROR(0x0000258E)
     2442#define WERR_DNS_ERROR_WINS_INIT_FAILED W_ERROR(0x0000258F)
     2443#define WERR_DNS_ERROR_NEED_WINS_SERVERS        W_ERROR(0x00002590)
     2444#define WERR_DNS_ERROR_NBSTAT_INIT_FAILED       W_ERROR(0x00002591)
     2445#define WERR_DNS_ERROR_SOA_DELETE_INVALID       W_ERROR(0x00002592)
     2446#define WERR_DNS_ERROR_FORWARDER_ALREADY_EXISTS W_ERROR(0x00002593)
     2447#define WERR_DNS_ERROR_ZONE_REQUIRES_MASTER_IP  W_ERROR(0x00002594)
     2448#define WERR_DNS_ERROR_ZONE_IS_SHUTDOWN W_ERROR(0x00002595)
     2449#define WERR_DNS_ERROR_PRIMARY_REQUIRES_DATAFILE        W_ERROR(0x000025B3)
     2450#define WERR_DNS_ERROR_INVALID_DATAFILE_NAME    W_ERROR(0x000025B4)
     2451#define WERR_DNS_ERROR_DATAFILE_OPEN_FAILURE    W_ERROR(0x000025B5)
     2452#define WERR_DNS_ERROR_FILE_WRITEBACK_FAILED    W_ERROR(0x000025B6)
     2453#define WERR_DNS_ERROR_DATAFILE_PARSING W_ERROR(0x000025B7)
     2454#define WERR_DNS_ERROR_RECORD_DOES_NOT_EXIST    W_ERROR(0x000025E5)
     2455#define WERR_DNS_ERROR_RECORD_FORMAT    W_ERROR(0x000025E6)
     2456#define WERR_DNS_ERROR_NODE_CREATION_FAILED     W_ERROR(0x000025E7)
     2457#define WERR_DNS_ERROR_UNKNOWN_RECORD_TYPE      W_ERROR(0x000025E8)
     2458#define WERR_DNS_ERROR_RECORD_TIMED_OUT W_ERROR(0x000025E9)
     2459#define WERR_DNS_ERROR_NAME_NOT_IN_ZONE W_ERROR(0x000025EA)
     2460#define WERR_DNS_ERROR_CNAME_LOOP       W_ERROR(0x000025EB)
     2461#define WERR_DNS_ERROR_NODE_IS_CNAME    W_ERROR(0x000025EC)
     2462#define WERR_DNS_ERROR_CNAME_COLLISION  W_ERROR(0x000025ED)
     2463#define WERR_DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT W_ERROR(0x000025EE)
     2464#define WERR_DNS_ERROR_RECORD_ALREADY_EXISTS    W_ERROR(0x000025EF)
     2465#define WERR_DNS_ERROR_SECONDARY_DATA   W_ERROR(0x000025F0)
     2466#define WERR_DNS_ERROR_NO_CREATE_CACHE_DATA     W_ERROR(0x000025F1)
     2467#define WERR_DNS_ERROR_NAME_DOES_NOT_EXIST      W_ERROR(0x000025F2)
     2468#define WERR_DNS_WARNING_PTR_CREATE_FAILED      W_ERROR(0x000025F3)
     2469#define WERR_DNS_WARNING_DOMAIN_UNDELETED       W_ERROR(0x000025F4)
     2470#define WERR_DNS_ERROR_DS_UNAVAILABLE   W_ERROR(0x000025F5)
     2471#define WERR_DNS_ERROR_DS_ZONE_ALREADY_EXISTS   W_ERROR(0x000025F6)
     2472#define WERR_DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE   W_ERROR(0x000025F7)
     2473#define WERR_DNS_INFO_AXFR_COMPLETE     W_ERROR(0x00002617)
     2474#define WERR_DNS_ERROR_AXFR     W_ERROR(0x00002618)
     2475#define WERR_DNS_INFO_ADDED_LOCAL_WINS  W_ERROR(0x00002619)
     2476#define WERR_DNS_STATUS_CONTINUE_NEEDED W_ERROR(0x00002649)
     2477#define WERR_DNS_ERROR_NO_TCPIP W_ERROR(0x0000267B)
     2478#define WERR_DNS_ERROR_NO_DNS_SERVERS   W_ERROR(0x0000267C)
     2479#define WERR_DNS_ERROR_DP_DOES_NOT_EXIST        W_ERROR(0x000026AD)
     2480#define WERR_DNS_ERROR_DP_ALREADY_EXISTS        W_ERROR(0x000026AE)
     2481#define WERR_DNS_ERROR_DP_NOT_ENLISTED  W_ERROR(0x000026AF)
     2482#define WERR_DNS_ERROR_DP_ALREADY_ENLISTED      W_ERROR(0x000026B0)
     2483#define WERR_DNS_ERROR_DP_NOT_AVAILABLE W_ERROR(0x000026B1)
     2484#define WERR_DNS_ERROR_DP_FSMO_ERROR    W_ERROR(0x000026B2)
    23892485#define WERR_IPSEC_QM_POLICY_EXISTS     W_ERROR(0x000032C8)
    23902486#define WERR_IPSEC_QM_POLICY_NOT_FOUND  W_ERROR(0x000032C9)
Note: See TracChangeset for help on using the changeset viewer.