summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/architecture.h51
-rw-r--r--src/shared/strv.c34
-rw-r--r--src/shared/strv.h2
-rw-r--r--src/shared/util.c4
4 files changed, 87 insertions, 4 deletions
diff --git a/src/shared/architecture.h b/src/shared/architecture.h
index 20e848bd8f..08079244dc 100644
--- a/src/shared/architecture.h
+++ b/src/shared/architecture.h
@@ -23,6 +23,8 @@
#include "util.h"
+/* A cleaned up architecture definition */
+
typedef enum Architecture {
ARCHITECTURE_X86 = 0,
ARCHITECTURE_X86_64,
@@ -38,7 +40,9 @@ typedef enum Architecture {
ARCHITECTURE_SPARC,
ARCHITECTURE_SPARC64,
ARCHITECTURE_MIPS,
+ ARCHITECTURE_MIPS_LE,
ARCHITECTURE_MIPS64,
+ ARCHITECTURE_MIPS64_LE,
ARCHITECTURE_ALPHA,
ARCHITECTURE_ARM,
ARCHITECTURE_ARM_BE,
@@ -55,64 +59,107 @@ typedef enum Architecture {
Architecture uname_architecture(void);
+/*
+ * ARCH_TUPLE should resolve to the local architecture systemd is
+ * built for, according to the Debian tuple list:
+ *
+ * https://wiki.debian.org/Multiarch/Tuples
+ *
+ */
+
#if defined(__x86_64__)
# define native_architecture() ARCHITECTURE_X86_64
+# define ARCH_TUPLE "x86_64-linux-gnu"
#elif defined(__i386__)
# define native_architecture() ARCHITECTURE_X86
+# define ARCH_TUPLE "i386-linux-gnu"
#elif defined(__powerpc64__)
# if defined(WORDS_BIGENDIAN)
# define native_architecture() ARCHITECTURE_PPC64
+# define ARCH_TUPLE "ppc64-linux-gnu"
# else
# define native_architecture() ARCHITECTURE_PPC64_LE
+# error "Missing ARCH_TUPLE for PPC64LE"
# endif
#elif defined(__powerpc__)
# if defined(WORDS_BIGENDIAN)
# define native_architecture() ARCHITECTURE_PPC
+# define ARCH_TUPLE "powerpc-linux-gnu"
# else
# define native_architecture() ARCHITECTURE_PPC_LE
+# error "Missing ARCH_TUPLE for PPCLE"
# endif
#elif defined(__ia64__)
# define native_architecture() ARCHITECTURE_IA64
+# define ARCH_TUPLE "ia64-linux-gnu"
#elif defined(__hppa64__)
# define native_architecture() ARCHITECTURE_PARISC64
+# error "Missing ARCH_TUPLE for HPPA64"
#elif defined(__hppa__)
# define native_architecture() ARCHITECTURE_PARISC
+# define ARCH_TUPLE "hppa‑linux‑gnu"
#elif defined(__s390x__)
# define native_architecture() ARCHITECTURE_S390X
+# define ARCH_TUPLE "s390x-linux-gnu"
#elif defined(__s390__)
# define native_architecture() ARCHITECTURE_S390
+# define ARCH_TUPLE "s390-linux-gnu"
#elif defined(__sparc64__)
# define native_architecture() ARCHITECTURE_SPARC64
+# define ARCH_TUPLE "sparc64-linux-gnu"
#elif defined(__sparc__)
# define native_architecture() ARCHITECTURE_SPARC
+# define ARCH_TUPLE "sparc-linux-gnu"
#elif defined(__mips64__)
-# define native_architecture() ARCHITECTURE_MIPS64
+# if defined(WORDS_BIGENDIAN)
+# define native_architecture() ARCHITECTURE_MIPS64
+# error "Missing ARCH_TUPLE for MIPS64"
+# else
+# define native_architecture() ARCHITECTURE_MIPS64_LE
+# error "Missing ARCH_TUPLE for MIPS64_LE"
+# endif
#elif defined(__mips__)
-# define native_architecture() ARCHITECTURE_MIPS
+# if defined(WORDS_BIGENDIAN)
+# define native_architecture() ARCHITECTURE_MIPS
+# define ARCH_TUPLE "mips-linux-gnu"
+# else
+# define native_architecture() ARCHITECTURE_MIPS_LE
+# define ARCH_TUPLE "mipsel-linux-gnu"
+#endif
#elif defined(__alpha__)
# define native_architecture() ARCHITECTURE_ALPHA
+# define ARCH_TUPLE "alpha-linux-gnu"
#elif defined(__aarch64__)
# if defined(WORDS_BIGENDIAN)
# define native_architecture() ARCHITECTURE_ARM64_BE
+# define ARCH_TUPLE "aarch64_be-linux-gnu"
# else
# define native_architecture() ARCHITECTURE_ARM64
+# define ARCH_TUPLE "aarch64-linux-gnu"
# endif
#elif defined(__arm__)
# if defined(WORDS_BIGENDIAN)
# define native_architecture() ARCHITECTURE_ARM_BE
+# error "Missing ARCH_TUPLE for ARM_BE"
# else
# define native_architecture() ARCHITECTURE_ARM
+# error "Missing ARCH_TUPLE for ARM"
# endif
#elif defined(__sh64__)
# define native_architecture() ARCHITECTURE_SH64
+# error "Missing ARCH_TUPLE for SH64"
#elif defined(__sh__)
# define native_architecture() ARCHITECTURE_SH
+# define ARCH_TUPLE "sh4-linux-gnu"
#elif defined(__m68k__)
# define native_architecture() ARCHITECTURE_M68K
+# define ARCH_TUPLE "m68k-linux-gnu"
#elif defined(__tilegx__)
# define native_architecture() ARCHITECTURE_TILEGX
+# error "Missing ARCH_TUPLE for TILEGX"
#elif defined(__cris__)
# define native_architecture() ARCHITECTURE_CRIS
+# error "Missing ARCH_TUPLE for CRIS"
#else
#error "Please register your architecture here!"
#endif
diff --git a/src/shared/strv.c b/src/shared/strv.c
index 1ef0b26a25..b4c476eff2 100644
--- a/src/shared/strv.c
+++ b/src/shared/strv.c
@@ -378,6 +378,30 @@ int strv_push(char ***l, char *value) {
return 0;
}
+int strv_push_prepend(char ***l, char *value) {
+ char **c;
+ unsigned n, i;
+
+ if (!value)
+ return 0;
+
+ n = strv_length(*l);
+ c = new(char*, n + 2);
+ if (!c)
+ return -ENOMEM;
+
+ for (i = 0; i < n; i++)
+ c[i+1] = (*l)[i];
+
+ c[0] = value;
+ c[n+1] = NULL;
+
+ free(*l);
+ *l = c;
+
+ return 0;
+}
+
int strv_consume(char ***l, char *value) {
int r;
@@ -388,6 +412,16 @@ int strv_consume(char ***l, char *value) {
return r;
}
+int strv_consume_prepend(char ***l, char *value) {
+ int r;
+
+ r = strv_push_prepend(l, value);
+ if (r < 0)
+ free(value);
+
+ return r;
+}
+
int strv_extend(char ***l, const char *value) {
char *v;
diff --git a/src/shared/strv.h b/src/shared/strv.h
index e26ab828d2..3034073d32 100644
--- a/src/shared/strv.h
+++ b/src/shared/strv.h
@@ -41,7 +41,9 @@ int strv_extend_strv_concat(char ***a, char **b, const char *suffix);
int strv_extend(char ***l, const char *value);
int strv_extendf(char ***l, const char *format, ...) _printf_(2,0);
int strv_push(char ***l, char *value);
+int strv_push_prepend(char ***l, char *value);
int strv_consume(char ***l, char *value);
+int strv_consume_prepend(char ***l, char *value);
char **strv_remove(char **l, const char *s);
char **strv_uniq(char **l);
diff --git a/src/shared/util.c b/src/shared/util.c
index 9b5a47ab6f..a1c8baf237 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -5226,8 +5226,8 @@ int get_home_dir(char **_h) {
assert(_h);
/* Take the user specified one */
- e = getenv("HOME");
- if (e) {
+ e = secure_getenv("HOME");
+ if (e && path_is_absolute(e)) {
h = strdup(e);
if (!h)
return -ENOMEM;