1 | /*
|
---|
2 | * Unix SMB/CIFS implementation.
|
---|
3 | * NetApi Shutdown Support
|
---|
4 | * Copyright (C) Guenther Deschner 2009
|
---|
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 |
|
---|
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 "../librpc/gen_ndr/cli_initshutdown.h"
|
---|
27 |
|
---|
28 | /****************************************************************
|
---|
29 | ****************************************************************/
|
---|
30 |
|
---|
31 | WERROR NetShutdownInit_r(struct libnetapi_ctx *ctx,
|
---|
32 | struct NetShutdownInit *r)
|
---|
33 | {
|
---|
34 | WERROR werr;
|
---|
35 | NTSTATUS status;
|
---|
36 | struct rpc_pipe_client *pipe_cli = NULL;
|
---|
37 | struct lsa_StringLarge message;
|
---|
38 |
|
---|
39 | werr = libnetapi_open_pipe(ctx, r->in.server_name,
|
---|
40 | &ndr_table_initshutdown.syntax_id,
|
---|
41 | &pipe_cli);
|
---|
42 | if (!W_ERROR_IS_OK(werr)) {
|
---|
43 | goto done;
|
---|
44 | }
|
---|
45 |
|
---|
46 | init_lsa_StringLarge(&message, r->in.message);
|
---|
47 |
|
---|
48 | status = rpccli_initshutdown_Init(pipe_cli, talloc_tos(),
|
---|
49 | NULL,
|
---|
50 | &message,
|
---|
51 | r->in.timeout,
|
---|
52 | r->in.force_apps,
|
---|
53 | r->in.do_reboot,
|
---|
54 | &werr);
|
---|
55 | if (!NT_STATUS_IS_OK(status)) {
|
---|
56 | werr = ntstatus_to_werror(status);
|
---|
57 | goto done;
|
---|
58 | }
|
---|
59 |
|
---|
60 | done:
|
---|
61 | return werr;
|
---|
62 | }
|
---|
63 |
|
---|
64 | /****************************************************************
|
---|
65 | ****************************************************************/
|
---|
66 |
|
---|
67 | WERROR NetShutdownInit_l(struct libnetapi_ctx *ctx,
|
---|
68 | struct NetShutdownInit *r)
|
---|
69 | {
|
---|
70 | LIBNETAPI_REDIRECT_TO_LOCALHOST(ctx, r, NetShutdownInit);
|
---|
71 | }
|
---|
72 |
|
---|
73 | /****************************************************************
|
---|
74 | ****************************************************************/
|
---|
75 |
|
---|
76 | WERROR NetShutdownAbort_r(struct libnetapi_ctx *ctx,
|
---|
77 | struct NetShutdownAbort *r)
|
---|
78 | {
|
---|
79 | WERROR werr;
|
---|
80 | NTSTATUS status;
|
---|
81 | struct rpc_pipe_client *pipe_cli = NULL;
|
---|
82 |
|
---|
83 | werr = libnetapi_open_pipe(ctx, r->in.server_name,
|
---|
84 | &ndr_table_initshutdown.syntax_id,
|
---|
85 | &pipe_cli);
|
---|
86 | if (!W_ERROR_IS_OK(werr)) {
|
---|
87 | goto done;
|
---|
88 | }
|
---|
89 |
|
---|
90 | status = rpccli_initshutdown_Abort(pipe_cli, talloc_tos(),
|
---|
91 | NULL,
|
---|
92 | &werr);
|
---|
93 | if (!NT_STATUS_IS_OK(status)) {
|
---|
94 | werr = ntstatus_to_werror(status);
|
---|
95 | goto done;
|
---|
96 | }
|
---|
97 |
|
---|
98 | done:
|
---|
99 | return werr;
|
---|
100 | }
|
---|
101 |
|
---|
102 | /****************************************************************
|
---|
103 | ****************************************************************/
|
---|
104 |
|
---|
105 | WERROR NetShutdownAbort_l(struct libnetapi_ctx *ctx,
|
---|
106 | struct NetShutdownAbort *r)
|
---|
107 | {
|
---|
108 | LIBNETAPI_REDIRECT_TO_LOCALHOST(ctx, r, NetShutdownAbort);
|
---|
109 | }
|
---|