Commit Graph

26 Commits

Author SHA1 Message Date
Sam Atkins
5bcb3e2f16 LibConfig+ConfigServer: Add permissive mode
When in permissive mode, the ConfigServer will not treat reads and
writes to non-pledged domains as errors, but instead turns them into
no-ops: Reads will act as if the key was not found, and writes will do
nothing. Permissive mode must be enabled before pledging any domains.

This is needed to make GUI Widgets nicer to work with in GML Playground:
a few Widgets include reads and writes to LibConfig in order to load
system settings (eg, GUI::Calendar) or to save and restore state
(eg, GUI::DynamicWidgetContainer). Without this change, editing a
layout that includes one of these Widgets will cause GML Playground to
crash when they try to access config domains that are not pledged.

The solution used previously is to make Playground pledge more domains,
but not only does this mean Playground has to know about these cases,
but also that working on a layout file can alter the user's settings in
other arbitrary apps, which is not something we want.

By simply ignoring these config accesses, we avoid those downsides, and
Widgets will simply use the fallback values they already have to provide
to Config::read_foo_value().
2024-03-07 17:49:01 -05:00
Ali Mohammad Pur
5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30
kleines Filmröllchen
33829f05fe Userland: Convert config listener callbacks to use StringView
The immutability of the string is not relevant here, since the string
we're given was allocated in the IPC serialization layer and will be
destroyed shortly afterwards. Additionally, noone relies on
DeprecatedString-specific functionality. This will make it easier to
convert the IPC layer itself to String later on.
2023-06-27 15:37:00 +01:00
Andreas Kling
16c47ccff6 LibCore: Big first step towards pluggable Core::EventLoop
The EventLoop is now a wrapper around an EventLoopImplementation.
Our old EventLoop code has moved into EventLoopImplementationUnix and
continues to work as before.

The main difference is that all the separate thread_local variables have
been collected into a file-local ThreadData data structure.

The goal here is to allow running Core::EventLoop with a totally
different backend, such as Qt for Ladybird.
2023-04-25 14:48:40 +02:00
Jelle Raaijmakers
357538ed25 LibConfig: Use full include path for endpoints
This fixes the SDL2 port build which expects this path to exist in
`/usr/include`.
2023-03-24 00:31:03 +01:00
Tim Schumacher
a96339b72b LibCore: Move Stream-based sockets into the Core namespace 2023-02-13 00:50:07 +00:00
Tim Schumacher
d43a7eae54 LibCore: Rename File to DeprecatedFile
As usual, this removes many unused includes and moves used includes
further down the chain.
2023-02-13 00:50:07 +00:00
Timothy Flynn
69beda23c3 LibConfig+LibCore+ConfigServer: Support u32 configuration entries 2022-12-23 23:26:21 +01:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Tim Schumacher
ce2f1b845f Everywhere: Mark dependencies of most targets as PRIVATE
Otherwise, we end up propagating those dependencies into targets that
link against that library, which creates unnecessary link-time
dependencies.

Also included are changes to readd now missing dependencies to tools
that actually need them.
2022-11-01 14:49:09 +00:00
Peter Elliott
7af5eef0dd SystemServer+LoginServer+Userland: Switch to sid-based sockets
This commit does three things atomically:
- switch over Core::Account+SystemServer+LoginServer to sid based socket
  names.
- change socket names with %uid to %sid.
- add/update necessary pledges and unveils.

Userland: Switch over servers to sid based sockets

Userland: Properly pledge and unveil for sid based sockets
2022-10-03 11:11:29 +02:00
thankyouverycool
c34f2e75e9 LibCore+LibConfig+ConfigServer: Add Config::{add,remove}_group()
Plumbs synchronous calls for adding and removing group entries to
config files. This is useful for services like SystemServer which
default to group names for executable paths, and for removing all
keys at once.
2022-10-01 13:39:10 +03:30
thankyouverycool
6f394d9ee2 LibConfig+ConfigServer: Make remove_key() synchronous
Previously, when removing keys, the config utility terminated its
connection before changes could be synced.
2022-10-01 13:39:10 +03:30
Lucas CHOLLET
07e89ad538 Base: Launch ConfigServer at session start-up 2022-08-14 21:52:35 +01:00
Lucas CHOLLET
1b36348d8b 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.
2022-08-14 21:52:35 +01:00
Moustafa Raafat
0a3467d665 LibConfig+ConfigServer: Write config values synchronously
This patch fixes the issue of pressing the ok button of a settings menu
without saving the changes, or not reverting the changes when pressing
the cancel button because the app has died before the new values make
it to the other end.
2022-04-26 22:51:49 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Itamar
d88da82e28 Userland: Rename IPC::ServerConnection=>IPC::ConnectionToServer
This was done with CLion's automatic rename feature.
2022-02-25 22:35:12 +01:00
Vitaly Dyachkov
32b8795091 LibConfig: Rename pledge_domains(String) => pledge_domain(String)
pledge_domains() that takes only one String argument was specifically
added as a shortcut for pledging a single domain. So, it makes sense to
use singular here.
2022-02-11 18:06:39 +01:00
sin-ack
2e1bbcb0fa LibCore+LibIPC+Everywhere: Return Stream::LocalSocket from LocalServer
This change unfortunately cannot be atomically made without a single
commit changing everything.

