r25068: Older samba3 DCs will return DCERPC_FAULT_OP_RNG_ERROR for every opcode on the
[Samba.git] / source / lib / util_reg_smbconf.c
blob8fe6b4e0b689b8a0ff0efde5f738dea0b00fed65
1 /*
2 * Unix SMB/CIFS implementation.
3 * Registry helper routines
4 * Copyright (C) Michael Adam 2007
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc., 675
18 * Mass Ave, Cambridge, MA 02139, USA.
21 #include "includes.h"
23 extern REGISTRY_OPS smbconf_reg_ops;
26 * create a fake token just with enough rights to
27 * locally access the registry.
29 NT_USER_TOKEN *registry_create_admin_token(TALLOC_CTX *mem_ctx)
31 NT_USER_TOKEN *token = NULL;
33 /* fake a user token: builtin administrators sid and the
34 * disk operators privilege is all we need to access the
35 * registry... */
36 if (!(token = TALLOC_ZERO_P(mem_ctx, NT_USER_TOKEN))) {
37 DEBUG(1, ("talloc failed\n"));
38 goto done;
40 token->privileges = se_disk_operators;
41 if (!add_sid_to_array(token, &global_sid_Builtin_Administrators,
42 &token->user_sids, &token->num_sids)) {
43 DEBUG(1, ("Error adding builtin administrators sid "
44 "to fake token.\n"));
45 goto done;
47 done:
48 return token;
52 * init the smbconf portion of the registry.
53 * for use in places where not the whole registry is needed,
54 * e.g. utils/net_conf.c and loadparm.c
56 BOOL registry_init_regdb(void)
58 BOOL ret = False;
59 int saved_errno = 0;
60 static REGISTRY_HOOK smbconf_reg_hook = {KEY_SMBCONF, &smbconf_reg_ops};
62 DEBUG(10, ("registry_init_regdb called\n"));
64 if (!regdb_init()) {
65 saved_errno = errno;
66 DEBUG(1, ("Can't open the registry"));
67 if (saved_errno) {
68 DEBUGADD(1, (": %s", strerror(saved_errno)));
70 DEBUGADD(1, (".\n"));
71 goto done;
73 reghook_cache_init();
74 if (!reghook_cache_add(&smbconf_reg_hook)) {
75 DEBUG(1, ("Error adding smbconf reghooks to reghook cache.\n"));
76 goto done;
79 ret = True;
81 done:
82 return ret;