fix(polkit): use libpolkit-agent sessions

This commit is contained in:
Ly-sec
2026-04-29 13:57:51 +02:00
parent 8cee9e52bd
commit 7bb1f51629
6 changed files with 475 additions and 501 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ For dependencies and normal build commands, start with [README.md](README.md).
| Images | `Wuffs` (vendored), `nanosvg` (vendored), `stb_image_resize2` (vendored), `libwebp` |
| IPC | `sdbus-c++` |
| Audio | `libpipewire`, `dr_wav` (vendored) |
| Authentication | `PAM` |
| Authentication | `PAM`, `polkit-agent-1`, `polkit-gobject-1`, `glib-2.0`, `gobject-2.0` |
| HTTP | `libcurl` |
| Config | `tomlplusplus` (vendored) |
| JSON | `nlohmann/json` (vendored) |
+11 -6
View File
@@ -15,9 +15,9 @@ sudo dnf install meson gcc-c++ just \
libEGL-devel mesa-libGLES-devel \
freetype-devel fontconfig-devel \
cairo-devel pango-devel \
libxkbcommon-devel \
libxkbcommon-devel glib2-devel \
sdbus-cpp-devel pipewire-devel \
pam-devel libcurl-devel libwebp-devel
pam-devel polkit-devel libcurl-devel libwebp-devel
```
### Arch
@@ -27,8 +27,8 @@ sudo pacman -S meson gcc just \
wayland wayland-protocols \
libglvnd freetype2 fontconfig \
cairo pango \
libxkbcommon \
sdbus-cpp libpipewire \
libxkbcommon glib2 \
sdbus-cpp libpipewire polkit \
pam curl libwebp
```
@@ -40,9 +40,10 @@ sudo apt install meson g++ just \
libegl-dev libgles-dev \
libfreetype-dev libfontconfig-dev \
libcairo2-dev libpango1.0-dev \
libxkbcommon-dev \
libxkbcommon-dev libglib2.0-dev \
libsdbus-c++-dev libpipewire-0.3-dev \
libpam0g-dev libcurl4-openssl-dev libwebp-dev
libpam0g-dev libpolkit-agent-1-dev libpolkit-gobject-1-dev \
libcurl4-openssl-dev libwebp-dev
```
Vendored dependencies, with no system package needed: `Wuffs`, `nanosvg`, `tomlplusplus`, `tinyexpr`,
@@ -51,6 +52,10 @@ Vendored dependencies, with no system package needed: `Wuffs`, `nanosvg`, `tomlp
System packages required beyond the Wayland/GL stack: `libwebp` handles WebP decoding and thumbnail encoding. Wuffs
handles the other supported raster image formats.
Polkit agent support requires development files that provide the `polkit-agent-1` and `polkit-gobject-1` pkg-config
modules. Some distros ship these in the runtime `polkit` package, while split-package distros use names such as
`polkit-devel`, `polkit-dev`, or `libpolkit-agent-1-dev` / `libpolkit-gobject-1-dev`.
Sanitizer runtime packages are only needed for ASan/UBSan builds configured with `just configure asan`.
## Build
+8
View File
@@ -42,6 +42,10 @@ cairo_ft_dep = dependency('cairo-ft')
pango_dep = dependency('pango')
pangocairo_dep = dependency('pangocairo')
xkbcommon_dep = dependency('xkbcommon')
glib_dep = dependency('glib-2.0')
gobject_dep = dependency('gobject-2.0')
polkit_agent_dep = dependency('polkit-agent-1')
polkit_gobject_dep = dependency('polkit-gobject-1')
# PipeWire/SPA headers use GCC extensions that trigger -Wpedantic/-Wconversion;
# mark as system so the compiler suppresses those warnings.
pipewire_dep = dependency('libpipewire-0.3', include_type: 'system')
@@ -621,6 +625,10 @@ executable('noctalia',
pango_dep,
pangocairo_dep,
xkbcommon_dep,
glib_dep,
gobject_dep,
polkit_agent_dep,
polkit_gobject_dep,
pipewire_dep,
curl_dep,
pam_dep,
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -9,7 +9,7 @@
class SystemBus;
struct PolkitIdentity {
struct PolkitRequestIdentity {
std::string kind;
std::uint32_t uid = 0;
std::string userName;
@@ -20,7 +20,7 @@ struct PolkitRequest {
std::string message;
std::string iconName;
std::string cookie;
std::vector<PolkitIdentity> identities;
std::vector<PolkitRequestIdentity> identities;
};
class PolkitAgent {
@@ -38,6 +38,7 @@ public:
void cancelRequest();
void addPollFds(std::vector<pollfd>& fds) const;
[[nodiscard]] int pollTimeoutMs() const;
void dispatch(const std::vector<pollfd>& fds, std::size_t startIdx);
[[nodiscard]] bool hasPendingRequest() const noexcept;
+2
View File
@@ -7,6 +7,8 @@ class PolkitPollSource final : public PollSource {
public:
explicit PolkitPollSource(PolkitAgent& agent) : m_agent(agent) {}
[[nodiscard]] int pollTimeoutMs() const override { return m_agent.pollTimeoutMs(); }
void dispatch(const std::vector<pollfd>& fds, std::size_t startIdx) override { m_agent.dispatch(fds, startIdx); }
protected: