-
Notifications
You must be signed in to change notification settings - Fork 496
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
NAS-131285 / 25.10 / Add API to migrate from root user #15441
base: master
Are you sure you want to change the base?
Conversation
This commit adds an API endpoint to migrate root user to one with the specified username and password combination. If password is omitted then the one currently used for root is preserved for the new admin account. Various root account parameters are migrated to the new admin account such as: * ssh keys * password enabled status * two factor authentication configuration and secret * email address * shell * home directory
class UserMigrateRootArgs(BaseModel): | ||
username: LocalUsername | ||
"""Username of new local user account to which to migration the root account. | ||
NOTE: user account nust not exist.""" |
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.
NOTE: user account nust not exist.""" | |
NOTE: user account must not exist.""" |
if filter_list(local_groups, [['group', '=', username]]): | ||
raise CallError(f'{username!r} group already exists, setting up local administrator is not possible', | ||
errno.EEXIST) | ||
# This should be relatively invexpensive even though it's a job since we |
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.
# This should be relatively invexpensive even though it's a job since we | |
# This should be relatively inexpensive even though it's a job since we |
|
||
os.chown(homedir, ADMIN_UID, ADMIN_GID) | ||
os.chmod(homedir, 0o700) | ||
home_copy_job = self.middleware.call_sync('user.do_home_copy', '/root', homedir, '700', ADMIN_UID) |
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.
Because this can take awhile, we should go ahead and print progress via the job object so we have some idea of what's going on. Probably should add job progress for the entirety of this method actually.
This commit adds an API endpoint to migrate root user to one with the specified username and password combination. If password is omitted then the one currently used for root is preserved for the new admin account. Various root account parameters are migrated to the new admin account such as: