Skip to content

Auto-configure SCREENDIR in sudoers during server installation - #148

Merged
elyxlz merged 5 commits into
masterfrom
fix/auto-configure-screendir-sudoers
Nov 24, 2025
Merged

Auto-configure SCREENDIR in sudoers during server installation#148
elyxlz merged 5 commits into
masterfrom
fix/auto-configure-screendir-sudoers

Conversation

@elyxlz

@elyxlz elyxlz commented Nov 24, 2025

Copy link
Copy Markdown
Owner

Summary

Fixes nx attach by auto-configuring SCREENDIR environment variable in sudoers during server installation. No manual configuration needed.

Problem

PR #146 and #147 fixed the client-side attach logic, but users still need to manually configure sudoers to allow SCREENDIR environment variable, which is error-prone and requires system knowledge.

Solution

Modified setup_passwordless_nexus_attach() in src/nexus/server/installation/setup.py to automatically add Defaults env_keep += "SCREENDIR" to /etc/sudoers.d/nexus_attach during installation.

Changes

  • Line 156: Added Defaults env_keep += "SCREENDIR" to sudoers content
  • Bumped version to 0.5.35

Result

After running sudo nexus-server install, nx attach will work immediately without any additional configuration:

  • Server creates screens in /tmp/nexus-screen/
  • Client can attach using sudo -u nexus SCREENDIR=/tmp/nexus-screen screen -r ...
  • SCREENDIR passes through sudo thanks to auto-configured env_keep

Test Plan

  • Install server: sudo nexus-server install
  • Verify /etc/sudoers.d/nexus_attach contains env_keep line
  • Run job: nx add "sleep 100"
  • Test attach: nx attach <job_id> (should work without password prompt)

🤖 Generated with Claude Code

elyxlz and others added 5 commits November 24, 2025 17:11
Modified setup_passwordless_nexus_attach() to add SCREENDIR to env_keep
in /etc/sudoers.d/nexus_attach during installation. This allows nx attach
to work without manual sudoers configuration.

Changes:
- Added "Defaults env_keep += \"SCREENDIR\"" to sudoers file
- Bumped version to 0.5.35

Now nx attach works automatically after running: sudo nexus-server install

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

Co-Authored-By: Claude <noreply@anthropic.com>
Major refactoring to simplify screen session attachment:

Server changes:
- Added screen_dir config field (default: /tmp/nexus-screen)
- Updated job.py to use config.screen_dir
- Removed restrictive chmod(0o700) - rely on setup permissions

Setup changes:
- Fixed directory name: /tmp/screen_nexus → /tmp/nexus-screen
- Removed sudoers configuration (no longer needed)
- Updated _check_screen_permissions to check correct directory

Client changes:
- Simplified attach to use screen multiuser mode (-x flag)
- No sudo required - uses SCREENDIR env var only
- Removed all fallback logic for clean, fail-fast behavior
- Remote: ssh ... "SCREENDIR=/tmp/nexus-screen screen -x nexus/{session}"
- Local: SCREENDIR=/tmp/nexus-screen screen -x nexus/{session}

Result: Clean, simple attachment with no sudo complexity

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

Co-Authored-By: Claude <noreply@anthropic.com>
Screen requires non-world-writable permissions for security.
Changed from 0o1777 to 0o755 in both setup and check functions.
Screen requires mode 700 for SCREENDIR which prevents multiuser access.
Solution: Don't override SCREENDIR at all - let screen use its default location.

Changes:
- Removed screen_dir from server config
- Removed SCREENDIR override from job.py
- Removed SCREENDIR from client attach commands
- Client uses "screen -x nexus/{session}" which finds sessions automatically

With setuid screen and multiuser mode, this works without any directory overrides.

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

Co-Authored-By: Claude <noreply@anthropic.com>
@elyxlz
elyxlz merged commit 5a85e26 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