@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s Where = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
+ readonly s ExtraOptions = '...';
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly u DirectoryMode = ...;
readonly s Result = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
<!--property Where is not documented!-->
+ <!--property ExtraOptions is not documented!-->
+
<!--property DirectoryMode is not documented!-->
<!--property TimeoutIdleUSec is not documented!-->
<variablelist class="dbus-property" generated="True" extra-ref="Where"/>
+ <variablelist class="dbus-property" generated="True" extra-ref="ExtraOptions"/>
+
<variablelist class="dbus-property" generated="True" extra-ref="DirectoryMode"/>
<variablelist class="dbus-property" generated="True" extra-ref="Result"/>
This option is mandatory.</para></listitem>
</varlistentry>
+ <varlistentry>
+ <term><varname>ExtraOptions=</varname></term>
+ <listitem><para>Extra mount options to use when creating the autofs
+ mountpoint. This takes a comma-separated list of options. This setting
+ is optional. Note that the usual specifier expansion is applied to this
+ setting, literal percent characters should hence be written as
+ <literal class='specifiers'>%%</literal>.</para></listitem>
+ </varlistentry>
+
<varlistentry>
<term><varname>DirectoryMode=</varname></term>
<listitem><para>Directories of automount points (and any
#include "dbus-unit.h"
#include "fd-util.h"
#include "format-util.h"
+#include "fstab-util.h"
#include "io-util.h"
#include "label.h"
#include "mkdir-label.h"
unmount_autofs(a);
a->where = mfree(a->where);
+ a->extra_options = mfree(a->extra_options);
a->tokens = set_free(a->tokens);
a->expire_tokens = set_free(a->expire_tokens);
}
static int automount_verify(Automount *a) {
+ static const char *const reserved_options[] = {
+ "fd\0",
+ "pgrp\0",
+ "minproto\0",
+ "maxproto\0",
+ "direct\0",
+ "indirect\0",
+ };
+
_cleanup_free_ char *e = NULL;
int r;
if (!unit_has_name(UNIT(a), e))
return log_unit_error_errno(UNIT(a), SYNTHETIC_ERRNO(ENOEXEC), "Where= setting doesn't match unit name. Refusing.");
+ for (size_t i = 0; i < ELEMENTSOF(reserved_options); i++)
+ if (fstab_test_option(a->extra_options, reserved_options[i]))
+ return log_unit_error_errno(
+ UNIT(a),
+ SYNTHETIC_ERRNO(ENOEXEC),
+ "ExtraOptions= setting may not contain reserved option %s.",
+ reserved_options[i]);
+
return 0;
}
"%sAutomount State: %s\n"
"%sResult: %s\n"
"%sWhere: %s\n"
+ "%sExtraOptions: %s\n"
"%sDirectoryMode: %04o\n"
"%sTimeoutIdleUSec: %s\n",
prefix, automount_state_to_string(a->state),
prefix, automount_result_to_string(a->result),
prefix, a->where,
+ prefix, a->extra_options,
prefix, a->directory_mode,
prefix, FORMAT_TIMESPAN(a->timeout_idle_usec, USEC_PER_SEC));
}
_cleanup_close_ int ioctl_fd = -1;
int p[2] = { -1, -1 };
char name[STRLEN("systemd-") + DECIMAL_STR_MAX(pid_t) + 1];
- char options[STRLEN("fd=,pgrp=,minproto=5,maxproto=5,direct")
- + DECIMAL_STR_MAX(int) + DECIMAL_STR_MAX(gid_t) + 1];
+ _cleanup_free_ char *options = NULL;
bool mounted = false;
int r, dev_autofs_fd;
struct stat st;
if (r < 0)
goto fail;
- xsprintf(options, "fd=%i,pgrp="PID_FMT",minproto=5,maxproto=5,direct", p[1], getpgrp());
+ if (asprintf(
+ &options,
+ "fd=%i,pgrp="PID_FMT",minproto=5,maxproto=5,direct%s%s",
+ p[1],
+ getpgrp(),
+ isempty(a->extra_options) ? "" : ",",
+ strempty(a->extra_options)) < 0) {
+ r = -ENOMEM;
+ goto fail;
+ }
+
xsprintf(name, "systemd-"PID_FMT, getpid_cached());
r = mount_nofollow(name, a->where, "autofs", 0, options);
if (r < 0)
AutomountState state, deserialized_state;
char *where;
+ char *extra_options;
usec_t timeout_idle_usec;
int pipe_fd;
const sd_bus_vtable bus_automount_vtable[] = {
SD_BUS_VTABLE_START(0),
SD_BUS_PROPERTY("Where", "s", NULL, offsetof(Automount, where), SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("ExtraOptions", "s", NULL, offsetof(Automount, extra_options), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("DirectoryMode", "u", bus_property_get_mode, offsetof(Automount, directory_mode), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Automount, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("TimeoutIdleUSec", "t", bus_property_get_usec, offsetof(Automount, timeout_idle_usec), SD_BUS_VTABLE_PROPERTY_CONST),
if (streq(name, "Where"))
return bus_set_transient_path(u, name, &a->where, message, flags, error);
+ if (streq(name, "ExtraOptions"))
+ return bus_set_transient_string(u, name, &a->extra_options, message, flags, error);
+
if (streq(name, "TimeoutIdleUSec"))
return bus_set_transient_usec_fix_0(u, name, &a->timeout_idle_usec, message, flags, error);
{{ CGROUP_CONTEXT_CONFIG_ITEMS('Mount') }}
{{ KILL_CONTEXT_CONFIG_ITEMS('Mount') }}
Automount.Where, config_parse_unit_path_printf, 0, offsetof(Automount, where)
+Automount.ExtraOptions, config_parse_unit_string_printf, 0, offsetof(Automount, extra_options)
Automount.DirectoryMode, config_parse_mode, 0, offsetof(Automount, directory_mode)
Automount.TimeoutIdleSec, config_parse_sec_fix_0, 0, offsetof(Automount, timeout_idle_usec)
Swap.What, config_parse_unit_path_printf, 0, offsetof(Swap, parameters_fragment.what)
}
static int bus_append_automount_property(sd_bus_message *m, const char *field, const char *eq) {
- if (streq(field, "Where"))
+ if (STR_IN_SET(field, "Where",
+ "ExtraOptions"))
return bus_append_string(m, field, eq);
if (streq(field, "DirectoryMode"))
DirectoryMode=
TimeoutIdleSec=
Where=
+ExtraOptions=