👷 gucc: add option to create system group

This commit is contained in:
Vladislav Nepogodin 2024-07-04 11:32:57 +04:00
parent bb43ad5def
commit cfd260855c
No known key found for this signature in database
GPG Key ID: B62C3D10C54D5DA9
2 changed files with 3 additions and 3 deletions

View File

@ -15,7 +15,7 @@ struct UserInfo final {
};
// Create group on the system
auto create_group(std::string_view group, std::string_view mountpoint) noexcept -> bool;
auto create_group(std::string_view group, std::string_view mountpoint, bool is_system = false) noexcept -> bool;
// Set user password on the system
auto set_user_password(std::string_view username, std::string_view password, std::string_view mountpoint) noexcept -> bool;

View File

@ -34,11 +34,11 @@ using namespace std::string_view_literals;
namespace gucc::user {
auto create_group(std::string_view group, std::string_view mountpoint) noexcept -> bool {
auto create_group(std::string_view group, std::string_view mountpoint, bool is_system) noexcept -> bool {
// TODO(vnepogodin):
// 1. add parameter to check if the group was already created
// 2. add parameter if the group should be --system group
const auto& cmd = fmt::format(FMT_COMPILE("groupadd {}"), group);
const auto& cmd = fmt::format(FMT_COMPILE("groupadd {}{}"), is_system ? "--system"sv : ""sv, group);
return utils::arch_chroot_checked(cmd, mountpoint);
}