Code

Merge branch 'rs/blame'
[git.git] / daemon.c
index c315932ced825f96f669003616a9fb304309c75d..b9ba44c582b3b6cfac0f150f7f8901d60b48bbb3 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -537,6 +537,10 @@ static int execute(struct sockaddr *addr)
 #endif
                }
                loginfo("Connection from %s:%d", addrbuf, port);
+               setenv("REMOTE_ADDR", addrbuf, 1);
+       }
+       else {
+               unsetenv("REMOTE_ADDR");
        }
 
        alarm(init_timeout ? init_timeout : timeout);
@@ -1083,7 +1087,8 @@ int main(int argc, char **argv)
                openlog("git-daemon", LOG_PID, LOG_DAEMON);
                set_die_routine(daemon_die);
        } else
-               setlinebuf(stderr); /* avoid splitting a message in the middle */
+               /* avoid splitting a message in the middle */
+               setvbuf(stderr, NULL, _IOLBF, 0);
 
        if (inetd_mode && (group_name || user_name))
                die("--user and --group are incompatible with --inetd");
@@ -1115,13 +1120,9 @@ int main(int argc, char **argv)
        if (strict_paths && (!ok_paths || !*ok_paths))
                die("option --strict-paths requires a whitelist");
 
-       if (base_path) {
-               struct stat st;
-
-               if (stat(base_path, &st) || !S_ISDIR(st.st_mode))
-                       die("base-path '%s' does not exist or "
-                           "is not a directory", base_path);
-       }
+       if (base_path && !is_directory(base_path))
+               die("base-path '%s' does not exist or is not a directory",
+                   base_path);
 
        if (inetd_mode) {
                struct sockaddr_storage ss;