mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-26 09:57:26 +03:00
tmpfiles: add 'z', like 'Z' but not recursive
This commit is contained in:
parent
062e01bbdb
commit
777b87e702
@ -84,8 +84,8 @@
|
|||||||
<listitem><para>If this option is passed all
|
<listitem><para>If this option is passed all
|
||||||
files and directories marked with f,
|
files and directories marked with f,
|
||||||
F, d, D in the configuration files are
|
F, d, D in the configuration files are
|
||||||
created. Files and directories marked with Z
|
created. Files and directories marked with z,
|
||||||
have their ownership, access mode and security
|
Z have their ownership, access mode and security
|
||||||
labels set.</para></listitem>
|
labels set.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
@ -156,6 +156,16 @@ d /run/user 0755 root root 10d</programlisting>
|
|||||||
names.</para></listitem>
|
names.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><varname>z</varname></term>
|
||||||
|
<listitem><para>Set ownership, access
|
||||||
|
mode and relabel security context of
|
||||||
|
a file or directory if it exists.
|
||||||
|
Lines of this type accept shell-style
|
||||||
|
globs in place of normal path names.
|
||||||
|
</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><varname>Z</varname></term>
|
<term><varname>Z</varname></term>
|
||||||
<listitem><para>Recursively set
|
<listitem><para>Recursively set
|
||||||
@ -175,7 +185,7 @@ d /run/user 0755 root root 10d</programlisting>
|
|||||||
<para>The file access mode to use when
|
<para>The file access mode to use when
|
||||||
creating this file or directory. If omitted or
|
creating this file or directory. If omitted or
|
||||||
when set to - the default is used: 0755 for
|
when set to - the default is used: 0755 for
|
||||||
directories, 0644 for files. For Z lines
|
directories, 0644 for files. For z, Z lines
|
||||||
if omitted or when set to - the file access mode will
|
if omitted or when set to - the file access mode will
|
||||||
not be modified. This parameter is ignored for x, r, R
|
not be modified. This parameter is ignored for x, r, R
|
||||||
lines.</para>
|
lines.</para>
|
||||||
@ -188,7 +198,7 @@ d /run/user 0755 root root 10d</programlisting>
|
|||||||
or directory. This may either be a numeric
|
or directory. This may either be a numeric
|
||||||
user/group ID or a user or group name. If
|
user/group ID or a user or group name. If
|
||||||
omitted or when set to - the default 0 (root)
|
omitted or when set to - the default 0 (root)
|
||||||
is used. For Z lines when omitted or when set to -
|
is used. For z, Z lines when omitted or when set to -
|
||||||
the file ownership will not be modified.
|
the file ownership will not be modified.
|
||||||
These parameters are ignored for x, r, R lines.</para>
|
These parameters are ignored for x, r, R lines.</para>
|
||||||
</refsect2>
|
</refsect2>
|
||||||
|
@ -62,6 +62,7 @@ typedef enum ItemType {
|
|||||||
IGNORE_PATH = 'x',
|
IGNORE_PATH = 'x',
|
||||||
REMOVE_PATH = 'r',
|
REMOVE_PATH = 'r',
|
||||||
RECURSIVE_REMOVE_PATH = 'R',
|
RECURSIVE_REMOVE_PATH = 'R',
|
||||||
|
RELABEL_PATH = 'z',
|
||||||
RECURSIVE_RELABEL_PATH = 'Z'
|
RECURSIVE_RELABEL_PATH = 'Z'
|
||||||
} ItemType;
|
} ItemType;
|
||||||
|
|
||||||
@ -92,7 +93,7 @@ static const char *arg_prefix = NULL;
|
|||||||
#define MAX_DEPTH 256
|
#define MAX_DEPTH 256
|
||||||
|
|
||||||
static bool needs_glob(ItemType t) {
|
static bool needs_glob(ItemType t) {
|
||||||
return t == IGNORE_PATH || t == REMOVE_PATH || t == RECURSIVE_REMOVE_PATH || t == RECURSIVE_RELABEL_PATH;
|
return t == IGNORE_PATH || t == REMOVE_PATH || t == RECURSIVE_REMOVE_PATH || t == RELABEL_PATH || t == RECURSIVE_RELABEL_PATH;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct Item* find_glob(Hashmap *h, const char *match) {
|
static struct Item* find_glob(Hashmap *h, const char *match) {
|
||||||
@ -646,6 +647,13 @@ static int create_item(Item *i) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RELABEL_PATH:
|
||||||
|
|
||||||
|
r = glob_item(i, item_set_perms);
|
||||||
|
if (r < 0)
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
|
||||||
case RECURSIVE_RELABEL_PATH:
|
case RECURSIVE_RELABEL_PATH:
|
||||||
|
|
||||||
r = glob_item(i, recursive_relabel);
|
r = glob_item(i, recursive_relabel);
|
||||||
@ -670,6 +678,7 @@ static int remove_item_instance(Item *i, const char *instance) {
|
|||||||
case CREATE_DIRECTORY:
|
case CREATE_DIRECTORY:
|
||||||
case CREATE_FIFO:
|
case CREATE_FIFO:
|
||||||
case IGNORE_PATH:
|
case IGNORE_PATH:
|
||||||
|
case RELABEL_PATH:
|
||||||
case RECURSIVE_RELABEL_PATH:
|
case RECURSIVE_RELABEL_PATH:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -707,6 +716,7 @@ static int remove_item(Item *i) {
|
|||||||
case CREATE_DIRECTORY:
|
case CREATE_DIRECTORY:
|
||||||
case CREATE_FIFO:
|
case CREATE_FIFO:
|
||||||
case IGNORE_PATH:
|
case IGNORE_PATH:
|
||||||
|
case RELABEL_PATH:
|
||||||
case RECURSIVE_RELABEL_PATH:
|
case RECURSIVE_RELABEL_PATH:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -808,15 +818,19 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
|
|||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type != CREATE_FILE &&
|
switch(type) {
|
||||||
type != TRUNCATE_FILE &&
|
case CREATE_FILE:
|
||||||
type != CREATE_DIRECTORY &&
|
case TRUNCATE_FILE:
|
||||||
type != TRUNCATE_DIRECTORY &&
|
case CREATE_DIRECTORY:
|
||||||
type != CREATE_FIFO &&
|
case TRUNCATE_DIRECTORY:
|
||||||
type != IGNORE_PATH &&
|
case CREATE_FIFO:
|
||||||
type != REMOVE_PATH &&
|
case IGNORE_PATH:
|
||||||
type != RECURSIVE_REMOVE_PATH &&
|
case REMOVE_PATH:
|
||||||
type != RECURSIVE_RELABEL_PATH) {
|
case RECURSIVE_REMOVE_PATH:
|
||||||
|
case RELABEL_PATH:
|
||||||
|
case RECURSIVE_RELABEL_PATH:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
log_error("[%s:%u] Unknown file type '%c'.", fname, line, type);
|
log_error("[%s:%u] Unknown file type '%c'.", fname, line, type);
|
||||||
r = -EBADMSG;
|
r = -EBADMSG;
|
||||||
goto finish;
|
goto finish;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user