1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-25 01:34:28 +03:00

core: StateDirectory= and friends imply RequiresMountsFor=

This commit is contained in:
Yu Watanabe 2017-08-31 18:19:35 +09:00
parent e9ea4526a3
commit ada5e27657
2 changed files with 24 additions and 4 deletions

View File

@ -86,10 +86,11 @@
<para>A few execution parameters result in additional, automatic
dependencies to be added.</para>
<para>Units with <varname>WorkingDirectory=</varname>, <varname>RootDirectory=</varname> or
<varname>RootImage=</varname> set automatically gain dependencies of type <varname>Requires=</varname> and
<varname>After=</varname> on all mount units required to access the specified paths. This is equivalent to having
them listed explicitly in <varname>RequiresMountsFor=</varname>.</para>
<para>Units with <varname>WorkingDirectory=</varname>, <varname>RootDirectory=</varname>, <varname>RootImage=</varname>,
<varname>RuntimeDirectory=</varname>, <varname>StateDirectory=</varname>, <varname>CacheDirectory=</varname>,
<varname>LogsDirectory=</varname> or <varname>ConfigurationDirectory=</varname> set automatically gain dependencies
of type <varname>Requires=</varname> and <varname>After=</varname> on all mount units required to access the specified paths.
This is equivalent to having them listed explicitly in <varname>RequiresMountsFor=</varname>.</para>
<para>Similar, units with <varname>PrivateTmp=</varname> enabled automatically get mount unit dependencies for all
mounts required to access <filename>/tmp</filename> and <filename>/var/tmp</filename>. They will also gain an

View File

@ -846,6 +846,8 @@ Unit* unit_follow_merge(Unit *u) {
}
int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
ExecDirectoryType dt;
char **dp;
int r;
assert(u);
@ -869,6 +871,23 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
return r;
}
for (dt = 0; dt < _EXEC_DIRECTORY_MAX; dt++) {
if (!u->manager->prefix[dt])
continue;
STRV_FOREACH(dp, c->directories[dt].paths) {
_cleanup_free_ char *p;
p = strjoin(u->manager->prefix[dt], "/", *dp);
if (!p)
return -ENOMEM;
r = unit_require_mounts_for(u, p);
if (r < 0)
return r;
}
}
if (!MANAGER_IS_SYSTEM(u->manager))
return 0;