Skip to content

Commit

Permalink
filesets: set xattr- and aclsupport default to yes
Browse files Browse the repository at this point in the history
Before, xattr and acl support were disabled by default.

Our expectation is that extended attributes and acls are backed up
by default so now the settings of both default to yes.

Current status is logged now into job message.
  • Loading branch information
franku committed Oct 5, 2018
1 parent bf08139 commit 260f6af
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/src/dird/dird_conf.cc
Expand Up @@ -2169,7 +2169,7 @@ bool FilesetResource::PrintConfig(PoolMem &buff, bool hide_sensitive_data, bool
}
break;
case 'X':
IndentConfigItem(cfg_str, 3, "Xattr = Yes\n");
IndentConfigItem(cfg_str, 3, "XattrSupport = Yes\n");
break;
case 'x':
IndentConfigItem(cfg_str, 3, "AutoExclude = No\n");
Expand Down
31 changes: 29 additions & 2 deletions core/src/dird/inc_conf.cc
Expand Up @@ -46,6 +46,12 @@

namespace directordaemon {

typedef struct {
bool configured;
std::string default_value;
} options_default_value_s;


/*
* Imported subroutines
*/
Expand Down Expand Up @@ -475,7 +481,8 @@ static void StoreMeta(LEX *lc, ResourceItem *item, int index, int pass)
/**
* New style options come here
*/
static void StoreOption(LEX *lc, ResourceItem *item, int index, int pass)
static void StoreOption(LEX *lc, ResourceItem *item, int index, int pass,
std::map<int,options_default_value_s> &option_default_values)
{
int i;
int keyword;
Expand All @@ -490,6 +497,9 @@ static void StoreOption(LEX *lc, ResourceItem *item, int index, int pass)
for (i = 0; FS_option_kw[i].name; i++) {
if (Bstrcasecmp(item->name, FS_option_kw[i].name)) {
keyword = FS_option_kw[i].token;
if (option_default_values.find(keyword) != option_default_values.end()) {
option_default_values[keyword].configured = true;
}
break;
}
}
Expand Down Expand Up @@ -544,6 +554,10 @@ static void SetupCurrentOpts(void)
static void StoreOptionsRes(LEX *lc, ResourceItem *item, int index, int pass, bool exclude)
{
int token, i;
std::map<int,options_default_value_s> option_default_values = {
{ INC_KW_ACL, {false, "A"} },
{ INC_KW_XATTR, {false, "X"} }
};

if (exclude) {
scan_err0(lc, _("Options section not permitted in Exclude\n"));
Expand Down Expand Up @@ -577,7 +591,7 @@ static void StoreOptionsRes(LEX *lc, ResourceItem *item, int index, int pass, bo
/* Call item handler */
switch (options_items[i].type) {
case CFG_TYPE_OPTION:
StoreOption(lc, &options_items[i], i, pass);
StoreOption(lc, &options_items[i], i, pass, option_default_values);
break;
case CFG_TYPE_REGEX:
StoreRegex(lc, &options_items[i], i, pass);
Expand Down Expand Up @@ -611,6 +625,19 @@ static void StoreOptionsRes(LEX *lc, ResourceItem *item, int index, int pass, bo
scan_err1(lc, _("Keyword %s not permitted in this resource"), lc->str);
}
}

/* apply default values for unset options */
if (pass == 1) {
for (auto const &o : option_default_values) {
int keyword_id = o.first;
bool was_set_in_config = o.second.configured;
std::string default_value = o.second.default_value;
if (!was_set_in_config) {
bstrncat(res_incexe.current_opts->opts, default_value.c_str(), MAX_FOPTS);
Dmsg2(900, "setting default value for keyword-id=%d, %s\n", keyword_id, default_value.c_str());
}
}
}
}

/**
Expand Down
27 changes: 27 additions & 0 deletions core/src/filed/dir_cmd.cc
Expand Up @@ -1617,6 +1617,30 @@ static bool StorageCmd(JobControlRecord *jcr)
return false;
}

static void LogFlagStatus(JobControlRecord *jcr, int flag, const char *flag_text)
{
findFILESET *fileset = jcr->ff->fileset;
bool found = false;
if (fileset) {
for (int i = 0; i < fileset->include_list.size() && !found; i++) {
findIncludeExcludeItem *incexe = (findIncludeExcludeItem *)fileset->include_list.get(i);

for (int j = 0; j < incexe->opts_list.size() && !found; j++) {
findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j);

if (BitIsSet(flag, fo->flags)) {
found = true;
}
}
}
}

std::string m = flag_text;
m += found ? "is enabled\n" : "is disabled\n";
Jmsg(jcr, M_INFO, 0, m.c_str());
}


/**
* Clear a flag in the find options.
*
Expand Down Expand Up @@ -1841,6 +1865,9 @@ static bool BackupCmd(JobControlRecord *jcr)

ClearCompressionFlagInFileset(jcr);

LogFlagStatus(jcr, FO_XATTR, "Extended attribute support ");
LogFlagStatus(jcr, FO_ACL, "ACL support ");

if (!GetWantedCryptoCipher(jcr, &cipher)) {
dir->fsend(BADcmd, "backup");
goto cleanup;
Expand Down

0 comments on commit 260f6af

Please sign in to comment.