[1] | 1 | /* SAMHAIN file system integrity testing */
|
---|
| 2 | /* Copyright (C) 1999, 2000 Rainer Wichmann */
|
---|
| 3 | /* */
|
---|
| 4 | /* This program is free software; you can redistribute it */
|
---|
| 5 | /* and/or modify */
|
---|
| 6 | /* it under the terms of the GNU General Public License as */
|
---|
| 7 | /* published by */
|
---|
| 8 | /* the Free Software Foundation; either version 2 of the License, or */
|
---|
| 9 | /* (at your option) any later version. */
|
---|
| 10 | /* */
|
---|
| 11 | /* This program is distributed in the hope that it will be useful, */
|
---|
| 12 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
---|
| 13 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
---|
| 14 | /* GNU General Public License for more details. */
|
---|
| 15 | /* */
|
---|
| 16 | /* You should have received a copy of the GNU General Public License */
|
---|
| 17 | /* along with this program; if not, write to the Free Software */
|
---|
| 18 | /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
---|
| 19 |
|
---|
| 20 | #include "config_xor.h"
|
---|
| 21 |
|
---|
| 22 | #include <string.h>
|
---|
| 23 | #include <stdio.h>
|
---|
| 24 | #include <stdlib.h>
|
---|
| 25 |
|
---|
| 26 | #if HAVE_SYS_TIME_H
|
---|
| 27 | #include <sys/time.h>
|
---|
[583] | 28 | #endif
|
---|
[1] | 29 | #include <time.h>
|
---|
[583] | 30 |
|
---|
[131] | 31 | #include <unistd.h>
|
---|
[1] | 32 |
|
---|
| 33 |
|
---|
| 34 | #ifdef SH_WITH_SERVER
|
---|
| 35 |
|
---|
| 36 |
|
---|
| 37 | #include "samhain.h"
|
---|
[481] | 38 | #include "sh_xfer.h"
|
---|
[1] | 39 | #include "sh_error.h"
|
---|
| 40 | #include "sh_unix.h"
|
---|
| 41 | #include "sh_utils.h"
|
---|
| 42 | #include "sh_html.h"
|
---|
| 43 |
|
---|
| 44 | #undef FIL__
|
---|
| 45 | #define FIL__ _("sh_html.c")
|
---|
| 46 |
|
---|
| 47 |
|
---|
| 48 | s_stat server_status;
|
---|
| 49 |
|
---|
| 50 |
|
---|
| 51 |
|
---|
| 52 | static
|
---|
| 53 | char * replace_stat (char * line)
|
---|
| 54 | {
|
---|
| 55 | st_format rep_serv_tab[] = {
|
---|
| 56 | { 'T', S_FMT_TIME, 0, 0, NULL},
|
---|
| 57 | { 'S', S_FMT_TIME, 0, 0, NULL},
|
---|
| 58 | { 'L', S_FMT_TIME, 0, 0, NULL},
|
---|
| 59 | { 'O', S_FMT_ULONG, 0, 0, NULL},
|
---|
| 60 | { 'A', S_FMT_ULONG, 0, 0, NULL},
|
---|
| 61 | { 'M', S_FMT_ULONG, 0, 0, NULL},
|
---|
| 62 | {'\0', S_FMT_ULONG, 0, 0, NULL},
|
---|
| 63 | };
|
---|
| 64 |
|
---|
| 65 | rep_serv_tab[0].data_ulong = (unsigned long) time(NULL);
|
---|
| 66 | rep_serv_tab[1].data_ulong = server_status.start;
|
---|
| 67 | rep_serv_tab[2].data_ulong = server_status.last;
|
---|
| 68 | rep_serv_tab[3].data_ulong = server_status.conn_open;
|
---|
| 69 | rep_serv_tab[4].data_ulong = server_status.conn_total;
|
---|
| 70 | rep_serv_tab[5].data_ulong = server_status.conn_max;
|
---|
| 71 |
|
---|
| 72 | return (sh_util_formatted(line, rep_serv_tab));
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 |
|
---|
| 76 | static
|
---|
| 77 | int sh_html_head(SL_TICKET ticket)
|
---|
| 78 | {
|
---|
| 79 | long status = SL_ENONE;
|
---|
| 80 | SL_TICKET fd = (-1);
|
---|
| 81 | char line[512];
|
---|
| 82 | char endhead[512];
|
---|
| 83 | char outline[1024];
|
---|
| 84 | char ts1[81];
|
---|
| 85 | char ts2[81];
|
---|
| 86 | time_t now;
|
---|
| 87 | struct tm * time_ptr;
|
---|
[131] | 88 | #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_LOCALTIME_R)
|
---|
| 89 | struct tm time_tm;
|
---|
| 90 | #endif
|
---|
[1] | 91 |
|
---|
| 92 | char * formatted;
|
---|
| 93 | char * qstr;
|
---|
| 94 |
|
---|
| 95 | char * p;
|
---|
| 96 |
|
---|
| 97 | SL_ENTER(_("sh_html_head"));
|
---|
| 98 |
|
---|
| 99 | p = sh_util_strconcat(DEFAULT_DATAROOT, _("/head.html"), NULL);
|
---|
| 100 |
|
---|
| 101 | if (p)
|
---|
| 102 | {
|
---|
[248] | 103 | fd = sl_open_read (FIL__, __LINE__, p, SL_YESPRIV);
|
---|
[1] | 104 | SH_FREE(p);
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | if (!SL_ISERROR(fd))
|
---|
| 108 | {
|
---|
[34] | 109 | while (!SL_ISERROR(status) && sh_unix_getline (fd, line, sizeof(line)) > 0)
|
---|
[1] | 110 | {
|
---|
| 111 | formatted = replace_stat (line);
|
---|
| 112 | if (formatted)
|
---|
| 113 | {
|
---|
| 114 | status = sl_write_line (ticket, formatted, sl_strlen(formatted));
|
---|
| 115 | SH_FREE(formatted);
|
---|
| 116 | }
|
---|
| 117 | }
|
---|
| 118 | sl_close(fd);
|
---|
| 119 | }
|
---|
| 120 | else
|
---|
| 121 | {
|
---|
[34] | 122 | qstr = sh_util_basename(DEFAULT_HTML_FILE);
|
---|
[1] | 123 | if (qstr != NULL)
|
---|
| 124 | {
|
---|
| 125 | sl_snprintf(endhead, 511,
|
---|
| 126 | _("<meta http-equiv=%crefresh%c content=%c120; URL=./%s%c></HEAD><BODY>"),
|
---|
| 127 | 34, 34, 34, qstr, 34);
|
---|
| 128 | SH_FREE(qstr);
|
---|
| 129 | }
|
---|
| 130 | else
|
---|
| 131 | {
|
---|
| 132 | sl_snprintf(endhead, 511, _("</HEAD><BODY>"));
|
---|
| 133 | }
|
---|
| 134 |
|
---|
| 135 | status =
|
---|
| 136 | sl_write_line (ticket,
|
---|
| 137 | _("<HTML><HEAD><TITLE>Report</TITLE>"),
|
---|
| 138 | sizeof("<HTML><HEAD><TITLE>Report</TITLE>")-1);
|
---|
| 139 | if (!SL_ISERROR(status))
|
---|
| 140 | status =
|
---|
| 141 | sl_write_line (ticket, endhead, strlen(endhead));
|
---|
| 142 | if (!SL_ISERROR(status))
|
---|
| 143 | status =
|
---|
| 144 | sl_write_line (ticket,
|
---|
| 145 | _("<H1>Samhain Server Report</H1>"),
|
---|
| 146 | sizeof("<H1>Samhain Server Report</H1>")-1);
|
---|
| 147 | if (!SL_ISERROR(status))
|
---|
| 148 | {
|
---|
[131] | 149 | #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_LOCALTIME_R)
|
---|
| 150 | time_ptr = localtime_r (&(server_status.start), &time_tm);
|
---|
| 151 | #else
|
---|
[1] | 152 | time_ptr = localtime (&(server_status.start));
|
---|
[131] | 153 | #endif
|
---|
[1] | 154 | if (time_ptr != NULL)
|
---|
[383] | 155 | strftime (ts1, 80, _("%d-%m-%Y %H:%M:%S"), time_ptr);
|
---|
[481] | 156 | else
|
---|
| 157 | sl_strlcpy(ts1, _("01-01-1970 00:00:00"), sizeof(ts1));
|
---|
[1] | 158 | now = time(NULL);
|
---|
[131] | 159 | #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_LOCALTIME_R)
|
---|
| 160 | time_ptr = localtime_r (&now, &time_tm);
|
---|
| 161 | #else
|
---|
[1] | 162 | time_ptr = localtime (&now);
|
---|
[131] | 163 | #endif
|
---|
[1] | 164 | if (time_ptr != NULL)
|
---|
[383] | 165 | strftime (ts2, 80, _("%d-%m-%Y %H:%M:%S"), time_ptr);
|
---|
[481] | 166 | else
|
---|
| 167 | sl_strlcpy(ts2, _("01-01-1970 00:00:00"), sizeof(ts2));
|
---|
[1] | 168 |
|
---|
| 169 | sl_snprintf(outline, 1023,
|
---|
| 170 | _("<p>Time:<BR>Now: %s<BR>Start: %s</p>"),
|
---|
| 171 | ts2, ts1);
|
---|
| 172 | status =
|
---|
| 173 | sl_write_line (ticket, outline, sl_strlen(outline));
|
---|
| 174 | }
|
---|
| 175 | if (!SL_ISERROR(status))
|
---|
| 176 | {
|
---|
| 177 | sl_snprintf(outline, 1023,
|
---|
| 178 | _("<p>Connections (max. %d simultaneous):"\
|
---|
| 179 | "<BR>Now: %d<BR>Total: %ld</p>"),
|
---|
| 180 | server_status.conn_max,
|
---|
| 181 | server_status.conn_open,
|
---|
| 182 | server_status.conn_total);
|
---|
| 183 | status =
|
---|
| 184 | sl_write_line (ticket, outline, sl_strlen(outline));
|
---|
| 185 | if (server_status.last > (time_t) 0)
|
---|
| 186 | {
|
---|
[131] | 187 | #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_LOCALTIME_R)
|
---|
| 188 | time_ptr = localtime_r (&(server_status.last), &time_tm);
|
---|
| 189 | #else
|
---|
[1] | 190 | time_ptr = localtime (&(server_status.last));
|
---|
[131] | 191 | #endif
|
---|
[1] | 192 | if (time_ptr != NULL)
|
---|
[383] | 193 | strftime (ts1, 80, _("%d-%m-%Y %H:%M:%S"), time_ptr);
|
---|
[481] | 194 | else
|
---|
| 195 | sl_strlcpy(ts1, _("01-01-1970 00:00:00"), sizeof(ts1));
|
---|
[1] | 196 | sl_snprintf(outline, 1023,
|
---|
| 197 | _("<p>Last connection at %s</p>"),
|
---|
| 198 | ts1);
|
---|
| 199 | status =
|
---|
| 200 | sl_write_line (ticket, outline, sl_strlen(outline));
|
---|
| 201 | }
|
---|
| 202 | }
|
---|
| 203 | if (!SL_ISERROR(status))
|
---|
| 204 | status =
|
---|
| 205 | sl_write_line (ticket,
|
---|
| 206 | _("<center><table cellpadding=5 cellspacing=2 border=2>"),
|
---|
| 207 | sizeof("<center><table cellpadding=5 cellspacing=2 border=2>")-1);
|
---|
| 208 | }
|
---|
| 209 |
|
---|
| 210 | if (SL_ISERROR(status))
|
---|
| 211 | SL_RETURN((-1), _("sh_html_head"));
|
---|
| 212 |
|
---|
| 213 | SL_RETURN((0), _("sh_html_head"));
|
---|
| 214 | }
|
---|
| 215 |
|
---|
| 216 | static
|
---|
| 217 | int sh_html_foot(SL_TICKET ticket)
|
---|
| 218 | {
|
---|
| 219 | long status = SL_ENONE;
|
---|
| 220 | SL_TICKET fd = (-1);
|
---|
| 221 | char line[512];
|
---|
| 222 | char * p;
|
---|
| 223 |
|
---|
| 224 | SL_ENTER(_("sh_html_foot"));
|
---|
| 225 |
|
---|
| 226 | p = sh_util_strconcat(DEFAULT_DATAROOT, _("/foot.html"), NULL);
|
---|
| 227 |
|
---|
| 228 | if (p)
|
---|
| 229 | {
|
---|
[248] | 230 | fd = sl_open_read (FIL__, __LINE__, p, SL_YESPRIV);
|
---|
[1] | 231 | SH_FREE(p);
|
---|
| 232 | }
|
---|
| 233 |
|
---|
| 234 | if (!SL_ISERROR(fd))
|
---|
| 235 | {
|
---|
[34] | 236 | while (!SL_ISERROR(status) && sh_unix_getline (fd, line, sizeof(line)) > 0)
|
---|
[1] | 237 | {
|
---|
| 238 | status = sl_write_line (ticket, line, sl_strlen(line));
|
---|
| 239 | }
|
---|
| 240 | sl_close(fd);
|
---|
| 241 | }
|
---|
| 242 | else
|
---|
| 243 | {
|
---|
| 244 | status = sl_write_line (ticket, _("</table></center></BODY></HTML>"),
|
---|
| 245 | sizeof("</table></center></BODY></HTML>")-1);
|
---|
| 246 | }
|
---|
| 247 | if (SL_ISERROR(status))
|
---|
| 248 | SL_RETURN((-1), _("sh_html_foot"));
|
---|
| 249 |
|
---|
| 250 | SL_RETURN((0), _("sh_html_foot"));
|
---|
| 251 | }
|
---|
| 252 |
|
---|
| 253 |
|
---|
| 254 | static
|
---|
| 255 | char * replace_tab (const char * line, char * host, char * status,
|
---|
| 256 | char * timestamp)
|
---|
| 257 | {
|
---|
| 258 | st_format rep_serv_tab[] = {
|
---|
| 259 | { 'H', S_FMT_STRING, 0, 0, NULL},
|
---|
| 260 | { 'S', S_FMT_STRING, 0, 0, NULL},
|
---|
| 261 | { 'T', S_FMT_STRING, 0, 0, NULL},
|
---|
| 262 | {'\0', S_FMT_ULONG, 0, 0, NULL},
|
---|
| 263 | };
|
---|
| 264 | char * p;
|
---|
| 265 |
|
---|
| 266 | SL_ENTER(_("replace_tab"));
|
---|
| 267 |
|
---|
| 268 | rep_serv_tab[0].data_str = host;
|
---|
| 269 | rep_serv_tab[1].data_str = status;
|
---|
| 270 | rep_serv_tab[2].data_str = timestamp;
|
---|
| 271 |
|
---|
| 272 | p = sh_util_formatted(line, rep_serv_tab);
|
---|
| 273 | SL_RETURN(p, _("replace_tab"));
|
---|
| 274 | }
|
---|
| 275 |
|
---|
| 276 | static char * entry_orig = NULL;
|
---|
| 277 | static size_t entry_size = 0;
|
---|
| 278 |
|
---|
| 279 | static
|
---|
[170] | 280 | int sh_html_get_entry (void)
|
---|
[1] | 281 | {
|
---|
| 282 | long retval = SL_ENONE;
|
---|
| 283 | SL_TICKET fd = (-1);
|
---|
| 284 | char line[512];
|
---|
| 285 | size_t line_size;
|
---|
| 286 | size_t add_size = 0;
|
---|
| 287 | char * p;
|
---|
| 288 |
|
---|
| 289 | SL_ENTER(_("sh_html_get_entry"));
|
---|
| 290 |
|
---|
| 291 | p = sh_util_strconcat(DEFAULT_DATAROOT, _("/entry.html"), NULL);
|
---|
| 292 |
|
---|
| 293 | entry_size = 0;
|
---|
| 294 | if (entry_orig != NULL)
|
---|
| 295 | {
|
---|
| 296 | free (entry_orig);
|
---|
| 297 | entry_orig = NULL;
|
---|
| 298 | entry_size = 0;
|
---|
| 299 | }
|
---|
| 300 |
|
---|
| 301 | if (p)
|
---|
| 302 | {
|
---|
[248] | 303 | fd = sl_open_read (FIL__, __LINE__, p, SL_YESPRIV);
|
---|
[1] | 304 | SH_FREE(p);
|
---|
| 305 | }
|
---|
| 306 | if (!SL_ISERROR(fd))
|
---|
| 307 | {
|
---|
[34] | 308 | while (!SL_ISERROR(retval) && sh_unix_getline (fd, line, sizeof(line)) > 0)
|
---|
[1] | 309 | {
|
---|
| 310 | line_size = sl_strlen(line);
|
---|
| 311 | add_size = 0;
|
---|
| 312 | if (entry_orig != NULL)
|
---|
| 313 | {
|
---|
[473] | 314 | char * ptr = realloc(entry_orig, /* free() ok */
|
---|
[22] | 315 | entry_size + line_size + 1);
|
---|
[473] | 316 | if (ptr) {
|
---|
| 317 | entry_orig = ptr;
|
---|
| 318 | add_size = line_size;
|
---|
| 319 | } else {
|
---|
| 320 | { free(entry_orig); entry_orig = NULL; }
|
---|
| 321 | }
|
---|
[1] | 322 | }
|
---|
| 323 | else
|
---|
| 324 | {
|
---|
[454] | 325 | entry_orig = calloc(1, line_size + 1); /* free() ok */
|
---|
[22] | 326 | if (entry_orig) { entry_orig[0] = '\0'; add_size = line_size; }
|
---|
[1] | 327 | }
|
---|
| 328 | if (!entry_orig)
|
---|
| 329 | {
|
---|
| 330 | entry_size = 0;
|
---|
[383] | 331 | /* add_size = 0; *//* never read */
|
---|
[1] | 332 | SL_RETURN( 0, _("sh_html_get_entry"));
|
---|
| 333 | }
|
---|
| 334 |
|
---|
[22] | 335 | sl_strlcat(&entry_orig[entry_size], line, line_size + 1);
|
---|
[1] | 336 | entry_size += add_size;
|
---|
[25] | 337 | SH_VALIDATE_EQ(entry_orig[entry_size], '\0');
|
---|
[1] | 338 | }
|
---|
| 339 | sl_close(fd);
|
---|
| 340 | }
|
---|
| 341 | SL_RETURN( entry_size, _("sh_html_get_entry"));
|
---|
| 342 | }
|
---|
| 343 |
|
---|
| 344 | static
|
---|
| 345 | int sh_html_entry (SL_TICKET ticket,
|
---|
| 346 | char * host, char * status, char * timestamp, int flag)
|
---|
| 347 | {
|
---|
| 348 | char outline[1024];
|
---|
| 349 | long retval = SL_ENONE;
|
---|
| 350 |
|
---|
| 351 | char * formatted;
|
---|
| 352 |
|
---|
| 353 | SL_ENTER(_("sh_html_entry"));
|
---|
| 354 |
|
---|
| 355 | if (entry_size > 0 && entry_orig != NULL)
|
---|
| 356 | {
|
---|
| 357 | formatted = replace_tab(entry_orig, host, status, timestamp);
|
---|
| 358 | if (formatted)
|
---|
| 359 | {
|
---|
| 360 | retval = sl_write_line (ticket, formatted, sl_strlen(formatted));
|
---|
| 361 | SH_FREE(formatted);
|
---|
| 362 | }
|
---|
| 363 | }
|
---|
| 364 | else
|
---|
| 365 | {
|
---|
| 366 | sl_snprintf(outline, 1023,
|
---|
| 367 | _("<tr><td>%s</td><td>%s</td><td>%s</td></tr>"),
|
---|
| 368 | host, status, timestamp);
|
---|
| 369 | retval = sl_write_line (ticket, outline, sl_strlen(outline));
|
---|
| 370 | }
|
---|
| 371 |
|
---|
| 372 | /* write a status line
|
---|
| 373 | */
|
---|
| 374 | if ((flag == 1) && (!SL_ISERROR(retval)))
|
---|
| 375 | {
|
---|
| 376 | sl_snprintf(outline, 1023,
|
---|
| 377 | _("<!-- \n[STATUS:] %s %s %s\n -->"),
|
---|
| 378 | host, status, timestamp);
|
---|
| 379 | retval = sl_write_line (ticket, outline, sl_strlen(outline));
|
---|
| 380 | }
|
---|
| 381 |
|
---|
| 382 | if (SL_ISERROR(retval))
|
---|
| 383 | SL_RETURN((-1), _("sh_html_entry"));
|
---|
| 384 |
|
---|
| 385 | SL_RETURN((0), _("sh_html_entry"));
|
---|
| 386 | }
|
---|
| 387 |
|
---|
| 388 | typedef struct _sort_arr {
|
---|
| 389 | char msg[TIM_MAX];
|
---|
| 390 | char tim[TIM_MAX];
|
---|
| 391 | } sort_arr;
|
---|
| 392 |
|
---|
| 393 | static sort_arr sort_stat[CLT_MAX];
|
---|
| 394 |
|
---|
| 395 | static
|
---|
| 396 | int comp_arr (const void * ao, const void * bo)
|
---|
| 397 | {
|
---|
[170] | 398 | const sort_arr * a;
|
---|
| 399 | const sort_arr * b;
|
---|
[1] | 400 |
|
---|
| 401 | if (ao == NULL && bo == NULL)
|
---|
| 402 | return 0;
|
---|
| 403 | else if (ao == NULL && bo != NULL)
|
---|
| 404 | return (-1);
|
---|
| 405 | else if (ao != NULL && bo == NULL)
|
---|
| 406 | return (1);
|
---|
| 407 |
|
---|
[170] | 408 | a = (const sort_arr *) ao;
|
---|
| 409 | b = (const sort_arr *) bo;
|
---|
[1] | 410 |
|
---|
| 411 | return ((-1) * sl_strcmp(a->tim, b->tim));
|
---|
| 412 | }
|
---|
| 413 |
|
---|
| 414 | static
|
---|
| 415 | int sh_html_print_one (SL_TICKET ticket, client_t * top)
|
---|
| 416 | {
|
---|
| 417 | int status;
|
---|
| 418 | int clt_status;
|
---|
[481] | 419 | unsigned int i, n;
|
---|
[1] | 420 |
|
---|
| 421 | SL_ENTER(_("sh_html_print_one"));
|
---|
| 422 |
|
---|
| 423 | if (top == NULL)
|
---|
| 424 | SL_RETURN((0), _("sh_html_print_one"));
|
---|
| 425 |
|
---|
| 426 | clt_status = top->status_now;
|
---|
| 427 | status = sh_html_entry (ticket,
|
---|
| 428 | top->hostname,
|
---|
| 429 | _(clt_stat[clt_status]),
|
---|
| 430 | top->timestamp[clt_status],
|
---|
| 431 | 1);
|
---|
| 432 |
|
---|
| 433 | n = 0;
|
---|
| 434 |
|
---|
| 435 | if (clt_status != CLT_INACTIVE)
|
---|
| 436 | {
|
---|
| 437 | for (i = 1; i < CLT_MAX; ++i)
|
---|
| 438 | {
|
---|
| 439 | if (top->status_arr[i] != CLT_INACTIVE)
|
---|
| 440 | {
|
---|
| 441 | clt_status = top->status_arr[i];
|
---|
| 442 | sl_strlcpy(sort_stat[n].msg, _(clt_stat[clt_status]), TIM_MAX);
|
---|
| 443 | sl_strlcpy(sort_stat[n].tim, top->timestamp[clt_status],TIM_MAX);
|
---|
| 444 | ++n;
|
---|
| 445 | }
|
---|
| 446 | }
|
---|
| 447 | }
|
---|
| 448 |
|
---|
| 449 | if (n > 0)
|
---|
| 450 | {
|
---|
| 451 | qsort(&(sort_stat[0]), n, sizeof(sort_arr), comp_arr);
|
---|
| 452 |
|
---|
| 453 | for (i = 1; i < n; ++i)
|
---|
| 454 | {
|
---|
| 455 | status = sh_html_entry (ticket,
|
---|
| 456 | " ",
|
---|
| 457 | sort_stat[i].msg,
|
---|
| 458 | sort_stat[i].tim,
|
---|
| 459 | 0);
|
---|
| 460 | }
|
---|
| 461 | }
|
---|
| 462 |
|
---|
| 463 | if (SL_ISERROR(status))
|
---|
| 464 | SL_RETURN((-1), _("sh_html_print_one"));
|
---|
| 465 |
|
---|
| 466 | SL_RETURN((0), _("sh_html_print_one"));
|
---|
| 467 | }
|
---|
| 468 |
|
---|
| 469 | #include "zAVLTree.h"
|
---|
| 470 |
|
---|
| 471 | int sh_html_write(void * inptr)
|
---|
| 472 | {
|
---|
| 473 | long fd;
|
---|
| 474 | zAVLCursor avlcursor;
|
---|
| 475 | client_t * item;
|
---|
| 476 | zAVLTree * top = (zAVLTree *) inptr;
|
---|
| 477 |
|
---|
| 478 | SL_ENTER(_("sh_html_write"));
|
---|
| 479 |
|
---|
| 480 | if (0 != (fd = tf_trust_check (DEFAULT_HTML_FILE, SL_YESPRIV)))
|
---|
| 481 | {
|
---|
| 482 | sh_error_handle((-1), FIL__, __LINE__, fd, MSG_E_TRUST,
|
---|
| 483 | (long) sh.effective.uid,
|
---|
| 484 | DEFAULT_HTML_FILE);
|
---|
| 485 | SL_RETURN((-1), _("sh_html_write"));
|
---|
| 486 | }
|
---|
| 487 |
|
---|
| 488 |
|
---|
[248] | 489 | fd = sl_open_write_trunc (FIL__, __LINE__, DEFAULT_HTML_FILE, SL_YESPRIV);
|
---|
[1] | 490 |
|
---|
| 491 | if (SL_ISERROR(fd))
|
---|
| 492 | {
|
---|
| 493 | sh_error_handle((-1), FIL__, __LINE__, fd, MSG_E_ACCESS,
|
---|
| 494 | (long) sh.effective.uid,
|
---|
| 495 | DEFAULT_HTML_FILE);
|
---|
| 496 | SL_RETURN((-1), _("sh_html_write"));
|
---|
| 497 | }
|
---|
| 498 |
|
---|
| 499 | sh_html_get_entry();
|
---|
| 500 |
|
---|
| 501 | sh_html_head(fd);
|
---|
| 502 | for (item = (client_t *) zAVLFirst(&avlcursor, top); item;
|
---|
| 503 | item = (client_t *) zAVLNext(&avlcursor))
|
---|
| 504 | sh_html_print_one (fd, item);
|
---|
| 505 | sh_html_foot(fd);
|
---|
| 506 | sl_close(fd);
|
---|
| 507 |
|
---|
| 508 | SL_RETURN((0), _("sh_html_write"));
|
---|
| 509 | }
|
---|
| 510 |
|
---|
[415] | 511 | int sh_html_zero()
|
---|
| 512 | {
|
---|
| 513 | long fd;
|
---|
| 514 |
|
---|
| 515 | SL_ENTER(_("sh_html_zero"));
|
---|
| 516 |
|
---|
| 517 | if (0 != (fd = tf_trust_check (DEFAULT_HTML_FILE, SL_YESPRIV)))
|
---|
| 518 | {
|
---|
| 519 | SL_RETURN((-1), _("sh_html_zero"));
|
---|
| 520 | }
|
---|
| 521 |
|
---|
| 522 | fd = sl_open_write_trunc (FIL__, __LINE__, DEFAULT_HTML_FILE, SL_YESPRIV);
|
---|
| 523 |
|
---|
| 524 | if (SL_ISERROR(fd))
|
---|
| 525 | {
|
---|
| 526 | SL_RETURN((-1), _("sh_html_zero"));
|
---|
| 527 | }
|
---|
| 528 |
|
---|
| 529 | sh_html_head(fd);
|
---|
| 530 | sh_html_foot(fd);
|
---|
| 531 |
|
---|
| 532 | sl_close(fd);
|
---|
| 533 |
|
---|
| 534 | SL_RETURN((0), _("sh_html_zero"));
|
---|
| 535 | }
|
---|
| 536 |
|
---|
[1] | 537 | /* SH_WITH_SERVER */
|
---|
| 538 | #endif
|
---|
| 539 |
|
---|
| 540 |
|
---|
| 541 |
|
---|
| 542 |
|
---|
| 543 |
|
---|
| 544 |
|
---|
| 545 |
|
---|
| 546 |
|
---|
| 547 |
|
---|
| 548 |
|
---|
| 549 |
|
---|
| 550 |
|
---|
| 551 |
|
---|
| 552 |
|
---|
| 553 |
|
---|