diff options
-rw-r--r-- | lib/cmd/shell.sh | 24 | ||||
-rw-r--r-- | lib/session.sh | 11 |
2 files changed, 15 insertions, 20 deletions
diff --git a/lib/cmd/shell.sh b/lib/cmd/shell.sh index 9f5b6ba..c2570e0 100644 --- a/lib/cmd/shell.sh +++ b/lib/cmd/shell.sh @@ -24,7 +24,7 @@ use session cmd_shell_main() { local root= - local uname_s= + local session_dir= if [ ${#} -lt 1 ]; then print_cmd_usage 'shell' >&2 @@ -37,28 +37,14 @@ cmd_shell_main() . "${root}/etc/os-release" profile_set "${ID}" - uname_s="$( (uname -s) 2>/dev/null)" || uname_s='unknown' - mkdir -p "${root}/prokit/wd/${$}" - case "${uname_s}" in - 'Linux') - mount -o bind . "${root}/prokit/wd/${$}" - ;; - esac - - session_begin "${root}" : + session_begin "${root}" . : + session_dir="/prokit/sessions/$(session_id)" if [ ${#} -eq 0 ]; then - chroot "${root}" /bin/sh -c "cd '/prokit/wd/${$}'; /bin/sh" + chroot "${root}" /bin/sh -c "cd '${session_dir}'; /bin/sh" printf '\n' info "$(get_msg 'cmd_shell_exiting')" else - chroot "${root}" /bin/sh -c "cd '/prokit/wd/${$}'; ${*}" + chroot "${root}" /bin/sh -c "cd '${session_dir}'; ${*}" fi session_end - - case "${uname_s}" in - 'Linux') - umount "${root}/prokit/wd/${$}" - ;; - esac - rmdir "${root}/prokit/wd/${$}" } diff --git a/lib/session.sh b/lib/session.sh index 0d66eeb..e189277 100644 --- a/lib/session.sh +++ b/lib/session.sh @@ -31,18 +31,21 @@ session_id= session_root= session_arch= session_plat= +session_mountdir= session_atexit= session_begin() { local root="${1}" - local atexit="${2}" + local mountdir="${2}" + local atexit="${3}" rand session_id=${rand_x} session_root="${root}" session_arch="$(cat "${root}/etc/proteanos_arch")" session_plat="$(cat "${root}/etc/proteanos_plat")" + session_mountdir="${mountdir}" session_atexit="${atexit}" if ! mutex_lock_timeout "${session_root}/prokit/sessions.lock" 5; then @@ -68,6 +71,9 @@ session_begin() # Register the session. mkdir "${session_root}/prokit/sessions/${session_id}" + profile_bind_mount "${session_arch}" "${session_plat}" \ + "${session_mountdir}" \ + "${session_root}/prokit/sessions/${session_id}" mutex_unlock "${session_root}/prokit/sessions.lock" } @@ -75,6 +81,9 @@ session_begin() session_end() { # Unregister the session. + profile_bind_umount "${session_arch}" "${session_plat}" \ + "${session_mountdir}" \ + "${session_root}/prokit/sessions/${session_id}" rmdir "${session_root}/prokit/sessions/${session_id}" if ! mutex_lock_timeout "${session_root}/prokit/sessions.lock" 5; then |