-
Notifications
You must be signed in to change notification settings - Fork 15
WIP toplevel_info: PID and security context #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
PID may also be useful if we want anything to provide an option to force kill an app (or is there a better way to do that?). Not sure what other uses there are for it. I think we talked about wanting PID here for something. Another thing I'd like to add to toplevel_info somehow is https://wayland.app/protocols/xdg-toplevel-icon-v1, but I don't really know how that would work... seems a bit of a pain to pass through to client shell components. I guess for X11 clients, the XID would allow a shell component to get that sort of thing. |
|
Just some random mumbling, feel free to ignore.
IMHO this should be a compositor feature rather than a desktop shell feature. Something like if application didn't react for X seconds to a xdg/xwayland-ping request following a close request: ask the user to force-quit the application at which point the compositor can either disconnect the client or actually kill it via PID from its socket connection peer credentials. Another note: linux pid namespaces might make the PID irrelevant depending on what component runs in which pid namespace.
Yes, some kind of solution would be nice for this, also upstream. Its relatively trivial if the client just sends an icon name but if it sends a bunch of wl_buffers it gets a bit annoying to deal with, both client and compositor side. Edit: |
Yeah, if we wanted to prompt to force quit an app based on response to pings, that will need more cooperation from the compositor.
If xdg-desktop-portal-cosmic, cosmic-comp, and XWayland are running without any special sandboxing, then PIDs should match between them, and using the PID to deal with sandboxed apps works fine (though it will be mapped to a different PID within the sandbox.) But yeah, if any of those things were in a separate PID namespace, this wouldn't work. (I wonder if we could do anything to sandbox XWayland.)
That could work in some cases. Though presumably not for all apps. (Particularly sandboxed apps probably can use icons for toplevels that may not be installed at a path the compositor will search?) We can always fallback to using the icon based on app_id, but this may not provide the best experience for some software. |
I wonder if the following could work:
That would then mean that every non-sandboxed app (sandboxed apps shouldn't have access to |
We could also just expose a ping-timeout or ping-restored event in
Please lets not do an |
Drakulix
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine apart from missing descriptions
| <arg name="sandbox_engine", type="string" allow-null="true"/> | ||
| <arg name="app_id", type="string" allow-null="true"/> | ||
| <arg name="instance_id", type="string" allow-null="true"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <arg name="sandbox_engine", type="string" allow-null="true"/> | |
| <arg name="app_id", type="string" allow-null="true"/> | |
| <arg name="instance_id", type="string" allow-null="true"/> | |
| <arg name="sandbox_engine" type="string" allow-null="true"/> | |
| <arg name="app_id" type="string" allow-null="true"/> | |
| <arg name="instance_id" type="string" allow-null="true"/> |
As of 6.5 |
|
So if we use Hopefully anything using COSMIC will have a recent kernel, and BSDs don't currently have Flatpak anyway, so we don't need the PID for that purpose. I guess cctk can store it as an |
Exactly and we can add logic to fallback to other options, if no fd is provided by the compositor. (Looking at e.g. the background portal, which is somewhat functional without it.)
If we hit them, we should just increase the limit. FDs are cheap in recent kernel versions, the folks behind systemd have put a lot of work into making sure they can be used for everything. The only reason for the conservative limit is |
|
Yeah, using FDs is really the right way to do things like this. |
|
https://www.corsix.org/content/what-is-a-pidfd
Gotta love that consistency. It would be nice if a pidfd was just the same thing as a proc directory fd... So as far as I can tell, there's no direct way to convert a pidfd to a
So I think we can avoid the race, but it still would be an issue to be in a different PID namespace than the compositor. But of course, it makes sense that a process in a PID namespace couldn't access this sort of information about a process outside it. I guess instead of the We might actually be able to, and want to, sandbox the portal daemon with systemd sandboxing if we switch to socket activation, but presumably that won't use a PID namespace, or has a way to disable that. We don't expose toplevel-info to Flatpaks regardless. If we wanted to iterate over the directory multiple times, after opening the directory fd, the standard library doesn't have anything for that, but Pidfd seems doable, but a bit more annoying to deal with than I might wish... |
Just for the record, related work regarding the ping timeout: https://gitlab.freedesktop.org/wlroots/wlr-protocols/-/merge_requests/127. |
The xdg-desktop-portal-gnome background portal uses the
sandbox_app_idfrom theorg.gnome.Shell.Introspectprotocol to get the app ID of flatpak/snap apps.Mutter implements this by getting the PID of the Wayland or X11 client, then accessing
/proc/$PID/root/.flatpak-info. (Or something else for Snaps.)If we want to do the same, it's probably easier to have the compositor expose the PID (which may also be useful for other purposes), and then let our portal do any further lookups.
For Wayland apps,
security-context-v1is probably a more robust way to get the sandboxing information, but presumably we still need a PID-based approach for X11 clients. So it would be good to expose that too.Pid of course is potentially racy. But a pidfd would still be racy in the compositor, since we'd have to create it from a PID, and it wouldn't work on non-Linux platforms. Races probably aren't a problem if the client immediately looks up the process after the compositor adversities the window, and the compositor will remove windows immediately when the client is gone (assuming the process that created the socket is the only one with it open).
We should probably also have a field to indicate that the client uses X11. Maybe an
xidfield. Though like PID, this is potentially racy.