mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Automatically remove existing system group if it exists when creating primary groups
This commit is contained in:
parent
74c1478b74
commit
3b670b6cf9
2 changed files with 6 additions and 1 deletions
|
@ -221,6 +221,7 @@
|
|||
"good_practices_about_user_password": "You are now about to define a new user password. The password should be at least 8 characters—though it is good practice to use longer password (i.e. a passphrase) and/or to a variation of characters (uppercase, lowercase, digits and special characters).",
|
||||
"group_already_exist": "Group {group} already exists",
|
||||
"group_already_exist_on_system": "Group {group} already exists in the system groups",
|
||||
"group_already_exist_on_system_but_removing_it": "Group {group} already exists in the system groups, but YunoHost will remove it…",
|
||||
"group_created": "Group '{group}' created",
|
||||
"group_creation_failed": "Could not create the group '{group}': {error}",
|
||||
"group_cannot_edit_all_users": "The group 'all_users' cannot be edited manually. It is a special group meant to contain all users registered in YunoHost",
|
||||
|
|
|
@ -576,7 +576,11 @@ def user_group_create(operation_logger, groupname, gid=None, primary_group=False
|
|||
# Validate uniqueness of groupname in system group
|
||||
all_existing_groupnames = {x.gr_name for x in grp.getgrall()}
|
||||
if groupname in all_existing_groupnames:
|
||||
raise YunohostError('group_already_exist_on_system', group=groupname)
|
||||
if primary_group:
|
||||
logger.warning('group_already_exist_on_system_but_removing_it', group=groupname)
|
||||
subprocess.check_call("sed --in-place '/^%s:/d' /etc/group" % groupname, shell=True)
|
||||
else:
|
||||
raise YunohostError('group_already_exist_on_system', group=groupname)
|
||||
|
||||
if not gid:
|
||||
# Get random GID
|
||||
|
|
Loading…
Add table
Reference in a new issue