Zero out the out policy handler in lsa_Close
[Samba/gebeck_regimport.git] / source3 / lib / util_reg.c
blob2475dca04022cfaf99ef9425f24371b5f1dd9e98
1 /*
2 * Unix SMB/CIFS implementation.
3 * Registry helper routines
4 * Copyright (C) Volker Lendecke 2006
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 3 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, see <http://www.gnu.org/licenses/>.
20 #include "includes.h"
22 #undef DBGC_CLASS
23 #define DBGC_CLASS DBGC_REGISTRY
25 extern REGISTRY_OPS smbconf_reg_ops;
27 const char *reg_type_lookup(enum winreg_Type type)
29 const char *result;
31 switch(type) {
32 case REG_NONE:
33 result = "REG_NONE";
34 break;
35 case REG_SZ:
36 result = "REG_SZ";
37 break;
38 case REG_EXPAND_SZ:
39 result = "REG_EXPAND_SZ";
40 break;
41 case REG_BINARY:
42 result = "REG_BINARY";
43 break;
44 case REG_DWORD:
45 result = "REG_DWORD";
46 break;
47 case REG_DWORD_BIG_ENDIAN:
48 result = "REG_DWORD_BIG_ENDIAN";
49 break;
50 case REG_LINK:
51 result = "REG_LINK";
52 break;
53 case REG_MULTI_SZ:
54 result = "REG_MULTI_SZ";
55 break;
56 case REG_RESOURCE_LIST:
57 result = "REG_RESOURCE_LIST";
58 break;
59 case REG_FULL_RESOURCE_DESCRIPTOR:
60 result = "REG_FULL_RESOURCE_DESCRIPTOR";
61 break;
62 case REG_RESOURCE_REQUIREMENTS_LIST:
63 result = "REG_RESOURCE_REQUIREMENTS_LIST";
64 break;
65 case REG_QWORD:
66 result = "REG_QWORD";
67 break;
68 default:
69 result = "REG TYPE IS UNKNOWN";
70 break;
72 return result;
75 WERROR reg_pull_multi_sz(TALLOC_CTX *mem_ctx, const void *buf, size_t len,
76 uint32 *num_values, char ***values)
78 const smb_ucs2_t *p = (const smb_ucs2_t *)buf;
79 *num_values = 0;
82 * Make sure that a talloc context for the strings retrieved exists
85 if (!(*values = TALLOC_ARRAY(mem_ctx, char *, 1))) {
86 return WERR_NOMEM;
89 len /= 2; /* buf is a set of UCS2 strings */
91 while (len > 0) {
92 char *val;
93 size_t dstlen, thislen;
95 thislen = strnlen_w(p, len) + 1;
96 dstlen = convert_string_allocate(*values, CH_UTF16LE, CH_UNIX,
97 p, thislen*2, (void *)&val,
98 true);
99 if (dstlen == (size_t)-1) {
100 TALLOC_FREE(*values);
101 return WERR_NOMEM;
104 ADD_TO_ARRAY(*values, char *, val, values, num_values);
105 if (*values == NULL) {
106 return WERR_NOMEM;
109 p += thislen;
110 len -= thislen;
113 return WERR_OK;
116 void normalize_dbkey(char *key)
118 size_t len = strlen(key);
119 string_sub(key, "\\", "/", len+1);
120 strupper_m(key);
124 * check whether a given value name is forbidden in registry (smbconf)
126 bool registry_smbconf_valname_forbidden(const char *valname)
128 /* hard code the list of forbidden names here for now */
129 const char *forbidden_valnames[] = {
130 "include",
131 "lock directory",
132 "lock dir",
133 "config backend",
134 NULL
136 const char **forbidden = NULL;
138 for (forbidden = forbidden_valnames; *forbidden != NULL; forbidden++) {
139 if (strwicmp(valname, *forbidden) == 0) {
140 return true;
143 return false;