Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/git-daemon.txt28
-rw-r--r--daemon.c46
2 files changed, 64 insertions, 10 deletions
diff --git a/Documentation/git-daemon.txt b/Documentation/git-daemon.txt
index 3c91db7bed..56d54a4898 100644
--- a/Documentation/git-daemon.txt
+++ b/Documentation/git-daemon.txt
@@ -20,6 +20,7 @@ SYNOPSIS
[--inetd |
[--listen=<host_or_ipaddr>] [--port=<n>]
[--user=<user> [--group=<group>]]]
+ [--log-destination=(stderr|syslog|none)]
[<directory>...]
DESCRIPTION
@@ -80,7 +81,8 @@ OPTIONS
do not have the 'git-daemon-export-ok' file.
--inetd::
- Have the server run as an inetd service. Implies --syslog.
+ Have the server run as an inetd service. Implies --syslog (may be
+ overridden with `--log-destination=`).
Incompatible with --detach, --port, --listen, --user and --group
options.
@@ -110,8 +112,28 @@ OPTIONS
zero for no limit.
--syslog::
- Log to syslog instead of stderr. Note that this option does not imply
- --verbose, thus by default only error conditions will be logged.
+ Short for `--log-destination=syslog`.
+
+--log-destination=<destination>::
+ Send log messages to the specified destination.
+ Note that this option does not imply --verbose,
+ thus by default only error conditions will be logged.
+ The <destination> must be one of:
++
+--
+stderr::
+ Write to standard error.
+ Note that if `--detach` is specified,
+ the process disconnects from the real standard error,
+ making this destination effectively equivalent to `none`.
+syslog::
+ Write to syslog, using the `git-daemon` identifier.
+none::
+ Disable all logging.
+--
++
+The default destination is `syslog` if `--inetd` or `--detach` is specified,
+otherwise `stderr`.
--user-path::
--user-path=<path>::
diff --git a/daemon.c b/daemon.c
index e37e343d0a..fb538e3678 100644
--- a/daemon.c
+++ b/daemon.c
@@ -9,7 +9,12 @@
#define initgroups(x, y) (0) /* nothing */
#endif
-static int log_syslog;
+static enum log_destination {
+ LOG_DESTINATION_UNSET = -1,
+ LOG_DESTINATION_NONE = 0,
+ LOG_DESTINATION_STDERR = 1,
+ LOG_DESTINATION_SYSLOG = 2,
+} log_destination = LOG_DESTINATION_UNSET;
static int verbose;
static int reuseaddr;
static int informative_errors;
@@ -25,6 +30,7 @@ static const char daemon_usage[] =
" [--access-hook=<path>]\n"
" [--inetd | [--listen=<host_or_ipaddr>] [--port=<n>]\n"
" [--detach] [--user=<user> [--group=<group>]]\n"
+" [--log-destination=(stderr|syslog|none)]\n"
" [<directory>...]";
/* List of acceptable pathname prefixes */
@@ -74,11 +80,14 @@ static const char *get_ip_address(struct hostinfo *hi)
static void logreport(int priority, const char *err, va_list params)
{
- if (log_syslog) {
+ switch (log_destination) {
+ case LOG_DESTINATION_SYSLOG: {
char buf[1024];
vsnprintf(buf, sizeof(buf), err, params);
syslog(priority, "%s", buf);
- } else {
+ break;
+ }
+ case LOG_DESTINATION_STDERR:
/*
* Since stderr is set to buffered mode, the
* logging of different processes will not overlap
@@ -88,6 +97,11 @@ static void logreport(int priority, const char *err, va_list params)
vfprintf(stderr, err, params);
fputc('\n', stderr);
fflush(stderr);
+ break;
+ case LOG_DESTINATION_NONE:
+ break;
+ case LOG_DESTINATION_UNSET:
+ BUG("log destination not initialized correctly");
}
}
@@ -1289,7 +1303,6 @@ int cmd_main(int argc, const char **argv)
}
if (!strcmp(arg, "--inetd")) {
inetd_mode = 1;
- log_syslog = 1;
continue;
}
if (!strcmp(arg, "--verbose")) {
@@ -1297,9 +1310,22 @@ int cmd_main(int argc, const char **argv)
continue;
}
if (!strcmp(arg, "--syslog")) {
- log_syslog = 1;
+ log_destination = LOG_DESTINATION_SYSLOG;
continue;
}
+ if (skip_prefix(arg, "--log-destination=", &v)) {
+ if (!strcmp(v, "syslog")) {
+ log_destination = LOG_DESTINATION_SYSLOG;
+ continue;
+ } else if (!strcmp(v, "stderr")) {
+ log_destination = LOG_DESTINATION_STDERR;
+ continue;
+ } else if (!strcmp(v, "none")) {
+ log_destination = LOG_DESTINATION_NONE;
+ continue;
+ } else
+ die("unknown log destination '%s'", v);
+ }
if (!strcmp(arg, "--export-all")) {
export_all_trees = 1;
continue;
@@ -1356,7 +1382,6 @@ int cmd_main(int argc, const char **argv)
}
if (!strcmp(arg, "--detach")) {
detach = 1;
- log_syslog = 1;
continue;
}
if (skip_prefix(arg, "--user=", &v)) {
@@ -1402,7 +1427,14 @@ int cmd_main(int argc, const char **argv)
usage(daemon_usage);
}
- if (log_syslog) {
+ if (log_destination == LOG_DESTINATION_UNSET) {
+ if (inetd_mode || detach)
+ log_destination = LOG_DESTINATION_SYSLOG;
+ else
+ log_destination = LOG_DESTINATION_STDERR;
+ }
+
+ if (log_destination == LOG_DESTINATION_SYSLOG) {
openlog("git-daemon", LOG_PID, LOG_DAEMON);
set_die_routine(daemon_die);
} else