This commit is contained in:
Mars 2025-05-03 22:28:09 -04:00
parent e4cafe1960
commit 17e356513f
Signed by: pupbrained
GPG key ID: 0FF5B8826803F895

View file

@ -1,23 +1,20 @@
#ifdef __serenity__ #ifdef __serenity__
// clang-format off // clang-format off
#include <cerrno> // For errno #include <format> // std::format
#include <cstring> // For strerror #include <fstream> // std::ifstream
#include <filesystem>
#include <format>
#include <fstream>
#include <glaze/core/common.hpp> // glz::object #include <glaze/core/common.hpp> // glz::object
#include <glaze/core/context.hpp> // glz::error_ctx, glz::error_code #include <glaze/core/context.hpp> // glz::error_ctx, glz::error_code
#include <glaze/core/meta.hpp> // glz::detail::Object #include <glaze/core/meta.hpp> // glz::detail::Object
#include <glaze/json/read.hpp> // glz::read_json #include <glaze/core/read.hpp> // glz::read
#include <iostream> #include <iterator> // std::istreambuf_iterator
#include <pwd.h> // For getpwuid(), struct passwd #include <pwd.h> // getpwuid, struct passwd
#include <string> #include <string> // std::string (String)
#include <string_view> #include <string_view> // std::string_view (StringView)
#include <sys/statvfs.h> #include <sys/statvfs.h> // statvfs
#include <sys/types.h> // For uid_t #include <sys/types.h> // uid_t
#include <sys/utsname.h> #include <sys/utsname.h> // utsname, uname
#include <unistd.h> #include <unistd.h> // getuid, gethostname
#include "src/util/defs.hpp" #include "src/util/defs.hpp"
#include "src/util/error.hpp" #include "src/util/error.hpp"
@ -99,9 +96,8 @@ namespace os {
fn GetDesktopEnvironment() -> Result<String, DracError> { return "SerenityOS Desktop"; } fn GetDesktopEnvironment() -> Result<String, DracError> { return "SerenityOS Desktop"; }
fn GetShell() -> Result<String, DracError> { fn GetShell() -> Result<String, DracError> {
uid_t userId = getuid(); uid_t userId = getuid();
errno = 0; struct passwd* pw = getpwuid(userId);
struct passwd* pw = getpwuid(userId);
if (pw == nullptr) if (pw == nullptr)
return Err(DracError(DracErrorCode::NotFound, std::format("User ID {} not found in /etc/passwd", userId))); return Err(DracError(DracErrorCode::NotFound, std::format("User ID {} not found in /etc/passwd", userId)));