feat: Add user management daemon#309
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
153ac44 to
2846d1f
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
2846d1f to
3bbde60
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
This PR implements a user management daemon (userd) for SONiC that provides centralized user administration capabilities. The daemon integrates with CONFIG_DB to manage local users, roles, SSH keys, and security policies, replacing manual user management with an automated, database-driven approach.
Key Changes
- Core daemon implementation (userd.cpp): 1190-line C++ daemon using SWSS framework for CONFIG_DB integration, implementing full user lifecycle management (create/update/delete/enable/disable), role-based access control, SSH key management, and PAM faillock configuration
- Build and packaging infrastructure: Complete CMake build system, Debian packaging with systemd service configuration, and Makefile for compilation and installation
- Security policy templates: Jinja2 template for rendering PAM faillock configuration based on role-specific security policies
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 25 comments.
Show a summary per file
| File | Description |
|---|---|
| userd/src/userd.cpp | Main daemon implementation with UserManager class for CONFIG_DB-driven user lifecycle management, SSH key handling, PAM configuration, and security policy enforcement |
| userd/src/CMakeLists.txt | CMake build configuration with C++17, compiler flags, SWSS dependencies, and installation rules |
| userd/Makefile | Top-level Makefile with build-cpp, install, and clean targets for development and packaging |
| userd/debian/control | Debian package metadata with dependencies on SWSS, nlohmann-json, and crypt libraries |
| userd/debian/sonic-host-userd.service | Systemd service unit with dependencies on config-setup and sonic.target |
| userd/debian/rules | Debian packaging rules integrating with Makefile build system |
| userd/debian/install | Installation manifest placing userd binary in /usr/local/bin |
| userd/debian/changelog | Package changelog with initial release information |
| userd/debian/compat | Debhelper compatibility level 11 |
| userd/debian/copyright | Apache 2.0 license information |
| data/templates/faillock.conf.j2 | Jinja2 template for rendering PAM faillock configuration from security policies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@manoharan-nexthop can you resolve any open comments that are now resolved, human and AI. @aidan-gallagher could you take a look at this as the 202605 release is getting close and we would like to get this in |
3bbde60 to
1bfd8ad
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
1bfd8ad to
ecfc7c8
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
LGTM |
SONiC needed a centralized user management daemon that can: - Monitor CONFIG_DB for user configuration changes - Manage local system users based on SONiC configuration - Provide role-based access control with predefined groups - Handle SSH key management with proper security - Integrate with PAM for authentication policies - Support efficient change detection to minimize system calls **1. User Management Daemon (userd):** - Implemented C++ daemon using SWSS framework for CONFIG_DB integration - Added comprehensive user lifecycle management (create/update/delete/enable/disable) - Implemented role-based group assignment (administrator, operator roles) - Added SSH key management with proper file permissions and ownership - Used posix_spawn() for secure command execution without shell interpretation - Added efficient change detection using UserInfo comparison to avoid unnecessary system calls - Integrated PAM faillock configuration using Jinja2 templates **2. Build System Integration:** - Added CMakeLists.txt for C++ compilation with SWSS dependencies - Created debian packaging with proper control files and dependencies - Added systemd service configuration for userd daemon - Integrated Makefile for building and installation **3. Security Features:** - Secure password handling using system's native hashing methods - Proper file permissions for SSH keys (600) and directories (700) - Role-based group assignments with predefined security groups - PAM faillock integration for login attempt limiting - Input validation and sanitization for all user operations **4. Testing Framework:** - Added comprehensive unit tests for userd functionality - Integration tests for CONFIG_DB interaction - User lifecycle testing with proper cleanup - SSH key management testing - Role-based access control validation Signed-off-by: Manoharan Sundaramoorthy <manoharan@nexthop.ai>
- Add userd-rs crate with full user management functionality - Remove C++ userd implementation (userd/ directory) - Add userd binary to sonic-host-services-rs package - Add userd.service to sonic-host-services-data package Features: - User CRUD operations (create, update, delete) - Role-based access control (administrator, operator) - SSH key management with validation - Security policies and PAM faillock configuration - Consistency checking on startup - CONFIG_DB monitoring via SubscriberStateTable The Rust implementation is a drop-in replacement for the C++ version, producing the same 'userd' binary installed to /usr/local/bin/userd. Signed-off-by: Manoharan Sundaramoorthy <manoharan@nexthop.ai>
ecfc7c8 to
b8dfc9d
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This implementation addresses the User Management HLD requirements for centralized user administration in SONiC. sonic-net/SONiC#2018
1. User Management Daemon (userd):
2. Security Features: