When using daemon mode over a remote shell program and not running as root,

default the config file to just "rsyncd.conf" in the current directory
instead of /etc/rsyncd.conf.  Also, fix problems with logging messages when
running daemon mode over a remote shell program: it was pretty much doing
the opposite of what it should have, sending early error messages to the
log and later messages to the client.  Switched it around so the very early
error messages go to the client and the later ones go to the log.
This commit is contained in:
David Dykstra
2002-08-30 23:27:26 +00:00
parent d53d7795ee
commit 30e8c8e1e4
8 changed files with 46 additions and 26 deletions

View File

@@ -502,6 +502,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());

View File

@@ -748,6 +748,9 @@ False on failure.
***************************************************************************/
BOOL lp_load(char *pszFname, int globals_only)
{
extern int am_server;
extern int am_daemon;
extern int am_root;
pstring n2;
BOOL bRetval;
@@ -757,7 +760,12 @@ BOOL lp_load(char *pszFname, int globals_only)
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;

24
log.c
View File

@@ -27,6 +27,7 @@
*/
#include "rsync.h"
static int log_initialised;
static char *logfname;
static FILE *logfile;
static int log_error_fd = -1;
@@ -146,12 +147,11 @@ static void logit(int priority, char *buf)
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
@@ -238,16 +238,20 @@ void rwrite(enum logcode code, char *buf, int len)
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;

View File

@@ -108,7 +108,7 @@ int suffix_specified = 0;
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;

View File

@@ -491,8 +491,8 @@ static FILE *OpenConfFile( char *FileName )
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 );

View File

@@ -26,7 +26,8 @@
#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://"

View File

@@ -212,9 +212,12 @@ used to check against the rsyncd.conf on the remote host.
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)
@@ -234,7 +237,7 @@ quote(rsync --server --daemon .)
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) .)
@@ -727,7 +730,7 @@ bf(rsync://host/module/) syntax.
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.
@@ -747,8 +750,10 @@ address (or hostname) to bind to. This makes virtual hosting possible
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.
@@ -1093,7 +1098,7 @@ enddit()
manpagefiles()
/etc/rsyncd.conf
/etc/rsyncd.conf or rsyncd.conf
manpageseealso()

View File

@@ -68,7 +68,7 @@ your system. You will then need to send inetd a HUP signal to tell it to
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)
@@ -127,7 +127,7 @@ of available modules. The default is no comment.
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
@@ -438,7 +438,7 @@ susan:herpass
manpagefiles()
/etc/rsyncd.conf
/etc/rsyncd.conf or rsyncd.conf
manpageseealso()