Skip to content

feat: Add user management daemon#309

Open
manoharan-nexthop wants to merge 2 commits into
sonic-net:masterfrom
manoharan-nexthop:sonic-net.user-management
Open

feat: Add user management daemon#309
manoharan-nexthop wants to merge 2 commits into
sonic-net:masterfrom
manoharan-nexthop:sonic-net.user-management

Conversation

@manoharan-nexthop
Copy link
Copy Markdown

@manoharan-nexthop manoharan-nexthop commented Sep 8, 2025

This implementation addresses the User Management HLD requirements for centralized user administration in SONiC. sonic-net/SONiC#2018

1. User Management Daemon (userd):

  • Implemented Rust daemon using SWSS framework for CONFIG_DB integration
  • Added 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
  • Integrated PAM faillock configuration using Jinja2 templates

2. Security Features:

  • Secure password handling using system's native hashing methods
  • Role-based group assignments with predefined security groups
  • PAM faillock integration for login attempt limiting

@mssonicbld
Copy link
Copy Markdown

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@manoharan-nexthop manoharan-nexthop changed the title [userd] Add user management daemon feat: Add user management daemon Sep 8, 2025
Comment thread data/debian/control Outdated
Comment thread data/debian/rules Outdated
Comment thread debian/control Outdated
Comment thread debian/control
@mssonicbld
Copy link
Copy Markdown

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Comment thread userd/src/userd.cpp Outdated
Comment thread userd/src/userd.cpp Outdated
@mssonicbld
Copy link
Copy Markdown

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Comment thread data/templates/faillock.conf.j2 Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread userd/src/userd.cpp Outdated
Comment thread userd/src/userd.cpp Outdated
Comment thread userd/src/userd.cpp Outdated
Comment thread userd/src/userd.cpp Outdated
Comment thread userd/src/userd.cpp Outdated
Comment thread userd/debian/changelog Outdated
Comment thread userd/src/userd.cpp Outdated
Comment thread userd/src/userd.cpp Outdated
Comment thread userd/src/userd.cpp Outdated
Comment thread userd/src/userd.cpp Outdated
@ronan-nexthop
Copy link
Copy Markdown

ronan-nexthop commented Apr 16, 2026

@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

@manoharan-nexthop manoharan-nexthop force-pushed the sonic-net.user-management branch from 3bbde60 to 1bfd8ad Compare April 16, 2026 14:27
@mssonicbld
Copy link
Copy Markdown

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@manoharan-nexthop manoharan-nexthop force-pushed the sonic-net.user-management branch from 1bfd8ad to ecfc7c8 Compare April 16, 2026 14:32
@mssonicbld
Copy link
Copy Markdown

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@aidan-gallagher
Copy link
Copy Markdown

@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

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>
@manoharan-nexthop manoharan-nexthop force-pushed the sonic-net.user-management branch from ecfc7c8 to b8dfc9d Compare May 24, 2026 17:41
@mssonicbld
Copy link
Copy Markdown

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

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.

7 participants