r25417: Use DBGC_REGISTRY class.
[samba.git] / source3 / lib / util_reg.c
index c74a57314974222ce601bda7ffb0f6c6a8508b38..c319d7d31f03ddf8eadaa259b363af2253ba1078 100644 (file)
@@ -5,7 +5,7 @@
  * 
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
+ * Software Foundation; either version 3 of the License, or (at your option)
  * any later version.
  * 
  * This program is distributed in the hope that it will be useful, but WITHOUT
  * more details.
  * 
  * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 675
- * Mass Ave, Cambridge, MA 02139, USA.
+ * this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "includes.h"
 
-const char *reg_type_lookup(uint32 type)
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_REGISTRY
+
+extern REGISTRY_OPS smbconf_reg_ops;
+
+const char *reg_type_lookup(enum winreg_Type type)
 {
        const char *result;
 
@@ -68,8 +72,8 @@ const char *reg_type_lookup(uint32 type)
        return result;
 }
 
-NTSTATUS reg_pull_multi_sz(TALLOC_CTX *mem_ctx, const void *buf, size_t len,
-                          uint32 *num_values, char ***values)
+WERROR reg_pull_multi_sz(TALLOC_CTX *mem_ctx, const void *buf, size_t len,
+                        uint32 *num_values, char ***values)
 {
        const smb_ucs2_t *p = (const smb_ucs2_t *)buf;
        *num_values = 0;
@@ -79,7 +83,7 @@ NTSTATUS reg_pull_multi_sz(TALLOC_CTX *mem_ctx, const void *buf, size_t len,
         */
 
        if (!(*values = TALLOC_ARRAY(mem_ctx, char *, 1))) {
-               return NT_STATUS_NO_MEMORY;
+               return WERR_NOMEM;
        }
 
        len /= 2;               /* buf is a set of UCS2 strings */
@@ -94,17 +98,46 @@ NTSTATUS reg_pull_multi_sz(TALLOC_CTX *mem_ctx, const void *buf, size_t len,
                                                 True);
                if (dstlen == (size_t)-1) {
                        TALLOC_FREE(*values);
-                       return NT_STATUS_NO_MEMORY;
+                       return WERR_NOMEM;
                }
 
                ADD_TO_ARRAY(*values, char *, val, values, num_values);
                if (*values == NULL) {
-                       return NT_STATUS_NO_MEMORY;
+                       return WERR_NOMEM;
                }
 
                p += thislen;
                len -= thislen;
        }
 
-       return NT_STATUS_OK;
+       return WERR_OK;
+}
+
+void normalize_dbkey(char *key)
+{
+       size_t len = strlen(key);
+       string_sub(key, "\\", "/", len+1);
+       strupper_m(key);
+}
+
+/*
+ * check whether a given value name is forbidden in registry (smbconf)
+ */
+BOOL registry_smbconf_valname_forbidden(const char *valname)
+{
+       /* hard code the list of forbidden names here for now */
+       const char *forbidden_valnames[] = {
+               "include",
+               "lock directory",
+               "lock dir",
+               NULL
+       };
+       const char **forbidden = NULL;
+
+       for (forbidden = forbidden_valnames; *forbidden != NULL; forbidden++) {
+               if (strwicmp(valname, *forbidden) == 0) {
+                       return True;
+               }
+       }
+       return False;
 }