Re: "-otaperscan=XXX" override prevents reading of CONFIG/amanda.conf
Jean-Louis Martineau <[email protected]> Fri, 10 Nov 2017 08:14:31 -0500
| Newsgroups | gmane.comp.archivers.amanda.devel |
|---|---|
| Message-ID | <[email protected]> |
Nathan,
You are too late, I say that problem last week and started to work on a fix.
I just finished the patch, can you try it?
Jean-Louis
On 10/11/17 02:01 AM, Nathan Stratton Treadway wrote:
> (Testing with amanda v3.5.)
>
> It seems that using "-otaperscan=XXX" on an amanda-utility command
> line causes
> the conffile subsystem to skip reading CONFIG/amanda.conf for some
> reason.
>
> I am using a config file based on the examples/amanda.conf file, and it
> defines three taper scans like this:
> =====
> define taperscan taper_traditional {
> comment "traditional"
> plugin "traditional"
> }
> define taperscan taper_oldest {
> comment "oldest"
> plugin "oldest"
> }
> define taperscan taper_lexical {
> comment "lexical"
> plugin "lexical"
> }
> taperscan "taper_lexical"
> =====
>
> This seems to work fine, and in particular using amgetconf I can both
> get the global "taperscan" value and access the defined taperscans:
>
> =====
> # amgetconf TestBackup taperscan
> taper_lexical
> # amgetconf TestBackup taperscan:taper_lexical:comment
> lexical
> # amgetconf TestBackup taperscan:taper_oldest:comment
> oldest
> =====
>
> However, if I try to use -otaperscan= to chose a new taperscan (or even
> just choose taper_lexical again), I get an error that the named taperscan
> can't be found.
> =====
> # amgetconf TestBackup taperscan:taper_oldest:comment
> -otaperscan=taper_lexical
> argument '"taper_lexical"': Unknown taperscan named: taper_lexical
> argument '"taper_lexical"': Unknown taperscan named: taper_lexical
> amgetconf: errors processing config file at /usr/sbin/amgetconf line 363.
>
> # amgetconf TestBackup taperscan:taper_oldest:comment
> -otaperscan=taper_oldest
> argument '"taper_oldest"': Unknown taperscan named: taper_oldest
> argument '"taper_oldest"': Unknown taperscan named: taper_oldest
> amgetconf: errors processing config file at /usr/sbin/amgetconf line 363.
> =====
>
> However, if I use -o to re-define some other variable, I don't get this
> error:
> =====
> # amgetconf TestBackup taperscan:taper_oldest:comment -onetusage=3
> oldest
> =====
>
> (I first noticed the problem running the "amtape" command, and duplicated
> it with "amcheck" as well, so it's not limited to a particular command.)
>
> Interestingly, if I run the command under strace, I see that in the
> failure case it never opens TestBackup/amanda.conf -- which certainly
> explains why "taper_lexical" is not defined...:
>
> =====
> # strace amgetconf TestBackup taperscan:taper_oldest:comment
> -otaperscan=taper_lexical 2>&1 | grep "amanda.conf"
> open("/etc/amanda/amanda.conf", O_RDONLY) = -1 ENOENT (No such file or
> directory)
> # strace amgetconf TestBackup taperscan:taper_oldest:comment
> -onetusage=3 2>&1 | grep "amanda.conf"
> open("/etc/amanda/amanda.conf", O_RDONLY) = -1 ENOENT (No such file or
> directory)
> open("/etc/amanda/TestBackup/amanda.conf", O_RDONLY) = 3
> read(3, "# amanda.conf - sample Amanda co"..., 4096) = 4096
> =====
>
>
> Nathan
>
> ----------------------------------------------------------------------------
> Nathan Stratton Treadway - [email protected] - Mid-Atlantic region
> Ray Ontko & Co. - Software consulting services - http://www.ontko.com/
> <http://www.ontko.com/>
> GPG Key: http://www.ontko.com/~nathanst/gpg_key.txt
> <http://www.ontko.com/~nathanst/gpg_key.txt>
> ID: 1023D/ECFB6239
> Key fingerprint = 6AD8 485E 20B9 5C71 231C 0C32 15F3 ADCD ECFB 6239
This message is the property of CARBONITE, INC. and may contain confidential or privileged information.
If this message has been delivered to you by mistake, then do not copy or deliver this message to anyone. Instead, destroy it and notify me by reply e-mail
override-error.diff
(text/x-patch, 3.1 KB)
diff --git a/common-src/conffile.c b/common-src/conffile.c
index 851ebd7..037b6ef 100644
--- a/common-src/conffile.c
+++ b/common-src/conffile.c
@@ -442,6 +442,7 @@ struct catalog_s {
/* The current parser table */
static conf_var_t *parsetable = NULL;
+static gboolean generate_errors = TRUE;
/* Read and parse a configuration file, recursively reading any included
* files. This function sets the keytable and parsetable appropriately
@@ -6133,7 +6134,8 @@ config_init_with_global(
char *arg_config_name)
{
cfgerr_level_t cfgerr_level;
- cfgerr_level = config_init(flags|CONFIG_INIT_GLOBAL, arg_config_name);
+ cfgerr_level = config_init(flags|CONFIG_INIT_GLOBAL|CONFIG_OVERRDIDE_NO_ERROR, arg_config_name);
+ //cfgerr_level = config_init(flags|CONFIG_INIT_GLOBAL, arg_config_name);
if (config_errors(NULL) >= CFGERR_WARNINGS) {
return cfgerr_level;
}
@@ -6145,6 +6147,7 @@ config_init(
config_init_flags flags,
char *arg_config_name)
{
+ generate_errors = TRUE;
if (!(flags & CONFIG_INIT_OVERLAY)) {
/* Clear out anything that's already in there */
config_uninit();
@@ -6228,7 +6231,9 @@ config_init(
}
/* apply config overrides to default setting */
+ generate_errors = FALSE;
apply_config_overrides(config_overrides, NULL);
+ generate_errors = TRUE;
/* If we have a config_dir, we can try reading something */
if (config_dir) {
@@ -6254,7 +6259,9 @@ config_init(
}
/* apply config overrides to default setting */
+ generate_errors = !(flags & CONFIG_OVERRDIDE_NO_ERROR);
apply_config_overrides(config_overrides, NULL);
+ generate_errors = TRUE;
if (!(flags & CONFIG_INIT_GLOBAL) || !arg_config_name) {
if (config_overrides) {
@@ -10839,9 +10846,14 @@ static void conf_error_common(
const char * format,
va_list argp)
{
- char *msg = g_strdup_vprintf(format, argp);
+ char *msg = NULL;
char *errstr = NULL;
+ if (!generate_errors)
+ return;
+
+ msg = g_strdup_vprintf(format, argp);
+
if(current_line)
errstr = g_strdup_printf(_("argument '%s': %s"),
current_line, msg);
diff --git a/common-src/conffile.h b/common-src/conffile.h
index f4ac0c7..0ab0421 100644
--- a/common-src/conffile.h
+++ b/common-src/conffile.h
@@ -1800,6 +1800,9 @@ typedef enum {
/* Load the global config */
CONFIG_INIT_GLOBAL = 1 << 4,
+
+ /* Do not generate errors (internal use) */
+ CONFIG_OVERRDIDE_NO_ERROR = 1 << 5,
} config_init_flags;
/* Initialize this application's configuration, with the specific actions
diff --git a/perl/Amanda/Config.swg b/perl/Amanda/Config.swg
index 83ebf4d..963dba27 100644
--- a/perl/Amanda/Config.swg
+++ b/perl/Amanda/Config.swg
@@ -1740,6 +1740,7 @@ amglue_add_constant(CONFIG_INIT_USE_CWD, config_init_flags);
amglue_add_constant(CONFIG_INIT_CLIENT, config_init_flags);
amglue_add_constant(CONFIG_INIT_OVERLAY, config_init_flags);
amglue_add_constant(CONFIG_INIT_GLOBAL, config_init_flags);
+amglue_add_constant(CONFIG_OVERRDIDE_NO_ERROR, config_init_flags);
amglue_copy_to_tag(config_init_flags, init);
cfgerr_level_t config_init(config_init_flags flags,