+ 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;
+ int ret;
+ char *request=NULL;
+ extern int am_sender;
+ extern int am_server;
+ extern int am_daemon;
+ extern int remote_version;
+ extern int am_root;
+
+ 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);
+ io_printf(f_out, "@ERROR: access denied to %s from %s (%s)\n",
+ name, host, addr);
+ return -1;
+ }
+
+ if (am_daemon && am_server) {
+ rprintf(FINFO, "rsync allowed access on module %s from %s (%s)\n",
+ name, host, addr);
+ }
+
+ if (!claim_connection(lp_lock_file(i), lp_max_connections(i))) {
+ if (errno) {
+ rprintf(FERROR,"failed to open lock file %s : %s\n",
+ lp_lock_file(i), strerror(errno));
+ io_printf(f_out, "@ERROR: failed to open lock file %s : %s\n",
+ lp_lock_file(i), strerror(errno));
+ } else {
+ rprintf(FERROR,"max connections (%d) reached\n",
+ lp_max_connections(i));
+ io_printf(f_out, "@ERROR: max connections (%d) reached - try again later\n", lp_max_connections(i));
+ }
+ return -1;
+ }
+
+
+ auth_user = auth_server(f_in, f_out, i, addr, "@RSYNCD: AUTHREQD ");
+
+ if (!auth_user) {
+ rprintf(FERROR,"auth failed on module %s from %s (%s)\n",
+ name, host, addr);
+ io_printf(f_out, "@ERROR: auth failed on module %s\n", name);
+ return -1;
+ }