exit_cleanup(RERR_SYNTAX);
}
+ log_init();
+
if (!am_server) {
set_socket_options(f_in, "SO_KEEPALIVE");
set_socket_options(f_in, lp_socket_options());
***************************************************************************/
BOOL lp_load(char *pszFname, int globals_only)
{
+ extern int am_server;
+ extern int am_daemon;
+ extern int am_root;
pstring n2;
BOOL bRetval;
init_globals();
- pstrcpy(n2,pszFname);
+ if (pszFname)
+ pstrcpy(n2,pszFname);
+ else if (am_server && am_daemon && !am_root)
+ pstrcpy(n2,RSYNCD_USERCONF);
+ else
+ pstrcpy(n2,RSYNCD_SYSCONF);
/* We get sections first, so have to start 'behind' to make up */
iServiceIndex = -1;
*/
#include "rsync.h"
+static int log_initialised;
static char *logfname;
static FILE *logfile;
static int log_error_fd = -1;
void log_init(void)
{
- static int initialised;
int options = LOG_PID;
time_t t;
- if (initialised) return;
- initialised = 1;
+ if (log_initialised) return;
+ log_initialised = 1;
/* this looks pointless, but it is needed in order for the
C library on some systems to fetch the timezone info
return;
}
- /* If that fails, try to pass it to the other end.
- *
- * io_multiplex_write can fail if we do not have a multiplexed
- * connection at the moment, in which case we fall through and
- * log locally instead. */
- if (am_server && io_multiplex_write(code, buf, len)) {
+ /* next, if we are a server but not in daemon mode, and multiplexing
+ * is enabled, pass it to the other side. */
+ if (am_server && !am_daemon && io_multiplex_write(code, buf, len)) {
return;
}
- if (am_daemon) {
+ /* otherwise, if in daemon mode and either we are not a server
+ * (that is, we are not running --daemon over a remote shell) or
+ * the log has already been initialised, log the message on this
+ * side because we don't want the client to see most errors for
+ * security reasons. We do want early messages when running daemon
+ * mode over a remote shell to go to the remote side; those will
+ * fall through to the next case. */
+ if (am_daemon && (!am_server || log_initialised)) {
static int depth;
int priority = LOG_INFO;
if (code == FERROR) priority = LOG_WARNING;
char *backup_suffix = BACKUP_SUFFIX;
char *tmpdir = NULL;
char *compare_dest = NULL;
-char *config_file = RSYNCD_CONF;
+char *config_file = NULL;
char *shell_cmd = NULL;
char *log_format = NULL;
char *password_file = NULL;
OpenedFile = fopen( FileName, "r" );
if( NULL == OpenedFile )
{
- rprintf(FERROR,"%s Unable to open configuration file \"%s\":\n\t%s\n",
- func, FileName, strerror(errno));
+ rprintf(FERROR,"rsync: unable to open configuration file \"%s\": %s\n",
+ FileName, strerror(errno));
}
return( OpenedFile );
#define RSYNC_RSH_ENV "RSYNC_RSH"
#define RSYNC_NAME "rsync"
-#define RSYNCD_CONF "/etc/rsyncd.conf"
+#define RSYNCD_SYSCONF "/etc/rsyncd.conf"
+#define RSYNCD_USERCONF "rsyncd.conf"
#define DEFAULT_LOCK_FILE "/var/run/rsyncd.lock"
#define URL_PREFIX "rsync://"
manpagesection(RUNNING AN RSYNC SERVER)
-An rsync server is configured using a config file which by default is
-called /etc/rsyncd.conf. Please see the rsyncd.conf(5) man page for more
-information.
+An rsync server is configured using a config file. Please see the
+rsyncd.conf(5) man page for more information. By default the configuration
+file is called /etc/rsyncd.conf, unless rsync is running over a remote
+shell program and is not running as root; in that case, the default name
+is rsyncd.conf in the current directory on the remote computer
+(typically $HOME).
manpagesection(RUNNING AN RSYNC SERVER OVER A REMOTE SHELL PROGRAM)
NOTE: rsync's argument parsing expects the trailing ".", so make sure
that it's there. If you want to use a rsyncd.conf(5)-style
-configuration file other than /etc/rsyncd.conf, you can added a
+configuration file other than the default, you can added a
--config-file option to the em(command):
quote(rsync --server --daemon --config-file=em(file) .)
If standard input is a socket then rsync will assume that it is being
run via inetd, otherwise it will detach from the current terminal and
become a background daemon. The daemon will read the config file
-(/etc/rsyncd.conf) on each connect made by a client and respond to
+(rsyncd.conf) on each connect made by a client and respond to
requests accordingly. See the rsyncd.conf(5) man page for more
details.
in conjunction with the --config option.
dit(bf(--config=FILE)) This specifies an alternate config file than
-the default /etc/rsyncd.conf. This is only relevant when --daemon is
-specified.
+the default. This is only relevant when --daemon is specified.
+The default is /etc/rsyncd.conf unless the daemon is running over
+a remote shell program and the remote user is not root; in that case
+the default is rsyncd.conf in the current directory (typically $HOME).
dit(bf(--port=PORT)) This specifies an alternate TCP port number to use
rather than the default port 873.
manpagefiles()
-/etc/rsyncd.conf
+/etc/rsyncd.conf or rsyncd.conf
manpageseealso()
reread its config file.
Note that you should not send the rsync server a HUP signal to force
-it to reread the tt(/etc/rsyncd.conf). The file is re-read on each client
+it to reread the tt(rsyncd.conf) file. The file is re-read on each client
connection.
manpagesection(GLOBAL OPTIONS)
dit(bf(path)) The "path" option specifies the directory in the servers
filesystem to make available in this module. You must specify this option
-for each module in tt(/etc/rsyncd.conf).
+for each module in tt(rsyncd.conf).
dit(bf(use chroot)) If "use chroot" is true, the rsync server will chroot
to the "path" before starting the file transfer with the client. This has
manpagefiles()
-/etc/rsyncd.conf
+/etc/rsyncd.conf or rsyncd.conf
manpageseealso()