Changeset 745 for trunk/server/source4/rpc_server/winreg
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source4/rpc_server/winreg/rpc_winreg.c
r414 r745 26 26 #include "librpc/gen_ndr/ndr_winreg.h" 27 27 #include "librpc/gen_ndr/ndr_security.h" 28 #include "libcli/security/se curity.h"28 #include "libcli/security/session.h" 29 29 30 30 enum handle_types { HTYPE_REGVAL, HTYPE_REGKEY }; … … 37 37 38 38 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, 40 41 NULL); 41 42 … … 61 62 62 63 h = dcesrv_handle_new(dce_call->context, HTYPE_REGKEY); 64 W_ERROR_HAVE_NO_MEMORY(h); 63 65 64 66 result = reg_get_predefined_key(ctx, hkey, … … 98 100 DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY); 99 101 100 talloc_ free(h);102 talloc_unlink(dce_call->context, h); 101 103 102 104 ZERO_STRUCTP(r->out.handle); … … 122 124 newh = dcesrv_handle_new(dce_call->context, HTYPE_REGKEY); 123 125 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)) 125 127 { 126 128 case SECURITY_SYSTEM: 127 129 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 128 135 /* the security descriptor is optional */ 129 136 if (r->in.secdesc != NULL) { … … 135 142 return WERR_INVALID_PARAM; 136 143 } 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, 138 145 (ndr_pull_flags_fn_t)ndr_pull_security_descriptor); 139 146 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 144 151 result = reg_key_add_name(newh, key, r->in.name.name, NULL, 145 152 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 146 161 if (W_ERROR_IS_OK(result)) { 147 162 r->out.new_handle = &newh->wire_handle; 163 *r->out.action_taken = REG_CREATED_NEW_KEY; 148 164 } else { 149 165 talloc_free(newh); 150 166 } 151 167 152 168 return result; 153 169 default: … … 166 182 struct dcesrv_handle *h; 167 183 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)) 173 190 { 174 191 case SECURITY_SYSTEM: 175 192 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; 177 197 default: 178 198 return WERR_ACCESS_DENIED; … … 194 214 key = h->data; 195 215 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)) 197 217 { 198 218 case SECURITY_SYSTEM: 199 219 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); 201 221 default: 202 222 return WERR_ACCESS_DENIED; … … 282 302 } 283 303 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 289 304 /* "data_name" is NULL when we query the default attribute */ 290 305 if (data_name != NULL) { … … 297 312 r->out.name->size = r->in.name->size; 298 313 299 r->out.type = talloc(mem_ctx, uint32_t);314 r->out.type = talloc(mem_ctx, enum winreg_Type); 300 315 if (!r->out.type) { 301 316 return WERR_NOMEM; 302 317 } 303 *r->out.type = data_type;318 *r->out.type = (enum winreg_Type) data_type; 304 319 305 320 /* check the client has enough room for the value */ … … 337 352 key = h->data; 338 353 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)) 340 355 { 341 356 case SECURITY_SYSTEM: … … 399 414 key = h->data; 400 415 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)) 402 417 { 403 418 case SECURITY_SYSTEM: … … 422 437 return WERR_ACCESS_DENIED; 423 438 } 424 425 439 } 426 440 … … 441 455 key = h->data; 442 456 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)) 444 458 { 445 459 case SECURITY_SYSTEM: … … 451 465 r->out.max_valnamelen, r->out.max_valbufsize); 452 466 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 453 476 if (classname != NULL) { 454 477 r->out.classname->name = classname; … … 483 506 key = h->data; 484 507 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)) 486 509 { 487 510 case SECURITY_SYSTEM: 488 511 case SECURITY_ADMINISTRATOR: 489 512 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 490 518 result = reg_key_get_value_by_name(mem_ctx, key, 491 519 r->in.value_name->name, &value_type, &value_data); … … 496 524 value_data.data = r->in.data; 497 525 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); 501 534 if (!r->out.type) { 502 535 return WERR_NOMEM; 503 536 } 504 *r->out.type = value_type;537 *r->out.type = (enum winreg_Type) value_type; 505 538 r->out.data_length = talloc(mem_ctx, uint32_t); 506 539 if (!r->out.data_length) { … … 581 614 key = h->data; 582 615 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)) 584 617 { 585 618 case SECURITY_SYSTEM: … … 691 724 } 692 725 726 /* 727 winreg_DeleteKeyEx 728 */ 729 static 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 } 693 735 694 736 /* include the generated boilerplate */
Note:
See TracChangeset
for help on using the changeset viewer.