r9209: - fixed the ldb registry backend to work with the new provision ldif
[samba.git] / source4 / lib / registry / reg_samba.c
1 /* 
2    Unix SMB/CIFS implementation.
3    Copyright (C) Jelmer Vernooij                        2004.
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include "includes.h"
21 #include "registry.h"
22
23 #undef DBGC_CLASS
24 #define DBGC_CLASS DBGC_REGISTRY
25
26 static WERROR reg_samba_get_predef (struct registry_context *ctx, uint32_t hkey, struct registry_key **k)
27 {
28         WERROR error;
29         const char *conf;
30         char *backend;
31         const char *location;
32         const char *hivename = reg_get_predef_name(hkey);
33
34         *k = NULL;
35
36         conf = lp_parm_string(-1, "registry", hivename);
37         
38         if (!conf) {
39                 return WERR_NOT_SUPPORTED;
40         }
41
42         location = strchr(conf, ':');
43         if (location) {
44                 backend = talloc_strndup(ctx, conf, (int)(location - conf));
45                 location++;
46         } else {
47                 backend = talloc_strdup(ctx, "ldb");
48                 location = conf;
49         }
50
51         /* FIXME: Different hive backend for HKEY_CLASSES_ROOT: merged view of HKEY_LOCAL_MACHINE\Software\Classes
52          * and HKEY_CURRENT_USER\Software\Classes */
53
54         /* FIXME: HKEY_CURRENT_CONFIG is an alias for HKEY_LOCAL_MACHINE\System\CurrentControlSet\Hardware Profiles\Current */
55
56         /* FIXME: HKEY_PERFORMANCE_DATA is dynamically generated */
57
58         /* FIXME: HKEY_LOCAL_MACHINE\Hardware is autogenerated */
59
60         /* FIXME: HKEY_LOCAL_MACHINE\Security\SAM is an alias for HKEY_LOCAL_MACHINE\SAM */
61
62         error = reg_open_hive(ctx, backend, location, NULL, k);
63
64         talloc_free(backend);
65
66         return error;
67 }
68
69 WERROR reg_open_local (struct registry_context **ctx)
70 {
71         *ctx = talloc(NULL, struct registry_context);
72         (*ctx)->get_predefined_key = reg_samba_get_predef;
73         
74         return WERR_OK;
75 }