1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 | diagnosis tools for web admin
|
---|
4 | Copyright (C) Andrew Tridgell 1998
|
---|
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 | #include "web/swat_proto.h"
|
---|
22 |
|
---|
23 | extern struct in_addr loopback_ip;
|
---|
24 |
|
---|
25 | #ifdef WITH_WINBIND
|
---|
26 |
|
---|
27 | /* check to see if winbind is running by pinging it */
|
---|
28 |
|
---|
29 | BOOL winbindd_running(void)
|
---|
30 | {
|
---|
31 | return winbind_ping();
|
---|
32 | }
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | /* check to see if nmbd is running on localhost by looking for a __SAMBA__
|
---|
36 | response */
|
---|
37 | BOOL nmbd_running(void)
|
---|
38 | {
|
---|
39 | int fd, count, flags;
|
---|
40 | struct in_addr *ip_list;
|
---|
41 |
|
---|
42 | if ((fd = open_socket_in(SOCK_DGRAM, 0, 3,
|
---|
43 | interpret_addr("127.0.0.1"), True)) != -1) {
|
---|
44 | if ((ip_list = name_query(fd, "__SAMBA__", 0,
|
---|
45 | True, True, loopback_ip,
|
---|
46 | &count, &flags, NULL)) != NULL) {
|
---|
47 | SAFE_FREE(ip_list);
|
---|
48 | close(fd);
|
---|
49 | return True;
|
---|
50 | }
|
---|
51 | close (fd);
|
---|
52 | }
|
---|
53 |
|
---|
54 | return False;
|
---|
55 | }
|
---|
56 |
|
---|
57 |
|
---|
58 | /* check to see if smbd is running on localhost by trying to open a connection
|
---|
59 | then closing it */
|
---|
60 | BOOL smbd_running(void)
|
---|
61 | {
|
---|
62 | NTSTATUS status;
|
---|
63 | struct cli_state *cli;
|
---|
64 |
|
---|
65 | if ((cli = cli_initialise()) == NULL)
|
---|
66 | return False;
|
---|
67 |
|
---|
68 | status = cli_connect(cli, global_myname(), &loopback_ip);
|
---|
69 | if (!NT_STATUS_IS_OK(status)) {
|
---|
70 | cli_shutdown(cli);
|
---|
71 | return False;
|
---|
72 | }
|
---|
73 |
|
---|
74 | cli_shutdown(cli);
|
---|
75 | return True;
|
---|
76 | }
|
---|