mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:24:57 +00:00
usermod: Add -G
option to modify supplementary groups
This commit is contained in:
parent
d7fccfc237
commit
caf55c0b2d
2 changed files with 22 additions and 1 deletions
|
@ -57,6 +57,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
StringView shell;
|
||||
StringView gecos;
|
||||
StringView username;
|
||||
Vector<gid_t> extra_gids;
|
||||
|
||||
auto args_parser = Core::ArgsParser();
|
||||
args_parser.set_general_help("Modify a user account");
|
||||
|
@ -74,6 +75,21 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return gid.has_value();
|
||||
},
|
||||
});
|
||||
args_parser.add_option(Core::ArgsParser::Option {
|
||||
.argument_mode = Core::ArgsParser::OptionArgumentMode::Required,
|
||||
.help_string = "Set the user's supplementary groups. Groups are specified with a comma-separated list. Group names or numbers may be used",
|
||||
.long_name = "groups",
|
||||
.short_name = 'G',
|
||||
.value_name = "groups",
|
||||
.accept_value = [&extra_gids](StringView comma_separated_groups) {
|
||||
auto groups = comma_separated_groups.split_view(',');
|
||||
for (auto group : groups) {
|
||||
if (auto gid = group_string_to_gid(group); gid.has_value())
|
||||
extra_gids.append(gid.value());
|
||||
}
|
||||
return true;
|
||||
},
|
||||
});
|
||||
args_parser.add_option(lock, "Lock password", "lock", 'L');
|
||||
args_parser.add_option(unlock, "Unlock password", "unlock", 'U');
|
||||
args_parser.add_option(new_home_directory, "The user's new login directory", "home", 'd', "new-home");
|
||||
|
@ -162,6 +178,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
target_account.set_gecos(gecos);
|
||||
}
|
||||
|
||||
if (!extra_gids.is_empty()) {
|
||||
target_account.set_extra_gids(extra_gids);
|
||||
}
|
||||
|
||||
TRY(Core::System::pledge("stdio wpath rpath cpath fattr"));
|
||||
|
||||
TRY(target_account.sync());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue