-
Notifications
You must be signed in to change notification settings - Fork 132
feat: Add user management daemon #309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: Add user management daemon #309
Conversation
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
data/debian/rules
Outdated
%: | ||
dh $@ | ||
|
||
override_dh_auto_build: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these changes have no effect?
You override the default behaviour (dh_auto_build
) and then invoke the default behaviour (dh_auto_build
).
153ac44
to
2846d1f
Compare
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
// Add user to role-specific groups | ||
for (const std::string& group : it->second) { | ||
if (!is_user_in_group(username, group)) { | ||
std::vector<std::string> cmd = {"/usr/sbin/usermod", "-a", "-G", group, username}; | ||
SystemCommand::execute(cmd); // Don't fail if group doesn't exist | ||
SWSS_LOG_DEBUG("Added user %s to group %s", username.c_str(), group.c_str()); | ||
} else { | ||
SWSS_LOG_DEBUG("User %s already in group %s", username.c_str(), group.c_str()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we ever need to remove users from a group? For example if one is downgraded from admin to operator?
userd/src/userd.cpp
Outdated
bool set_user_password(const std::string& username, const std::string& password_hash) { | ||
std::vector<std::string> cmd = {"/usr/sbin/usermod", "-p", password_hash, username}; | ||
|
||
if (!SystemCommand::execute(cmd)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SystemCommand::execute
with log the hash as well. Do we want that?
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
2846d1f
to
3bbde60
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. Build System Integration:
3. Security Features: