Coverage Report

Created: 2026-05-24 06:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/samba/source3/lib/netapi/shutdown.c
Line
Count
Source
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/ndr_initshutdown_c.h"
27
#include "rpc_client/init_lsa.h"
28
29
/****************************************************************
30
****************************************************************/
31
32
WERROR NetShutdownInit_r(struct libnetapi_ctx *ctx,
33
       struct NetShutdownInit *r)
34
0
{
35
0
  WERROR werr;
36
0
  NTSTATUS status;
37
0
  struct lsa_StringLarge message;
38
0
  struct dcerpc_binding_handle *b;
39
40
0
  werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
41
0
              &ndr_table_initshutdown,
42
0
              &b);
43
0
  if (!W_ERROR_IS_OK(werr)) {
44
0
    goto done;
45
0
  }
46
47
0
  init_lsa_StringLarge(&message, r->in.message);
48
49
0
  status = dcerpc_initshutdown_Init(b, talloc_tos(),
50
0
            NULL,
51
0
            &message,
52
0
            r->in.timeout,
53
0
            r->in.force_apps,
54
0
            r->in.do_reboot,
55
0
            &werr);
56
0
  if (!NT_STATUS_IS_OK(status)) {
57
0
    werr = ntstatus_to_werror(status);
58
0
    goto done;
59
0
  }
60
61
0
 done:
62
0
  return werr;
63
0
}
64
65
/****************************************************************
66
****************************************************************/
67
68
WERROR NetShutdownInit_l(struct libnetapi_ctx *ctx,
69
       struct NetShutdownInit *r)
70
0
{
71
0
  LIBNETAPI_REDIRECT_TO_LOCALHOST(ctx, r, NetShutdownInit);
72
0
}
73
74
/****************************************************************
75
****************************************************************/
76
77
WERROR NetShutdownAbort_r(struct libnetapi_ctx *ctx,
78
        struct NetShutdownAbort *r)
79
0
{
80
0
  WERROR werr;
81
0
  NTSTATUS status;
82
0
  struct dcerpc_binding_handle *b;
83
84
0
  werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
85
0
              &ndr_table_initshutdown,
86
0
              &b);
87
0
  if (!W_ERROR_IS_OK(werr)) {
88
0
    goto done;
89
0
  }
90
91
0
  status = dcerpc_initshutdown_Abort(b, talloc_tos(),
92
0
             NULL,
93
0
             &werr);
94
0
  if (!NT_STATUS_IS_OK(status)) {
95
0
    werr = ntstatus_to_werror(status);
96
0
    goto done;
97
0
  }
98
99
0
 done:
100
0
  return werr;
101
0
}
102
103
/****************************************************************
104
****************************************************************/
105
106
WERROR NetShutdownAbort_l(struct libnetapi_ctx *ctx,
107
        struct NetShutdownAbort *r)
108
0
{
109
0
  LIBNETAPI_REDIRECT_TO_LOCALHOST(ctx, r, NetShutdownAbort);
110
0
}