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

Samba Server: update vendor to 3.6.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified vendor/current/source4/torture/rpc/lsa_lookup.c

    r414 r740  
    2020
    2121#include "includes.h"
    22 #include "torture/torture.h"
    23 #include "lib/events/events.h"
    24 #include "libnet/libnet_join.h"
    25 #include "torture/rpc/rpc.h"
     22#include "torture/rpc/torture_rpc.h"
    2623#include "librpc/gen_ndr/ndr_lsa_c.h"
    2724#include "libcli/security/security.h"
    2825
    29 static bool open_policy(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
     26static bool open_policy(struct torture_context *tctx,
     27                        struct dcerpc_binding_handle *b,
    3028                        struct policy_handle **handle)
    3129{
     
    3331        struct lsa_QosInfo qos;
    3432        struct lsa_OpenPolicy2 r;
    35         NTSTATUS status;
    36 
    37         *handle = talloc(mem_ctx, struct policy_handle);
     33
     34        *handle = talloc(tctx, struct policy_handle);
    3835        if (!*handle) {
    3936                return false;
     
    5754        r.out.handle = *handle;
    5855
    59         status = dcerpc_lsa_OpenPolicy2(p, mem_ctx, &r);
    60 
    61         return NT_STATUS_IS_OK(status);
    62 }
    63 
    64 static bool get_domainsid(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
     56        torture_assert_ntstatus_ok(tctx, dcerpc_lsa_OpenPolicy2_r(b, tctx, &r),
     57                "OpenPolicy2 failed");
     58
     59        return NT_STATUS_IS_OK(r.out.result);
     60}
     61
     62static bool get_domainsid(struct torture_context *tctx,
     63                          struct dcerpc_binding_handle *b,
    6564                          struct policy_handle *handle,
    6665                          struct dom_sid **sid)
     
    6867        struct lsa_QueryInfoPolicy r;
    6968        union lsa_PolicyInformation *info = NULL;
    70         NTSTATUS status;
    7169
    7270        r.in.level = LSA_POLICY_INFO_DOMAIN;
     
    7472        r.out.info = &info;
    7573
    76         status = dcerpc_lsa_QueryInfoPolicy(p, mem_ctx, &r);
    77         if (!NT_STATUS_IS_OK(status)) return false;
     74        torture_assert_ntstatus_ok(tctx, dcerpc_lsa_QueryInfoPolicy_r(b, tctx, &r),
     75                "QueryInfoPolicy failed");
     76        torture_assert_ntstatus_ok(tctx, r.out.result, "QueryInfoPolicy failed");
    7877
    7978        *sid = info->domain.sid;
     
    8180}
    8281
    83 static NTSTATUS lookup_sids(TALLOC_CTX *mem_ctx, uint16_t level,
    84                             struct dcerpc_pipe *p,
     82static NTSTATUS lookup_sids(struct torture_context *tctx,
     83                            uint16_t level,
     84                            struct dcerpc_binding_handle *b,
    8585                            struct policy_handle *handle,
    8686                            struct dom_sid **sids, uint32_t num_sids,
     
    9292        uint32_t count = 0;
    9393        uint32_t i;
     94        NTSTATUS status;
    9495
    9596        names->count = 0;
     
    9798
    9899        sidarray.num_sids = num_sids;
    99         sidarray.sids = talloc_array(mem_ctx, struct lsa_SidPtr, num_sids);
     100        sidarray.sids = talloc_array(tctx, struct lsa_SidPtr, num_sids);
    100101
    101102        for (i=0; i<num_sids; i++) {
     
    112113        r.out.domains = &domains;
    113114
    114         return dcerpc_lsa_LookupSids(p, mem_ctx, &r);
    115 }
    116 
    117 static const char *sid_type_lookup(enum lsa_SidType r)
    118 {
    119         switch (r) {
    120                 case SID_NAME_USE_NONE: return "SID_NAME_USE_NONE"; break;
    121                 case SID_NAME_USER: return "SID_NAME_USER"; break;
    122                 case SID_NAME_DOM_GRP: return "SID_NAME_DOM_GRP"; break;
    123                 case SID_NAME_DOMAIN: return "SID_NAME_DOMAIN"; break;
    124                 case SID_NAME_ALIAS: return "SID_NAME_ALIAS"; break;
    125                 case SID_NAME_WKN_GRP: return "SID_NAME_WKN_GRP"; break;
    126                 case SID_NAME_DELETED: return "SID_NAME_DELETED"; break;
    127                 case SID_NAME_INVALID: return "SID_NAME_INVALID"; break;
    128                 case SID_NAME_UNKNOWN: return "SID_NAME_UNKNOWN"; break;
    129                 case SID_NAME_COMPUTER: return "SID_NAME_COMPUTER"; break;
    130         }
    131         return "Invalid sid type\n";
    132 }
    133 
    134 static bool test_lookupsids(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
     115        status = dcerpc_lsa_LookupSids_r(b, tctx, &r);
     116        if (!NT_STATUS_IS_OK(status)) {
     117                return status;
     118        }
     119        return r.out.result;
     120}
     121
     122static bool test_lookupsids(struct torture_context *tctx,
     123                            struct dcerpc_binding_handle *b,
    135124                            struct policy_handle *handle,
    136125                            struct dom_sid **sids, uint32_t num_sids,
     
    143132        bool ret = true;
    144133
    145         status = lookup_sids(mem_ctx, level, p, handle, sids, num_sids,
     134        status = lookup_sids(tctx, level, b, handle, sids, num_sids,
    146135                             &names);
    147136        if (!NT_STATUS_EQUAL(status, expected_result)) {
     
    161150                        printf("In level %d, for sid %s expected %s, "
    162151                               "got %s\n", level,
    163                                dom_sid_string(mem_ctx, sids[i]),
     152                               dom_sid_string(tctx, sids[i]),
    164153                               sid_type_lookup(types[i]),
    165154                               sid_type_lookup(names.names[i].sid_type));
     
    170159}
    171160
    172 static bool get_downleveltrust(struct torture_context *tctx, struct dcerpc_pipe *p,
     161static bool get_downleveltrust(struct torture_context *tctx, struct dcerpc_binding_handle *b,
    173162                               struct policy_handle *handle,
    174163                               struct dom_sid **sid)
     
    177166        uint32_t resume_handle = 0;
    178167        struct lsa_DomainList domains;
    179         NTSTATUS status;
    180168        int i;
    181169
     
    186174        r.out.resume_handle = &resume_handle;
    187175
    188         status = dcerpc_lsa_EnumTrustDom(p, tctx, &r);
    189 
    190         if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES))
     176        torture_assert_ntstatus_ok(tctx, dcerpc_lsa_EnumTrustDom_r(b, tctx, &r),
     177                "EnumTrustDom failed");
     178
     179        if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_NO_MORE_ENTRIES))
    191180                torture_fail(tctx, "no trusts");
    192181
     
    207196                q.out.info = &info;
    208197
    209                 status = dcerpc_lsa_QueryTrustedDomainInfoBySid(p, tctx, &q);
    210                 if (!NT_STATUS_IS_OK(status)) continue;
     198                torture_assert_ntstatus_ok(tctx, dcerpc_lsa_QueryTrustedDomainInfoBySid_r(b, tctx, &q),
     199                        "QueryTrustedDomainInfoBySid failed");
     200                if (!NT_STATUS_IS_OK(q.out.result)) continue;
    211201
    212202                if ((info->info_ex.trust_direction & 2) &&
     
    228218        bool ret = true;
    229219        struct policy_handle *handle;
    230         struct dom_sid *dom_sid;
    231         struct dom_sid *trusted_sid;
     220        struct dom_sid *dom_sid = NULL;
     221        struct dom_sid *trusted_sid = NULL;
    232222        struct dom_sid *sids[NUM_SIDS];
     223        struct dcerpc_binding_handle *b;
    233224
    234225        status = torture_rpc_connection(torture, &p, &ndr_table_lsarpc);
     
    236227                torture_fail(torture, "unable to connect to table");
    237228        }
    238 
    239         ret &= open_policy(torture, p, &handle);
     229        b = p->binding_handle;
     230
     231        ret &= open_policy(torture, b, &handle);
    240232        if (!ret) return false;
    241233
    242         ret &= get_domainsid(torture, p, handle, &dom_sid);
     234        ret &= get_domainsid(torture, b, handle, &dom_sid);
    243235        if (!ret) return false;
    244236
    245         ret &= get_downleveltrust(torture, p, handle, &trusted_sid);
     237        ret &= get_downleveltrust(torture, b, handle, &trusted_sid);
    246238        if (!ret) return false;
    247239
     
    258250        sids[7] = dom_sid_add_rid(torture, trusted_sid, 512);
    259251
    260         ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 0,
     252        ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 0,
    261253                               NT_STATUS_INVALID_PARAMETER, NULL);
    262254
     
    267259                          SID_NAME_DOMAIN, SID_NAME_DOM_GRP };
    268260
    269                 ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 1,
     261                ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 1,
    270262                                       NT_STATUS_OK, types);
    271263        }
     
    277269                          SID_NAME_DOMAIN, SID_NAME_DOM_GRP,
    278270                          SID_NAME_DOMAIN, SID_NAME_DOM_GRP };
    279                 ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 2,
     271                ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 2,
    280272                                       STATUS_SOME_UNMAPPED, types);
    281273        }
     
    287279                          SID_NAME_DOMAIN, SID_NAME_DOM_GRP,
    288280                          SID_NAME_UNKNOWN, SID_NAME_UNKNOWN };
    289                 ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 3,
     281                ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 3,
    290282                                       STATUS_SOME_UNMAPPED, types);
    291283        }
     
    297289                          SID_NAME_DOMAIN, SID_NAME_DOM_GRP,
    298290                          SID_NAME_UNKNOWN, SID_NAME_UNKNOWN };
    299                 ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 4,
     291                ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 4,
    300292                                       STATUS_SOME_UNMAPPED, types);
    301293        }
    302294
    303         ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 5,
     295        ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 5,
    304296                               NT_STATUS_NONE_MAPPED, NULL);
    305297
     
    310302                          SID_NAME_DOMAIN, SID_NAME_DOM_GRP,
    311303                          SID_NAME_UNKNOWN, SID_NAME_UNKNOWN };
    312                 ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 6,
     304                ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 6,
    313305                                       STATUS_SOME_UNMAPPED, types);
    314306        }
    315307
    316         ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 7,
     308        ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 7,
    317309                               NT_STATUS_INVALID_PARAMETER, NULL);
    318         ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 8,
     310        ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 8,
    319311                               NT_STATUS_INVALID_PARAMETER, NULL);
    320         ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 9,
     312        ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 9,
    321313                               NT_STATUS_INVALID_PARAMETER, NULL);
    322         ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 10,
     314        ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 10,
    323315                               NT_STATUS_INVALID_PARAMETER, NULL);
    324316
     
    341333
    342334        uint32_t i;
    343         NTSTATUS status;
    344335        const char *dom_sid = "S-1-5-21-1111111111-2222222222-3333333333";
    345336        const char *dom_admin_sid;
    346 
    347         if (!open_policy(tctx, p, &handle)) {
     337        struct dcerpc_binding_handle *b = p->binding_handle;
     338
     339        if (!open_policy(tctx, b, &handle)) {
    348340                return false;
    349341        }
     
    374366        r.out.domains   = &domains;
    375367
    376         status = dcerpc_lsa_LookupSids(p, tctx, &r);
    377 
    378         torture_assert_ntstatus_equal(tctx, status, NT_STATUS_NONE_MAPPED,
     368        torture_assert_ntstatus_ok(tctx, dcerpc_lsa_LookupSids_r(b, tctx, &r),
     369                "LookupSids failed");
     370
     371        torture_assert_ntstatus_equal(tctx, r.out.result, NT_STATUS_NONE_MAPPED,
    379372                "unexpected error code");
    380373
     
    405398        struct torture_rpc_tcase *tcase;
    406399
    407         suite = torture_suite_create(mem_ctx, "LSA-LOOKUPSIDS");
     400        suite = torture_suite_create(mem_ctx, "lsa.lookupsids");
    408401        tcase = torture_suite_add_rpc_iface_tcase(suite, "lsa",
    409402                                                  &ndr_table_lsarpc);
Note: See TracChangeset for help on using the changeset viewer.