MountParameters *p;
Unit *tu;
int r;
- bool noauto, handle, automount;
+ bool noauto, handle, automount, user;
assert(m);
return 0;
noauto = !!mount_test_option(p->options, MNTOPT_NOAUTO);
+ user = mount_test_option(p->options, "user") || mount_test_option(p->options, "users");
handle = !!mount_test_option(p->options, "comment=systemd.mount");
automount = !!mount_test_option(p->options, "comment=systemd.automount");
if ((r = manager_load_unit(UNIT(m)->meta.manager, target, NULL, &tu)) < 0)
return r;
- if (automount) {
+ if (automount && m->meta.manager->running_as != MANAGER_SESSION) {
Unit *am;
if ((r = unit_load_related_unit(UNIT(m), ".automount", &am)) < 0)
} else {
if (!noauto && handle)
- if ((r = unit_add_dependency(tu, UNIT_WANTS, UNIT(m), true)) < 0)
- return r;
+ if (user || m->meta.manager->running_as != MANAGER_SESSION)
+ if ((r = unit_add_dependency(tu, UNIT_WANTS, UNIT(m), true)) < 0)
+ return r;
return unit_add_dependency(UNIT(m), UNIT_BEFORE, tu, true);
}