Auto-configure SCREENDIR in sudoers during server installation - #148
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes
nx attachby 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()insrc/nexus/server/installation/setup.pyto automatically addDefaults env_keep += "SCREENDIR"to/etc/sudoers.d/nexus_attachduring installation.Changes
Defaults env_keep += "SCREENDIR"to sudoers contentResult
After running
sudo nexus-server install,nx attachwill work immediately without any additional configuration:/tmp/nexus-screen/sudo -u nexus SCREENDIR=/tmp/nexus-screen screen -r ...Test Plan
sudo nexus-server install/etc/sudoers.d/nexus_attachcontains env_keep linenx add "sleep 100"nx attach <job_id>(should work without password prompt)🤖 Generated with Claude Code