Changeset 745 for trunk/server/libcli


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

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
16 deleted
50 edited
61 copied

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/libcli/auth/credentials.c

    r590 r745  
    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;
  • trunk/server/libcli/auth/credentials.h

    r414 r745  
    6969#define NETLOGON_NEG_AUTH2_ADS_FLAGS (0x200fbffb | NETLOGON_NEG_ARCFOUR | NETLOGON_NEG_128BIT | NETLOGON_NEG_SCHANNEL)
    7070
     71
    7172
  • trunk/server/libcli/auth/msrpc_parse.c

    r414 r745  
    4141  C = constant ascii string
    4242 */
    43 bool msrpc_gen(TALLOC_CTX *mem_ctx,
     43 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
     61
     62
    6063        intargs = talloc_array(pointers, int, strlen(format));
     64
     65
     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 ;
    7682                        }
    7783                        pointers[i].length = n;
     
    8793                        if (!ret) {
    8894                                va_end(ap);
    89                                 return false;
     95                                return ;
    9096                        }
    9197                        pointers[i].length = n;
     
    103109                        if (!ret) {
    104110                                va_end(ap);
    105                                 return false;
     111                                return ;
    106112                        }
    107113                        pointers[i].length = n;
     
    133139                        head_size += pointers[i].length;
    134140                        break;
     141
     142
     143
    135144                }
    136145        }
    137146        va_end(ap);
     147
     148
     149
     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
     204
     205
    185206                }
    186207        }
     
    189210        talloc_free(pointers);
    190211
    191         return true;
     212        return ;
    192213}
    193214
     
    229250        bool ret = true;
    230251
     252
     253
     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, ut);
    337362                        /* make sure its in the right format - be strict */
    338363                        NEED_DATA(len1);
  • trunk/server/libcli/auth/msrpc_parse.h

    r414 r745  
     1
     2
     3
     4
     5
     6
     7
     8
     9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     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,
     35 msrpc_gen(TALLOC_CTX *mem_ctx,
    1536               DATA_BLOB *blob,
    1637               const char *format, ...);
  • trunk/server/libcli/auth/ntlm_check.c

    r414 r745  
    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, becuse 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,
  • trunk/server/libcli/auth/proto.h

    r590 r745  
    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], uint8_t in[16], const uint8_t key[14], int forw);
     198void sam_rid_crypt(ut rid, const uint8_t *in, uint8_t *out, int forw);
    199199#undef _PRINTF_ATTRIBUTE
    200200#define _PRINTF_ATTRIBUTE(a1, a2)
  • trunk/server/libcli/auth/schannel_proto.h

    r414 r745  
    2424#define _LIBCLI_AUTH_SCHANNEL_PROTO_H__
    2525
     26
     27
     28
     29
     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);
     36
    3137NTSTATUS netsec_outgoing_packet(struct schannel_state *state,
    3238                                TALLOC_CTX *mem_ctx,
  • trunk/server/libcli/auth/schannel_sign.c

    r414 r745  
    205205}
    206206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
    207221NTSTATUS netsec_outgoing_packet(struct schannel_state *state,
    208222                                TALLOC_CTX *mem_ctx,
  • trunk/server/libcli/auth/schannel_state.h

    r414 r745  
    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
  • trunk/server/libcli/auth/schannel_state_tdb.c

    r414 r745  
    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
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     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, 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)));
    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
    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(0,("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,
    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
    139187
    140188        if (!NT_STATUS_IS_OK(status)) {
     
    148196}
    149197
     198
     199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
     222
     223
     224
     225
     226
     227
     228
     229
     230
     231
     232
     233
     234
     235
     236
     237
     238
     239
     240
     241
     242
     243
     244
     245
     246
     247
     248
     249
     250
     251
     252
     253
     254
     255
     256
     257
     258
     259
     260
     261
     262
     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_c,
     276                                ,
     277                                    const char *computer_name,
     278                                ,
     279                                ,
     280                               
     281{
     282       
     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
  • trunk/server/libcli/auth/smbdes.c

    r414 r745  
    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], 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(ut rid, const uint8_t *in, uint8_t *out, int forw)
    371371{
    372372        uint8_t s[14];
  • trunk/server/libcli/auth/smbencrypt.c

    r414 r745  
    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        size_t new_pw_len;
    533535
    534536        /* the incoming buffer can be any alignment. */
     
    538540                                 password,
    539541                                 sizeof(new_pw), string_flags);
     542
     543
     544
    540545
    541546        memcpy(&buffer[512 - new_pw_len], new_pw, new_pw_len);
  • trunk/server/libcli/auth/spnego.h

    r414 r745  
    2626#define OID_KERBEROS5 "1.2.840.113554.1.2.2"
    2727
     28
     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
     39
     40
     41
     42
    3543
    3644enum spnego_negResult {
  • trunk/server/libcli/auth/spnego_parse.c

    r480 r745  
    5050                        for (i = 0; !asn1->has_error &&
    5151                                     0 < asn1_tag_remaining(asn1); i++) {
     52
    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
    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
     388
     389
     390
    383391        /* Write mechTypes */
    384392        if (mech_types && *mech_types) {
  • trunk/server/libcli/cldap/cldap.c

    r414 r745  
    168168}
    169169
    170 static void cldap_socket_recv_dgram(struct cldap_socket *c,
     170static 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
    179180
    180181        c->recv_subreq = NULL;
     
    200201
    201202        /* this function should free or steal 'in' */
    202         cldap_socket_recv_dgram(c, in);
     203        cldap_socket_recv_dgram(c, in);
    203204        in = NULL;
    204205
    205         if (!cldap_recvfrom_setup(c)) {
     206        if (!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 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;
    266267        }
    267268
     
    271272        search->response.asn1->ofs = 0;
    272273
     274
     275
     276
     277
     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
    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)) {
  • trunk/server/libcli/cldap/cldap.h

    r414 r745  
    2020*/
    2121
    22 #include "../libcli/netlogon.h"
     22#include "../libcli/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,
  • trunk/server/libcli/drsuapi/repl_decrypt.c

    r414 r745  
    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_ATT_dBCSPwd:
     150        case DRSUAPI_ATT_unicodePwd:
     151        case DRSUAPI_ATT_ntPwdHistory:
     152        case DRSUAPI_ATT_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_ATT_supplementalCredentials:
     156        case DRSUAPI_ATT_priorValue:
     157        case DRSUAPI_ATT_currentValue:
     158        case DRSUAPI_ATT_trustAuthOutgoing:
     159        case DRSUAPI_ATT_trustAuthIncoming:
     160        case DRSUAPI_ATT_initialAuthOutgoing:
     161        case DRSUAPI_ATT_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_ATT_dBCSPwd:
     312        case DRSUAPI_ATT_unicodePwd:
     313        case DRSUAPI_ATT_ntPwdHistory:
     314        case DRSUAPI_ATT_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_ATT_supplementalCredentials:
     318        case DRSUAPI_ATT_priorValue:
     319        case DRSUAPI_ATT_currentValue:
     320        case DRSUAPI_ATT_trustAuthOutgoing:
     321        case DRSUAPI_ATT_trustAuthIncoming:
     322        case DRSUAPI_ATT_initialAuthOutgoing:
     323        case DRSUAPI_ATT_initialAuthIncoming:
    324324                break;
    325325        default:
  • trunk/server/libcli/ldap/ldap_message.c

    r414 r745  
    168168
    169169        for (i = 0; handlers[i].oid != NULL; i++) {
     170
     171
     172
     173
     174
     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
     444
    437445                break;
    438446        }
     
    669677                                                 control_handlers,
    670678                                                 msg->controls[i])) {
     679
     680
    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}
  • trunk/server/libcli/ldap/ldap_message.h

    r414 r745  
    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 {
  • trunk/server/libcli/ldap/ldap_ndr.c

    r414 r745  
    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, struct GUID *guid)
    6569{
    6670        DATA_BLOB blob;
    67         enum ndr_err_code ndr_err;
     71        ;
    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);
  • trunk/server/libcli/ldap/ldap_ndr.h

    r414 r745  
     1
     2
     3
     4
     5
     6
     7
     8
     9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     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, struct GUID *guid);
    931NTSTATUS ldap_decode_ndr_GUID(TALLOC_CTX *mem_ctx, struct ldb_val val, struct GUID *guid);
    1032
  • trunk/server/libcli/named_pipe_auth/npa_tstream.c

    r414 r745  
    2525#include "../librpc/gen_ndr/ndr_named_pipe_auth.h"
    2626#include "../libcli/named_pipe_auth/npa_tstream.h"
     27
    2728#include "libcli/raw/smb.h"
     29
    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
     77
    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 = 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 = ;
    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
     412
    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 = 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 = 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 = pbase;
    606589                        }
    607590                        pbase = NULL;
     
    691674                }
    692675                ZERO_STRUCT(state->hdr);
    693                 vector[0].iov_base = state->hdr;
     676                vector[0].iov_base = 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 = 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 = 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 i 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, , left);
    752735                if (!npas->pending.iov_base) {
    753736                        return -1;
     
    809792
    810793        /* the header for message mode */
     794
    811795        uint8_t hdr[2];
    812796
     
    845829        switch (npas->file_type) {
    846830        case FILE_TYPE_BYTE_MODE_PIPE:
     831
    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 = state->hdr;
    861846                new_vector[0].iov_len = sizeof(state->hdr);
    862847                memcpy(new_vector + 1, vector, sizeof(struct iovec)*count);
    863848
     849
    864850                state->vector   = new_vector;
    865851                state->count    = count + 1;
     
    910896                tevent_req_error(req, sys_errno);
    911897                return;
     898
     899
     900
     901
     902
     903
     904
     905
    912906        }
    913907
     
    10701064}
    10711065
     1066
     1067
     1068
     1069
     1070
     1071
     1072
     1073
     1074
     1075
     1076
     1077
     1078
     1079
     1080
     1081
     1082
     1083
     1084
     1085
     1086
     1087
     1088
     1089
     1090
     1091
     1092
     1093
     1094
     1095
     1096
     1097
     1098
     1099
     1100
     1101
     1102
     1103
     1104
     1105
     1106
     1107
     1108
     1109
     1110
     1111
     1112
     1113
     1114
     1115
     1116
     1117
     1118
     1119
     1120
     1121
     1122
     1123
     1124
     1125
     1126
     1127
     1128
     1129
     1130
     1131
     1132
     1133
     1134
     1135
     1136
     1137
     1138
     1139
     1140
     1141
     1142
     1143
     1144
     1145
     1146
     1147
     1148
     1149
     1150
     1151
     1152
     1153
     1154
     1155
     1156
     1157
     1158
     1159
     1160
     1161
     1162
     1163
     1164
     1165
     1166
     1167
     1168
     1169
     1170
     1171
     1172
     1173
     1174
     1175
     1176
     1177
     1178
     1179
     1180
     1181
     1182
     1183
     1184
     1185
     1186
     1187
     1188
     1189
     1190
     1191
     1192
     1193
     1194
     1195
     1196
     1197
     1198
     1199
     1200
     1201
     1202
     1203
     1204
     1205
     1206
     1207
     1208
     1209
     1210
     1211
     1212
     1213
     1214
     1215
     1216
     1217
     1218
     1219
     1220
     1221
     1222
     1223
     1224
     1225
     1226
     1227
     1228
     1229
     1230
     1231
     1232
     1233
     1234
     1235
     1236
     1237
     1238
     1239
     1240
     1241
     1242
     1243
     1244
     1245
     1246
     1247
     1248
     1249
     1250
     1251
     1252
     1253
     1254
     1255
     1256
     1257
     1258
     1259
     1260
     1261
     1262
     1263
     1264
     1265
     1266
     1267
     1268
     1269
     1270
     1271
     1272
     1273
     1274
     1275
     1276
     1277
     1278
     1279
     1280
     1281
     1282
     1283
     1284
     1285
     1286
     1287
     1288
     1289
     1290
     1291
     1292
     1293
     1294
     1295
     1296
     1297
     1298
     1299
     1300
     1301
     1302
     1303
     1304
     1305
     1306
     1307
     1308
     1309
     1310
     1311
     1312
     1313
     1314
     1315
     1316
     1317
     1318
     1319
     1320
     1321
     1322
     1323
     1324
     1325
     1326
     1327
     1328
     1329
     1330
     1331
     1332
     1333
     1334
     1335
     1336
     1337
     1338
     1339
     1340
     1341
     1342
     1343
     1344
     1345
     1346
     1347
     1348
     1349
     1350
     1351
     1352
     1353
     1354
     1355
     1356
     1357
     1358
     1359
     1360
     1361
     1362
     1363
     1364
     1365
     1366
     1367
     1368
     1369
     1370
     1371
     1372
     1373
     1374
     1375
     1376
     1377
     1378
     1379
     1380
     1381
     1382
     1383
     1384
     1385
     1386
     1387
     1388
     1389
     1390
     1391
     1392
     1393
     1394
     1395
     1396
     1397
     1398
     1399
     1400
     1401
     1402
     1403
     1404
     1405
     1406
     1407
     1408
     1409
     1410
     1411
     1412
     1413
     1414
     1415
     1416
     1417
     1418
     1419
     1420
     1421
     1422
     1423
     1424
     1425
     1426
     1427
     1428
     1429
     1430
     1431
     1432
     1433
     1434
     1435
     1436
     1437
     1438
     1439
     1440
     1441
     1442
     1443
     1444
     1445
     1446
  • trunk/server/libcli/named_pipe_auth/npa_tstream.h

    r414 r745  
    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
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
     113
     114
     115
     116
     117
     118
     119
    60120#endif /* NPA_TSTREAM_H */
  • trunk/server/libcli/nbt/libnbt.h

    r414 r745  
    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
     369
     370
     371
     372
     373
     374
     375
     376
     377
     378
     379
     380
    363381#endif /* __LIBNBT_H__ */
  • trunk/server/libcli/nbt/lmhosts.c

    r414 r745  
    2727#include "system/filesys.h"
    2828#include "system/network.h"
     29
    2930
    3031/********************************************************
     
    156157}
    157158
     159
     160
     161
     162
     163
     164
     165
     166
     167
     168
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
     184
     185
     186
     187
     188
     189
     190
     191
     192
     193
     194
     195
     196
     197
     198
     199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
     222
     223
     224
     225
     226
     227
     228
     229
     230
     231
     232
     233
     234
     235
     236
     237
  • trunk/server/libcli/nbt/man/nmblookup.1.xml

    r414 r745  
    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 "-//">
    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>
  • trunk/server/libcli/nbt/namerefresh.c

    r414 r745  
    2121
    2222#include "includes.h"
     23
    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
    2728
    2829/*
     
    143144  reply for each address
    144145*/
    145 struct refresh_wins_state {
     146struct 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}
  • trunk/server/libcli/nbt/nameregister.c

    r414 r745  
    2121
    2222#include "includes.h"
     23
    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
    2829
    2930/*
     
    149150  a name registration demand
    150151*/
    151 struct register_bcast_state {
     152struct 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 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
     316
     317
     318
     319
     320
     321
     322
     323
     324
     325
     326
     327
     328
     329
     330
     331
     332
     333
     334
     335
     336
     337
     338
     339
     340
     341
     342
     343
     344
     345
     346
     347
     348
     349
     350
     351
     352
     353
     354
     355
     356
     357
     358
     359
     360
     361
     362
     363
     364
     365
     366
     367
     368
     369
     370
     371
     372
     373
     374
     375
     376
     377
     378
     379
     380
     381
     382
     383
     384
     385
     386
     387
     388
     389
     390
     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
     411
     412
     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}
  • trunk/server/libcli/nbt/nbt_proto.h

    r414 r745  
     1
     2
     3
     4
     5
     6
     7
     8
     9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
    122#ifndef _____LIBCLI_NBT_NBT_PROTO_H__
    223#define _____LIBCLI_NBT_NBT_PROTO_H__
  • trunk/server/libcli/nbt/nbtname.c

    r596 r745  
    2828#include "librpc/gen_ndr/ndr_misc.h"
    2929#include "system/locale.h"
     30
    3031
    3132/* don't allow an unlimited number of name components */
     
    4950{
    5051        uint8_t len;
    51         uint_t loops = 0;
     52        ut 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] > 0x00003F",
    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
     524
     525
     526
     527
     528
     529
     530
     531
     532
     533
     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 > 1) {
     565                r->scope = talloc_strndup(r, (char *)(namebuf+1), 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
     635
     636
     637
     638
     639
     640
     641
     642
     643
     644
    619645
    620646        talloc_free(namebuf);
  • trunk/server/libcli/nbt/nbtsocket.c

    r414 r745  
    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 = ;
    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);
  • trunk/server/libcli/nbt/pynbt.c

    r414 r745  
    1818*/
    1919
     20
    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
     27
     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;
     33 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()
     42{
     43        talloc_free(->mem_ctx);
     44        );
    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 = py_nbt_node_dealloc,
    397399        .tp_methods = py_nbt_methods,
    398400        .tp_doc = "Node()\n"
  • trunk/server/libcli/nbt/tools/nmblookup.c

    r414 r745  
    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, lp_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, lp_nbt_port(cmdline_lp_ctx));
    368368        }
    369369
  • trunk/server/libcli/samsync/decrypt.c

    r414 r745  
    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)) {
  • trunk/server/libcli/samsync/samsync.h

    r414 r745  
    2323#define __SAMSYNC_SAMSYNC_H__
    2424
     25
     26
    2527/**
    2628 * Fix up the delta, dealing with encryption issues so that the final
  • trunk/server/libcli/security/display_sec.c

    r414 r745  
    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
    2625
    2726/****************************************************************************
     
    160159static void disp_sec_ace_object(struct security_ace_object *object)
    161160{
     161
    162162        if (object->flags & SEC_ACE_OBJECT_TYPE_PRESENT) {
     163
     164
    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",
     167                );
    166168        }
    167169        if (object->flags & SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT) {
     170
     171
    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",
     174                );
    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        t i;
     238
     239        printf("\tACL\tNum ACEs:\t%\trevision:\t%x\n",
    236240                         sec_acl->num_aces, sec_acl->revision);
    237241        printf("\t---\n");
  • trunk/server/libcli/security/dom_sid.c

    r583 r745  
    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 = _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       
     302                talloc_free(sid);
     303        ;
     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(len, "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(, "-%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}
  • trunk/server/libcli/security/dom_sid.h

    r583 r745  
    2626#include "librpc/gen_ndr/security.h"
    2727
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
    2857int dom_sid_compare(const struct dom_sid *sid1, const struct dom_sid *sid2);
     58
     59
    2960bool dom_sid_equal(const struct dom_sid *sid1, const struct dom_sid *sid2);
     61
     62
     63
     64
    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
     78
    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_*/
  • trunk/server/libcli/security/secace.c

    r414 r745  
    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, 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, 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, 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, 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( 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( 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( 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        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
  • trunk/server/libcli/security/secace.h

    r414 r745  
    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, 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, struct dom_sid *sid, uint32_t mask);
     31NTSTATUS sec_ace_mod_sid(struct security_ace *ace, size_t num, 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, struct dom_sid *sid);
     33bool sec_ace_equal( struct security_ace *s2);
     34int nt_ace_inherit_comp( struct security_ace *a2);
     35int nt_ace_canon_comp( struct security_ace *a2);
    3636void dacl_sort_into_canonical_order(struct security_ace *srclist, unsigned int num_aces);
    3737
  • trunk/server/libcli/security/secacl.c

    r414 r745  
    2424#include "librpc/gen_ndr/ndr_security.h"
    2525#include "libcli/security/secace.h"
     26
    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 }
  • trunk/server/libcli/security/secacl.h

    r414 r745  
    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
  • trunk/server/libcli/security/security_descriptor.c

    r414 r745  
    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
     58
     59
     60
    5861        nacl = talloc (mem_ctx, struct security_acl);
    5962        if (nacl == NULL) {
     
    8386{
    8487        struct security_acl *nacl;
    85         int i;
     88        t i;
    8689
    8790        if (!acl1 && !acl2)
     
    268271                                            const struct dom_sid *trustee)
    269272{
    270         int i;
     273        t i;
    271274        bool found = false;
    272275        struct security_acl *acl = NULL;
     
    362365                        const struct security_acl *acl2)
    363366{
    364         int i;
     367        t i;
    365368
    366369        if (acl1 == acl2) return true;
  • trunk/server/libcli/security/security_descriptor.h

    r414 r745  
    6969                                              const struct security_acl *acl2);
    7070
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
    7184#endif /* __SECURITY_DESCRIPTOR_H__ */
  • trunk/server/libcli/smb/smb2_constants.h

    r414 r745  
    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
     42
    4043
    4144/* header flags */
     
    8285#define SMB2_CAP_DFS                     0x00000001
    8386#define SMB2_CAP_LEASING                 0x00000002 /* only in dialect 0x210 */
     87
    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
     96
     97
     98
    9099
    91100/* SMB2 share flags */
     
    101110#define SMB2_SHAREFLAG_ACCESS_BASED_DIRECTORY_ENUM       0x0800
    102111#define SMB2_SHAREFLAG_ALL                               0x0F33
     112
     113
     114
    103115
    104116/* SMB2 create security flags */
     
    173185#define SMB2_GETINFO_QUOTA              0x04
    174186
     187
     188
    175189#endif
  • trunk/server/libcli/smbreadline/smbreadline.c

    r741 r745  
    100100                        return ret;
    101101                }
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
     126
     127
     128
     129
     130
     131
     132
     133
     134
     135
     136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
     149
     150
    102151                if (callback) {
    103152                        callback();
  • trunk/server/libcli/util/doserr.c

    r414 r745  
    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
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
     184
     185
     186
     187
     188
     189
     190
     191
     192
     193
     194
     195
     196
     197
     198
     199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
     222
     223
     224
     225
     226
     227
     228
     229
     230
     231
     232
     233
     234
     235
     236
     237
     238
     239
     240
     241
     242
     243
     244
     245
     246
     247
     248
     249
     250
     251
     252
     253
     254
     255
     256
     257
     258
     259
     260
     261
     262
    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_YNTAX, "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
     4948
     4949
     4950
     4951
     4952
     4953
     4954
     4955
     4956
     4957
     4958
     4959
     4960
     4961
     4962
     4963
     4964
     4965
     4966
     4967
     4968
     4969
     4970
     4971
     4972
     4973
     4974
     4975
     4976
     4977
     4978
     4979
     4980
     4981
     4982
     4983
     4984
     4985
     4986
     4987
     4988
     4989
     4990
     4991
     4992
     4993
     4994
     4995
     4996
     4997
     4998
     4999
     5000
     5001
     5002
     5003
     5004
     5005
     5006
     5007
     5008
     5009
     5010
     5011
     5012
     5013
     5014
     5015
     5016
     5017
     5018
     5019
     5020
     5021
     5022
     5023
     5024
     5025
     5026
     5027
     5028
     5029
     5030
     5031
     5032
     5033
     5034
     5035
     5036
     5037
     5038
     5039
     5040
    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." },
  • trunk/server/libcli/util/error.h

    r414 r745  
    4747NTSTATUS map_nt_error_from_unix(int unix_error);
    4848
     49
     50
     51
     52
     53
     54
     55
    4956#endif /* _SAMBA_ERROR_H */
  • trunk/server/libcli/util/ntstatus.h

    r456 r745  
    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/>.
     
    3030*/
    3131
    32 #if defined(HAVE_IMMEDIATE_STRUCTURES) && !defined(__OS2__)
     32#if defined(HAVE_IMMEDIATE_STRUCTURES) && !defined(__OS2__)
    3333typedef struct {uint32_t v;} NTSTATUS;
    3434#define NT_STATUS(x) ((NTSTATUS) { x })
     
    602602#define NT_STATUS_NO_SUCH_JOB NT_STATUS(0xC0000000 | 0xEDE) /* scheduler */
    603603#define NT_STATUS_DOWNGRADE_DETECTED NT_STATUS(0xC0000000 | 0x0388)
     604
     605
    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
     655
     656
     657
     658
     659
     660
    639661
    640662#define NT_STATUS_IS_OK(x) (likely(NT_STATUS_V(x) == 0))
     
    675697} while (0)
    676698
     699
     700
     701
     702
     703
     704
     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 */
  • trunk/server/libcli/util/werror.h

    r456 r745  
    3030*/
    3131
    32 #if defined(HAVE_IMMEDIATE_STRUCTURES) && !defined(__OS2__)
     32#if defined(HAVE_IMMEDIATE_STRUCTURES) && !defined(__OS2__)
    3333typedef struct {uint32_t v;} WERROR;
    3434#define W_ERROR(x) ((WERROR) { x })
     
    4545#define W_ERROR_HAVE_NO_MEMORY(x) do { \
    4646        if (!(x)) {\
     47
     48
     49
     50
     51
     52
     53
    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
     2021
     2022
     2023
    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
     2032
     2033
    20722034#define WERR_DS_SIZELIMIT_EXCEEDED      W_ERROR(0x00002023)
     2035
     2036
     2037
     2038
     2039
     2040
    20732041#define WERR_DS_AUTH_UNKNOWN    W_ERROR(0x0000202A)
     2042
     2043
     2044
     2045
     2046
     2047
     2048
     2049
    20742050#define WERR_DS_IS_LEAF W_ERROR(0x00002033)
     2051
     2052
     2053
     2054
    20752055#define WERR_DS_OBJECT_RESULTS_TOO_LARGE        W_ERROR(0x00002038)
     2056
    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
    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
    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
    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
    21252110#define WERR_DS_DSA_MUST_BE_INT_MASTER  W_ERROR(0x00002096)
    21262111#define WERR_DS_CLASS_NOT_DSA   W_ERROR(0x00002097)
     2112
    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
     2182
     2183
    21952184#define WERR_DS_GCVERIFY_ERROR  W_ERROR(0x000020E1)
     2185
    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
    22142205#define WERR_DS_DRA_BUSY        W_ERROR(0x000020F6)
     2206
     2207
    22152208#define WERR_DS_DRA_DN_EXISTS   W_ERROR(0x000020F9)
     2209
    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
    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
     2219
     2220
    22232221#define WERR_DS_DRA_NOT_SUPPORTED       W_ERROR(0x00002106)
    22242222#define WERR_DS_DRA_RPC_CANCELLED       W_ERROR(0x00002107)
     2223
    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
    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
     2360
    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
     2392
     2393
     2394
     2395
     2396
     2397
     2398
     2399
     2400
     2401
     2402
     2403
     2404
     2405
     2406
     2407
     2408
     2409
     2410
     2411
     2412
     2413
     2414
     2415
     2416
     2417
     2418
     2419
     2420
     2421
     2422
     2423
     2424
     2425
     2426
     2427
     2428
     2429
     2430
     2431
     2432
     2433
     2434
     2435
     2436
     2437
     2438
     2439
     2440
     2441
     2442
     2443
     2444
     2445
     2446
     2447
     2448
     2449
     2450
     2451
     2452
     2453
     2454
     2455
     2456
     2457
     2458
     2459
     2460
     2461
     2462
     2463
     2464
     2465
     2466
     2467
     2468
     2469
     2470
     2471
     2472
     2473
     2474
     2475
     2476
     2477
     2478
     2479
     2480
     2481
     2482
     2483
     2484
    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.