Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | From 3dc731c1d270e2e143de621db9bd898299fd849d Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Fri, 20 Feb 2015 05:24:49 +0000 |
| 4 | Subject: [PATCH 10/11] 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: Denied |
| 11 | Upstream wants to have a unified hierarchy where everyone is |
| 12 | using the same root folder. |
| 13 | https://github.com/systemd/systemd/issues/541 |
| 14 | |
| 15 | Signed-off-by: Dan McGregor <dan.mcgregor@usask.ca> |
| 16 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 17 | --- |
| 18 | Makefile.am | 2 ++ |
| 19 | configure.ac | 7 +++++++ |
| 20 | src/core/unit-printf.c | 2 +- |
| 21 | src/nspawn/nspawn.c | 4 ++-- |
| 22 | src/basic/util.c | 4 ++-- |
| 23 | units/console-shell.service.m4.in | 4 ++-- |
| 24 | units/emergency.service.in | 4 ++-- |
| 25 | units/rescue.service.in | 4 ++-- |
| 26 | 8 files changed, 20 insertions(+), 11 deletions(-) |
| 27 | |
| 28 | Index: git/Makefile.am |
| 29 | =================================================================== |
| 30 | --- git.orig/Makefile.am |
| 31 | +++ git/Makefile.am |
| 32 | @@ -208,6 +208,7 @@ AM_CPPFLAGS = \ |
| 33 | -DLIBDIR=\"$(libdir)\" \ |
| 34 | -DROOTLIBDIR=\"$(rootlibdir)\" \ |
| 35 | -DROOTLIBEXECDIR=\"$(rootlibexecdir)\" \ |
| 36 | + -DROOTHOMEDIR=\"$(roothomedir)\" \ |
| 37 | -DTEST_DIR=\"$(abs_top_srcdir)/test\" \ |
| 38 | -I $(top_srcdir)/src \ |
| 39 | -I $(top_builddir)/src/basic \ |
| 40 | @@ -5615,6 +5616,7 @@ EXTRA_DIST += \ |
| 41 | substitutions = \ |
| 42 | '|rootlibexecdir=$(rootlibexecdir)|' \ |
| 43 | '|rootbindir=$(rootbindir)|' \ |
| 44 | + '|roothomedir=$(roothomedir)|' \ |
| 45 | '|bindir=$(bindir)|' \ |
| 46 | '|SYSTEMCTL=$(rootbindir)/systemctl|' \ |
| 47 | '|SYSTEMD_NOTIFY=$(rootbindir)/systemd-notify|' \ |
| 48 | Index: git/configure.ac |
| 49 | =================================================================== |
| 50 | --- git.orig/configure.ac |
| 51 | +++ git/configure.ac |
| 52 | @@ -1383,6 +1383,11 @@ AC_ARG_WITH([rootlibdir], |
| 53 | [with_rootlibdir=${libdir}]) |
| 54 | AX_NORMALIZE_PATH([with_rootlibdir]) |
| 55 | |
| 56 | +AC_ARG_WITH([roothomedir], |
| 57 | + AS_HELP_STRING([--with-roothomedir=DIR], [Home directory for the root user]), |
| 58 | + [], |
| 59 | + [with_roothomedir=/root]) |
| 60 | + |
| 61 | AC_ARG_WITH([pamlibdir], |
| 62 | AS_HELP_STRING([--with-pamlibdir=DIR], [Directory for PAM modules]), |
| 63 | [], |
| 64 | @@ -1474,6 +1479,7 @@ AC_SUBST([pamlibdir], [$with_pamlibdir]) |
| 65 | AC_SUBST([pamconfdir], [$with_pamconfdir]) |
| 66 | AC_SUBST([rootprefix], [$with_rootprefix]) |
| 67 | AC_SUBST([rootlibdir], [$with_rootlibdir]) |
| 68 | +AC_SUBST([roothomedir], [$with_roothomedir]) |
| 69 | |
| 70 | AC_CONFIG_FILES([ |
| 71 | Makefile |
| 72 | @@ -1563,6 +1569,7 @@ AC_MSG_RESULT([ |
| 73 | includedir: ${includedir} |
| 74 | lib dir: ${libdir} |
| 75 | rootlib dir: ${with_rootlibdir} |
| 76 | + root home dir: ${with_roothomedir} |
| 77 | SysV init scripts: ${SYSTEM_SYSVINIT_PATH} |
| 78 | SysV rc?.d directories: ${SYSTEM_SYSVRCND_PATH} |
| 79 | Build Python: ${PYTHON} |
| 80 | Index: git/src/core/unit-printf.c |
| 81 | =================================================================== |
| 82 | --- git.orig/src/core/unit-printf.c |
| 83 | +++ git/src/core/unit-printf.c |
| 84 | @@ -237,7 +237,7 @@ static int specifier_user_home(char spec |
| 85 | * best of it if we can, but fail if we can't */ |
| 86 | |
| 87 | if (!c->user || streq(c->user, "root") || streq(c->user, "0")) |
| 88 | - n = strdup("/root"); |
| 89 | + n = strdup(ROOTHOMEDIR); |
| 90 | else |
| 91 | return -EOPNOTSUPP; |
| 92 | |
| 93 | Index: git/src/nspawn/nspawn.c |
| 94 | =================================================================== |
| 95 | --- git.orig/src/nspawn/nspawn.c |
| 96 | +++ git/src/nspawn/nspawn.c |
| 97 | @@ -4176,7 +4176,7 @@ static int inner_child( |
| 98 | if (envp[n_env]) |
| 99 | n_env ++; |
| 100 | |
| 101 | - if ((asprintf((char**)(envp + n_env++), "HOME=%s", home ? home: "/root") < 0) || |
| 102 | + if ((asprintf((char**)(envp + n_env++), "HOME=%s", home ? home: ROOTHOMEDIR) < 0) || |
| 103 | (asprintf((char**)(envp + n_env++), "USER=%s", arg_user ? arg_user : "root") < 0) || |
| 104 | (asprintf((char**)(envp + n_env++), "LOGNAME=%s", arg_user ? arg_user : "root") < 0)) |
| 105 | return log_oom(); |
| 106 | @@ -4247,7 +4247,7 @@ static int inner_child( |
| 107 | execvp(argv[optind], argv + optind); |
| 108 | #endif /* HAVE_EXECVPE */ |
| 109 | else { |
| 110 | - chdir(home ? home : "/root"); |
| 111 | + chdir(home ? home : ROOTHOMEDIR); |
| 112 | execle("/bin/bash", "-bash", NULL, env_use); |
| 113 | execle("/bin/sh", "-sh", NULL, env_use); |
| 114 | } |
| 115 | Index: git/src/basic/util.c |
| 116 | =================================================================== |
| 117 | --- git.orig/src/basic/util.c |
| 118 | +++ git/src/basic/util.c |
| 119 | @@ -3233,7 +3233,7 @@ int get_user_creds( |
| 120 | *gid = 0; |
| 121 | |
| 122 | if (home) |
| 123 | - *home = "/root"; |
| 124 | + *home = ROOTHOMEDIR; |
| 125 | |
| 126 | if (shell) |
| 127 | *shell = "/bin/sh"; |
| 128 | @@ -4069,7 +4069,7 @@ int get_home_dir(char **_h) { |
| 129 | /* Hardcode home directory for root to avoid NSS */ |
| 130 | u = getuid(); |
| 131 | if (u == 0) { |
| 132 | - h = strdup("/root"); |
| 133 | + h = strdup(ROOTHOMEDIR); |
| 134 | if (!h) |
| 135 | return -ENOMEM; |
| 136 | |
| 137 | Index: git/units/console-shell.service.m4.in |
| 138 | =================================================================== |
| 139 | --- git.orig/units/console-shell.service.m4.in |
| 140 | +++ git/units/console-shell.service.m4.in |
| 141 | @@ -15,8 +15,8 @@ After=rc-local.service |
| 142 | Before=getty.target |
| 143 | |
| 144 | [Service] |
| 145 | -Environment=HOME=/root |
| 146 | -WorkingDirectory=/root |
| 147 | +Environment=HOME=@roothomedir@ |
| 148 | +WorkingDirectory=@roothomedir@ |
| 149 | ExecStart=-@SULOGIN@ |
| 150 | ExecStopPost=-@SYSTEMCTL@ poweroff |
| 151 | Type=idle |
| 152 | Index: git/units/emergency.service.in |
| 153 | =================================================================== |
| 154 | --- git.orig/units/emergency.service.in |
| 155 | +++ git/units/emergency.service.in |
| 156 | @@ -14,8 +14,8 @@ Conflicts=rescue.service |
| 157 | Before=shutdown.target |
| 158 | |
| 159 | [Service] |
| 160 | -Environment=HOME=/root |
| 161 | -WorkingDirectory=/root |
| 162 | +Environment=HOME=@roothomedir@ |
| 163 | +WorkingDirectory=@roothomedir@ |
| 164 | ExecStartPre=-/bin/plymouth --wait quit |
| 165 | ExecStartPre=-/bin/echo -e 'Welcome to 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.' |
| 166 | ExecStart=-/bin/sh -c "@SULOGIN@; @SYSTEMCTL@ --job-mode=fail --no-block default" |
| 167 | Index: git/units/rescue.service.in |
| 168 | =================================================================== |
| 169 | --- git.orig/units/rescue.service.in |
| 170 | +++ git/units/rescue.service.in |
| 171 | @@ -14,8 +14,8 @@ After=sysinit.target plymouth-start.serv |
| 172 | Before=shutdown.target |
| 173 | |
| 174 | [Service] |
| 175 | -Environment=HOME=/root |
| 176 | -WorkingDirectory=/root |
| 177 | +Environment=HOME=@roothomedir@ |
| 178 | +WorkingDirectory=@roothomedir@ |
| 179 | ExecStartPre=-/bin/plymouth quit |
| 180 | ExecStartPre=-/bin/echo -e 'Welcome to emergency mode! After logging in, type "journalctl -xb" to view\\nsystem logs, "systemctl reboot" to reboot, "systemctl default" or ^D to\\nboot into default mode.' |
| 181 | ExecStart=-/bin/sh -c "@SULOGIN@; @SYSTEMCTL@ --job-mode=fail --no-block default" |