/src/samba/source3/registry/reg_init_smbconf.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Unix SMB/CIFS implementation. |
3 | | * Registry helper routines |
4 | | * Copyright (C) Michael Adam 2007 |
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. |
10 | | * |
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. |
15 | | * |
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/>. |
18 | | */ |
19 | | |
20 | | #include "includes.h" |
21 | | #include "registry.h" |
22 | | #include "reg_cachehook.h" |
23 | | #include "reg_backend_db.h" |
24 | | #include "reg_init_basic.h" |
25 | | #include "reg_init_smbconf.h" |
26 | | |
27 | | #undef DBGC_CLASS |
28 | 0 | #define DBGC_CLASS DBGC_REGISTRY |
29 | | |
30 | | extern struct registry_ops smbconf_reg_ops; |
31 | | |
32 | | /* |
33 | | * init the smbconf portion of the registry. |
34 | | * for use in places where not the whole registry is needed, |
35 | | * e.g. utils/net_conf.c and loadparm.c |
36 | | */ |
37 | | WERROR registry_init_smbconf(const char *keyname) |
38 | 0 | { |
39 | 0 | WERROR werr; |
40 | |
|
41 | 0 | DEBUG(10, ("registry_init_smbconf called\n")); |
42 | |
|
43 | 0 | if (keyname == NULL) { |
44 | 0 | DEBUG(10, ("registry_init_smbconf: defaulting to key '%s'\n", |
45 | 0 | KEY_SMBCONF)); |
46 | 0 | keyname = KEY_SMBCONF; |
47 | 0 | } |
48 | |
|
49 | 0 | werr = registry_init_common(); |
50 | 0 | if (!W_ERROR_IS_OK(werr)) { |
51 | 0 | goto done; |
52 | 0 | } |
53 | | |
54 | 0 | werr = init_registry_key(keyname); |
55 | 0 | if (!W_ERROR_IS_OK(werr)) { |
56 | 0 | DEBUG(1, ("Failed to initialize registry key '%s': %s\n", |
57 | 0 | keyname, win_errstr(werr))); |
58 | 0 | goto done; |
59 | 0 | } |
60 | | |
61 | 0 | werr = reghook_cache_add(keyname, &smbconf_reg_ops); |
62 | 0 | if (!W_ERROR_IS_OK(werr)) { |
63 | 0 | DEBUG(1, ("Failed to add smbconf reghooks to reghook cache: " |
64 | 0 | "%s\n", win_errstr(werr))); |
65 | 0 | goto done; |
66 | 0 | } |
67 | | |
68 | 0 | done: |
69 | 0 | regdb_close(); |
70 | 0 | return werr; |
71 | 0 | } |