Terminal: show the live full working-directory path in the toolbar
Deploy Ladill Hosting / deploy (push) Successful in 45s
Deploy Ladill Hosting / deploy (push) Successful in 45s
The toolbar showed a static ~/public_html. The jailed shell now reports its cwd via OSC 7 each prompt (jail rcfile keeps the user's prompt + emits it); xterm captures it and the toolbar shows the full path (/home/<user>/...), updating as the user cd's. Launcher/rcfile committed in deployment/ for reproducibility. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
d7b47e67fb
commit
75ba450938
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<div class="flex items-center gap-2 pl-3">
|
||||
<span class="font-mono text-xs text-white/40">{{ $account->username }}@ladill</span>
|
||||
<span class="text-white/20">:</span>
|
||||
<span class="font-mono text-xs text-emerald-400/80" x-text="promptPath()">~</span>
|
||||
<span class="font-mono text-xs text-emerald-400/80" x-text="fullPath">~</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user