systemd-tmpfiles: deprecate F for f+

This commit is contained in:
Zach Smith 2019-10-28 09:32:16 -07:00
parent 21d0dd5a89
commit eccebf4b0d
3 changed files with 15 additions and 23 deletions

1
TODO
View File

@ -943,7 +943,6 @@ Features:
* tmpfiles: * tmpfiles:
- apply "x" on "D" too (see patch from William Douglas) - apply "x" on "D" too (see patch from William Douglas)
- replace F with f+.
- instead of ignoring unknown fields, reject them. - instead of ignoring unknown fields, reject them.
- creating new directories/subvolumes/fifos/device nodes - creating new directories/subvolumes/fifos/device nodes
should not follow symlinks. None of the other adjustment or creation should not follow symlinks. None of the other adjustment or creation

View File

@ -39,7 +39,7 @@
<programlisting>#Type Path Mode User Group Age Argument <programlisting>#Type Path Mode User Group Age Argument
f /file/to/create mode user group - content f /file/to/create mode user group - content
F /file/to/create-or-truncate mode user group - content f+ /file/to/create-or-truncate mode user group - content
w /file/to/write-to - - - - content w /file/to/write-to - - - - content
d /directory/to/create-and-cleanup mode user group cleanup-age - d /directory/to/create-and-cleanup mode user group cleanup-age -
D /directory/to/create-and-remove mode user group cleanup-age - D /directory/to/create-and-remove mode user group cleanup-age -
@ -155,19 +155,16 @@ L /tmp/foobar - - - - /dev/null</programlisting>
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term><varname>f</varname></term> <term><varname>f</varname></term>
<listitem><para>Create a file if it does not exist yet. If the argument parameter is given and the file did <term><varname>f+</varname></term>
not exist yet, it will be written to the file. Does not follow symlinks.</para></listitem> <listitem><para><varname>f</varname> will create a file if it does not exist yet. If the argument
parameter is given and the file did not exist yet, it will be written to the file.
<varname>f+</varname> will create or truncate the file. If the argument parameter is given, it will
be written to the file. Does not follow symlinks.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><varname>F</varname></term> <term><varname>w</varname></term>
<listitem><para>Create or truncate a file. If the argument <term><varname>w+</varname></term>
parameter is given, it will be written to the file. Does not follow symlinks.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>w, w+</varname></term>
<listitem><para>Write the argument parameter to a file, if the file exists. <listitem><para>Write the argument parameter to a file, if the file exists.
If suffixed with <varname>+</varname>, the line will be appended to the file. If suffixed with <varname>+</varname>, the line will be appended to the file.
If your configuration writes multiple lines to the same file, use <varname>w+</varname>. If your configuration writes multiple lines to the same file, use <varname>w+</varname>.

View File

@ -77,7 +77,7 @@ typedef enum OperationMask {
typedef enum ItemType { typedef enum ItemType {
/* These ones take file names */ /* These ones take file names */
CREATE_FILE = 'f', CREATE_FILE = 'f',
TRUNCATE_FILE = 'F', TRUNCATE_FILE = 'F', /* deprecated: use f+ */
CREATE_DIRECTORY = 'd', CREATE_DIRECTORY = 'd',
TRUNCATE_DIRECTORY = 'D', TRUNCATE_DIRECTORY = 'D',
CREATE_SUBVOLUME = 'v', CREATE_SUBVOLUME = 'v',
@ -1370,7 +1370,7 @@ static int truncate_file(Item *i, const char *path) {
assert(i); assert(i);
assert(path); assert(path);
assert(i->type == TRUNCATE_FILE); assert(i->type == TRUNCATE_FILE || (i->type == CREATE_FILE && i->append_or_force));
/* We want to operate on regular file exclusively especially since /* We want to operate on regular file exclusively especially since
* O_TRUNC is unspecified if the file is neither a regular file nor a * O_TRUNC is unspecified if the file is neither a regular file nor a
@ -1927,20 +1927,16 @@ static int create_item(Item *i) {
case RECURSIVE_REMOVE_PATH: case RECURSIVE_REMOVE_PATH:
return 0; return 0;
case TRUNCATE_FILE:
case CREATE_FILE: case CREATE_FILE:
RUN_WITH_UMASK(0000) RUN_WITH_UMASK(0000)
(void) mkdir_parents_label(i->path, 0755); (void) mkdir_parents_label(i->path, 0755);
r = create_file(i, i->path); if ((i->type == CREATE_FILE && i->append_or_force) || i->type == TRUNCATE_FILE)
if (r < 0) r = truncate_file(i, i->path);
return r; else
break; r = create_file(i, i->path);
case TRUNCATE_FILE:
RUN_WITH_UMASK(0000)
(void) mkdir_parents_label(i->path, 0755);
r = truncate_file(i, i->path);
if (r < 0) if (r < 0)
return r; return r;
break; break;