Skip to content

Commit

Permalink
Retrieve Application ID from PID's cgroup
Browse files Browse the repository at this point in the history
This commit adds an optional dependency on libsystemd and, when
available, uses it to attempt to find an application ID even for
processes which are not Snap or Flatpak sandboxes. This is not always
successful, so we still need to handle the case of an empty app ID for
an XdpAppInfo.

Since this is not a perfect solution for finding the app ID, we may
eventually want to introduce a way for *unsandboxed* processes to
specify their own app ID, perhaps a portal-wide SetAppID() method. This
is analogous to the security model gnome-shell has: if a process is
sandboxed use that app ID, and otherwise use information that is under
the control of the application (e.g. WM_CLASS, GApplication ID, etc.).

Helps: #579

(Originally authored by Carlo Castoldi, re-done by Phaedrus Leeds)
  • Loading branch information
carlocastoldi authored and mwleeds committed Mar 2, 2022
1 parent 56b2fbd commit 8a11540
Show file tree
Hide file tree
Showing 7 changed files with 475 additions and 14 deletions.
9 changes: 9 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ if test x$enable_pipewire = xyes ; then
fi
AM_CONDITIONAL([HAVE_PIPEWIRE],[test "$enable_pipewire" = "yes"])

AC_ARG_WITH([systemd],
AS_HELP_STRING([--with-systemd], [Build with systemd support [default=yes]]),
[], [with_systemd=yes])
if test "x$with_systemd" = "xyes"; then
PKG_CHECK_MODULES(SYSTEMD, [libsystemd])
AC_DEFINE([HAVE_LIBSYSTEMD], [1], [Define if libsystemd is available])
fi
AM_CONDITIONAL([HAVE_LIBSYSTEMD], [test "x$with_systemd" != "xno"])

AC_ARG_ENABLE(docbook-docs,
[AS_HELP_STRING([--enable-docbook-docs],[build documentation (requires xmlto)])],
enable_docbook_docs=$enableval, enable_docbook_docs=auto)
Expand Down
12 changes: 8 additions & 4 deletions document-portal/Makefile.am.inc
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,16 @@ DB_SOURCES = \
xdg_permission_store_SOURCES = \
src/xdp-utils.c \
src/xdp-utils.h \
src/sd-escape.c \
src/sd-escape.h \
document-portal/permission-store.c \
document-portal/xdg-permission-store.c \
document-portal/xdg-permission-store.h \
$(DB_SOURCES) \
$(NULL)

xdg_permission_store_LDADD = $(AM_LDADD) $(BASE_LIBS)
xdg_permission_store_CFLAGS = $(AM_CFLAGS) $(BASE_CFLAGS) -I$(srcdir)/document-portal -I$(builddir)/document-portal
xdg_permission_store_LDADD = $(AM_LDADD) $(BASE_LIBS) $(SYSTEMD_LIBS)
xdg_permission_store_CFLAGS = $(AM_CFLAGS) $(BASE_CFLAGS) $(SYSTEMD_CFLAGS) -I$(srcdir)/document-portal -I$(builddir)/document-portal

nodist_xdg_document_portal_SOURCES = \
$(nodist_xdg_permission_store_SOURCES) \
Expand All @@ -88,6 +90,8 @@ CLEANFILES += $(nodist_xdg_document_portal_SOURCES)
xdg_document_portal_SOURCES = \
src/xdp-utils.c \
src/xdp-utils.h \
src/sd-escape.c \
src/sd-escape.h \
document-portal/document-portal.h \
document-portal/document-portal.c \
document-portal/file-transfer.h \
Expand All @@ -100,5 +104,5 @@ xdg_document_portal_SOURCES = \
$(DB_SOURCES) \
$(NULL)

xdg_document_portal_LDADD = $(AM_LDADD) $(BASE_LIBS) $(FUSE3_LIBS)
xdg_document_portal_CFLAGS = $(AM_CFLAGS) $(BASE_CFLAGS) $(FUSE3_CFLAGS) -I$(srcdir)/document-portal -I$(builddir)/document-portal
xdg_document_portal_LDADD = $(AM_LDADD) $(BASE_LIBS) $(FUSE3_LIBS) $(SYSTEMD_LIBS)
xdg_document_portal_CFLAGS = $(AM_CFLAGS) $(BASE_CFLAGS) $(FUSE3_CFLAGS) $(SYSTEMD_CFLAGS) -I$(srcdir)/document-portal -I$(builddir)/document-portal
9 changes: 9 additions & 0 deletions src/Makefile.am.inc
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ xdg_desktop_portal_SOURCES = \
src/portal-impl.c \
$(NULL)

if HAVE_LIBSYSTEMD
xdg_desktop_portal_SOURCES += \
src/sd-escape.c \
src/sd-escape.h \
$(NULL)
endif

if HAVE_PIPEWIRE
xdg_desktop_portal_SOURCES += \
src/screen-cast.c \
Expand All @@ -200,6 +207,7 @@ xdg_desktop_portal_LDADD = \
$(BASE_LIBS) \
$(PIPEWIRE_LIBS) \
$(GEOCLUE_LIBS) \
$(SYSTEMD_LIBS) \
$(NULL)
xdg_desktop_portal_CFLAGS = \
-DDATADIR=\"$(datadir)\" \
Expand All @@ -208,6 +216,7 @@ xdg_desktop_portal_CFLAGS = \
$(BASE_CFLAGS) \
$(PIPEWIRE_CFLAGS) \
$(GEOCLUE_CFLAGS) \
$(SYSTEMD_CFLAGS) \
-I$(srcdir)/src \
-I$(builddir)/src \
-I$(srcdir)/document-portal \
Expand Down
Loading

0 comments on commit 8a11540

Please sign in to comment.