Fix authservice count.
[jelmer/samba4-debian.git] / source / lib / registry / samba.c
1 /*
2    Unix SMB/CIFS implementation.
3    Copyright (C) Jelmer Vernooij                        2004-2007.
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 #include "param/param.h"
22
23 /**
24  * @file
25  * @brief Samba-specific registry functions
26  */
27
28 static WERROR mount_samba_hive(struct registry_context *ctx,
29                                struct loadparm_context *lp_ctx,
30                                struct auth_session_info *auth_info,
31                                struct cli_credentials *creds,
32                                const char *name,
33                                uint32_t hive_id)
34 {
35         WERROR error;
36         struct hive_key *hive;
37         const char *location;
38
39         location = talloc_asprintf(ctx, "%s/%s.ldb",
40                                    lp_private_dir(lp_ctx),
41                                    name);
42
43         error = reg_open_hive(ctx, location, auth_info, creds, lp_ctx, &hive);
44
45         if (W_ERROR_EQUAL(error, WERR_BADFILE))
46                 error = reg_open_ldb_file(ctx, location, auth_info,
47                                           creds, lp_ctx, &hive);
48
49         if (!W_ERROR_IS_OK(error))
50                 return error;
51
52         return reg_mount_hive(ctx, hive, hive_id, NULL);
53 }
54
55
56 _PUBLIC_ WERROR reg_open_samba(TALLOC_CTX *mem_ctx,
57                                struct registry_context **ctx,
58                                struct loadparm_context *lp_ctx,
59                                struct auth_session_info *session_info,
60                                struct cli_credentials *credentials)
61 {
62         WERROR result;
63
64         result = reg_open_local(mem_ctx, ctx, session_info, credentials);
65         if (!W_ERROR_IS_OK(result)) {
66                 return result;
67         }
68
69         mount_samba_hive(*ctx, lp_ctx, session_info, credentials,
70                          "hklm", HKEY_LOCAL_MACHINE);
71
72         mount_samba_hive(*ctx, lp_ctx, session_info, credentials,
73                          "hkcr", HKEY_CLASSES_ROOT);
74
75         /* FIXME: Should be mounted from NTUSER.DAT in the home directory of the
76          * current user */
77         mount_samba_hive(*ctx, lp_ctx, session_info, credentials,
78                          "hkcu", HKEY_CURRENT_USER);
79
80         mount_samba_hive(*ctx, lp_ctx, session_info, credentials,
81                          "hku", HKEY_USERS);
82
83         /* FIXME: Different hive backend for HKEY_CLASSES_ROOT: merged view of HKEY_LOCAL_MACHINE\Software\Classes
84          * and HKEY_CURRENT_USER\Software\Classes */
85
86         /* FIXME: HKEY_CURRENT_CONFIG is an alias for HKEY_LOCAL_MACHINE\System\CurrentControlSet\Hardware Profiles\Current */
87
88         /* FIXME: HKEY_PERFORMANCE_DATA is dynamically generated */
89
90         /* FIXME: HKEY_LOCAL_MACHINE\Hardware is autogenerated */
91
92         /* FIXME: HKEY_LOCAL_MACHINE\Security\SAM is an alias for HKEY_LOCAL_MACHINE\SAM */
93
94         return WERR_OK;
95 }