Resolve "[sync] Improve login_enabled field accuracy with native Linux checks" #170
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
Collect raw login data in alpamon and send to server for improved
login_enabledaccuracy.shadow_expire_date:*int64- raw value transmitted (days since epoch)valid_shells:[]string- full /etc/shells list transmittedServer determines
login_enabledusing this raw data, enabling policy changes without agent updates.Changes
pkg/runner/commit_types.go
UserDatastructshadowEntrystruct (internal use)GetData()methodpkg/runner/commit.go
loadValidShells(): Parse /etc/shells and return[]stringloadShadowData(): Parse /etc/shadow for password lock and expire dategetUserData(): Collect raw data and include in UserDatapkg/runner/commit_test.go
TestLoadValidShells: Test /etc/shells parsingTestLoadShadowData: Test /etc/shadow parsingTestGetUserDataWithRawFields: Test raw data fieldsAPI 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
Test Plan
go build ./...succeedsgo test ./pkg/runner/...passesRelated Issues
login_enabledfield accuracy with native Linux checks #169