tevent: expose tevent_context_init_ops
[Samba/gebeck_regimport.git] / source3 / web / diagnose.c
blob955ff89b99cb978cdac5b93d52e56a536750df79
1 /*
2 Unix SMB/CIFS implementation.
3 diagnosis tools for web admin
4 Copyright (C) Andrew Tridgell 1998
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/>.
20 #include "includes.h"
21 #include "web/swat_proto.h"
22 #include "lib/winbind_util.h"
23 #include "libsmb/libsmb.h"
25 #ifdef WITH_WINBIND
27 /* check to see if winbind is running by pinging it */
29 bool winbindd_running(void)
31 return winbind_ping();
33 #endif
35 /* check to see if nmbd is running on localhost by looking for a __SAMBA__
36 response */
37 bool nmbd_running(void)
39 struct in_addr loopback_ip;
40 int count;
41 struct sockaddr_storage *ss_list;
42 struct sockaddr_storage ss;
43 NTSTATUS status;
45 loopback_ip.s_addr = htonl(INADDR_LOOPBACK);
46 in_addr_to_sockaddr_storage(&ss, loopback_ip);
48 status = name_query("__SAMBA__", 0,
49 True, True, &ss,
50 talloc_tos(), &ss_list, &count,
51 NULL);
52 if (NT_STATUS_IS_OK(status)) {
53 TALLOC_FREE(ss_list);
54 return True;
57 return False;
61 /* check to see if smbd is running on localhost by trying to open a connection
62 then closing it */
63 bool smbd_running(void)
65 struct in_addr loopback_ip;
66 NTSTATUS status;
67 struct cli_state *cli;
68 struct sockaddr_storage ss;
70 loopback_ip.s_addr = htonl(INADDR_LOOPBACK);
71 in_addr_to_sockaddr_storage(&ss, loopback_ip);
73 status = cli_connect_nb("localhost", &ss, 0, 0x20, lp_netbios_name(),
74 SMB_SIGNING_DEFAULT, 0, &cli);
75 if (!NT_STATUS_IS_OK(status)) {
76 return false;
78 cli_shutdown(cli);
79 return True;