mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:07:45 +00:00
LibCore+LibIPC: Recognise %uid in path
This patch allows to insert "%uid" in `IPC_CLIENT_CONNECTION` declaration and in SystemServer's ini files. This pattern is replaced then replaced by the UID of the owner of the service. It opens a path for seamlessly managed, per-user portal.
This commit is contained in:
parent
c5b7c9f479
commit
1b36348d8b
21 changed files with 33 additions and 21 deletions
|
@ -68,6 +68,15 @@ ErrorOr<Account> Account::from_passwd(passwd const& pwd, spwd const& spwd)
|
|||
return account;
|
||||
}
|
||||
|
||||
String Account::parse_path_with_uid(StringView general_path, Optional<uid_t> uid)
|
||||
{
|
||||
if (general_path.contains("%uid"sv)) {
|
||||
auto const final_uid = uid.has_value() ? uid.value() : getuid();
|
||||
return general_path.replace("%uid"sv, String::number(final_uid), ReplaceMode::All);
|
||||
}
|
||||
return general_path;
|
||||
}
|
||||
|
||||
ErrorOr<Account> Account::self([[maybe_unused]] Read options)
|
||||
{
|
||||
Vector<gid_t> extra_gids = TRY(Core::System::getgroups());
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
|
||||
// FIXME: Convert the methods below to take StringViews instead.
|
||||
|
||||
static String parse_path_with_uid(StringView general_path, Optional<uid_t> force_uid = {});
|
||||
static ErrorOr<Account> self(Read options = Read::All);
|
||||
static ErrorOr<Account> from_name(char const* username, Read options = Read::All);
|
||||
static ErrorOr<Account> from_uid(uid_t uid, Read options = Read::All);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue