Commit 582831a4 authored by Wayne Davison's avatar Wayne Davison

- Don't require a daemon config &directive to use an equal sign.

- Improved some daemon-config error messages.
parent 312b6841
......@@ -761,7 +761,7 @@ BOOL set_dparams(int syntax_check_only)
*equal = '\0';
if (syntax_check_only) {
if (map_parameter(params[j]) < 0) {
rprintf(FCLIENT, "Unknown parameter \"%s\"\n", params[j]);
rprintf(FERROR, "Unknown parameter \"%s\"\n", params[j]);
*equal = '=';
return False;
}
......
......@@ -225,7 +225,7 @@ static BOOL Section( FILE *InFile, BOOL (*sfunc)(char *) )
bufr[end] = '\0';
if( 0 == end ) /* Don't allow an empty name. */
{
rprintf(FLOG, "%s Empty section name in configuration file.\n", func );
rprintf(FLOG, "%s Empty section name in config file.\n", func );
return( False );
}
if( !sfunc( bufr ) ) /* Got a valid name. Deal with it. */
......@@ -238,7 +238,7 @@ static BOOL Section( FILE *InFile, BOOL (*sfunc)(char *) )
if( i < 0 )
{
bufr[end] = '\0';
rprintf(FLOG, "%s Badly formed line in configuration file: %s\n",
rprintf(FLOG, "%s Badly formed line in config file: %s\n",
func, bufr );
return( False );
}
......@@ -263,7 +263,7 @@ static BOOL Section( FILE *InFile, BOOL (*sfunc)(char *) )
}
/* We arrive here if we've met the EOF before the closing bracket. */
rprintf(FLOG, "%s Unexpected EOF in the configuration file: %s\n", func, bufr );
rprintf(FLOG, "%s Unexpected EOF in the config file: %s\n", func, bufr );
return( False );
} /* Section */
......@@ -317,13 +317,12 @@ static BOOL Parameter( FILE *InFile, BOOL (*pfunc)(char *, char *), int c )
case '=': /* Equal sign marks end of param name. */
if( 0 == end ) /* Don't allow an empty name. */
{
rprintf(FLOG, "%s Invalid parameter name in config. file.\n", func );
rprintf(FLOG, "%s Invalid parameter name in config file.\n", func );
return( False );
}
bufr[end++] = '\0'; /* Mark end of string & advance. */
i = end; /* New string starts here. */
vstart = end; /* New string is parameter value. */
bufr[i] = '\0'; /* New string is nul, for now. */
i = vstart = end; /* New string starts here. */
c = EatWhitespace(InFile);
break;
case '\n': /* Find continuation char, else error. */
......@@ -331,7 +330,7 @@ static BOOL Parameter( FILE *InFile, BOOL (*pfunc)(char *, char *), int c )
if( i < 0 )
{
bufr[end] = '\0';
rprintf(FLOG, "%s Ignoring badly formed line in configuration file: %s\n",
rprintf(FLOG, "%s Ignoring badly formed line in config file: %s\n",
func, bufr );
return( True );
}
......@@ -345,6 +344,19 @@ static BOOL Parameter( FILE *InFile, BOOL (*pfunc)(char *, char *), int c )
rprintf(FLOG, "%s Unexpected end-of-file at: %s\n", func, bufr );
return( True );
case ' ':
case '\t':
/* A directive divides at the first space or tab. */
if (*bufr == '&') {
bufr[end++] = '\0';
i = vstart = end;
c = EatWhitespace(InFile);
if (c == '=')
c = EatWhitespace(InFile);
break;
}
/* FALL THROUGH */
default:
if( isspace( c ) ) /* One ' ' per whitespace region. */
{
......@@ -362,7 +374,6 @@ static BOOL Parameter( FILE *InFile, BOOL (*pfunc)(char *, char *), int c )
}
/* Now parse the value. */
c = EatWhitespace( InFile ); /* Again, trim leading whitespace. */
while( (EOF !=c) && (c > 0) )
{
......@@ -418,8 +429,10 @@ static int include_config(char *include, int manage_globals)
STRUCT_STAT sb;
int ret;
if (do_stat(include, &sb) < 0)
if (do_stat(include, &sb) < 0) {
rsyserr(FLOG, errno, "unable to stat config file \"%s\"", include);
return 0;
}
if (S_ISREG(sb.st_mode)) {
if (manage_globals && the_sfunc)
......@@ -434,8 +447,10 @@ static int include_config(char *include, int manage_globals)
size_t j;
DIR *d;
if (!(d = opendir(include)))
if (!(d = opendir(include))) {
rsyserr(FLOG, errno, "unable to open config dir \"%s\"", include);
return 0;
}
memset(&conf_list, 0, sizeof conf_list);
......@@ -476,11 +491,11 @@ static int include_config(char *include, int manage_globals)
static int parse_directives(char *name, char *val)
{
if (strcasecmp(name, "include") == 0)
if (strcasecmp(name, "&include") == 0)
return include_config(val, 1);
if (strcasecmp(name, "merge") == 0)
if (strcasecmp(name, "&merge") == 0)
return include_config(val, 0);
rprintf(FLOG, "Unknown directive: &%s.\n", name);
rprintf(FLOG, "Unknown directive: %s.\n", name);
return 0;
}
......@@ -541,7 +556,6 @@ static int Parse( FILE *InFile,
case '&': /* Handle directives */
the_sfunc = sfunc;
the_pfunc = pfunc;
c = EatWhitespace( InFile );
c = Parameter( InFile, parse_directives, c );
if (c != 1)
return c;
......@@ -560,7 +574,7 @@ static int Parse( FILE *InFile,
static FILE *OpenConfFile( char *FileName )
/* ------------------------------------------------------------------------ **
* Open a configuration file.
* Open a config file.
*
* Input: FileName - The pathname of the config file to be opened.
*
......@@ -575,14 +589,14 @@ static FILE *OpenConfFile( char *FileName )
if( NULL == FileName || 0 == *FileName )
{
rprintf(FLOG, "%s No configuration filename specified.\n", func);
rprintf(FLOG, "%s No config filename specified.\n", func);
return( NULL );
}
OpenedFile = fopen( FileName, "r" );
if( NULL == OpenedFile )
{
rsyserr(FLOG, errno, "unable to open configuration file \"%s\"",
rsyserr(FLOG, errno, "unable to open config file \"%s\"",
FileName);
}
......
......@@ -630,13 +630,17 @@ manpagesection(CONFIG DIRECTIVES)
There are currently two config directives available that allow a config file to
incorporate the contents of other files: bf(&include) and bf(&merge). Both
allow a reference to either a file or a directory. They differ in how
segregated the file's contents are considered to be. The bf(&include)
directive treats each file as more distinct, with each one inheriting the
defaults of the parent file, and starting the parameter parsing as
globals/defaults. The bf(&merge) directive, on the other hand, treats the
file's contents as if it were simply inserted in place of the directive, and
thus it can contain parameters that can be set inside a parent file's module
settings, or whatever you like.
segregated the file's contents are considered to be.
The bf(&include) directive treats each file as more distinct, with each one
inheriting the defaults of the parent file, starting the parameter parsing
as globals/defaults, and leaving the defaults unchanged for the parsing of
the rest of the parent file.
The bf(&merge) directive, on the other hand, treats the file's contents as
if it were simply inserted in place of the directive, and thus it can set
parameters in a module started in another file, can affect the defaults for
other files, etc.
When an bf(&include) or bf(&merge) directive refers to a directory, it will read
in all the bf(*.conf) files contained inside that directory (without any
......@@ -644,23 +648,23 @@ recursive scanning), with the files sorted into alpha order. So, if you have a
directory named "rsyncd.d" with the files "foo.conf", "bar.conf", and
"baz.conf" inside it, this directive:
verb( &include = /path/rsyncd.d )
verb( &include /path/rsyncd.d )
would be the same as this set of directives:
verb( &include = /path/rsyncd.d/bar.conf
&include = /path/rsyncd.d/baz.conf
&include = /path/rsyncd.d/foo.conf )
verb( &include /path/rsyncd.d/bar.conf
&include /path/rsyncd.d/baz.conf
&include /path/rsyncd.d/foo.conf )
except that it adjusts as files are added and removed from the directory.
The advantage of the bf(&include) directive is that you can define one or more
modules in a separate file with only the defaults you set in the parent file
affecting it, so you don't need to worry about the settings of a prior include
file changing a default. For instance, this is a useful /etc/rsyncd.conf file:
modules in a separate file without worrying about unintended side-effects
between the self-contained module files. For instance, this is a useful
/etc/rsyncd.conf file:
verb( port = 873
log file = /path/rsync.log
log file = /var/log/rsync.log
pid file = /var/lock/rsync.lock
&include /etc/rsyncd.d )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment