Ignore:
Timestamp:
Jul 2, 2011, 3:35:33 PM (14 years ago)
Author:
Herwig Bauernfeind
Message:

Samba 3.5: Update trunk to 3.5.8

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/source3/rpc_client/cli_netlogon.c

    r414 r596  
    284284}
    285285
     286#define COPY_LSA_STRING(mem_ctx, in, out, name) do { \
     287        if (in->name.string) { \
     288                out->name.string = talloc_strdup(mem_ctx, in->name.string); \
     289                NT_STATUS_HAVE_NO_MEMORY(out->name.string); \
     290        } \
     291} while (0)
     292
     293static NTSTATUS copy_netr_SamBaseInfo(TALLOC_CTX *mem_ctx,
     294                                      const struct netr_SamBaseInfo *in,
     295                                      struct netr_SamBaseInfo *out)
     296{
     297        /* first copy all, then realloc pointers */
     298        *out = *in;
     299
     300        COPY_LSA_STRING(mem_ctx, in, out, account_name);
     301        COPY_LSA_STRING(mem_ctx, in, out, full_name);
     302        COPY_LSA_STRING(mem_ctx, in, out, logon_script);
     303        COPY_LSA_STRING(mem_ctx, in, out, profile_path);
     304        COPY_LSA_STRING(mem_ctx, in, out, home_directory);
     305        COPY_LSA_STRING(mem_ctx, in, out, home_drive);
     306
     307        if (in->groups.count) {
     308                out->groups.rids = (struct samr_RidWithAttribute *)
     309                        talloc_memdup(mem_ctx, in->groups.rids,
     310                                (sizeof(struct samr_RidWithAttribute) *
     311                                        in->groups.count));
     312                NT_STATUS_HAVE_NO_MEMORY(out->groups.rids);
     313        }
     314
     315        COPY_LSA_STRING(mem_ctx, in, out, logon_server);
     316        COPY_LSA_STRING(mem_ctx, in, out, domain);
     317
     318        if (in->domain_sid) {
     319                out->domain_sid = sid_dup_talloc(mem_ctx, in->domain_sid);
     320                NT_STATUS_HAVE_NO_MEMORY(out->domain_sid);
     321        }
     322
     323        return NT_STATUS_OK;
     324}
     325
     326static NTSTATUS map_validation_to_info3(TALLOC_CTX *mem_ctx,
     327                                        uint16_t validation_level,
     328                                        union netr_Validation *validation,
     329                                        struct netr_SamInfo3 **info3_p)
     330{
     331        struct netr_SamInfo3 *info3;
     332        NTSTATUS status;
     333
     334        if (validation == NULL) {
     335                return NT_STATUS_INVALID_PARAMETER;
     336        }
     337
     338        switch (validation_level) {
     339        case 3:
     340                if (validation->sam3 == NULL) {
     341                        return NT_STATUS_INVALID_PARAMETER;
     342                }
     343
     344                info3 = talloc_move(mem_ctx, &validation->sam3);
     345                break;
     346        case 6:
     347                if (validation->sam6 == NULL) {
     348                        return NT_STATUS_INVALID_PARAMETER;
     349                }
     350
     351                info3 = talloc_zero(mem_ctx, struct netr_SamInfo3);
     352                if (info3 == NULL) {
     353                        return NT_STATUS_NO_MEMORY;
     354                }
     355                status = copy_netr_SamBaseInfo(info3, &validation->sam6->base, &info3->base);
     356                if (!NT_STATUS_IS_OK(status)) {
     357                        TALLOC_FREE(info3);
     358                        return status;
     359                }
     360
     361                info3->sidcount = validation->sam6->sidcount;
     362                info3->sids = talloc_move(info3, &validation->sam6->sids);
     363                break;
     364        default:
     365                return NT_STATUS_BAD_VALIDATION_CLASS;
     366        }
     367
     368        *info3_p = info3;
     369
     370        return NT_STATUS_OK;
     371}
    286372
    287373/**
     
    299385                                           const char *workstation,
    300386                                           const uint8 chal[8],
     387                                           uint16_t validation_level,
    301388                                           DATA_BLOB lm_response,
    302389                                           DATA_BLOB nt_response,
     
    304391{
    305392        NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
    306         int validation_level = 3;
    307393        const char *workstation_name_slash;
    308394        const char *server_name_slash;
     
    398484        netlogon_creds_decrypt_samlogon(cli->dc, validation_level, &validation);
    399485
    400         *info3 = validation.sam3;
     486        result = map_validation_to_info3(mem_ctx, validation_level, &validation, info3);
     487        if (!NT_STATUS_IS_OK(result)) {
     488                return result;
     489        }
    401490
    402491        return result;
     
    411500                                              const char *workstation,
    412501                                              const uint8 chal[8],
     502                                              uint16_t validation_level,
    413503                                              DATA_BLOB lm_response,
    414504                                              DATA_BLOB nt_response,
     
    416506{
    417507        NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
    418         int validation_level = 3;
    419508        const char *workstation_name_slash;
    420509        const char *server_name_slash;
     
    499588        netlogon_creds_decrypt_samlogon(cli->dc, validation_level, &validation);
    500589
    501         *info3 = validation.sam3;
     590        result = map_validation_to_info3(mem_ctx, validation_level, &validation, info3);
     591        if (!NT_STATUS_IS_OK(result)) {
     592                return result;
     593        }
    502594
    503595        return result;
Note: See TracChangeset for help on using the changeset viewer.