Check the right flist_num in gen_wants_ndx().
[rsync/rsync.git] / clientserver.c
index 5002959..059be75 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 1998-2001 Andrew Tridgell <tridge@samba.org>
  * Copyright (C) 2001-2002 Martin Pool <mbp@samba.org>
- * Copyright (C) 2002-2008 Wayne Davison
+ * Copyright (C) 2002-2009 Wayne Davison
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -81,6 +81,9 @@ static int rl_nulls = 0;
 static struct sigaction sigact;
 #endif
 
+/* Used when "reverse lookup" is off. */
+const char undetermined_hostname[] = "UNDETERMINED";
+
 /**
  * Run a client connected to an rsyncd.  The alternative to this
  * function for remote-shell connections is do_cmd().
@@ -405,7 +408,7 @@ static int path_failure(int f_out, const char *dir, BOOL was_chdir)
        return -1;
 }
 
-static int rsync_module(int f_in, int f_out, int i, char *addr, char *host)
+static int rsync_module(int f_in, int f_out, int i, const char *addr, const char *host)
 {
        int argc;
        char **argv, **orig_argv, **orig_early_argv, *module_chdir;
@@ -427,6 +430,11 @@ static int rsync_module(int f_in, int f_out, int i, char *addr, char *host)
        iconv_opt = NULL;
 #endif
 
+       /* If reverse lookup is disabled globally but enabled for this module,
+        * we need to do it now before the access check. */
+       if (host == undetermined_hostname && lp_reverse_lookup(i))
+               host = client_name(f_in);
+
        if (!allow_access(addr, host, lp_hosts_allow(i), lp_hosts_deny(i))) {
                rprintf(FLOG, "rsync denied on module %s from %s (%s)\n",
                        name, host, addr);
@@ -914,7 +922,7 @@ static int load_config(int globals_only)
 int start_daemon(int f_in, int f_out)
 {
        char line[1024];
-       char *addr, *host;
+       const char *addr, *host;
        int i;
 
        io_set_sock_fds(f_in, f_out);
@@ -927,7 +935,7 @@ int start_daemon(int f_in, int f_out)
                exit_cleanup(RERR_SYNTAX);
 
        addr = client_addr(f_in);
-       host = client_name(f_in);
+       host = lp_reverse_lookup(-1) ? client_name(f_in) : undetermined_hostname;
        rprintf(FLOG, "connect from %s (%s)\n", host, addr);
 
        if (!am_server) {