1998-03-15 05:37:52 +03:00
/*
2002-01-30 09:08:46 +03:00
Unix SMB / CIFS implementation .
1998-03-15 05:37:52 +03:00
web status page
Copyright ( C ) Andrew Tridgell 1997 - 1998
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 23:25:36 +04:00
the Free Software Foundation ; either version 3 of the License , or
1998-03-15 05:37:52 +03:00
( at your option ) any later version .
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 .
You should have received a copy of the GNU General Public License
2007-07-10 04:52:41 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
1998-03-15 05:37:52 +03:00
*/
# include "includes.h"
2004-10-07 08:01:18 +04:00
# include "web/swat_proto.h"
2010-10-12 08:27:50 +04:00
# include "libcli/security/security.h"
2011-03-23 14:43:17 +03:00
# include "locking/proto.h"
2011-11-24 17:11:28 +04:00
# include "librpc/gen_ndr/open_files.h"
2012-06-04 17:32:28 +04:00
# include "lib/conn_tdb.h"
2012-07-20 03:36:18 +04:00
# include "../lib/util/pidfile.h"
1998-03-15 05:37:52 +03:00
2007-12-04 04:17:05 +03:00
# define _(x) lang_msg_rotate(talloc_tos(),x)
2007-08-27 15:41:05 +04:00
2001-10-06 22:03:25 +04:00
# define PIDMAP struct PidMap
2003-04-24 06:35:00 +04:00
/* how long to wait for start/stops to take effect */
# define SLEEP_TIME 3
2001-10-06 22:03:25 +04:00
PIDMAP {
PIDMAP * next , * prev ;
2007-05-07 13:35:35 +04:00
struct server_id pid ;
2001-10-06 22:03:25 +04:00
char * machine ;
} ;
static PIDMAP * pidmap ;
static int PID_or_Machine ; /* 0 = show PID, else show Machine name */
2007-05-07 13:35:35 +04:00
static struct server_id smbd_pid ;
1998-03-15 05:37:52 +03:00
2001-10-06 22:03:25 +04:00
/* from 2nd call on, remove old list */
static void initPid2Machine ( void )
{
/* show machine name rather PID on table "Open Files"? */
if ( PID_or_Machine ) {
2008-10-02 00:15:54 +04:00
PIDMAP * p , * next ;
2001-10-06 22:03:25 +04:00
2008-10-02 00:15:54 +04:00
for ( p = pidmap ; p ! = NULL ; p = next ) {
next = p - > next ;
2001-10-06 22:03:25 +04:00
DLIST_REMOVE ( pidmap , p ) ;
SAFE_FREE ( p - > machine ) ;
SAFE_FREE ( p ) ;
}
pidmap = NULL ;
}
}
/* add new PID <-> Machine name mapping */
2007-08-29 17:52:07 +04:00
static void addPid2Machine ( struct server_id pid , const char * machine )
2001-10-06 22:03:25 +04:00
{
/* show machine name rather PID on table "Open Files"? */
if ( PID_or_Machine ) {
PIDMAP * newmap ;
2004-12-07 21:25:53 +03:00
if ( ( newmap = SMB_MALLOC_P ( PIDMAP ) ) = = NULL ) {
2001-10-06 22:03:25 +04:00
/* XXX need error message for this?
if malloc fails , PID is always shown */
return ;
}
newmap - > pid = pid ;
2004-12-07 21:25:53 +03:00
newmap - > machine = SMB_STRDUP ( machine ) ;
2001-10-06 22:03:25 +04:00
DLIST_ADD ( pidmap , newmap ) ;
}
}
/* lookup PID <-> Machine name mapping */
2007-05-07 13:35:35 +04:00
static char * mapPid2Machine ( struct server_id pid )
2001-10-06 22:03:25 +04:00
{
static char pidbuf [ 64 ] ;
PIDMAP * map ;
/* show machine name rather PID on table "Open Files"? */
if ( PID_or_Machine ) {
for ( map = pidmap ; map ! = NULL ; map = map - > next ) {
2012-06-16 02:26:26 +04:00
if ( serverid_equal ( & pid , & map - > pid ) ) {
2001-10-06 22:03:25 +04:00
if ( map - > machine = = NULL ) /* no machine name */
break ; /* show PID */
return map - > machine ;
}
}
}
/* PID not in list or machine name NULL? return pid as string */
2005-09-30 21:13:37 +04:00
snprintf ( pidbuf , sizeof ( pidbuf ) - 1 , " %s " ,
procid_str_static ( & pid ) ) ;
2001-10-06 22:03:25 +04:00
return pidbuf ;
}
2007-12-04 04:17:05 +03:00
static const char * tstring ( TALLOC_CTX * ctx , time_t t )
1998-03-15 09:43:15 +03:00
{
2007-12-04 04:17:05 +03:00
char * buf ;
buf = talloc_strdup ( ctx , time_to_asc ( t ) ) ;
if ( ! buf ) {
return " " ;
}
buf = talloc_all_string_sub ( ctx ,
buf ,
" " ,
" " ) ;
if ( ! buf ) {
return " " ;
}
1998-03-15 09:43:15 +03:00
return buf ;
}
2006-07-21 18:13:30 +04:00
static void print_share_mode ( const struct share_mode_entry * e ,
const char * sharepath ,
const char * fname ,
void * dummy )
1998-03-15 05:37:52 +03:00
{
2004-10-02 02:24:44 +04:00
char * utf8_fname ;
2010-01-18 12:15:29 +03:00
char * utf8_sharepath ;
2006-02-01 00:54:24 +03:00
int deny_mode ;
2008-04-30 01:36:24 +04:00
size_t converted_size ;
2006-02-01 00:54:24 +03:00
if ( ! is_valid_share_mode_entry ( e ) ) {
return ;
}
deny_mode = map_share_mode_to_deny_mode ( e - > share_access ,
2005-07-08 08:51:27 +04:00
e - > private_options ) ;
2004-10-02 02:24:44 +04:00
printf ( " <tr><td>%s</td> " , _ ( mapPid2Machine ( e - > pid ) ) ) ;
2006-06-21 06:31:12 +04:00
printf ( " <td>%u</td> " , ( unsigned int ) e - > uid ) ;
2004-10-02 02:24:44 +04:00
printf ( " <td> " ) ;
2005-07-08 08:51:27 +04:00
switch ( ( deny_mode > > 4 ) & 0xF ) {
2004-10-02 02:24:44 +04:00
case DENY_NONE : printf ( " DENY_NONE " ) ; break ;
case DENY_ALL : printf ( " DENY_ALL " ) ; break ;
case DENY_DOS : printf ( " DENY_DOS " ) ; break ;
2005-07-08 08:51:27 +04:00
case DENY_FCB : printf ( " DENY_FCB " ) ; break ;
2004-10-02 02:24:44 +04:00
case DENY_READ : printf ( " DENY_READ " ) ; break ;
case DENY_WRITE : printf ( " DENY_WRITE " ) ; break ;
1998-03-15 05:37:52 +03:00
}
2004-10-02 02:24:44 +04:00
printf ( " </td> " ) ;
1998-03-15 05:37:52 +03:00
2004-10-02 02:24:44 +04:00
printf ( " <td> " ) ;
2005-07-08 08:51:27 +04:00
if ( e - > access_mask & ( FILE_READ_DATA | FILE_WRITE_DATA ) ) {
printf ( " %s " , _ ( " RDWR " ) ) ;
} else if ( e - > access_mask & FILE_WRITE_DATA ) {
printf ( " %s " , _ ( " WRONLY " ) ) ;
} else {
printf ( " %s " , _ ( " RDONLY " ) ) ;
1998-03-15 05:37:52 +03:00
}
2004-10-02 02:24:44 +04:00
printf ( " </td> " ) ;
1998-03-15 05:37:52 +03:00
2004-10-02 02:24:44 +04:00
printf ( " <td> " ) ;
1998-03-15 05:37:52 +03:00
if ( ( e - > op_type &
( EXCLUSIVE_OPLOCK | BATCH_OPLOCK ) ) = =
( EXCLUSIVE_OPLOCK | BATCH_OPLOCK ) )
2004-10-02 02:24:44 +04:00
printf ( " EXCLUSIVE+BATCH " ) ;
1998-03-15 05:37:52 +03:00
else if ( e - > op_type & EXCLUSIVE_OPLOCK )
2004-10-02 02:24:44 +04:00
printf ( " EXCLUSIVE " ) ;
1998-03-15 05:37:52 +03:00
else if ( e - > op_type & BATCH_OPLOCK )
2004-10-02 02:24:44 +04:00
printf ( " BATCH " ) ;
1999-12-13 16:27:58 +03:00
else if ( e - > op_type & LEVEL_II_OPLOCK )
2004-10-02 02:24:44 +04:00
printf ( " LEVEL_II " ) ;
1998-03-15 05:37:52 +03:00
else
2004-10-02 02:24:44 +04:00
printf ( " NONE " ) ;
printf ( " </td> " ) ;
1998-03-15 05:37:52 +03:00
2009-03-19 04:20:11 +03:00
push_utf8_talloc ( talloc_tos ( ) , & utf8_fname , fname , & converted_size ) ;
2010-01-18 12:15:29 +03:00
push_utf8_talloc ( talloc_tos ( ) , & utf8_sharepath , sharepath ,
& converted_size ) ;
printf ( " <td>%s</td><td>%s</td><td>%s</td></tr> \n " ,
utf8_sharepath , utf8_fname , tstring ( talloc_tos ( ) , e - > time . tv_sec ) ) ;
2009-03-19 04:20:11 +03:00
TALLOC_FREE ( utf8_fname ) ;
1998-03-15 05:37:52 +03:00
}
1999-12-21 07:54:30 +03:00
/* kill off any connections chosen by the user */
2010-03-01 16:28:22 +03:00
static int traverse_fn1 ( const struct connections_key * key ,
2007-05-08 17:44:36 +04:00
const struct connections_data * crec ,
2007-05-28 15:38:42 +04:00
void * private_data )
1999-12-21 07:54:30 +03:00
{
2012-06-06 17:22:31 +04:00
if ( crec - > cnum = = TID_FIELD_INVALID & & process_exists ( crec - > pid ) ) {
1999-12-21 07:54:30 +03:00
char buf [ 30 ] ;
2007-05-28 15:38:42 +04:00
slprintf ( buf , sizeof ( buf ) - 1 , " kill_%s " , procid_str_static ( & crec - > pid ) ) ;
1999-12-21 07:54:30 +03:00
if ( cgi_variable ( buf ) ) {
2007-05-08 17:44:36 +04:00
kill_pid ( crec - > pid ) ;
2003-04-24 06:35:00 +04:00
sleep ( SLEEP_TIME ) ;
1999-12-21 07:54:30 +03:00
}
}
return 0 ;
}
/* traversal fn for showing machine connections */
2010-03-01 16:28:22 +03:00
static int traverse_fn2 ( const struct connections_key * key ,
2007-05-28 15:38:42 +04:00
const struct connections_data * crec ,
void * private_data )
1999-12-21 07:54:30 +03:00
{
2012-06-06 17:22:31 +04:00
if ( crec - > cnum = = TID_FIELD_INVALID | | ! process_exists ( crec - > pid ) | |
2012-06-16 02:26:26 +04:00
serverid_equal ( & crec - > pid , & smbd_pid ) )
2001-05-15 22:12:02 +04:00
return 0 ;
1999-12-21 07:54:30 +03:00
2007-05-08 17:44:36 +04:00
addPid2Machine ( crec - > pid , crec - > machine ) ;
2001-10-06 22:03:25 +04:00
2005-09-30 21:13:37 +04:00
printf ( " <tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td> \n " ,
2007-05-08 17:44:36 +04:00
procid_str_static ( & crec - > pid ) ,
crec - > machine , crec - > addr ,
2007-12-04 04:17:05 +03:00
tstring ( talloc_tos ( ) , crec - > start ) ) ;
1999-12-21 07:54:30 +03:00
if ( geteuid ( ) = = 0 ) {
2005-09-30 21:13:37 +04:00
printf ( " <td><input type=submit value= \" X \" name= \" kill_%s \" ></td> \n " ,
2007-05-08 17:44:36 +04:00
procid_str_static ( & crec - > pid ) ) ;
1999-12-21 07:54:30 +03:00
}
2004-10-02 02:24:44 +04:00
printf ( " </tr> \n " ) ;
1999-12-21 07:54:30 +03:00
return 0 ;
}
/* traversal fn for showing share connections */
2010-03-01 16:28:22 +03:00
static int traverse_fn3 ( const struct connections_key * key ,
2007-05-28 15:38:42 +04:00
const struct connections_data * crec ,
void * private_data )
1999-12-21 07:54:30 +03:00
{
2012-06-06 17:22:31 +04:00
if ( crec - > cnum = = TID_FIELD_INVALID | | ! process_exists ( crec - > pid ) )
2001-05-15 22:12:02 +04:00
return 0 ;
1999-12-21 07:54:30 +03:00
2005-09-30 21:13:37 +04:00
printf ( " <tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr> \n " ,
2007-05-08 17:44:36 +04:00
crec - > servicename , uidtoname ( crec - > uid ) ,
gidtoname ( crec - > gid ) , procid_str_static ( & crec - > pid ) ,
crec - > machine ,
2007-12-04 04:17:05 +03:00
tstring ( talloc_tos ( ) , crec - > start ) ) ;
1999-12-21 07:54:30 +03:00
return 0 ;
}
1998-03-15 05:37:52 +03:00
/* show the current server status */
void status_page ( void )
{
2003-01-03 11:28:12 +03:00
const char * v ;
1998-03-17 14:44:16 +03:00
int autorefresh = 0 ;
int refresh_interval = 30 ;
2003-04-23 03:19:09 +04:00
int nr_running = 0 ;
2007-10-19 04:40:25 +04:00
bool waitup = False ;
2007-12-04 04:17:05 +03:00
TALLOC_CTX * ctx = talloc_stackframe ( ) ;
2011-07-08 14:58:53 +04:00
const char form_name [ ] = " status " ;
1998-03-15 05:37:52 +03:00
2012-07-20 03:36:18 +04:00
smbd_pid = pid_to_procid ( pidfile_pid ( lp_piddir ( ) , " smbd " ) ) ;
2001-05-07 07:55:54 +04:00
2011-07-08 14:58:53 +04:00
if ( ! verify_xsrf_token ( form_name ) ) {
goto output_page ;
}
2003-04-23 03:19:09 +04:00
if ( cgi_variable ( " smbd_restart " ) | | cgi_variable ( " all_restart " ) ) {
2000-01-07 11:47:34 +03:00
stop_smbd ( ) ;
1998-05-08 05:45:12 +04:00
start_smbd ( ) ;
2003-04-24 06:35:00 +04:00
waitup = True ;
1998-05-08 05:45:12 +04:00
}
2003-04-23 03:19:09 +04:00
if ( cgi_variable ( " smbd_start " ) | | cgi_variable ( " all_start " ) ) {
1998-03-15 05:37:52 +03:00
start_smbd ( ) ;
2003-04-24 06:35:00 +04:00
waitup = True ;
1998-03-15 05:37:52 +03:00
}
2003-04-23 03:19:09 +04:00
if ( cgi_variable ( " smbd_stop " ) | | cgi_variable ( " all_stop " ) ) {
1998-03-15 05:37:52 +03:00
stop_smbd ( ) ;
2003-04-24 06:35:00 +04:00
waitup = True ;
1998-03-15 05:37:52 +03:00
}
2003-04-23 03:19:09 +04:00
if ( cgi_variable ( " nmbd_restart " ) | | cgi_variable ( " all_restart " ) ) {
2000-01-07 11:47:34 +03:00
stop_nmbd ( ) ;
1998-05-08 05:45:12 +04:00
start_nmbd ( ) ;
2003-04-24 06:35:00 +04:00
waitup = True ;
1998-05-08 05:45:12 +04:00
}
2003-04-23 03:19:09 +04:00
if ( cgi_variable ( " nmbd_start " ) | | cgi_variable ( " all_start " ) ) {
1998-03-15 05:37:52 +03:00
start_nmbd ( ) ;
2003-04-24 06:35:00 +04:00
waitup = True ;
1998-03-15 05:37:52 +03:00
}
2003-04-23 03:19:09 +04:00
if ( cgi_variable ( " nmbd_stop " ) | | cgi_variable ( " all_stop " ) ) {
1998-03-15 05:37:52 +03:00
stop_nmbd ( ) ;
2003-04-24 06:35:00 +04:00
waitup = True ;
1998-03-15 05:37:52 +03:00
}
2002-08-17 18:34:48 +04:00
# ifdef WITH_WINBIND
2003-04-23 03:19:09 +04:00
if ( cgi_variable ( " winbindd_restart " ) | | cgi_variable ( " all_restart " ) ) {
2002-08-17 18:34:48 +04:00
stop_winbindd ( ) ;
start_winbindd ( ) ;
2003-04-24 06:35:00 +04:00
waitup = True ;
2002-08-17 18:34:48 +04:00
}
2003-04-23 03:19:09 +04:00
if ( cgi_variable ( " winbindd_start " ) | | cgi_variable ( " all_start " ) ) {
2002-08-17 18:34:48 +04:00
start_winbindd ( ) ;
2003-04-24 06:35:00 +04:00
waitup = True ;
2002-08-17 18:34:48 +04:00
}
2003-04-23 03:19:09 +04:00
if ( cgi_variable ( " winbindd_stop " ) | | cgi_variable ( " all_stop " ) ) {
2002-08-17 18:34:48 +04:00
stop_winbindd ( ) ;
2003-04-24 06:35:00 +04:00
waitup = True ;
2002-08-17 18:34:48 +04:00
}
# endif
2003-04-24 06:35:00 +04:00
/* wait for daemons to start/stop */
if ( waitup )
sleep ( SLEEP_TIME ) ;
1998-03-17 14:44:16 +03:00
if ( cgi_variable ( " autorefresh " ) ) {
autorefresh = 1 ;
} else if ( cgi_variable ( " norefresh " ) ) {
autorefresh = 0 ;
} else if ( cgi_variable ( " refresh " ) ) {
autorefresh = 1 ;
}
if ( ( v = cgi_variable ( " refresh_interval " ) ) ) {
refresh_interval = atoi ( v ) ;
}
2001-10-06 22:03:25 +04:00
if ( cgi_variable ( " show_client_in_col_1 " ) ) {
PID_or_Machine = 1 ;
}
2003-10-03 05:42:53 +04:00
if ( cgi_variable ( " show_pid_in_col_1 " ) ) {
PID_or_Machine = 0 ;
}
2010-03-01 16:28:22 +03:00
connections_forall_read ( traverse_fn1 , NULL ) ;
2007-12-04 04:17:05 +03:00
2001-10-06 22:03:25 +04:00
initPid2Machine ( ) ;
1998-03-15 05:37:52 +03:00
2011-07-08 14:58:53 +04:00
output_page :
2004-10-02 02:24:44 +04:00
printf ( " <H2>%s</H2> \n " , _ ( " Server Status " ) ) ;
1998-03-15 05:37:52 +03:00
2004-10-02 02:24:44 +04:00
printf ( " <FORM method=post> \n " ) ;
2011-07-08 14:58:53 +04:00
print_xsrf_token ( cgi_user_name ( ) , cgi_user_pass ( ) , form_name ) ;
1998-03-15 05:37:52 +03:00
1998-03-17 14:44:16 +03:00
if ( ! autorefresh ) {
2004-10-02 02:24:44 +04:00
printf ( " <input type=submit value= \" %s \" name= \" autorefresh \" > \n " , _ ( " Auto Refresh " ) ) ;
printf ( " <br>%s " , _ ( " Refresh Interval: " ) ) ;
printf ( " <input type=text size=2 name= \" refresh_interval \" value= \" %d \" > \n " ,
1998-03-17 14:44:16 +03:00
refresh_interval ) ;
} else {
2004-10-02 02:24:44 +04:00
printf ( " <input type=submit value= \" %s \" name= \" norefresh \" > \n " , _ ( " Stop Refreshing " ) ) ;
printf ( " <br>%s%d \n " , _ ( " Refresh Interval: " ) , refresh_interval ) ;
printf ( " <input type=hidden name= \" refresh \" value= \" 1 \" > \n " ) ;
1998-03-17 14:44:16 +03:00
}
2004-10-02 02:24:44 +04:00
printf ( " <p> \n " ) ;
1998-03-17 14:44:16 +03:00
2004-10-02 02:24:44 +04:00
printf ( " <table> \n " ) ;
1998-03-15 05:37:52 +03:00
2009-01-16 00:27:52 +03:00
printf ( " <tr><td>%s</td><td>%s</td></tr> " , _ ( " version: " ) , samba_version_string ( ) ) ;
1998-03-15 05:37:52 +03:00
fflush ( stdout ) ;
2004-10-02 02:24:44 +04:00
printf ( " <tr><td>%s</td><td>%s</td> \n " , _ ( " smbd: " ) , smbd_running ( ) ? _ ( " running " ) : _ ( " not running " ) ) ;
1999-12-13 16:27:58 +03:00
if ( geteuid ( ) = = 0 ) {
if ( smbd_running ( ) ) {
2003-04-23 03:19:09 +04:00
nr_running + + ;
2004-10-02 02:24:44 +04:00
printf ( " <td><input type=submit name= \" smbd_stop \" value= \" %s \" ></td> \n " , _ ( " Stop smbd " ) ) ;
1999-12-13 16:27:58 +03:00
} else {
2004-10-02 02:24:44 +04:00
printf ( " <td><input type=submit name= \" smbd_start \" value= \" %s \" ></td> \n " , _ ( " Start smbd " ) ) ;
1999-12-13 16:27:58 +03:00
}
2004-10-02 02:24:44 +04:00
printf ( " <td><input type=submit name= \" smbd_restart \" value= \" %s \" ></td> \n " , _ ( " Restart smbd " ) ) ;
1998-03-15 05:37:52 +03:00
}
2004-10-02 02:24:44 +04:00
printf ( " </tr> \n " ) ;
1998-03-15 05:37:52 +03:00
fflush ( stdout ) ;
2004-10-02 02:24:44 +04:00
printf ( " <tr><td>%s</td><td>%s</td> \n " , _ ( " nmbd: " ) , nmbd_running ( ) ? _ ( " running " ) : _ ( " not running " ) ) ;
1999-12-13 16:27:58 +03:00
if ( geteuid ( ) = = 0 ) {
if ( nmbd_running ( ) ) {
2003-04-23 03:19:09 +04:00
nr_running + + ;
2004-10-02 02:24:44 +04:00
printf ( " <td><input type=submit name= \" nmbd_stop \" value= \" %s \" ></td> \n " , _ ( " Stop nmbd " ) ) ;
1999-12-13 16:27:58 +03:00
} else {
2004-10-02 02:24:44 +04:00
printf ( " <td><input type=submit name= \" nmbd_start \" value= \" %s \" ></td> \n " , _ ( " Start nmbd " ) ) ;
1999-12-13 16:27:58 +03:00
}
2004-10-02 02:24:44 +04:00
printf ( " <td><input type=submit name= \" nmbd_restart \" value= \" %s \" ></td> \n " , _ ( " Restart nmbd " ) ) ;
1998-03-15 05:37:52 +03:00
}
2004-10-02 02:24:44 +04:00
printf ( " </tr> \n " ) ;
1998-03-15 05:37:52 +03:00
2002-08-17 18:34:48 +04:00
# ifdef WITH_WINBIND
fflush ( stdout ) ;
2004-10-02 02:24:44 +04:00
printf ( " <tr><td>%s</td><td>%s</td> \n " , _ ( " winbindd: " ) , winbindd_running ( ) ? _ ( " running " ) : _ ( " not running " ) ) ;
2002-08-17 18:34:48 +04:00
if ( geteuid ( ) = = 0 ) {
if ( winbindd_running ( ) ) {
2003-04-23 03:19:09 +04:00
nr_running + + ;
2004-10-02 02:24:44 +04:00
printf ( " <td><input type=submit name= \" winbindd_stop \" value= \" %s \" ></td> \n " , _ ( " Stop winbindd " ) ) ;
2002-08-17 18:34:48 +04:00
} else {
2004-10-02 02:24:44 +04:00
printf ( " <td><input type=submit name= \" winbindd_start \" value= \" %s \" ></td> \n " , _ ( " Start winbindd " ) ) ;
2002-08-17 18:34:48 +04:00
}
2004-10-02 02:24:44 +04:00
printf ( " <td><input type=submit name= \" winbindd_restart \" value= \" %s \" ></td> \n " , _ ( " Restart winbindd " ) ) ;
2003-04-24 06:35:00 +04:00
}
2004-10-02 02:24:44 +04:00
printf ( " </tr> \n " ) ;
2003-04-24 06:35:00 +04:00
# endif
if ( geteuid ( ) = = 0 ) {
2004-10-02 02:24:44 +04:00
printf ( " <tr><td></td><td></td> \n " ) ;
2003-04-23 03:19:09 +04:00
if ( nr_running > = 1 ) {
/* stop, restart all */
2004-10-02 02:24:44 +04:00
printf ( " <td><input type=submit name= \" all_stop \" value= \" %s \" ></td> \n " , _ ( " Stop All " ) ) ;
printf ( " <td><input type=submit name= \" all_restart \" value= \" %s \" ></td> \n " , _ ( " Restart All " ) ) ;
2003-04-23 03:19:09 +04:00
}
else if ( nr_running = = 0 ) {
/* start all */
2004-10-02 02:24:44 +04:00
printf ( " <td><input type=submit name= \" all_start \" value= \" %s \" ></td> \n " , _ ( " Start All " ) ) ;
2003-04-23 03:19:09 +04:00
}
2004-10-02 02:24:44 +04:00
printf ( " </tr> \n " ) ;
2002-08-17 18:34:48 +04:00
}
2004-10-02 02:24:44 +04:00
printf ( " </table> \n " ) ;
1998-03-15 05:37:52 +03:00
fflush ( stdout ) ;
2004-10-02 02:24:44 +04:00
printf ( " <p><h3>%s</h3> \n " , _ ( " Active Connections " ) ) ;
printf ( " <table border=1> \n " ) ;
printf ( " <tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th> \n " , _ ( " PID " ) , _ ( " Client " ) , _ ( " IP address " ) , _ ( " Date " ) ) ;
1999-12-13 16:27:58 +03:00
if ( geteuid ( ) = = 0 ) {
2004-10-02 02:24:44 +04:00
printf ( " <th>%s</th> \n " , _ ( " Kill " ) ) ;
1999-12-13 16:27:58 +03:00
}
2004-10-02 02:24:44 +04:00
printf ( " </tr> \n " ) ;
1998-03-15 05:37:52 +03:00
2010-03-01 16:28:22 +03:00
connections_forall_read ( traverse_fn2 , NULL ) ;
1998-03-15 05:37:52 +03:00
2004-10-02 02:24:44 +04:00
printf ( " </table><p> \n " ) ;
1998-03-15 05:37:52 +03:00
2004-10-02 02:24:44 +04:00
printf ( " <p><h3>%s</h3> \n " , _ ( " Active Shares " ) ) ;
printf ( " <table border=1> \n " ) ;
printf ( " <tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr> \n \n " ,
2001-09-24 19:55:09 +04:00
_ ( " Share " ) , _ ( " User " ) , _ ( " Group " ) , _ ( " PID " ) , _ ( " Client " ) , _ ( " Date " ) ) ;
1998-03-15 05:37:52 +03:00
2010-03-01 16:28:22 +03:00
connections_forall_read ( traverse_fn3 , NULL ) ;
1998-03-15 05:37:52 +03:00
2004-10-02 02:24:44 +04:00
printf ( " </table><p> \n " ) ;
1998-03-15 05:37:52 +03:00
2004-10-02 02:24:44 +04:00
printf ( " <h3>%s</h3> \n " , _ ( " Open Files " ) ) ;
printf ( " <table border=1> \n " ) ;
2010-01-18 12:15:29 +03:00
printf ( " <tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr> \n " ,
_ ( " PID " ) , _ ( " UID " ) , _ ( " Sharing " ) , _ ( " R/W " ) , _ ( " Oplock " ) , _ ( " Share " ) , _ ( " File " ) , _ ( " Date " ) ) ;
1998-03-15 05:37:52 +03:00
2007-12-05 22:53:22 +03:00
locking_init_readonly ( ) ;
2006-07-21 18:13:30 +04:00
share_mode_forall ( print_share_mode , NULL ) ;
1998-03-15 05:37:52 +03:00
locking_end ( ) ;
2004-10-02 02:24:44 +04:00
printf ( " </table> \n " ) ;
1998-03-15 05:37:52 +03:00
2004-10-02 02:24:44 +04:00
printf ( " <br><input type=submit name= \" show_client_in_col_1 \" value= \" %s \" > \n " , _ ( " Show Client in col 1 " ) ) ;
printf ( " <input type=submit name= \" show_pid_in_col_1 \" value= \" %s \" > \n " , _ ( " Show PID in col 1 " ) ) ;
2001-10-06 22:03:25 +04:00
2004-10-02 02:24:44 +04:00
printf ( " </FORM> \n " ) ;
1998-03-18 10:44:27 +03:00
if ( autorefresh ) {
/* this little JavaScript allows for automatic refresh
of the page . There are other methods but this seems
to be the best alternative */
2004-10-02 02:24:44 +04:00
printf ( " <script language= \" JavaScript \" > \n " ) ;
printf ( " <!-- \n setTimeout('window.location.replace( \" %s/status?refresh_interval=%d&refresh=1 \" )', %d) \n " ,
1998-03-18 10:44:27 +03:00
cgi_baseurl ( ) ,
refresh_interval ,
refresh_interval * 1000 ) ;
2004-10-02 02:24:44 +04:00
printf ( " //--> \n </script> \n " ) ;
1998-03-18 10:44:27 +03:00
}
2007-12-04 04:17:05 +03:00
TALLOC_FREE ( ctx ) ;
1998-03-15 05:37:52 +03:00
}