repart: resolve $TMP specifiers too

This might be useful for CopyFiles=, to reference some subdir of $TMP in
a generic way. This allows us to use the new common
system_and_tmp_specifier_table[].
This commit is contained in:
Lennart Poettering 2021-05-26 17:10:56 +02:00
parent 2caed041c0
commit b3e22322b6
2 changed files with 10 additions and 11 deletions

View file

@ -622,7 +622,9 @@
<refsect1>
<title>Specifiers</title>
<para>Specifiers may be used in the <varname>Label=</varname> setting. The following expansions are understood:</para>
<para>Specifiers may be used in the <varname>Label=</varname>, <varname>CopyBlocks=</varname>,
<varname>CopyFiles=</varname>, <varname>MakeDirectories=</varname> settings. The following expansions are
understood:</para>
<table class='specifiers'>
<title>Specifiers available</title>
<tgroup cols='3' align='left' colsep='1' rowsep='1'>
@ -649,6 +651,8 @@
<xi:include href="standard-specifiers.xml" xpointer="v"/>
<xi:include href="standard-specifiers.xml" xpointer="w"/>
<xi:include href="standard-specifiers.xml" xpointer="W"/>
<xi:include href="standard-specifiers.xml" xpointer="T"/>
<xi:include href="standard-specifiers.xml" xpointer="V"/>
<xi:include href="standard-specifiers.xml" xpointer="percent"/>
</tbody>
</tgroup>

View file

@ -949,11 +949,6 @@ static int config_parse_type(
return 0;
}
static const Specifier specifier_table[] = {
COMMON_SYSTEM_SPECIFIERS,
{}
};
static int config_parse_label(
const char *unit,
const char *filename,
@ -976,7 +971,7 @@ static int config_parse_label(
/* Nota bene: the empty label is a totally valid one. Let's hence not follow our usual rule of
* assigning the empty string to reset to default here, but really accept it as label to set. */
r = specifier_printf(rvalue, GPT_LABEL_MAX, specifier_table, NULL, &resolved);
r = specifier_printf(rvalue, GPT_LABEL_MAX, system_and_tmp_specifier_table, NULL, &resolved);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to expand specifiers in Label=, ignoring: %s", rvalue);
@ -1141,7 +1136,7 @@ static int config_parse_copy_files(
if (!isempty(p))
return log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL), "Too many arguments: %s", rvalue);
r = specifier_printf(source, PATH_MAX-1, specifier_table, NULL, &resolved_source);
r = specifier_printf(source, PATH_MAX-1, system_and_tmp_specifier_table, NULL, &resolved_source);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to expand specifiers in CopyFiles= source, ignoring: %s", rvalue);
@ -1152,7 +1147,7 @@ static int config_parse_copy_files(
if (r < 0)
return 0;
r = specifier_printf(target, PATH_MAX-1, specifier_table, NULL, &resolved_target);
r = specifier_printf(target, PATH_MAX-1, system_and_tmp_specifier_table, NULL, &resolved_target);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to expand specifiers in CopyFiles= target, ignoring: %s", resolved_target);
@ -1201,7 +1196,7 @@ static int config_parse_copy_blocks(
return 0;
}
r = specifier_printf(rvalue, PATH_MAX-1, specifier_table, NULL, &d);
r = specifier_printf(rvalue, PATH_MAX-1, system_and_tmp_specifier_table, NULL, &d);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to expand specifiers in CopyBlocks= source path, ignoring: %s", rvalue);
@ -1249,7 +1244,7 @@ static int config_parse_make_dirs(
if (r == 0)
return 0;
r = specifier_printf(word, PATH_MAX-1, specifier_table, NULL, &d);
r = specifier_printf(word, PATH_MAX-1, system_and_tmp_specifier_table, NULL, &d);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to expand specifiers in MakeDirectories= parameter, ignoring: %s", word);