<listitem><para>Takes an absolute
directory path. Sets the working
- directory for executed
- processes.</para></listitem>
+ directory for executed processes. If
+ not set defaults to the root directory
+ when systemd is running as a system
+ instance and the respective user's
+ home directory if run as
+ user.</para></listitem>
</varlistentry>
<varlistentry>
r = mount_add_extras(m);
if (r < 0)
return r;
+
+ r = unit_patch_working_directory(UNIT(m), &m->exec_context);
+ if (r < 0)
+ return r;
}
return mount_verify(m);
if (UNIT(s)->default_dependencies)
if ((r = service_add_default_dependencies(s)) < 0)
return r;
+
+ r = unit_patch_working_directory(UNIT(s), &s->exec_context);
+ if (r < 0)
+ return r;
}
return service_verify(s);
if (UNIT(s)->default_dependencies)
if ((r = socket_add_default_dependencies(s)) < 0)
return r;
+
+ r = unit_patch_working_directory(UNIT(s), &s->exec_context);
+ if (r < 0)
+ return r;
}
return socket_verify(s);
if (UNIT(s)->default_dependencies)
if ((r = swap_add_default_dependencies(s)) < 0)
return r;
+
+ r = unit_patch_working_directory(UNIT(s), &s->exec_context);
+ if (r < 0)
+ return r;
}
return swap_verify(s);
return 0;
}
+int unit_patch_working_directory(Unit *u, ExecContext *c) {
+ assert(u);
+ assert(c);
+
+ if (u->manager->running_as != MANAGER_USER)
+ return 0;
+
+ if (c->working_directory)
+ return 0;
+
+ return get_home_dir(&c->working_directory);
+}
+
static const char* const unit_active_state_table[_UNIT_ACTIVE_STATE_MAX] = {
[UNIT_ACTIVE] = "active",
[UNIT_RELOADING] = "reloading",
int unit_add_one_mount_link(Unit *u, Mount *m);
int unit_add_mount_links(Unit *u);
+int unit_patch_working_directory(Unit *u, ExecContext *c);
+
const char *unit_active_state_to_string(UnitActiveState i);
UnitActiveState unit_active_state_from_string(const char *s);