diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 77 |
1 files changed, 40 insertions, 37 deletions
@@ -81,6 +81,6 @@ static char *html_template_option = NULL; | |||
81 | 81 | ||
82 | const char *program_version = "tagr (" PACKAGE_STRING ")"; | 82 | const char *program_version = "tagr (" PACKAGE_STRING ")"; |
83 | static char doc[] = "tagr -- traffic analyzer and grapher"; | 83 | static char doc[] = N_("tagr -- traffic analyzer and grapher"); |
84 | static char args_doc[] = ""; | 84 | static char args_doc[] = "[FILES or DIRS...]"; |
85 | 85 | ||
86 | enum { | 86 | enum { |
@@ -113,5 +113,5 @@ static struct argp_option options[] = { | |||
113 | GRID+1 }, | 113 | GRID+1 }, |
114 | {"read", OPT_READ, NULL, 0, | 114 | {"read", OPT_READ, NULL, 0, |
115 | N_("read statistics from the given file or standard input") }, | 115 | N_("read statistics from given FILEs or standard input") }, |
116 | {"rebuild", 'b', NULL, 0, | 116 | {"rebuild", 'b', NULL, 0, |
117 | N_("rebuild graphs using existing statistics"), GRID+1}, | 117 | N_("rebuild graphs using existing statistics"), GRID+1}, |
@@ -188,10 +188,10 @@ static void | |||
188 | show_defaults () | 188 | show_defaults () |
189 | { | 189 | { |
190 | printf ("Configuration file: %s\n", TAGR_CONFIGFILE); | 190 | printf (_("Configuration file: %s\n"), TAGR_CONFIGFILE); |
191 | printf ("Page template file: %s\n", TAGR_TEMPLATE); | 191 | printf (_("Page template file: %s\n"), TAGR_TEMPLATE); |
192 | printf ("PID file: %s\n", TAGR_PIDFILE); | 192 | printf (_("PID file: %s\n"), TAGR_PIDFILE); |
193 | printf ("DB file name: %s\n", TAGR_DBNAME); | 193 | printf (_("DB file name: %s\n"), TAGR_DBNAME); |
194 | printf ("DB file permissions: %#o\n", TAGR_DBMODE); | 194 | printf (_("DB file permissions: %#o\n"), TAGR_DBMODE); |
195 | printf ("Syslog facility number: %d\n", LOGFACILITY); | 195 | printf (_("Syslog facility number: %d\n"), LOG_FACILITY); |
196 | } | 196 | } |
197 | 197 | ||
@@ -336,5 +336,5 @@ change_privs (uid_t uid, gid_t gid) | |||
336 | if (geteuid () == 0 && setgroups (1, emptygidset)) | 336 | if (geteuid () == 0 && setgroups (1, emptygidset)) |
337 | { | 337 | { |
338 | logmsg (L_ERR, "setgroups(1, %lu) failed: %s", | 338 | logmsg (L_ERR, _("setgroups(1, %lu) failed: %s"), |
339 | (u_long) emptygidset[0], strerror (errno)); | 339 | (u_long) emptygidset[0], strerror (errno)); |
340 | rc = 1; | 340 | rc = 1; |
@@ -346,12 +346,13 @@ change_privs (uid_t uid, gid_t gid) | |||
346 | #if defined(HAVE_SETEGID) | 346 | #if defined(HAVE_SETEGID) |
347 | if ((rc = setegid (gid)) < 0) | 347 | if ((rc = setegid (gid)) < 0) |
348 | logmsg (L_ERR, "setegid(%lu) failed: %s", (u_long) gid, strerror (errno)); | 348 | logmsg (L_ERR, _("setegid(%lu) failed: %s"), |
349 | (u_long) gid, strerror (errno)); | ||
349 | #elif defined(HAVE_SETREGID) | 350 | #elif defined(HAVE_SETREGID) |
350 | if ((rc = setregid (gid, gid)) < 0) | 351 | if ((rc = setregid (gid, gid)) < 0) |
351 | logmsg (L_ERR, "setregid(%lu,%lu) failed: %s", | 352 | logmsg (L_ERR, _("setregid(%lu,%lu) failed: %s"), |
352 | (u_long) gid, (u_long) gid, strerror (errno)); | 353 | (u_long) gid, (u_long) gid, strerror (errno)); |
353 | #elif defined(HAVE_SETRESGID) | 354 | #elif defined(HAVE_SETRESGID) |
354 | if ((rc = setresgid (gid, gid, gid)) < 0) | 355 | if ((rc = setresgid (gid, gid, gid)) < 0) |
355 | logmsg (L_ERR, "setresgid(%lu,%lu,%lu) failed: %s", | 356 | logmsg (L_ERR, _("setresgid(%lu,%lu,%lu) failed: %s"), |
356 | (u_long) gid, (u_long) gid, (u_long) gid, strerror (errno)); | 357 | (u_long) gid, (u_long) gid, (u_long) gid, strerror (errno)); |
357 | #endif | 358 | #endif |
@@ -360,9 +361,9 @@ change_privs (uid_t uid, gid_t gid) | |||
360 | { | 361 | { |
361 | if ((rc = setgid (gid)) < 0 && getegid () != gid) | 362 | if ((rc = setgid (gid)) < 0 && getegid () != gid) |
362 | logmsg (L_ERR, "setgid(%lu) failed: %s", | 363 | logmsg (L_ERR, _("setgid(%lu) failed: %s"), |
363 | (u_long) gid, strerror (errno)); | 364 | (u_long) gid, strerror (errno)); |
364 | if (rc == 0 && getegid () != gid) | 365 | if (rc == 0 && getegid () != gid) |
365 | { | 366 | { |
366 | logmsg (L_ERR, "cannot set effective gid to %lu: %s", | 367 | logmsg (L_ERR, _("cannot set effective gid to %lu: %s"), |
367 | (u_long) gid, strerror (errno)); | 368 | (u_long) gid, strerror (errno)); |
368 | rc = 1; | 369 | rc = 1; |
@@ -386,5 +387,5 @@ change_privs (uid_t uid, gid_t gid) | |||
386 | { | 387 | { |
387 | logmsg (L_ERR, | 388 | logmsg (L_ERR, |
388 | "setreuid(%lu,-1) failed: %s", | 389 | _("setreuid(%lu,-1) failed: %s"), |
389 | (u_long) uid, strerror (errno)); | 390 | (u_long) uid, strerror (errno)); |
390 | rc = 1; | 391 | rc = 1; |
@@ -393,5 +394,5 @@ change_privs (uid_t uid, gid_t gid) | |||
393 | { | 394 | { |
394 | logmsg (L_ERR, | 395 | logmsg (L_ERR, |
395 | "second setuid(%lu) failed: %s", | 396 | _("second setuid(%lu) failed: %s"), |
396 | (u_long) uid, strerror (errno)); | 397 | (u_long) uid, strerror (errno)); |
397 | rc = 1; | 398 | rc = 1; |
@@ -401,5 +402,5 @@ change_privs (uid_t uid, gid_t gid) | |||
401 | #endif | 402 | #endif |
402 | { | 403 | { |
403 | logmsg (L_ERR, "setuid(%lu) failed: %s", | 404 | logmsg (L_ERR, _("setuid(%lu) failed: %s"), |
404 | (u_long) uid, strerror (errno)); | 405 | (u_long) uid, strerror (errno)); |
405 | rc = 1; | 406 | rc = 1; |
@@ -413,10 +414,10 @@ change_privs (uid_t uid, gid_t gid) | |||
413 | if (uid != 0 && setuid (0) == 0) | 414 | if (uid != 0 && setuid (0) == 0) |
414 | { | 415 | { |
415 | logmsg (L_ERR, "seteuid(0) succeeded when it should not"); | 416 | logmsg (L_ERR, _("seteuid(0) succeeded when it should not")); |
416 | rc = 1; | 417 | rc = 1; |
417 | } | 418 | } |
418 | else if (uid != euid && setuid (euid) == 0) | 419 | else if (uid != euid && setuid (euid) == 0) |
419 | { | 420 | { |
420 | logmsg (L_ERR, "cannot drop non-root setuid privileges"); | 421 | logmsg (L_ERR, _("cannot drop non-root setuid privileges")); |
421 | rc = 1; | 422 | rc = 1; |
422 | } | 423 | } |
@@ -435,5 +436,5 @@ change_user () | |||
435 | if (getuid () == 0) | 436 | if (getuid () == 0) |
436 | { | 437 | { |
437 | logmsg (L_NOTICE, "not a superuser: ignoring the `user' statement"); | 438 | logmsg (L_NOTICE, _("not a superuser: ignoring the `user' statement")); |
438 | return; | 439 | return; |
439 | } | 440 | } |
@@ -463,5 +464,6 @@ decode_buffer () | |||
463 | if (reply->n_addr > MAXADDR) | 464 | if (reply->n_addr > MAXADDR) |
464 | { | 465 | { |
465 | logmsg (L_NOTICE, "got invalid packet: n_addr = %d", reply->n_addr); | 466 | logmsg (L_NOTICE, _("got invalid packet: n_addr = %d"), |
467 | reply->n_addr); | ||
466 | return; | 468 | return; |
467 | } | 469 | } |
@@ -472,5 +474,5 @@ decode_buffer () | |||
472 | strftime (tbuf, sizeof tbuf, "%Y-%m-%d %H:%M:%S", | 474 | strftime (tbuf, sizeof tbuf, "%Y-%m-%d %H:%M:%S", |
473 | gmtime (&reply->timestamp)); | 475 | gmtime (&reply->timestamp)); |
474 | logmsg (L_INFO, "Received packet: %d %lu - %s", reply->n_addr, | 476 | logmsg (L_INFO, _("Received packet: %d %lu - %s"), reply->n_addr, |
475 | (unsigned long) reply->timestamp, tbuf); | 477 | (unsigned long) reply->timestamp, tbuf); |
476 | } | 478 | } |
@@ -484,5 +486,5 @@ decode_buffer () | |||
484 | return; | 486 | return; |
485 | else if (pid < 0) | 487 | else if (pid < 0) |
486 | logmsg (L_ERR, "can't fork: %s", strerror (errno)); | 488 | logmsg (L_ERR, _("cannot fork: %s"), strerror (errno)); |
487 | else | 489 | else |
488 | { | 490 | { |
@@ -498,5 +500,5 @@ decode_buffer () | |||
498 | sp->in = ntohl (sp->in); | 500 | sp->in = ntohl (sp->in); |
499 | sp->out = ntohl (sp->out); | 501 | sp->out = ntohl (sp->out); |
500 | verbose (1, "Monitor %s: %lu %lu", sp->name, sp->in, sp->out); | 502 | verbose (1, _("Monitor %s: %lu %lu"), sp->name, sp->in, sp->out); |
501 | report (sp, reply->timestamp); | 503 | report (sp, reply->timestamp); |
502 | } | 504 | } |
@@ -526,8 +528,9 @@ read_input (const char *name) | |||
526 | fp = fopen (name, "r"); | 528 | fp = fopen (name, "r"); |
527 | if (!fp) | 529 | if (!fp) |
528 | die (EX_OSERR, "cannot open file `%s': %s", name, strerror (errno)); | 530 | die (EX_OSERR, _("cannot open file `%s': %s"), |
531 | name, strerror (errno)); | ||
529 | } | 532 | } |
530 | 533 | ||
531 | verbose (2, "Reading `%s'", name); | 534 | verbose (2, _("Reading `%s'"), name); |
532 | 535 | ||
533 | open_db (TAGR_DB_WR); | 536 | open_db (TAGR_DB_WR); |
@@ -548,5 +551,5 @@ read_input (const char *name) | |||
548 | { | 551 | { |
549 | if (i > MAX_NAME_LENGTH) | 552 | if (i > MAX_NAME_LENGTH) |
550 | die (EX_DATAERR, "%s:%lu: ID too long", name, line); | 553 | die (EX_DATAERR, _("%s:%lu: ID too long"), name, line); |
551 | st.name[i++] = *p++; | 554 | st.name[i++] = *p++; |
552 | } | 555 | } |
@@ -554,10 +557,10 @@ read_input (const char *name) | |||
554 | 557 | ||
555 | if (sscanf (p, " %lu %lu %lu\n", &t, &st.in, &st.out) != 3) | 558 | if (sscanf (p, " %lu %lu %lu\n", &t, &st.in, &st.out) != 3) |
556 | die (EX_DATAERR, "%s:%lu: invalid input line", name, line); | 559 | die (EX_DATAERR, _("%s:%lu: invalid input line"), name, line); |
557 | report (&st, t); | 560 | report (&st, t); |
558 | } | 561 | } |
559 | fclose (fp); | 562 | fclose (fp); |
560 | close_db (); | 563 | close_db (); |
561 | verbose (2, "Finished reading `%s'", name); | 564 | verbose (2, _("Finished reading `%s'"), name); |
562 | } | 565 | } |
563 | 566 | ||
@@ -576,5 +579,5 @@ get_port (char *str) | |||
576 | else | 579 | else |
577 | { | 580 | { |
578 | logmsg (L_ERR, "no such service: %s", str); | 581 | logmsg (L_ERR, _("no such service: %s"), str); |
579 | return 0; | 582 | return 0; |
580 | } | 583 | } |
@@ -595,5 +598,5 @@ RETSIGTYPE | |||
595 | sig_quit (int sig) | 598 | sig_quit (int sig) |
596 | { | 599 | { |
597 | logmsg (L_INFO, "exiting on signal %d", sig); | 600 | logmsg (L_INFO, _("exiting on signal %d"), sig); |
598 | unlink (pidfile); | 601 | unlink (pidfile); |
599 | exit (0); | 602 | exit (0); |
@@ -603,5 +606,5 @@ RETSIGTYPE | |||
603 | sig_fatal (int sig) | 606 | sig_fatal (int sig) |
604 | { | 607 | { |
605 | logmsg (L_ERR, "FATAL: exiting on signal %d", sig); | 608 | logmsg (L_ERR, _("FATAL: exiting on signal %d"), sig); |
606 | unlink (pidfile); | 609 | unlink (pidfile); |
607 | exit (EX_UNAVAILABLE); | 610 | exit (EX_UNAVAILABLE); |
@@ -717,5 +720,5 @@ tagr_restart (char **argv) | |||
717 | do \ | 720 | do \ |
718 | if (cond) \ | 721 | if (cond) \ |
719 | die (EX_USAGE, "%s is meaningless with %s", opt, mode_opt); \ | 722 | die (EX_USAGE, _("%s is meaningless with %s"), opt, mode_opt); \ |
720 | while (0) | 723 | while (0) |
721 | 724 | ||
@@ -774,5 +777,5 @@ main (int argc, char **argv) | |||
774 | 777 | ||
775 | if (argc != 0 && !(list_option || import_option)) | 778 | if (argc != 0 && !(list_option || import_option)) |
776 | die (EX_USAGE, "Too many arguments"); | 779 | die (EX_USAGE, _("Too many arguments")); |
777 | 780 | ||
778 | if (readconfig ()) | 781 | if (readconfig ()) |
@@ -896,5 +899,5 @@ main (int argc, char **argv) | |||
896 | 899 | ||
897 | if (daemon (0, 0)) | 900 | if (daemon (0, 0)) |
898 | die (EX_OSERR, "cannot become daemon: %s", strerror (errno)); | 901 | die (EX_OSERR, _("cannot become daemon: %s"), strerror (errno)); |
899 | 902 | ||
900 | if ((fp = fopen (pidfile, "w")) != NULL) |