From d360320618fe3a7f53ac1f05ee3ac54323a03c82 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 15 Mar 1998 02:37:52 +0000 Subject: - added the ability to kill off individual connections from SWAT (from the status page) - split the claim_connection() code into its own file - fixed the claim_connection() code to lock the file when manipulating it - always claim a null connection at startup - fixed a bug in the pidfile code (This used to be commit abd4a17e21d12be3d1747e94ceb1915abaf135e3) --- source3/web/statuspage.c | 194 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 source3/web/statuspage.c (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c new file mode 100644 index 0000000000..3a95d99d37 --- /dev/null +++ b/source3/web/statuspage.c @@ -0,0 +1,194 @@ +/* + 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; + int i, pid; + char *v; + + 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(); + } + + for (i=0;cgi_vnum(i, &v); i++) { + if (strncmp(v, "kill_", 5) != 0) continue; + pid = atoi(v+5); + if (pid > 0) { + printf("killing %d
\n", pid); + kill_pid(pid); + } + } + + + printf("

Server Status

\n"); + + printf("
\n"); + + pstrcpy(fname,lp_lockdir()); + standard_sub_basic(fname); + trim_string(fname,"","/"); + strcat(fname,"/STATUS..LCK"); + + f = fopen(fname,"r"); + if (!f) { + printf("Couldn't open status file %s\n",fname); + if (!lp_status(-1)) + printf("You need to have status=yes in your smb config file\n"); + return; + } + + + printf("\n"); + + printf("",VERSION); + + fflush(stdout); + if (smbd_running()) { + printf("\n"); + } else { + printf("\n"); + } + + fflush(stdout); + if (nmbd_running()) { + printf("\n"); + } else { + printf("\n"); + } + + printf("
version:%s
smbd:running
smbd:not running
nmbd:running
nmbd:not running
\n"); + fflush(stdout); + + + if (geteuid() != 0) + printf("NOTE: You are not logged in as root and won't be able to start/stop the server

\n"); + + printf("

Active Connections

\n"); + printf("\n"); + printf("\n"); + + while (!feof(f)) { + if (fread(&crec,sizeof(crec),1,f) != 1) + break; + if (crec.magic == 0x280267 && process_exists(crec.pid)) { + printf("\n", + crec.pid, + crec.machine,crec.addr, + asctime(LocalTime(&crec.start)), + crec.pid); + } + } + + printf("
PIDClientIP addressDateKill
%d%s%s%s

\n"); + + fseek(f, 0, SEEK_SET); + + printf("

Active Shares

\n"); + printf("\n"); + printf("\n\n"); + + while (!feof(f)) { + if (fread(&crec,sizeof(crec),1,f) != 1) + break; + if (crec.cnum == -1) continue; + if (crec.magic == 0x280267 && process_exists(crec.pid)) { + printf("\n", + crec.name,uidtoname(crec.uid), + gidtoname(crec.gid),crec.pid, + crec.machine, + asctime(LocalTime(&crec.start))); + } + } + + printf("
ShareUserGroupPIDClientDate
%s%s%s%d%s%s

\n"); + + printf("

Open Files

\n"); + printf("\n"); + printf("\n"); + + locking_init(1); + share_mode_forall(print_share_mode); + locking_end(); + printf("
PIDSharingR/WOplockFileDate
\n"); + + fclose(f); + + printf("
\n"); +} + -- cgit From 08a6e255fe8dec721b57aa15a4e606b11dc7f44d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 15 Mar 1998 02:47:22 +0000 Subject: safer killing of connections - it ensures the process is still a valid smbd when killing (This used to be commit 78675036e81e2cde7209d9e68956d71ef6661137) --- source3/web/statuspage.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 3a95d99d37..0031adde9f 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -86,16 +86,22 @@ void status_page(void) stop_nmbd(); } - for (i=0;cgi_vnum(i, &v); i++) { - if (strncmp(v, "kill_", 5) != 0) continue; - pid = atoi(v+5); - if (pid > 0) { - printf("killing %d
\n", pid); - kill_pid(pid); + 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(pid); + } + } } + fclose(f); } - printf("

Server Status

\n"); printf("
\n"); -- cgit From 86f5105fbca56ab07f8a33e892fe656672600388 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 15 Mar 1998 03:06:50 +0000 Subject: - claim the null connection after the session request to mak sure we have the netbios name - fix another kill connection bug (This used to be commit c634b799874795d42dae28fb4440ea452dc89b1b) --- source3/web/statuspage.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 0031adde9f..25a45928f2 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -67,8 +67,6 @@ void status_page(void) struct connect_record crec; pstring fname; FILE *f; - int i, pid; - char *v; if (cgi_variable("smbd_start")) { start_smbd(); @@ -86,6 +84,12 @@ void status_page(void) 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)) { @@ -95,7 +99,7 @@ void status_page(void) char buf[30]; sprintf(buf,"kill_%d", crec.pid); if (cgi_variable(buf)) { - kill_pid(pid); + kill_pid(crec.pid); } } } @@ -106,11 +110,6 @@ void status_page(void) printf("\n"); - pstrcpy(fname,lp_lockdir()); - standard_sub_basic(fname); - trim_string(fname,"","/"); - strcat(fname,"/STATUS..LCK"); - f = fopen(fname,"r"); if (!f) { printf("Couldn't open status file %s\n",fname); @@ -152,7 +151,9 @@ void status_page(void) while (!feof(f)) { if (fread(&crec,sizeof(crec),1,f) != 1) break; - if (crec.magic == 0x280267 && process_exists(crec.pid)) { + if (crec.magic == 0x280267 && + crec.cnum == -1 && + process_exists(crec.pid)) { printf("%d%s%s%s\n", crec.pid, crec.machine,crec.addr, -- cgit From 7a418233e27a21d0177fbc7ac657e9fdf74a0a4a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 15 Mar 1998 06:43:15 +0000 Subject: changed the date formatting (This used to be commit 57aa1db47cda9c625cd1ef742fece14d14590590) --- source3/web/statuspage.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 25a45928f2..3ba46ff14f 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -22,6 +22,14 @@ #include "includes.h" +static char *tstring(time_t t) +{ + static pstring buf; + pstrcpy(buf, asctime(LocalTime(&t))); + string_sub(buf," "," "); + return buf; +} + static void print_share_mode(share_mode_entry *e, char *fname) { printf("%d",e->pid); @@ -57,7 +65,7 @@ static void print_share_mode(share_mode_entry *e, char *fname) printf(""); printf("%s%s\n", - fname,asctime(LocalTime((time_t *)&e->time.tv_sec))); + fname,tstring(e->time.tv_sec)); } @@ -157,7 +165,7 @@ void status_page(void) printf("%d%s%s%s\n", crec.pid, crec.machine,crec.addr, - asctime(LocalTime(&crec.start)), + tstring(crec.start), crec.pid); } } @@ -179,7 +187,7 @@ void status_page(void) crec.name,uidtoname(crec.uid), gidtoname(crec.gid),crec.pid, crec.machine, - asctime(LocalTime(&crec.start))); + tstring(crec.start)); } } -- cgit From 59d7006b05bb301e36f786b047b90ab9ef5be122 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 17 Mar 1998 11:44:16 +0000 Subject: - added "Full View"/"Normal View" on the "view config" page - added the ability to auto-refresh the status page. There is a problem with this (it can kill inetd!). Hopefully we can fix that. (This used to be commit 4488d8932fa072bf8a3ae236ab666618051b5e83) --- source3/web/statuspage.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 3ba46ff14f..41681c2228 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -75,6 +75,9 @@ void status_page(void) struct connect_record crec; pstring fname; FILE *f; + char *v; + int autorefresh=0; + int refresh_interval=30; if (cgi_variable("smbd_start")) { start_smbd(); @@ -92,6 +95,23 @@ void status_page(void) stop_nmbd(); } + 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); + } + + if (autorefresh) { + printf("\n", + refresh_interval, cgi_baseurl(), refresh_interval); + } + pstrcpy(fname,lp_lockdir()); standard_sub_basic(fname); trim_string(fname,"","/"); @@ -118,6 +138,19 @@ void status_page(void) printf("\n"); + if (!autorefresh) { + printf("\n"); + printf("
Refresh Interval: "); + printf("\n", + refresh_interval); + } else { + printf("\n"); + printf("
Refresh Interval: %d\n", refresh_interval); + printf("\n"); + } + + printf("

\n"); + f = fopen(fname,"r"); if (!f) { printf("Couldn't open status file %s\n",fname); -- cgit From c8c61ac6a643d1c51c1546a6e346c566bb34f3b2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 18 Mar 1998 07:33:11 +0000 Subject: changed the method used for auto-reload on the status page to use JavaScript. This avoids the nasty inetd problem. (This used to be commit 9d9b13880963a0e3cf5213ce2a24c52f4a11a472) --- source3/web/statuspage.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 41681c2228..98c0982b99 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -107,11 +107,6 @@ void status_page(void) refresh_interval = atoi(v); } - if (autorefresh) { - printf("\n", - refresh_interval, cgi_baseurl(), refresh_interval); - } - pstrcpy(fname,lp_lockdir()); standard_sub_basic(fname); trim_string(fname,"","/"); @@ -147,6 +142,15 @@ void status_page(void) printf("\n"); printf("
Refresh Interval: %d\n", refresh_interval); printf("\n"); + /* this little JavaScript allows for automatic refresh + of the page. There are other methods but this seems + to be the best alternative */ + printf("\n"); } printf("

\n"); -- cgit From 78dd0fe44826761f93785f73ab5b7fdc88e2c4ea Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 18 Mar 1998 07:44:27 +0000 Subject: moved the refresh script to the end of the page so that silly things like a refresh of 0 actually work. (This used to be commit 4c04e1d2aea64ba0b53846c04235669eef0b28ca) --- source3/web/statuspage.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 98c0982b99..5f89eee43a 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -142,15 +142,6 @@ void status_page(void) printf("\n"); printf("
Refresh Interval: %d\n", refresh_interval); printf("\n"); - /* this little JavaScript allows for automatic refresh - of the page. There are other methods but this seems - to be the best alternative */ - printf("\n"); } printf("

\n"); @@ -242,5 +233,17 @@ void status_page(void) fclose(f); printf("

\n"); + + if (autorefresh) { + /* this little JavaScript allows for automatic refresh + of the page. There are other methods but this seems + to be the best alternative */ + printf("\n"); + } } -- cgit From 51bc0c19c06f480c03cfc279388387c0aa8ae75c Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Fri, 8 May 1998 01:45:12 +0000 Subject: The globals section now shows non-default variables (like the view config section does) in the basic view. There is also a reset button to undo all changes you have made (that haven't been committed). In addition each field now has a "Set Default" button. Multi-choice fields are now select fields instead of a set of radio buttons. On the status screen I added a "restart" option for stopping then starting smbd and nmbd. (This used to be commit a6edde4f004d3ba65d938acd3e6e094664a6c468) --- source3/web/statuspage.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 5f89eee43a..9bcc99a6af 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -79,6 +79,12 @@ void status_page(void) int autorefresh=0; int refresh_interval=30; + if (cgi_variable("smbd_restart")) { + if (smbd_running()) + stop_smbd(); + start_smbd(); + } + if (cgi_variable("smbd_start")) { start_smbd(); } @@ -87,6 +93,11 @@ void status_page(void) stop_smbd(); } + if (cgi_variable("nmbd_restart")) { + if (nmbd_running()) + stop_nmbd(); + start_nmbd(); + } if (cgi_variable("nmbd_start")) { start_nmbd(); } @@ -161,16 +172,16 @@ void status_page(void) fflush(stdout); if (smbd_running()) { - printf("smbd:running\n"); + printf("smbd:running\n"); } else { - printf("smbd:not running\n"); + printf("smbd:not running>\n"); } fflush(stdout); if (nmbd_running()) { - printf("nmbd:running\n"); + printf("nmbd:running\n"); } else { - printf("nmbd:not running\n"); + printf("nmbd:not running\n"); } printf("\n"); -- cgit From f888868f46a5418bac9ab528497136c152895305 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 12 May 1998 00:55:32 +0000 Subject: This is a security audit change of the main source. It removed all ocurrences of the following functions : sprintf strcpy strcat The replacements are slprintf, safe_strcpy and safe_strcat. It should not be possible to use code in Samba that uses sprintf, strcpy or strcat, only the safe_equivalents. Once Andrew has fixed the slprintf implementation then this code will be moved back to the 1.9.18 code stream. Jeremy. (This used to be commit 2d774454005f0b54e5684cf618da7060594dfcbb) --- source3/web/statuspage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 9bcc99a6af..184f7e1f73 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -121,7 +121,7 @@ void status_page(void) pstrcpy(fname,lp_lockdir()); standard_sub_basic(fname); trim_string(fname,"","/"); - strcat(fname,"/STATUS..LCK"); + pstrcat(fname,"/STATUS..LCK"); f = fopen(fname,"r"); @@ -131,7 +131,7 @@ void status_page(void) if (crec.magic == 0x280267 && crec.cnum == -1 && process_exists(crec.pid)) { char buf[30]; - sprintf(buf,"kill_%d", crec.pid); + slprintf(buf,sizeof(buf)-1,"kill_%d", crec.pid); if (cgi_variable(buf)) { kill_pid(crec.pid); } -- cgit From 768761820e8d7481c586c4e0ab4ac7cb36d18c4b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 17 Nov 1998 20:50:07 +0000 Subject: Added the same open()/fopen()/creat()/mmap() -> sys_XXX calls. Tidied up some of the mess (no other word for it). Still doesn't compile cleanly. There are calls with incorrect parameters that don't seem to be doing the right thing. This code still needs surgery :-(. Jeremy. (This used to be commit 18ff93a9abbf68ee8c59c0af3e57c63e4a015dac) --- source3/web/statuspage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 184f7e1f73..81564390a0 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -124,7 +124,7 @@ void status_page(void) pstrcat(fname,"/STATUS..LCK"); - f = fopen(fname,"r"); + f = sys_fopen(fname,"r"); if (f) { while (!feof(f)) { if (fread(&crec,sizeof(crec),1,f) != 1) break; @@ -157,7 +157,7 @@ void status_page(void) printf("

\n"); - f = fopen(fname,"r"); + f = sys_fopen(fname,"r"); if (!f) { printf("Couldn't open status file %s\n",fname); if (!lp_status(-1)) -- cgit From 8757254f39ab75c93e9917a6bdf99475c6a024d7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 23 Nov 1998 03:36:10 +0000 Subject: changed string_sub() to replace " ; and ` in the inserted string with _ use all_string_sub() if you don't want this. (This used to be commit a3357ab49335106674fe7a7481cd0f146d74fbe5) --- source3/web/statuspage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 81564390a0..faf1dcb20d 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -26,7 +26,7 @@ static char *tstring(time_t t) { static pstring buf; pstrcpy(buf, asctime(LocalTime(&t))); - string_sub(buf," "," "); + all_string_sub(buf," "," "); return buf; } -- cgit From 3db52feb1f3b2c07ce0b06ad4a7099fa6efe3fc7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Dec 1999 13:27:58 +0000 Subject: first pass at updating head branch to be to be the same as the SAMBA_2_0 branch (This used to be commit 453a822a76780063dff23526c35408866d0c0154) --- source3/web/statuspage.c | 72 +++++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 28 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index faf1dcb20d..304a122e23 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -26,13 +26,13 @@ static char *tstring(time_t t) { static pstring buf; pstrcpy(buf, asctime(LocalTime(&t))); - all_string_sub(buf," "," "); + all_string_sub(buf," "," ",sizeof(buf)); return buf; } static void print_share_mode(share_mode_entry *e, char *fname) { - printf("%d",e->pid); + printf("%d",(int)e->pid); printf(""); switch ((e->share_mode>>4)&0xF) { case DENY_NONE: printf("DENY_NONE"); break; @@ -60,12 +60,14 @@ static void print_share_mode(share_mode_entry *e, char *fname) printf("EXCLUSIVE "); else if (e->op_type & BATCH_OPLOCK) printf("BATCH "); + else if (e->op_type & LEVEL_II_OPLOCK) + printf("LEVEL_II "); else printf("NONE "); printf(""); printf("%s%s\n", - fname,tstring(e->time.tv_sec)); + dos_to_unix(fname,False),tstring(e->time.tv_sec)); } @@ -131,7 +133,7 @@ void status_page(void) if (crec.magic == 0x280267 && crec.cnum == -1 && process_exists(crec.pid)) { char buf[30]; - slprintf(buf,sizeof(buf)-1,"kill_%d", crec.pid); + slprintf(buf,sizeof(buf)-1,"kill_%d", (int)crec.pid); if (cgi_variable(buf)) { kill_pid(crec.pid); } @@ -159,10 +161,10 @@ void status_page(void) f = sys_fopen(fname,"r"); if (!f) { - printf("Couldn't open status file %s\n",fname); + /* open failure either means no connections have been + made or status=no */ if (!lp_status(-1)) printf("You need to have status=yes in your smb config file\n"); - return; } @@ -171,60 +173,74 @@ void status_page(void) printf("version:%s",VERSION); fflush(stdout); - if (smbd_running()) { - printf("smbd:running\n"); - } else { - printf("smbd:not running>\n"); + printf("smbd:%srunning\n",smbd_running()?"":"not "); + if (geteuid() == 0) { + if (smbd_running()) { + printf("\n"); + } else { + printf("\n"); + } + printf("\n"); } + printf("\n"); fflush(stdout); - if (nmbd_running()) { - printf("nmbd:running\n"); - } else { - printf("nmbd:not running\n"); + printf("nmbd:%srunning\n",nmbd_running()?"":"not "); + if (geteuid() == 0) { + if (nmbd_running()) { + printf("\n"); + } else { + printf("\n"); + } + printf("\n"); } + printf("\n"); printf("\n"); fflush(stdout); - - if (geteuid() != 0) - printf("NOTE: You are not logged in as root and won't be able to start/stop the server

\n"); - printf("

Active Connections

\n"); printf("\n"); - printf("\n"); + printf("\n"); + if (geteuid() == 0) { + printf("\n"); + } + printf("\n"); - while (!feof(f)) { + while (f && !feof(f)) { if (fread(&crec,sizeof(crec),1,f) != 1) break; if (crec.magic == 0x280267 && crec.cnum == -1 && process_exists(crec.pid)) { - printf("\n", - crec.pid, + printf("\n", + (int)crec.pid, crec.machine,crec.addr, - tstring(crec.start), - crec.pid); + tstring(crec.start)); + if (geteuid() == 0) { + printf("\n", + (int)crec.pid); + } + printf("\n"); } } printf("
PIDClientIP addressDateKill
PIDClientIP addressDateKill
%d%s%s%s
%d%s%s%s

\n"); - fseek(f, 0, SEEK_SET); + if (f) fseek(f, 0, SEEK_SET); printf("

Active Shares

\n"); printf("\n"); printf("\n\n"); - while (!feof(f)) { + while (f && !feof(f)) { if (fread(&crec,sizeof(crec),1,f) != 1) break; if (crec.cnum == -1) continue; if (crec.magic == 0x280267 && process_exists(crec.pid)) { printf("\n", crec.name,uidtoname(crec.uid), - gidtoname(crec.gid),crec.pid, + gidtoname(crec.gid),(int)crec.pid, crec.machine, tstring(crec.start)); } @@ -241,7 +257,7 @@ void status_page(void) locking_end(); printf("
ShareUserGroupPIDClientDate
%s%s%s%d%s%s
\n"); - fclose(f); + if (f) fclose(f); printf("\n"); -- cgit From 69d24d869bf97978b31a51fe8e8d08cac4874d67 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 21 Dec 1999 04:54:30 +0000 Subject: first cut at using the tdb code for the connections structure, the SWAT status page and smbstatus. It made the code _much_ simpler, I wish we'd done a database module a long time ago! (This used to be commit 4951755413c11d4c5b9af4699a6e622056d52433) --- source3/web/statuspage.c | 117 +++++++++++++++++++++++++---------------------- 1 file changed, 63 insertions(+), 54 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 304a122e23..8b7108c0b5 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -71,15 +71,68 @@ static void print_share_mode(share_mode_entry *e, char *fname) } +/* kill off any connections chosen by the user */ +static int traverse_fn1(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf) +{ + struct connections_data crec; + memcpy(&crec, dbuf.dptr, sizeof(crec)); + + if (crec.cnum == -1 && process_exists(crec.pid)) { + char buf[30]; + slprintf(buf,sizeof(buf)-1,"kill_%d", (int)crec.pid); + if (cgi_variable(buf)) { + kill_pid(crec.pid); + } + } + return 0; +} + +/* traversal fn for showing machine connections */ +static int traverse_fn2(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf) +{ + struct connections_data crec; + memcpy(&crec, dbuf.dptr, sizeof(crec)); + + if (crec.cnum != -1 || !process_exists(crec.pid)) return 0; + + printf("%d%s%s%s\n", + (int)crec.pid, + crec.machine,crec.addr, + tstring(crec.start)); + if (geteuid() == 0) { + printf("\n", + (int)crec.pid); + } + printf("\n"); + + return 0; +} + +/* traversal fn for showing share connections */ +static int traverse_fn3(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf) +{ + struct connections_data crec; + memcpy(&crec, dbuf.dptr, sizeof(crec)); + + if (crec.cnum != -1 || !process_exists(crec.pid)) return 0; + + printf("%s%s%s%d%s%s\n", + crec.name,uidtoname(crec.uid), + gidtoname(crec.gid),(int)crec.pid, + crec.machine, + tstring(crec.start)); + return 0; +} + + /* show the current server status */ void status_page(void) { - struct connect_record crec; pstring fname; - FILE *f; char *v; int autorefresh=0; int refresh_interval=30; + TDB_CONTEXT *tdb; if (cgi_variable("smbd_restart")) { if (smbd_running()) @@ -123,24 +176,10 @@ void status_page(void) pstrcpy(fname,lp_lockdir()); standard_sub_basic(fname); trim_string(fname,"","/"); - pstrcat(fname,"/STATUS..LCK"); - - - f = sys_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]; - slprintf(buf,sizeof(buf)-1,"kill_%d", (int)crec.pid); - if (cgi_variable(buf)) { - kill_pid(crec.pid); - } - } - } - fclose(f); - } + pstrcat(fname,"/connections.tdb"); + + tdb = tdb_open(fname, 0, O_RDONLY, 0); + if (tdb) tdb_traverse(tdb, traverse_fn1); printf("

Server Status

\n"); @@ -159,8 +198,7 @@ void status_page(void) printf("

\n"); - f = sys_fopen(fname,"r"); - if (!f) { + if (!tdb) { /* open failure either means no connections have been made or status=no */ if (!lp_status(-1)) @@ -207,44 +245,15 @@ void status_page(void) } printf("\n"); - while (f && !feof(f)) { - if (fread(&crec,sizeof(crec),1,f) != 1) - break; - if (crec.magic == 0x280267 && - crec.cnum == -1 && - process_exists(crec.pid)) { - printf("%d%s%s%s\n", - (int)crec.pid, - crec.machine,crec.addr, - tstring(crec.start)); - if (geteuid() == 0) { - printf("\n", - (int)crec.pid); - } - printf("\n"); - } - } + if (tdb) tdb_traverse(tdb, traverse_fn2); printf("

\n"); - if (f) fseek(f, 0, SEEK_SET); - printf("

Active Shares

\n"); printf("\n"); printf("\n\n"); - while (f && !feof(f)) { - if (fread(&crec,sizeof(crec),1,f) != 1) - break; - if (crec.cnum == -1) continue; - if (crec.magic == 0x280267 && process_exists(crec.pid)) { - printf("\n", - crec.name,uidtoname(crec.uid), - gidtoname(crec.gid),(int)crec.pid, - crec.machine, - tstring(crec.start)); - } - } + if (tdb) tdb_traverse(tdb, traverse_fn3); printf("
ShareUserGroupPIDClientDate
%s%s%s%d%s%s

\n"); @@ -257,7 +266,7 @@ void status_page(void) locking_end(); printf("\n"); - if (f) fclose(f); + tdb_close(tdb); printf("\n"); -- cgit From 4e1291a83f61a72989045879763d9ef05fd38f71 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 21 Dec 1999 09:25:59 +0000 Subject: converted all our existing shared memory code to use a tdb database instead of either sysv or mmap shared memory or lock files. this means we can now completely remove locking_shm.c locking_slow.c shmem.c shmem_sysv.c and lots of other things also got simpler locking.c got a bit larger, but is much better compartmentalised now (This used to be commit e48c2d9937eea0667b8cd3332e49c06314ef31e7) --- source3/web/statuspage.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 8b7108c0b5..e3e10f09d5 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -128,7 +128,6 @@ static int traverse_fn3(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf) /* show the current server status */ void status_page(void) { - pstring fname; char *v; int autorefresh=0; int refresh_interval=30; @@ -173,12 +172,7 @@ void status_page(void) refresh_interval = atoi(v); } - pstrcpy(fname,lp_lockdir()); - standard_sub_basic(fname); - trim_string(fname,"","/"); - pstrcat(fname,"/connections.tdb"); - - tdb = tdb_open(fname, 0, O_RDONLY, 0); + tdb = tdb_open(lock_path("connections.tdb"), 0, O_RDONLY, 0); if (tdb) tdb_traverse(tdb, traverse_fn1); printf("

Server Status

\n"); -- cgit From 9a781a8c6de9513ba5f4cafef41379fae96807c1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 2 Jan 2000 23:00:27 +0000 Subject: - added tdb_flags option to tdb_open() - added TDB_CLEAR_IF_FIRST flag to clear the database if this is the first attached process. Useful for non-persistent databases like our locking area (this will also make upgrades to new database layouts easier) - use lock_path() in a couple of places - leave connections database open while smbd running - cleaned up some tdb code a little, using macros for constants (This used to be commit 00e9da3ca577527db392aced62f02c69cfee8f4f) --- source3/web/statuspage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index e3e10f09d5..eaf3fdb864 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -172,7 +172,7 @@ void status_page(void) refresh_interval = atoi(v); } - tdb = tdb_open(lock_path("connections.tdb"), 0, O_RDONLY, 0); + tdb = tdb_open(lock_path("connections.tdb"), 0, 0, O_RDONLY, 0); if (tdb) tdb_traverse(tdb, traverse_fn1); printf("

Server Status

\n"); -- cgit From 98b1c568af7ed5f738b92a7aae1826856d638046 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 3 Jan 2000 00:32:14 +0000 Subject: fixed active shares display (This used to be commit b87d1442db86165d983007dd58647c88ac702abf) --- source3/web/statuspage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index eaf3fdb864..359db5c80a 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -114,7 +114,7 @@ static int traverse_fn3(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf) struct connections_data crec; memcpy(&crec, dbuf.dptr, sizeof(crec)); - if (crec.cnum != -1 || !process_exists(crec.pid)) return 0; + if (crec.cnum == -1 || !process_exists(crec.pid)) return 0; printf("%s%s%s%d%s%s\n", crec.name,uidtoname(crec.uid), @@ -260,7 +260,7 @@ void status_page(void) locking_end(); printf("\n"); - tdb_close(tdb); + if (tdb) tdb_close(tdb); printf("\n"); -- cgit From dd9e8074f70f6077ee9aeac262f2a46a5a69bc7b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 7 Jan 2000 08:47:34 +0000 Subject: always restart nmbd and smbd when asked, even if they appear not to be responding. They could be stuck (This used to be commit 8728c0bc94743935cec28caa83d93833ea3aa6a6) --- source3/web/statuspage.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 359db5c80a..e9cda3bd70 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -134,8 +134,7 @@ void status_page(void) TDB_CONTEXT *tdb; if (cgi_variable("smbd_restart")) { - if (smbd_running()) - stop_smbd(); + stop_smbd(); start_smbd(); } @@ -148,8 +147,7 @@ void status_page(void) } if (cgi_variable("nmbd_restart")) { - if (nmbd_running()) - stop_nmbd(); + stop_nmbd(); start_nmbd(); } if (cgi_variable("nmbd_start")) { -- cgit From bbe275e95b86bc7af5a641455cbb379974823f84 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 4 Feb 2000 04:59:31 +0000 Subject: 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) --- source3/web/statuspage.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index e9cda3bd70..5c800797c0 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -72,7 +72,7 @@ static void print_share_mode(share_mode_entry *e, char *fname) /* kill off any connections chosen by the user */ -static int traverse_fn1(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf) +static int traverse_fn1(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* state) { struct connections_data crec; memcpy(&crec, dbuf.dptr, sizeof(crec)); @@ -88,7 +88,7 @@ static int traverse_fn1(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf) } /* traversal fn for showing machine connections */ -static int traverse_fn2(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf) +static int traverse_fn2(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* state) { struct connections_data crec; memcpy(&crec, dbuf.dptr, sizeof(crec)); @@ -109,7 +109,7 @@ static int traverse_fn2(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf) } /* traversal fn for showing share connections */ -static int traverse_fn3(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf) +static int traverse_fn3(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* state) { struct connections_data crec; memcpy(&crec, dbuf.dptr, sizeof(crec)); @@ -171,7 +171,7 @@ void status_page(void) } tdb = tdb_open(lock_path("connections.tdb"), 0, 0, O_RDONLY, 0); - if (tdb) tdb_traverse(tdb, traverse_fn1); + if (tdb) tdb_traverse(tdb, traverse_fn1, NULL); printf("

Server Status

\n"); @@ -237,7 +237,7 @@ void status_page(void) } printf("\n"); - if (tdb) tdb_traverse(tdb, traverse_fn2); + if (tdb) tdb_traverse(tdb, traverse_fn2, NULL); printf("

\n"); @@ -245,7 +245,7 @@ void status_page(void) printf("\n"); printf("\n\n"); - if (tdb) tdb_traverse(tdb, traverse_fn3); + if (tdb) tdb_traverse(tdb, traverse_fn3, NULL); printf("
ShareUserGroupPIDClientDate

\n"); -- cgit From 6056766247fc2e7206d6bb13ad1ac467663ac298 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 7 May 2001 03:55:54 +0000 Subject: merge some fixes from 2.2 (This used to be commit 7e57adf2a039cb5b6458496f9190c9c642645600) --- source3/web/statuspage.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 5c800797c0..27a40d1695 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -21,6 +21,7 @@ #include "includes.h" +static pid_t smbd_pid; static char *tstring(time_t t) { @@ -93,7 +94,8 @@ static int traverse_fn2(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st struct connections_data crec; memcpy(&crec, dbuf.dptr, sizeof(crec)); - if (crec.cnum != -1 || !process_exists(crec.pid)) return 0; + if (crec.cnum != -1 || !process_exists(crec.pid) || + (crec.pid == smbd_pid)) return 0; printf("%d%s%s%s\n", (int)crec.pid, @@ -133,6 +135,8 @@ void status_page(void) int refresh_interval=30; TDB_CONTEXT *tdb; + smbd_pid = pidfile_pid("smbd"); + if (cgi_variable("smbd_restart")) { stop_smbd(); start_smbd(); -- cgit From 10211f53f9fa9e21a6ededf892b8be27bad9643e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 15 May 2001 18:12:02 +0000 Subject: Check sizes of data entries in connections.tdb before deciding they're crecs... We will need this when we use finer grained locking for max connections. Jeremy. (This used to be commit c6cd42a6791e26174eb795fd08ddbbd797e5a9cf) --- source3/web/statuspage.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 27a40d1695..51f2e8f00e 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -1,6 +1,6 @@ /* Unix SMB/Netbios implementation. - Version 1.9. + Version 2.2. web status page Copyright (C) Andrew Tridgell 1997-1998 @@ -76,6 +76,10 @@ static void print_share_mode(share_mode_entry *e, char *fname) static int traverse_fn1(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* state) { struct connections_data crec; + + if (dbuf.dsize != sizeof(crec)) + return 0; + memcpy(&crec, dbuf.dptr, sizeof(crec)); if (crec.cnum == -1 && process_exists(crec.pid)) { @@ -92,10 +96,14 @@ static int traverse_fn1(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st static int traverse_fn2(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* state) { struct connections_data crec; + + if (dbuf.dsize != sizeof(crec)) + return 0; + memcpy(&crec, dbuf.dptr, sizeof(crec)); - if (crec.cnum != -1 || !process_exists(crec.pid) || - (crec.pid == smbd_pid)) return 0; + if (crec.cnum != -1 || !process_exists(crec.pid) || (crec.pid == smbd_pid)) + return 0; printf("%d%s%s%s\n", (int)crec.pid, @@ -114,9 +122,14 @@ static int traverse_fn2(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st static int traverse_fn3(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* state) { struct connections_data crec; + + if (dbuf.dsize != sizeof(crec)) + return 0; + memcpy(&crec, dbuf.dptr, sizeof(crec)); - if (crec.cnum == -1 || !process_exists(crec.pid)) return 0; + if (crec.cnum == -1 || !process_exists(crec.pid)) + return 0; printf("%s%s%s%d%s%s\n", crec.name,uidtoname(crec.uid), @@ -278,4 +291,3 @@ void status_page(void) printf("//-->\n\n"); } } - -- cgit From 05fc3e578c895f632b351969d09cd00feb7599c7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Jun 2001 05:13:59 +0000 Subject: use LDSHFLAGS not -shared in several places (This used to be commit 8ec9c87b5d1a7dae17d5b1a30f58effaf5e69e4b) --- source3/web/statuspage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 51f2e8f00e..f3b07425b7 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -187,7 +187,7 @@ void status_page(void) refresh_interval = atoi(v); } - tdb = tdb_open(lock_path("connections.tdb"), 0, 0, O_RDONLY, 0); + tdb = tdb_open_log(lock_path("connections.tdb"), 0, 0, O_RDONLY, 0); if (tdb) tdb_traverse(tdb, traverse_fn1, NULL); printf("

Server Status

\n"); -- cgit From 87fbb7092b8f8b2f0db0f361c3d625e19de57cd9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 4 Jul 2001 07:15:53 +0000 Subject: The big character set handling changeover! This commit gets rid of all our old codepage handling and replaces it with iconv. All internal strings in Samba are now in "unix" charset, which may be multi-byte. See internals.doc and my posting to samba-technical for a more complete explanation. (This used to be commit debb471267960e56005a741817ebd227ecfc512a) --- source3/web/statuspage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index f3b07425b7..2efc37a051 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -68,7 +68,7 @@ static void print_share_mode(share_mode_entry *e, char *fname) printf(""); printf("%s%s\n", - dos_to_unix(fname,False),tstring(e->time.tv_sec)); + fname,tstring(e->time.tv_sec)); } -- cgit From 996719cce26700c68ff0e456e6a25d20085d091f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 30 Jul 2001 22:21:31 +0000 Subject: Added "use mmap" for HPUX. Jeremy. (This used to be commit 840802f10677cb0009cb4df4c37c7d01aa5edacd) --- source3/web/statuspage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 2efc37a051..dc26e86ef8 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -187,7 +187,7 @@ void status_page(void) refresh_interval = atoi(v); } - tdb = tdb_open_log(lock_path("connections.tdb"), 0, 0, O_RDONLY, 0); + tdb = tdb_open_log(lock_path("connections.tdb"), 0, USE_TDB_MMAP_FLAG, O_RDONLY, 0); if (tdb) tdb_traverse(tdb, traverse_fn1, NULL); printf("

Server Status

\n"); -- cgit From 2051bb7d0366e07c5ecda5e5f7cfedc4153d6228 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 22 Aug 2001 19:11:55 +0000 Subject: A few changes: drop paramaters: status utmp hostname change session code to always record each vuid current on the server. The sessionid struct is no longer packed, as I couldn't get that to work ;-) change smbstatus to show this info and less of the connections.tdb info (its not actualy that accurate). I'll get swat doing some of this shortly. (This used to be commit b068ad300527c44673bbee0aede7849199c89de7) --- source3/web/statuspage.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index dc26e86ef8..c112deb224 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -209,9 +209,7 @@ void status_page(void) if (!tdb) { /* open failure either means no connections have been - made or status=no */ - if (!lp_status(-1)) - printf("You need to have status=yes in your smb config file\n"); + made */ } -- cgit From 9a9ac2739bbdc993ecdfa78298bdd9c059328378 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Sep 2001 22:08:19 +0000 Subject: got rid of USE_TDB_MMAP_FLAG as its not needed any more (This used to be commit c26e0d3f27a05ecc8bd2390f9aab7f9451524e47) --- source3/web/statuspage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index c112deb224..e930629eee 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -187,7 +187,7 @@ void status_page(void) refresh_interval = atoi(v); } - tdb = tdb_open_log(lock_path("connections.tdb"), 0, USE_TDB_MMAP_FLAG, O_RDONLY, 0); + tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_DEFAULT, O_RDONLY, 0); if (tdb) tdb_traverse(tdb, traverse_fn1, NULL); printf("

Server Status

\n"); -- cgit From 96db4b1ba3a48f50b80b2cfbf0b940e073b7843c Mon Sep 17 00:00:00 2001 From: Motonobu Takahashi Date: Mon, 24 Sep 2001 15:55:09 +0000 Subject: Added SWAT i18n feature: TO enable configure with --with-i18n-swat to support this gettext is integrated and a new directories name "po" and "intl" are created. now these languages are supported: en - English (default) ja - Japanese po - Polish tr - Turkish To add your language, to create ${your_language}.po by translating source/po/en.po into your language is needed. some of html and image files of various language version are not included yet, though message catalogue files are installed. you need to copy files manually under ${swatdir}/lang/$ln/{help,images,included,using_samba} And also added a option to intall manual pages: of various lang version To enable configure with --with-manlangs but manual pages themself are not included yet. (This used to be commit 486b79a6fc4ba20a751aab544bd0f7ccff2b3d19) --- source3/web/statuspage.c | 72 +++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 35 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index e930629eee..61bbf67a13 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -20,6 +20,7 @@ */ #include "includes.h" +#include "webintl.h" static pid_t smbd_pid; @@ -36,19 +37,19 @@ static void print_share_mode(share_mode_entry *e, char *fname) printf("%d",(int)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; + 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; + case 0: printf(_("RDONLY ")); break; + case 1: printf(_("WRONLY ")); break; + case 2: printf(_("RDWR ")); break; } printf(""); @@ -56,15 +57,15 @@ static void print_share_mode(share_mode_entry *e, char *fname) if((e->op_type & (EXCLUSIVE_OPLOCK|BATCH_OPLOCK)) == (EXCLUSIVE_OPLOCK|BATCH_OPLOCK)) - printf("EXCLUSIVE+BATCH "); + printf(_("EXCLUSIVE+BATCH ")); else if (e->op_type & EXCLUSIVE_OPLOCK) - printf("EXCLUSIVE "); + printf(_("EXCLUSIVE ")); else if (e->op_type & BATCH_OPLOCK) - printf("BATCH "); + printf(_("BATCH ")); else if (e->op_type & LEVEL_II_OPLOCK) - printf("LEVEL_II "); + printf(_("LEVEL_II ")); else - printf("NONE "); + printf(_("NONE ")); printf(""); printf("%s%s\n", @@ -107,7 +108,7 @@ static int traverse_fn2(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st printf("%d%s%s%s\n", (int)crec.pid, - crec.machine,crec.addr, + crec.machine, crec.addr, tstring(crec.start)); if (geteuid() == 0) { printf("\n", @@ -190,18 +191,18 @@ void status_page(void) tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_DEFAULT, O_RDONLY, 0); if (tdb) tdb_traverse(tdb, traverse_fn1, NULL); - printf("

Server Status

\n"); + printf("

%s

\n", _("Server Status")); printf("
\n"); if (!autorefresh) { - printf("\n"); - printf("
Refresh Interval: "); + printf("\n", _("Auto Refresh")); + printf("
%s", _("Refresh Interval: ")); printf("\n", refresh_interval); } else { - printf("\n"); - printf("
Refresh Interval: %d\n", refresh_interval); + printf("\n", _("Stop Refreshing")); + printf("
%s%d\n", _("Refresh Interval: "), refresh_interval); printf("\n"); } @@ -215,40 +216,40 @@ void status_page(void) printf("\n"); - printf("",VERSION); + printf("", _("version:"), VERSION); fflush(stdout); - printf("\n",smbd_running()?"":"not "); + printf("\n", _("smbd:"), smbd_running()?_("running"):_("not running")); if (geteuid() == 0) { if (smbd_running()) { - printf("\n"); + printf("\n", _("Stop smbd")); } else { - printf("\n"); + printf("\n", _("Start smbd")); } - printf("\n"); + printf("\n", _("Restart smbd")); } printf("\n"); fflush(stdout); - printf("\n",nmbd_running()?"":"not "); + printf("\n", _("nmbd:"), nmbd_running()?_("running"):_("not running")); if (geteuid() == 0) { if (nmbd_running()) { - printf("\n"); + printf("\n", _("Stop nmbd")); } else { - printf("\n"); + printf("\n", _("Start nmbd")); } - printf("\n"); + printf("\n", _("Restart nmbd")); } printf("\n"); printf("
version:%s
%s%s
smbd:%srunning
%s%s
nmbd:%srunning
%s%s
\n"); fflush(stdout); - printf("

Active Connections

\n"); + printf("

%s

\n", _("Active Connections")); printf("\n"); - printf("\n"); + printf("\n", _("PID"), _("Client"), _("IP address"), _("Date")); if (geteuid() == 0) { - printf("\n"); + printf("\n", _("Kill")); } printf("\n"); @@ -256,17 +257,18 @@ void status_page(void) printf("
PIDClientIP addressDate
%s%s%s%sKill%s

\n"); - printf("

Active Shares

\n"); + printf("

%s

\n", _("Active Shares")); printf("\n"); - printf("\n\n"); + printf("\n\n", + _("Share"), _("User"), _("Group"), _("PID"), _("Client"), _("Date")); if (tdb) tdb_traverse(tdb, traverse_fn3, NULL); printf("
ShareUserGroupPIDClientDate
%s%s%s%s%s%s

\n"); - printf("

Open Files

\n"); + printf("

%s

\n", _("Open Files")); printf("\n"); - printf("\n"); + printf("\n", _("PID"), _("Sharing"), _("R/W"), _("Oplock"), _("File"), _("Date")); locking_init(1); share_mode_forall(print_share_mode); -- cgit From 8ad2982968478d91c9f799808195baf818d4fdae Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 6 Oct 2001 18:03:25 +0000 Subject: merge from 2.2 (This used to be commit 831530d93d606d13a792be1d3d4ac561697504d8) --- source3/web/statuspage.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 84 insertions(+), 2 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 61bbf67a13..b49fc7b656 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -22,8 +22,79 @@ #include "includes.h" #include "webintl.h" +#define PIDMAP struct PidMap + +PIDMAP { + PIDMAP *next, *prev; + pid_t pid; + char *machine; +}; + +static PIDMAP *pidmap; +static int PID_or_Machine; /* 0 = show PID, else show Machine name */ + static pid_t smbd_pid; +/* from 2nd call on, remove old list */ +static void initPid2Machine (void) +{ + /* show machine name rather PID on table "Open Files"? */ + if (PID_or_Machine) { + PIDMAP *p, *q; + + for (p = pidmap; p != NULL; ) { + DLIST_REMOVE(pidmap, p); + SAFE_FREE(p->machine); + SAFE_FREE(p); + } + + pidmap = NULL; + } +} + +/* add new PID <-> Machine name mapping */ +static void addPid2Machine (pid_t pid, char *machine) +{ + /* show machine name rather PID on table "Open Files"? */ + if (PID_or_Machine) { + PIDMAP *newmap; + + if ((newmap = (PIDMAP *) malloc (sizeof (PIDMAP))) == NULL) { + /* XXX need error message for this? + if malloc fails, PID is always shown */ + return; + } + + newmap->pid = pid; + newmap->machine = strdup (machine); + + DLIST_ADD(pidmap, newmap); + } +} + +/* lookup PID <-> Machine name mapping */ +static char *mapPid2Machine (pid_t pid) +{ + 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) { + if (pid == map->pid) { + 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 */ + snprintf (pidbuf, sizeof (pidbuf) - 1, "%d", pid); + return pidbuf; +} + static char *tstring(time_t t) { static pstring buf; @@ -34,7 +105,7 @@ static char *tstring(time_t t) static void print_share_mode(share_mode_entry *e, char *fname) { - printf("",(int)e->pid); + printf("",_(mapPid2Machine(e->pid))); printf("\n", (int)crec.pid, - crec.machine, crec.addr, + crec.machine,crec.addr, tstring(crec.start)); if (geteuid() == 0) { printf("\n", @@ -188,8 +261,14 @@ void status_page(void) refresh_interval = atoi(v); } + if (cgi_variable("show_client_in_col_1")) { + PID_or_Machine = 1; + } + tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_DEFAULT, O_RDONLY, 0); if (tdb) tdb_traverse(tdb, traverse_fn1, NULL); + + initPid2Machine (); printf("

%s

\n", _("Server Status")); @@ -277,6 +356,9 @@ void status_page(void) if (tdb) tdb_close(tdb); + printf("
\n"); + printf("\n"); + printf("\n"); if (autorefresh) { -- cgit From a689b24db14436ab1faa2f2f79b9f27b777b1fdb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 14 Oct 2001 12:10:29 +0000 Subject: the next step in the intl changeover. This should get us compiling agian, and also completes the switch to lang_tdb.c. SWAT should now work with a po file in the lib/ directory also removed useless SYSLOG defines in many files (This used to be commit 5296b20ad85d7519c870768455cb4d8df048c55a) --- source3/web/statuspage.c | 137 +++++++++++++++++++++++------------------------ 1 file changed, 68 insertions(+), 69 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index b49fc7b656..6af7674dc9 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -20,7 +20,6 @@ */ #include "includes.h" -#include "webintl.h" #define PIDMAP struct PidMap @@ -40,7 +39,7 @@ static void initPid2Machine (void) { /* show machine name rather PID on table "Open Files"? */ if (PID_or_Machine) { - PIDMAP *p, *q; + PIDMAP *p; for (p = pidmap; p != NULL; ) { DLIST_REMOVE(pidmap, p); @@ -105,41 +104,41 @@ static char *tstring(time_t t) static void print_share_mode(share_mode_entry *e, char *fname) { - printf("",_(mapPid2Machine(e->pid))); - printf("",_(mapPid2Machine(e->pid))); + d_printf(""); + d_printf(""); - printf(""); + d_printf(""); - printf(""); + d_printf("NONE "); + d_printf(""); - printf("\n", + d_printf("\n", fname,tstring(e->time.tv_sec)); } @@ -179,15 +178,15 @@ static int traverse_fn2(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st addPid2Machine (crec.pid, crec.machine); - printf("\n", + d_printf("\n", (int)crec.pid, crec.machine,crec.addr, tstring(crec.start)); if (geteuid() == 0) { - printf("\n", + d_printf("\n", (int)crec.pid); } - printf("\n"); + d_printf("\n"); return 0; } @@ -205,7 +204,7 @@ static int traverse_fn3(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st if (crec.cnum == -1 || !process_exists(crec.pid)) return 0; - printf("\n", + d_printf("\n", crec.name,uidtoname(crec.uid), gidtoname(crec.gid),(int)crec.pid, crec.machine, @@ -270,22 +269,22 @@ void status_page(void) initPid2Machine (); - printf("

%s

\n", _("Server Status")); + d_printf("

%s

\n", _("Server Status")); - printf("\n"); + d_printf("\n"); if (!autorefresh) { - printf("\n", _("Auto Refresh")); - printf("
%s", _("Refresh Interval: ")); - printf("\n", + d_printf("\n", _("Auto Refresh")); + d_printf("
%s", _("Refresh Interval: ")); + d_printf("\n", refresh_interval); } else { - printf("\n", _("Stop Refreshing")); - printf("
%s%d\n", _("Refresh Interval: "), refresh_interval); - printf("\n"); + d_printf("\n", _("Stop Refreshing")); + d_printf("
%s%d\n", _("Refresh Interval: "), refresh_interval); + d_printf("\n"); } - printf("

\n"); + d_printf("

\n"); if (!tdb) { /* open failure either means no connections have been @@ -293,83 +292,83 @@ void status_page(void) } - printf("

PIDSharingR/WOplockFileDate
%s%s%s%s%s%s
%d
%s"); switch ((e->share_mode>>4)&0xF) { case DENY_NONE: printf(_("DENY_NONE")); break; @@ -106,9 +177,11 @@ static int traverse_fn2(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st if (crec.cnum != -1 || !process_exists(crec.pid) || (crec.pid == smbd_pid)) return 0; + addPid2Machine (crec.pid, crec.machine); + printf("
%d%s%s%s
%s"); + d_printf("
%s"); 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; + case DENY_NONE: d_printf("DENY_NONE"); break; + case DENY_ALL: d_printf("DENY_ALL "); break; + case DENY_DOS: d_printf("DENY_DOS "); break; + case DENY_READ: d_printf("DENY_READ "); break; + case DENY_WRITE:d_printf("DENY_WRITE "); break; } - printf(""); + d_printf(""); switch (e->share_mode&0xF) { - case 0: printf(_("RDONLY ")); break; - case 1: printf(_("WRONLY ")); break; - case 2: printf(_("RDWR ")); break; + case 0: d_printf("RDONLY "); break; + case 1: d_printf("WRONLY "); break; + case 2: d_printf("RDWR "); break; } - printf(""); + d_printf(""); if((e->op_type & (EXCLUSIVE_OPLOCK|BATCH_OPLOCK)) == (EXCLUSIVE_OPLOCK|BATCH_OPLOCK)) - printf(_("EXCLUSIVE+BATCH ")); + d_printf("EXCLUSIVE+BATCH "); else if (e->op_type & EXCLUSIVE_OPLOCK) - printf(_("EXCLUSIVE ")); + d_printf("EXCLUSIVE "); else if (e->op_type & BATCH_OPLOCK) - printf(_("BATCH ")); + d_printf("BATCH "); else if (e->op_type & LEVEL_II_OPLOCK) - printf(_("LEVEL_II ")); + d_printf("LEVEL_II "); else - printf(_("NONE ")); - printf("%s%s
%s%s
%d%s%s%s
%d%s%s%s
%s%s%s%d%s%s
%s%s%s%d%s%s
\n"); + d_printf("
\n"); - printf("", _("version:"), VERSION); + d_printf("", _("version:"), VERSION); fflush(stdout); - printf("\n", _("smbd:"), smbd_running()?_("running"):_("not running")); + d_printf("\n", _("smbd:"), smbd_running()?_("running"):_("not running")); if (geteuid() == 0) { if (smbd_running()) { - printf("\n", _("Stop smbd")); + d_printf("\n", _("Stop smbd")); } else { - printf("\n", _("Start smbd")); + d_printf("\n", _("Start smbd")); } - printf("\n", _("Restart smbd")); + d_printf("\n", _("Restart smbd")); } - printf("\n"); + d_printf("\n"); fflush(stdout); - printf("\n", _("nmbd:"), nmbd_running()?_("running"):_("not running")); + d_printf("\n", _("nmbd:"), nmbd_running()?_("running"):_("not running")); if (geteuid() == 0) { if (nmbd_running()) { - printf("\n", _("Stop nmbd")); + d_printf("\n", _("Stop nmbd")); } else { - printf("\n", _("Start nmbd")); + d_printf("\n", _("Start nmbd")); } - printf("\n", _("Restart nmbd")); + d_printf("\n", _("Restart nmbd")); } - printf("\n"); + d_printf("\n"); - printf("
%s%s
%s%s
%s%s
%s%s
%s%s
%s%s
\n"); + d_printf("\n"); fflush(stdout); - printf("

%s

\n", _("Active Connections")); - printf("\n"); - printf("\n", _("PID"), _("Client"), _("IP address"), _("Date")); + d_printf("

%s

\n", _("Active Connections")); + d_printf("
%s%s%s%s
\n"); + d_printf("\n", _("PID"), _("Client"), _("IP address"), _("Date")); if (geteuid() == 0) { - printf("\n", _("Kill")); + d_printf("\n", _("Kill")); } - printf("\n"); + d_printf("\n"); if (tdb) tdb_traverse(tdb, traverse_fn2, NULL); - printf("
%s%s%s%s%s%s

\n"); + d_printf("

\n"); - printf("

%s

\n", _("Active Shares")); - printf("\n"); - printf("\n\n", + d_printf("

%s

\n", _("Active Shares")); + d_printf("
%s%s%s%s%s%s
\n"); + d_printf("\n\n", _("Share"), _("User"), _("Group"), _("PID"), _("Client"), _("Date")); if (tdb) tdb_traverse(tdb, traverse_fn3, NULL); - printf("
%s%s%s%s%s%s

\n"); + d_printf("

\n"); - printf("

%s

\n", _("Open Files")); - printf("\n"); - printf("\n", _("PID"), _("Sharing"), _("R/W"), _("Oplock"), _("File"), _("Date")); + d_printf("

%s

\n", _("Open Files")); + d_printf("
%s%s%s%s%s%s
\n"); + d_printf("\n", _("PID"), _("Sharing"), _("R/W"), _("Oplock"), _("File"), _("Date")); locking_init(1); share_mode_forall(print_share_mode); locking_end(); - printf("
%s%s%s%s%s%s
\n"); + d_printf("\n"); if (tdb) tdb_close(tdb); - printf("
\n"); - printf("\n"); + d_printf("
\n"); + d_printf("\n"); - printf("\n"); + d_printf("\n"); if (autorefresh) { /* this little JavaScript allows for automatic refresh of the page. There are other methods but this seems to be the best alternative */ - printf("\n"); + d_printf("//-->\n\n"); } } -- cgit From cd68afe31256ad60748b34f7318a180cfc2127cc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 30 Jan 2002 06:08:46 +0000 Subject: Removed version number from file header. Changed "SMB/Netbios" to "SMB/CIFS" in file header. (This used to be commit 6a58c9bd06d0d7502a24bf5ce5a2faf0a146edfa) --- source3/web/statuspage.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 6af7674dc9..62158a5f32 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -1,6 +1,5 @@ /* - Unix SMB/Netbios implementation. - Version 2.2. + Unix SMB/CIFS implementation. web status page Copyright (C) Andrew Tridgell 1997-1998 -- cgit From e90b65284812aaa5ff9e9935ce9bbad7791cbbcd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 15 Jul 2002 10:35:28 +0000 Subject: updated the 3.0 branch from the head branch - ready for alpha18 (This used to be commit 03ac082dcb375b6f3ca3d810a6a6367542bc23ce) --- source3/web/statuspage.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 62158a5f32..792e077a61 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -19,6 +19,7 @@ */ #include "includes.h" +#include "../web/swat_proto.h" #define PIDMAP struct PidMap -- cgit From fcbb06414d2c8385ce4e68f23905a528c8fbd4e8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 17 Aug 2002 14:34:48 +0000 Subject: sync 3.0 branch with HEAD (This used to be commit d53d77cc8e21dfbfd376d529661ef299e14e31a0) --- source3/web/statuspage.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 792e077a61..3b597d44c0 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -248,6 +248,20 @@ void status_page(void) stop_nmbd(); } +#ifdef WITH_WINBIND + if (cgi_variable("winbindd_restart")) { + stop_winbindd(); + start_winbindd(); + } + + if (cgi_variable("winbindd_start")) { + start_winbindd(); + } + + if (cgi_variable("winbindd_stop")) { + stop_winbindd(); + } +#endif if (cgi_variable("autorefresh")) { autorefresh = 1; } else if (cgi_variable("norefresh")) { @@ -320,6 +334,20 @@ void status_page(void) } d_printf("\n"); +#ifdef WITH_WINBIND + fflush(stdout); + d_printf("%s%s\n", _("winbindd:"), winbindd_running()?_("running"):_("not running")); + if (geteuid() == 0) { + if (winbindd_running()) { + d_printf("\n", _("Stop winbindd")); + } else { + d_printf("\n", _("Start winbindd")); + } + d_printf("\n", _("Restart winbindd")); + } + d_printf("\n"); +#endif + d_printf("\n"); fflush(stdout); -- cgit From 634c54310c92c48dd4eceec602e230a021bdcfc5 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 3 Jan 2003 08:28:12 +0000 Subject: Merge from HEAD - make Samba compile with -Wwrite-strings without additional warnings. (Adds a lot of const). Andrew Bartlett (This used to be commit 3a7458f9472432ef12c43008414925fd1ce8ea0c) --- source3/web/statuspage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 3b597d44c0..8e41d62cb0 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -216,7 +216,7 @@ static int traverse_fn3(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st /* show the current server status */ void status_page(void) { - char *v; + const char *v; int autorefresh=0; int refresh_interval=30; TDB_CONTEXT *tdb; -- cgit From 9c6e58869f45dd2be0904b9ecf9e757b2b3841d6 Mon Sep 17 00:00:00 2001 From: John Terpstra Date: Tue, 22 Apr 2003 23:19:09 +0000 Subject: Added Stephen Roylance's patch - Adds to Status page, a Start All, Restart All and Stop All deamons button. (This used to be commit 57cfcb3108935f46cb3938b403a3eaba2888fb55) --- source3/web/statuspage.c | 47 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 8e41d62cb0..ddbe658a6c 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -220,45 +220,46 @@ void status_page(void) int autorefresh=0; int refresh_interval=30; TDB_CONTEXT *tdb; + int nr_running=0; smbd_pid = pidfile_pid("smbd"); - if (cgi_variable("smbd_restart")) { + if (cgi_variable("smbd_restart") || cgi_variable("all_restart")) { stop_smbd(); start_smbd(); } - if (cgi_variable("smbd_start")) { + if (cgi_variable("smbd_start") || cgi_variable("all_start")) { start_smbd(); } - if (cgi_variable("smbd_stop")) { + if (cgi_variable("smbd_stop") || cgi_variable("all_stop")) { stop_smbd(); } - if (cgi_variable("nmbd_restart")) { + if (cgi_variable("nmbd_restart") || cgi_variable("all_restart")) { stop_nmbd(); start_nmbd(); } - if (cgi_variable("nmbd_start")) { + if (cgi_variable("nmbd_start") || cgi_variable("all_start")) { start_nmbd(); } - if (cgi_variable("nmbd_stop")) { + if (cgi_variable("nmbd_stop")|| cgi_variable("all_stop")) { stop_nmbd(); } #ifdef WITH_WINBIND - if (cgi_variable("winbindd_restart")) { + if (cgi_variable("winbindd_restart") || cgi_variable("all_restart")) { stop_winbindd(); start_winbindd(); } - if (cgi_variable("winbindd_start")) { + if (cgi_variable("winbindd_start") || cgi_variable("all_start")) { start_winbindd(); } - if (cgi_variable("winbindd_stop")) { + if (cgi_variable("winbindd_stop") || cgi_variable("all_stop")) { stop_winbindd(); } #endif @@ -314,6 +315,7 @@ void status_page(void) d_printf("%s%s\n", _("smbd:"), smbd_running()?_("running"):_("not running")); if (geteuid() == 0) { if (smbd_running()) { + nr_running++; d_printf("\n", _("Stop smbd")); } else { d_printf("\n", _("Start smbd")); @@ -326,11 +328,25 @@ void status_page(void) d_printf("%s%s\n", _("nmbd:"), nmbd_running()?_("running"):_("not running")); if (geteuid() == 0) { if (nmbd_running()) { + nr_running++; d_printf("\n", _("Stop nmbd")); } else { d_printf("\n", _("Start nmbd")); } d_printf("\n", _("Restart nmbd")); +#ifndef WITH_WINBIND + if (nr_running >= 1) { + /* stop, restart all */ + d_printf("\n"); + d_printf("\n", _("Stop All")); + d_printf("\n", _("Restart All")); + } + else if (nr_running == 0) { + /* start all */ + d_printf("\n"); + d_printf("\n", _("Start All")); + } +#endif } d_printf("\n"); @@ -339,11 +355,24 @@ void status_page(void) d_printf("%s%s\n", _("winbindd:"), winbindd_running()?_("running"):_("not running")); if (geteuid() == 0) { if (winbindd_running()) { + nr_running++; d_printf("\n", _("Stop winbindd")); } else { d_printf("\n", _("Start winbindd")); } d_printf("\n", _("Restart winbindd")); + if (nr_running >= 1) { + /* stop, restart all */ + d_printf("\n"); + d_printf("\n", _("Stop All")); + d_printf("\n", _("Restart All")); + } + else if (nr_running == 0) { + /* start all */ + d_printf("\n"); + d_printf("\n", _("Start All")); + } + } d_printf("\n"); #endif -- cgit From 8f6e88dbb6936abdb62a90a6bb0ef947ec8c9bb6 Mon Sep 17 00:00:00 2001 From: John Terpstra Date: Thu, 24 Apr 2003 02:35:00 +0000 Subject: Added patch from Stephen Roylance. (This used to be commit 71369f90890eeca399fec55d978a5dd4a13f077f) --- source3/web/statuspage.c | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index ddbe658a6c..44461232b8 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -23,6 +23,9 @@ #define PIDMAP struct PidMap +/* how long to wait for start/stops to take effect */ +#define SLEEP_TIME 3 + PIDMAP { PIDMAP *next, *prev; pid_t pid; @@ -158,6 +161,7 @@ static int traverse_fn1(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st slprintf(buf,sizeof(buf)-1,"kill_%d", (int)crec.pid); if (cgi_variable(buf)) { kill_pid(crec.pid); + sleep(SLEEP_TIME); } } return 0; @@ -221,48 +225,62 @@ void status_page(void) int refresh_interval=30; TDB_CONTEXT *tdb; int nr_running=0; + BOOL waitup = False; smbd_pid = pidfile_pid("smbd"); if (cgi_variable("smbd_restart") || cgi_variable("all_restart")) { stop_smbd(); start_smbd(); + waitup=True; } if (cgi_variable("smbd_start") || cgi_variable("all_start")) { start_smbd(); + waitup=True; } if (cgi_variable("smbd_stop") || cgi_variable("all_stop")) { stop_smbd(); + waitup=True; } if (cgi_variable("nmbd_restart") || cgi_variable("all_restart")) { stop_nmbd(); start_nmbd(); + waitup=True; } if (cgi_variable("nmbd_start") || cgi_variable("all_start")) { start_nmbd(); + waitup=True; } if (cgi_variable("nmbd_stop")|| cgi_variable("all_stop")) { stop_nmbd(); + waitup=True; } #ifdef WITH_WINBIND if (cgi_variable("winbindd_restart") || cgi_variable("all_restart")) { stop_winbindd(); start_winbindd(); + waitup=True; } if (cgi_variable("winbindd_start") || cgi_variable("all_start")) { start_winbindd(); + waitup=True; } if (cgi_variable("winbindd_stop") || cgi_variable("all_stop")) { stop_winbindd(); + waitup=True; } #endif + /* wait for daemons to start/stop */ + if (waitup) + sleep(SLEEP_TIME); + if (cgi_variable("autorefresh")) { autorefresh = 1; } else if (cgi_variable("norefresh")) { @@ -333,20 +351,7 @@ void status_page(void) } else { d_printf("\n", _("Start nmbd")); } - d_printf("\n", _("Restart nmbd")); -#ifndef WITH_WINBIND - if (nr_running >= 1) { - /* stop, restart all */ - d_printf("\n"); - d_printf("\n", _("Stop All")); - d_printf("\n", _("Restart All")); - } - else if (nr_running == 0) { - /* start all */ - d_printf("\n"); - d_printf("\n", _("Start All")); - } -#endif + d_printf("\n", _("Restart nmbd")); } d_printf("\n"); @@ -361,22 +366,23 @@ void status_page(void) d_printf("\n", _("Start winbindd")); } d_printf("\n", _("Restart winbindd")); + } + d_printf("\n"); +#endif + + if (geteuid() == 0) { + d_printf("\n"); if (nr_running >= 1) { /* stop, restart all */ - d_printf("\n"); d_printf("\n", _("Stop All")); d_printf("\n", _("Restart All")); } else if (nr_running == 0) { /* start all */ - d_printf("\n"); d_printf("\n", _("Start All")); } - + d_printf("\n"); } - d_printf("\n"); -#endif - d_printf("\n"); fflush(stdout); -- cgit From 80c1f1d865b13a63c7a60876b63458119566e044 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 22 Jul 2003 04:31:20 +0000 Subject: Fixup a bunch of printf-style functions and debugs to use unsigned long when displaying pid_t, uid_t and gid_t values. This removes a whole lot of warnings on some of the 64-bit build farm machines as well as help us out when 64-bit uid/gid/pid values come along. (This used to be commit f93528ba007c8800a850678f35f499fb7360fb9a) --- source3/web/statuspage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 44461232b8..c579e8f112 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -93,7 +93,7 @@ static char *mapPid2Machine (pid_t pid) } /* PID not in list or machine name NULL? return pid as string */ - snprintf (pidbuf, sizeof (pidbuf) - 1, "%d", pid); + snprintf (pidbuf, sizeof (pidbuf) - 1, "%lu", (unsigned long)pid); return pidbuf; } -- cgit From 8bfe26b62db2e671b143d93a5428f8fb64a9df05 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 20 Aug 2003 17:13:38 +0000 Subject: metze's autogenerate patch for version.h (This used to be commit ae452e51b02672a56adf18aa7a7e365eeaba9272) --- source3/web/statuspage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index c579e8f112..21d7e45738 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -327,7 +327,7 @@ void status_page(void) d_printf("\n"); - d_printf("", _("version:"), VERSION); + d_printf("", _("version:"), SAMBA_VERSION_STRING); fflush(stdout); d_printf("\n", _("smbd:"), smbd_running()?_("running"):_("not running")); -- cgit From 635dff752869d8284386d9c4b84a87840868ecd6 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 3 Oct 2003 01:42:53 +0000 Subject: Moving towards better i18n support in SWAT. This commit contains a bunch of updates to bug 413 from Monyo: 1) pick up proper strings to call msg strings for example to add strings in wizard menu in web/swat.c, web/statuspage.c and param/loadparm.c. 2) define N_() macro in include/intl.h to pick up some strings in param/loadparm.c 3) quote all name and value tag with '"' For example in swat.c:720 the "Edit Parameter Values" string is displayd only as "Edit" because value tag is not quoted like: value=Edit Parameter Values These tags should be quoted though it sometimes works well without quotation. 4) modify the msg strings not to contain HTML tags or other non-message strings. For example dprintf(_("test\n")); is modified to dprintf("%s\n", _("test")); (This used to be commit 351d16956d8125bc689ca84adcb71e0a57d6b7cc) --- source3/web/statuspage.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 21d7e45738..9ce9c05b19 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -120,9 +120,9 @@ static void print_share_mode(share_mode_entry *e, char *fname) d_printf(""); @@ -297,6 +297,10 @@ void status_page(void) PID_or_Machine = 1; } + if (cgi_variable("show_pid_in_col_1")) { + PID_or_Machine = 0; + } + tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_DEFAULT, O_RDONLY, 0); if (tdb) tdb_traverse(tdb, traverse_fn1, NULL); @@ -307,14 +311,14 @@ void status_page(void) d_printf("\n"); if (!autorefresh) { - d_printf("\n", _("Auto Refresh")); + d_printf("\n", _("Auto Refresh")); d_printf("
%s", _("Refresh Interval: ")); - d_printf("\n", + d_printf("\n", refresh_interval); } else { - d_printf("\n", _("Stop Refreshing")); + d_printf("\n", _("Stop Refreshing")); d_printf("
%s%d\n", _("Refresh Interval: "), refresh_interval); - d_printf("\n"); + d_printf("\n"); } d_printf("

\n"); @@ -418,8 +422,8 @@ void status_page(void) if (tdb) tdb_close(tdb); - d_printf("
\n"); - d_printf("\n"); + d_printf("
\n", _("Show Client in col 1")); + d_printf("\n", _("Show PID in col 1")); d_printf("\n"); -- cgit From 474758956cd73be0b5eea1070f9259608c12a4e6 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 5 Mar 2004 18:37:01 +0000 Subject: BUG 488: fix the 'show client in col 1' button and corrctely enumerate active connections (This used to be commit d77d38560d1bdc10a58408f449fbc320275bcacc) --- source3/web/statuspage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 9ce9c05b19..3d70796830 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -177,7 +177,7 @@ static int traverse_fn2(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st memcpy(&crec, dbuf.dptr, sizeof(crec)); - if (crec.cnum != -1 || !process_exists(crec.pid) || (crec.pid == smbd_pid)) + if (crec.cnum == -1 || !process_exists(crec.pid) || (crec.pid == smbd_pid)) return 0; addPid2Machine (crec.pid, crec.machine); -- cgit From b2dc329d437603e525609b101ecced7f0c5b19cd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 1 Oct 2004 22:24:44 +0000 Subject: r2771: Second (and last) part of Swat-i18n-Patch from Björn Jacke MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "Do not use display charset for swat output. In HTML we do not care about the "locale charmap" because HTML code is UTF-8 only now. Additionally take care that we convert files from statuspage from unix charset to UTF-8. Thus we have correct HTML output under all circumstances. We now also convert the share names correctly from unix encoding to web encoding and vice vera. " Guenther (This used to be commit 6d9f77c2bb95db4939b8ef375e22b188168b70ab) --- source3/web/statuspage.c | 160 ++++++++++++++++++++++++----------------------- 1 file changed, 82 insertions(+), 78 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 3d70796830..2c645de248 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -107,42 +107,46 @@ static char *tstring(time_t t) static void print_share_mode(share_mode_entry *e, char *fname) { - d_printf("

",_(mapPid2Machine(e->pid))); - d_printf("",_(mapPid2Machine(e->pid))); + printf(""); + printf(""); - d_printf(""); + printf(""); - d_printf(""); + printf("NONE "); + printf(""); - d_printf("\n", - fname,tstring(e->time.tv_sec)); + push_utf8_allocate(&utf8_fname, fname); + printf("\n", + utf8_fname,tstring(e->time.tv_sec)); + SAFE_FREE(utf8_fname); } @@ -182,15 +186,15 @@ static int traverse_fn2(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st addPid2Machine (crec.pid, crec.machine); - d_printf("\n", + printf("\n", (int)crec.pid, crec.machine,crec.addr, tstring(crec.start)); if (geteuid() == 0) { - d_printf("\n", + printf("\n", (int)crec.pid); } - d_printf("\n"); + printf("\n"); return 0; } @@ -208,7 +212,7 @@ static int traverse_fn3(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st if (crec.cnum == -1 || !process_exists(crec.pid)) return 0; - d_printf("\n", + printf("\n", crec.name,uidtoname(crec.uid), gidtoname(crec.gid),(int)crec.pid, crec.machine, @@ -306,22 +310,22 @@ void status_page(void) initPid2Machine (); - d_printf("

%s

\n", _("Server Status")); + printf("

%s

\n", _("Server Status")); - d_printf("\n"); + printf("\n"); if (!autorefresh) { - d_printf("\n", _("Auto Refresh")); - d_printf("
%s", _("Refresh Interval: ")); - d_printf("\n", + printf("\n", _("Auto Refresh")); + printf("
%s", _("Refresh Interval: ")); + printf("\n", refresh_interval); } else { - d_printf("\n", _("Stop Refreshing")); - d_printf("
%s%d\n", _("Refresh Interval: "), refresh_interval); - d_printf("\n"); + printf("\n", _("Stop Refreshing")); + printf("
%s%d\n", _("Refresh Interval: "), refresh_interval); + printf("\n"); } - d_printf("

\n"); + printf("

\n"); if (!tdb) { /* open failure either means no connections have been @@ -329,113 +333,113 @@ void status_page(void) } - d_printf("

%s%s
%s%s
%s%s"); switch (e->share_mode&0xF) { - case 0: d_printf("RDONLY "); break; - case 1: d_printf("WRONLY "); break; - case 2: d_printf("RDWR "); break; + case 0: d_printf("%s", _("RDONLY ")); break; + case 1: d_printf("%s", _("WRONLY ")); break; + case 2: d_printf("%s", _("RDWR ")); break; } d_printf("
%s"); + char *utf8_fname; + + printf("
%s"); switch ((e->share_mode>>4)&0xF) { - case DENY_NONE: d_printf("DENY_NONE"); break; - case DENY_ALL: d_printf("DENY_ALL "); break; - case DENY_DOS: d_printf("DENY_DOS "); break; - case DENY_READ: d_printf("DENY_READ "); break; - case DENY_WRITE:d_printf("DENY_WRITE "); break; + 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; } - d_printf(""); + printf(""); switch (e->share_mode&0xF) { - case 0: d_printf("%s", _("RDONLY ")); break; - case 1: d_printf("%s", _("WRONLY ")); break; - case 2: d_printf("%s", _("RDWR ")); break; + case 0: printf("%s", _("RDONLY ")); break; + case 1: printf("%s", _("WRONLY ")); break; + case 2: printf("%s", _("RDWR ")); break; } - d_printf(""); + printf(""); if((e->op_type & (EXCLUSIVE_OPLOCK|BATCH_OPLOCK)) == (EXCLUSIVE_OPLOCK|BATCH_OPLOCK)) - d_printf("EXCLUSIVE+BATCH "); + printf("EXCLUSIVE+BATCH "); else if (e->op_type & EXCLUSIVE_OPLOCK) - d_printf("EXCLUSIVE "); + printf("EXCLUSIVE "); else if (e->op_type & BATCH_OPLOCK) - d_printf("BATCH "); + printf("BATCH "); else if (e->op_type & LEVEL_II_OPLOCK) - d_printf("LEVEL_II "); + printf("LEVEL_II "); else - d_printf("NONE "); - d_printf("%s%s
%s%s
%d%s%s%s
%d%s%s%s
%s%s%s%d%s%s
%s%s%s%d%s%s
\n"); + printf("
\n"); - d_printf("", _("version:"), SAMBA_VERSION_STRING); + printf("", _("version:"), SAMBA_VERSION_STRING); fflush(stdout); - d_printf("\n", _("smbd:"), smbd_running()?_("running"):_("not running")); + printf("\n", _("smbd:"), smbd_running()?_("running"):_("not running")); if (geteuid() == 0) { if (smbd_running()) { nr_running++; - d_printf("\n", _("Stop smbd")); + printf("\n", _("Stop smbd")); } else { - d_printf("\n", _("Start smbd")); + printf("\n", _("Start smbd")); } - d_printf("\n", _("Restart smbd")); + printf("\n", _("Restart smbd")); } - d_printf("\n"); + printf("\n"); fflush(stdout); - d_printf("\n", _("nmbd:"), nmbd_running()?_("running"):_("not running")); + printf("\n", _("nmbd:"), nmbd_running()?_("running"):_("not running")); if (geteuid() == 0) { if (nmbd_running()) { nr_running++; - d_printf("\n", _("Stop nmbd")); + printf("\n", _("Stop nmbd")); } else { - d_printf("\n", _("Start nmbd")); + printf("\n", _("Start nmbd")); } - d_printf("\n", _("Restart nmbd")); + printf("\n", _("Restart nmbd")); } - d_printf("\n"); + printf("\n"); #ifdef WITH_WINBIND fflush(stdout); - d_printf("\n", _("winbindd:"), winbindd_running()?_("running"):_("not running")); + printf("\n", _("winbindd:"), winbindd_running()?_("running"):_("not running")); if (geteuid() == 0) { if (winbindd_running()) { nr_running++; - d_printf("\n", _("Stop winbindd")); + printf("\n", _("Stop winbindd")); } else { - d_printf("\n", _("Start winbindd")); + printf("\n", _("Start winbindd")); } - d_printf("\n", _("Restart winbindd")); + printf("\n", _("Restart winbindd")); } - d_printf("\n"); + printf("\n"); #endif if (geteuid() == 0) { - d_printf("\n"); + printf("\n"); if (nr_running >= 1) { /* stop, restart all */ - d_printf("\n", _("Stop All")); - d_printf("\n", _("Restart All")); + printf("\n", _("Stop All")); + printf("\n", _("Restart All")); } else if (nr_running == 0) { /* start all */ - d_printf("\n", _("Start All")); + printf("\n", _("Start All")); } - d_printf("\n"); + printf("\n"); } - d_printf("
%s%s
%s%s
%s%s
%s%s
%s%s
%s%s
%s%s
%s%s
\n"); + printf("\n"); fflush(stdout); - d_printf("

%s

\n", _("Active Connections")); - d_printf("\n"); - d_printf("\n", _("PID"), _("Client"), _("IP address"), _("Date")); + printf("

%s

\n", _("Active Connections")); + printf("
%s%s%s%s
\n"); + printf("\n", _("PID"), _("Client"), _("IP address"), _("Date")); if (geteuid() == 0) { - d_printf("\n", _("Kill")); + printf("\n", _("Kill")); } - d_printf("\n"); + printf("\n"); if (tdb) tdb_traverse(tdb, traverse_fn2, NULL); - d_printf("
%s%s%s%s%s%s

\n"); + printf("

\n"); - d_printf("

%s

\n", _("Active Shares")); - d_printf("\n"); - d_printf("\n\n", + printf("

%s

\n", _("Active Shares")); + printf("
%s%s%s%s%s%s
\n"); + printf("\n\n", _("Share"), _("User"), _("Group"), _("PID"), _("Client"), _("Date")); if (tdb) tdb_traverse(tdb, traverse_fn3, NULL); - d_printf("
%s%s%s%s%s%s

\n"); + printf("

\n"); - d_printf("

%s

\n", _("Open Files")); - d_printf("\n"); - d_printf("\n", _("PID"), _("Sharing"), _("R/W"), _("Oplock"), _("File"), _("Date")); + printf("

%s

\n", _("Open Files")); + printf("
%s%s%s%s%s%s
\n"); + printf("\n", _("PID"), _("Sharing"), _("R/W"), _("Oplock"), _("File"), _("Date")); locking_init(1); share_mode_forall(print_share_mode); locking_end(); - d_printf("
%s%s%s%s%s%s
\n"); + printf("\n"); if (tdb) tdb_close(tdb); - d_printf("
\n", _("Show Client in col 1")); - d_printf("\n", _("Show PID in col 1")); + printf("
\n", _("Show Client in col 1")); + printf("\n", _("Show PID in col 1")); - d_printf("\n"); + printf("\n"); if (autorefresh) { /* this little JavaScript allows for automatic refresh of the page. There are other methods but this seems to be the best alternative */ - d_printf("\n"); + printf("//-->\n\n"); } } -- cgit From b4cf9e95059071df49b34ff8574e48cb96f42da1 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 7 Oct 2004 04:01:18 +0000 Subject: r2835: Since we always have -I. and -I$(srcdir) in CFLAGS, we can get rid of '..' from all #include preprocessor commands. This fixes bugzilla #1880 where OpenVMS gets confused about the '.' characters. (This used to be commit 7f161702fa4916979602cc0295919b541912acd6) --- source3/web/statuspage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 2c645de248..953222c2fc 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -19,7 +19,7 @@ */ #include "includes.h" -#include "../web/swat_proto.h" +#include "web/swat_proto.h" #define PIDMAP struct PidMap -- cgit From acf9d61421faa6c0055d57fdee7db300dc5431aa Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 7 Dec 2004 18:25:53 +0000 Subject: r4088: Get medieval on our ass about malloc.... :-). Take control of all our allocation functions so we can funnel through some well known functions. Should help greatly with malloc checking. HEAD patch to follow. Jeremy. (This used to be commit 620f2e608f70ba92f032720c031283d295c5c06a) --- source3/web/statuspage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 953222c2fc..57b5d0f7b7 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -61,14 +61,14 @@ static void addPid2Machine (pid_t pid, char *machine) if (PID_or_Machine) { PIDMAP *newmap; - if ((newmap = (PIDMAP *) malloc (sizeof (PIDMAP))) == NULL) { + if ((newmap = SMB_MALLOC_P(PIDMAP)) == NULL) { /* XXX need error message for this? if malloc fails, PID is always shown */ return; } newmap->pid = pid; - newmap->machine = strdup (machine); + newmap->machine = SMB_STRDUP(machine); DLIST_ADD(pidmap, newmap); } -- cgit From af8a691db11a5072865f8b03fd1cbd3aab5cb6d7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 8 Jul 2005 04:51:27 +0000 Subject: r8219: Merge the new open code from HEAD to 3.0. Haven't yet run the torture tests on this as it's very late NY time (just wanted to get this work into the tree). I'll test this over the weekend.... Jerry - in looking at the difference between the two trees there seem to be some printing/ntprinting.c and registry changes we might want to examine to try keep in sync. Jeremy. (This used to be commit c7fe18761e2c753afbffd3a78abff46472a9b8eb) --- source3/web/statuspage.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 57b5d0f7b7..871e07b5d0 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -108,23 +108,28 @@ static char *tstring(time_t t) static void print_share_mode(share_mode_entry *e, char *fname) { char *utf8_fname; + int deny_mode = map_share_mode_to_deny_mode(e->share_access, + e->private_options); printf("%s",_(mapPid2Machine(e->pid))); printf(""); - switch ((e->share_mode>>4)&0xF) { + switch ((deny_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_FCB: printf("DENY_FCB "); 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("%s", _("RDONLY ")); break; - case 1: printf("%s", _("WRONLY ")); break; - case 2: printf("%s", _("RDWR ")); break; + 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 ")); } printf(""); -- cgit From 54abd2aa66069e6baf7769c496f46d9dba18db39 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 30 Sep 2005 17:13:37 +0000 Subject: r10656: BIG merge from trunk. Features not copied over * \PIPE\unixinfo * winbindd's {group,alias}membership new functions * winbindd's lookupsids() functionality * swat (trunk changes to be reverted as per discussion with Deryck) (This used to be commit 939c3cb5d78e3a2236209b296aa8aba8bdce32d3) --- source3/web/statuspage.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 871e07b5d0..edc0318373 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -28,14 +28,14 @@ PIDMAP { PIDMAP *next, *prev; - pid_t pid; + struct process_id pid; char *machine; }; static PIDMAP *pidmap; static int PID_or_Machine; /* 0 = show PID, else show Machine name */ -static pid_t smbd_pid; +static struct process_id smbd_pid; /* from 2nd call on, remove old list */ static void initPid2Machine (void) @@ -55,7 +55,7 @@ static void initPid2Machine (void) } /* add new PID <-> Machine name mapping */ -static void addPid2Machine (pid_t pid, char *machine) +static void addPid2Machine (struct process_id pid, char *machine) { /* show machine name rather PID on table "Open Files"? */ if (PID_or_Machine) { @@ -75,7 +75,7 @@ static void addPid2Machine (pid_t pid, char *machine) } /* lookup PID <-> Machine name mapping */ -static char *mapPid2Machine (pid_t pid) +static char *mapPid2Machine (struct process_id pid) { static char pidbuf [64]; PIDMAP *map; @@ -83,7 +83,7 @@ static char *mapPid2Machine (pid_t pid) /* show machine name rather PID on table "Open Files"? */ if (PID_or_Machine) { for (map = pidmap; map != NULL; map = map->next) { - if (pid == map->pid) { + if (procid_equal(&pid, &map->pid)) { if (map->machine == NULL) /* no machine name */ break; /* show PID */ @@ -93,7 +93,8 @@ static char *mapPid2Machine (pid_t pid) } /* PID not in list or machine name NULL? return pid as string */ - snprintf (pidbuf, sizeof (pidbuf) - 1, "%lu", (unsigned long)pid); + snprintf (pidbuf, sizeof (pidbuf) - 1, "%s", + procid_str_static(&pid)); return pidbuf; } @@ -105,7 +106,7 @@ static char *tstring(time_t t) return buf; } -static void print_share_mode(share_mode_entry *e, char *fname) +static void print_share_mode(const struct share_mode_entry *e, char *fname) { char *utf8_fname; int deny_mode = map_share_mode_to_deny_mode(e->share_access, @@ -167,7 +168,7 @@ static int traverse_fn1(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st if (crec.cnum == -1 && process_exists(crec.pid)) { char buf[30]; - slprintf(buf,sizeof(buf)-1,"kill_%d", (int)crec.pid); + slprintf(buf,sizeof(buf)-1,"kill_%s", procid_str_static(&crec.pid)); if (cgi_variable(buf)) { kill_pid(crec.pid); sleep(SLEEP_TIME); @@ -186,18 +187,19 @@ static int traverse_fn2(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st memcpy(&crec, dbuf.dptr, sizeof(crec)); - if (crec.cnum == -1 || !process_exists(crec.pid) || (crec.pid == smbd_pid)) + if (crec.cnum == -1 || !process_exists(crec.pid) || + procid_equal(&crec.pid, &smbd_pid)) return 0; addPid2Machine (crec.pid, crec.machine); - printf("%d%s%s%s\n", - (int)crec.pid, + printf("%s%s%s%s\n", + procid_str_static(&crec.pid), crec.machine,crec.addr, tstring(crec.start)); if (geteuid() == 0) { - printf("\n", - (int)crec.pid); + printf("\n", + procid_str_static(&crec.pid)); } printf("\n"); @@ -217,9 +219,9 @@ static int traverse_fn3(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st if (crec.cnum == -1 || !process_exists(crec.pid)) return 0; - printf("%s%s%s%d%s%s\n", + printf("%s%s%s%s%s%s\n", crec.name,uidtoname(crec.uid), - gidtoname(crec.gid),(int)crec.pid, + gidtoname(crec.gid),procid_str_static(&crec.pid), crec.machine, tstring(crec.start)); return 0; @@ -236,7 +238,7 @@ void status_page(void) int nr_running=0; BOOL waitup = False; - smbd_pid = pidfile_pid("smbd"); + smbd_pid = pid_to_procid(pidfile_pid("smbd")); if (cgi_variable("smbd_restart") || cgi_variable("all_restart")) { stop_smbd(); -- cgit From 6d5757395a0e54245543794d0d6d6d6a32cd857a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 5 Nov 2005 04:21:55 +0000 Subject: r11511: A classic "friday night check-in" :-). This moves much of the Samba4 timezone handling code back into Samba3. Gets rid of "kludge-gmt" and removes the effectiveness of the parameter "time offset" (I can add this back in very easily if needed) - it's no longer being looked at. I'm hoping this will fix the problems people have been having with DST transitions. I'll start comprehensive testing tomorrow, but for now all modifications are done. Splits time get/set functions into srv_XXX and cli_XXX as they need to look at different timezone offsets. Get rid of much of the "efficiency" cruft that was added to Samba back in the day when the C library timezone handling functions were slow. Jeremy. (This used to be commit 414303bc0272f207046b471a0364fa296b67c1f8) --- source3/web/statuspage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index edc0318373..6447f95bac 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -101,7 +101,7 @@ static char *mapPid2Machine (struct process_id pid) static char *tstring(time_t t) { static pstring buf; - pstrcpy(buf, asctime(LocalTime(&t))); + pstrcpy(buf, asctime(localtime(&t))); all_string_sub(buf," "," ",sizeof(buf)); return buf; } -- cgit From 7d2771e758d4e8ef0adb45e55775b524de4dba9a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 12 Dec 2005 22:07:36 +0000 Subject: r12203: Add the share path into the sharemode db. This involves revving the minor version number for libsmbsharemodes (we now have a new _ex interface that takes the share path as well as the filename). Needed for #3303. Some code written by SATOH Fumiyasu included in the changes to locking/locking.c. The smbstatus output is a bit of a mess and needs overhauling... Jeremy. (This used to be commit 9d93af713f8520ca506730dd32aa2b994937eaba) --- source3/web/statuspage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 6447f95bac..24d7eaf72e 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -106,7 +106,7 @@ static char *tstring(time_t t) return buf; } -static void print_share_mode(const struct share_mode_entry *e, char *fname) +static void print_share_mode(const struct share_mode_entry *e, const char *sharepath, const char *fname) { char *utf8_fname; int deny_mode = map_share_mode_to_deny_mode(e->share_access, -- cgit From 0e551cd5a2f468ad297f1bfbccbc9f91579dc794 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 31 Jan 2006 21:54:24 +0000 Subject: r13262: Arrgggg. Fix smbstatus and swat status to ignore bloody placeholder share mode entries (I hate these - I've had to add this filter code now to too many places :-). Jeremy. (This used to be commit 815340e1a413f98c1c36aacc1c34041e9160d0e3) --- source3/web/statuspage.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 24d7eaf72e..7430f4ebf5 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -109,7 +109,13 @@ static char *tstring(time_t t) static void print_share_mode(const struct share_mode_entry *e, const char *sharepath, const char *fname) { char *utf8_fname; - int deny_mode = map_share_mode_to_deny_mode(e->share_access, + int deny_mode; + + if (!is_valid_share_mode_entry(e)) { + return; + } + + deny_mode = map_share_mode_to_deny_mode(e->share_access, e->private_options); printf("%s",_(mapPid2Machine(e->pid))); -- cgit From a1e0a0e9286fbe90ca04cda9df38e72d8d18b0c1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 14 Jun 2006 21:36:49 +0000 Subject: r16230: Fix Klocwork #861 and others. localtime and asctime can return NULL. Ensure we check all returns correctly. Jeremy. (This used to be commit 6c61dc8ed6d84f310ef391fb7700e93ef42c4afc) --- source3/web/statuspage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 7430f4ebf5..769ab217b3 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -101,7 +101,7 @@ static char *mapPid2Machine (struct process_id pid) static char *tstring(time_t t) { static pstring buf; - pstrcpy(buf, asctime(localtime(&t))); + pstrcpy(buf, time_to_asc(&t)); all_string_sub(buf," "," ",sizeof(buf)); return buf; } -- cgit From 54ea3c23e3bfd25008198e85fdcc1f48b0325eab Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 21 Jun 2006 02:31:12 +0000 Subject: r16435: Add in the uid info that Jerry needs into the share_mode struct. Allows us to know the unix uid of the opener of the file/directory. Needed for info level queries on open files. Jeremy. (This used to be commit d929323d6f513902381369d77bcd7b714346d713) --- source3/web/statuspage.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 769ab217b3..cb6fa91171 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -119,6 +119,7 @@ static void print_share_mode(const struct share_mode_entry *e, const char *share e->private_options); printf("%s",_(mapPid2Machine(e->pid))); + printf("%u",(unsigned int)e->uid); printf(""); switch ((deny_mode>>4)&0xF) { case DENY_NONE: printf("DENY_NONE"); break; -- cgit From e0c68d0a1d591e4285746a8af70040448752a735 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 21 Jul 2006 14:13:30 +0000 Subject: r17177: Get rid of a global variable by adding a private data pointer to share_mode_forall(). Volker (This used to be commit f97f6cedffdc4d10afcac90a163b93a801acf514) --- source3/web/statuspage.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index cb6fa91171..459b679d81 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -106,7 +106,10 @@ static char *tstring(time_t t) return buf; } -static void print_share_mode(const struct share_mode_entry *e, const char *sharepath, const char *fname) +static void print_share_mode(const struct share_mode_entry *e, + const char *sharepath, + const char *fname, + void *dummy) { char *utf8_fname; int deny_mode; @@ -434,7 +437,7 @@ void status_page(void) printf("%s%s%s%s%s%s\n", _("PID"), _("Sharing"), _("R/W"), _("Oplock"), _("File"), _("Date")); locking_init(1); - share_mode_forall(print_share_mode); + share_mode_forall(print_share_mode, NULL); locking_end(); printf("\n"); -- cgit From 4952fe368a40b239140b3035db6075427d237bb9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 5 Mar 2007 23:40:03 +0000 Subject: r21714: Change the VFS interface to use struct timespec for utimes - change the call to ntimes. This preserves nsec timestamps we get from stat (if the system supports it) and only maps back down to usec or sec resolution on time set. Looks bigger than it is as I had to move lots of internal code from using time_t and struct utimebuf to struct timespec. Jeremy. (This used to be commit 8f3d530c5a748ea90f42ed8fbe68ae92178d4875) --- source3/web/statuspage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 459b679d81..a88e5debd0 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -101,7 +101,7 @@ static char *mapPid2Machine (struct process_id pid) static char *tstring(time_t t) { static pstring buf; - pstrcpy(buf, time_to_asc(&t)); + pstrcpy(buf, time_to_asc(t)); all_string_sub(buf," "," ",sizeof(buf)); return buf; } -- cgit From b1842fd29432220b99cbaf0ba1a3bc24994c3596 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 16 Apr 2007 20:06:02 +0000 Subject: r22282: Fix last few name -> servicename changes. Jeremy. (This used to be commit f5c22f26f7ec7e8139fbf11a75820336db3d55c0) --- source3/web/statuspage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index a88e5debd0..e4d726c4fd 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -230,7 +230,7 @@ static int traverse_fn3(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st return 0; printf("%s%s%s%s%s%s\n", - crec.name,uidtoname(crec.uid), + crec.servicename,uidtoname(crec.uid), gidtoname(crec.gid),procid_str_static(&crec.pid), crec.machine, tstring(crec.start)); -- cgit From e6383f47629368d9dd4e803f17566a24e9d7359e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 7 May 2007 09:35:35 +0000 Subject: r22736: Start to merge the low-hanging fruit from the now 7000-line cluster patch. This changes "struct process_id" to "struct server_id", keeping both is just too much hassle. No functional change (I hope ;-)) Volker (This used to be commit 0ad4b1226c9d91b72136310d3bbb640d2c5d67b8) --- source3/web/statuspage.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index e4d726c4fd..7b5c528a7d 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -28,14 +28,14 @@ PIDMAP { PIDMAP *next, *prev; - struct process_id pid; + struct server_id pid; char *machine; }; static PIDMAP *pidmap; static int PID_or_Machine; /* 0 = show PID, else show Machine name */ -static struct process_id smbd_pid; +static struct server_id smbd_pid; /* from 2nd call on, remove old list */ static void initPid2Machine (void) @@ -55,7 +55,7 @@ static void initPid2Machine (void) } /* add new PID <-> Machine name mapping */ -static void addPid2Machine (struct process_id pid, char *machine) +static void addPid2Machine (struct server_id pid, char *machine) { /* show machine name rather PID on table "Open Files"? */ if (PID_or_Machine) { @@ -75,7 +75,7 @@ static void addPid2Machine (struct process_id pid, char *machine) } /* lookup PID <-> Machine name mapping */ -static char *mapPid2Machine (struct process_id pid) +static char *mapPid2Machine (struct server_id pid) { static char pidbuf [64]; PIDMAP *map; -- cgit From 4aa44f7475e03dcc596f6a13fffffda7268074a1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 8 May 2007 13:44:36 +0000 Subject: r22761: This introduces lib/conn_tdb.c with two main functions: connections_traverse and connections_forall. This centralizes all the routines that did individual tdb_open("connections.tdb") and direct tdb_traverse. Volker (This used to be commit e43e94cda1ad8876b3cb5d1129080b57fa6ec214) --- source3/web/statuspage.c | 83 ++++++++++++++++++------------------------------ 1 file changed, 31 insertions(+), 52 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 7b5c528a7d..2071561e2e 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -167,20 +167,17 @@ static void print_share_mode(const struct share_mode_entry *e, /* kill off any connections chosen by the user */ -static int traverse_fn1(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* state) +static int traverse_fn1(TDB_CONTEXT *tdb, + const struct connections_key *key, + const struct connections_data *crec, + void* state) { - struct connections_data crec; - - if (dbuf.dsize != sizeof(crec)) - return 0; - - memcpy(&crec, dbuf.dptr, sizeof(crec)); - - if (crec.cnum == -1 && process_exists(crec.pid)) { + if (crec->cnum == -1 && process_exists(crec->pid)) { char buf[30]; - slprintf(buf,sizeof(buf)-1,"kill_%s", procid_str_static(&crec.pid)); + slprintf(buf, sizeof(buf)-1,"kill_%s", + procid_str_static(&crec->pid)); if (cgi_variable(buf)) { - kill_pid(crec.pid); + kill_pid(crec->pid); sleep(SLEEP_TIME); } } @@ -188,28 +185,24 @@ static int traverse_fn1(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st } /* traversal fn for showing machine connections */ -static int traverse_fn2(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* state) +static int traverse_fn2(TDB_CONTEXT *tdb, + const struct connections_key *key, + const struct connections_data *crec, + void* state) { - struct connections_data crec; - - if (dbuf.dsize != sizeof(crec)) - return 0; - - memcpy(&crec, dbuf.dptr, sizeof(crec)); - - if (crec.cnum == -1 || !process_exists(crec.pid) || - procid_equal(&crec.pid, &smbd_pid)) + if (crec->cnum == -1 || !process_exists(crec->pid) || + procid_equal(&crec->pid, &smbd_pid)) return 0; - addPid2Machine (crec.pid, crec.machine); + addPid2Machine (crec->pid, crec->machine); printf("%s%s%s%s\n", - procid_str_static(&crec.pid), - crec.machine,crec.addr, - tstring(crec.start)); + procid_str_static(&crec->pid), + crec->machine, crec->addr, + tstring(crec->start)); if (geteuid() == 0) { printf("\n", - procid_str_static(&crec.pid)); + procid_str_static(&crec->pid)); } printf("\n"); @@ -217,23 +210,19 @@ static int traverse_fn2(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st } /* traversal fn for showing share connections */ -static int traverse_fn3(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* state) +static int traverse_fn3(TDB_CONTEXT *tdb, + const struct connections_key *key, + const struct connections_data *crec, + void* state) { - struct connections_data crec; - - if (dbuf.dsize != sizeof(crec)) - return 0; - - memcpy(&crec, dbuf.dptr, sizeof(crec)); - - if (crec.cnum == -1 || !process_exists(crec.pid)) + if (crec->cnum == -1 || !process_exists(crec->pid)) return 0; printf("%s%s%s%s%s%s\n", - crec.servicename,uidtoname(crec.uid), - gidtoname(crec.gid),procid_str_static(&crec.pid), - crec.machine, - tstring(crec.start)); + crec->servicename, uidtoname(crec->uid), + gidtoname(crec->gid),procid_str_static(&crec->pid), + crec->machine, + tstring(crec->start)); return 0; } @@ -244,7 +233,6 @@ void status_page(void) const char *v; int autorefresh=0; int refresh_interval=30; - TDB_CONTEXT *tdb; int nr_running=0; BOOL waitup = False; @@ -322,8 +310,7 @@ void status_page(void) PID_or_Machine = 0; } - tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_DEFAULT, O_RDONLY, 0); - if (tdb) tdb_traverse(tdb, traverse_fn1, NULL); + connections_forall(traverse_fn1, NULL); initPid2Machine (); @@ -344,12 +331,6 @@ void status_page(void) printf("

\n"); - if (!tdb) { - /* open failure either means no connections have been - made */ - } - - printf("\n"); printf("", _("version:"), SAMBA_VERSION_STRING); @@ -419,7 +400,7 @@ void status_page(void) } printf("\n"); - if (tdb) tdb_traverse(tdb, traverse_fn2, NULL); + connections_forall(traverse_fn2, NULL); printf("
%s%s

\n"); @@ -428,7 +409,7 @@ void status_page(void) printf("%s%s%s%s%s%s\n\n", _("Share"), _("User"), _("Group"), _("PID"), _("Client"), _("Date")); - if (tdb) tdb_traverse(tdb, traverse_fn3, NULL); + connections_forall(traverse_fn3, NULL); printf("

\n"); @@ -441,8 +422,6 @@ void status_page(void) locking_end(); printf("\n"); - if (tdb) tdb_close(tdb); - printf("
\n", _("Show Client in col 1")); printf("\n", _("Show PID in col 1")); -- cgit From 054bf2fc8bd8ac62e16ec04001c0a4a8409d0e1d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 28 May 2007 11:38:42 +0000 Subject: r23171: Convert connections.tdb to dbwrap (This used to be commit 80a1f43825063bbbda896175d99700ede5a4757a) --- source3/web/statuspage.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 2071561e2e..cd7b23d864 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -167,15 +167,14 @@ static void print_share_mode(const struct share_mode_entry *e, /* kill off any connections chosen by the user */ -static int traverse_fn1(TDB_CONTEXT *tdb, +static int traverse_fn1(struct db_record *rec, const struct connections_key *key, const struct connections_data *crec, - void* state) + void *private_data) { if (crec->cnum == -1 && process_exists(crec->pid)) { char buf[30]; - slprintf(buf, sizeof(buf)-1,"kill_%s", - procid_str_static(&crec->pid)); + slprintf(buf,sizeof(buf)-1,"kill_%s", procid_str_static(&crec->pid)); if (cgi_variable(buf)) { kill_pid(crec->pid); sleep(SLEEP_TIME); @@ -185,10 +184,10 @@ static int traverse_fn1(TDB_CONTEXT *tdb, } /* traversal fn for showing machine connections */ -static int traverse_fn2(TDB_CONTEXT *tdb, - const struct connections_key *key, - const struct connections_data *crec, - void* state) +static int traverse_fn2(struct db_record *rec, + const struct connections_key *key, + const struct connections_data *crec, + void *private_data) { if (crec->cnum == -1 || !process_exists(crec->pid) || procid_equal(&crec->pid, &smbd_pid)) @@ -210,10 +209,10 @@ static int traverse_fn2(TDB_CONTEXT *tdb, } /* traversal fn for showing share connections */ -static int traverse_fn3(TDB_CONTEXT *tdb, - const struct connections_key *key, - const struct connections_data *crec, - void* state) +static int traverse_fn3(struct db_record *rec, + const struct connections_key *key, + const struct connections_data *crec, + void *private_data) { if (crec->cnum == -1 || !process_exists(crec->pid)) return 0; -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/web/statuspage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index cd7b23d864..0a909886ce 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -5,7 +5,7 @@ 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 + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/web/statuspage.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 0a909886ce..f4f84cd239 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -14,8 +14,7 @@ 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. + along with this program. If not, see . */ #include "includes.h" -- cgit From 5b9ecb5ae3fbbe10260312608f1a175e683347fe Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 27 Aug 2007 11:41:05 +0000 Subject: r24701: Fix the swat build Swat has not been built by default for a while, so I did not notice that the _ macro is actually used. Re-add the lang_msg_rotate function, this time only to swat so that this is the only binary that has to take the 16k penalty. (This used to be commit 191e1ef840c293f8575cc0a3f3ffba2080431fae) --- source3/web/statuspage.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index f4f84cd239..e90a94d9e7 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -20,6 +20,8 @@ #include "includes.h" #include "web/swat_proto.h" +#define _(x) lang_msg_rotate(x) + #define PIDMAP struct PidMap /* how long to wait for start/stops to take effect */ -- cgit From 24fc1d6dd5fce0fc02813d9bb68c12b7539de413 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 29 Aug 2007 13:52:07 +0000 Subject: r24781: Fix build warning. Guenther (This used to be commit 71307c371fea917b91214df7a24cd91170d40dd9) --- source3/web/statuspage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index e90a94d9e7..a03c7998ed 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -56,7 +56,7 @@ static void initPid2Machine (void) } /* add new PID <-> Machine name mapping */ -static void addPid2Machine (struct server_id pid, char *machine) +static void addPid2Machine (struct server_id pid, const char *machine) { /* show machine name rather PID on table "Open Files"? */ if (PID_or_Machine) { -- cgit From 30191d1a5704ad2b158386b511558972d539ce47 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Oct 2007 17:40:25 -0700 Subject: RIP BOOL. Convert BOOL -> bool. I found a few interesting bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f) --- source3/web/statuspage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index a03c7998ed..b59c5cdf43 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -234,7 +234,7 @@ void status_page(void) int autorefresh=0; int refresh_interval=30; int nr_running=0; - BOOL waitup = False; + bool waitup = False; smbd_pid = pid_to_procid(pidfile_pid("smbd")); -- cgit From 6f46f75dfc2c80b99a6a5fb277bab456a5fd247b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 3 Dec 2007 17:17:05 -0800 Subject: Make strhex_to_str clear on string limits. Remove pstring from web/*.c Jeremy. (This used to be commit f9c8d62389f8cb47837e5360209936176537df13) --- source3/web/statuspage.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index b59c5cdf43..647e4fcb5b 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -20,7 +20,7 @@ #include "includes.h" #include "web/swat_proto.h" -#define _(x) lang_msg_rotate(x) +#define _(x) lang_msg_rotate(talloc_tos(),x) #define PIDMAP struct PidMap @@ -99,11 +99,20 @@ static char *mapPid2Machine (struct server_id pid) return pidbuf; } -static char *tstring(time_t t) +static const char *tstring(TALLOC_CTX *ctx, time_t t) { - static pstring buf; - pstrcpy(buf, time_to_asc(t)); - all_string_sub(buf," "," ",sizeof(buf)); + char *buf; + buf = talloc_strdup(ctx, time_to_asc(t)); + if (!buf) { + return ""; + } + buf = talloc_all_string_sub(ctx, + buf, + " ", + " "); + if (!buf) { + return ""; + } return buf; } @@ -162,7 +171,7 @@ static void print_share_mode(const struct share_mode_entry *e, push_utf8_allocate(&utf8_fname, fname); printf("%s%s\n", - utf8_fname,tstring(e->time.tv_sec)); + utf8_fname,tstring(talloc_tos(),e->time.tv_sec)); SAFE_FREE(utf8_fname); } @@ -199,7 +208,7 @@ static int traverse_fn2(struct db_record *rec, printf("%s%s%s%s\n", procid_str_static(&crec->pid), crec->machine, crec->addr, - tstring(crec->start)); + tstring(talloc_tos(),crec->start)); if (geteuid() == 0) { printf("\n", procid_str_static(&crec->pid)); @@ -222,7 +231,7 @@ static int traverse_fn3(struct db_record *rec, crec->servicename, uidtoname(crec->uid), gidtoname(crec->gid),procid_str_static(&crec->pid), crec->machine, - tstring(crec->start)); + tstring(talloc_tos(),crec->start)); return 0; } @@ -235,6 +244,7 @@ void status_page(void) int refresh_interval=30; int nr_running=0; bool waitup = False; + TALLOC_CTX *ctx = talloc_stackframe(); smbd_pid = pid_to_procid(pidfile_pid("smbd")); @@ -311,7 +321,7 @@ void status_page(void) } connections_forall(traverse_fn1, NULL); - + initPid2Machine (); printf("

%s

\n", _("Server Status")); @@ -438,4 +448,5 @@ void status_page(void) refresh_interval*1000); printf("//-->\n\n"); } + TALLOC_FREE(ctx); } -- cgit From d60fac2a5a789680b6dd9f05ab15a3033ec2887c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 5 Dec 2007 20:53:22 +0100 Subject: Tiny simplifications locking.c:open_read_only was unused don't export the silly boolean flag locking_init(bool read_only) (This used to be commit 2f3c865707010bc7c463a02782dbee3dc2479da1) --- source3/web/statuspage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 647e4fcb5b..eda53b66ab 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -427,7 +427,7 @@ void status_page(void) printf("\n"); printf("\n", _("PID"), _("Sharing"), _("R/W"), _("Oplock"), _("File"), _("Date")); - locking_init(1); + locking_init_readonly(); share_mode_forall(print_share_mode, NULL); locking_end(); printf("
%s%s%s%s%s%s
\n"); -- cgit From fb37f156009611af0dd454a0fb0829a09cd638ac Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Tue, 29 Apr 2008 14:36:24 -0700 Subject: Cleanup size_t return values in callers of convert_string_allocate This patch is the second iteration of an inside-out conversion to cleanup functions in charcnv.c returning size_t == -1 to indicate failure. (This used to be commit 6b189dabc562d86dcaa685419d0cb6ea276f100d) --- source3/web/statuspage.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index eda53b66ab..ce24c7cddd 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -123,6 +123,7 @@ static void print_share_mode(const struct share_mode_entry *e, { char *utf8_fname; int deny_mode; + size_t converted_size; if (!is_valid_share_mode_entry(e)) { return; @@ -169,7 +170,7 @@ static void print_share_mode(const struct share_mode_entry *e, printf("NONE "); printf(""); - push_utf8_allocate(&utf8_fname, fname); + push_utf8_allocate(&utf8_fname, fname, &converted_size); printf("%s%s\n", utf8_fname,tstring(talloc_tos(),e->time.tv_sec)); SAFE_FREE(utf8_fname); -- cgit