diff --git a/deployment/ladill-jail-bashrc b/deployment/ladill-jail-bashrc new file mode 100644 index 0000000..680307f --- /dev/null +++ b/deployment/ladill-jail-bashrc @@ -0,0 +1,8 @@ +# Ladill jail interactive shell rc: keep the user's shell config, start in the +# requested directory, and report the working directory to the control panel via +# OSC 7 on every prompt so the toolbar shows the live full path. +[ -r /etc/bash.bashrc ] && . /etc/bash.bashrc +[ -r "$HOME/.bashrc" ] && . "$HOME/.bashrc" +[ -n "${LADILL_START_DIR:-}" ] && cd "$LADILL_START_DIR" 2>/dev/null +__ladill_cwd() { printf '\033]7;file://%s%s\007' "${HOSTNAME:-ladill}" "$PWD"; } +case "$-" in *i*) PROMPT_COMMAND="__ladill_cwd${PROMPT_COMMAND:+; $PROMPT_COMMAND}"; __ladill_cwd ;; esac diff --git a/deployment/ladill-jailsh b/deployment/ladill-jailsh index 19f409b..e4df9a4 100755 --- a/deployment/ladill-jailsh +++ b/deployment/ladill-jailsh @@ -28,5 +28,5 @@ mount -t tmpfs -o mode=0755,nosuid,nodev tmpfs "$JAIL/run" mount --bind "$JAIL/run/passwd" "$JAIL/etc/passwd" mount --bind "$JAIL/run/group" "$JAIL/etc/group" export HOME="/home/$U" USER="$U" LOGNAME="$U" SHELL=/bin/bash PATH=/usr/bin:/bin -export TERM="${TERM:-xterm-256color}" -exec /usr/sbin/chroot --userspec="$UID_:$GID_" "$JAIL" /bin/bash -l -c "cd '/home/$U$REL' 2>/dev/null || cd ~; exec /bin/bash -l" +export TERM="${TERM:-xterm-256color}" LADILL_START_DIR="/home/$U$REL" HOSTNAME="$(hostname 2>/dev/null || echo ladill)" +exec /usr/sbin/chroot --userspec="$UID_:$GID_" "$JAIL" /bin/bash --rcfile /etc/ladill-jail-bashrc -i diff --git a/deployment/setup-terminal-jail.sh b/deployment/setup-terminal-jail.sh index ee88290..9c64957 100755 --- a/deployment/setup-terminal-jail.sh +++ b/deployment/setup-terminal-jail.sh @@ -27,6 +27,9 @@ install -d -m 1777 "$JAIL/tmp" # any customer enumerate every tenant. ladill-jailsh injects a per-session # passwd/group (root + the current user only) inside each session's namespace. +echo "==> Installing the interactive rc (keeps user prompt + reports cwd via OSC 7)" +install -o root -g root -m 644 "$(dirname "$0")/ladill-jail-bashrc" "$JAIL/etc/ladill-jail-bashrc" + echo "==> Installing the jailed-shell launcher + scoped sudoers" install -o root -g root -m 755 "$(dirname "$0")/ladill-jailsh" /usr/local/sbin/ladill-jailsh echo 'www-data ALL=(root) NOPASSWD: /usr/local/sbin/ladill-jailsh *' > /etc/sudoers.d/ladill-jailsh diff --git a/resources/js/hosting-terminal.js b/resources/js/hosting-terminal.js index 8ecf6b5..d444569 100644 --- a/resources/js/hosting-terminal.js +++ b/resources/js/hosting-terminal.js @@ -25,6 +25,11 @@ window.hostingInteractiveTerminal = (config = {}) => { termHasOutput: false, currentPath: config.initialPath ?? '/public_html', currentPathLabel: `Starting in ${config.initialPath === '/' ? `/home/${config.username ?? ''}` : `/home/${config.username ?? ''}${config.initialPath ?? '/public_html'}`}`, + // Full working-directory path shown in the toolbar; updated live from the + // shell's OSC 7 cwd report as the user navigates. + fullPath: config.initialPath === '/' + ? `/home/${config.username ?? ''}` + : `/home/${config.username ?? ''}${config.initialPath ?? '/public_html'}`, promptPath() { if (this.currentPath === '/' || !this.currentPath) { return '~'; @@ -79,6 +84,18 @@ window.hostingInteractiveTerminal = (config = {}) => { this.fitAddon = new FitAddon(); this.term.loadAddon(this.fitAddon); this.term.open(this.$refs.terminal); + // The shell reports its working directory via OSC 7 (file://host/path); + // capture it so the toolbar shows the live full path as the user cd's. + this.term.parser?.registerOscHandler(7, (data) => { + try { + let p = String(data || '').replace(/^file:\/\/[^/]*/, ''); + p = decodeURIComponent(p); + if (p) { + this.fullPath = p.replace(/\/$/, '') || '/'; + } + } catch (e) { /* ignore malformed cwd reports */ } + return true; + }); this.term.onData((data) => { if (this.sessionId) { this.queueInput(data); diff --git a/resources/views/hosting/panel/terminal.blade.php b/resources/views/hosting/panel/terminal.blade.php index 3271922..08e4cc3 100644 --- a/resources/views/hosting/panel/terminal.blade.php +++ b/resources/views/hosting/panel/terminal.blade.php @@ -24,7 +24,7 @@