1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 | Popt routines specifically for registry
|
---|
4 |
|
---|
5 | Copyright (C) Jelmer Vernooij 2007
|
---|
6 |
|
---|
7 | This program is free software; you can redistribute it and/or modify
|
---|
8 | it under the terms of the GNU General Public License as published by
|
---|
9 | the Free Software Foundation; either version 3 of the License, or
|
---|
10 | (at your option) any later version.
|
---|
11 |
|
---|
12 | This program is distributed in the hope that it will be useful,
|
---|
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | GNU General Public License for more details.
|
---|
16 |
|
---|
17 | You should have received a copy of the GNU General Public License
|
---|
18 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 |
|
---|
21 | #include "includes.h"
|
---|
22 | #include "auth/credentials/credentials.h"
|
---|
23 | #include "lib/registry/registry.h"
|
---|
24 | #include "lib/registry/tools/common.h"
|
---|
25 |
|
---|
26 | struct registry_context *reg_common_open_remote(const char *remote,
|
---|
27 | struct tevent_context *ev_ctx,
|
---|
28 | struct loadparm_context *lp_ctx,
|
---|
29 | struct cli_credentials *creds)
|
---|
30 | {
|
---|
31 | struct registry_context *h = NULL;
|
---|
32 | WERROR error;
|
---|
33 |
|
---|
34 | error = reg_open_remote(&h, NULL, creds, lp_ctx, remote, ev_ctx);
|
---|
35 |
|
---|
36 | if (!W_ERROR_IS_OK(error)) {
|
---|
37 | fprintf(stderr, "Unable to open remote registry at %s:%s \n",
|
---|
38 | remote, win_errstr(error));
|
---|
39 | return NULL;
|
---|
40 | }
|
---|
41 |
|
---|
42 | return h;
|
---|
43 | }
|
---|
44 |
|
---|
45 | struct registry_key *reg_common_open_file(const char *path,
|
---|
46 | struct tevent_context *ev_ctx,
|
---|
47 | struct loadparm_context *lp_ctx,
|
---|
48 | struct cli_credentials *creds)
|
---|
49 | {
|
---|
50 | struct hive_key *hive_root;
|
---|
51 | struct registry_context *h = NULL;
|
---|
52 | WERROR error;
|
---|
53 |
|
---|
54 | error = reg_open_hive(ev_ctx, path, NULL, creds, ev_ctx, lp_ctx, &hive_root);
|
---|
55 |
|
---|
56 | if(!W_ERROR_IS_OK(error)) {
|
---|
57 | fprintf(stderr, "Unable to open '%s': %s \n",
|
---|
58 | path, win_errstr(error));
|
---|
59 | return NULL;
|
---|
60 | }
|
---|
61 |
|
---|
62 | error = reg_open_local(NULL, &h);
|
---|
63 | if (!W_ERROR_IS_OK(error)) {
|
---|
64 | fprintf(stderr, "Unable to initialize local registry: %s\n",
|
---|
65 | win_errstr(error));
|
---|
66 | return NULL;
|
---|
67 | }
|
---|
68 |
|
---|
69 | return reg_import_hive_key(h, hive_root, -1, NULL);
|
---|
70 | }
|
---|
71 |
|
---|
72 | struct registry_context *reg_common_open_local(struct cli_credentials *creds,
|
---|
73 | struct tevent_context *ev_ctx,
|
---|
74 | struct loadparm_context *lp_ctx)
|
---|
75 | {
|
---|
76 | WERROR error;
|
---|
77 | struct registry_context *h = NULL;
|
---|
78 |
|
---|
79 | error = reg_open_samba(NULL, &h, ev_ctx, lp_ctx, NULL, creds);
|
---|
80 |
|
---|
81 | if(!W_ERROR_IS_OK(error)) {
|
---|
82 | fprintf(stderr, "Unable to open local registry:%s \n",
|
---|
83 | win_errstr(error));
|
---|
84 | return NULL;
|
---|
85 | }
|
---|
86 |
|
---|
87 | return h;
|
---|
88 | }
|
---|