rpc_client/cli_reg.c

説明を見る。
00001 /* 
00002    Unix SMB/CIFS implementation.
00003    RPC Pipe client
00004  
00005    Copyright (C) Andrew Tridgell              1992-2000,
00006    Copyright (C) Jeremy Allison                    1999 - 2005
00007    Copyright (C) Simo Sorce                        2001
00008    Copyright (C) Jeremy Cooper                     2004
00009    Copyright (C) Gerald (Jerry) Carter             2005
00010    
00011    This program is free software; you can redistribute it and/or modify
00012    it under the terms of the GNU General Public License as published by
00013    the Free Software Foundation; either version 2 of the License, or
00014    (at your option) any later version.
00015    
00016    This program is distributed in the hope that it will be useful,
00017    but WITHOUT ANY WARRANTY; without even the implied warranty of
00018    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019    GNU General Public License for more details.
00020    
00021    You should have received a copy of the GNU General Public License
00022    along with this program; if not, write to the Free Software
00023    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024 */
00025 
00026 #include "includes.h"
00027 #include "rpc_client.h"
00028 
00029 /* Shutdown a server */
00030 
00031 /*******************************************************************
00032  internal connect to a registry hive root (open a registry policy)
00033 *******************************************************************/
00034 
00035 static WERROR rpccli_reg_open_hive_int(struct rpc_pipe_client *cli,
00036                                       TALLOC_CTX *mem_ctx, uint16 op_code,
00037                                       const char *op_name,
00038                                       uint32 access_mask, POLICY_HND *hnd)
00039 {
00040         REG_Q_OPEN_HIVE in;
00041         REG_R_OPEN_HIVE out;
00042         prs_struct qbuf, rbuf;
00043 
00044         ZERO_STRUCT(in);
00045         ZERO_STRUCT(out);
00046 
00047         init_reg_q_open_hive(&in, access_mask);
00048 
00049         CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, op_code, 
00050                     in, out, 
00051                     qbuf, rbuf,
00052                     reg_io_q_open_hive,
00053                     reg_io_r_open_hive, 
00054                     WERR_GENERAL_FAILURE );
00055 
00056         if ( !W_ERROR_IS_OK( out.status ) )
00057                 return out.status;
00058 
00059         memcpy( hnd, &out.pol, sizeof(POLICY_HND) );
00060 
00061         return out.status;
00062 }
00063 
00064 /*******************************************************************
00065  connect to a registry hive root (open a registry policy)
00066 *******************************************************************/
00067 
00068 WERROR rpccli_reg_connect(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00069                          uint32 reg_type, uint32 access_mask,
00070                          POLICY_HND *reg_hnd)
00071 {       uint16 op_code;
00072         const char *op_name;
00073 
00074         ZERO_STRUCTP(reg_hnd);
00075 
00076         switch (reg_type)
00077         {
00078         case HKEY_CLASSES_ROOT:
00079                 op_code = REG_OPEN_HKCR;
00080                 op_name = "REG_OPEN_HKCR";
00081                 break;
00082         case HKEY_LOCAL_MACHINE:
00083                 op_code = REG_OPEN_HKLM;
00084                 op_name = "REG_OPEN_HKLM";
00085                 break;
00086         case HKEY_USERS:
00087                 op_code = REG_OPEN_HKU;
00088                 op_name = "REG_OPEN_HKU";
00089                 break;
00090         case HKEY_PERFORMANCE_DATA:
00091                 op_code = REG_OPEN_HKPD;
00092                 op_name = "REG_OPEN_HKPD";
00093                 break;
00094         default:
00095                 return WERR_INVALID_PARAM;
00096         }
00097 
00098         return rpccli_reg_open_hive_int(cli, mem_ctx, op_code, op_name,
00099                                      access_mask, reg_hnd);
00100 }
00101 
00102 
00103 /*******************************************************************
00104 *******************************************************************/
00105 
00106 WERROR rpccli_reg_shutdown(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00107                           const char *msg, uint32 timeout, BOOL do_reboot,
00108                           BOOL force)
00109 {
00110         REG_Q_SHUTDOWN in;
00111         REG_R_SHUTDOWN out;
00112         prs_struct qbuf, rbuf;
00113 
00114         if (msg == NULL) 
00115                 return WERR_INVALID_PARAM;
00116 
00117         ZERO_STRUCT (in);
00118         ZERO_STRUCT (out);
00119 
00120         /* Marshall data and send request */
00121 
00122         init_reg_q_shutdown(&in, msg, timeout, do_reboot, force);
00123 
00124         CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_SHUTDOWN, 
00125                     in, out, 
00126                     qbuf, rbuf,
00127                     reg_io_q_shutdown,
00128                     reg_io_r_shutdown, 
00129                     WERR_GENERAL_FAILURE );
00130 
00131         return out.status;
00132 }
00133 
00134 /*******************************************************************
00135 *******************************************************************/
00136 
00137 WERROR rpccli_reg_abort_shutdown(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
00138 {
00139         REG_Q_ABORT_SHUTDOWN in;
00140         REG_R_ABORT_SHUTDOWN out;
00141         prs_struct qbuf, rbuf;
00142 
00143         ZERO_STRUCT (in);
00144         ZERO_STRUCT (out);
00145 
00146         CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_ABORT_SHUTDOWN, 
00147                     in, out, 
00148                     qbuf, rbuf,
00149                     reg_io_q_abort_shutdown,
00150                     reg_io_r_abort_shutdown, 
00151                     WERR_GENERAL_FAILURE );
00152 
00153         return out.status;      
00154 }
00155 
00156 
00157 /****************************************************************************
00158 do a REG Unknown 0xB command.  sent after a create key or create value.
00159 this might be some sort of "sync" or "refresh" command, sent after
00160 modification of the registry...
00161 ****************************************************************************/
00162 
00163 WERROR rpccli_reg_flush_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00164                            POLICY_HND *hnd)
00165 {
00166         REG_Q_FLUSH_KEY in;
00167         REG_R_FLUSH_KEY out;
00168         prs_struct qbuf, rbuf;
00169 
00170         ZERO_STRUCT (in);
00171         ZERO_STRUCT (out);
00172         
00173         init_reg_q_flush_key(&in, hnd);
00174 
00175         CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_FLUSH_KEY, 
00176                     in, out, 
00177                     qbuf, rbuf,
00178                     reg_io_q_flush_key,
00179                     reg_io_r_flush_key, 
00180                     WERR_GENERAL_FAILURE );
00181                     
00182         return out.status;
00183 }
00184 
00185 /****************************************************************************
00186 do a REG Query Key
00187 ****************************************************************************/
00188 
00189 WERROR rpccli_reg_query_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00190                            POLICY_HND *hnd,
00191                            char *key_class, uint32 *class_len,
00192                            uint32 *num_subkeys, uint32 *max_subkeylen,
00193                            uint32 *max_classlen, uint32 *num_values,
00194                            uint32 *max_valnamelen, uint32 *max_valbufsize,
00195                            uint32 *sec_desc, NTTIME *mod_time)
00196 {
00197         REG_Q_QUERY_KEY in;
00198         REG_R_QUERY_KEY out;
00199         prs_struct qbuf, rbuf;
00200         uint32 saved_class_len = *class_len;
00201 
00202         ZERO_STRUCT (in);
00203         ZERO_STRUCT (out);
00204 
00205         init_reg_q_query_key( &in, hnd, key_class );
00206 
00207         CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_QUERY_KEY, 
00208                     in, out, 
00209                     qbuf, rbuf,
00210                     reg_io_q_query_key,
00211                     reg_io_r_query_key, 
00212                     WERR_GENERAL_FAILURE );
00213 
00214         if ( W_ERROR_EQUAL( out.status, WERR_MORE_DATA ) ) {
00215                 ZERO_STRUCT (in);
00216 
00217                 *class_len = out.key_class.string->uni_max_len;
00218                 if ( *class_len > saved_class_len )
00219                         return out.status;
00220                         
00221                 /* set a string of spaces and NULL terminate */
00222 
00223                 memset( key_class, (int)' ', *class_len );
00224                 key_class[*class_len] = '\0';
00225                 
00226                 init_reg_q_query_key( &in, hnd, key_class );
00227 
00228                 ZERO_STRUCT (out);
00229 
00230                 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_QUERY_KEY, 
00231                             in, out, 
00232                             qbuf, rbuf,
00233                             reg_io_q_query_key,
00234                             reg_io_r_query_key, 
00235                             WERR_GENERAL_FAILURE );
00236         }
00237         
00238         if ( !W_ERROR_IS_OK( out.status ) )
00239                 return out.status;
00240 
00241         *class_len      = out.key_class.string->uni_max_len;
00242         unistr2_to_ascii(key_class, out.key_class.string, saved_class_len-1);
00243         *num_subkeys    = out.num_subkeys   ;
00244         *max_subkeylen  = out.max_subkeylen ;
00245         *num_values     = out.num_values    ;
00246         *max_valnamelen = out.max_valnamelen;
00247         *max_valbufsize = out.max_valbufsize;
00248         *sec_desc       = out.sec_desc      ;
00249         *mod_time       = out.mod_time      ;
00250         /* Maybe: *max_classlen = out.reserved; */
00251 
00252         return out.status;
00253 }
00254 
00255 /****************************************************************************
00256 ****************************************************************************/
00257 
00258 WERROR rpccli_reg_getversion(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00259                             POLICY_HND *hnd, uint32 *version)
00260 {
00261         REG_Q_GETVERSION in;
00262         REG_R_GETVERSION out;
00263         prs_struct qbuf, rbuf;
00264 
00265         ZERO_STRUCT (in);
00266         ZERO_STRUCT (out);
00267         
00268         init_reg_q_getversion(&in, hnd);
00269 
00270         CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_GETVERSION, 
00271                     in, out, 
00272                     qbuf, rbuf,
00273                     reg_io_q_getversion,
00274                     reg_io_r_getversion, 
00275                     WERR_GENERAL_FAILURE );
00276                     
00277 
00278         if ( !W_ERROR_IS_OK( out.status ) )
00279                 return out.status;
00280                 
00281         *version = out.win_version;
00282 
00283         return out.status;
00284 }
00285 
00286 /****************************************************************************
00287 do a REG Query Info
00288 ****************************************************************************/
00289 
00290 WERROR rpccli_reg_query_value(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00291                            POLICY_HND *hnd, const char *val_name,
00292                            uint32 *type, REGVAL_BUFFER *buffer)
00293 {
00294         REG_Q_QUERY_VALUE in;
00295         REG_R_QUERY_VALUE out;
00296         prs_struct qbuf, rbuf;
00297 
00298         ZERO_STRUCT (in);
00299         ZERO_STRUCT (out);
00300         
00301         init_reg_q_query_value(&in, hnd, val_name, buffer);
00302 
00303         CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_QUERY_VALUE, 
00304                     in, out, 
00305                     qbuf, rbuf,
00306                     reg_io_q_query_value,
00307                     reg_io_r_query_value, 
00308                     WERR_GENERAL_FAILURE );
00309                     
00310 
00311         if ( !W_ERROR_IS_OK( out.status ) )
00312                 return out.status;
00313                 
00314         *type   = *out.type;
00315         *buffer = *out.value;
00316 
00317         return out.status;
00318 }
00319 
00320 /****************************************************************************
00321 do a REG Set Key Security 
00322 ****************************************************************************/
00323 
00324 WERROR rpccli_reg_set_key_sec(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00325                              POLICY_HND *hnd, uint32 sec_info,
00326                              size_t secdesc_size, SEC_DESC *sec_desc)
00327 {
00328         REG_Q_SET_KEY_SEC in;
00329         REG_R_SET_KEY_SEC out;
00330         prs_struct qbuf, rbuf;
00331         SEC_DESC_BUF *sec_desc_buf;
00332 
00333         ZERO_STRUCT (in);
00334         ZERO_STRUCT (out);
00335         
00336         /* Flatten the security descriptor */
00337         
00338         if ( !(sec_desc_buf = make_sec_desc_buf(mem_ctx, secdesc_size, sec_desc)) )
00339                 return WERR_GENERAL_FAILURE;
00340                 
00341         init_reg_q_set_key_sec(&in, hnd, sec_info, sec_desc_buf);
00342 
00343         CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_SET_KEY_SEC, 
00344                     in, out, 
00345                     qbuf, rbuf,
00346                     reg_io_q_set_key_sec,
00347                     reg_io_r_set_key_sec, 
00348                     WERR_GENERAL_FAILURE );
00349                     
00350 
00351         return out.status;
00352 }
00353 
00354 
00355 /****************************************************************************
00356 do a REG Query Key Security 
00357 ****************************************************************************/
00358 
00359 WERROR rpccli_reg_get_key_sec(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00360                              POLICY_HND *hnd, uint32 sec_info,
00361                              uint32 *sec_buf_size, SEC_DESC_BUF *sec_buf)
00362 {
00363         REG_Q_GET_KEY_SEC in;
00364         REG_R_GET_KEY_SEC out;
00365         prs_struct qbuf, rbuf;
00366 
00367         ZERO_STRUCT (in);
00368         ZERO_STRUCT (out);
00369         
00370         init_reg_q_get_key_sec(&in, hnd, sec_info, *sec_buf_size, sec_buf);
00371 
00372         CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_GET_KEY_SEC, 
00373                     in, out, 
00374                     qbuf, rbuf,
00375                     reg_io_q_get_key_sec,
00376                     reg_io_r_get_key_sec, 
00377                     WERR_GENERAL_FAILURE );
00378                     
00379 
00380         /* this might be able to return WERR_MORE_DATA, I'm not sure */
00381         
00382         if ( !W_ERROR_IS_OK( out.status ) )
00383                 return out.status;
00384         
00385         sec_buf       = out.data;
00386         *sec_buf_size = out.data->len;
00387                 
00388         return out.status;      
00389 }
00390 
00391 /****************************************************************************
00392 do a REG Delete Value
00393 ****************************************************************************/
00394 
00395 WERROR rpccli_reg_delete_val(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00396                             POLICY_HND *hnd, char *val_name)
00397 {
00398         REG_Q_DELETE_VALUE in;
00399         REG_R_DELETE_VALUE out;
00400         prs_struct qbuf, rbuf;
00401 
00402         ZERO_STRUCT (in);
00403         ZERO_STRUCT (out);
00404         
00405         init_reg_q_delete_val(&in, hnd, val_name);
00406 
00407         CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_DELETE_VALUE, 
00408                     in, out, 
00409                     qbuf, rbuf,
00410                     reg_io_q_delete_value,
00411                     reg_io_r_delete_value, 
00412                     WERR_GENERAL_FAILURE );
00413         
00414         return out.status;
00415 }
00416 
00417 /****************************************************************************
00418 do a REG Delete Key
00419 ****************************************************************************/
00420 
00421 WERROR rpccli_reg_delete_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00422                             POLICY_HND *hnd, char *key_name)
00423 {
00424         REG_Q_DELETE_KEY in;
00425         REG_R_DELETE_KEY out;
00426         prs_struct qbuf, rbuf;
00427 
00428         ZERO_STRUCT (in);
00429         ZERO_STRUCT (out);
00430         
00431         init_reg_q_delete_key(&in, hnd, key_name);
00432 
00433         CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_DELETE_KEY, 
00434                     in, out, 
00435                     qbuf, rbuf,
00436                     reg_io_q_delete_key,
00437                     reg_io_r_delete_key, 
00438                     WERR_GENERAL_FAILURE );
00439         
00440         return out.status;
00441 }
00442 
00443 /****************************************************************************
00444 do a REG Create Key
00445 ****************************************************************************/
00446 
00447 WERROR rpccli_reg_create_key_ex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00448                             POLICY_HND *hnd, char *key_name, char *key_class,
00449                             uint32 access_desired, POLICY_HND *key)
00450 {
00451         REG_Q_CREATE_KEY_EX in;
00452         REG_R_CREATE_KEY_EX out;
00453         prs_struct qbuf, rbuf;
00454         SEC_DESC *sec;
00455         SEC_DESC_BUF *sec_buf;
00456         size_t sec_len;
00457 
00458         ZERO_STRUCT (in);
00459         ZERO_STRUCT (out);
00460         
00461         if ( !(sec = make_sec_desc(mem_ctx, 1, SEC_DESC_SELF_RELATIVE,
00462                 NULL, NULL, NULL, NULL, &sec_len)) ) {
00463                 return WERR_GENERAL_FAILURE;
00464         }
00465                                  
00466         if ( !(sec_buf = make_sec_desc_buf(mem_ctx, sec_len, sec)) )
00467                 return WERR_GENERAL_FAILURE;
00468 
00469         init_reg_q_create_key_ex(&in, hnd, key_name, key_class, access_desired, sec_buf);
00470 
00471         CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_CREATE_KEY_EX, 
00472                     in, out, 
00473                     qbuf, rbuf,
00474                     reg_io_q_create_key_ex,
00475                     reg_io_r_create_key_ex, 
00476                     WERR_GENERAL_FAILURE );
00477                     
00478 
00479         if ( !W_ERROR_IS_OK( out.status ) )
00480                 return out.status;
00481         
00482         memcpy( key, &out.handle, sizeof(POLICY_HND) );
00483         
00484         return out.status;
00485 }
00486 
00487 /****************************************************************************
00488 do a REG Enum Key
00489 ****************************************************************************/
00490 
00491 WERROR rpccli_reg_enum_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00492                           POLICY_HND *hnd, int key_index, fstring key_name,
00493                           fstring class_name, time_t *mod_time)
00494 {
00495         REG_Q_ENUM_KEY in;
00496         REG_R_ENUM_KEY out;
00497         prs_struct qbuf, rbuf;
00498 
00499         ZERO_STRUCT (in);
00500         ZERO_STRUCT (out);
00501         
00502         init_reg_q_enum_key(&in, hnd, key_index);
00503 
00504         CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_ENUM_KEY, 
00505                     in, out, 
00506                     qbuf, rbuf,
00507                     reg_io_q_enum_key,
00508                     reg_io_r_enum_key, 
00509                     WERR_GENERAL_FAILURE );
00510 
00511         if ( !W_ERROR_IS_OK(out.status) )
00512                 return out.status;
00513 
00514         if ( out.keyname.string )
00515                 rpcstr_pull( key_name, out.keyname.string->buffer, sizeof(fstring), -1, STR_TERMINATE );
00516         else
00517                 fstrcpy( key_name, "(Default)" );
00518 
00519         if ( out.classname && out.classname->string )
00520                 rpcstr_pull( class_name, out.classname->string->buffer, sizeof(fstring), -1, STR_TERMINATE );
00521         else
00522                 fstrcpy( class_name, "" );
00523 
00524         *mod_time   = nt_time_to_unix(*out.time);
00525 
00526         return out.status;
00527 }
00528 
00529 /****************************************************************************
00530 do a REG Create Value
00531 ****************************************************************************/
00532 
00533 WERROR rpccli_reg_set_val(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00534                             POLICY_HND *hnd, char *val_name, uint32 type,
00535                             RPC_DATA_BLOB *data)
00536 {
00537         REG_Q_SET_VALUE in;
00538         REG_R_SET_VALUE out;
00539         prs_struct qbuf, rbuf;
00540 
00541         ZERO_STRUCT (in);
00542         ZERO_STRUCT (out);
00543         
00544         init_reg_q_set_val(&in, hnd, val_name, type, data);
00545 
00546         CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_SET_VALUE, 
00547                     in, out, 
00548                     qbuf, rbuf,
00549                     reg_io_q_set_value,
00550                     reg_io_r_set_value, 
00551                     WERR_GENERAL_FAILURE );
00552 
00553         return out.status;
00554 }
00555 
00556 /****************************************************************************
00557 do a REG Enum Value
00558 ****************************************************************************/
00559 
00560 WERROR rpccli_reg_enum_val(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00561                           POLICY_HND *hnd, int idx,
00562                           fstring val_name, uint32 *type, REGVAL_BUFFER *value)
00563 {
00564         REG_Q_ENUM_VALUE in;
00565         REG_R_ENUM_VALUE out;
00566         prs_struct qbuf, rbuf;
00567 
00568         ZERO_STRUCT (in);
00569         ZERO_STRUCT (out);
00570         
00571         init_reg_q_enum_val(&in, hnd, idx, 0x0100, 0x1000);
00572 
00573         CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_ENUM_VALUE, 
00574                     in, out, 
00575                     qbuf, rbuf,
00576                     reg_io_q_enum_val,
00577                     reg_io_r_enum_val, 
00578                     WERR_GENERAL_FAILURE );
00579 
00580         if ( W_ERROR_EQUAL(out.status, WERR_MORE_DATA) ) {
00581 
00582                 ZERO_STRUCT (in);
00583 
00584                 init_reg_q_enum_val(&in, hnd, idx, 0x0100, *out.buffer_len1);
00585 
00586                 ZERO_STRUCT (out);
00587 
00588                 CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_ENUM_VALUE, 
00589                             in, out, 
00590                             qbuf, rbuf,
00591                             reg_io_q_enum_val,
00592                             reg_io_r_enum_val, 
00593                             WERR_GENERAL_FAILURE );
00594         }
00595 
00596         if ( !W_ERROR_IS_OK(out.status) )
00597                 return out.status;
00598 
00599         unistr2_to_ascii(val_name, out.name.string, sizeof(fstring)-1);
00600         *type      = *out.type;
00601         *value     = *out.value;
00602         
00603         return out.status;
00604 }
00605 
00606 /****************************************************************************
00607 ****************************************************************************/
00608 
00609 WERROR rpccli_reg_open_entry(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00610                             POLICY_HND *hnd, char *key_name,
00611                             uint32 access_desired, POLICY_HND *key_hnd)
00612 {
00613         REG_Q_OPEN_ENTRY in;
00614         REG_R_OPEN_ENTRY out;
00615         prs_struct qbuf, rbuf;
00616 
00617         ZERO_STRUCT (in);
00618         ZERO_STRUCT (out);
00619         
00620         init_reg_q_open_entry(&in, hnd, key_name, access_desired);
00621 
00622         CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_OPEN_ENTRY, 
00623                     in, out, 
00624                     qbuf, rbuf,
00625                     reg_io_q_open_entry,
00626                     reg_io_r_open_entry, 
00627                     WERR_GENERAL_FAILURE );
00628 
00629         if ( !W_ERROR_IS_OK( out.status ) )
00630                 return out.status;
00631 
00632         memcpy( key_hnd, &out.handle, sizeof(POLICY_HND) );
00633         
00634         return out.status;
00635 }
00636 
00637 /****************************************************************************
00638 ****************************************************************************/
00639 
00640 WERROR rpccli_reg_close(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00641                        POLICY_HND *hnd)
00642 {
00643         REG_Q_CLOSE in;
00644         REG_R_CLOSE out;
00645         prs_struct qbuf, rbuf;
00646 
00647         ZERO_STRUCT (in);
00648         ZERO_STRUCT (out);
00649         
00650         init_reg_q_close(&in, hnd);
00651 
00652         CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_CLOSE, 
00653                     in, out, 
00654                     qbuf, rbuf,
00655                     reg_io_q_close,
00656                     reg_io_r_close, 
00657                     WERR_GENERAL_FAILURE );
00658         
00659         return out.status;
00660 }
00661 
00662 /****************************************************************************
00663 do a REG Query Info
00664 ****************************************************************************/
00665 
00666 WERROR rpccli_reg_save_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00667                          POLICY_HND *hnd, const char *filename )
00668 {
00669         REG_Q_SAVE_KEY in;
00670         REG_R_SAVE_KEY out;
00671         prs_struct qbuf, rbuf;
00672 
00673         ZERO_STRUCT (in);
00674         ZERO_STRUCT (out);
00675         
00676         init_q_reg_save_key( &in, hnd, filename );
00677 
00678         CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_SAVE_KEY, 
00679                     in, out, 
00680                     qbuf, rbuf,
00681                     reg_io_q_save_key,
00682                     reg_io_r_save_key,
00683                     WERR_GENERAL_FAILURE );
00684 
00685         return out.status;
00686 }
00687 
00688 
00689 /* 
00690  #################################################################
00691   Utility functions
00692  #################################################################
00693  */
00694 
00695 /*****************************************************************
00696  Splits out the start of the key (HKLM or HKU) and the rest of the key.
00697 *****************************************************************/  
00698 
00699 BOOL reg_split_hive(const char *full_keyname, uint32 *reg_type, pstring key_name)
00700 {
00701         pstring tmp;
00702 
00703         if (!next_token(&full_keyname, tmp, "\\", sizeof(tmp)))
00704                 return False;
00705 
00706         (*reg_type) = 0;
00707 
00708         DEBUG(10, ("reg_split_key: hive %s\n", tmp));
00709 
00710         if (strequal(tmp, "HKLM") || strequal(tmp, "HKEY_LOCAL_MACHINE"))
00711                 (*reg_type) = HKEY_LOCAL_MACHINE;
00712         else if (strequal(tmp, "HKCR") || strequal(tmp, "HKEY_CLASSES_ROOT"))
00713                 (*reg_type) = HKEY_CLASSES_ROOT;
00714         else if (strequal(tmp, "HKU") || strequal(tmp, "HKEY_USERS"))
00715                 (*reg_type) = HKEY_USERS;
00716         else if (strequal(tmp, "HKPD")||strequal(tmp, "HKEY_PERFORMANCE_DATA"))
00717                 (*reg_type) = HKEY_PERFORMANCE_DATA;
00718         else {
00719                 DEBUG(10,("reg_split_key: unrecognised hive key %s\n", tmp));
00720                 return False;
00721         }
00722         
00723         if (next_token(&full_keyname, tmp, "\n\r", sizeof(tmp)))
00724                 pstrcpy(key_name, tmp);
00725         else
00726                 key_name[0] = 0;
00727 
00728         DEBUG(10, ("reg_split_key: name %s\n", key_name));
00729 
00730         return True;
00731 }

Sambaに対してSat Aug 29 21:23:16 2009に生成されました。  doxygen 1.4.7