/*
Unix SMB/Netbios implementation.
Version 1.9.
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 02139, USA.
*/
#include "includes.h"
static void print_share_mode(share_mode_entry *e, char *fname)
{
printf("
%d | ",e->pid);
printf("");
switch ((e->share_mode>>4)&0xF) {
case DENY_NONE: printf("DENY_NONE"); break;
case DENY_ALL: printf("DENY_ALL "); break;
case DENY_DOS: printf("DENY_DOS "); break;
case DENY_READ: printf("DENY_READ "); break;
case DENY_WRITE:printf("DENY_WRITE "); break;
}
printf(" | ");
printf("");
switch (e->share_mode&0xF) {
case 0: printf("RDONLY "); break;
case 1: printf("WRONLY "); break;
case 2: printf("RDWR "); break;
}
printf(" | ");
printf("");
if((e->op_type &
(EXCLUSIVE_OPLOCK|BATCH_OPLOCK)) ==
(EXCLUSIVE_OPLOCK|BATCH_OPLOCK))
printf("EXCLUSIVE+BATCH ");
else if (e->op_type & EXCLUSIVE_OPLOCK)
printf("EXCLUSIVE ");
else if (e->op_type & BATCH_OPLOCK)
printf("BATCH ");
else
printf("NONE ");
printf(" | ");
printf("%s | %s |
\n",
fname,asctime(LocalTime((time_t *)&e->time.tv_sec)));
}
/* show the current server status */
void status_page(void)
{
struct connect_record crec;
pstring fname;
FILE *f;
if (cgi_variable("smbd_start")) {
start_smbd();
}
if (cgi_variable("smbd_stop")) {
stop_smbd();
}
if (cgi_variable("nmbd_start")) {
start_nmbd();
}
if (cgi_variable("nmbd_stop")) {
stop_nmbd();
}
pstrcpy(fname,lp_lockdir());
standard_sub_basic(fname);
trim_string(fname,"","/");
strcat(fname,"/STATUS..LCK");
f = fopen(fname,"r");
if (f) {
while (!feof(f)) {
if (fread(&crec,sizeof(crec),1,f) != 1) break;
if (crec.magic == 0x280267 && crec.cnum == -1 &&
process_exists(crec.pid)) {
char buf[30];
sprintf(buf,"kill_%d", crec.pid);
if (cgi_variable(buf)) {
kill_pid(crec.pid);
}
}
}
fclose(f);
}
printf("Server Status
\n");
printf("\n");
}