From cfd260855caec0e83cb943e0fa2deb4a1399ff99 Mon Sep 17 00:00:00 2001 From: Vladislav Nepogodin Date: Thu, 4 Jul 2024 11:32:57 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20gucc:=20add=20option=20to=20crea?= =?UTF-8?q?te=20system=20group?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gucc/include/gucc/user.hpp | 2 +- gucc/src/user.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gucc/include/gucc/user.hpp b/gucc/include/gucc/user.hpp index d86f0be..0faabfc 100644 --- a/gucc/include/gucc/user.hpp +++ b/gucc/include/gucc/user.hpp @@ -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; diff --git a/gucc/src/user.cpp b/gucc/src/user.cpp index 05670c5..762c4d0 100644 --- a/gucc/src/user.cpp +++ b/gucc/src/user.cpp @@ -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); }