-
Notifications
You must be signed in to change notification settings - Fork 1
Resolve "[Alpamon Agent Refactoring] Integrate Main Branch Changes into Refactored Architecture" #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
geunwoonoh
merged 89 commits into
131-alpamon-agent-refactoring
from
162-alpamon-agent-refactoring-integrate-main-branch-changes-into-refactored-architecture
Dec 29, 2025
Merged
Conversation
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
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
…nt-via-mfa-authentication' of https://github.com/alpacax/alpamon into 99-sudo-privilege-verification-and-centralized-management-via-mfa-authentication
…tion-and-centralized-management-via-mfa-authentication
- Add alpamon-pam as recommended dependency in .goreleaser.yaml - Debian/Ubuntu: recommends alpamon-pam - CentOS/RHEL: recommends alpamon-pam - Update README.md with PAM module documentation - Add installation instructions with/without PAM module - Document PAM configuration steps for /etc/pam.d/sudo and /etc/sudo.conf - Add note about Alpamon service requirement for PAM authentication
…tion-and-centralized-management-via-mfa-authentication
Convert Korean comment in Dockerfile to English for better maintainability. Changes: - Dockerfiles/ubuntu/22.04/Dockerfile: Convert GOARCH architecture comment
Add AuthManager for centralized sudo privilege verification: - Unix domain socket server (/var/run/alpamon/auth.sock) - Handle check_user requests from pam_alpamon.so - Handle sudo_approval requests from alpacon_approval.so - Distinguish Alpacon users (pidToSessionMap) vs local users (localSudoRequests) - Retry logic with exponential backoff for WebSocket communication - Response routing back to PAM/sudo plugin via Unix socket Security improvements: - Root-only socket permissions (0600) - 30-second timeout to prevent DoS - Request ID based mapping for concurrent requests - Proper cleanup on timeout and connection errors Integration: - WebSocket communication with alpacon-server - Coordinate with PtyClient session management - Support both authenticated and local user approval flows
…atting Replace Msg(fmt.Sprintf(...)) with Msgf(...) to fix staticcheck SA1006 linting error. This resolves the golangci-lint failure in CI while maintaining the same functionality.
Use Str() instead of Err(fmt.Errorf()) to fix staticcheck SA1006 error. The result variable is already a string, so we use structured logging with Str().
- Fix critical mutex double unlock bug in HandleSudoApprovalResponse - Previously unlocked mutex inside loop, causing panic on second unlock - Now unlocks once after checking both alpacon and local requests - Improve connection lifecycle management in handleSudoRequest - Remove defer close() to prevent double-close with manual cleanup - Explicitly close connections after check_user requests - Document that sudo_approval connections are managed by response handlers - Add default case for unknown request types with proper cleanup - Improve timeout handling with explicit service shutdown cleanup
- Rename is_alpcon_user to is_alpacon_user for consistency - SudoApprovalRequest, SudoApprovalResponse structs - MFAResponse, IsAlpconResponse structs
Signed-off-by: sangyeong01 <[email protected]>
…tion-and-centralized-management-via-mfa-authentication
- Remove hardcoded sudo group addition in adduser - Sudo privilege is now controlled by alpacon-server via gids
- Add ControlClient to handle control WebSocket connection - Refactor client.go to separate control logic into control_client.go - Support sudo_approval request/response via control channel
- Rename variables to camelCase (unix_conn -> unixConn, sudo_approval_req -> sudoApprovalReq) - Add BaseRequest struct for type-safe request parsing - Extract createSendOperation method from sendSudoRequestWithRetry - Add completion channels for proper timeout handling - Close connection after sendSudoApprovalResponse in cleanupTimeoutRequest - Call RemovePIDSessionMapping when PtyClient disconnects
- Remove lumberjack dependency for log rotation - Output logs to stderr for systemd/journald to capture - Update systemd service to use journald (StandardOutput/Error=journal) - Add log viewing instructions to README
…tion-and-centralized-management-via-mfa-authentication
…nd-centralized-management-via-mfa-authentication feat: implement MFA-based sudo approval system
…tdout refactor(logger): remove lumberjack, use systemd journald for logging
feat: Support for Websh based TCP-tunneling
Add support for deploying packages to different PackageCloud repositories based on release tag patterns: - stable (alpamon): vX.Y.Z tags - latest (alpamon-latest): vX.Y.Z-rc.N tags - dev (alpamon-dev): vX.Y.Z-dev, -beta.N, -alpha.N tags Also enable automatic GitHub pre-release detection in goreleaser.
…loud-channels-stable-dev-latest
…ls-stable-dev-latest Resolve "Separate PackageCloud Channels (stable, dev, latest)"
…actoring-integrate-main-branch-changes-into-refactored-architecture
Add TunnelHandler to handle the following commands: opentunnel, closetunnel Define types and structs related to TunnelHandler.
Add fields related to tunneling functionality in conjunction with TunnelHandler.
…ation Update RegisterAll() to include TunnelHandler registration.
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
Integrates new features from main branch (Tunneling, Auth Manager, Logger refactoring, Ping/Pong) into the refactored architecture.
Changes
Test plan
go build -v ./...succeedsgo test -v ./... -p 1all tests passDetailed Changes
1. Tunneling Feature (PR #156 Integration)
New files:
pkg/executor/handlers/tunnel/tunnel.go- TunnelHandler implementationpkg/executor/handlers/tunnel/types.go- Data type definitionspkg/runner/tunnel_client.go- smux multiplexing tunnel clientpkg/runner/tunnel_worker.go- Tunnel worker subprocesspkg/runner/tunnel_linux.go- Linux privilege demotionpkg/runner/tunnel_darwin.go- macOS implementationpkg/tunnel/conn.go- WebSocket adapterpkg/tunnel/pool.go- Buffer poolcmd/alpamon/command/tunnel/tunnel.go- CLI commandModified files:
pkg/executor/factory.go- Register TunnelHandlerpkg/executor/handlers/common/types.go- Add OpenTunnel, CloseTunnel typespkg/executor/handlers/common/args.go- Add TargetPort fieldinternal/protocol/command.go- Add TargetPort mappingpkg/config/config.go- Add smux configuration2. Auth Manager / MFA Feature (PR #101 Integration)
New files:
pkg/runner/auth_manager.go- Sudo approval request management (Unix socket)pkg/runner/control_client.go- Control WebSocket clientModified files:
cmd/alpamon/command/root.go- ControlClient, AuthManager initialization and shutdownpkg/runner/pty.go- Add/remove PID mapping for PTY sessions3. Logger Refactoring (PR #160 Integration)
Modified files:
pkg/logger/logger.go- Remove lumberjack, output to stdout/stderrcmd/alpamon/command/root.go- Remove lumberjack-related code4. Ping/Pong Handler (PR #158 Integration)
Modified files:
pkg/runner/client.go- AddSendPongResponse(), handle ping queries5. Miscellaneous
.github/workflows/release.yml- PackageCloud channel separationconfigs/alpamon.service- systemd service configuration updatego.mod,go.sum- Add smux dependencyArchitecture Compliance
Compliance with refactoring architecture :
Security Considerations
127.0.0.1)Concurrency Safety
Related Issues/PRs