s3:smbd: pass smbXsrv_connection to process_smb()
[Samba.git] / source3 / utils / regedit_wrap.c
blob00d72d88f1ab002cfcc7d3b0e54777e6422ba59a
1 /*
2 * Samba Unix/Linux SMB client library
3 * Registry Editor
4 * Copyright (C) Christopher Davis 2012
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 /* Wrap s3 registry API calls to avoid conflicts with 'struct registry_key',
21 etc, in s4 libregistry. */
23 #include "includes.h"
24 #include "registry.h"
25 #include "registry/reg_api.h"
26 #include "registry/reg_init_basic.h"
27 #include "registry/reg_util_token.h"
29 #include "regedit.h"
31 WERROR reg_openhive_wrap(TALLOC_CTX *ctx, const char *hive,
32 struct samba3_registry_key *pkey)
34 struct security_token *token;
35 WERROR rv;
37 SMB_ASSERT(pkey->key == NULL);
39 rv = ntstatus_to_werror(registry_create_admin_token(ctx, &token));
40 if (!W_ERROR_IS_OK(rv)) {
41 return rv;
44 return reg_openhive(ctx, hive, REG_KEY_READ | REG_KEY_WRITE, token,
45 &pkey->key);
48 WERROR reg_openkey_wrap(TALLOC_CTX *ctx, struct samba3_registry_key *parent,
49 const char *name, struct samba3_registry_key *pkey)
51 SMB_ASSERT(pkey->key == NULL);
52 return reg_openkey(ctx, parent->key, name,
53 REG_KEY_READ | REG_KEY_WRITE, &pkey->key);
56 WERROR reg_enumvalue_wrap(TALLOC_CTX *ctx, struct samba3_registry_key *key,
57 uint32 idx, char **name, uint32_t *type,
58 DATA_BLOB *data)
60 struct registry_value *val = NULL;
61 WERROR rv;
63 rv = reg_enumvalue(ctx, key->key, idx, name, &val);
65 if (val && W_ERROR_IS_OK(rv)) {
66 *type = (uint32_t)val->type;
67 *data = val->data;
70 return rv;
73 WERROR reg_queryvalue_wrap(TALLOC_CTX *ctx, struct samba3_registry_key *key,
74 const char *name, uint32_t *type, DATA_BLOB *data)
76 struct registry_value *val = NULL;
77 WERROR rv;
79 rv = reg_queryvalue(ctx, key->key, name, &val);
81 if (val && W_ERROR_IS_OK(rv)) {
82 *type = (uint32_t)val->type;
83 *data = val->data;
86 return rv;
89 WERROR reg_enumkey_wrap(TALLOC_CTX *ctx, struct samba3_registry_key *key,
90 uint32 idx, char **name, NTTIME *last_write_time)
92 return reg_enumkey(ctx, key->key, idx, name, last_write_time);
95 WERROR reg_createkey_wrap(TALLOC_CTX *ctx, struct samba3_registry_key *parent,
96 const char *subkeypath,
97 struct samba3_registry_key *pkey)
99 enum winreg_CreateAction act;
101 SMB_ASSERT(pkey->key == NULL);
102 return reg_createkey(ctx, parent->key, subkeypath,
103 REG_KEY_READ | REG_KEY_WRITE, &pkey->key, &act);
106 WERROR reg_deletekey_wrap(struct samba3_registry_key *parent, const char *path)
108 return reg_deletekey(parent->key, path);
111 WERROR reg_deletevalue_wrap(struct samba3_registry_key *key, const char *name)
113 return reg_deletevalue(key->key, name);
116 WERROR reg_queryinfokey_wrap(struct samba3_registry_key *key,
117 uint32_t *num_subkeys, uint32_t *max_subkeylen,
118 uint32_t *max_subkeysize, uint32_t *num_values,
119 uint32_t *max_valnamelen,
120 uint32_t *max_valbufsize, uint32_t *secdescsize,
121 NTTIME *last_changed_time)
123 return reg_queryinfokey(key->key, num_subkeys, max_subkeylen,
124 max_subkeysize, num_values, max_valnamelen,
125 max_valbufsize, secdescsize,
126 last_changed_time);
129 WERROR reg_setvalue_wrap(struct samba3_registry_key *key, const char *name,
130 uint32_t type, const DATA_BLOB data)
132 struct registry_value val;
134 val.type = type;
135 val.data = data;
137 return reg_setvalue(key->key, name, &val);
140 WERROR reg_init_wrap(void)
142 return registry_init_basic();