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:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source4/rpc_server/winreg/rpc_winreg.c

    r414 r745  
    2626#include "librpc/gen_ndr/ndr_winreg.h"
    2727#include "librpc/gen_ndr/ndr_security.h"
    28 #include "libcli/security/security.h"
     28#include "libcli/security/session.h"
    2929
    3030enum handle_types { HTYPE_REGVAL, HTYPE_REGKEY };
     
    3737
    3838        err = reg_open_samba(dce_call->context,
    39                              &ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info,
     39                             &ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx,
     40                             dce_call->conn->auth_state.session_info,
    4041                             NULL);
    4142
     
    6162
    6263        h = dcesrv_handle_new(dce_call->context, HTYPE_REGKEY);
     64        W_ERROR_HAVE_NO_MEMORY(h);
    6365
    6466        result = reg_get_predefined_key(ctx, hkey,
     
    98100        DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
    99101
    100         talloc_free(h);
     102        talloc_unlink(dce_call->context, h);
    101103
    102104        ZERO_STRUCTP(r->out.handle);
     
    122124        newh = dcesrv_handle_new(dce_call->context, HTYPE_REGKEY);
    123125
    124         switch (security_session_user_level(dce_call->conn->auth_state.session_info))
     126        switch (security_session_user_level(dce_call->conn->auth_state.session_info, NULL))
    125127        {
    126128        case SECURITY_SYSTEM:
    127129        case SECURITY_ADMINISTRATOR:
     130                /* we support only non volatile keys */
     131                if (r->in.options != REG_OPTION_NON_VOLATILE) {
     132                        return WERR_NOT_SUPPORTED;
     133                }
     134
    128135                /* the security descriptor is optional */
    129136                if (r->in.secdesc != NULL) {
     
    135142                                return WERR_INVALID_PARAM;
    136143                        }
    137                         ndr_err = ndr_pull_struct_blob_all(&sdblob, mem_ctx, NULL, &sd,
     144                        ndr_err = ndr_pull_struct_blob_all(&sdblob, mem_ctx, &sd,
    138145                                                           (ndr_pull_flags_fn_t)ndr_pull_security_descriptor);
    139146                        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    144151                result = reg_key_add_name(newh, key, r->in.name.name, NULL,
    145152                        r->in.secdesc?&sd:NULL, (struct registry_key **)&newh->data);
     153
     154                r->out.action_taken = talloc(mem_ctx, enum winreg_CreateAction);
     155                if (r->out.action_taken == NULL) {
     156                        talloc_free(newh);
     157                        return WERR_NOMEM;
     158                }
     159                *r->out.action_taken = REG_ACTION_NONE;
     160
    146161                if (W_ERROR_IS_OK(result)) {
    147162                        r->out.new_handle = &newh->wire_handle;
     163                        *r->out.action_taken = REG_CREATED_NEW_KEY;
    148164                } else {
    149165                        talloc_free(newh);
    150166                }
    151                
     167
    152168                return result;
    153169        default:
     
    166182        struct dcesrv_handle *h;
    167183        struct registry_key *key;
    168 
    169         DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
    170         key = h->data;
    171 
    172         switch (security_session_user_level(dce_call->conn->auth_state.session_info))
     184        WERROR result;
     185
     186        DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
     187        key = h->data;
     188
     189        switch (security_session_user_level(dce_call->conn->auth_state.session_info, NULL))
    173190        {
    174191        case SECURITY_SYSTEM:
    175192        case SECURITY_ADMINISTRATOR:
    176                 return reg_key_del(key, r->in.key.name);
     193                result = reg_key_del(mem_ctx, key, r->in.key.name);
     194                talloc_unlink(dce_call->context, h);
     195
     196                return result;
    177197        default:
    178198                return WERR_ACCESS_DENIED;
     
    194214        key = h->data;
    195215
    196         switch (security_session_user_level(dce_call->conn->auth_state.session_info))
     216        switch (security_session_user_level(dce_call->conn->auth_state.session_info, NULL))
    197217        {
    198218        case SECURITY_SYSTEM:
    199219        case SECURITY_ADMINISTRATOR:
    200                 return reg_del_value(key, r->in.value.name);
     220                return reg_del_value(mem_ctx, key, r->in.value.name);
    201221        default:
    202222                return WERR_ACCESS_DENIED;
     
    282302        }
    283303
    284         /* check if there is enough room for the name */
    285         if (r->in.name->size < 2*strlen_m_term(data_name)) {
    286                 return WERR_MORE_DATA;
    287         }
    288 
    289304        /* "data_name" is NULL when we query the default attribute */
    290305        if (data_name != NULL) {
     
    297312        r->out.name->size = r->in.name->size;
    298313
    299         r->out.type = talloc(mem_ctx, uint32_t);
     314        r->out.type = talloc(mem_ctx, enum winreg_Type);
    300315        if (!r->out.type) {
    301316                return WERR_NOMEM;
    302317        }
    303         *r->out.type = data_type;
     318        *r->out.type = (enum winreg_Type) data_type;
    304319
    305320        /* check the client has enough room for the value */
     
    337352        key = h->data;
    338353
    339         switch (security_session_user_level(dce_call->conn->auth_state.session_info))
     354        switch (security_session_user_level(dce_call->conn->auth_state.session_info, NULL))
    340355        {
    341356        case SECURITY_SYSTEM:
     
    399414        key = h->data;
    400415
    401         switch (security_session_user_level(dce_call->conn->auth_state.session_info))
     416        switch (security_session_user_level(dce_call->conn->auth_state.session_info, NULL))
    402417        {
    403418        case SECURITY_SYSTEM:
     
    422437                return WERR_ACCESS_DENIED;
    423438        }
    424 
    425439}
    426440
     
    441455        key = h->data;
    442456
    443         switch (security_session_user_level(dce_call->conn->auth_state.session_info))
     457        switch (security_session_user_level(dce_call->conn->auth_state.session_info, NULL))
    444458        {
    445459        case SECURITY_SYSTEM:
     
    451465                        r->out.max_valnamelen, r->out.max_valbufsize);
    452466
     467                if (r->out.max_subkeylen != NULL) {
     468                        /* for UTF16 encoding */
     469                        *r->out.max_subkeylen *= 2;
     470                }
     471                if (r->out.max_valnamelen != NULL) {
     472                        /* for UTF16 encoding */
     473                        *r->out.max_valnamelen *= 2;
     474                }
     475
    453476                if (classname != NULL) {
    454477                        r->out.classname->name = classname;
     
    483506        key = h->data;
    484507
    485         switch (security_session_user_level(dce_call->conn->auth_state.session_info))
     508        switch (security_session_user_level(dce_call->conn->auth_state.session_info, NULL))
    486509        {
    487510        case SECURITY_SYSTEM:
    488511        case SECURITY_ADMINISTRATOR:
    489512        case SECURITY_USER:
     513                if ((r->in.type == NULL) || (r->in.data_length == NULL) ||
     514                    (r->in.data_size == NULL)) {
     515                        return WERR_INVALID_PARAM;
     516                }
     517
    490518                result = reg_key_get_value_by_name(mem_ctx, key,
    491519                         r->in.value_name->name, &value_type, &value_data);
     
    496524                        value_data.data = r->in.data;
    497525                        value_data.length = *r->in.data_length;
    498                 }
    499 
    500                 r->out.type = talloc(mem_ctx, uint32_t);
     526                } else {
     527                        if ((r->in.data != NULL)
     528                            && (*r->in.data_size < value_data.length)) {
     529                                result = WERR_MORE_DATA;
     530                        }
     531                }
     532
     533                r->out.type = talloc(mem_ctx, enum winreg_Type);
    501534                if (!r->out.type) {
    502535                        return WERR_NOMEM;
    503536                }
    504                 *r->out.type = value_type;
     537                *r->out.type = (enum winreg_Type) value_type;
    505538                r->out.data_length = talloc(mem_ctx, uint32_t);
    506539                if (!r->out.data_length) {
     
    581614        key = h->data;
    582615
    583         switch (security_session_user_level(dce_call->conn->auth_state.session_info))
     616        switch (security_session_user_level(dce_call->conn->auth_state.session_info, NULL))
    584617        {
    585618        case SECURITY_SYSTEM:
     
    691724}
    692725
     726/*
     727  winreg_DeleteKeyEx
     728*/
     729static WERROR dcesrv_winreg_DeleteKeyEx(struct dcesrv_call_state *dce_call,
     730                                        TALLOC_CTX *mem_ctx,
     731                                        struct winreg_DeleteKeyEx *r)
     732{
     733        return WERR_NOT_SUPPORTED;
     734}
    693735
    694736/* include the generated boilerplate */
Note: See TracChangeset for help on using the changeset viewer.