+extern int protect_args;
+extern int ignore_errors;
+extern int preserve_xattrs;
+extern int kluge_around_eof;
+extern int daemon_over_rsh;
+extern int munge_symlinks;
+extern int sanitize_paths;
+extern int numeric_ids;
+extern int filesfrom_fd;
+extern int remote_protocol;
+extern int protocol_version;
+extern int io_timeout;
+extern int no_detach;
+extern int write_batch;
+extern int default_af_hint;
+extern int logfile_format_has_i;
+extern int logfile_format_has_o_or_i;
+extern mode_t orig_umask;
+extern char *bind_address;
+extern char *config_file;
+extern char *logfile_format;
+extern char *files_from;
+extern char *tmpdir;
+extern struct chmod_mode_struct *chmod_modes;
+extern filter_rule_list daemon_filter_list;
+#ifdef ICONV_OPTION
+extern char *iconv_opt;
+extern iconv_t ic_send, ic_recv;
+#endif
+
+#define MAX_GID_LIST 32
+
+char *auth_user;
+int read_only = 0;
+int module_id = -1;
+struct chmod_mode_struct *daemon_chmod_modes;
+
+/* module_dirlen is the length of the module_dir string when in daemon
+ * mode and module_dir is not "/"; otherwise 0. (Note that a chroot-
+ * enabled module can have a non-"/" module_dir these days.) */
+char *module_dir = NULL;
+unsigned int module_dirlen = 0;
+
+char *full_module_path;
+
+static int rl_nulls = 0;
+
+#ifdef HAVE_SIGACTION
+static struct sigaction sigact;
+#endif
+
+static gid_t gid_list[MAX_GID_LIST];
+static int gid_count = 0;
+
+/* 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().
+ *
+ * After negotiating which module to use and reading the server's
+ * motd, this hands over to client_run(). Telling the server the
+ * module will cause it to chroot/setuid/etc.
+ *
+ * Instead of doing a transfer, the client may at this stage instead
+ * get a listing of remote modules and exit.
+ *
+ * @return -1 for error in startup, or the result of client_run().
+ * Either way, it eventually gets passed to exit_cleanup().
+ **/
+int start_socket_client(char *host, int remote_argc, char *remote_argv[],
+ int argc, char *argv[])