root/source3/web/diagnose.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. winbindd_running
  2. nmbd_running
  3. smbd_running

   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 #ifdef WITH_WINBIND
  24 
  25 /* check to see if winbind is running by pinging it */
  26 
  27 bool winbindd_running(void)
     /* [<][>][^][v][top][bottom][index][help] */
  28 {
  29         return winbind_ping();
  30 }       
  31 #endif
  32 
  33 /* check to see if nmbd is running on localhost by looking for a __SAMBA__
  34    response */
  35 bool nmbd_running(void)
     /* [<][>][^][v][top][bottom][index][help] */
  36 {
  37         struct in_addr loopback_ip;
  38         int fd, count, flags;
  39         struct sockaddr_storage *ss_list;
  40         struct sockaddr_storage ss;
  41 
  42         loopback_ip.s_addr = htonl(INADDR_LOOPBACK);
  43         in_addr_to_sockaddr_storage(&ss, loopback_ip);
  44 
  45         if ((fd = open_socket_in(SOCK_DGRAM, 0, 3,
  46                                  &ss, True)) != -1) {
  47                 if ((ss_list = name_query(fd, "__SAMBA__", 0, 
  48                                           True, True, &ss,
  49                                           &count, &flags, NULL)) != NULL) {
  50                         SAFE_FREE(ss_list);
  51                         close(fd);
  52                         return True;
  53                 }
  54                 close (fd);
  55         }
  56 
  57         return False;
  58 }
  59 
  60 
  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)
     /* [<][>][^][v][top][bottom][index][help] */
  64 {
  65         struct in_addr loopback_ip;
  66         NTSTATUS status;
  67         struct cli_state *cli;
  68         struct sockaddr_storage ss;
  69 
  70         loopback_ip.s_addr = htonl(INADDR_LOOPBACK);
  71         in_addr_to_sockaddr_storage(&ss, loopback_ip);
  72 
  73         if ((cli = cli_initialise()) == NULL)
  74                 return False;
  75 
  76         status = cli_connect(cli, global_myname(), &ss);
  77         if (!NT_STATUS_IS_OK(status)) {
  78                 cli_shutdown(cli);
  79                 return False;
  80         }
  81 
  82         cli_shutdown(cli);
  83         return True;
  84 }

/* [<][>][^][v][top][bottom][index][help] */