560e1ded31c6769a63d9dd15db27fb35aca5bf8c
[bbaumbach/samba-autobuild/.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 3 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, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "includes.h"
20 #include "registry.h"
21
22 /**
23  * @file
24  * @brief Samba-specific registry functions
25  */
26
27 static WERROR reg_samba_get_predef (struct registry_context *ctx, uint32_t hkey, struct registry_key **k)
28 {
29         WERROR error;
30         const char *conf;
31         char *backend;
32         const char *location;
33         const char *hivename = reg_get_predef_name(hkey);
34
35         *k = NULL;
36
37         conf = lp_parm_string(-1, "registry", hivename);
38         
39         if (!conf) {
40                 return WERR_NOT_SUPPORTED;
41         }
42
43         location = strchr(conf, ':');
44         if (location) {
45                 backend = talloc_strndup(ctx, conf, (int)(location - conf));
46                 location++;
47         } else {
48                 backend = talloc_strdup(ctx, "ldb");
49                 location = conf;
50         }
51
52         /* FIXME: Different hive backend for HKEY_CLASSES_ROOT: merged view of HKEY_LOCAL_MACHINE\Software\Classes
53          * and HKEY_CURRENT_USER\Software\Classes */
54
55         /* FIXME: HKEY_CURRENT_CONFIG is an alias for HKEY_LOCAL_MACHINE\System\CurrentControlSet\Hardware Profiles\Current */
56
57         /* FIXME: HKEY_PERFORMANCE_DATA is dynamically generated */
58
59         /* FIXME: HKEY_LOCAL_MACHINE\Hardware is autogenerated */
60
61         /* FIXME: HKEY_LOCAL_MACHINE\Security\SAM is an alias for HKEY_LOCAL_MACHINE\SAM */
62
63         error = reg_open_hive(ctx, backend, location, ctx->session_info, ctx->credentials, k);
64
65         talloc_free(backend);
66
67         return error;
68 }
69
70 _PUBLIC_ WERROR reg_open_local (TALLOC_CTX *mem_ctx, 
71                                 struct registry_context **ctx, 
72                                 struct auth_session_info *session_info, 
73                                 struct cli_credentials *credentials)
74 {
75         *ctx = talloc(mem_ctx, struct registry_context);
76         (*ctx)->credentials = talloc_reference(*ctx, credentials);
77         (*ctx)->session_info = talloc_reference(*ctx, session_info);
78         (*ctx)->get_predefined_key = reg_samba_get_predef;
79         
80         return WERR_OK;
81 }