summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-02-19 02:15:24 +0100
committerLennart Poettering <lennart@poettering.net>2014-02-19 03:27:03 +0100
commitac45f971a12280de55b834a65237f72dcacfc099 (patch)
tree00b60ba7dcf78849a8615f994f952f02c1371781 /src/shared
parent49a356c2580c7c80f9c1e7e897ff7dcf9d9bce4c (diff)
core: add Personality= option for units to set the personality for spawned processes
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/exit-status.c3
-rw-r--r--src/shared/exit-status.h3
-rw-r--r--src/shared/util.c21
-rw-r--r--src/shared/util.h3
4 files changed, 27 insertions, 3 deletions
diff --git a/src/shared/exit-status.c b/src/shared/exit-status.c
index 70789f5136..8b096da7e1 100644
--- a/src/shared/exit-status.c
+++ b/src/shared/exit-status.c
@@ -133,6 +133,9 @@ const char* exit_status_to_string(ExitStatus status, ExitStatusLevel level) {
case EXIT_SELINUX_CONTEXT:
return "SELINUX_CONTEXT";
+
+ case EXIT_PERSONALITY:
+ return "PERSONALITY";
}
}
diff --git a/src/shared/exit-status.h b/src/shared/exit-status.h
index 8f9bddf069..dde5bdda8b 100644
--- a/src/shared/exit-status.h
+++ b/src/shared/exit-status.h
@@ -68,7 +68,8 @@ typedef enum ExitStatus {
EXIT_NAMESPACE,
EXIT_NO_NEW_PRIVILEGES,
EXIT_SECCOMP,
- EXIT_SELINUX_CONTEXT
+ EXIT_SELINUX_CONTEXT,
+ EXIT_PERSONALITY /* 230 */
} ExitStatus;
typedef enum ExitStatusLevel {
diff --git a/src/shared/util.c b/src/shared/util.c
index 99658f0975..55246f5a4d 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -6194,7 +6194,7 @@ int fd_warn_permissions(const char *path, int fd) {
return 0;
}
-unsigned long parse_personality(const char *p) {
+unsigned long personality_from_string(const char *p) {
/* Parse a personality specifier. We introduce our own
* identifiers that indicate specific ABIs, rather than just
@@ -6222,3 +6222,22 @@ unsigned long parse_personality(const char *p) {
* as error indicator. */
return 0xffffffffUL;
}
+
+const char* personality_to_string(unsigned long p) {
+
+#if defined(__x86_64__)
+
+ if (p == PER_LINUX32)
+ return "x86";
+
+ if (p == PER_LINUX)
+ return "x86-64";
+
+#elif defined(__i386__)
+
+ if (p == PER_LINUX)
+ return "x86";
+#endif
+
+ return NULL;
+}
diff --git a/src/shared/util.h b/src/shared/util.h
index e379c30e63..d1230d2b64 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -871,4 +871,5 @@ int open_tmpfile(const char *path, int flags);
int fd_warn_permissions(const char *path, int fd);
-unsigned long parse_personality(const char *p);
+unsigned long personality_from_string(const char *p);
+const char *personality_to_string(unsigned long);