Changeset 77 for trunk/samba/source/rpc_client/cli_reg.c
- Timestamp:
- Sep 30, 2007, 3:42:50 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/samba/source/rpc_client/cli_reg.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/samba/source/rpc_client/cli_reg.c
r1 r77 3 3 RPC Pipe client 4 4 5 Copyright (C) Andrew Tridgell 1992-2000, 6 Copyright (C) Jeremy Allison 1999 - 2005 7 Copyright (C) Simo Sorce 2001 8 Copyright (C) Jeremy Cooper 2004 9 Copyright (C) Gerald (Jerry) Carter 2005 5 Copyright (C) Gerald (Jerry) Carter 2005-2006 10 6 11 7 This program is free software; you can redistribute it and/or modify 12 8 it under the terms of the GNU General Public License as published by 13 the Free Software Foundation; either version 2of the License, or9 the Free Software Foundation; either version of the License, or 14 10 (at your option) any later version. 15 11 … … 20 16 21 17 You should have received a copy of the GNU General Public License 22 along with this program; if not, write to the Free Software 23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 along with this program. If not, see <http://www.gnu.org/licenses/>. 24 19 */ 25 20 … … 27 22 #include "rpc_client.h" 28 23 29 /* Shutdown a server */30 31 /*******************************************************************32 internal connect to a registry hive root (open a registry policy)33 *******************************************************************/34 35 static WERROR rpccli_reg_open_hive_int(struct rpc_pipe_client *cli,36 TALLOC_CTX *mem_ctx, uint16 op_code,37 const char *op_name,38 uint32 access_mask, POLICY_HND *hnd)39 {40 REG_Q_OPEN_HIVE in;41 REG_R_OPEN_HIVE out;42 prs_struct qbuf, rbuf;43 44 ZERO_STRUCT(in);45 ZERO_STRUCT(out);46 47 init_reg_q_open_hive(&in, access_mask);48 49 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, op_code,50 in, out,51 qbuf, rbuf,52 reg_io_q_open_hive,53 reg_io_r_open_hive,54 WERR_GENERAL_FAILURE );55 56 if ( !W_ERROR_IS_OK( out.status ) )57 return out.status;58 59 memcpy( hnd, &out.pol, sizeof(POLICY_HND) );60 61 return out.status;62 }63 64 24 /******************************************************************* 65 25 connect to a registry hive root (open a registry policy) 66 26 *******************************************************************/ 67 27 68 WERROR rpccli_reg_connect(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,28 onnect(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, 69 29 uint32 reg_type, uint32 access_mask, 70 30 POLICY_HND *reg_hnd) 71 { uint16 op_code; 72 const char *op_name; 73 31 { 74 32 ZERO_STRUCTP(reg_hnd); 75 33 … … 77 35 { 78 36 case HKEY_CLASSES_ROOT: 79 op_code = REG_OPEN_HKCR; 80 op_name = "REG_OPEN_HKCR"; 37 return rpccli_winreg_OpenHKCR( cli, mem_ctx, NULL, 38 access_mask, reg_hnd ); 39 40 case HKEY_LOCAL_MACHINE: 41 return rpccli_winreg_OpenHKLM( cli, mem_ctx, NULL, 42 access_mask, reg_hnd ); 43 44 case HKEY_USERS: 45 return rpccli_winreg_OpenHKU( cli, mem_ctx, NULL, 46 access_mask, reg_hnd ); 47 48 case HKEY_CURRENT_USER: 49 return rpccli_winreg_OpenHKCU( cli, mem_ctx, NULL, 50 access_mask, reg_hnd ); 51 52 case HKEY_PERFORMANCE_DATA: 53 return rpccli_winreg_OpenHKPD( cli, mem_ctx, NULL, 54 access_mask, reg_hnd ); 55 56 default: 57 /* fall through to end of function */ 81 58 break; 82 case HKEY_LOCAL_MACHINE:83 op_code = REG_OPEN_HKLM;84 op_name = "REG_OPEN_HKLM";85 break;86 case HKEY_USERS:87 op_code = REG_OPEN_HKU;88 op_name = "REG_OPEN_HKU";89 break;90 case HKEY_PERFORMANCE_DATA:91 op_code = REG_OPEN_HKPD;92 op_name = "REG_OPEN_HKPD";93 break;94 default:95 return WERR_INVALID_PARAM;96 59 } 97 60 98 return rpccli_reg_open_hive_int(cli, mem_ctx, op_code, op_name, 99 access_mask, reg_hnd); 100 } 101 102 103 /******************************************************************* 104 *******************************************************************/ 105 106 WERROR rpccli_reg_shutdown(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, 107 const char *msg, uint32 timeout, BOOL do_reboot, 108 BOOL force) 109 { 110 REG_Q_SHUTDOWN in; 111 REG_R_SHUTDOWN out; 112 prs_struct qbuf, rbuf; 113 114 if (msg == NULL) 115 return WERR_INVALID_PARAM; 116 117 ZERO_STRUCT (in); 118 ZERO_STRUCT (out); 119 120 /* Marshall data and send request */ 121 122 init_reg_q_shutdown(&in, msg, timeout, do_reboot, force); 123 124 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_SHUTDOWN, 125 in, out, 126 qbuf, rbuf, 127 reg_io_q_shutdown, 128 reg_io_r_shutdown, 129 WERR_GENERAL_FAILURE ); 130 131 return out.status; 61 return NT_STATUS_INVALID_PARAMETER; 132 62 } 133 63 134 64 /******************************************************************* 135 *******************************************************************/ 65 Fill in a REGVAL_BUFFER for the data given a REGISTRY_VALUE 66 *******************************************************************/ 136 67 137 WERROR rpccli_reg_abort_shutdown(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)68 ) 138 69 { 139 REG_Q_ABORT_SHUTDOWN in; 140 REG_R_ABORT_SHUTDOWN out; 141 prs_struct qbuf, rbuf; 70 uint32 real_size = 0; 71 72 if ( !buf2 || !val ) 73 return 0; 74 75 real_size = regval_size(val); 76 init_regval_buffer( buf2, (unsigned char*)regval_data_p(val), real_size ); 142 77 143 ZERO_STRUCT (in); 144 ZERO_STRUCT (out); 145 146 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_ABORT_SHUTDOWN, 147 in, out, 148 qbuf, rbuf, 149 reg_io_q_abort_shutdown, 150 reg_io_r_abort_shutdown, 151 WERR_GENERAL_FAILURE ); 152 153 return out.status; 78 return real_size; 154 79 } 155 156 157 /****************************************************************************158 do a REG Unknown 0xB command. sent after a create key or create value.159 this might be some sort of "sync" or "refresh" command, sent after160 modification of the registry...161 ****************************************************************************/162 163 WERROR rpccli_reg_flush_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,164 POLICY_HND *hnd)165 {166 REG_Q_FLUSH_KEY in;167 REG_R_FLUSH_KEY out;168 prs_struct qbuf, rbuf;169 170 ZERO_STRUCT (in);171 ZERO_STRUCT (out);172 173 init_reg_q_flush_key(&in, hnd);174 175 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_FLUSH_KEY,176 in, out,177 qbuf, rbuf,178 reg_io_q_flush_key,179 reg_io_r_flush_key,180 WERR_GENERAL_FAILURE );181 182 return out.status;183 }184 185 /****************************************************************************186 do a REG Query Key187 ****************************************************************************/188 189 WERROR rpccli_reg_query_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,190 POLICY_HND *hnd,191 char *key_class, uint32 *class_len,192 uint32 *num_subkeys, uint32 *max_subkeylen,193 uint32 *max_classlen, uint32 *num_values,194 uint32 *max_valnamelen, uint32 *max_valbufsize,195 uint32 *sec_desc, NTTIME *mod_time)196 {197 REG_Q_QUERY_KEY in;198 REG_R_QUERY_KEY out;199 prs_struct qbuf, rbuf;200 uint32 saved_class_len = *class_len;201 202 ZERO_STRUCT (in);203 ZERO_STRUCT (out);204 205 init_reg_q_query_key( &in, hnd, key_class );206 207 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_QUERY_KEY,208 in, out,209 qbuf, rbuf,210 reg_io_q_query_key,211 reg_io_r_query_key,212 WERR_GENERAL_FAILURE );213 214 if ( W_ERROR_EQUAL( out.status, WERR_MORE_DATA ) ) {215 ZERO_STRUCT (in);216 217 *class_len = out.key_class.string->uni_max_len;218 if ( *class_len > saved_class_len )219 return out.status;220 221 /* set a string of spaces and NULL terminate */222 223 memset( key_class, (int)' ', *class_len );224 key_class[*class_len] = '\0';225 226 init_reg_q_query_key( &in, hnd, key_class );227 228 ZERO_STRUCT (out);229 230 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_QUERY_KEY,231 in, out,232 qbuf, rbuf,233 reg_io_q_query_key,234 reg_io_r_query_key,235 WERR_GENERAL_FAILURE );236 }237 238 if ( !W_ERROR_IS_OK( out.status ) )239 return out.status;240 241 *class_len = out.key_class.string->uni_max_len;242 unistr2_to_ascii(key_class, out.key_class.string, saved_class_len-1);243 *num_subkeys = out.num_subkeys ;244 *max_subkeylen = out.max_subkeylen ;245 *num_values = out.num_values ;246 *max_valnamelen = out.max_valnamelen;247 *max_valbufsize = out.max_valbufsize;248 *sec_desc = out.sec_desc ;249 *mod_time = out.mod_time ;250 /* Maybe: *max_classlen = out.reserved; */251 252 return out.status;253 }254 255 /****************************************************************************256 ****************************************************************************/257 258 WERROR rpccli_reg_getversion(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,259 POLICY_HND *hnd, uint32 *version)260 {261 REG_Q_GETVERSION in;262 REG_R_GETVERSION out;263 prs_struct qbuf, rbuf;264 265 ZERO_STRUCT (in);266 ZERO_STRUCT (out);267 268 init_reg_q_getversion(&in, hnd);269 270 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_GETVERSION,271 in, out,272 qbuf, rbuf,273 reg_io_q_getversion,274 reg_io_r_getversion,275 WERR_GENERAL_FAILURE );276 277 278 if ( !W_ERROR_IS_OK( out.status ) )279 return out.status;280 281 *version = out.win_version;282 283 return out.status;284 }285 286 /****************************************************************************287 do a REG Query Info288 ****************************************************************************/289 290 WERROR rpccli_reg_query_value(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,291 POLICY_HND *hnd, const char *val_name,292 uint32 *type, REGVAL_BUFFER *buffer)293 {294 REG_Q_QUERY_VALUE in;295 REG_R_QUERY_VALUE out;296 prs_struct qbuf, rbuf;297 298 ZERO_STRUCT (in);299 ZERO_STRUCT (out);300 301 init_reg_q_query_value(&in, hnd, val_name, buffer);302 303 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_QUERY_VALUE,304 in, out,305 qbuf, rbuf,306 reg_io_q_query_value,307 reg_io_r_query_value,308 WERR_GENERAL_FAILURE );309 310 311 if ( !W_ERROR_IS_OK( out.status ) )312 return out.status;313 314 *type = *out.type;315 *buffer = *out.value;316 317 return out.status;318 }319 320 /****************************************************************************321 do a REG Set Key Security322 ****************************************************************************/323 324 WERROR rpccli_reg_set_key_sec(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,325 POLICY_HND *hnd, uint32 sec_info,326 size_t secdesc_size, SEC_DESC *sec_desc)327 {328 REG_Q_SET_KEY_SEC in;329 REG_R_SET_KEY_SEC out;330 prs_struct qbuf, rbuf;331 SEC_DESC_BUF *sec_desc_buf;332 333 ZERO_STRUCT (in);334 ZERO_STRUCT (out);335 336 /* Flatten the security descriptor */337 338 if ( !(sec_desc_buf = make_sec_desc_buf(mem_ctx, secdesc_size, sec_desc)) )339 return WERR_GENERAL_FAILURE;340 341 init_reg_q_set_key_sec(&in, hnd, sec_info, sec_desc_buf);342 343 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_SET_KEY_SEC,344 in, out,345 qbuf, rbuf,346 reg_io_q_set_key_sec,347 reg_io_r_set_key_sec,348 WERR_GENERAL_FAILURE );349 350 351 return out.status;352 }353 354 355 /****************************************************************************356 do a REG Query Key Security357 ****************************************************************************/358 359 WERROR rpccli_reg_get_key_sec(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,360 POLICY_HND *hnd, uint32 sec_info,361 uint32 *sec_buf_size, SEC_DESC_BUF *sec_buf)362 {363 REG_Q_GET_KEY_SEC in;364 REG_R_GET_KEY_SEC out;365 prs_struct qbuf, rbuf;366 367 ZERO_STRUCT (in);368 ZERO_STRUCT (out);369 370 init_reg_q_get_key_sec(&in, hnd, sec_info, *sec_buf_size, sec_buf);371 372 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_GET_KEY_SEC,373 in, out,374 qbuf, rbuf,375 reg_io_q_get_key_sec,376 reg_io_r_get_key_sec,377 WERR_GENERAL_FAILURE );378 379 380 /* this might be able to return WERR_MORE_DATA, I'm not sure */381 382 if ( !W_ERROR_IS_OK( out.status ) )383 return out.status;384 385 sec_buf = out.data;386 *sec_buf_size = out.data->len;387 388 return out.status;389 }390 391 /****************************************************************************392 do a REG Delete Value393 ****************************************************************************/394 395 WERROR rpccli_reg_delete_val(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,396 POLICY_HND *hnd, char *val_name)397 {398 REG_Q_DELETE_VALUE in;399 REG_R_DELETE_VALUE out;400 prs_struct qbuf, rbuf;401 402 ZERO_STRUCT (in);403 ZERO_STRUCT (out);404 405 init_reg_q_delete_val(&in, hnd, val_name);406 407 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_DELETE_VALUE,408 in, out,409 qbuf, rbuf,410 reg_io_q_delete_value,411 reg_io_r_delete_value,412 WERR_GENERAL_FAILURE );413 414 return out.status;415 }416 417 /****************************************************************************418 do a REG Delete Key419 ****************************************************************************/420 421 WERROR rpccli_reg_delete_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,422 POLICY_HND *hnd, char *key_name)423 {424 REG_Q_DELETE_KEY in;425 REG_R_DELETE_KEY out;426 prs_struct qbuf, rbuf;427 428 ZERO_STRUCT (in);429 ZERO_STRUCT (out);430 431 init_reg_q_delete_key(&in, hnd, key_name);432 433 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_DELETE_KEY,434 in, out,435 qbuf, rbuf,436 reg_io_q_delete_key,437 reg_io_r_delete_key,438 WERR_GENERAL_FAILURE );439 440 return out.status;441 }442 443 /****************************************************************************444 do a REG Create Key445 ****************************************************************************/446 447 WERROR rpccli_reg_create_key_ex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,448 POLICY_HND *hnd, char *key_name, char *key_class,449 uint32 access_desired, POLICY_HND *key)450 {451 REG_Q_CREATE_KEY_EX in;452 REG_R_CREATE_KEY_EX out;453 prs_struct qbuf, rbuf;454 SEC_DESC *sec;455 SEC_DESC_BUF *sec_buf;456 size_t sec_len;457 458 ZERO_STRUCT (in);459 ZERO_STRUCT (out);460 461 if ( !(sec = make_sec_desc(mem_ctx, 1, SEC_DESC_SELF_RELATIVE,462 NULL, NULL, NULL, NULL, &sec_len)) ) {463 return WERR_GENERAL_FAILURE;464 }465 466 if ( !(sec_buf = make_sec_desc_buf(mem_ctx, sec_len, sec)) )467 return WERR_GENERAL_FAILURE;468 469 init_reg_q_create_key_ex(&in, hnd, key_name, key_class, access_desired, sec_buf);470 471 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_CREATE_KEY_EX,472 in, out,473 qbuf, rbuf,474 reg_io_q_create_key_ex,475 reg_io_r_create_key_ex,476 WERR_GENERAL_FAILURE );477 478 479 if ( !W_ERROR_IS_OK( out.status ) )480 return out.status;481 482 memcpy( key, &out.handle, sizeof(POLICY_HND) );483 484 return out.status;485 }486 487 /****************************************************************************488 do a REG Enum Key489 ****************************************************************************/490 491 WERROR rpccli_reg_enum_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,492 POLICY_HND *hnd, int key_index, fstring key_name,493 fstring class_name, time_t *mod_time)494 {495 REG_Q_ENUM_KEY in;496 REG_R_ENUM_KEY out;497 prs_struct qbuf, rbuf;498 499 ZERO_STRUCT (in);500 ZERO_STRUCT (out);501 502 init_reg_q_enum_key(&in, hnd, key_index);503 504 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_ENUM_KEY,505 in, out,506 qbuf, rbuf,507 reg_io_q_enum_key,508 reg_io_r_enum_key,509 WERR_GENERAL_FAILURE );510 511 if ( !W_ERROR_IS_OK(out.status) )512 return out.status;513 514 if ( out.keyname.string )515 rpcstr_pull( key_name, out.keyname.string->buffer, sizeof(fstring), -1, STR_TERMINATE );516 else517 fstrcpy( key_name, "(Default)" );518 519 if ( out.classname && out.classname->string )520 rpcstr_pull( class_name, out.classname->string->buffer, sizeof(fstring), -1, STR_TERMINATE );521 else522 fstrcpy( class_name, "" );523 524 *mod_time = nt_time_to_unix(*out.time);525 526 return out.status;527 }528 529 /****************************************************************************530 do a REG Create Value531 ****************************************************************************/532 533 WERROR rpccli_reg_set_val(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,534 POLICY_HND *hnd, char *val_name, uint32 type,535 RPC_DATA_BLOB *data)536 {537 REG_Q_SET_VALUE in;538 REG_R_SET_VALUE out;539 prs_struct qbuf, rbuf;540 541 ZERO_STRUCT (in);542 ZERO_STRUCT (out);543 544 init_reg_q_set_val(&in, hnd, val_name, type, data);545 546 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_SET_VALUE,547 in, out,548 qbuf, rbuf,549 reg_io_q_set_value,550 reg_io_r_set_value,551 WERR_GENERAL_FAILURE );552 553 return out.status;554 }555 556 /****************************************************************************557 do a REG Enum Value558 ****************************************************************************/559 560 WERROR rpccli_reg_enum_val(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,561 POLICY_HND *hnd, int idx,562 fstring val_name, uint32 *type, REGVAL_BUFFER *value)563 {564 REG_Q_ENUM_VALUE in;565 REG_R_ENUM_VALUE out;566 prs_struct qbuf, rbuf;567 568 ZERO_STRUCT (in);569 ZERO_STRUCT (out);570 571 init_reg_q_enum_val(&in, hnd, idx, 0x0100, 0x1000);572 573 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_ENUM_VALUE,574 in, out,575 qbuf, rbuf,576 reg_io_q_enum_val,577 reg_io_r_enum_val,578 WERR_GENERAL_FAILURE );579 580 if ( W_ERROR_EQUAL(out.status, WERR_MORE_DATA) ) {581 582 ZERO_STRUCT (in);583 584 init_reg_q_enum_val(&in, hnd, idx, 0x0100, *out.buffer_len1);585 586 ZERO_STRUCT (out);587 588 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_ENUM_VALUE,589 in, out,590 qbuf, rbuf,591 reg_io_q_enum_val,592 reg_io_r_enum_val,593 WERR_GENERAL_FAILURE );594 }595 596 if ( !W_ERROR_IS_OK(out.status) )597 return out.status;598 599 unistr2_to_ascii(val_name, out.name.string, sizeof(fstring)-1);600 *type = *out.type;601 *value = *out.value;602 603 return out.status;604 }605 606 /****************************************************************************607 ****************************************************************************/608 609 WERROR rpccli_reg_open_entry(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,610 POLICY_HND *hnd, char *key_name,611 uint32 access_desired, POLICY_HND *key_hnd)612 {613 REG_Q_OPEN_ENTRY in;614 REG_R_OPEN_ENTRY out;615 prs_struct qbuf, rbuf;616 617 ZERO_STRUCT (in);618 ZERO_STRUCT (out);619 620 init_reg_q_open_entry(&in, hnd, key_name, access_desired);621 622 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_OPEN_ENTRY,623 in, out,624 qbuf, rbuf,625 reg_io_q_open_entry,626 reg_io_r_open_entry,627 WERR_GENERAL_FAILURE );628 629 if ( !W_ERROR_IS_OK( out.status ) )630 return out.status;631 632 memcpy( key_hnd, &out.handle, sizeof(POLICY_HND) );633 634 return out.status;635 }636 637 /****************************************************************************638 ****************************************************************************/639 640 WERROR rpccli_reg_close(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,641 POLICY_HND *hnd)642 {643 REG_Q_CLOSE in;644 REG_R_CLOSE out;645 prs_struct qbuf, rbuf;646 647 ZERO_STRUCT (in);648 ZERO_STRUCT (out);649 650 init_reg_q_close(&in, hnd);651 652 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_CLOSE,653 in, out,654 qbuf, rbuf,655 reg_io_q_close,656 reg_io_r_close,657 WERR_GENERAL_FAILURE );658 659 return out.status;660 }661 662 /****************************************************************************663 do a REG Query Info664 ****************************************************************************/665 666 WERROR rpccli_reg_save_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,667 POLICY_HND *hnd, const char *filename )668 {669 REG_Q_SAVE_KEY in;670 REG_R_SAVE_KEY out;671 prs_struct qbuf, rbuf;672 673 ZERO_STRUCT (in);674 ZERO_STRUCT (out);675 676 init_q_reg_save_key( &in, hnd, filename );677 678 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_SAVE_KEY,679 in, out,680 qbuf, rbuf,681 reg_io_q_save_key,682 reg_io_r_save_key,683 WERR_GENERAL_FAILURE );684 685 return out.status;686 }687 688 689 /*690 #################################################################691 Utility functions692 #################################################################693 */694 695 /*****************************************************************696 Splits out the start of the key (HKLM or HKU) and the rest of the key.697 *****************************************************************/698 699 BOOL reg_split_hive(const char *full_keyname, uint32 *reg_type, pstring key_name)700 {701 pstring tmp;702 703 if (!next_token(&full_keyname, tmp, "\\", sizeof(tmp)))704 return False;705 706 (*reg_type) = 0;707 708 DEBUG(10, ("reg_split_key: hive %s\n", tmp));709 710 if (strequal(tmp, "HKLM") || strequal(tmp, "HKEY_LOCAL_MACHINE"))711 (*reg_type) = HKEY_LOCAL_MACHINE;712 else if (strequal(tmp, "HKCR") || strequal(tmp, "HKEY_CLASSES_ROOT"))713 (*reg_type) = HKEY_CLASSES_ROOT;714 else if (strequal(tmp, "HKU") || strequal(tmp, "HKEY_USERS"))715 (*reg_type) = HKEY_USERS;716 else if (strequal(tmp, "HKPD")||strequal(tmp, "HKEY_PERFORMANCE_DATA"))717 (*reg_type) = HKEY_PERFORMANCE_DATA;718 else {719 DEBUG(10,("reg_split_key: unrecognised hive key %s\n", tmp));720 return False;721 }722 723 if (next_token(&full_keyname, tmp, "\n\r", sizeof(tmp)))724 pstrcpy(key_name, tmp);725 else726 key_name[0] = 0;727 728 DEBUG(10, ("reg_split_key: name %s\n", key_name));729 730 return True;731 }
Note:
See TracChangeset
for help on using the changeset viewer.
