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
the Free Software Foundation ; either version 2 of the License , or
( 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
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
# include "includes.h"
2004-10-07 08:01:18 +04:00
# include "web/swat_proto.h"
1998-03-15 05:37:52 +03: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 ;
2005-09-30 21:13:37 +04:00
struct process_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 */
2005-09-30 21:13:37 +04:00
static struct process_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 ) {
2001-10-14 16:10:29 +04:00
PIDMAP * p ;
2001-10-06 22:03:25 +04:00
for ( p = pidmap ; p ! = NULL ; ) {
DLIST_REMOVE ( pidmap , p ) ;
SAFE_FREE ( p - > machine ) ;
SAFE_FREE ( p ) ;
}
pidmap = NULL ;
}
}
/* add new PID <-> Machine name mapping */
2005-09-30 21:13:37 +04:00
static void addPid2Machine ( struct process_id pid , 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 */
2005-09-30 21:13:37 +04:00
static char * mapPid2Machine ( struct process_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 ) {
2005-09-30 21:13:37 +04:00
if ( procid_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 ;
}
1998-03-15 09:43:15 +03:00
static char * tstring ( time_t t )
{
static pstring buf ;
2006-06-15 01:36:49 +04:00
pstrcpy ( buf , time_to_asc ( & t ) ) ;
1999-12-13 16:27:58 +03:00
all_string_sub ( buf , " " , " " , sizeof ( buf ) ) ;
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 ;
2006-02-01 00:54:24 +03:00
int deny_mode ;
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
2004-10-02 02:24:44 +04:00
push_utf8_allocate ( & utf8_fname , fname ) ;
printf ( " <td>%s</td><td>%s</td></tr> \n " ,
utf8_fname , tstring ( e - > time . tv_sec ) ) ;
SAFE_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 */
1) added void* state argument to tdb_traverse. guess what! there were
two places i found where it was appropriate to _use_ that third argument,
in locking.c and brlock.c! there was a static traverse_function and
i removed the static variable, typecast it to a void*, passed it to
tdb_traverse and re-cast it back to the traverse_function inside the
tdb_traverse function. this makes the use of tdb_traverse() reentrant,
which is never going to happen, i know, i just don't like to see
statics lying about when there's no need for them.
as i had to do in samba-tng, all uses of tdb_traverse modified to take
the new void* state argument.
2) disabled rpcclient: referring people to use SAMBA_TNG rpcclient.
i don't know how the other samba team members would react if i deleted
rpcclient from cvs main. damn, that code's so old, it's unreal.
20 rpcclient commands, instead of about 70 in SAMBA_TNG.
(This used to be commit 49d7f0afbc1c5425d53019e234d54ddf205c8e9a)
2000-02-04 07:59:31 +03:00
static int traverse_fn1 ( TDB_CONTEXT * tdb , TDB_DATA kbuf , TDB_DATA dbuf , void * state )
1999-12-21 07:54:30 +03:00
{
struct connections_data crec ;
2001-05-15 22:12:02 +04:00
if ( dbuf . dsize ! = sizeof ( crec ) )
return 0 ;
1999-12-21 07:54:30 +03:00
memcpy ( & crec , dbuf . dptr , sizeof ( crec ) ) ;
if ( crec . cnum = = - 1 & & process_exists ( crec . pid ) ) {
char buf [ 30 ] ;
2005-09-30 21:13:37 +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 ) ) {
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 */
1) added void* state argument to tdb_traverse. guess what! there were
two places i found where it was appropriate to _use_ that third argument,
in locking.c and brlock.c! there was a static traverse_function and
i removed the static variable, typecast it to a void*, passed it to
tdb_traverse and re-cast it back to the traverse_function inside the
tdb_traverse function. this makes the use of tdb_traverse() reentrant,
which is never going to happen, i know, i just don't like to see
statics lying about when there's no need for them.
as i had to do in samba-tng, all uses of tdb_traverse modified to take
the new void* state argument.
2) disabled rpcclient: referring people to use SAMBA_TNG rpcclient.
i don't know how the other samba team members would react if i deleted
rpcclient from cvs main. damn, that code's so old, it's unreal.
20 rpcclient commands, instead of about 70 in SAMBA_TNG.
(This used to be commit 49d7f0afbc1c5425d53019e234d54ddf205c8e9a)
2000-02-04 07:59:31 +03:00
static int traverse_fn2 ( TDB_CONTEXT * tdb , TDB_DATA kbuf , TDB_DATA dbuf , void * state )
1999-12-21 07:54:30 +03:00
{
struct connections_data crec ;
2001-05-15 22:12:02 +04:00
if ( dbuf . dsize ! = sizeof ( crec ) )
return 0 ;
1999-12-21 07:54:30 +03:00
memcpy ( & crec , dbuf . dptr , sizeof ( crec ) ) ;
2005-09-30 21:13:37 +04:00
if ( crec . cnum = = - 1 | | ! process_exists ( crec . pid ) | |
procid_equal ( & crec . pid , & smbd_pid ) )
2001-05-15 22:12:02 +04:00
return 0 ;
1999-12-21 07:54:30 +03:00
2001-10-06 22:03:25 +04:00
addPid2Machine ( crec . pid , crec . machine ) ;
2005-09-30 21:13:37 +04:00
printf ( " <tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td> \n " ,
procid_str_static ( & crec . pid ) ,
2001-10-06 22:03:25 +04:00
crec . machine , crec . addr ,
1999-12-21 07:54:30 +03:00
tstring ( crec . start ) ) ;
if ( geteuid ( ) = = 0 ) {
2005-09-30 21:13:37 +04:00
printf ( " <td><input type=submit value= \" X \" name= \" kill_%s \" ></td> \n " ,
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 */
1) added void* state argument to tdb_traverse. guess what! there were
two places i found where it was appropriate to _use_ that third argument,
in locking.c and brlock.c! there was a static traverse_function and
i removed the static variable, typecast it to a void*, passed it to
tdb_traverse and re-cast it back to the traverse_function inside the
tdb_traverse function. this makes the use of tdb_traverse() reentrant,
which is never going to happen, i know, i just don't like to see
statics lying about when there's no need for them.
as i had to do in samba-tng, all uses of tdb_traverse modified to take
the new void* state argument.
2) disabled rpcclient: referring people to use SAMBA_TNG rpcclient.
i don't know how the other samba team members would react if i deleted
rpcclient from cvs main. damn, that code's so old, it's unreal.
20 rpcclient commands, instead of about 70 in SAMBA_TNG.
(This used to be commit 49d7f0afbc1c5425d53019e234d54ddf205c8e9a)
2000-02-04 07:59:31 +03:00
static int traverse_fn3 ( TDB_CONTEXT * tdb , TDB_DATA kbuf , TDB_DATA dbuf , void * state )
1999-12-21 07:54:30 +03:00
{
struct connections_data crec ;
2001-05-15 22:12:02 +04:00
if ( dbuf . dsize ! = sizeof ( crec ) )
return 0 ;
1999-12-21 07:54:30 +03:00
memcpy ( & crec , dbuf . dptr , sizeof ( crec ) ) ;
2001-05-15 22:12:02 +04:00
if ( crec . cnum = = - 1 | | ! process_exists ( crec . pid ) )
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 " ,
1999-12-21 07:54:30 +03:00
crec . name , uidtoname ( crec . uid ) ,
2005-09-30 21:13:37 +04:00
gidtoname ( crec . gid ) , procid_str_static ( & crec . pid ) ,
1999-12-21 07:54:30 +03:00
crec . machine ,
tstring ( crec . start ) ) ;
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 ;
1999-12-21 07:54:30 +03:00
TDB_CONTEXT * tdb ;
2003-04-23 03:19:09 +04:00
int nr_running = 0 ;
2003-04-24 06:35:00 +04:00
BOOL waitup = False ;
1998-03-15 05:37:52 +03:00
2005-09-30 21:13:37 +04:00
smbd_pid = pid_to_procid ( pidfile_pid ( " smbd " ) ) ;
2001-05-07 07:55:54 +04:00
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 ;
}
2001-09-07 02:08:19 +04:00
tdb = tdb_open_log ( lock_path ( " connections.tdb " ) , 0 , TDB_DEFAULT , O_RDONLY , 0 ) ;
1) added void* state argument to tdb_traverse. guess what! there were
two places i found where it was appropriate to _use_ that third argument,
in locking.c and brlock.c! there was a static traverse_function and
i removed the static variable, typecast it to a void*, passed it to
tdb_traverse and re-cast it back to the traverse_function inside the
tdb_traverse function. this makes the use of tdb_traverse() reentrant,
which is never going to happen, i know, i just don't like to see
statics lying about when there's no need for them.
as i had to do in samba-tng, all uses of tdb_traverse modified to take
the new void* state argument.
2) disabled rpcclient: referring people to use SAMBA_TNG rpcclient.
i don't know how the other samba team members would react if i deleted
rpcclient from cvs main. damn, that code's so old, it's unreal.
20 rpcclient commands, instead of about 70 in SAMBA_TNG.
(This used to be commit 49d7f0afbc1c5425d53019e234d54ddf205c8e9a)
2000-02-04 07:59:31 +03:00
if ( tdb ) tdb_traverse ( tdb , traverse_fn1 , NULL ) ;
2001-10-06 22:03:25 +04:00
initPid2Machine ( ) ;
1998-03-15 05:37:52 +03:00
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 " ) ;
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
1999-12-21 07:54:30 +03:00
if ( ! tdb ) {
1999-12-13 16:27:58 +03:00
/* open failure either means no connections have been
2001-08-22 23:11:55 +04:00
made */
1998-03-15 05:37:52 +03:00
}
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 ( " <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
1) added void* state argument to tdb_traverse. guess what! there were
two places i found where it was appropriate to _use_ that third argument,
in locking.c and brlock.c! there was a static traverse_function and
i removed the static variable, typecast it to a void*, passed it to
tdb_traverse and re-cast it back to the traverse_function inside the
tdb_traverse function. this makes the use of tdb_traverse() reentrant,
which is never going to happen, i know, i just don't like to see
statics lying about when there's no need for them.
as i had to do in samba-tng, all uses of tdb_traverse modified to take
the new void* state argument.
2) disabled rpcclient: referring people to use SAMBA_TNG rpcclient.
i don't know how the other samba team members would react if i deleted
rpcclient from cvs main. damn, that code's so old, it's unreal.
20 rpcclient commands, instead of about 70 in SAMBA_TNG.
(This used to be commit 49d7f0afbc1c5425d53019e234d54ddf205c8e9a)
2000-02-04 07:59:31 +03:00
if ( tdb ) tdb_traverse ( tdb , 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
1) added void* state argument to tdb_traverse. guess what! there were
two places i found where it was appropriate to _use_ that third argument,
in locking.c and brlock.c! there was a static traverse_function and
i removed the static variable, typecast it to a void*, passed it to
tdb_traverse and re-cast it back to the traverse_function inside the
tdb_traverse function. this makes the use of tdb_traverse() reentrant,
which is never going to happen, i know, i just don't like to see
statics lying about when there's no need for them.
as i had to do in samba-tng, all uses of tdb_traverse modified to take
the new void* state argument.
2) disabled rpcclient: referring people to use SAMBA_TNG rpcclient.
i don't know how the other samba team members would react if i deleted
rpcclient from cvs main. damn, that code's so old, it's unreal.
20 rpcclient commands, instead of about 70 in SAMBA_TNG.
(This used to be commit 49d7f0afbc1c5425d53019e234d54ddf205c8e9a)
2000-02-04 07:59:31 +03:00
if ( tdb ) tdb_traverse ( tdb , 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 " ) ;
printf ( " <tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr> \n " , _ ( " PID " ) , _ ( " Sharing " ) , _ ( " R/W " ) , _ ( " Oplock " ) , _ ( " File " ) , _ ( " Date " ) ) ;
1998-03-15 05:37:52 +03:00
locking_init ( 1 ) ;
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
2000-01-03 03:32:14 +03:00
if ( tdb ) tdb_close ( tdb ) ;
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
}
1998-03-15 05:37:52 +03:00
}