{"thread":{"id":"1934","subject":"[PATCH 0/4] Minor git-daemon enhancements","startedAt":"2005-09-24T14:12:54Z","lastAt":"2005-09-24T14:13:03Z","messageCount":5,"participants":["Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"9225","messageId":"20050924141254.8423.80265.stgit@machine.or.cz","threadId":"1934","inReplyTo":null,"subject":"[PATCH 0/4] Minor git-daemon enhancements","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2005-09-24T14:12:54Z","receivedAt":"2005-09-24T14:12:54Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"The following series contains some minor git-daemon enhancements,\nbased on the input from the mailing list.\n\nAnd I'm also playing with StGIT. ;-)\n\n-- \nAnd on the eigth day, God started debugging.\n"},{"id":"9228","messageId":"20050924141256.8423.53339.stgit@machine.or.cz","threadId":"1934","inReplyTo":"20050924141254.8423.80265.stgit@machine.or.cz","subject":"[PATCH 1/4] Fix git-daemon's pid_t logging","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2005-09-24T14:12:56Z","receivedAt":"2005-09-24T14:12:56Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"git-daemon's logging code did not properly printf() pid_t - we need\nto explicitly typecast it, since it might not be int. Pointed out\nby Morten Welinder.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n---\n\n daemon.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/daemon.c b/daemon.c\n--- a/daemon.c\n+++ b/daemon.c\n@@ -22,7 +22,7 @@ static void logreport(const char *err, v\n \tint maxlen, msglen;\n \n \t/* sizeof(buf) should be big enough for \"[pid] \\n\" */\n-\tbuflen = snprintf(buf, sizeof(buf), \"[%d] \", getpid());\n+\tbuflen = snprintf(buf, sizeof(buf), \"[%ld] \", (long) getpid());\n \n \tmaxlen = sizeof(buf) - buflen - 1; /* -1 for our own LF */\n \tmsglen = vsnprintf(buf + buflen, maxlen, err, params);\n"},{"id":"9226","messageId":"20050924141258.8423.21470.stgit@machine.or.cz","threadId":"1934","inReplyTo":"20050924141254.8423.80265.stgit@machine.or.cz","subject":"[PATCH 2/4] Update git-daemon documentation wrt. the --verbose parameter","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2005-09-24T14:12:58Z","receivedAt":"2005-09-24T14:12:58Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Signed-off-by: Petr Baudis <pasky@suse.cz>\n---\n\n Documentation/git-daemon.txt |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-daemon.txt b/Documentation/git-daemon.txt\n--- a/Documentation/git-daemon.txt\n+++ b/Documentation/git-daemon.txt\n@@ -7,7 +7,7 @@ git-daemon - A really simple server for \n \n SYNOPSIS\n --------\n-'git-daemon' [--inetd | --port=n]\n+'git-daemon' [--verbose] [--inetd | --port=n]\n \n DESCRIPTION\n -----------\n@@ -32,6 +32,9 @@ OPTIONS\n --port::\n \tListen on an alternative port.\n \n+--verbose::\n+\tLog details about the incoming connections and requested files.\n+\n Author\n ------\n Written by Linus Torvalds <torvalds@osdl.org> and YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>\n"},{"id":"9227","messageId":"20050924141300.8423.36900.stgit@machine.or.cz","threadId":"1934","inReplyTo":"20050924141254.8423.80265.stgit@machine.or.cz","subject":"[PATCH 3/4] git-daemon --syslog to log through syslog","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2005-09-24T14:13:01Z","receivedAt":"2005-09-24T14:13:01Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Well, this makes it even more clear that we need the packet reader and\nfriends to use the daemon logging code. :/  Therefore, we at least indicate\nin the \"Disconnect\" log message if the child process exitted with an error\ncode or not.\n\nIdea by Linus.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n---\n\n Documentation/git-daemon.txt |    6 +++++-\n daemon.c                     |   34 +++++++++++++++++++++++++++-------\n 2 files changed, 32 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-daemon.txt b/Documentation/git-daemon.txt\n--- a/Documentation/git-daemon.txt\n+++ b/Documentation/git-daemon.txt\n@@ -7,7 +7,7 @@ git-daemon - A really simple server for \n \n SYNOPSIS\n --------\n-'git-daemon' [--verbose] [--inetd | --port=n]\n+'git-daemon' [--verbose] [--syslog] [--inetd | --port=n]\n \n DESCRIPTION\n -----------\n@@ -32,6 +32,10 @@ OPTIONS\n --port::\n \tListen on an alternative port.\n \n+--syslog::\n+\tLog to syslog instead of stderr. Note that this option does not imply\n+\t--verbose, thus by default only error conditions will be logged.\n+\n --verbose::\n \tLog details about the incoming connections and requested files.\n \ndiff --git a/daemon.c b/daemon.c\n--- a/daemon.c\n+++ b/daemon.c\n@@ -7,13 +7,15 @@\n #include <netdb.h>\n #include <netinet/in.h>\n #include <arpa/inet.h>\n+#include <syslog.h>\n \n+static int log_syslog;\n static int verbose;\n \n-static const char daemon_usage[] = \"git-daemon [--verbose] [--inetd | --port=n]\";\n+static const char daemon_usage[] = \"git-daemon [--verbose] [--syslog] [--inetd | --port=n]\";\n \n \n-static void logreport(const char *err, va_list params)\n+static void logreport(int priority, const char *err, va_list params)\n {\n \t/* We should do a single write so that it is atomic and output\n \t * of several processes do not get intermingled. */\n@@ -27,6 +29,11 @@ static void logreport(const char *err, v\n \tmaxlen = sizeof(buf) - buflen - 1; /* -1 for our own LF */\n \tmsglen = vsnprintf(buf + buflen, maxlen, err, params);\n \n+\tif (log_syslog) {\n+\t\tsyslog(priority, \"%s\", buf);\n+\t\treturn;\n+\t}\n+\n \t/* maxlen counted our own LF but also counts space given to\n \t * vsnprintf for the terminating NUL.  We want to make sure that\n \t * we have space for our own LF and NUL after the \"meat\" of the\n@@ -48,7 +55,7 @@ void logerror(const char *err, ...)\n {\n \tva_list params;\n \tva_start(params, err);\n-\tlogreport(err, params);\n+\tlogreport(LOG_ERR, err, params);\n \tva_end(params);\n }\n \n@@ -58,7 +65,7 @@ void lognotice(const char *err, ...)\n \tif (!verbose)\n \t\treturn;\n \tva_start(params, err);\n-\tlogreport(err, params);\n+\tlogreport(LOG_INFO, err, params);\n \tva_end(params);\n }\n \n@@ -285,15 +292,23 @@ static void handle(int incoming, struct \n static void child_handler(int signo)\n {\n \tfor (;;) {\n-\t\tpid_t pid = waitpid(-1, NULL, WNOHANG);\n+\t\tint status;\n+\t\tpid_t pid = waitpid(-1, &status, WNOHANG);\n \n \t\tif (pid > 0) {\n \t\t\tunsigned reaped = children_reaped;\n \t\t\tdead_child[reaped % MAX_CHILDREN] = pid;\n \t\t\tchildren_reaped = reaped + 1;\n \t\t\t/* XXX: Custom logging, since we don't wanna getpid() */\n-\t\t\tif (verbose)\n-\t\t\t\tfprintf(stderr, \"[%d] Disconnected\\n\", pid);\n+\t\t\tif (verbose) {\n+\t\t\t\tchar *dead = \"\";\n+\t\t\t\tif (!WIFEXITED(status) || WEXITSTATUS(status) > 0)\n+\t\t\t\t\tdead = \" (with error)\";\n+\t\t\t\tif (log_syslog)\n+\t\t\t\t\tsyslog(LOG_INFO, \"[%d] Disconnected%s\", pid, dead);\n+\t\t\t\telse\n+\t\t\t\t\tfprintf(stderr, \"[%d] Disconnected%s\\n\", pid, dead);\n+\t\t\t}\n \t\t\tcontinue;\n \t\t}\n \t\tbreak;\n@@ -435,6 +450,11 @@ int main(int argc, char **argv)\n \t\t\tverbose = 1;\n \t\t\tcontinue;\n \t\t}\n+\t\tif (!strcmp(arg, \"--syslog\")) {\n+\t\t\tlog_syslog = 1;\n+\t\t\topenlog(\"git-daemon\", 0, LOG_DAEMON);\n+\t\t\tcontinue;\n+\t\t}\n \n \t\tusage(daemon_usage);\n \t}\n"},{"id":"9229","messageId":"20050924141303.8423.54292.stgit@machine.or.cz","threadId":"1934","inReplyTo":"20050924141254.8423.80265.stgit@machine.or.cz","subject":"[PATCH 4/4] Rename daemon.c's lognotice() to loginfo()","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2005-09-24T14:13:03Z","receivedAt":"2005-09-24T14:13:03Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"The syslog code logs with severity LOG_INFO in the loginfo() function, so make\nthings less confusing.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n---\n\n daemon.c |    6 +++---\n 1 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/daemon.c b/daemon.c\n--- a/daemon.c\n+++ b/daemon.c\n@@ -59,7 +59,7 @@ void logerror(const char *err, ...)\n \tva_end(params);\n }\n \n-void lognotice(const char *err, ...)\n+void loginfo(const char *err, ...)\n {\n \tva_list params;\n \tif (!verbose)\n@@ -72,7 +72,7 @@ void lognotice(const char *err, ...)\n \n static int upload(char *dir, int dirlen)\n {\n-\tlognotice(\"Request for '%s'\", dir);\n+\tloginfo(\"Request for '%s'\", dir);\n \tif (chdir(dir) < 0) {\n \t\tlogerror(\"Cannot chdir('%s'): %s\", dir, strerror(errno));\n \t\treturn -1;\n@@ -284,7 +284,7 @@ static void handle(int incoming, struct \n \n \t\tport = sin6_addr->sin6_port;\n \t}\n-\tlognotice(\"Connection from %s:%d\", addrbuf, port);\n+\tloginfo(\"Connection from %s:%d\", addrbuf, port);\n \n \texit(execute());\n }\n"}]}