Skip to content
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2af27c6
add auth manager and related changes
Aug 5, 2025
a6e2e7e
add test code and fix authmanager
Aug 6, 2025
b44eff0
Update cmd/alpamon/command/root.go
hyunwoo-alps Aug 6, 2025
8c8ea5f
Update pkg/runner/auth_manager.go
hyunwoo-alps Aug 6, 2025
2d22993
Fix connection leak in handleSudoRequest by adding explicit unix_conn…
Aug 6, 2025
2842fd2
Fix golangci-lint issues: handle error return values and unused fields
Aug 6, 2025
1a36799
Fix staticcheck SA1006 by using fmt.Sprintf instead of string concate…
Aug 6, 2025
82b8b33
modify socket path directory management
Aug 7, 2025
5589152
add local fall back and alpacon_approval.c
Aug 18, 2025
c12ee1a
fix mistake
Aug 18, 2025
1ba9fd6
Update pkg/runner/pty.go
hyunwoo-alps Aug 19, 2025
8419b0e
Update pkg/runner/auth_manager.go
hyunwoo-alps Aug 19, 2025
8c89095
update build
Aug 20, 2025
36d51ae
Merge branch '99-sudo-privilege-verification-and-centralized-manageme…
Aug 20, 2025
0ea7abb
Merge remote-tracking branch 'origin' into 99-sudo-privilege-verifica…
junho226 Nov 10, 2025
5470e3d
docs: add alpamon-pam as recommended package and update README
junho226 Nov 21, 2025
779bf92
Merge remote-tracking branch 'origin' into 99-sudo-privilege-verifica…
junho226 Nov 21, 2025
ab7a614
refactor: convert Korean comments to English
junho226 Nov 24, 2025
e94ed9a
feat(auth): implement centralized sudo approval via MFA authentication
junho226 Nov 25, 2025
d92a672
fix(runner): use Msgf instead of Msg with fmt.Sprintf for proper form…
junho226 Nov 25, 2025
79aeaad
fix(runner): replace Err with Str for string error logging
junho226 Nov 25, 2025
628ad43
fix(auth): resolve mutex unlock bug and improve connection lifecycle
junho226 Nov 25, 2025
4a43682
refactor: standardize is_alpacon_user field naming in auth structs
junho226 Nov 25, 2025
8d7dc9b
Merge remote-tracking branch 'origin' into 99-sudo-privilege-verifica…
junho226 Nov 26, 2025
828d370
refactor(runner): remove unconditional sudo group addition
junho226 Nov 27, 2025
b2a1fae
feat(runner): add ControlClient for server control channel
junho226 Nov 28, 2025
90ab531
fix: correct typo in response type (is_alpcon_response -> is_alpacon_…
junho226 Dec 1, 2025
25203cb
fix(package): change alpamon-pam dependency from recommends to suggests
junho226 Dec 1, 2025
0089a78
fix: address PR review feedback for auth manager
junho226 Dec 22, 2025
ea20dfe
Merge remote-tracking branch 'origin' into 99-sudo-privilege-verifica…
junho226 Dec 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,16 @@ nfpms:
- sqlite3
- nftables | iptables
file_name_template: '{{ .PackageName }}_{{ trimprefix .Version "v" }}_{{ .Os }}_{{ .Arch }}'
suggests:
- alpamon-pam
rpm:
dependencies:
- zip
- sqlite
- nftables | iptables
file_name_template: '{{ .PackageName }}-{{ trimprefix .Version "v" }}-1.{{ .Os }}.{{ .Arch }}'
suggests:
- alpamon-pam

changelog:
sort: asc
Expand Down
15 changes: 12 additions & 3 deletions Dockerfiles/ubuntu/22.04/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
FROM golang:1.23 AS builder

# Set golang env
# Automatically set GOARCH to the build-time architecture
ARG TARGETARCH
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64
GOARCH=${TARGETARCH:-amd64}

WORKDIR /build

Expand All @@ -18,7 +19,15 @@ RUN go build -o alpamon ./cmd/alpamon/main.go

FROM ubuntu:22.04

RUN apt-get update && apt-get install -y --no-install-recommends systemd ca-certificates
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
systemd \
ca-certificates \
sudo \
vim \
build-essential \
libpam0g-dev \
libjansson-dev

WORKDIR /usr/local/alpamon

Expand Down
5 changes: 5 additions & 0 deletions Dockerfiles/ubuntu/22.04/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ EOL
echo -e "\nThe following configuration file is being used:\n"
cat /etc/alpamon/alpamon.conf

echo "[entrypoint] creating /var/run/alpamon..."
mkdir -p /var/run/alpamon
chown root:root /var/run/alpamon
chmod 750 /var/run/alpamon

exec /usr/local/alpamon/alpamon
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,45 @@ Download the latest `alpamon` directly from our releases page or install it usin
```bash
curl -s https://packagecloud.io/install/repositories/alpacax/alpamon/script.deb.sh?any=true | sudo bash

# Install alpamon (includes PAM module by default)
sudo apt-get install alpamon

# Install without PAM module
sudo apt-get install alpamon --no-install-recommends
```

#### CentOS and RHEL
```bash
curl -s https://packagecloud.io/install/repositories/alpacax/alpamon/script.rpm.sh?any=true | sudo bash

# Install alpamon (includes PAM module by default)
sudo yum install alpamon

# Install without PAM module
sudo yum install alpamon --setopt=install_weak_deps=False
```

### PAM Module

By default, `alpamon` installation includes the `alpamon-pam` package, which provides PAM (Pluggable Authentication Modules) integration for advanced authentication features:
- **pam_alpamon.so**: Verifies Alpacon users during sudo authentication
- **alpacon_approval.so**: Handles sudo command approval requests

#### Configuration
After installation, configure PAM and sudo to enable the authentication features:

1. Add to `/etc/pam.d/sudo`:
```
auth [user_unknown=ignore auth_err=die success=done default=bad] pam_alpamon.so
```

2. Add to `/etc/sudo.conf`:
```
Plugin approval_plugin alpacon_approval.so
```

**Note**: The Alpamon service must be running with socket at `/var/run/alpamon/auth.sock` for PAM authentication to work.

### macOS

#### Clone the source code
Expand Down
23 changes: 18 additions & 5 deletions cmd/alpamon/command/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,25 +99,32 @@ func runAgent() {
metricCollector.Start()
}

// Websocket Client
// Websocket Client (Backhaul - commands, sessions)
wsClient := runner.NewWebsocketClient(session)
go wsClient.RunForever(ctx)

// Control Client (Control - sudo approval)
controlClient := runner.NewControlClient()
go controlClient.RunForever(ctx)

authManager := runner.GetAuthManager(controlClient)
go authManager.Start(ctx)

for {
select {
case <-ctx.Done():
log.Info().Msg("Received termination signal. Shutting down...")
gracefulShutdown(metricCollector, wsClient, logRotate, logServer, pidFilePath)
gracefulShutdown(metricCollector, wsClient, controlClient, authManager, logRotate, logServer, pidFilePath)
return
case <-wsClient.ShutDownChan:
log.Info().Msg("Shutdown command received. Shutting down...")
cancel()
gracefulShutdown(metricCollector, wsClient, logRotate, logServer, pidFilePath)
gracefulShutdown(metricCollector, wsClient, controlClient, authManager, logRotate, logServer, pidFilePath)
return
case <-wsClient.RestartChan:
log.Info().Msg("Restart command received. Restarting...")
cancel()
gracefulShutdown(metricCollector, wsClient, logRotate, logServer, pidFilePath)
gracefulShutdown(metricCollector, wsClient, controlClient, authManager, logRotate, logServer, pidFilePath)
restartAgent()
return
case <-wsClient.CollectorRestartChan:
Expand All @@ -142,13 +149,19 @@ func restartAgent() {
}
}

func gracefulShutdown(collector *collector.Collector, wsClient *runner.WebsocketClient, logRotate *lumberjack.Logger, logServer *logger.LogServer, pidPath string) {
func gracefulShutdown(collector *collector.Collector, wsClient *runner.WebsocketClient, controlClient *runner.ControlClient, authManager *runner.AuthManager, logRotate *lumberjack.Logger, logServer *logger.LogServer, pidPath string) {
if collector != nil {
collector.Stop()
}
if wsClient != nil {
wsClient.Close()
}
if controlClient != nil {
controlClient.Close()
}
if authManager != nil {
authManager.Stop()
}
if logServer != nil {
logServer.Stop()
}
Expand Down
3 changes: 2 additions & 1 deletion configs/tmpfile.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ d /etc/alpamon 0700 root root - -
f /etc/alpamon/alpamon.conf 0600 root root - -
d /var/lib/alpamon 0750 root root - -
f /var/lib/alpamon/alpamon.db 0750 root root - -
d /var/log/alpamon 0750 root root - -
d /var/log/alpamon 0750 root root - -
d /var/run/alpamon 0750 root root - -
Loading