Skip to content

Conversation

@geunwoonoh
Copy link
Collaborator

@geunwoonoh geunwoonoh commented Jan 7, 2026

Summary

Collect raw login data in alpamon and send to server for improved login_enabled accuracy.

  • shadow_expire_date: *int64 - raw value transmitted (days since epoch)
  • valid_shells: []string - full /etc/shells list transmitted

Server determines login_enabled using this raw data, enabling policy changes without agent updates.

Changes

pkg/runner/commit_types.go

  • Add raw data fields to UserData struct
  • Add shadowEntry struct (internal use)
  • Update GetData() method

pkg/runner/commit.go

  • loadValidShells(): Parse /etc/shells and return []string
  • loadShadowData(): Parse /etc/shadow for password lock and expire date
  • getUserData(): Collect raw data and include in UserData

pkg/runner/commit_test.go

  • TestLoadValidShells: Test /etc/shells parsing
  • TestLoadShadowData: Test /etc/shadow parsing
  • TestGetUserDataWithRawFields: Test raw data fields

API Changes

Before:

{
  "uid": 4,
  "username": "sync",
  "shell": "/bin/sync"
}

After:

{
  "uid": 4,
  "username": "sync",
  "shell": "/bin/sync",
  "shadow_expire_date": null,
  "valid_shells": ["/bin/sh", "/bin/bash", "/bin/zsh"]
}

Backward Compatibility

alpamon alpacon-server Behavior
Old Old Server calculates from shell
Old New Server calculates from shell (fallback)
New Old Server ignores extra fields
New New Server uses raw data for accurate determination

Test Plan

  • go build ./... succeeds
  • go test ./pkg/runner/... passes
  • Test /etc/shadow reading on Linux (requires root)
  • Integration test with alpacon-server

Related Issues

Add fields for server-side login_enabled determination:
- PasswordLocked *bool: password lock status from
/etc/shadow
- ShadowExpireDate *int64: raw expiration date
(days since epoch)
- ValidShells []string: full /etc/shells list

Server will use this raw data to compute login_enabled,
enabling centralized security policy management.
- Add TestLoadValidShells: verify /etc/shells parsing returns []string
- Add TestLoadShadowData: verify /etc/shadow parsing with expireDate
- Add TestGetUserDataWithRawFields: verify raw data fields in UserData
- Update TestGetUserData comments for raw data field expectations
@geunwoonoh geunwoonoh requested a review from mingyu-00 January 7, 2026 13:50
@geunwoonoh geunwoonoh self-assigned this Jan 7, 2026
@geunwoonoh geunwoonoh linked an issue Jan 7, 2026 that may be closed by this pull request
8 tasks
Since alpamon runs with root privileges, websh/webftp can access
password-locked accounts regardless.
Remove unnecessary field.
Apply golint.
@geunwoonoh geunwoonoh merged commit d2e3bb1 into main Jan 8, 2026
5 checks passed
@geunwoonoh geunwoonoh deleted the 169-sync-improve-login_enabled-field-accuracy-with-native-linux-checks branch January 8, 2026 04:16
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.

[sync] Improve login_enabled field accuracy with native Linux checks

3 participants