From 2e8b01970bc67dfc0d36d759e401a3451f562c32 Mon Sep 17 00:00:00 2001 From: scttfrdmn <3011922+scttfrdmn@users.noreply.github.com> Date: Mon, 20 Jul 2026 20:59:52 -0700 Subject: [PATCH] fix: run plugins as the instance login user, not hardcoded ec2-user Use the new {{ instance.login_user }} template var (spawn) instead of hardcoding ec2-user, so services + files land under the real login user (e.g. scttfrdmn): - jupyterlab/code-server/vscode-tunnel: systemd User= + config/home paths - rclone: rclone.conf + mount owner + systemd User= - docker: usermod -aG docker - github-actions-runner: chown runner dir + svc.sh install (config.sh already ran as_user) Caught in the smoke: jupyterlab/code-server had launched as ec2-user, writing to /home/ec2-user instead of the login user's home. Requires spawn with instance.login_user (merged, ships next release). Re-validated all 8 --strict. --- plugins/code-server/plugin.yaml | 27 +++++++++++++++-------- plugins/docker/plugin.yaml | 5 +++-- plugins/github-actions-runner/plugin.yaml | 8 ++++--- plugins/jupyterlab/plugin.yaml | 17 ++++++++------ plugins/rclone/plugin.yaml | 18 +++++++++------ plugins/vscode-tunnel/plugin.yaml | 7 +++--- 6 files changed, 51 insertions(+), 31 deletions(-) diff --git a/plugins/code-server/plugin.yaml b/plugins/code-server/plugin.yaml index fd7e5e3..5b8cb77 100644 --- a/plugins/code-server/plugin.yaml +++ b/plugins/code-server/plugin.yaml @@ -16,7 +16,7 @@ permissions: ports: - 8080 # code-server web UI (listens on loopback; reach via tunnel/Tailscale) files: - - /home/ec2-user/.config/code-server/config.yaml + - ~/.config/code-server/config.yaml # in the login user's home config: port: @@ -53,31 +53,40 @@ remote: set -eu PORT={{ config.port }} PASSWORD={{ config.password }} - # code-server reads ~/.config/code-server/config.yaml of the service user. - install -d -o ec2-user -g ec2-user /home/ec2-user/.config/code-server - cat > /home/ec2-user/.config/code-server/config.yaml < systemd template unit). + install -d -o "$LOGIN_USER" -g "$LOGIN_USER" "$HOME_DIR/.config/code-server" + cat > "$HOME_DIR/.config/code-server/config.yaml" < /etc/systemd/system/jupyterlab.service < /home/ec2-user/.config/rclone/rclone.conf - chown ec2-user:ec2-user /home/ec2-user/.config/rclone/rclone.conf - chmod 600 /home/ec2-user/.config/rclone/rclone.conf + LOGIN_USER={{ instance.login_user }} + HOME_DIR=$(getent passwd "$LOGIN_USER" | cut -d: -f6) + install -d -o "$LOGIN_USER" -g "$LOGIN_USER" "$HOME_DIR/.config/rclone" + printf '%s' "$CONF" > "$HOME_DIR/.config/rclone/rclone.conf" + chown "$LOGIN_USER:$LOGIN_USER" "$HOME_DIR/.config/rclone/rclone.conf" + chmod 600 "$HOME_DIR/.config/rclone/rclone.conf" - type: run run: | set -eu REMOTE={{ config.remote }} RPATH={{ config.path }} MOUNT_PATH={{ config.mount_path }} - install -d -o ec2-user -g ec2-user "$MOUNT_PATH" + LOGIN_USER={{ instance.login_user }} + HOME_DIR=$(getent passwd "$LOGIN_USER" | cut -d: -f6) + install -d -o "$LOGIN_USER" -g "$LOGIN_USER" "$MOUNT_PATH" # allow_other lets other users see the mount; requires user_allow_other in # /etc/fuse.conf, which we ensure. grep -q '^user_allow_other' /etc/fuse.conf 2>/dev/null || echo user_allow_other >> /etc/fuse.conf @@ -107,8 +111,8 @@ remote: [Service] Type=notify - User=ec2-user - ExecStart=/usr/bin/rclone mount ${REMOTE}:${RPATH} $MOUNT_PATH --config /home/ec2-user/.config/rclone/rclone.conf --allow-other --vfs-cache-mode writes + User=$LOGIN_USER + ExecStart=/usr/bin/rclone mount ${REMOTE}:${RPATH} $MOUNT_PATH --config $HOME_DIR/.config/rclone/rclone.conf --allow-other --vfs-cache-mode writes ExecStop=/bin/fusermount -u $MOUNT_PATH Restart=on-failure diff --git a/plugins/vscode-tunnel/plugin.yaml b/plugins/vscode-tunnel/plugin.yaml index 94362e8..e9f58ba 100644 --- a/plugins/vscode-tunnel/plugin.yaml +++ b/plugins/vscode-tunnel/plugin.yaml @@ -61,10 +61,11 @@ remote: run: | set -eu NAME={{ config.name }} + LOGIN_USER={{ instance.login_user }} NAME_ARG="" [ -n "$NAME" ] && NAME_ARG="--name $NAME" - # Per-user service: runs `code tunnel` as ec2-user so the device-login - # token and tunnel state persist under /home/ec2-user/.vscode-cli. + # Per-user service: runs `code tunnel` as the login user so the + # device-login token + tunnel state persist under that user's ~/.vscode-cli. cat > /etc/systemd/system/vscode-tunnel.service <