Skip to content

Fix nx attach sudo password prompt - #147

Merged
elyxlz merged 2 commits into
masterfrom
fix/nx-attach-sudo-env-syntax
Nov 24, 2025
Merged

Fix nx attach sudo password prompt#147
elyxlz merged 2 commits into
masterfrom
fix/nx-attach-sudo-env-syntax

Conversation

@elyxlz

@elyxlz elyxlz commented Nov 24, 2025

Copy link
Copy Markdown
Owner

Summary

Fixes sudo password prompt issue in nx attach that appeared after PR #146 was merged.

Problem

PR #146 added env SCREENDIR=/tmp/nexus-screen to fix screen session detection, but this caused sudo to prompt for a password:

sudo -u nexus env SCREENDIR=/tmp/nexus-screen screen -r ...

Root Cause

The sudoers configuration typically whitelists specific commands (like /usr/bin/screen) for passwordless execution. When we added the env command, sudo now sees us trying to run /usr/bin/env instead of /usr/bin/screen, which isn't whitelisted.

Solution

Use sudo's built-in environment variable syntax instead of the env command:

sudo -u nexus SCREENDIR=/tmp/nexus-screen screen -r ...

This passes the environment variable directly through sudo without needing to whitelist the env binary.

Changes

  • Remote SSH attach: Removed "env" from command array (src/nexus/cli/jobs.py:1182)
  • Local sudo attach: Removed "env" from command array (src/nexus/cli/jobs.py:1198)

Test Plan

  • Verify nx attach <job_id> works on remote target without password prompt
  • Verify nx attach <job_id> works on local target
  • Confirm SCREENDIR is still correctly set and screen sessions are found

🤖 Generated with Claude Code

elyxlz and others added 2 commits November 24, 2025 16:19
Changed from using the env command to sudo's native environment variable passing:
- Before: sudo -u nexus env SCREENDIR=/tmp/nexus-screen screen -r ...
- After:  sudo -u nexus SCREENDIR=/tmp/nexus-screen screen -r ...

This avoids requiring the env binary to be whitelisted in sudoers while still setting SCREENDIR correctly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@elyxlz
elyxlz merged commit b08919e into master Nov 24, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant