summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/systemd/systemd/0013-Make-root-s-home-directory-configurable.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/systemd/systemd/0013-Make-root-s-home-directory-configurable.patch')
-rw-r--r--meta/recipes-core/systemd/systemd/0013-Make-root-s-home-directory-configurable.patch154
1 files changed, 154 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/0013-Make-root-s-home-directory-configurable.patch b/meta/recipes-core/systemd/systemd/0013-Make-root-s-home-directory-configurable.patch
new file mode 100644
index 0000000000..2b333375bb
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/0013-Make-root-s-home-directory-configurable.patch
@@ -0,0 +1,154 @@
1From 79e64a07840e0d97d66e46111f1c086bf83981b7 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 9 Nov 2016 20:35:30 -0800
4Subject: [PATCH 13/19] Make root's home directory configurable
5
6OpenEmbedded has a configurable home directory for root. Allow
7systemd to be built using its idea of what root's home directory
8should be.
9
10Upstream-Status: Denied
11Upstream wants to have a unified hierarchy where everyone is
12using the same root folder.
13https://github.com/systemd/systemd/issues/541
14
15Signed-off-by: Dan McGregor <dan.mcgregor@usask.ca>
16Signed-off-by: Khem Raj <raj.khem@gmail.com>
17---
18 Makefile.am | 2 ++
19 configure.ac | 7 +++++++
20 src/basic/user-util.c | 4 ++--
21 src/nspawn/nspawn.c | 4 ++--
22 units/emergency.service.in | 4 ++--
23 units/rescue.service.in | 4 ++--
24 6 files changed, 17 insertions(+), 8 deletions(-)
25
26diff --git a/Makefile.am b/Makefile.am
27index 420e0e0..3010b01 100644
28--- a/Makefile.am
29+++ b/Makefile.am
30@@ -213,6 +213,7 @@ AM_CPPFLAGS = \
31 -DLIBDIR=\"$(libdir)\" \
32 -DROOTLIBDIR=\"$(rootlibdir)\" \
33 -DROOTLIBEXECDIR=\"$(rootlibexecdir)\" \
34+ -DROOTHOMEDIR=\"$(roothomedir)\" \
35 -DTEST_DIR=\"$(abs_top_srcdir)/test\" \
36 -I $(top_srcdir)/src \
37 -I $(top_builddir)/src/basic \
38@@ -6057,6 +6058,7 @@ substitutions = \
39 '|rootlibdir=$(rootlibdir)|' \
40 '|rootlibexecdir=$(rootlibexecdir)|' \
41 '|rootbindir=$(rootbindir)|' \
42+ '|roothomedir=$(roothomedir)|' \
43 '|bindir=$(bindir)|' \
44 '|SYSTEMCTL=$(rootbindir)/systemctl|' \
45 '|SYSTEMD_NOTIFY=$(rootbindir)/systemd-notify|' \
46diff --git a/configure.ac b/configure.ac
47index b10c952..dfc0bd3 100644
48--- a/configure.ac
49+++ b/configure.ac
50@@ -1513,6 +1513,11 @@ AC_ARG_WITH([rootlibdir],
51 [with_rootlibdir=${libdir}])
52 AX_NORMALIZE_PATH([with_rootlibdir])
53
54+AC_ARG_WITH([roothomedir],
55+ AS_HELP_STRING([--with-roothomedir=DIR], [Home directory for the root user]),
56+ [],
57+ [with_roothomedir=/root])
58+
59 AC_ARG_WITH([pamlibdir],
60 AS_HELP_STRING([--with-pamlibdir=DIR], [Directory for PAM modules]),
61 [],
62@@ -1598,6 +1603,7 @@ AC_SUBST([pamlibdir], [$with_pamlibdir])
63 AC_SUBST([pamconfdir], [$with_pamconfdir])
64 AC_SUBST([rootprefix], [$with_rootprefix])
65 AC_SUBST([rootlibdir], [$with_rootlibdir])
66+AC_SUBST([roothomedir], [$with_roothomedir])
67
68 AC_CONFIG_FILES([
69 Makefile
70@@ -1688,6 +1694,7 @@ AC_MSG_RESULT([
71 includedir: ${includedir}
72 lib dir: ${libdir}
73 rootlib dir: ${with_rootlibdir}
74+ root home dir: ${with_roothomedir}
75 SysV init scripts: ${SYSTEM_SYSVINIT_PATH}
76 SysV rc?.d directories: ${SYSTEM_SYSVRCND_PATH}
77 Build Python: ${PYTHON}
78diff --git a/src/basic/user-util.c b/src/basic/user-util.c
79index 938533d..3f9fdc4 100644
80--- a/src/basic/user-util.c
81+++ b/src/basic/user-util.c
82@@ -127,7 +127,7 @@ int get_user_creds(
83 *gid = 0;
84
85 if (home)
86- *home = "/root";
87+ *home = ROOTHOMEDIR;
88
89 if (shell)
90 *shell = "/bin/sh";
91@@ -387,7 +387,7 @@ int get_home_dir(char **_h) {
92 /* Hardcode home directory for root to avoid NSS */
93 u = getuid();
94 if (u == 0) {
95- h = strdup("/root");
96+ h = strdup(ROOTHOMEDIR);
97 if (!h)
98 return -ENOMEM;
99
100diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
101index 19b47cd..e42bf19 100644
102--- a/src/nspawn/nspawn.c
103+++ b/src/nspawn/nspawn.c
104@@ -2798,7 +2798,7 @@ static int inner_child(
105 if (envp[n_env])
106 n_env++;
107
108- if ((asprintf((char**)(envp + n_env++), "HOME=%s", home ? home: "/root") < 0) ||
109+ if ((asprintf((char**)(envp + n_env++), "HOME=%s", home ? home: ROOTHOMEDIR) < 0) ||
110 (asprintf((char**)(envp + n_env++), "USER=%s", arg_user ? arg_user : "root") < 0) ||
111 (asprintf((char**)(envp + n_env++), "LOGNAME=%s", arg_user ? arg_user : "root") < 0))
112 return log_oom();
113@@ -2882,7 +2882,7 @@ static int inner_child(
114 else {
115 if (!arg_chdir)
116 /* If we cannot change the directory, we'll end up in /, that is expected. */
117- (void) chdir(home ?: "/root");
118+ (void) chdir(home ?: ROOTHOMEDIR);
119
120 execle("/bin/bash", "-bash", NULL, env_use);
121 execle("/bin/sh", "-sh", NULL, env_use);
122diff --git a/units/emergency.service.in b/units/emergency.service.in
123index da68eb8..e25f879 100644
124--- a/units/emergency.service.in
125+++ b/units/emergency.service.in
126@@ -15,8 +15,8 @@ Conflicts=syslog.socket
127 Before=shutdown.target
128
129 [Service]
130-Environment=HOME=/root
131-WorkingDirectory=-/root
132+Environment=HOME=@roothomedir@
133+WorkingDirectory=-@roothomedir@
134 ExecStartPre=-/bin/plymouth --wait quit
135 ExecStartPre=-/bin/echo -e 'You are in emergency mode. After logging in, type "journalctl -xb" to view\\nsystem logs, "systemctl reboot" to reboot, "systemctl default" or ^D to\\ntry again to boot into default mode.'
136 ExecStart=-/bin/sh -c "@SULOGIN@; @SYSTEMCTL@ --job-mode=fail --no-block default"
137diff --git a/units/rescue.service.in b/units/rescue.service.in
138index 5feff69..a83439e 100644
139--- a/units/rescue.service.in
140+++ b/units/rescue.service.in
141@@ -14,8 +14,8 @@ After=sysinit.target plymouth-start.service
142 Before=shutdown.target
143
144 [Service]
145-Environment=HOME=/root
146-WorkingDirectory=-/root
147+Environment=HOME=@roothomedir@
148+WorkingDirectory=-@roothomedir@
149 ExecStartPre=-/bin/plymouth --wait quit
150 ExecStartPre=-/bin/echo -e 'You are in rescue mode. After logging in, type "journalctl -xb" to view\\nsystem logs, "systemctl reboot" to reboot, "systemctl default" or ^D to\\nboot into default mode.'
151 ExecStart=-/bin/sh -c "@SULOGIN@; @SYSTEMCTL@ --job-mode=fail --no-block default"
152--
1532.10.2
154