diff options
author | Dan McGregor <dan.mcgregor@usask.ca> | 2014-09-03 13:49:28 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-10-24 17:36:13 +0100 |
commit | fd50427935b242971202b4f855ae291d95c261a6 (patch) | |
tree | 68dd990ff7147e9716609af4fb510f7e1767f812 | |
parent | ad065f94acb0bfb81e33935890a1db251d6e2979 (diff) | |
download | poky-fd50427935b242971202b4f855ae291d95c261a6.tar.gz |
systemd: Use ${ROOT_HOME} instead of /root
systemd avoids using nss lookups for the root user, so
naturally it assumes that root's home directory is /root.
In OE that's not the case, and it can lead to long delays when
shutting down due to user shutdown unit failures.
(From OE-Core rev: e1efc61979b329c651c15acff1afeba2987397b5)
Signed-off-by: Dan McGregor <dan.mcgregor@usask.ca>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/recipes-core/systemd/systemd/0001-Make-root-s-home-directory-configurable.patch | 180 | ||||
-rw-r--r-- | meta/recipes-core/systemd/systemd_216.bb | 3 |
2 files changed, 182 insertions, 1 deletions
diff --git a/meta/recipes-core/systemd/systemd/0001-Make-root-s-home-directory-configurable.patch b/meta/recipes-core/systemd/systemd/0001-Make-root-s-home-directory-configurable.patch new file mode 100644 index 0000000000..c5ad29174c --- /dev/null +++ b/meta/recipes-core/systemd/systemd/0001-Make-root-s-home-directory-configurable.patch | |||
@@ -0,0 +1,180 @@ | |||
1 | From 4dc8dee0435bb63cbe474004b0a8df0363fe94dd Mon Sep 17 00:00:00 2001 | ||
2 | From: Dan McGregor <dan.mcgregor@usask.ca> | ||
3 | Date: Fri, 5 Sep 2014 06:28:58 -0600 | ||
4 | Subject: [PATCH] Make root's home directory configurable. | ||
5 | |||
6 | OpenEmbedded has a configurable home directory for root. Allow | ||
7 | systemd to be built using its idea of what root's home directory | ||
8 | should be. | ||
9 | |||
10 | Upstream-Status: Pending | ||
11 | |||
12 | Signed-off-by: Dan McGregor <dan.mcgregor@usask.ca> | ||
13 | --- | ||
14 | Makefile.am | 2 ++ | ||
15 | configure.ac | 7 +++++++ | ||
16 | src/core/unit-printf.c | 2 +- | ||
17 | src/nspawn/nspawn.c | 4 ++-- | ||
18 | src/shared/util.c | 4 ++-- | ||
19 | units/console-shell.service.m4.in | 4 ++-- | ||
20 | units/emergency.service.in | 4 ++-- | ||
21 | units/rescue.service.m4.in | 4 ++-- | ||
22 | 8 files changed, 20 insertions(+), 11 deletions(-) | ||
23 | |||
24 | diff --git a/Makefile.am b/Makefile.am | ||
25 | index 4028112..5d18f5c 100644 | ||
26 | --- a/Makefile.am | ||
27 | +++ b/Makefile.am | ||
28 | @@ -191,6 +191,7 @@ AM_CPPFLAGS = \ | ||
29 | -DKEXEC=\"$(KEXEC)\" \ | ||
30 | -DLIBDIR=\"$(libdir)\" \ | ||
31 | -DROOTLIBDIR=\"$(rootlibdir)\" \ | ||
32 | + -DROOTHOMEDIR=\"$(roothomedir)\" \ | ||
33 | -DTEST_DIR=\"$(abs_top_srcdir)/test\" \ | ||
34 | -I $(top_srcdir)/src \ | ||
35 | -I $(top_builddir)/src/shared \ | ||
36 | @@ -5584,6 +5585,7 @@ EXTRA_DIST += \ | ||
37 | substitutions = \ | ||
38 | '|rootlibexecdir=$(rootlibexecdir)|' \ | ||
39 | '|rootbindir=$(rootbindir)|' \ | ||
40 | + '|roothomedir=$(roothomedir)|' \ | ||
41 | '|bindir=$(bindir)|' \ | ||
42 | '|SYSTEMCTL=$(rootbindir)/systemctl|' \ | ||
43 | '|SYSTEMD_NOTIFY=$(rootbindir)/systemd-notify|' \ | ||
44 | diff --git a/configure.ac b/configure.ac | ||
45 | index 18b7198..365bc73 100644 | ||
46 | --- a/configure.ac | ||
47 | +++ b/configure.ac | ||
48 | @@ -1272,6 +1272,11 @@ AC_ARG_WITH([rootlibdir], | ||
49 | [], | ||
50 | [with_rootlibdir=${libdir}]) | ||
51 | |||
52 | +AC_ARG_WITH([roothomedir], | ||
53 | + AS_HELP_STRING([--with-roothomedir=DIR], [Home directory for the root user]), | ||
54 | + [], | ||
55 | + [with_roothomedir=/root]) | ||
56 | + | ||
57 | AC_ARG_WITH([pamlibdir], | ||
58 | AS_HELP_STRING([--with-pamlibdir=DIR], [Directory for PAM modules]), | ||
59 | [], | ||
60 | @@ -1317,6 +1322,7 @@ AC_SUBST([pamlibdir], [$with_pamlibdir]) | ||
61 | AC_SUBST([pamconfdir], [$with_pamconfdir]) | ||
62 | AC_SUBST([rootprefix], [$with_rootprefix]) | ||
63 | AC_SUBST([rootlibdir], [$with_rootlibdir]) | ||
64 | +AC_SUBST([roothomedir], [$with_roothomedir]) | ||
65 | |||
66 | AC_CONFIG_FILES([ | ||
67 | Makefile po/Makefile.in | ||
68 | @@ -1400,6 +1406,7 @@ AC_MSG_RESULT([ | ||
69 | include_prefix: ${INCLUDE_PREFIX} | ||
70 | lib dir: ${libdir} | ||
71 | rootlib dir: ${with_rootlibdir} | ||
72 | + root home dir: ${with_roothomedir} | ||
73 | SysV init scripts: ${SYSTEM_SYSVINIT_PATH} | ||
74 | SysV rc?.d directories: ${SYSTEM_SYSVRCND_PATH} | ||
75 | Build Python: ${PYTHON} | ||
76 | diff --git a/src/core/unit-printf.c b/src/core/unit-printf.c | ||
77 | index 62599d0..852d34c 100644 | ||
78 | --- a/src/core/unit-printf.c | ||
79 | +++ b/src/core/unit-printf.c | ||
80 | @@ -259,7 +259,7 @@ static int specifier_user_home(char specifier, void *data, void *userdata, char | ||
81 | * best of it if we can, but fail if we can't */ | ||
82 | |||
83 | if (!c->user || streq(c->user, "root") || streq(c->user, "0")) | ||
84 | - n = strdup("/root"); | ||
85 | + n = strdup(ROOTHOMEDIR); | ||
86 | else | ||
87 | return -ENOTSUP; | ||
88 | |||
89 | diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c | ||
90 | index d01da45..3e876d5 100644 | ||
91 | --- a/src/nspawn/nspawn.c | ||
92 | +++ b/src/nspawn/nspawn.c | ||
93 | @@ -3312,7 +3312,7 @@ int main(int argc, char *argv[]) { | ||
94 | if (r < 0) | ||
95 | _exit(EXIT_FAILURE); | ||
96 | |||
97 | - if ((asprintf((char**)(envp + n_env++), "HOME=%s", home ? home: "/root") < 0) || | ||
98 | + if ((asprintf((char**)(envp + n_env++), "HOME=%s", home ? home: ROOTHOMEDIR) < 0) || | ||
99 | (asprintf((char**)(envp + n_env++), "USER=%s", arg_user ? arg_user : "root") < 0) || | ||
100 | (asprintf((char**)(envp + n_env++), "LOGNAME=%s", arg_user ? arg_user : "root") < 0)) { | ||
101 | log_oom(); | ||
102 | @@ -3402,7 +3402,7 @@ int main(int argc, char *argv[]) { | ||
103 | } else if (argc > optind) | ||
104 | execvpe(argv[optind], argv + optind, env_use); | ||
105 | else { | ||
106 | - chdir(home ? home : "/root"); | ||
107 | + chdir(home ? home : ROOTHOMEDIR); | ||
108 | execle("/bin/bash", "-bash", NULL, env_use); | ||
109 | execle("/bin/sh", "-sh", NULL, env_use); | ||
110 | } | ||
111 | diff --git a/src/shared/util.c b/src/shared/util.c | ||
112 | index 85a570a..aef6033 100644 | ||
113 | --- a/src/shared/util.c | ||
114 | +++ b/src/shared/util.c | ||
115 | @@ -4377,7 +4377,7 @@ int get_user_creds( | ||
116 | *gid = 0; | ||
117 | |||
118 | if (home) | ||
119 | - *home = "/root"; | ||
120 | + *home = ROOTHOMEDIR; | ||
121 | |||
122 | if (shell) | ||
123 | *shell = "/bin/sh"; | ||
124 | @@ -5363,7 +5363,7 @@ int get_home_dir(char **_h) { | ||
125 | /* Hardcode home directory for root to avoid NSS */ | ||
126 | u = getuid(); | ||
127 | if (u == 0) { | ||
128 | - h = strdup("/root"); | ||
129 | + h = strdup(ROOTHOMEDIR); | ||
130 | if (!h) | ||
131 | return -ENOMEM; | ||
132 | |||
133 | diff --git a/units/console-shell.service.m4.in b/units/console-shell.service.m4.in | ||
134 | index 3f4904a..e2af652 100644 | ||
135 | --- a/units/console-shell.service.m4.in | ||
136 | +++ b/units/console-shell.service.m4.in | ||
137 | @@ -15,8 +15,8 @@ After=rc-local.service | ||
138 | Before=getty.target | ||
139 | |||
140 | [Service] | ||
141 | -Environment=HOME=/root | ||
142 | -WorkingDirectory=/root | ||
143 | +Environment=HOME=@roothomedir@ | ||
144 | +WorkingDirectory=@roothomedir@ | ||
145 | ExecStart=-/sbin/sulogin | ||
146 | ExecStopPost=-@SYSTEMCTL@ poweroff | ||
147 | Type=idle | ||
148 | diff --git a/units/emergency.service.in b/units/emergency.service.in | ||
149 | index 91fc1bb..659547e 100644 | ||
150 | --- a/units/emergency.service.in | ||
151 | +++ b/units/emergency.service.in | ||
152 | @@ -13,8 +13,8 @@ Conflicts=shutdown.target | ||
153 | Before=shutdown.target | ||
154 | |||
155 | [Service] | ||
156 | -Environment=HOME=/root | ||
157 | -WorkingDirectory=/root | ||
158 | +Environment=HOME=@roothomedir@ | ||
159 | +WorkingDirectory=@roothomedir@ | ||
160 | ExecStartPre=-/bin/plymouth quit | ||
161 | ExecStartPre=-/bin/echo -e 'Welcome to emergency mode! After logging in, type "journalctl -xb" to view\\nsystem logs, "systemctl reboot" to reboot, "systemctl default" to try again\\nto boot into default mode.' | ||
162 | ExecStart=-/bin/sh -c "/sbin/sulogin; @SYSTEMCTL@ --fail --no-block default" | ||
163 | diff --git a/units/rescue.service.m4.in b/units/rescue.service.m4.in | ||
164 | index ef54369..7aad86f 100644 | ||
165 | --- a/units/rescue.service.m4.in | ||
166 | +++ b/units/rescue.service.m4.in | ||
167 | @@ -14,8 +14,8 @@ After=sysinit.target plymouth-start.service | ||
168 | Before=shutdown.target | ||
169 | |||
170 | [Service] | ||
171 | -Environment=HOME=/root | ||
172 | -WorkingDirectory=/root | ||
173 | +Environment=HOME=@roothomedir@ | ||
174 | +WorkingDirectory=@roothomedir@ | ||
175 | ExecStartPre=-/bin/plymouth quit | ||
176 | ExecStartPre=-/bin/echo -e 'Welcome to rescue mode! Type "systemctl default" or ^D to enter default mode.\\nType "journalctl -xb" to view system logs. Type "systemctl reboot" to reboot.' | ||
177 | ExecStart=-/bin/sh -c "/sbin/sulogin; @SYSTEMCTL@ --fail --no-block default" | ||
178 | -- | ||
179 | 1.9.3 | ||
180 | |||
diff --git a/meta/recipes-core/systemd/systemd_216.bb b/meta/recipes-core/systemd/systemd_216.bb index ebf939574d..598d45e7de 100644 --- a/meta/recipes-core/systemd/systemd_216.bb +++ b/meta/recipes-core/systemd/systemd_216.bb | |||
@@ -32,6 +32,7 @@ SRC_URI = "git://anongit.freedesktop.org/systemd/systemd;branch=master;protocol= | |||
32 | file://uclibc-get-physmem.patch \ | 32 | file://uclibc-get-physmem.patch \ |
33 | file://0001-add-support-for-executing-scripts-under-etc-rcS.d.patch \ | 33 | file://0001-add-support-for-executing-scripts-under-etc-rcS.d.patch \ |
34 | file://0001-missing.h-add-fake-__NR_memfd_create-for-MIPS.patch \ | 34 | file://0001-missing.h-add-fake-__NR_memfd_create-for-MIPS.patch \ |
35 | file://0001-Make-root-s-home-directory-configurable.patch \ | ||
35 | file://touchscreen.rules \ | 36 | file://touchscreen.rules \ |
36 | file://00-create-volatile.conf \ | 37 | file://00-create-volatile.conf \ |
37 | file://init \ | 38 | file://init \ |
@@ -74,6 +75,7 @@ rootlibexecdir = "${rootprefix}/lib" | |||
74 | # The gtk+ tools should get built as a separate recipe e.g. systemd-tools | 75 | # The gtk+ tools should get built as a separate recipe e.g. systemd-tools |
75 | EXTRA_OECONF = " --with-rootprefix=${rootprefix} \ | 76 | EXTRA_OECONF = " --with-rootprefix=${rootprefix} \ |
76 | --with-rootlibdir=${rootlibdir} \ | 77 | --with-rootlibdir=${rootlibdir} \ |
78 | --with-roothomedir=${ROOT_HOME} \ | ||
77 | ${@bb.utils.contains('DISTRO_FEATURES', 'pam', '--enable-pam', '--disable-pam', d)} \ | 79 | ${@bb.utils.contains('DISTRO_FEATURES', 'pam', '--enable-pam', '--disable-pam', d)} \ |
78 | --disable-manpages \ | 80 | --disable-manpages \ |
79 | --disable-coredump \ | 81 | --disable-coredump \ |
@@ -99,7 +101,6 @@ do_configure_prepend() { | |||
99 | else | 101 | else |
100 | cp -r ${S}/units ${S}/units.pre_sed | 102 | cp -r ${S}/units ${S}/units.pre_sed |
101 | fi | 103 | fi |
102 | sed -i -e 's:=/root:=${ROOT_HOME}:g' ${S}/units/*.service* | ||
103 | sed -i '/ln --relative --help/d' ${S}/configure.ac | 104 | sed -i '/ln --relative --help/d' ${S}/configure.ac |
104 | sed -i -e 's:\$(LN_S) --relative -f:lnr:g' ${S}/Makefile.am | 105 | sed -i -e 's:\$(LN_S) --relative -f:lnr:g' ${S}/Makefile.am |
105 | sed -i -e 's:\$(LN_S) --relative:lnr:g' ${S}/Makefile.am | 106 | sed -i -e 's:\$(LN_S) --relative:lnr:g' ${S}/Makefile.am |