[systemd-commits] 4 commits - Makefile.am man/systemd.exec.xml man/tmpfiles.d.xml src/core src/shared
Lennart Poettering
lennart at kemper.freedesktop.org
Mon Mar 3 08:55:37 PST 2014
Makefile.am | 22 +++++++---
man/systemd.exec.xml | 41 ++++++++++++++++++++
man/tmpfiles.d.xml | 20 +++++++++
src/core/dbus-execute.c | 2
src/core/execute.c | 69 +++++++++++++++++++++++++++++++++-
src/core/execute.h | 12 +++--
src/core/load-fragment-gperf.gperf.m4 | 2
src/core/load-fragment.c | 50 ++++++++++++++++++++++++
src/core/load-fragment.h | 1
src/core/main.c | 3 +
src/core/manager.c | 7 +++
src/core/manager.h | 2
src/core/mount.c | 3 +
src/core/service.c | 6 ++
src/core/socket.c | 3 +
src/core/swap.c | 3 +
src/shared/exit-status.c | 3 +
src/shared/exit-status.h | 1
src/shared/mkdir.c | 4 -
19 files changed, 236 insertions(+), 18 deletions(-)
New commits:
commit e66cf1a3f94fff48a572f6dbd19b43c9bcf7b8c7
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Mar 3 17:14:07 2014 +0100
core: introduce new RuntimeDirectory= and RuntimeDirectoryMode= unit settings
As discussed on the ML these are useful to manage runtime directories
below /run for services.
diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml
index 9224f1e..f1bcf9b 100644
--- a/man/systemd.exec.xml
+++ b/man/systemd.exec.xml
@@ -1195,6 +1195,46 @@
kernel.</para></listitem>
</varlistentry>
+ <varlistentry>
+ <term><varname>RuntimeDirectory=</varname></term>
+ <term><varname>RuntimeDirectoryMode=</varname></term>
+
+ <listitem><para>Takes a list of
+ directory names. If set one or more
+ directories by the specified names
+ will be created below
+ <filename>/run</filename> (for system
+ services) or below
+ <varname>$XDG_RUNTIME_DIR</varname>
+ (for user services) when the unit is
+ started and removed when the unit is
+ stopped. The directories will have the
+ access mode specified in
+ <varname>RuntimeDirectoryMode=</varname>,
+ and will be owned by the user and
+ group specified in
+ <varname>User=</varname> and
+ <varname>Group=</varname>. Use this to
+ manage one or more runtime directories
+ of the unit and bind their lifetime to
+ the daemon runtime. The specified
+ directory names must be relative, and
+ may not include a
+ <literal>/</literal>, i.e. must refer
+ to simple directories to create or
+ remove. This is particularly useful
+ for unpriviliges daemons that cannot
+ create runtime directories in
+ <filename>/run</filename> due to lack
+ of privileges, and to make sure the
+ runtime directory is cleaned up
+ automatically after use. For runtime
+ directories that require more complex
+ or different configuration or lifetime
+ guarantees, please consider using
+ <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para></listitem>
+ </varlistentry>
+
</variablelist>
</refsect1>
@@ -1352,6 +1392,7 @@
<citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
+ <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>exec</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>
diff --git a/man/tmpfiles.d.xml b/man/tmpfiles.d.xml
index 0a006d1..343fad1 100644
--- a/man/tmpfiles.d.xml
+++ b/man/tmpfiles.d.xml
@@ -61,6 +61,23 @@
temporary files and directories which usually reside
in directories such as <filename>/run</filename>
or <filename>/tmp</filename>.</para>
+
+ <para>Volatile and temporary files and directories are
+ those located in <filename>/run</filename> (and its
+ alias <filename>/var/run</filename>),
+ <filename>/tmp</filename>,
+ <filename>/var/tmp</filename>, the API file systems
+ such as <filename>/sys</filename> or
+ <filename>/proc</filename>, as well as some other
+ directories below <filename>/var</filename>.</para>
+
+ <para>System daemons frequently require private
+ runtime directories below <filename>/run</filename> to
+ place communication sockets and similar in. For these
+ consider declaring them in their unit files using
+ <varname>RuntimeDirectory=</varname>
+ (see <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> for details),
+ if this is feasible.</para>
</refsect1>
<refsect1>
@@ -458,7 +475,8 @@ x /var/tmp/abrt/*</programlisting>
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-tmpfiles</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
- <citerefentry><refentrytitle>systemd-delta</refentrytitle><manvolnum>1</manvolnum></citerefentry>
+ <citerefentry><refentrytitle>systemd-delta</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
+ <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
</para>
</refsect1>
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index 02e2a6d..6d0bdce 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -635,6 +635,8 @@ const sd_bus_vtable bus_exec_vtable[] = {
SD_BUS_PROPERTY("SystemCallErrorNumber", "i", property_get_syscall_errno, 0, SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("Personality", "s", property_get_personality, 0, SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("RestrictAddressFamilies", "(bas)", property_get_address_families, 0, SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("RuntimeDirectoryMode", "u", bus_property_get_mode, offsetof(ExecContext, runtime_directory_mode), SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("RuntimeDirectory", "as", NULL, offsetof(ExecContext, runtime_directory), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_VTABLE_END
};
diff --git a/src/core/execute.c b/src/core/execute.c
index 3312885..fec4b3b 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -82,6 +82,7 @@
#include "selinux-util.h"
#include "errno-list.h"
#include "af-list.h"
+#include "mkdir.h"
#include "apparmor-util.h"
#ifdef HAVE_SECCOMP
@@ -1247,6 +1248,7 @@ int exec_spawn(ExecCommand *command,
bool confirm_spawn,
CGroupControllerMask cgroup_supported,
const char *cgroup_path,
+ const char *runtime_prefix,
const char *unit_id,
usec_t watchdog_usec,
int idle_pipe[4],
@@ -1544,6 +1546,27 @@ int exec_spawn(ExecCommand *command,
}
#endif
+ if (!strv_isempty(context->runtime_directory) && runtime_prefix) {
+ char **rt;
+
+ STRV_FOREACH(rt, context->runtime_directory) {
+ _cleanup_free_ char *p;
+
+ p = strjoin(runtime_prefix, "/", *rt, NULL);
+ if (!p) {
+ r = EXIT_RUNTIME_DIRECTORY;
+ err = -ENOMEM;
+ goto fail_child;
+ }
+
+ err = mkdir_safe(p, context->runtime_directory_mode, uid, gid);
+ if (err < 0) {
+ r = EXIT_RUNTIME_DIRECTORY;
+ goto fail_child;
+ }
+ }
+ }
+
if (apply_permissions) {
err = enforce_groups(context, username, gid);
if (err < 0) {
@@ -1840,6 +1863,7 @@ void exec_context_init(ExecContext *c) {
c->ignore_sigpipe = true;
c->timer_slack_nsec = (nsec_t) -1;
c->personality = 0xffffffffUL;
+ c->runtime_directory_mode = 0755;
}
void exec_context_done(ExecContext *c) {
@@ -1918,6 +1942,33 @@ void exec_context_done(ExecContext *c) {
set_free(c->address_families);
c->address_families = NULL;
+
+ strv_free(c->runtime_directory);
+ c->runtime_directory = NULL;
+}
+
+int exec_context_destroy_runtime_directory(ExecContext *c, const char *runtime_prefix) {
+ char **i;
+
+ assert(c);
+
+ if (!runtime_prefix)
+ return 0;
+
+ STRV_FOREACH(i, c->runtime_directory) {
+ _cleanup_free_ char *p;
+
+ p = strjoin(runtime_prefix, "/", *i, NULL);
+ if (!p)
+ return -ENOMEM;
+
+ /* We execute this synchronously, since we need to be
+ * sure this is gone when we start the service
+ * next. */
+ rm_rf_dangerous(p, false, true, false);
+ }
+
+ return 0;
}
void exec_command_done(ExecCommand *c) {
diff --git a/src/core/execute.h b/src/core/execute.h
index efda23f..2c5d8bb 100644
--- a/src/core/execute.h
+++ b/src/core/execute.h
@@ -177,6 +177,9 @@ struct ExecContext {
Set *address_families;
bool address_families_whitelist:1;
+ char **runtime_directory;
+ mode_t runtime_directory_mode;
+
bool oom_score_adjust_set:1;
bool nice_set:1;
bool ioprio_set:1;
@@ -196,6 +199,7 @@ int exec_spawn(ExecCommand *command,
bool confirm_spawn,
CGroupControllerMask cgroup_mask,
const char *cgroup_path,
+ const char *runtime_prefix,
const char *unit_id,
usec_t watchdog_usec,
int pipe_fd[2],
@@ -219,6 +223,8 @@ void exec_context_init(ExecContext *c);
void exec_context_done(ExecContext *c);
void exec_context_dump(ExecContext *c, FILE* f, const char *prefix);
+int exec_context_destroy_runtime_directory(ExecContext *c, const char *runtime_root);
+
int exec_context_load_environment(const ExecContext *c, char ***l);
bool exec_context_may_touch_console(ExecContext *c);
diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4
index beff290..c9ab5c3 100644
--- a/src/core/load-fragment-gperf.gperf.m4
+++ b/src/core/load-fragment-gperf.gperf.m4
@@ -82,6 +82,8 @@ $1.PrivateNetwork, config_parse_bool, 0,
$1.PrivateDevices, config_parse_bool, 0, offsetof($1, exec_context.private_devices)
$1.MountFlags, config_parse_exec_mount_flags, 0, offsetof($1, exec_context)
$1.Personality, config_parse_personality, 0, offsetof($1, exec_context.personality)
+$1.RuntimeDirectoryMode, config_parse_mode, 0, offsetof($1, exec_context.runtime_directory_mode)
+$1.RuntimeDirectory, config_parse_runtime_directory, 0, offsetof($1, exec_context.runtime_directory)
m4_ifdef(`HAVE_LIBWRAP',
`$1.TCPWrapName, config_parse_unit_string_printf, 0, offsetof($1, exec_context.tcpwrap_name)',
`$1.TCPWrapName, config_parse_warn_compat, 0, 0')
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 478d22c..6f0027b 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -2719,6 +2719,56 @@ int config_parse_personality(
return 0;
}
+int config_parse_runtime_directory(
+ const char *unit,
+ const char *filename,
+ unsigned line,
+ const char *section,
+ unsigned section_line,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
+ char***rt = data, *w, *state;
+ size_t l;
+ int r;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+ assert(data);
+
+ if (isempty(rvalue)) {
+ /* Empty assignment resets the list */
+ strv_free(*rt);
+ *rt = NULL;
+ return 0;
+ }
+
+ FOREACH_WORD_QUOTED(w, l, rvalue, state) {
+ _cleanup_free_ char *n;
+
+ n = strndup(w, l);
+ if (!n)
+ return log_oom();
+
+ if (!filename_is_safe(n)) {
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Runtime directory is not valid, ignoring assignment: %s", rvalue);
+ continue;
+ }
+
+ r = strv_push(rt, n);
+ if (r < 0)
+ return log_oom();
+
+ n = NULL;
+ }
+
+ return 0;
+}
+
#define FOLLOW_MAX 8
static int open_follow(char **filename, FILE **_f, Set *names, char **_final) {
diff --git a/src/core/load-fragment.h b/src/core/load-fragment.h
index c5dbe61..5488f1d 100644
--- a/src/core/load-fragment.h
+++ b/src/core/load-fragment.h
@@ -91,6 +91,7 @@ int config_parse_exec_selinux_context(const char *unit, const char *filename, un
int config_parse_personality(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_exec_apparmor_profile(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_address_families(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+int config_parse_runtime_directory(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
/* gperf prototypes */
const struct ConfigPerfItem* load_fragment_gperf_lookup(const char *key, unsigned length);
diff --git a/src/core/manager.c b/src/core/manager.c
index 9172a24..822c7cc 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -2851,3 +2851,10 @@ Set *manager_get_units_requiring_mounts_for(Manager *m, const char *path) {
return hashmap_get(m->units_requiring_mounts_for, streq(p, "/") ? "" : p);
}
+
+const char *manager_get_runtime_prefix(Manager *m) {
+
+ return m->running_as == SYSTEMD_SYSTEM ?
+ "/run" :
+ getenv("XDG_RUNTIME_DIR");
+}
diff --git a/src/core/manager.h b/src/core/manager.h
index 398c8e6..3192b63 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -318,3 +318,5 @@ void manager_status_printf(Manager *m, bool ephemeral, const char *status, const
void manager_flip_auto_status(Manager *m, bool enable);
Set *manager_get_units_requiring_mounts_for(Manager *m, const char *path);
+
+const char *manager_get_runtime_prefix(Manager *m);
diff --git a/src/core/mount.c b/src/core/mount.c
index 7a92e1c..60067d4 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -788,6 +788,7 @@ static int mount_spawn(Mount *m, ExecCommand *c, pid_t *_pid) {
UNIT(m)->manager->confirm_spawn,
UNIT(m)->manager->cgroup_supported,
UNIT(m)->cgroup_path,
+ manager_get_runtime_prefix(UNIT(m)->manager),
UNIT(m)->id,
0,
NULL,
@@ -820,6 +821,8 @@ static void mount_enter_dead(Mount *m, MountResult f) {
exec_runtime_destroy(m->exec_runtime);
m->exec_runtime = exec_runtime_unref(m->exec_runtime);
+ exec_context_destroy_runtime_directory(&m->exec_context, manager_get_runtime_prefix(UNIT(m)->manager));
+
mount_set_state(m, m->result != MOUNT_SUCCESS ? MOUNT_FAILED : MOUNT_DEAD);
}
diff --git a/src/core/service.c b/src/core/service.c
index 6de24ec..121ddec 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -1770,6 +1770,7 @@ static int service_spawn(
UNIT(s)->manager->confirm_spawn,
UNIT(s)->manager->cgroup_supported,
path,
+ manager_get_runtime_prefix(UNIT(s)->manager),
UNIT(s)->id,
s->watchdog_usec,
s->type == SERVICE_IDLE ? UNIT(s)->manager->idle_pipe : NULL,
@@ -1871,10 +1872,13 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart)
s->forbid_restart = false;
- /* we want fresh tmpdirs in case service is started again immediately */
+ /* We want fresh tmpdirs in case service is started again immediately */
exec_runtime_destroy(s->exec_runtime);
s->exec_runtime = exec_runtime_unref(s->exec_runtime);
+ /* Also, remove the runtime directory in */
+ exec_context_destroy_runtime_directory(&s->exec_context, manager_get_runtime_prefix(UNIT(s)->manager));
+
/* Try to delete the pid file. At this point it will be
* out-of-date, and some software might be confused by it, so
* let's remove it. */
diff --git a/src/core/socket.c b/src/core/socket.c
index 8e39032..35531ed 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -1255,6 +1255,7 @@ static int socket_spawn(Socket *s, ExecCommand *c, pid_t *_pid) {
UNIT(s)->manager->confirm_spawn,
UNIT(s)->manager->cgroup_supported,
UNIT(s)->cgroup_path,
+ manager_get_runtime_prefix(UNIT(s)->manager),
UNIT(s)->id,
0,
NULL,
@@ -1289,6 +1290,8 @@ static void socket_enter_dead(Socket *s, SocketResult f) {
exec_runtime_destroy(s->exec_runtime);
s->exec_runtime = exec_runtime_unref(s->exec_runtime);
+ exec_context_destroy_runtime_directory(&s->exec_context, manager_get_runtime_prefix(UNIT(s)->manager));
+
socket_set_state(s, s->result != SOCKET_SUCCESS ? SOCKET_FAILED : SOCKET_DEAD);
}
diff --git a/src/core/swap.c b/src/core/swap.c
index 96cf38a..7004ede 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -646,6 +646,7 @@ static int swap_spawn(Swap *s, ExecCommand *c, pid_t *_pid) {
UNIT(s)->manager->confirm_spawn,
UNIT(s)->manager->cgroup_supported,
UNIT(s)->cgroup_path,
+ manager_get_runtime_prefix(UNIT(s)->manager),
UNIT(s)->id,
0,
NULL,
@@ -678,6 +679,8 @@ static void swap_enter_dead(Swap *s, SwapResult f) {
exec_runtime_destroy(s->exec_runtime);
s->exec_runtime = exec_runtime_unref(s->exec_runtime);
+ exec_context_destroy_runtime_directory(&s->exec_context, manager_get_runtime_prefix(UNIT(s)->manager));
+
swap_set_state(s, s->result != SWAP_SUCCESS ? SWAP_FAILED : SWAP_DEAD);
}
diff --git a/src/shared/exit-status.c b/src/shared/exit-status.c
index c1b04a3..c1c0861 100644
--- a/src/shared/exit-status.c
+++ b/src/shared/exit-status.c
@@ -142,6 +142,9 @@ const char* exit_status_to_string(ExitStatus status, ExitStatusLevel level) {
case EXIT_ADDRESS_FAMILIES:
return "ADDRESS_FAMILIES";
+
+ case EXIT_RUNTIME_DIRECTORY:
+ return "RUNTIME_DIRECTORY";
}
}
diff --git a/src/shared/exit-status.h b/src/shared/exit-status.h
index e7f1203..9dc3fce 100644
--- a/src/shared/exit-status.h
+++ b/src/shared/exit-status.h
@@ -72,6 +72,7 @@ typedef enum ExitStatus {
EXIT_PERSONALITY, /* 230 */
EXIT_APPARMOR_PROFILE,
EXIT_ADDRESS_FAMILIES,
+ EXIT_RUNTIME_DIRECTORY
} ExitStatus;
typedef enum ExitStatusLevel {
diff --git a/src/shared/mkdir.c b/src/shared/mkdir.c
index 43c6ea6..4a2cd5e 100644
--- a/src/shared/mkdir.c
+++ b/src/shared/mkdir.c
@@ -42,8 +42,8 @@ int mkdir_safe_internal(const char *path, mode_t mode, uid_t uid, gid_t gid, mkd
return -errno;
if ((st.st_mode & 0777) != mode ||
- st.st_uid != uid ||
- st.st_gid != gid ||
+ (uid != (uid_t) -1 && st.st_uid != uid) ||
+ (gid != (gid_t) -1 && st.st_gid != gid) ||
!S_ISDIR(st.st_mode)) {
errno = EEXIST;
return -errno;
commit b64a3d86bcc3b3698824019d0ebdc2117ad31bb5
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Mar 3 17:12:56 2014 +0100
execute: no need to include seccomp.h from execute.h
diff --git a/src/core/execute.h b/src/core/execute.h
index 3c905ce..efda23f 100644
--- a/src/core/execute.h
+++ b/src/core/execute.h
@@ -33,14 +33,10 @@ typedef struct ExecRuntime ExecRuntime;
#include <stdbool.h>
#include <stdio.h>
#include <sched.h>
-#ifdef HAVE_SECCOMP
-#include <seccomp.h>
-
-#include "set.h"
-#endif
#include "list.h"
#include "util.h"
+#include "set.h"
#include "fdset.h"
typedef enum ExecInput {
diff --git a/src/core/main.c b/src/core/main.c
index d3581fc..71ec607 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -35,6 +35,9 @@
#ifdef HAVE_VALGRIND_VALGRIND_H
#include <valgrind/valgrind.h>
#endif
+#ifdef HAVE_SECCOMP
+#include <seccomp.h>
+#endif
#include "sd-daemon.h"
#include "sd-messages.h"
commit 98b47d54ce946ad3524f84eb38d2413498a333dc
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Mar 3 17:11:39 2014 +0100
execute: free directory path if we fail to remove it because we cannot allocate a thread
diff --git a/src/core/execute.c b/src/core/execute.c
index 9de6e87..3312885 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -2713,6 +2713,8 @@ static void *remove_tmpdir_thread(void *p) {
}
void exec_runtime_destroy(ExecRuntime *rt) {
+ int r;
+
if (!rt)
return;
@@ -2722,13 +2724,25 @@ void exec_runtime_destroy(ExecRuntime *rt) {
if (rt->tmp_dir) {
log_debug("Spawning thread to nuke %s", rt->tmp_dir);
- asynchronous_job(remove_tmpdir_thread, rt->tmp_dir);
+
+ r = asynchronous_job(remove_tmpdir_thread, rt->tmp_dir);
+ if (r < 0) {
+ log_warning("Failed to nuke %s: %s", rt->tmp_dir, strerror(-r));
+ free(rt->tmp_dir);
+ }
+
rt->tmp_dir = NULL;
}
if (rt->var_tmp_dir) {
log_debug("Spawning thread to nuke %s", rt->var_tmp_dir);
- asynchronous_job(remove_tmpdir_thread, rt->var_tmp_dir);
+
+ r = asynchronous_job(remove_tmpdir_thread, rt->var_tmp_dir);
+ if (r < 0) {
+ log_warning("Failed to nuke %s: %s", rt->var_tmp_dir, strerror(-r));
+ free(rt->var_tmp_dir);
+ }
+
rt->var_tmp_dir = NULL;
}
commit e2438b7a321de8050f5db6793599a1668c91ccf5
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Mar 3 17:10:16 2014 +0100
build-sys: prefer using ln --relative -s where appropriate
By using --relative symlinks look nicer when dealing with OS image trees
that are placed in arbitrary places of the OS.
diff --git a/Makefile.am b/Makefile.am
index e7134a2..3eafcff 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -208,7 +208,7 @@ define move-to-rootlibdir
$(MKDIR_P) $(DESTDIR)$(rootlibdir) && \
so_img_name=$$(readlink $(DESTDIR)$(libdir)/$$libname) && \
so_img_rel_target_prefix=$$(echo $(libdir) | sed 's,\(^/\|\)[^/][^/]*,..,g') && \
- $(LN_S) -f $$so_img_rel_target_prefix$(rootlibdir)/$$so_img_name $(DESTDIR)$(libdir)/$$libname && \
+ $(LN_S) --relative -f $$so_img_rel_target_prefix$(rootlibdir)/$$so_img_name $(DESTDIR)$(libdir)/$$libname && \
mv $(DESTDIR)$(libdir)/$$libname.* $(DESTDIR)$(rootlibdir); \
fi
endef
@@ -232,7 +232,6 @@ USER_BUSNAMES_TARGET_WANTS =
SYSTEM_UNIT_ALIASES =
USER_UNIT_ALIASES =
-
GENERAL_ALIASES =
install-target-wants-hook:
@@ -268,9 +267,9 @@ install-aliases-hook:
set -- $(SYSTEM_UNIT_ALIASES) && \
dir=$(systemunitdir) && $(install-aliases)
set -- $(USER_UNIT_ALIASES) && \
- dir=$(userunitdir) && $(install-aliases)
+ dir=$(userunitdir) && $(install-relative-aliases)
set -- $(GENERAL_ALIASES) && \
- dir= && $(install-aliases)
+ dir= && $(install-relative-aliases)
define install-aliases
while [ -n "$$1" ]; do \
@@ -281,6 +280,15 @@ define install-aliases
done
endef
+define install-relative-aliases
+ while [ -n "$$1" ]; do \
+ $(MKDIR_P) `dirname $(DESTDIR)$$dir/$$2` && \
+ rm -f $(DESTDIR)$$dir/$$2 && \
+ $(LN_S) --relative $(DESTDIR)$$1 $(DESTDIR)$$dir/$$2 && \
+ shift 2 || exit $$?; \
+ done
+endef
+
INSTALL_EXEC_HOOKS += \
install-target-wants-hook \
install-directories-hook \
@@ -1848,7 +1856,7 @@ systemd_dbus1_generator_LDADD = \
dbus1-generator-install-hook:
$(AM_V_at)$(MKDIR_P) $(DESTDIR)$(usergeneratordir)
- $(AM_V_LN)$(LN_S) -f $(systemgeneratordir)/systemd-dbus1-generator $(DESTDIR)$(usergeneratordir)/systemd-dbus1-generator
+ $(AM_V_LN)$(LN_S) --relative -f $(DESTDIR)$(systemgeneratordir)/systemd-dbus1-generator $(DESTDIR)$(usergeneratordir)/systemd-dbus1-generator
dbus1-generator-uninstall-hook:
rm -f $(DESTDIR)$(usergeneratordir)/systemd-dbus1-generator
@@ -1978,7 +1986,7 @@ systemd_bus_proxyd_LDADD = \
bus-proxyd-install-hook:
$(AM_V_at)$(MKDIR_P) $(DESTDIR)$(bindir)
- $(AM_V_LN)$(LN_S) -f $(rootlibexecdir)/systemd-bus-proxyd $(DESTDIR)$(bindir)/systemd-stdio-bridge
+ $(AM_V_LN)$(LN_S) --relative -f $(DESTDIR)$(rootlibexecdir)/systemd-bus-proxyd $(DESTDIR)$(bindir)/systemd-stdio-bridge
bus-proxyd-uninstall-hook:
rm -f $(DESTDIR)$(bindir)/systemd-stdio-bridge
@@ -4842,7 +4850,7 @@ GENERAL_ALIASES += \
$(systemunitdir)/remote-fs.target $(pkgsysconfdir)/system/multi-user.target.wants/remote-fs.target \
$(systemunitdir)/getty at .service $(pkgsysconfdir)/system/getty.target.wants/getty at tty1.service \
$(pkgsysconfdir)/user $(sysconfdir)/xdg/systemd/user \
- ../system-services/org.freedesktop.systemd1.service $(dbussessionservicedir)/org.freedesktop.systemd1.service
+ $(dbussystemservicedir)/org.freedesktop.systemd1.service $(dbussessionservicedir)/org.freedesktop.systemd1.service
if HAVE_SYSV_COMPAT
INSTALL_DIRS += \
More information about the systemd-commits
mailing list