aboutsummaryrefslogtreecommitdiff
path: root/src/wydawca.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/wydawca.c')
-rw-r--r--src/wydawca.c112
1 files changed, 56 insertions, 56 deletions
diff --git a/src/wydawca.c b/src/wydawca.c
index ce78fc1..cc6c8f0 100644
--- a/src/wydawca.c
+++ b/src/wydawca.c
@@ -29,12 +29,22 @@ int syslog_include_prio; /* syslog messages include priority */
unsigned long print_stats; /* Print final statistics output */
time_t file_sweep_time = 0;
char *tar_command_name = "tar";
int archive_signatures = 1; /* Archive sig files by default */
int lint_mode = 0;
int preprocess_only = 0;
+int cron_option = 0;
+int foreground_option = -1;
+int single_process_option = -1;
+
+int daemon_mode = 0;
+int foreground;
+int single_process;
+time_t wakeup_interval;
+
+struct gconf_sockaddr listen_sockaddr;
unsigned wydawca_stat[MAX_STAT];
/* Logging */
void
@@ -103,52 +113,26 @@ logmsg (int prio, char *fmt, ...)
va_start (ap, fmt);
log_printer (prio, fmt, ap);
va_end (ap);
}
-
-enum {
- SYSLOG_OPTION = 256,
- CONFIG_HELP_OPTION,
- DUMP_GRAMMAR_TRACE_OPTION,
- DUMP_LEX_TRACE_OPTION
-};
-
-struct option options[] = {
- { "config-file", required_argument, NULL, 'c' },
- { "config-help", no_argument, NULL, CONFIG_HELP_OPTION },
- { "dump-grammar-trace", no_argument, NULL, DUMP_GRAMMAR_TRACE_OPTION },
- { "dump-lex-trace", no_argument, NULL, DUMP_LEX_TRACE_OPTION },
- { "debug", no_argument, NULL, 'd' },
- { "stderr", no_argument, NULL, 'e' },
- { "syslog", no_argument, NULL, SYSLOG_OPTION },
- { "cron", no_argument, NULL, SYSLOG_OPTION },
- { "help", no_argument, NULL, 'h' },
- { "version", no_argument, NULL, 'v' },
- { "dry-run", no_argument, NULL, 'n' },
- { "lint", no_argument, NULL, 't' },
- { "include-directory", optional_argument, NULL, 'I' },
- { NULL }
-};
-
-
static char *stat_name[MAX_STAT] = {
- "errors",
- "warnings",
- "bad signatures",
- "access violation attempts",
- "complete triplets",
- "incomplete triplets",
- "bad triplets",
- "expired triplets",
- "triplet successes",
- "files uploaded",
- "files archived",
- "symlinks created",
- "symlinks removed",
+ N_("errors"),
+ N_("warnings"),
+ N_("bad signatures"),
+ N_("access violation attempts"),
+ N_("complete triplets"),
+ N_("incomplete triplets"),
+ N_("bad triplets"),
+ N_("expired triplets"),
+ N_("triplet successes"),
+ N_("files uploaded"),
+ N_("files archived"),
+ N_("symlinks created"),
+ N_("symlinks removed"),
};
static char *stat_kwname[MAX_STAT] = {
"stat:errors",
"stat:warnings",
"stat:bad_signatures",
@@ -209,13 +193,13 @@ logstats ()
int i;
if (stat_mask_p (print_stats))
{
for (i = 0; i < MAX_STAT; i++)
if (print_stats & STAT_MASK (i))
- logmsg (LOG_INFO, "%s: %u", stat_name[i], wydawca_stat[i]);
+ logmsg (LOG_INFO, "%s: %u", gettext (stat_name[i]), wydawca_stat[i]);
}
mail_stats ();
}
@@ -241,13 +225,13 @@ gconf_print_diag (gconf_locus_t *locus, int err, int errcode, const char *msg)
logmsg (err ? LOG_ERR : LOG_WARNING, "%s", msg);
}
}
static int uidc;
-static char *uidv;
+static uid_t *uidv;
static int
collect_uids (int argc, char **argv)
{
int i;
@@ -269,24 +253,12 @@ collect_uids (int argc, char **argv)
}
else
uidv[i] = pw->pw_uid;
}
}
-int
-match_uid_p (uid_t uid)
-{
- int i;
- if (!uidv)
- return 1;
- for (i = 0; i < uidc; i++)
- if (uidv[i] == uid)
- return 1;
- return 0;
-}
-
int
wydawca_uid (uid_t uid)
{
int rc;
@@ -305,12 +277,27 @@ wydawca_uid (uid_t uid)
logmsg (LOG_ERR, _("cannot switch to UID %d: %s (r=%d, e=%d)"),
uid, strerror (errno), getuid (), geteuid ());
return rc;
}
+void
+wydawca_daemon ()
+{
+ check_pidfile ();
+
+ if (!foreground && daemon (0, 0))
+ {
+ logmsg (LOG_ERR, "%s", strerror (errno));
+ exit (1);
+ }
+
+ wydawca_listener ();
+}
+
+
#include "cmdline.h"
int
main (int argc, char **argv)
{
program_name = argv[0];
@@ -330,28 +317,41 @@ main (int argc, char **argv)
gconf_parse (conffile);
if (lint_mode)
exit (0);
+ if (cron_option)
+ daemon_mode = 0;
+ if (foreground_option >= 0)
+ foreground = foreground_option;
+ if (single_process_option >= 0)
+ single_process = single_process_option;
+
if (log_to_stderr == -1)
- log_to_stderr = isatty (0);
+ log_to_stderr = (!daemon_mode || foreground) && isatty (0);
gconf_log_to_stderr = log_to_stderr;
if (!log_to_stderr)
{
openlog (syslog_tag, LOG_PID, log_facility);
log_printer = syslog_printer;
}
mail_init ();
logmsg (LOG_NOTICE, _("wydawca (%s) started"), PACKAGE_STRING);
- scan_directories ();
+ if (!daemon_mode)
+ {
+ scan_directories (uidc, uidv);
+ logstats ();
+ }
+ else
+ wydawca_daemon ();
+
logmsg (LOG_NOTICE, _("wydawca (%s) finished"), PACKAGE_STRING);
- logstats ();
mail_finish ();
exit (0);
}

Return to:

Send suggestions and report system problems to the System administrator.