Line data Source code
1 : /*
2 : * Unix SMB/CIFS implementation.
3 : * Group Policy Object Support
4 : * Copyright (C) Guenther Deschner 2005-2006
5 : *
6 : * This program is free software; you can redistribute it and/or modify
7 : * it under the terms of the GNU General Public License as published by
8 : * the Free Software Foundation; either version 3 of the License, or
9 : * (at your option) any later version.
10 : *
11 : * This program is distributed in the hope that it will be useful,
12 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 : * GNU General Public License for more details.
15 : *
16 : * You should have received a copy of the GNU General Public License
17 : * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 : */
19 :
20 : #include "includes.h"
21 : #include "system/filesys.h"
22 : #include "../libgpo/gpo.h"
23 : #include "../libgpo/gpo_ini.h"
24 :
25 : #include "libgpo/gpo_proto.h"
26 : #include "libsmb/libsmb.h"
27 :
28 : /****************************************************************
29 : explode the GPO CIFS URI into their components
30 : ****************************************************************/
31 :
32 0 : NTSTATUS gpo_explode_filesyspath(TALLOC_CTX *mem_ctx,
33 : const char *cache_dir,
34 : const char *file_sys_path,
35 : char **server,
36 : char **service,
37 : char **nt_path,
38 : char **unix_path)
39 : {
40 0 : char *path = NULL;
41 :
42 0 : *server = NULL;
43 0 : *service = NULL;
44 0 : *nt_path = NULL;
45 0 : *unix_path = NULL;
46 :
47 0 : if (!file_sys_path) {
48 0 : return NT_STATUS_OK;
49 : }
50 :
51 0 : if (!next_token_talloc(mem_ctx, &file_sys_path, server, "\\")) {
52 0 : return NT_STATUS_INVALID_PARAMETER;
53 : }
54 0 : NT_STATUS_HAVE_NO_MEMORY(*server);
55 :
56 0 : if (!next_token_talloc(mem_ctx, &file_sys_path, service, "\\")) {
57 0 : return NT_STATUS_INVALID_PARAMETER;
58 : }
59 0 : NT_STATUS_HAVE_NO_MEMORY(*service);
60 :
61 0 : if ((*nt_path = talloc_asprintf(mem_ctx, "\\%s", file_sys_path))
62 : == NULL) {
63 0 : return NT_STATUS_NO_MEMORY;
64 : }
65 0 : NT_STATUS_HAVE_NO_MEMORY(*nt_path);
66 :
67 0 : if ((path = talloc_asprintf(mem_ctx,
68 : "%s/%s",
69 : cache_dir,
70 : file_sys_path)) == NULL) {
71 0 : return NT_STATUS_NO_MEMORY;
72 : }
73 0 : path = talloc_string_sub(mem_ctx, path, "\\", "/");
74 0 : if (!path) {
75 0 : return NT_STATUS_NO_MEMORY;
76 : }
77 :
78 0 : *unix_path = talloc_strdup(mem_ctx, path);
79 0 : NT_STATUS_HAVE_NO_MEMORY(*unix_path);
80 :
81 0 : talloc_free(path);
82 0 : return NT_STATUS_OK;
83 : }
84 :
85 : /****************************************************************
86 : get the locally stored gpt.ini version number
87 : ****************************************************************/
88 :
89 46 : NTSTATUS gpo_get_sysvol_gpt_version(TALLOC_CTX *mem_ctx,
90 : const char *unix_path,
91 : uint32_t *sysvol_version,
92 : char **display_name)
93 : {
94 0 : NTSTATUS status;
95 46 : uint32_t version = 0;
96 46 : char *local_path = NULL;
97 46 : char *name = NULL;
98 :
99 46 : if (!unix_path) {
100 0 : return NT_STATUS_OK;
101 : }
102 :
103 46 : local_path = talloc_asprintf(mem_ctx, "%s/%s", unix_path, GPT_INI);
104 46 : NT_STATUS_HAVE_NO_MEMORY(local_path);
105 :
106 46 : status = parse_gpt_ini(mem_ctx, local_path, &version, &name);
107 46 : if (!NT_STATUS_IS_OK(status)) {
108 0 : DEBUG(10,("gpo_get_sysvol_gpt_version: "
109 : "failed to parse ini [%s]: %s\n",
110 : local_path, nt_errstr(status)));
111 0 : return status;
112 : }
113 :
114 46 : if (sysvol_version) {
115 46 : *sysvol_version = version;
116 : }
117 :
118 46 : if (name && *display_name) {
119 0 : *display_name = talloc_strdup(mem_ctx, name);
120 0 : NT_STATUS_HAVE_NO_MEMORY(*display_name);
121 : }
122 :
123 46 : return NT_STATUS_OK;
124 : }
|