1998-03-14 13:00:09 +00:00
/*
2002-01-30 06:08:46 +00:00
Unix SMB / CIFS implementation .
1998-03-14 13:00:09 +00:00
diagnosis tools for web admin
Copyright ( C ) Andrew Tridgell 1998
2011-01-08 11:28:27 +01:00
1998-03-14 13:00:09 +00:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-09 19:25:36 +00:00
the Free Software Foundation ; either version 3 of the License , or
1998-03-14 13:00:09 +00:00
( at your option ) any later version .
2011-01-08 11:28:27 +01:00
1998-03-14 13:00:09 +00:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2011-01-08 11:28:27 +01:00
1998-03-14 13:00:09 +00:00
You should have received a copy of the GNU General Public License
2007-07-10 00:52:41 +00:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
1998-03-14 13:00:09 +00:00
*/
# include "includes.h"
2004-10-07 04:01:18 +00:00
# include "web/swat_proto.h"
2011-02-24 22:30:16 +01:00
# include "lib/winbind_util.h"
1998-03-14 13:00:09 +00:00
2005-04-10 15:54:18 +00:00
# ifdef WITH_WINBIND
2002-08-17 14:34:48 +00:00
/* check to see if winbind is running by pinging it */
2007-10-18 17:40:25 -07:00
bool winbindd_running ( void )
2002-08-17 14:34:48 +00:00
{
2003-11-22 04:47:34 +00:00
return winbind_ping ( ) ;
2002-08-17 14:34:48 +00:00
}
# endif
1998-03-14 13:00:09 +00:00
/* check to see if nmbd is running on localhost by looking for a __SAMBA__
response */
2007-10-18 17:40:25 -07:00
bool nmbd_running ( void )
1998-03-14 13:00:09 +00:00
{
2007-10-10 18:25:16 -07:00
struct in_addr loopback_ip ;
2011-01-08 11:28:47 +01:00
int count ;
2007-10-24 14:16:54 -07:00
struct sockaddr_storage * ss_list ;
struct sockaddr_storage ss ;
2011-01-04 18:48:47 +01:00
NTSTATUS status ;
1998-03-14 13:00:09 +00:00
2007-10-10 18:25:16 -07:00
loopback_ip . s_addr = htonl ( INADDR_LOOPBACK ) ;
2007-10-24 14:16:54 -07:00
in_addr_to_sockaddr_storage ( & ss , loopback_ip ) ;
2007-10-10 18:25:16 -07:00
2011-01-04 18:48:47 +01:00
status = name_query ( " __SAMBA__ " , 0 ,
True , True , & ss ,
talloc_tos ( ) , & ss_list , & count ,
2011-01-08 11:28:47 +01:00
NULL ) ;
2011-01-04 18:48:47 +01:00
if ( NT_STATUS_IS_OK ( status ) ) {
TALLOC_FREE ( ss_list ) ;
return True ;
1998-03-14 13:00:09 +00:00
}
return False ;
}
/* check to see if smbd is running on localhost by trying to open a connection
then closing it */
2007-10-18 17:40:25 -07:00
bool smbd_running ( void )
1998-03-14 13:00:09 +00:00
{
2007-10-10 18:25:16 -07:00
struct in_addr loopback_ip ;
2007-06-20 17:38:42 +00:00
NTSTATUS status ;
2006-07-11 18:01:26 +00:00
struct cli_state * cli ;
2007-10-24 14:16:54 -07:00
struct sockaddr_storage ss ;
1998-03-14 13:00:09 +00:00
2007-10-10 18:25:16 -07:00
loopback_ip . s_addr = htonl ( INADDR_LOOPBACK ) ;
2007-10-24 14:16:54 -07:00
in_addr_to_sockaddr_storage ( & ss , loopback_ip ) ;
2007-10-10 18:25:16 -07:00
2006-07-11 18:01:26 +00:00
if ( ( cli = cli_initialise ( ) ) = = NULL )
1998-03-14 13:00:09 +00:00
return False ;
2007-10-24 14:16:54 -07:00
status = cli_connect ( cli , global_myname ( ) , & ss ) ;
2007-06-20 17:38:42 +00:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2006-07-11 18:01:26 +00:00
cli_shutdown ( cli ) ;
1998-03-14 13:00:09 +00:00
return False ;
}
2006-07-11 18:01:26 +00:00
cli_shutdown ( cli ) ;
1998-03-14 13:00:09 +00:00
return True ;
}