From 484365da7d8a505f14dacdec7a594be8d9e74810 Mon Sep 17 00:00:00 2001 From: Henrik Till Lemke Date: Fri, 16 Oct 2026 10:45:53 +0200 Subject: [PATCH] launcher-editor: on gac-* accounts, run as the person at the console via become A shared account shouldn't publish launcher changes under its own name. It now asks for the user name (zenity, like undulator-pointing), checks it, and runs launcher-editor as that user with become in a terminal (the password prompt needs one; the terminal stays open if login fails). --live and --help still run as the shared account. Without ~/network_drives (where the gitea SSH key is) and with a terminal at hand, it runs setup-network-drives before cloning/pulling. --- launcher-editor | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/launcher-editor b/launcher-editor index ae7c388..ff3085e 100755 --- a/launcher-editor +++ b/launcher-editor @@ -9,6 +9,10 @@ # Editing the Bernina launcher works on your own clone in ~/launcher_config. # Preview (F5) shows it in the real launcher; Publish commits and pushes it, # and the push deploys it to /sf/bernina/config/launcher. +# +# On a shared account (gac-*) it first asks for your own user name and runs +# the editor as you via `become` (password in a terminal), so changes are +# published under your name. --live and --help work as the shared account. # Update the app: git -C /sf/bernina/applications/launcher_editor pull APP=/sf/bernina/applications/launcher_editor @@ -20,6 +24,28 @@ ROOT=S_Bernina.json PREVIEW="epics_launcher --position 80 -120" NOTE="Publishing pushes to gitea, which deploys to $LIVE within about a minute. A launcher that is already open shows the change after it is restarted." +if [[ $USER == gac-* && $1 != --live && $1 != -h && $1 != --help ]]; then + me=$(zenity --entry --width=460 --title="Launcher editor" --text="You are logged in as $USER, a shared account. + +Launcher changes are published under your own name, so the editor runs as you on this console. You will be asked for your password in a terminal. + +Your PSI user name:" 2>/dev/null) || exit 0 + me=${me//[[:space:]]/} + if [ -z "$me" ] || [[ $me == gac-* ]] || ! id -- "$me" >/dev/null 2>&1; then + zenity --error --no-markup --width=420 --title="Launcher editor" \ + --text="Not a valid personal user name: ${me:-(empty)}" 2>/dev/null + exit 1 + fi + inner="/sf/bernina/bin/launcher-editor${*:+ $(printf '%q ' "$@")}" + if [ -t 0 ] && [ -t 1 ]; then + exec become "$me" -c "$inner" + fi + exec gnome-terminal --title="Launcher editor as $me" --wait -- bash -c ' + echo "Launcher editor: log in as $1 (your password)" + become "$1" -c "$2" || { echo; read -rp "Login or editor failed. Press Enter to close." _; }' \ + _ "$me" "$inner" +fi + source /sf/bernina/bin/bpy-env.sh >/dev/null editor() { @@ -36,6 +62,13 @@ zenity --question --width=440 --title="Launcher editor" \ Your own copy in ~/launcher_config is updated from gitea and opened. Preview (F5) shows your changes in the real launcher; Publish makes them live on all consoles." \ 2>/dev/null || editor +# The gitea SSH key lives on ~/network_drives. In a session without it +# (e.g. after `become`) mount it now, while we have a terminal for kinit. +if [ ! -d "$HOME/network_drives/home" ] && [ -t 0 ]; then + echo "Mounting ~/network_drives (needed for your gitea SSH key)..." + setup-network-drives || true +fi + export GIT_TERMINAL_PROMPT=0 GIT_SSH_COMMAND="ssh -o BatchMode=yes" if [ ! -d "$WORK/.git" ]; then if ! out=$(git clone -q "$REPO" "$WORK" 2>&1); then