From be2ae57ee78e583298a8cde47783180074960938 Mon Sep 17 00:00:00 2001 From: Vladislav Nepogodin Date: Sat, 13 Jul 2024 15:37:59 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20gucc:=20use=20std=20ranges=20fro?= =?UTF-8?q?m=20C++23=20in=20user?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gucc/src/user.cpp | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/gucc/src/user.cpp b/gucc/src/user.cpp index c3a525a..cb82ca7 100644 --- a/gucc/src/user.cpp +++ b/gucc/src/user.cpp @@ -3,31 +3,15 @@ #include "gucc/io_utils.hpp" #include "gucc/string_utils.hpp" -#include // for find -#include +#include // for find, contains +#include // for permissions +#include // for ranges::* #include #include #include -#if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wold-style-cast" -#elif defined(__GNUC__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wuseless-cast" -#pragma GCC diagnostic ignored "-Wold-style-cast" -#endif - -#include - -#if defined(__clang__) -#pragma clang diagnostic pop -#elif defined(__GNUC__) -#pragma GCC diagnostic pop -#endif - namespace fs = std::filesystem; using namespace std::string_view_literals; @@ -54,7 +38,7 @@ auto set_user_password(std::string_view username, std::string_view password, std } auto create_new_user(const user::UserInfo& user_info, const std::vector& default_groups, std::string_view mountpoint) noexcept -> bool { - if (!user_info.sudoers_group.empty() && !ranges::contains(default_groups, user_info.sudoers_group)) { + if (!user_info.sudoers_group.empty() && !std::ranges::contains(default_groups, user_info.sudoers_group)) { spdlog::error("Failed to create user {}! User default groups doesn't contain sudoers group({})", user_info.username, user_info.sudoers_group); return false; }