Compare commits

...

4 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 9e9dd3e329
Merge pull request #13862 from zachsmith/systemd-tmpfiles-deprecate-for-force
systemd-tmpfiles: deprecate F for f+
2019-11-12 10:28:59 +01:00
Yu Watanabe a566ed2c82 udev: do not append newline when write attributes
Before 25de7aa7b9, the content is written
by `fprintf()` without new line. So WRITE_STRING_FILE_AVOID_NEWLINE flag
is necessary.

Fixes #13985.
2019-11-12 09:25:00 +01:00
Zach Smith 4b55952dbe systemd-tmpfiles: cleanup man page program listing 2019-11-08 20:29:36 -08:00
Zach Smith eccebf4b0d systemd-tmpfiles: deprecate F for f+ 2019-10-31 22:27:56 -07:00
4 changed files with 24 additions and 26 deletions

1
TODO
View File

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

View File

@ -39,8 +39,9 @@
<programlisting>#Type Path Mode User Group Age Argument
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/append-to - - - - content
d /directory/to/create-and-cleanup mode user group cleanup-age -
D /directory/to/create-and-remove mode user group cleanup-age -
e /directory/to/cleanup mode user group cleanup-age -
@ -48,10 +49,13 @@ v /subvolume/to/create mode user group - -
v /subvolume-or-directory/to/create mode user group - -
Q /subvolume/to/create mode user group - -
p /fifo/to/create mode user group - -
p+ /fifo/to/[re]create mode user group - -
L /symlink/to/create - - - - symlink/target/path
L+ /symlink/to/[re]create - - - - symlink/target/path
c /dev/char-device-to-create mode user group - -
c+ /dev/char-device-to-[re]create mode user group - -
b /dev/block-device-to-create mode user group - -
# p+, L+, c+, b+ create target unconditionally, w+ appends to the file
b+ /dev/block-device-to-[re]create mode user group - -
C /target/to/create - - - - /source/to/copy
x /path-or-glob/to/ignore - - - - -
X /path-or-glob/to/ignore/recursively - - - - -
@ -64,8 +68,10 @@ T /path-or-glob/to/set/xattrs/recursively - - - - xattr
h /path-or-glob/to/set/attrs - - - - file attrs
H /path-or-glob/to/set/attrs/recursively - - - - file attrs
a /path-or-glob/to/set/acls - - - - POSIX ACLs
a+ /path-or-glob/to/append/acls - - - - POSIX ACLs
A /path-or-glob/to/set/acls/recursively - - - - POSIX ACLs
# a+, A+ append ACLs
A+ /path-or-glob/to/append/acls/recursively - - - - POSIX ACLs
</programlisting>
</refsynopsisdiv>
@ -155,19 +161,16 @@ L /tmp/foobar - - - - /dev/null</programlisting>
<variablelist>
<varlistentry>
<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
not exist yet, it will be written to the file. Does not follow symlinks.</para></listitem>
<term><varname>f+</varname></term>
<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>
<term><varname>F</varname></term>
<listitem><para>Create or truncate a file. If the argument
parameter is given, it will be written to the file. Does not follow symlinks.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>w, w+</varname></term>
<term><varname>w</varname></term>
<term><varname>w+</varname></term>
<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 your configuration writes multiple lines to the same file, use <varname>w+</varname>.

View File

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

View File

@ -2102,7 +2102,7 @@ static int udev_rule_apply_token_to_event(
(void) udev_event_apply_format(event, token->value, value, sizeof(value), false);
log_rule_debug(dev, rules, "ATTR '%s' writing '%s'", buf, value);
r = write_string_file(buf, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_DISABLE_BUFFER);
r = write_string_file(buf, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_DISABLE_BUFFER | WRITE_STRING_FILE_AVOID_NEWLINE);
if (r < 0)
log_rule_error_errno(dev, rules, r, "Failed to write ATTR{%s}, ignoring: %m", buf);
break;