Skip to content

Commit 307e85e

Browse files
committed
mount: add remote-fs.target/local-fs.target Wants links only when running as system instance
1 parent 9f23530 commit 307e85e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/mount.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static int mount_add_target_links(Mount *m) {
215215
MountParameters *p;
216216
Unit *tu;
217217
int r;
218-
bool noauto, handle, automount;
218+
bool noauto, handle, automount, user;
219219

220220
assert(m);
221221

@@ -227,6 +227,7 @@ static int mount_add_target_links(Mount *m) {
227227
return 0;
228228

229229
noauto = !!mount_test_option(p->options, MNTOPT_NOAUTO);
230+
user = mount_test_option(p->options, "user") || mount_test_option(p->options, "users");
230231
handle = !!mount_test_option(p->options, "comment=systemd.mount");
231232
automount = !!mount_test_option(p->options, "comment=systemd.automount");
232233

@@ -239,7 +240,7 @@ static int mount_add_target_links(Mount *m) {
239240
if ((r = manager_load_unit(UNIT(m)->meta.manager, target, NULL, &tu)) < 0)
240241
return r;
241242

242-
if (automount) {
243+
if (automount && m->meta.manager->running_as != MANAGER_SESSION) {
243244
Unit *am;
244245

245246
if ((r = unit_load_related_unit(UNIT(m), ".automount", &am)) < 0)
@@ -253,8 +254,9 @@ static int mount_add_target_links(Mount *m) {
253254
} else {
254255

255256
if (!noauto && handle)
256-
if ((r = unit_add_dependency(tu, UNIT_WANTS, UNIT(m), true)) < 0)
257-
return r;
257+
if (user || m->meta.manager->running_as != MANAGER_SESSION)
258+
if ((r = unit_add_dependency(tu, UNIT_WANTS, UNIT(m), true)) < 0)
259+
return r;
258260

259261
return unit_add_dependency(UNIT(m), UNIT_BEFORE, tu, true);
260262
}

0 commit comments

Comments
 (0)