2 * Unix SMB/CIFS implementation.
3 * NetApi Server Support
4 * Copyright (C) Guenther Deschner 2007
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.
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.
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/>.
22 #include "librpc/gen_ndr/libnetapi.h"
23 #include "lib/netapi/netapi.h"
24 #include "lib/netapi/netapi_private.h"
25 #include "lib/netapi/libnetapi.h"
26 #include "libnet/libnet.h"
28 /****************************************************************
29 ****************************************************************/
31 static WERROR
NetServerGetInfo_l_1005(struct libnetapi_ctx
*ctx
,
34 struct SERVER_INFO_1005 info1005
;
36 info1005
.sv1005_comment
= lp_serverstring();
37 *buffer
= (uint8_t *)talloc_memdup(ctx
, &info1005
, sizeof(info1005
));
45 /****************************************************************
46 ****************************************************************/
48 WERROR
NetServerGetInfo_l(struct libnetapi_ctx
*ctx
,
49 struct NetServerGetInfo
*r
)
51 switch (r
->in
.level
) {
53 return NetServerGetInfo_l_1005(ctx
, r
->out
.buffer
);
55 return WERR_UNKNOWN_LEVEL
;
58 return WERR_UNKNOWN_LEVEL
;
61 /****************************************************************
62 ****************************************************************/
64 WERROR
NetServerGetInfo_r(struct libnetapi_ctx
*ctx
,
65 struct NetServerGetInfo
*r
)
67 struct cli_state
*cli
= NULL
;
68 struct rpc_pipe_client
*pipe_cli
= NULL
;
71 union srvsvc_NetSrvInfo info
;
73 werr
= libnetapi_open_pipe(ctx
, r
->in
.server_name
,
74 &ndr_table_srvsvc
.syntax_id
,
77 if (!W_ERROR_IS_OK(werr
)) {
81 status
= rpccli_srvsvc_NetSrvGetInfo(pipe_cli
, ctx
,
86 if (!NT_STATUS_IS_OK(status
)) {
87 werr
= ntstatus_to_werror(status
);
91 *r
->out
.buffer
= (uint8_t *)talloc_memdup(ctx
, &info
, sizeof(info
));
92 if (!*r
->out
.buffer
) {
101 /****************************************************************
102 ****************************************************************/
104 static WERROR
NetServerSetInfo_l_1005(struct libnetapi_ctx
*ctx
,
105 struct NetServerSetInfo
*r
)
108 struct smbconf_ctx
*conf_ctx
;
109 struct srvsvc_NetSrvInfo1005
*info1005
;
112 *r
->out
.parm_error
= 1005; /* sure here ? */
113 return WERR_INVALID_PARAM
;
116 info1005
= (struct srvsvc_NetSrvInfo1005
*)r
->in
.buffer
;
118 if (!info1005
->comment
) {
119 *r
->out
.parm_error
= 1005;
120 return WERR_INVALID_PARAM
;
123 if (!lp_config_backend_is_registry()) {
124 libnetapi_set_error_string(ctx
,
125 "Configuration manipulation requested but not "
126 "supported by backend");
127 return WERR_NOT_SUPPORTED
;
130 werr
= smbconf_init_reg(ctx
, &conf_ctx
, NULL
);
131 if (!W_ERROR_IS_OK(werr
)) {
135 werr
= smbconf_set_global_parameter(conf_ctx
, "server string",
139 smbconf_shutdown(conf_ctx
);
143 /****************************************************************
144 ****************************************************************/
146 WERROR
NetServerSetInfo_l(struct libnetapi_ctx
*ctx
,
147 struct NetServerSetInfo
*r
)
149 switch (r
->in
.level
) {
151 return NetServerSetInfo_l_1005(ctx
, r
);
153 return WERR_UNKNOWN_LEVEL
;
156 return WERR_UNKNOWN_LEVEL
;
159 /****************************************************************
160 ****************************************************************/
162 WERROR
NetServerSetInfo_r(struct libnetapi_ctx
*ctx
,
163 struct NetServerSetInfo
*r
)
165 struct cli_state
*cli
= NULL
;
166 struct rpc_pipe_client
*pipe_cli
= NULL
;
169 union srvsvc_NetSrvInfo info
;
171 werr
= libnetapi_open_pipe(ctx
, r
->in
.server_name
,
172 &ndr_table_srvsvc
.syntax_id
,
175 if (!W_ERROR_IS_OK(werr
)) {
179 switch (r
->in
.level
) {
181 info
.info1005
= (struct srvsvc_NetSrvInfo1005
*)r
->in
.buffer
;
184 werr
= WERR_NOT_SUPPORTED
;
188 status
= rpccli_srvsvc_NetSrvSetInfo(pipe_cli
, ctx
,
194 if (!NT_STATUS_IS_OK(status
)) {
195 werr
= ntstatus_to_werror(status
);
203 /****************************************************************
204 ****************************************************************/
206 WERROR
NetRemoteTOD_r(struct libnetapi_ctx
*ctx
,
207 struct NetRemoteTOD
*r
)
209 struct cli_state
*cli
= NULL
;
210 struct rpc_pipe_client
*pipe_cli
= NULL
;
213 struct srvsvc_NetRemoteTODInfo
*info
= NULL
;
215 werr
= libnetapi_open_pipe(ctx
, r
->in
.server_name
,
216 &ndr_table_srvsvc
.syntax_id
,
219 if (!W_ERROR_IS_OK(werr
)) {
223 status
= rpccli_srvsvc_NetRemoteTOD(pipe_cli
, ctx
,
227 if (!NT_STATUS_IS_OK(status
)) {
228 werr
= ntstatus_to_werror(status
);
232 *r
->out
.buffer
= (uint8_t *)talloc_memdup(ctx
, info
,
233 sizeof(struct srvsvc_NetRemoteTODInfo
));
234 W_ERROR_HAVE_NO_MEMORY(*r
->out
.buffer
);
240 /****************************************************************
241 ****************************************************************/
243 WERROR
NetRemoteTOD_l(struct libnetapi_ctx
*ctx
,
244 struct NetRemoteTOD
*r
)
246 LIBNETAPI_REDIRECT_TO_LOCALHOST(ctx
, r
, NetRemoteTOD
);