* add fstab fields to add wait timeouts, change Wants to Requires by local-fs.target
-* hook emergency.target into local-fs.target in some way as OnFailure with isolate, add warning log message
-
* bind mounts are ignored
https://bugzilla.redhat.com/show_bug.cgi?id=682662
* 0595f9a1c182a84581749823ef47c5f292e545f9 is borked, freezes shutdown
(path: after installing inotify watches, recheck file again to fix race)
+* be nice to ingo
+
Features:
* fix alsa mixer restore to not print error when no config is stored
about policy loading. Probably check for available selinux in /proc/filesystems,
and check for active selinux with getcon_raw() == "kernel"
-* optionally create watched directories in .path units
-
* Support --test based on current system state
* consider services with no [Install] section and stored in /lib enabled by "systemctl is-enabled"
identical, except for the
suffix.</para></listitem>
</varlistentry>
+ <varlistentry>
+ <term><varname>MakeDirectory=</varname></term>
+
+ <listitem><para>Takes a boolean
+ argument. If true the directories to
+ watch are created before
+ watching. This option is ignored for
+ <varname>PathExists=</varname>
+ settings. Defaults to
+ <option>false</option>.</para></listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><varname>DirectoryMode=</varname></term>
+
+ <listitem><para>If
+ <varname>MakeDirectory=</varname> is
+ enabled use the mode specified here to
+ create the directories in
+ question. Takes an access mode in
+ octal notation. Defaults to
+ <option>0755</option>.</para></listitem>
+ </varlistentry>
</variablelist>
</refsect1>
" <interface name=\"org.freedesktop.systemd1.Path\">\n" \
" <property name=\"Unit\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"Paths\" type=\"a(ss)\" access=\"read\"/>\n" \
+ " <property name=\"MakeDirectory\" type=\"b\" access=\"read\"/>\n" \
+ " <property name=\"DirectoryMode\" type=\"u\" access=\"read\"/>\n" \
" </interface>\n"
#define INTROSPECTION \
DBusHandlerResult bus_path_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
- { "org.freedesktop.systemd1.Path", "Unit", bus_path_append_unit, "s", u },
- { "org.freedesktop.systemd1.Path", "Paths", bus_path_append_paths, "a(ss)", u },
+ { "org.freedesktop.systemd1.Path", "Unit", bus_path_append_unit, "s", u },
+ { "org.freedesktop.systemd1.Path", "Paths", bus_path_append_paths, "a(ss)", u },
+ { "org.freedesktop.systemd1.Path", "MakeDirectory", bus_property_append_bool, "b", &u->path.make_directory },
+ { "org.freedesktop.systemd1.Path", "DirectoryMode", bus_property_append_mode, "u", &u->path.directory_mode },
{ NULL, NULL, NULL, NULL, NULL }
};
{ "PathChanged", config_parse_path_spec, 0, &u->path, "Path" },
{ "DirectoryNotEmpty", config_parse_path_spec, 0, &u->path, "Path" },
{ "Unit", config_parse_path_unit, 0, &u->path, "Path" },
+ { "MakeDirectory", config_parse_bool, 0, &u->path.make_directory, "Path" },
+ { "DirectoryMode", config_parse_mode, 0, &u->path.directory_mode, "Path" },
/* The [Install] section is ignored here. */
{ "Alias", NULL, 0, NULL, "Install" },
/* Create a few directories we always want around */
mkdir("/run/systemd", 0755);
- mkdir("/run/systemd/ask-password", 0755);
return mount_cgroup_controllers();
}
[PATH_FAILED] = UNIT_FAILED
};
+static void path_init(Unit *u) {
+ Path *p = PATH(u);
+
+ assert(u);
+ assert(u->meta.load_state == UNIT_STUB);
+
+ p->directory_mode = 0755;
+}
+
static void path_unwatch_one(Path *p, PathSpec *s) {
if (s->inotify_fd < 0)
fprintf(f,
"%sPath State: %s\n"
- "%sUnit: %s\n",
+ "%sUnit: %s\n"
+ "%sMakeDirectory: %s\n"
+ "%sDirectoryMode: %04o\n",
prefix, path_state_to_string(p->state),
- prefix, p->unit->meta.id);
+ prefix, p->unit->meta.id,
+ prefix, yes_no(p->make_directory),
+ prefix, p->directory_mode);
LIST_FOREACH(spec, s, p->specs)
fprintf(f,
path_enter_dead(p, false);
}
+static void path_mkdir(Path *p) {
+ PathSpec *s;
+
+ assert(p);
+
+ if (!p->make_directory)
+ return;
+
+ LIST_FOREACH(spec, s, p->specs) {
+ int r;
+
+ if (s->type == PATH_EXISTS)
+ continue;
+
+ if ((r = mkdir_p(s->path, p->directory_mode)) < 0)
+ log_warning("mkdir(%s) failed: %s", s->path, strerror(-r));
+ }
+}
+
static int path_start(Unit *u) {
Path *p = PATH(u);
if (p->unit->meta.load_state != UNIT_LOADED)
return -ENOENT;
+ path_mkdir(p);
+
p->failure = false;
path_enter_waiting(p, true, true, false);
const UnitVTable path_vtable = {
.suffix = ".path",
+ .init = path_init,
.done = path_done,
.load = path_load,
bool failure;
bool inotify_triggered;
+
+ bool make_directory;
+ mode_t directory_mode;
};
void path_unit_notify(Unit *u, UnitActiveState new_state);
r /forcefsck
r /forcequotacheck
r /fastboot
+
+d /run/systemd/ask-password 0755 root root -
[Path]
DirectoryNotEmpty=/run/systemd/ask-password
+MakeDirectory=yes
[Path]
DirectoryNotEmpty=/run/systemd/ask-password
+MakeDirectory=yes
[Path]
DirectoryNotEmpty=/run/systemd/ask-password
+MakeDirectory=yes