Add config option to prevent primary group removal (#405)

This commit is contained in:
Luck 2017-09-04 17:03:17 +01:00
parent 925d3ccd1b
commit 754c7d8e3b
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
5 changed files with 20 additions and 1 deletions

View File

@ -105,6 +105,10 @@ temporary-add-behaviour: deny
# directly and indirectly
primary-group-calculation: stored
# If set to false, the plugin will allow a Users primary group to be removed with the
# 'parent remove' command, and will set their primary group back to default.
prevent-primary-group-removal: false
# If the plugin should check for "extra" permissions with users run LP commands.
#
# These extra permissions allow finer control over what users can do with each command, and

View File

@ -108,6 +108,10 @@ temporary-add-behaviour: deny
# directly and indirectly
primary-group-calculation: stored
# If set to false, the plugin will allow a Users primary group to be removed with the
# 'parent remove' command, and will set their primary group back to default.
prevent-primary-group-removal: false
# If the plugin should check for "extra" permissions with users run LP commands.
#
# These extra permissions allow finer control over what users can do with each command, and

View File

@ -79,7 +79,8 @@ public class ParentRemove extends SharedSubCommand {
if (holder instanceof User) {
User user = (User) holder;
boolean shouldPrevent = (context.isEmpty() || context.has("server", "global")) &&
boolean shouldPrevent = plugin.getConfiguration().get(ConfigKeys.PREVENT_PRIMARY_GROUP_REMOVAL) &&
context.isEmpty() &&
plugin.getConfiguration().get(ConfigKeys.PRIMARY_GROUP_CALCULATION_METHOD).equals("stored") &&
user.getPrimaryGroup().getStoredValue().equalsIgnoreCase(groupName);

View File

@ -166,6 +166,12 @@ public class ConfigKeys {
}
}));
/**
* If set to false, the plugin will allow a Users primary group to be removed with the
* 'parent remove' command, and will set their primary group back to default.
*/
public static final ConfigKey<Boolean> PREVENT_PRIMARY_GROUP_REMOVAL = BooleanKey.of("prevent-primary-group-removal", true);
/**
* If the plugin should check for "extra" permissions with users run LP commands
*/

View File

@ -106,6 +106,10 @@ temporary-add-behaviour="deny"
# directly and indirectly
primary-group-calculation="parents-by-weight"
# If set to false, the plugin will allow a Users primary group to be removed with the
# 'parent remove' command, and will set their primary group back to default.
prevent-primary-group-removal=false
# If the plugin should check for "extra" permissions with users run LP commands.
#
# These extra permissions allow finer control over what users can do with each command, and