Third part of my fix for usrmgr. Assuming automagic mapping
[Samba/gebeck_regimport.git] / source3 / web / diagnose.c
blob396499bcb9e9905dcce2fceb45e6c21a5783054f
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 #ifdef WITH_WINBIND
26 NSS_STATUS winbindd_request(int req_type,
27 struct winbindd_request *request,
28 struct winbindd_response *response);
30 /* check to see if winbind is running by pinging it */
32 BOOL winbindd_running(void)
35 if (winbindd_request(WINBINDD_PING, NULL, NULL))
36 return False;
38 return True;
40 #endif
42 /* check to see if nmbd is running on localhost by looking for a __SAMBA__
43 response */
44 BOOL nmbd_running(void)
46 extern struct in_addr loopback_ip;
47 int fd, count, flags;
48 struct in_addr *ip_list;
50 if ((fd = open_socket_in(SOCK_DGRAM, 0, 3,
51 interpret_addr("127.0.0.1"), True)) != -1) {
52 if ((ip_list = name_query(fd, "__SAMBA__", 0,
53 True, True, loopback_ip,
54 &count, &flags, NULL)) != NULL) {
55 SAFE_FREE(ip_list);
56 close(fd);
57 return True;
59 close (fd);
62 return False;
66 /* check to see if smbd is running on localhost by trying to open a connection
67 then closing it */
68 BOOL smbd_running(void)
70 static struct cli_state cli;
71 extern struct in_addr loopback_ip;
73 if (!cli_initialise(&cli))
74 return False;
76 if (!cli_connect(&cli, "localhost", &loopback_ip)) {
77 cli_shutdown(&cli);
78 return False;
81 cli_shutdown(&cli);
82 return True;