source: vendor/current/source3/utils/regedit_wrap.c

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 3.8 KB
Line 
1/*
2 * Samba Unix/Linux SMB client library
3 * Registry Editor
4 * Copyright (C) Christopher Davis 2012
5 *
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.
10 *
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.
15 *
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/>.
18 */
19
20/* Wrap s3 registry API calls to avoid conflicts with 'struct registry_key',
21 etc, in s4 libregistry. */
22
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"
28
29#include "regedit.h"
30
31WERROR reg_openhive_wrap(TALLOC_CTX *ctx, const char *hive,
32 struct samba3_registry_key *pkey)
33{
34 struct security_token *token;
35 WERROR rv;
36
37 SMB_ASSERT(pkey->key == NULL);
38
39 rv = ntstatus_to_werror(registry_create_admin_token(ctx, &token));
40 if (!W_ERROR_IS_OK(rv)) {
41 return rv;
42 }
43
44 return reg_openhive(ctx, hive, REG_KEY_READ | REG_KEY_WRITE, token,
45 &pkey->key);
46}
47
48WERROR reg_openkey_wrap(TALLOC_CTX *ctx, struct samba3_registry_key *parent,
49 const char *name, struct samba3_registry_key *pkey)
50{
51 SMB_ASSERT(pkey->key == NULL);
52 return reg_openkey(ctx, parent->key, name,
53 REG_KEY_READ | REG_KEY_WRITE, &pkey->key);
54}
55
56WERROR reg_enumvalue_wrap(TALLOC_CTX *ctx, struct samba3_registry_key *key,
57 uint32_t idx, char **name, uint32_t *type,
58 DATA_BLOB *data)
59{
60 struct registry_value *val = NULL;
61 WERROR rv;
62
63 rv = reg_enumvalue(ctx, key->key, idx, name, &val);
64
65 if (val && W_ERROR_IS_OK(rv)) {
66 *type = (uint32_t)val->type;
67 *data = val->data;
68 }
69
70 return rv;
71}
72
73WERROR reg_queryvalue_wrap(TALLOC_CTX *ctx, struct samba3_registry_key *key,
74 const char *name, uint32_t *type, DATA_BLOB *data)
75{
76 struct registry_value *val = NULL;
77 WERROR rv;
78
79 rv = reg_queryvalue(ctx, key->key, name, &val);
80
81 if (val && W_ERROR_IS_OK(rv)) {
82 *type = (uint32_t)val->type;
83 *data = val->data;
84 }
85
86 return rv;
87}
88
89WERROR reg_enumkey_wrap(TALLOC_CTX *ctx, struct samba3_registry_key *key,
90 uint32_t idx, char **name, NTTIME *last_write_time)
91{
92 return reg_enumkey(ctx, key->key, idx, name, last_write_time);
93}
94
95WERROR reg_createkey_wrap(TALLOC_CTX *ctx, struct samba3_registry_key *parent,
96 const char *subkeypath,
97 struct samba3_registry_key *pkey)
98{
99 enum winreg_CreateAction act;
100
101 SMB_ASSERT(pkey->key == NULL);
102 return reg_createkey(ctx, parent->key, subkeypath,
103 REG_KEY_READ | REG_KEY_WRITE, &pkey->key, &act);
104}
105
106WERROR reg_deletekey_wrap(struct samba3_registry_key *parent, const char *path)
107{
108 return reg_deletekey(parent->key, path);
109}
110
111WERROR reg_deletevalue_wrap(struct samba3_registry_key *key, const char *name)
112{
113 return reg_deletevalue(key->key, name);
114}
115
116WERROR 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)
122{
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);
127}
128
129WERROR reg_setvalue_wrap(struct samba3_registry_key *key, const char *name,
130 uint32_t type, const DATA_BLOB data)
131{
132 struct registry_value val;
133
134 val.type = type;
135 val.data = data;
136
137 return reg_setvalue(key->key, name, &val);
138}
139
140WERROR reg_init_wrap(void)
141{
142 return registry_init_basic();
143}
Note: See TracBrowser for help on using the repository browser.