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_ipc_connection(ctx
, r
->in
.server_name
, &cli
);
74 if (!W_ERROR_IS_OK(werr
)) {
78 werr
= libnetapi_open_pipe(ctx
, cli
, PI_SRVSVC
, &pipe_cli
);
79 if (!W_ERROR_IS_OK(werr
)) {
83 status
= rpccli_srvsvc_NetSrvGetInfo(pipe_cli
, ctx
,
88 if (!NT_STATUS_IS_OK(status
)) {
89 werr
= ntstatus_to_werror(status
);
93 *r
->out
.buffer
= (uint8_t *)talloc_memdup(ctx
, &info
, sizeof(info
));
94 if (!*r
->out
.buffer
) {
103 /****************************************************************
104 ****************************************************************/
106 static WERROR
NetServerSetInfo_l_1005(struct libnetapi_ctx
*ctx
,
107 struct NetServerSetInfo
*r
)
110 struct smbconf_ctx
*conf_ctx
;
111 struct srvsvc_NetSrvInfo1005
*info1005
;
114 *r
->out
.parm_error
= 1005; /* sure here ? */
115 return WERR_INVALID_PARAM
;
118 info1005
= (struct srvsvc_NetSrvInfo1005
*)r
->in
.buffer
;
120 if (!info1005
->comment
) {
121 *r
->out
.parm_error
= 1005;
122 return WERR_INVALID_PARAM
;
125 if (!lp_config_backend_is_registry()) {
126 libnetapi_set_error_string(ctx
,
127 "Configuration manipulation requested but not "
128 "supported by backend");
129 return WERR_NOT_SUPPORTED
;
132 werr
= smbconf_init_reg(ctx
, &conf_ctx
, NULL
);
133 if (!W_ERROR_IS_OK(werr
)) {
137 werr
= smbconf_set_global_parameter(conf_ctx
, "server string",
141 smbconf_shutdown(conf_ctx
);
145 /****************************************************************
146 ****************************************************************/
148 WERROR
NetServerSetInfo_l(struct libnetapi_ctx
*ctx
,
149 struct NetServerSetInfo
*r
)
151 switch (r
->in
.level
) {
153 return NetServerSetInfo_l_1005(ctx
, r
);
155 return WERR_UNKNOWN_LEVEL
;
158 return WERR_UNKNOWN_LEVEL
;
161 /****************************************************************
162 ****************************************************************/
164 WERROR
NetServerSetInfo_r(struct libnetapi_ctx
*ctx
,
165 struct NetServerSetInfo
*r
)
167 struct cli_state
*cli
= NULL
;
168 struct rpc_pipe_client
*pipe_cli
= NULL
;
171 union srvsvc_NetSrvInfo info
;
173 werr
= libnetapi_open_ipc_connection(ctx
, r
->in
.server_name
, &cli
);
174 if (!W_ERROR_IS_OK(werr
)) {
178 werr
= libnetapi_open_pipe(ctx
, cli
, PI_SRVSVC
, &pipe_cli
);
179 if (!W_ERROR_IS_OK(werr
)) {
183 switch (r
->in
.level
) {
185 info
.info1005
= (struct srvsvc_NetSrvInfo1005
*)r
->in
.buffer
;
188 werr
= WERR_NOT_SUPPORTED
;
192 status
= rpccli_srvsvc_NetSrvSetInfo(pipe_cli
, ctx
,
198 if (!NT_STATUS_IS_OK(status
)) {
199 werr
= ntstatus_to_werror(status
);