Optimized away 3 calls to strcmp().
[rsync/rsync.git] / clientserver.c
index 747307f..8a26ed5 100644 (file)
@@ -33,6 +33,7 @@ extern int verbose;
 extern int rsync_port;
 char *auth_user;
 extern int sanitize_paths;
+extern int filesfrom_fd;
 
 /**
  * Run a client connected to an rsyncd.  The alternative to this
@@ -204,7 +205,8 @@ static int rsync_module(int f_in, int f_out, int i)
        uid_t uid = (uid_t)-2;  /* canonically "nobody" */
        gid_t gid = (gid_t)-2;
        char *p;
-       char *addr, *host, addr_buf[128];
+       char *addr = client_addr(f_in);
+       char *host = client_name(f_in);
        char *name = lp_name(i);
        int use_chroot = lp_use_chroot(i);
        int start_glob=0;
@@ -216,25 +218,6 @@ static int rsync_module(int f_in, int f_out, int i)
        extern int remote_version;
        extern int am_root;
 
-       if (is_a_socket(f_in)) {
-               addr = client_addr(f_in);
-               host = client_name(f_in);
-       } else {
-               char *ssh_client = getenv("SSH_CLIENT");
-               if (ssh_client) {
-                       strlcpy(addr_buf, ssh_client, sizeof(addr_buf));
-                       /* truncate SSH_CLIENT to just IP address */
-                       p = strchr(addr_buf, ' ');
-                       if (p)
-                               *p = '\0';
-                       addr = addr_buf;
-                       host = "remote.shell.connection";
-               } else {
-                       addr = "0.0.0.0";
-                       host = "remote.shell.connection";
-               }
-       }
-
        if (!allow_access(addr, host, lp_hosts_allow(i), lp_hosts_deny(i))) {
                rprintf(FERROR,"rsync denied on module %s from %s (%s)\n",
                        name, host, addr);
@@ -442,6 +425,9 @@ static int rsync_module(int f_in, int f_out, int i)
         argp = argv;
        ret = parse_arguments(&argc, (const char ***) &argp, 0);
 
+       if (filesfrom_fd == 0)
+               filesfrom_fd = f_in;
+
        if (request) {
                if (*auth_user) {
                        rprintf(FINFO,"rsync %s %s from %s@%s (%s)\n",
@@ -520,6 +506,8 @@ int start_daemon(int f_in, int f_out)
                exit_cleanup(RERR_SYNTAX);
        }
 
+       log_init();
+
        if (!am_server) {
                set_socket_options(f_in, "SO_KEEPALIVE");
                set_socket_options(f_in, lp_socket_options());