Most of the important changes are in LibIPC/Connection.cpp,
LibIPC/ServerConnection.cpp and LibCore/LocalServer.cpp.

The notable changes are:
- IPCCompiler now generates the decode and decode_message functions such
  that they take a Core::Stream::LocalSocket instead of the socket fd.
- IPC::Decoder now uses the receive_fd method of LocalSocket instead of
  doing system calls directly on the fd.
- IPC::ConnectionBase and related classes now use the Stream API
  functions.
- IPC::ServerConnection no longer constructs the socket itself; instead,
  a convenience macro, IPC_CLIENT_CONNECTION, is used in place of
  C_OBJECT and will generate a static try_create factory function for
  the ServerConnection subclass. The subclass is now responsible for
  passing the socket constructed in this function to its
  ServerConnection base; the socket is passed as the first argument to
  the constructor (as a NonnullOwnPtr<Core::Stream::LocalServer>) before
  any other arguments.
- The functionality regarding taking over sockets from SystemServer has
  been moved to LibIPC/SystemServerTakeover.cpp. The Core::LocalSocket
  implementation of this functionality hasn't been deleted due to my
  intention of removing this class in the near future and to reduce
  noise on this (already quite noisy) PR.
2022-01-15 13:29:48 +03:30
faxe1008
f10036b7c5 LibConfig: Add list methods for groups and keys
Use the methods exposed by ConfigServer to list groups and keys.
2021-11-18 09:08:51 +01:00
faxe1008
b97f9f8e17 LibConfig: Add removal/notifcation for keys 2021-11-13 12:55:46 +01:00
Andreas Kling
edf7843409 ConfigServer+LibConfig: Add way for clients to listen for config changes
This patch adds a Config::Listener abstract class that anyone can
inherit from and receive notifications when configuration values change.

We don't yet monitor file system changes, so these only work for changes
made by ConfigServer itself.

In order to receive these notifications, clients must monitor the domain
by calling monitor_domain(). Only pledged domains can be monitored.

Note that the client initiating the change does not get notified.
2021-08-26 23:41:38 +02:00
Andreas Kling
eeddaa988a ConfigServer+LibConfig: Add pledge_domains() API
This API lets applications specify which configuration domains they
will be accessing throughout their lifetime. It works similarly in
spirit to the kernel's pledge().

You cannot pledge_domains() more than once, and once you have used it,
it's no longer possible to access any other configuration domain.

This is obviously just a first cut of this mechanism, and we may need
to tweak it further as we go.
2021-08-26 00:54:28 +02:00
Andreas Kling
870ecd5190 LibConfig: VERIFY that a Core::EventLoop exists before connecting
It's not possible to connect to ConfigServer without having an event
loop available. This VERIFY makes it much easier to understand why
things are not working. :^)
2021-08-26 00:54:28 +02:00
Andreas Kling
bdcd0abf9d Userland: Introduce ConfigServer and LibConfig
ConfigServer is an IPC service that provides access to application
configuration and settings. The idea is to replace all uses of
Core::ConfigFile with IPC requests to ConfigServer.

This first cut of the API is pretty similar to Core::ConfigFile.

The old:

    auto config = Core::ConfigFile::open_for_app("App");
    auto value = config->read_entry("Group", "Key");

The new:

    auto value = Config::read_string("App", "Group", "Key");

ConfigServer uses the ~/.config directory as its backing store
and all the files remain human-editable. :^)
2021-08-26 00:54:27 +02:00