Set version to 3.0.27a
[Samba.git] / source / web / diagnose.c
blob5f05d8ac9e92892b3a62abbb3bba1f6aa7414ef9
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 2 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, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "includes.h"
22 #include "web/swat_proto.h"
24 extern struct in_addr loopback_ip;
26 #ifdef WITH_WINBIND
28 /* check to see if winbind is running by pinging it */
30 BOOL winbindd_running(void)
32 return winbind_ping();
34 #endif
36 /* check to see if nmbd is running on localhost by looking for a __SAMBA__
37 response */
38 BOOL nmbd_running(void)
40 int fd, count, flags;
41 struct in_addr *ip_list;
43 if ((fd = open_socket_in(SOCK_DGRAM, 0, 3,
44 interpret_addr("127.0.0.1"), True)) != -1) {
45 if ((ip_list = name_query(fd, "__SAMBA__", 0,
46 True, True, loopback_ip,
47 &count, &flags, NULL)) != NULL) {
48 SAFE_FREE(ip_list);
49 close(fd);
50 return True;
52 close (fd);
55 return False;
59 /* check to see if smbd is running on localhost by trying to open a connection
60 then closing it */
61 BOOL smbd_running(void)
63 NTSTATUS status;
64 struct cli_state *cli;
66 if ((cli = cli_initialise()) == NULL)
67 return False;
69 status = cli_connect(cli, global_myname(), &loopback_ip);
70 if (!NT_STATUS_IS_OK(status)) {
71 cli_shutdown(cli);
72 return False;
75 cli_shutdown(cli);
76 return True;