[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] odd/rh_server df80604: Attempt, forlornly, to use `l
[lmi-commits] [lmi] odd/rh_server df80604: Attempt, forlornly, to use `logname` on redhat server
Mon, 24 Feb 2020 11:28:26 -0500 (EST)
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Attempt, forlornly, to use `logname` on redhat server
Hardcoding 'NORMAL_USER=greg' etc. is okay on a single-user machine.
On a corporate redhat server where we cannot create user accounts, the
quickest workaround is to edit the setup file by hand, but that's not
Calling logname seemed like a good idea, but this server uses something
like LDAP and doesn't show normal users in /etc/passwd , and it seems
impossible to find the login name from within 'sudo schroot -u root'.
- Maintain a ~/.lmi_identity file; but then '~' must be found by some
means other than /home/$(logname), if that's even possible
- pass parameters to schroot as
schroot [options] -- sh -c "FOO=bar ./eraseme.sh"
which is blecherous
- pass parameters to schroot as "user-modifiable keys"; but that seems
to affect only the environment in which schroot startup scripts run,
rather than the environment of the schroot itself
The last of those options seems clearly best. It requires changing the
schroot 'type' from 'plain' to 'directory'. But that change must be made
anyway, for schroot-1.7.3:
| The plain, loopback, lvm-snapshot and block-device chroot types have
| been removed.
and is desirable because it enables automatic mounting of required
directories like /proc and /dev/pts .
lmi_setup_inc.sh | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/lmi_setup_inc.sh b/lmi_setup_inc.sh
index bbd2196..f8eac42 100755
@@ -28,15 +28,20 @@
# shellcheck disable=SC2034
# (this file should only be sourced)
+# $(logname) should do what POSIX says, even if gnome disagrees:
+# A more complicated method can be considered if this becomes an
+# actual problem for lmi.
+NORMAL_USER=$(id -un "$(logname)")
+NORMAL_USER_UID=$(id -u "$(logname)")
+NORMAL_GROUP=$(id -gn "$(logname)")
+NORMAL_GROUP_GID=$(id -g "$(logname)")
# For a server that, bizarrely, blocks gnu.org but allows github.com: