X-Git-Url: http://git.samba.org/?a=blobdiff_plain;f=source3%2Fweb%2Fstatuspage.c;h=5314f3343269f5d7bdd4a2f384cf9345245f68dd;hb=aef5fcbfc74ab1e078d7133169215aeef1fab30e;hp=ddbe658a6cb4ba9f03e4d27b2803c50004320b89;hpb=9c6e58869f45dd2be0904b9ecf9e757b2b3841d6;p=samba.git
diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c
index ddbe658a6cb..5314f334326 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,
@@ -14,34 +14,41 @@
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"
-#include "../web/swat_proto.h"
+#include "web/swat_proto.h"
+#include "libcli/security/security.h"
+#include "locking/proto.h"
+
+#define _(x) lang_msg_rotate(talloc_tos(),x)
#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;
+ struct server_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 server_id 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;
+ PIDMAP *p, *next;
- for (p = pidmap; p != NULL; ) {
+ for (p = pidmap; p != NULL; p = next) {
+ next = p->next;
DLIST_REMOVE(pidmap, p);
SAFE_FREE(p->machine);
SAFE_FREE(p);
@@ -52,27 +59,27 @@ static void initPid2Machine (void)
}
/* add new PID <-> Machine name mapping */
-static void addPid2Machine (pid_t 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) {
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);
}
}
/* lookup PID <-> Machine name mapping */
-static char *mapPid2Machine (pid_t pid)
+static char *mapPid2Machine (struct server_id pid)
{
static char pidbuf [64];
PIDMAP *map;
@@ -80,7 +87,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 */
@@ -90,125 +97,145 @@ 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, "%s",
+ procid_str_static(&pid));
return pidbuf;
}
-static char *tstring(time_t t)
+static const char *tstring(TALLOC_CTX *ctx, time_t t)
{
- static pstring buf;
- pstrcpy(buf, asctime(LocalTime(&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;
}
-static void print_share_mode(share_mode_entry *e, char *fname)
+static void print_share_mode(const struct share_mode_entry *e,
+ const char *sharepath,
+ const char *fname,
+ void *dummy)
{
- d_printf("
%s
",_(mapPid2Machine(e->pid)));
- d_printf("
");
- 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;
+ char *utf8_fname;
+ char *utf8_sharepath;
+ int deny_mode;
+ size_t converted_size;
+
+ if (!is_valid_share_mode_entry(e)) {
+ return;
}
- d_printf("
\n", _("Server Status"));
- 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");
}
+ TALLOC_FREE(ctx);
}