[neon/backports-focal/xdg-desktop-portal/Neon/unstable] /: Merge Debian changes up to 1.8.1-1

David Cahalane null at kde.org
Tue Aug 3 20:13:37 BST 2021


Git commit b069abfdd9b09af3ff28629ae083062497125575 by David Cahalane.
Committed on 03/08/2021 at 18:58.
Pushed by jriddell into branch 'Neon/unstable'.

Merge Debian changes up to 1.8.1-1

M  +101  -10   Makefile.in
M  +12   -0    NEWS
M  +19   -19   configure
M  +2    -2    configure.ac
M  +21   -6    debian/changelog
M  +0    -1    debian/control
R  +13   -2    debian/patches/Replace-the-icon-validator-with-the-one-from-Flatpak-1.10.patch [from: debian/patches/Replace-the-icon-validator-with-the-one-from-Flatpak-1.8..patch - 093% similarity]
M  +1    -1    debian/patches/Revert-Stop-building-the-icon-validator.patch
M  +1    -7    debian/rules
A  +3    -0    debian/series
M  +18   -7    document-portal/document-portal.c
M  +0    -1    src/account.c
M  +2    -0    src/documents.c
M  +0    -1    src/file-chooser.c
M  +2    -1    src/open-uri.c
M  +0    -1    src/screenshot.c
M  +4    -2    src/wallpaper.c
M  +174  -136  src/xdp-utils.c
M  +17   -0    src/xdp-utils.h
M  +11   -1    tests/Makefile.am.inc
A  +99   -0    tests/can-use-fuse.c     [License: LGPL(v2.1+)]
A  +12   -0    tests/can-use-fuse.h     [License: LGPL(v2.1+)]
M  +12   -91   tests/test-doc-portal.c
A  +139  -0    tests/test-xdp-utils.c  *

The files marked with a * at the end have a non valid license. Please read: https://community.kde.org/Policies/Licensing_Policy and use the headers which are listed at that page.


https://invent.kde.org/neon/backports-focal/xdg-desktop-portal/commit/b069abfdd9b09af3ff28629ae083062497125575

diff --git a/Makefile.in b/Makefile.in
index f5026d8..379d165 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -214,9 +214,9 @@ am__installdirs = "$(DESTDIR)$(bindir)" \
 	"$(DESTDIR)$(installed_test_metadir)" \
 	"$(DESTDIR)$(installed_testdir)" "$(DESTDIR)$(pkgconfigdir)" \
 	"$(DESTDIR)$(systemduserunitdir)"
-am__EXEEXT_2 = test-portals$(EXEEXT) testdb$(EXEEXT) \
-	test-doc-portal$(EXEEXT) test-permission-store$(EXEEXT) \
-	$(am__EXEEXT_1)
+am__EXEEXT_2 = test-portals$(EXEEXT) test-xdp-utils$(EXEEXT) \
+	testdb$(EXEEXT) test-doc-portal$(EXEEXT) \
+	test-permission-store$(EXEEXT) $(am__EXEEXT_1)
 am__EXEEXT_3 = tests/test-backends$(EXEEXT) $(am__EXEEXT_1)
 am__EXEEXT_4 = $(am__EXEEXT_2) $(am__EXEEXT_3)
 @ENABLE_ALWAYS_BUILD_TESTS_FALSE at am__EXEEXT_5 = $(am__EXEEXT_4)
@@ -255,8 +255,11 @@ am__uninstall_files_from_dir = { \
 LTLIBRARIES = $(installed_test_LTLIBRARIES) $(lib_LTLIBRARIES) \
 	$(noinst_LTLIBRARIES)
 am__dirstamp = $(am__leading_dot)dirstamp
+am__objects_1 =
 am_test_doc_portal_OBJECTS =  \
-	tests/test_doc_portal-test-doc-portal.$(OBJEXT)
+	tests/test_doc_portal-can-use-fuse.$(OBJEXT) \
+	tests/test_doc_portal-test-doc-portal.$(OBJEXT) \
+	$(am__objects_1)
 nodist_test_doc_portal_OBJECTS = document-portal/test_doc_portal-document-portal-dbus.$(OBJEXT)
 test_doc_portal_OBJECTS = $(am_test_doc_portal_OBJECTS) \
 	$(nodist_test_doc_portal_OBJECTS)
@@ -293,7 +296,6 @@ am__test_portals_SOURCES_DIST = tests/test-portals.c tests/account.c \
 	tests/screenshot.h tests/trash.c tests/trash.h \
 	tests/wallpaper.c tests/wallpaper.h tests/utils.c \
 	tests/utils.h tests/glib-backports.c tests/glib-backports.h
-am__objects_1 =
 @HAVE_LIBPORTAL_TRUE at am__objects_2 =  \
 @HAVE_LIBPORTAL_TRUE@	tests/test_portals-account.$(OBJEXT) \
 @HAVE_LIBPORTAL_TRUE@	tests/test_portals-background.$(OBJEXT) \
@@ -327,6 +329,15 @@ test_portals_DEPENDENCIES = $(am__DEPENDENCIES_1) \
 test_portals_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_portals_CFLAGS) \
 	$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+am_test_xdp_utils_OBJECTS =  \
+	tests/test_xdp_utils-test-xdp-utils.$(OBJEXT) \
+	src/test_xdp_utils-xdp-utils.$(OBJEXT)
+test_xdp_utils_OBJECTS = $(am_test_xdp_utils_OBJECTS)
+test_xdp_utils_DEPENDENCIES = $(am__DEPENDENCIES_1)
+test_xdp_utils_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
+	$(test_xdp_utils_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o \
+	$@
 am__objects_3 = document-portal/testdb-permission-db.$(OBJEXT) \
 	document-portal/gvdb/testdb-gvdb-reader.$(OBJEXT) \
 	document-portal/gvdb/testdb-gvdb-builder.$(OBJEXT) \
@@ -522,6 +533,7 @@ am__depfiles_remade = document-portal/$(DEPDIR)/test_doc_portal-document-portal-
 	src/$(DEPDIR)/test_portals-xdp-dbus.Po \
 	src/$(DEPDIR)/test_portals-xdp-impl-dbus.Po \
 	src/$(DEPDIR)/test_portals-xdp-utils.Po \
+	src/$(DEPDIR)/test_xdp_utils-xdp-utils.Po \
 	src/$(DEPDIR)/tests_test_backends-xdp-impl-dbus.Po \
 	src/$(DEPDIR)/xdg_desktop_portal-account.Po \
 	src/$(DEPDIR)/xdg_desktop_portal-background.Po \
@@ -562,6 +574,7 @@ am__depfiles_remade = document-portal/$(DEPDIR)/test_doc_portal-document-portal-
 	src/$(DEPDIR)/xdg_document_portal-xdp-utils.Po \
 	src/$(DEPDIR)/xdg_permission_store-xdp-utils.Po \
 	tests/$(DEPDIR)/test_backends-glib-backports.Po \
+	tests/$(DEPDIR)/test_doc_portal-can-use-fuse.Po \
 	tests/$(DEPDIR)/test_doc_portal-test-doc-portal.Po \
 	tests/$(DEPDIR)/test_permission_store-test-permission-store.Po \
 	tests/$(DEPDIR)/test_portals-account.Po \
@@ -580,6 +593,7 @@ am__depfiles_remade = document-portal/$(DEPDIR)/test_doc_portal-document-portal-
 	tests/$(DEPDIR)/test_portals-trash.Po \
 	tests/$(DEPDIR)/test_portals-utils.Po \
 	tests/$(DEPDIR)/test_portals-wallpaper.Po \
+	tests/$(DEPDIR)/test_xdp_utils-test-xdp-utils.Po \
 	tests/$(DEPDIR)/testdb-testdb.Po \
 	tests/backend/$(DEPDIR)/test_backends-access.Po \
 	tests/backend/$(DEPDIR)/test_backends-account.Po \
@@ -619,7 +633,8 @@ SOURCES = $(test_doc_portal_SOURCES) $(nodist_test_doc_portal_SOURCES) \
 	$(test_permission_store_SOURCES) \
 	$(nodist_test_permission_store_SOURCES) \
 	$(test_portals_SOURCES) $(nodist_test_portals_SOURCES) \
-	$(testdb_SOURCES) $(tests_test_backends_SOURCES) \
+	$(test_xdp_utils_SOURCES) $(testdb_SOURCES) \
+	$(tests_test_backends_SOURCES) \
 	$(nodist_tests_test_backends_SOURCES) \
 	$(xdg_desktop_portal_SOURCES) \
 	$(nodist_xdg_desktop_portal_SOURCES) \
@@ -629,8 +644,8 @@ SOURCES = $(test_doc_portal_SOURCES) $(nodist_test_doc_portal_SOURCES) \
 	$(nodist_xdg_permission_store_SOURCES)
 DIST_SOURCES = $(test_doc_portal_SOURCES) \
 	$(test_permission_store_SOURCES) \
-	$(am__test_portals_SOURCES_DIST) $(testdb_SOURCES) \
-	$(tests_test_backends_SOURCES) \
+	$(am__test_portals_SOURCES_DIST) $(test_xdp_utils_SOURCES) \
+	$(testdb_SOURCES) $(tests_test_backends_SOURCES) \
 	$(am__xdg_desktop_portal_SOURCES_DIST) \
 	$(xdg_document_portal_SOURCES) $(xdg_permission_store_SOURCES)
 RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
@@ -1403,7 +1418,7 @@ tests_test_backends_SOURCES = \
 	$(NULL)
 
 nodist_tests_test_backends_SOURCES = src/xdp-impl-dbus.c
-test_programs = test-portals testdb test-doc-portal \
+test_programs = test-portals test-xdp-utils testdb test-doc-portal \
 	test-permission-store $(NULL)
 TESTS_ENVIRONMENT = \
 	PATH=$$(cd $(top_builddir) && pwd):$${PATH} \
@@ -1425,7 +1440,12 @@ test_doc_portal_LDADD = \
 	$(FUSE_LIBS) \
 	$(NULL)
 
-test_doc_portal_SOURCES = tests/test-doc-portal.c
+test_doc_portal_SOURCES = \
+	tests/can-use-fuse.c \
+	tests/can-use-fuse.h \
+	tests/test-doc-portal.c \
+	$(NULL)
+
 nodist_test_doc_portal_SOURCES = document-portal/document-portal-dbus.c
 EXTRA_test_doc_portal_DEPENDENCIES = tests/services/org.freedesktop.impl.portal.PermissionStore.service tests/services/org.freedesktop.portal.Documents.service
 test_portals_CFLAGS = $(AM_CFLAGS) $(BASE_CFLAGS) $(LIBPORTAL_CFLAGS) \
@@ -1450,6 +1470,9 @@ test_permission_store_LDADD = \
 test_permission_store_SOURCES = tests/test-permission-store.c
 nodist_test_permission_store_SOURCES = document-portal/permission-store-dbus.c src/xdp-utils.c
 EXTRA_test_permission_store_DEPENDENCIES = tests/services/org.freedesktop.impl.portal.PermissionStore.service tests/services/org.freedesktop.portal.Documents.service
+test_xdp_utils_CFLAGS = $(AM_CFLAGS) $(BASE_CFLAGS)
+test_xdp_utils_LDADD = $(AM_LD_ADD) $(BASE_LIBS)
+test_xdp_utils_SOURCES = tests/test-xdp-utils.c src/xdp-utils.c
 installed_test_dbsdir = $(installed_testdir)/dbs
 installed_test_portalsdir = $(installed_testdir)/portals
 @ENABLE_INSTALLED_TESTS_TRUE at dist_installed_test_dbs_DATA = tests/dbs/no_tables
@@ -1793,6 +1816,8 @@ tests/$(am__dirstamp):
 tests/$(DEPDIR)/$(am__dirstamp):
 	@$(MKDIR_P) tests/$(DEPDIR)
 	@: > tests/$(DEPDIR)/$(am__dirstamp)
+tests/test_doc_portal-can-use-fuse.$(OBJEXT): tests/$(am__dirstamp) \
+	tests/$(DEPDIR)/$(am__dirstamp)
 tests/test_doc_portal-test-doc-portal.$(OBJEXT):  \
 	tests/$(am__dirstamp) tests/$(DEPDIR)/$(am__dirstamp)
 document-portal/$(am__dirstamp):
@@ -1870,6 +1895,14 @@ document-portal/test_portals-permission-store-dbus.$(OBJEXT):  \
 test-portals$(EXEEXT): $(test_portals_OBJECTS) $(test_portals_DEPENDENCIES) $(EXTRA_test_portals_DEPENDENCIES) 
 	@rm -f test-portals$(EXEEXT)
 	$(AM_V_CCLD)$(test_portals_LINK) $(test_portals_OBJECTS) $(test_portals_LDADD) $(LIBS)
+tests/test_xdp_utils-test-xdp-utils.$(OBJEXT): tests/$(am__dirstamp) \
+	tests/$(DEPDIR)/$(am__dirstamp)
+src/test_xdp_utils-xdp-utils.$(OBJEXT): src/$(am__dirstamp) \
+	src/$(DEPDIR)/$(am__dirstamp)
+
+test-xdp-utils$(EXEEXT): $(test_xdp_utils_OBJECTS) $(test_xdp_utils_DEPENDENCIES) $(EXTRA_test_xdp_utils_DEPENDENCIES) 
+	@rm -f test-xdp-utils$(EXEEXT)
+	$(AM_V_CCLD)$(test_xdp_utils_LINK) $(test_xdp_utils_OBJECTS) $(test_xdp_utils_LDADD) $(LIBS)
 tests/testdb-testdb.$(OBJEXT): tests/$(am__dirstamp) \
 	tests/$(DEPDIR)/$(am__dirstamp)
 document-portal/testdb-permission-db.$(OBJEXT):  \
@@ -2155,6 +2188,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at src/$(DEPDIR)/test_portals-xdp-dbus.Po at am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote at src/$(DEPDIR)/test_portals-xdp-impl-dbus.Po at am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote at src/$(DEPDIR)/test_portals-xdp-utils.Po at am__quote@ # am--include-marker
+ at AMDEP_TRUE@@am__include@ @am__quote at src/$(DEPDIR)/test_xdp_utils-xdp-utils.Po at am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote at src/$(DEPDIR)/tests_test_backends-xdp-impl-dbus.Po at am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote at src/$(DEPDIR)/xdg_desktop_portal-account.Po at am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote at src/$(DEPDIR)/xdg_desktop_portal-background.Po at am__quote@ # am--include-marker
@@ -2195,6 +2229,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at src/$(DEPDIR)/xdg_document_portal-xdp-utils.Po at am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote at src/$(DEPDIR)/xdg_permission_store-xdp-utils.Po at am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote at tests/$(DEPDIR)/test_backends-glib-backports.Po at am__quote@ # am--include-marker
+ at AMDEP_TRUE@@am__include@ @am__quote at tests/$(DEPDIR)/test_doc_portal-can-use-fuse.Po at am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote at tests/$(DEPDIR)/test_doc_portal-test-doc-portal.Po at am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote at tests/$(DEPDIR)/test_permission_store-test-permission-store.Po at am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote at tests/$(DEPDIR)/test_portals-account.Po at am__quote@ # am--include-marker
@@ -2213,6 +2248,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at tests/$(DEPDIR)/test_portals-trash.Po at am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote at tests/$(DEPDIR)/test_portals-utils.Po at am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote at tests/$(DEPDIR)/test_portals-wallpaper.Po at am__quote@ # am--include-marker
+ at AMDEP_TRUE@@am__include@ @am__quote at tests/$(DEPDIR)/test_xdp_utils-test-xdp-utils.Po at am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote at tests/$(DEPDIR)/testdb-testdb.Po at am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote at tests/backend/$(DEPDIR)/test_backends-access.Po at am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote at tests/backend/$(DEPDIR)/test_backends-account.Po at am__quote@ # am--include-marker
@@ -2260,6 +2296,20 @@ am--depfiles: $(am__depfiles_remade)
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LTCOMPILE) -c -o $@ $<
 
+tests/test_doc_portal-can-use-fuse.o: tests/can-use-fuse.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_doc_portal_CFLAGS) $(CFLAGS) -MT tests/test_doc_portal-can-use-fuse.o -MD -MP -MF tests/$(DEPDIR)/test_doc_portal-can-use-fuse.Tpo -c -o tests/test_doc_portal-can-use-fuse.o `test -f 'tests/can-use-fuse.c' || echo '$(srcdir)/'`tests/can-use-fuse.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) tests/$(DEPDIR)/test_doc_portal-can-use-fuse.Tpo tests/$(DEPDIR)/test_doc_portal-can-use-fuse.Po
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='tests/can-use-fuse.c' object='tests/test_doc_portal-can-use-fuse.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_doc_portal_CFLAGS) $(CFLAGS) -c -o tests/test_doc_portal-can-use-fuse.o `test -f 'tests/can-use-fuse.c' || echo '$(srcdir)/'`tests/can-use-fuse.c
+
+tests/test_doc_portal-can-use-fuse.obj: tests/can-use-fuse.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_doc_portal_CFLAGS) $(CFLAGS) -MT tests/test_doc_portal-can-use-fuse.obj -MD -MP -MF tests/$(DEPDIR)/test_doc_portal-can-use-fuse.Tpo -c -o tests/test_doc_portal-can-use-fuse.obj `if test -f 'tests/can-use-fuse.c'; then $(CYGPATH_W) 'tests/can-use-fuse.c'; else $(CYGPATH_W) '$(srcdir)/tests/can-use-fuse.c'; fi`
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) tests/$(DEPDIR)/test_doc_portal-can-use-fuse.Tpo tests/$(DEPDIR)/test_doc_portal-can-use-fuse.Po
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='tests/can-use-fuse.c' object='tests/test_doc_portal-can-use-fuse.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_doc_portal_CFLAGS) $(CFLAGS) -c -o tests/test_doc_portal-can-use-fuse.obj `if test -f 'tests/can-use-fuse.c'; then $(CYGPATH_W) 'tests/can-use-fuse.c'; else $(CYGPATH_W) '$(srcdir)/tests/can-use-fuse.c'; fi`
+
 tests/test_doc_portal-test-doc-portal.o: tests/test-doc-portal.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_doc_portal_CFLAGS) $(CFLAGS) -MT tests/test_doc_portal-test-doc-portal.o -MD -MP -MF tests/$(DEPDIR)/test_doc_portal-test-doc-portal.Tpo -c -o tests/test_doc_portal-test-doc-portal.o `test -f 'tests/test-doc-portal.c' || echo '$(srcdir)/'`tests/test-doc-portal.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) tests/$(DEPDIR)/test_doc_portal-test-doc-portal.Tpo tests/$(DEPDIR)/test_doc_portal-test-doc-portal.Po
@@ -2610,6 +2660,34 @@ document-portal/test_portals-permission-store-dbus.obj: document-portal/permissi
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_portals_CPPFLAGS) $(CPPFLAGS) $(test_portals_CFLAGS) $(CFLAGS) -c -o document-portal/test_portals-permission-store-dbus.obj `if test -f 'document-portal/permission-store-dbus.c'; then $(CYGPATH_W) 'document-portal/permission-store-dbus.c'; else $(CYGPATH_W) '$(srcdir)/document-portal/permission-store-dbus.c'; fi`
 
+tests/test_xdp_utils-test-xdp-utils.o: tests/test-xdp-utils.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_xdp_utils_CFLAGS) $(CFLAGS) -MT tests/test_xdp_utils-test-xdp-utils.o -MD -MP -MF tests/$(DEPDIR)/test_xdp_utils-test-xdp-utils.Tpo -c -o tests/test_xdp_utils-test-xdp-utils.o `test -f 'tests/test-xdp-utils.c' || echo '$(srcdir)/'`tests/test-xdp-utils.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) tests/$(DEPDIR)/test_xdp_utils-test-xdp-utils.Tpo tests/$(DEPDIR)/test_xdp_utils-test-xdp-utils.Po
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='tests/test-xdp-utils.c' object='tests/test_xdp_utils-test-xdp-utils.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_xdp_utils_CFLAGS) $(CFLAGS) -c -o tests/test_xdp_utils-test-xdp-utils.o `test -f 'tests/test-xdp-utils.c' || echo '$(srcdir)/'`tests/test-xdp-utils.c
+
+tests/test_xdp_utils-test-xdp-utils.obj: tests/test-xdp-utils.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_xdp_utils_CFLAGS) $(CFLAGS) -MT tests/test_xdp_utils-test-xdp-utils.obj -MD -MP -MF tests/$(DEPDIR)/test_xdp_utils-test-xdp-utils.Tpo -c -o tests/test_xdp_utils-test-xdp-utils.obj `if test -f 'tests/test-xdp-utils.c'; then $(CYGPATH_W) 'tests/test-xdp-utils.c'; else $(CYGPATH_W) '$(srcdir)/tests/test-xdp-utils.c'; fi`
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) tests/$(DEPDIR)/test_xdp_utils-test-xdp-utils.Tpo tests/$(DEPDIR)/test_xdp_utils-test-xdp-utils.Po
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='tests/test-xdp-utils.c' object='tests/test_xdp_utils-test-xdp-utils.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_xdp_utils_CFLAGS) $(CFLAGS) -c -o tests/test_xdp_utils-test-xdp-utils.obj `if test -f 'tests/test-xdp-utils.c'; then $(CYGPATH_W) 'tests/test-xdp-utils.c'; else $(CYGPATH_W) '$(srcdir)/tests/test-xdp-utils.c'; fi`
+
+src/test_xdp_utils-xdp-utils.o: src/xdp-utils.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_xdp_utils_CFLAGS) $(CFLAGS) -MT src/test_xdp_utils-xdp-utils.o -MD -MP -MF src/$(DEPDIR)/test_xdp_utils-xdp-utils.Tpo -c -o src/test_xdp_utils-xdp-utils.o `test -f 'src/xdp-utils.c' || echo '$(srcdir)/'`src/xdp-utils.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) src/$(DEPDIR)/test_xdp_utils-xdp-utils.Tpo src/$(DEPDIR)/test_xdp_utils-xdp-utils.Po
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='src/xdp-utils.c' object='src/test_xdp_utils-xdp-utils.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_xdp_utils_CFLAGS) $(CFLAGS) -c -o src/test_xdp_utils-xdp-utils.o `test -f 'src/xdp-utils.c' || echo '$(srcdir)/'`src/xdp-utils.c
+
+src/test_xdp_utils-xdp-utils.obj: src/xdp-utils.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_xdp_utils_CFLAGS) $(CFLAGS) -MT src/test_xdp_utils-xdp-utils.obj -MD -MP -MF src/$(DEPDIR)/test_xdp_utils-xdp-utils.Tpo -c -o src/test_xdp_utils-xdp-utils.obj `if test -f 'src/xdp-utils.c'; then $(CYGPATH_W) 'src/xdp-utils.c'; else $(CYGPATH_W) '$(srcdir)/src/xdp-utils.c'; fi`
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) src/$(DEPDIR)/test_xdp_utils-xdp-utils.Tpo src/$(DEPDIR)/test_xdp_utils-xdp-utils.Po
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='src/xdp-utils.c' object='src/test_xdp_utils-xdp-utils.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_xdp_utils_CFLAGS) $(CFLAGS) -c -o src/test_xdp_utils-xdp-utils.obj `if test -f 'src/xdp-utils.c'; then $(CYGPATH_W) 'src/xdp-utils.c'; else $(CYGPATH_W) '$(srcdir)/src/xdp-utils.c'; fi`
+
 tests/testdb-testdb.o: tests/testdb.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testdb_CFLAGS) $(CFLAGS) -MT tests/testdb-testdb.o -MD -MP -MF tests/$(DEPDIR)/testdb-testdb.Tpo -c -o tests/testdb-testdb.o `test -f 'tests/testdb.c' || echo '$(srcdir)/'`tests/testdb.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) tests/$(DEPDIR)/testdb-testdb.Tpo tests/$(DEPDIR)/testdb-testdb.Po
@@ -4102,6 +4180,13 @@ test-portals.log: test-portals$(EXEEXT)
 	--log-file $$b.log --trs-file $$b.trs \
 	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
 	"$$tst" $(AM_TESTS_FD_REDIRECT)
+test-xdp-utils.log: test-xdp-utils$(EXEEXT)
+	@p='test-xdp-utils$(EXEEXT)'; \
+	b='test-xdp-utils'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
 testdb.log: testdb$(EXEEXT)
 	@p='testdb$(EXEEXT)'; \
 	b='testdb'; \
@@ -4432,6 +4517,7 @@ distclean: distclean-recursive
 	-rm -f src/$(DEPDIR)/test_portals-xdp-dbus.Po
 	-rm -f src/$(DEPDIR)/test_portals-xdp-impl-dbus.Po
 	-rm -f src/$(DEPDIR)/test_portals-xdp-utils.Po
+	-rm -f src/$(DEPDIR)/test_xdp_utils-xdp-utils.Po
 	-rm -f src/$(DEPDIR)/tests_test_backends-xdp-impl-dbus.Po
 	-rm -f src/$(DEPDIR)/xdg_desktop_portal-account.Po
 	-rm -f src/$(DEPDIR)/xdg_desktop_portal-background.Po
@@ -4472,6 +4558,7 @@ distclean: distclean-recursive
 	-rm -f src/$(DEPDIR)/xdg_document_portal-xdp-utils.Po
 	-rm -f src/$(DEPDIR)/xdg_permission_store-xdp-utils.Po
 	-rm -f tests/$(DEPDIR)/test_backends-glib-backports.Po
+	-rm -f tests/$(DEPDIR)/test_doc_portal-can-use-fuse.Po
 	-rm -f tests/$(DEPDIR)/test_doc_portal-test-doc-portal.Po
 	-rm -f tests/$(DEPDIR)/test_permission_store-test-permission-store.Po
 	-rm -f tests/$(DEPDIR)/test_portals-account.Po
@@ -4490,6 +4577,7 @@ distclean: distclean-recursive
 	-rm -f tests/$(DEPDIR)/test_portals-trash.Po
 	-rm -f tests/$(DEPDIR)/test_portals-utils.Po
 	-rm -f tests/$(DEPDIR)/test_portals-wallpaper.Po
+	-rm -f tests/$(DEPDIR)/test_xdp_utils-test-xdp-utils.Po
 	-rm -f tests/$(DEPDIR)/testdb-testdb.Po
 	-rm -f tests/backend/$(DEPDIR)/test_backends-access.Po
 	-rm -f tests/backend/$(DEPDIR)/test_backends-account.Po
@@ -4589,6 +4677,7 @@ maintainer-clean: maintainer-clean-recursive
 	-rm -f src/$(DEPDIR)/test_portals-xdp-dbus.Po
 	-rm -f src/$(DEPDIR)/test_portals-xdp-impl-dbus.Po
 	-rm -f src/$(DEPDIR)/test_portals-xdp-utils.Po
+	-rm -f src/$(DEPDIR)/test_xdp_utils-xdp-utils.Po
 	-rm -f src/$(DEPDIR)/tests_test_backends-xdp-impl-dbus.Po
 	-rm -f src/$(DEPDIR)/xdg_desktop_portal-account.Po
 	-rm -f src/$(DEPDIR)/xdg_desktop_portal-background.Po
@@ -4629,6 +4718,7 @@ maintainer-clean: maintainer-clean-recursive
 	-rm -f src/$(DEPDIR)/xdg_document_portal-xdp-utils.Po
 	-rm -f src/$(DEPDIR)/xdg_permission_store-xdp-utils.Po
 	-rm -f tests/$(DEPDIR)/test_backends-glib-backports.Po
+	-rm -f tests/$(DEPDIR)/test_doc_portal-can-use-fuse.Po
 	-rm -f tests/$(DEPDIR)/test_doc_portal-test-doc-portal.Po
 	-rm -f tests/$(DEPDIR)/test_permission_store-test-permission-store.Po
 	-rm -f tests/$(DEPDIR)/test_portals-account.Po
@@ -4647,6 +4737,7 @@ maintainer-clean: maintainer-clean-recursive
 	-rm -f tests/$(DEPDIR)/test_portals-trash.Po
 	-rm -f tests/$(DEPDIR)/test_portals-utils.Po
 	-rm -f tests/$(DEPDIR)/test_portals-wallpaper.Po
+	-rm -f tests/$(DEPDIR)/test_xdp_utils-test-xdp-utils.Po
 	-rm -f tests/$(DEPDIR)/testdb-testdb.Po
 	-rm -f tests/backend/$(DEPDIR)/test_backends-access.Po
 	-rm -f tests/backend/$(DEPDIR)/test_backends-account.Po
diff --git a/NEWS b/NEWS
index 77d37dd..5cbbf24 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,15 @@
+Changes in 1.8.1
+================
+
+- openuri: Fix an fd leak
+- filechooser: Fix directory support
+- build: Drop a fontconfig dependency
+- snap: Use cgroups to identify confined apps
+- documents: Add snap support
+- wallpaper: Fix a crash
+- build: Factor out a fuse check
+- Translation updates
+
 Changes in 1.8.0
 ================
 
diff --git a/configure b/configure
index 7c68579..4817197 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for xdg-desktop-portal 1.8.0.
+# Generated by GNU Autoconf 2.69 for xdg-desktop-portal 1.8.1.
 #
 #
 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -587,8 +587,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='xdg-desktop-portal'
 PACKAGE_TARNAME='xdg-desktop-portal'
-PACKAGE_VERSION='1.8.0'
-PACKAGE_STRING='xdg-desktop-portal 1.8.0'
+PACKAGE_VERSION='1.8.1'
+PACKAGE_STRING='xdg-desktop-portal 1.8.1'
 PACKAGE_BUGREPORT=''
 PACKAGE_URL=''
 
@@ -1405,7 +1405,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures xdg-desktop-portal 1.8.0 to adapt to many kinds of systems.
+\`configure' configures xdg-desktop-portal 1.8.1 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1476,7 +1476,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of xdg-desktop-portal 1.8.0:";;
+     short | recursive ) echo "Configuration of xdg-desktop-portal 1.8.1:";;
    esac
   cat <<\_ACEOF
 
@@ -1645,7 +1645,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-xdg-desktop-portal configure 1.8.0
+xdg-desktop-portal configure 1.8.1
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2010,7 +2010,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by xdg-desktop-portal $as_me 1.8.0, which was
+It was created by xdg-desktop-portal $as_me 1.8.1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -12753,7 +12753,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='xdg-desktop-portal'
- VERSION='1.8.0'
+ VERSION='1.8.1'
 
 
 # Some tools Automake needs.
@@ -15530,12 +15530,12 @@ if test -n "$BASE_CFLAGS"; then
     pkg_cv_BASE_CFLAGS="$BASE_CFLAGS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"glib-2.0 gio-2.0 gio-unix-2.0 fontconfig json-glib-1.0\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "glib-2.0 gio-2.0 gio-unix-2.0 fontconfig json-glib-1.0") 2>&5
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"glib-2.0 gio-2.0 gio-unix-2.0 json-glib-1.0\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "glib-2.0 gio-2.0 gio-unix-2.0 json-glib-1.0") 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
-  pkg_cv_BASE_CFLAGS=`$PKG_CONFIG --cflags "glib-2.0 gio-2.0 gio-unix-2.0 fontconfig json-glib-1.0" 2>/dev/null`
+  pkg_cv_BASE_CFLAGS=`$PKG_CONFIG --cflags "glib-2.0 gio-2.0 gio-unix-2.0 json-glib-1.0" 2>/dev/null`
 		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
@@ -15547,12 +15547,12 @@ if test -n "$BASE_LIBS"; then
     pkg_cv_BASE_LIBS="$BASE_LIBS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"glib-2.0 gio-2.0 gio-unix-2.0 fontconfig json-glib-1.0\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "glib-2.0 gio-2.0 gio-unix-2.0 fontconfig json-glib-1.0") 2>&5
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"glib-2.0 gio-2.0 gio-unix-2.0 json-glib-1.0\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "glib-2.0 gio-2.0 gio-unix-2.0 json-glib-1.0") 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
-  pkg_cv_BASE_LIBS=`$PKG_CONFIG --libs "glib-2.0 gio-2.0 gio-unix-2.0 fontconfig json-glib-1.0" 2>/dev/null`
+  pkg_cv_BASE_LIBS=`$PKG_CONFIG --libs "glib-2.0 gio-2.0 gio-unix-2.0 json-glib-1.0" 2>/dev/null`
 		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
@@ -15573,14 +15573,14 @@ else
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        BASE_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "glib-2.0 gio-2.0 gio-unix-2.0 fontconfig json-glib-1.0" 2>&1`
+	        BASE_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "glib-2.0 gio-2.0 gio-unix-2.0 json-glib-1.0" 2>&1`
         else
-	        BASE_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "glib-2.0 gio-2.0 gio-unix-2.0 fontconfig json-glib-1.0" 2>&1`
+	        BASE_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "glib-2.0 gio-2.0 gio-unix-2.0 json-glib-1.0" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
 	echo "$BASE_PKG_ERRORS" >&5
 
-	as_fn_error $? "Package requirements (glib-2.0 gio-2.0 gio-unix-2.0 fontconfig json-glib-1.0) were not met:
+	as_fn_error $? "Package requirements (glib-2.0 gio-2.0 gio-unix-2.0 json-glib-1.0) were not met:
 
 $BASE_PKG_ERRORS
 
@@ -16922,7 +16922,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by xdg-desktop-portal $as_me 1.8.0, which was
+This file was extended by xdg-desktop-portal $as_me 1.8.1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -16988,7 +16988,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-xdg-desktop-portal config.status 1.8.0
+xdg-desktop-portal config.status 1.8.1
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
index 172efd6..c059aa4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
 AC_PREREQ([2.63])
 
-AC_INIT([xdg-desktop-portal],[1.8.0])
+AC_INIT([xdg-desktop-portal],[1.8.1])
 
 AC_USE_SYSTEM_EXTENSIONS
 AC_SYS_LARGEFILE
@@ -70,7 +70,7 @@ AC_PATH_PROG([BWRAP], [bwrap])
 AC_SUBST([GLIB_COMPILE_RESOURCES], [`$PKG_CONFIG --variable glib_compile_resources gio-2.0`])
 AC_SUBST([GDBUS_CODEGEN], [`$PKG_CONFIG --variable gdbus_codegen gio-2.0`])
 
-PKG_CHECK_MODULES(BASE, [glib-2.0 gio-2.0 gio-unix-2.0 fontconfig json-glib-1.0])
+PKG_CHECK_MODULES(BASE, [glib-2.0 gio-2.0 gio-unix-2.0 json-glib-1.0])
 AC_SUBST(BASE_CFLAGS)
 AC_SUBST(BASE_LIBS)
 
diff --git a/debian/changelog b/debian/changelog
index 61e2b82..a63d327 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,24 @@
+xdg-desktop-portal (1.8.1-1) unstable; urgency=medium
+
+  * New upstream release
+    - Fix a fd leak when opening URIs
+    - Fix directory support in filechooser
+    - Improve Snap support
+    - Fix a crash when setting wallpaper fails
+  * Drop fontconfig build-dependency, no longer needed
+  * Define _GNU_SOURCE when compiling the icon validator,
+    avoiding an implicit declaration of execvpe()
+  * Label the icon validator as coming from Flatpak 1.10.1
+    (no actual changes, the code is identical to 1.8.1)
+
+ -- Simon McVittie <smcv at debian.org>  Fri, 19 Feb 2021 10:21:45 +0000
+
+xdg-desktop-portal (1.8.0-3) unstable; urgency=medium
+
+  * debian/rules: Build with pipewire support in ubuntu as well (LP: #1879580)
+
+ -- Marco Trevisan (TreviƱo) <marco at ubuntu.com>  Thu, 11 Feb 2021 19:08:03 +0100
+
 xdg-desktop-portal (1.8.0-2) unstable; urgency=medium
 
   * Version the build-dependency on libflatpak-dev.
@@ -16,12 +37,6 @@ xdg-desktop-portal (1.8.0-1) unstable; urgency=medium
 
  -- Simon McVittie <smcv at debian.org>  Wed, 16 Sep 2020 10:31:24 +0100
 
-xdg-desktop-portal (1.8.0-0neon) UNRELEASED; urgency=medium
-
-  * New release
-
- -- Jonathan Riddell <jr at jriddell.org>  Fri, 18 Dec 2020 10:48:58 +0000
-
 xdg-desktop-portal (1.7.2-2) unstable; urgency=medium
 
   * d/rules: Don't explicitly use --as-needed linker option.
diff --git a/debian/control b/debian/control
index 38f0f53..d513240 100644
--- a/debian/control
+++ b/debian/control
@@ -13,7 +13,6 @@ Build-Depends:
  libgdk-pixbuf-2.0-dev | libgdk-pixbuf2.0-dev,
  libgeoclue-2-dev (>= 2.5.2),
  libflatpak-dev (>= 1.5.0),
- libfontconfig1-dev,
  libfuse-dev,
  libglib2.0-dev,
  libjson-glib-dev,
diff --git a/debian/patches/Replace-the-icon-validator-with-the-one-from-Flatpak-1.8..patch b/debian/patches/Replace-the-icon-validator-with-the-one-from-Flatpak-1.10.patch
similarity index 93%
rename from debian/patches/Replace-the-icon-validator-with-the-one-from-Flatpak-1.8..patch
rename to debian/patches/Replace-the-icon-validator-with-the-one-from-Flatpak-1.10.patch
index bc59814..f4bfb47 100644
--- a/debian/patches/Replace-the-icon-validator-with-the-one-from-Flatpak-1.8..patch
+++ b/debian/patches/Replace-the-icon-validator-with-the-one-from-Flatpak-1.10.patch
@@ -1,16 +1,27 @@
 From: Simon McVittie <smcv at debian.org>
 Date: Fri, 25 Jan 2019 19:13:33 +0000
-Subject: Replace the icon validator with the one from Flatpak 1.8.1
+Subject: Replace the icon validator with the one from Flatpak 1.10.1
 
 We avoid relying on Flatpak here, since that dependency would be quite
 circular.
 
 Signed-off-by: Simon McVittie <smcv at debian.org>
 ---
+ src/Makefile.am.inc |   2 +-
  src/notification.c  |  14 +---
  src/validate-icon.c | 212 ++++++++++++++++++++++++++++++++++++++++++++++++++--
- 2 files changed, 207 insertions(+), 19 deletions(-)
+ 3 files changed, 208 insertions(+), 20 deletions(-)
 
+diff --git a/src/Makefile.am.inc b/src/Makefile.am.inc
+index 15cfdc1..c726e47 100644
+--- a/src/Makefile.am.inc
++++ b/src/Makefile.am.inc
+@@ -214,4 +214,4 @@ xdg_desktop_portal_CPPFLAGS = \
+ 
+ xdg_desktop_portal_validate_icon_SOURCES = src/validate-icon.c
+ xdg_desktop_portal_validate_icon_LDADD = $(GDK_PIXBUF_LIBS)
+-xdg_desktop_portal_validate_icon_CFLAGS = $(GDK_PIXBUF_CFLAGS) -DHELPER=\"$(BWRAP)\"
++xdg_desktop_portal_validate_icon_CFLAGS = $(GDK_PIXBUF_CFLAGS) -DHELPER=\"$(BWRAP)\" -D_GNU_SOURCE=1
 diff --git a/src/notification.c b/src/notification.c
 index 5412609..35c779c 100644
 --- a/src/notification.c
diff --git a/debian/patches/Revert-Stop-building-the-icon-validator.patch b/debian/patches/Revert-Stop-building-the-icon-validator.patch
index e9141fe..5871693 100644
--- a/debian/patches/Revert-Stop-building-the-icon-validator.patch
+++ b/debian/patches/Revert-Stop-building-the-icon-validator.patch
@@ -11,7 +11,7 @@ This reverts commit 2fb498f92f8e1c41049dedf887690083fa12f6d1.
  create mode 100644 src/validate-icon.c
 
 diff --git a/configure.ac b/configure.ac
-index 172efd6..6c72125 100644
+index c059aa4..afe6778 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -175,6 +175,7 @@ fi
diff --git a/debian/rules b/debian/rules
index 93b1c38..44df372 100755
--- a/debian/rules
+++ b/debian/rules
@@ -5,13 +5,6 @@ export LC_ALL=C.UTF-8
 
 include /usr/share/dpkg/default.mk
 
-# pipewire is not in Ubuntu main yet https://launchpad.net/bugs/1802533
-ifeq ($(shell dpkg-vendor --query vendor),Ubuntu)
-	CONFFLAGS += --disable-pipewire
-else
-	CONFFLAGS += --enable-pipewire
-endif
-
 # ITP #946605
 ifeq ($(filter pkg.libportal.enable,$(DEB_BUILD_PROFILES)),)
 CONFFLAGS += --disable-libportal
@@ -27,6 +20,7 @@ override_dh_auto_configure:
 		--enable-docbook-docs \
 		--enable-geoclue \
 		--enable-installed-tests \
+		--enable-pipewire \
 		$(CONFFLAGS)
 		$(NULL)
 
diff --git a/debian/series b/debian/series
new file mode 100644
index 0000000..36372b9
--- /dev/null
+++ b/debian/series
@@ -0,0 +1,3 @@
+Revert-Stop-building-the-icon-validator.patch
+validate-icon-Add-a-define-for-bwrap.patch
+Replace-the-icon-validator-with-the-one-from-Flatpak-1.10.patch
diff --git a/document-portal/document-portal.c b/document-portal/document-portal.c
index a4c044a..ec21c82 100644
--- a/document-portal/document-portal.c
+++ b/document-portal/document-portal.c
@@ -499,15 +499,16 @@ portal_add (GDBusMethodInvocation *invocation,
 }
 
 static char *
-flatpak (GError **error,
-         ...)
+get_output (GError     **error,
+            const char  *argv0,
+            ...)
 {
   gboolean res;
   g_autofree char *output = NULL;
   va_list ap;
 
-  va_start (ap, error);
-  res = xdp_spawn (NULL, &output, 0, error, "flatpak", ap);
+  va_start (ap, argv0);
+  res = xdp_spawn (NULL, &output, 0, error, argv0, ap);
   va_end (ap);
 
   if (res)
@@ -632,9 +633,17 @@ app_has_file_access (const char *target_app_id,
   if (target_app_id == NULL || target_app_id[0] == '\0')
     return FALSE;
 
-  /* First we try flatpak info --file-access=PATH APPID, which is supported on new versions */
-  arg = g_strdup_printf ("--file-access=%s", path);
-  res = flatpak (&error, "info", arg, target_app_id, NULL);
+  if (g_str_has_prefix (target_app_id, "snap."))
+    {
+      res = get_output (&error, "snap", "routine", "file-access",
+                        target_app_id + strlen ("snap."), path, NULL);
+    }
+  else
+    {
+      /* First we try flatpak info --file-access=PATH APPID, which is supported on new versions */
+      arg = g_strdup_printf ("--file-access=%s", path);
+      res = get_output (&error, "flatpak", "info", arg, target_app_id, NULL);
+    }
 
   if (res)
     {
@@ -1448,6 +1457,8 @@ on_name_acquired (GDBusConnection *connection,
 
   fuse_dev = stbuf.st_dev;
 
+  xdp_set_documents_mountpoint (xdp_fuse_get_mountpoint ());
+
   while ((invocation = g_queue_pop_head (&get_mount_point_invocations)) != NULL)
     {
       xdp_dbus_documents_complete_get_mount_point (dbus_api, invocation, xdp_fuse_get_mountpoint ());
diff --git a/src/account.c b/src/account.c
index 537d8b0..15a7e89 100644
--- a/src/account.c
+++ b/src/account.c
@@ -30,7 +30,6 @@
 #include <fcntl.h>
 
 #include <gio/gio.h>
-#include <gio/gunixfdlist.h>
 
 #include "account.h"
 #include "request.h"
diff --git a/src/documents.c b/src/documents.c
index 99de9e4..9ddc4ac 100644
--- a/src/documents.c
+++ b/src/documents.c
@@ -31,6 +31,7 @@
 #include <gio/gunixfdlist.h>
 
 #include "xdp-dbus.h"
+#include "xdp-utils.h"
 #include "document-enums.h"
 
 static XdpDocuments *documents = NULL;
@@ -46,6 +47,7 @@ init_document_proxy (GDBusConnection *connection)
   xdp_documents_call_get_mount_point_sync (documents,
                                            &documents_mountpoint,
                                            NULL, NULL);
+  xdp_set_documents_mountpoint (documents_mountpoint);
 }
 
 char *
diff --git a/src/file-chooser.c b/src/file-chooser.c
index 166ae9a..86f3c9a 100644
--- a/src/file-chooser.c
+++ b/src/file-chooser.c
@@ -31,7 +31,6 @@
 #include <fcntl.h>
 
 #include <gio/gio.h>
-#include <gio/gunixfdlist.h>
 
 #include "file-chooser.h"
 #include "request.h"
diff --git a/src/open-uri.c b/src/open-uri.c
index 9243e00..9525c1f 100644
--- a/src/open-uri.c
+++ b/src/open-uri.c
@@ -586,7 +586,7 @@ handle_open_in_thread_func (GTask *task,
   gboolean ask_for_content_type;
   GVariantBuilder opts_builder;
   gboolean skip_app_chooser = FALSE;
-  int fd;
+  g_auto(XdpFd) fd = -1;
   gboolean writable = FALSE;
   gboolean ask = FALSE;
   gboolean open_dir = FALSE;
@@ -844,6 +844,7 @@ handle_open_uri (XdpOpenURI *object,
   if (!g_variant_lookup (arg_options, "ask", "b", &ask))
     ask = FALSE;
 
+  g_object_set_data (G_OBJECT (request), "fd", GINT_TO_POINTER (-1));
   g_object_set_data_full (G_OBJECT (request), "uri", g_strdup (arg_uri), g_free);
   g_object_set_data_full (G_OBJECT (request), "parent-window", g_strdup (arg_parent_window), g_free);
   g_object_set_data (G_OBJECT (request), "writable", GINT_TO_POINTER (writable));
diff --git a/src/screenshot.c b/src/screenshot.c
index 175b4cc..abe2780 100644
--- a/src/screenshot.c
+++ b/src/screenshot.c
@@ -29,7 +29,6 @@
 #include <fcntl.h>
 
 #include <gio/gio.h>
-#include <gio/gunixfdlist.h>
 
 #include "screenshot.h"
 #include "request.h"
diff --git a/src/wallpaper.c b/src/wallpaper.c
index 4224a4f..e5c4d9a 100644
--- a/src/wallpaper.c
+++ b/src/wallpaper.c
@@ -145,9 +145,10 @@ handle_set_wallpaper_in_thread_func (GTask *task,
       g_warning ("Rejecting invalid open-uri request (both URI and fd are set)");
       if (request->exported)
         {
+          g_variant_builder_init (&opt_builder, G_VARIANT_TYPE_VARDICT);
           xdp_request_emit_response (XDP_REQUEST (request),
                                      XDG_DESKTOP_PORTAL_RESPONSE_OTHER,
-                                     NULL);
+                                     g_variant_builder_end (&opt_builder));
           request_unexport (request);
         }
       return;
@@ -238,9 +239,10 @@ handle_set_wallpaper_in_thread_func (GTask *task,
           /* Reject the request */
           if (request->exported)
             {
+              g_variant_builder_init (&opt_builder, G_VARIANT_TYPE_VARDICT);
               xdp_request_emit_response (XDP_REQUEST (request),
                                          XDG_DESKTOP_PORTAL_RESPONSE_OTHER,
-                                         NULL);
+                                         g_variant_builder_end (&opt_builder));
               request_unexport (request);
             }
           return;
diff --git a/src/xdp-utils.c b/src/xdp-utils.c
index 4f72df1..ef68f0f 100644
--- a/src/xdp-utils.c
+++ b/src/xdp-utils.c
@@ -28,8 +28,6 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <stdio.h>
-#include <mntent.h>
-#include <unistd.h>
 #include <sys/vfs.h>
 
 #include <gio/gdesktopappinfo.h>
@@ -131,7 +129,7 @@ struct _XdpAppInfo {
         } flatpak;
       struct
         {
-          int dummy;
+          GKeyFile *keyfile;
         } snap;
     } u;
 };
@@ -165,6 +163,7 @@ xdp_app_info_free (XdpAppInfo *app_info)
       break;
 
     case XDP_APP_INFO_KIND_SNAP:
+      g_clear_pointer (&app_info->u.snap.keyfile, g_key_file_free);
       break;
 
     case XDP_APP_INFO_KIND_HOST:
@@ -208,10 +207,27 @@ xdp_app_info_load_app_info (XdpAppInfo *app_info)
 
   g_return_val_if_fail (app_info != NULL, NULL);
 
-  if (app_info->id[0] == '\0')
-    return NULL;
+  switch (app_info->kind)
+    {
+    case XDP_APP_INFO_KIND_FLATPAK:
+      desktop_id = g_strconcat (app_info->id, ".desktop", NULL);
+      break;
 
-  desktop_id = g_strconcat (app_info->id, ".desktop", NULL);
+    case XDP_APP_INFO_KIND_SNAP:
+      desktop_id = g_key_file_get_string (app_info->u.snap.keyfile,
+                                          SNAP_METADATA_GROUP_INFO,
+                                          SNAP_METADATA_KEY_DESKTOP_FILE,
+                                          NULL);
+      break;
+
+    case XDP_APP_INFO_KIND_HOST:
+    default:
+      desktop_id = NULL;
+      break;
+    }
+
+  if (desktop_id == NULL)
+    return NULL;
 
   return G_APP_INFO (g_desktop_app_info_new (desktop_id));
 }
@@ -340,7 +356,9 @@ xdp_app_info_has_network (XdpAppInfo *app_info)
       break;
 
     case XDP_APP_INFO_KIND_SNAP:
-      has_network = TRUE; /* FIXME */
+      has_network = g_key_file_get_boolean (app_info->u.snap.keyfile,
+                                            SNAP_METADATA_GROUP_INFO,
+                                            SNAP_METADATA_KEY_NETWORK, NULL);
       break;
 
     case XDP_APP_INFO_KIND_HOST:
@@ -469,133 +487,132 @@ parse_app_info_from_flatpak_info (int pid, GError **error)
   return g_steal_pointer (&app_info);
 }
 
-static gboolean
-aa_is_enabled (void)
+int
+_xdp_parse_cgroup_file (FILE *f, gboolean *is_snap)
 {
-  static int apparmor_enabled = -1;
-  struct stat statbuf;
-  struct mntent *mntpt;
-  FILE *mntfile;
-
-  if (apparmor_enabled >= 0)
-    return apparmor_enabled;
-
-  apparmor_enabled = FALSE;
+  ssize_t n;
+  g_autofree char *id = NULL;
+  g_autofree char *controller = NULL;
+  g_autofree char *cgroup = NULL;
+  size_t id_len = 0, controller_len = 0, cgroup_len = 0;
 
-  mntfile = setmntent ("/proc/mounts", "r");
-  if (!mntfile)
-    return FALSE;
+  g_return_val_if_fail(f != NULL, -1);
+  g_return_val_if_fail(is_snap != NULL, -1);
 
-  while ((mntpt = getmntent (mntfile)))
+  *is_snap = FALSE;
+  do
     {
-      g_autofree char *proposed = NULL;
-
-      if (strcmp (mntpt->mnt_type, "securityfs") != 0)
-        continue;
-
-      proposed = g_strdup_printf ("%s/apparmor", mntpt->mnt_dir);
-      if (stat (proposed, &statbuf) == 0)
+      n = getdelim (&id, &id_len, ':', f);
+      if (n == -1) break;
+      n = getdelim (&controller, &controller_len, ':', f);
+      if (n == -1) break;
+      n = getdelim (&cgroup, &cgroup_len, '\n', f);
+      if (n == -1) break;
+
+      /* Only consider the freezer, systemd group or unified cgroup
+       * hierarchies */
+      if ((!strcmp (controller, "freezer:") != 0 ||
+           !strcmp (controller, "name=systemd:") != 0 ||
+           !strcmp (controller, ":") != 0) &&
+          strstr (cgroup, "/snap.") != NULL)
         {
-          apparmor_enabled = TRUE;
+          *is_snap = TRUE;
           break;
         }
     }
+  while (n >= 0);
 
-  endmntent (mntfile);
+  if (n < 0 && !feof(f)) return -1;
 
-  return apparmor_enabled;
+  return 0;
 }
 
-#define UNCONFINED		"unconfined"
-#define UNCONFINED_SIZE		strlen(UNCONFINED)
-
 static gboolean
-parse_unconfined (char *con, int size)
+pid_is_snap (pid_t pid, GError **error)
 {
-  return size == UNCONFINED_SIZE && strncmp (con, UNCONFINED, UNCONFINED_SIZE) == 0;
-}
-
-static char *
-aa_splitcon (char *con, char **mode)
-{
-  char *label = NULL;
-  char *mode_str = NULL;
-  char *newline = NULL;
-  int size = strlen (con);
+  g_autofree char *cgroup_path = NULL;;
+  int fd;
+  FILE *f = NULL;
+  gboolean is_snap = FALSE;
+  int err = 0;
 
-  if (size == 0)
-    return NULL;
+  g_return_val_if_fail(pid > 0, FALSE);
 
-  /* Strip newline */
-  if (con[size - 1] == '\n')
+  cgroup_path = g_strdup_printf ("/proc/%u/cgroup", (guint) pid);
+  fd = open (cgroup_path, O_RDONLY | O_CLOEXEC | O_NOCTTY);
+  if (fd == -1)
     {
-      newline = &con[size - 1];
-      size--;
+      err = errno;
+      goto end;
     }
 
-  if (parse_unconfined (con, size))
+  f = fdopen (fd, "r");
+  if (f == NULL)
     {
-      label = con;
+      err = errno;
+      goto end;
     }
-  else if (size > 3 && con[size - 1] == ')')
-    {
-      int pos = size - 2;
 
-      while (pos > 0 && !(con[pos] == ' ' && con[pos + 1] == '('))
-        pos--;
+  fd = -1; /* fd is now owned by f */
 
-      if (pos > 0)
-        {
-          con[pos] = 0; /* overwrite ' ' */
-          con[size - 1] = 0; /* overwrite trailing ) */
-          mode_str = &con[pos + 2]; /* skip '(' */
-          label = con;
-        }
-    }
+  if (_xdp_parse_cgroup_file (f, &is_snap) == -1)
+    err = errno;
 
-  if (label && newline)
-    *newline = 0; /* overwrite '\n', if requested, on success */
-  if (mode)
-    *mode = mode_str;
+  fclose (f);
 
-  return label;
+end:
+  /* Silence ENOENT, treating it as "not a snap" */
+  if (err != 0 && err != ENOENT)
+    {
+      g_set_error (error, G_IO_ERROR, g_io_error_from_errno (err),
+                   "Could not parse cgroup info for pid %u: %s", (guint) pid,
+                   g_strerror (err));
+    }
+  return is_snap;
 }
 
+/* Returns NULL with error set on failure, NULL with no error set if not a snap, and app-info otherwise */
 static XdpAppInfo *
-parse_app_info_from_security_label (const char *security_label)
+parse_app_info_from_snap (pid_t pid, GError **error)
 {
-  char *label, *dot;
-  g_autofree char *snap_name = NULL;
+  g_autoptr(GError) local_error = NULL;
+  g_autofree char *pid_str = NULL;
+  const char *argv[] = { "snap", "routine", "portal-info", NULL, NULL };
+  g_autofree char *output = NULL;
+  g_autoptr(GKeyFile) metadata = NULL;
   g_autoptr(XdpAppInfo) app_info = NULL;
+  g_autofree char *snap_name = NULL;
 
-  /* Snap confinement requires AppArmor */
-  if (aa_is_enabled ())
-    {
-      /* Parse the security label as an AppArmor context.  We take a copy
-       * of the string because aa_splitcon modifies its argument. */
-      g_autofree char *security_label_copy = g_strdup (security_label);
-
-      label = aa_splitcon (security_label_copy, NULL);
-      if (label && g_str_has_prefix (label, "snap."))
-        {
-          /* If the label belongs to a snap, it will be of the form
-           * snap.$PACKAGE.$APPLICATION.  We want to extract the package
-           * name */
+  /* Check the process's cgroup membership to fail quickly for non-snaps */
+  if (!pid_is_snap (pid, error)) return NULL;
 
-          label += 5;
-          dot = strchr (label, '.');
-          if (!dot)
-            return NULL;
-          snap_name = g_strndup (label, dot - label);
+  pid_str = g_strdup_printf ("%u", (guint) pid);
+  argv[3] = pid_str;
+  if (!xdp_spawnv (NULL, &output, 0, error, argv))
+    {
+      return NULL;
+    }
 
-          app_info = xdp_app_info_new (XDP_APP_INFO_KIND_SNAP);
-          app_info->id = g_strconcat ("snap.", snap_name, NULL);
+  metadata = g_key_file_new ();
+  if (!g_key_file_load_from_data (metadata, output, -1, G_KEY_FILE_NONE, &local_error))
+    {
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                   "Can't read snap info for pid %u: %s", pid, local_error->message);
+      return NULL;
+    }
 
-          return g_steal_pointer (&app_info);
-        }
+  snap_name = g_key_file_get_string (metadata, SNAP_METADATA_GROUP_INFO,
+                                     SNAP_METADATA_KEY_INSTANCE_NAME, error);
+  if (snap_name == NULL)
+    {
+      return NULL;
     }
 
-  return NULL;
+  app_info = xdp_app_info_new (XDP_APP_INFO_KIND_SNAP);
+  app_info->id = g_strconcat ("snap.", snap_name, NULL);
+  app_info->u.snap.keyfile = g_steal_pointer (&metadata);
+
+  return g_steal_pointer (&app_info);
 }
 
 
@@ -606,8 +623,6 @@ xdp_get_app_info_from_pid (pid_t pid,
   g_autoptr(XdpAppInfo) app_info = NULL;
   g_autoptr(GError) local_error = NULL;
 
-  /* TODO: Handle snap support via apparmor here */
-
   app_info = parse_app_info_from_flatpak_info (pid, &local_error);
   if (app_info == NULL && local_error)
     {
@@ -615,6 +630,16 @@ xdp_get_app_info_from_pid (pid_t pid,
       return NULL;
     }
 
+  if (app_info == NULL)
+    {
+      app_info = parse_app_info_from_snap (pid, &local_error);
+      if (app_info == NULL && local_error)
+        {
+          g_propagate_error (error, g_steal_pointer (&local_error));
+          return NULL;
+        }
+    }
+
   if (app_info == NULL)
     app_info = xdp_app_info_new_host ();
 
@@ -648,10 +673,6 @@ xdp_connection_lookup_app_info_sync (GDBusConnection       *connection,
   g_autoptr(GDBusMessage) reply = NULL;
   g_autoptr(XdpAppInfo) app_info = NULL;
   GVariant *body;
-  g_autoptr(GVariantIter) iter = NULL;
-  const char *key;
-  GVariant *value;
-  g_autofree char *security_label = NULL;
   guint32 pid = 0;
 
   app_info = lookup_cached_app_info_by_sender (sender);
@@ -661,7 +682,7 @@ xdp_connection_lookup_app_info_sync (GDBusConnection       *connection,
   msg = g_dbus_message_new_method_call (DBUS_NAME_DBUS,
                                         DBUS_PATH_DBUS,
                                         DBUS_INTERFACE_DBUS,
-                                        "GetConnectionCredentials");
+                                        "GetConnectionUnixProcessID");
   g_dbus_message_set_body (msg, g_variant_new ("(s)", sender));
 
   reply = g_dbus_connection_send_message_with_reply_sync (connection, msg,
@@ -680,37 +701,11 @@ xdp_connection_lookup_app_info_sync (GDBusConnection       *connection,
     }
 
   body = g_dbus_message_get_body (reply);
+  g_variant_get (body, "(u)", &pid);
 
-  g_variant_get (body, "(a{sv})", &iter);
-  while (g_variant_iter_loop (iter, "{&sv}", &key, &value))
-    {
-      if (strcmp (key, "ProcessID") == 0)
-        pid = g_variant_get_uint32 (value);
-      else if (strcmp (key, "LinuxSecurityLabel") == 0)
-        {
-          g_clear_pointer (&security_label, g_free);
-          security_label = g_variant_dup_bytestring (value, NULL);
-        }
-    }
-
-  if (app_info == NULL && security_label != NULL)
-    {
-      app_info = parse_app_info_from_security_label (security_label);
-    }
-
-  if (app_info == NULL)
-    {
-      g_autoptr(GError) local_error = NULL;
-      app_info = parse_app_info_from_flatpak_info (pid, &local_error);
-      if (app_info == NULL && local_error)
-        {
-          g_propagate_error (error, g_steal_pointer (&local_error));
-          return NULL;
-        }
-    }
-
+  app_info = xdp_get_app_info_from_pid (pid, error);
   if (app_info == NULL)
-    app_info = xdp_app_info_new_host ();
+    return NULL;
 
   G_LOCK (app_infos);
   ensure_app_info_by_unique_name ();
@@ -889,6 +884,35 @@ verify_proc_self_fd (XdpAppInfo *app_info,
   return xdp_app_info_remap_path (app_info, path_buffer);
 }
 
+static char *documents_mountpoint = NULL;
+
+void
+xdp_set_documents_mountpoint (const char *path)
+{
+  g_clear_pointer (&documents_mountpoint, g_free);
+  documents_mountpoint = g_strdup (path);
+}
+
+/* alternate_document_path converts a file path  */
+char *
+xdp_get_alternate_document_path (const char *path, const char *app_id)
+{
+  int len;
+
+  /* If we don't know where the document portal is mounted, then there
+   * is no alternate path */
+  if (documents_mountpoint == NULL)
+    return NULL;
+
+  /* If the path is not within the document portal, then there is no
+   * alternative path */
+  len = strlen (documents_mountpoint);
+  if (!g_str_has_prefix (path, documents_mountpoint) || path[len] != '/')
+    return NULL;
+
+  return g_strconcat (documents_mountpoint, "/by-app/", app_id, &path[len], NULL);
+}
+
 char *
 xdp_app_info_get_path_for_fd (XdpAppInfo *app_info,
                               int fd,
@@ -986,8 +1010,22 @@ xdp_app_info_get_path_for_fd (XdpAppInfo *app_info,
       st_buf->st_dev != real_st_buf.st_dev ||
       st_buf->st_ino != real_st_buf.st_ino)
     {
-      /* Different files on the inside and the outside, reject the request */
-      return NULL;
+      /* If the path is provided by the document portal, the inode
+         number will not match, due to only a subtree being mounted in
+         the sandbox.  So we check to see if the equivalent path
+         within that subtree matches our file descriptor.
+
+         If the alternate path doesn't match either, then we treat it
+         as a failure.
+      */
+      g_autofree char *alt_path = NULL;
+      alt_path = xdp_get_alternate_document_path (path, xdp_app_info_get_id (app_info));
+
+      if (alt_path == NULL ||
+          stat (alt_path, &real_st_buf) < 0 ||
+          st_buf->st_dev != real_st_buf.st_dev ||
+          st_buf->st_ino != real_st_buf.st_ino)
+        return NULL;
     }
 
   if (writable_out)
diff --git a/src/xdp-utils.h b/src/xdp-utils.h
index 58a154f..fea28b8 100644
--- a/src/xdp-utils.h
+++ b/src/xdp-utils.h
@@ -21,6 +21,7 @@
 
 #pragma once
 
+#include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
@@ -37,6 +38,11 @@
 #define FLATPAK_METADATA_KEY_RUNTIME_PATH "runtime-path"
 #define FLATPAK_METADATA_KEY_INSTANCE_ID "instance-id"
 
+#define SNAP_METADATA_GROUP_INFO "Snap Info"
+#define SNAP_METADATA_KEY_INSTANCE_NAME "InstanceName"
+#define SNAP_METADATA_KEY_DESKTOP_FILE "DesktopFile"
+#define SNAP_METADATA_KEY_NETWORK "HasNetworkStatus"
+
 gint xdp_mkstempat (int    dir_fd,
                     gchar *tmpl,
                     int    flags,
@@ -48,6 +54,9 @@ typedef void (*XdpPeerDiedCallback) (const char *name);
 
 typedef struct _XdpAppInfo XdpAppInfo;
 
+typedef int XdpFd;
+G_DEFINE_AUTO_CLEANUP_FREE_FUNC(XdpFd, close, -1)
+
 XdpAppInfo *xdp_app_info_ref             (XdpAppInfo  *app_info);
 void        xdp_app_info_unref           (XdpAppInfo  *app_info);
 const char *xdp_app_info_get_id          (XdpAppInfo  *app_info);
@@ -79,6 +88,9 @@ char **     xdp_app_info_rewrite_commandline (XdpAppInfo *app_info,
 
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(XdpAppInfo, xdp_app_info_unref)
 
+void  xdp_set_documents_mountpoint    (const char *path);
+char *xdp_get_alternate_document_path (const char *path, const char *app_id);
+
 XdpAppInfo *xdp_invocation_lookup_app_info_sync (GDBusMethodInvocation *invocation,
                                                  GCancellable          *cancellable,
                                                  GError               **error);
@@ -174,6 +186,11 @@ char * xdp_canonicalize_filename (const char *path);
 gboolean  xdp_has_path_prefix (const char *str,
                                const char *prefix);
 
+/* exposed for the benefit of tests */
+int _xdp_parse_cgroup_file (FILE     *f,
+                            gboolean *is_snap);
+
+
 #if !GLIB_CHECK_VERSION (2, 58, 0)
 static inline gboolean
 g_hash_table_steal_extended (GHashTable    *hash_table,
diff --git a/tests/Makefile.am.inc b/tests/Makefile.am.inc
index 6b0850b..89ae415 100644
--- a/tests/Makefile.am.inc
+++ b/tests/Makefile.am.inc
@@ -19,7 +19,11 @@ test_doc_portal_LDADD = \
 	$(BASE_LIBS) \
 	$(FUSE_LIBS) \
 	$(NULL)
-test_doc_portal_SOURCES = tests/test-doc-portal.c
+test_doc_portal_SOURCES = \
+	tests/can-use-fuse.c \
+	tests/can-use-fuse.h \
+	tests/test-doc-portal.c \
+	$(NULL)
 nodist_test_doc_portal_SOURCES = document-portal/document-portal-dbus.c
 
 EXTRA_test_doc_portal_DEPENDENCIES = tests/services/org.freedesktop.impl.portal.PermissionStore.service tests/services/org.freedesktop.portal.Documents.service
@@ -86,6 +90,12 @@ nodist_test_permission_store_SOURCES = document-portal/permission-store-dbus.c s
 
 EXTRA_test_permission_store_DEPENDENCIES = tests/services/org.freedesktop.impl.portal.PermissionStore.service tests/services/org.freedesktop.portal.Documents.service
 
+test_programs += test-xdp-utils
+test_xdp_utils_CFLAGS = $(AM_CFLAGS) $(BASE_CFLAGS)
+test_xdp_utils_LDADD = $(AM_LD_ADD) $(BASE_LIBS)
+test_xdp_utils_SOURCES = tests/test-xdp-utils.c src/xdp-utils.c
+
+
 tests/services/org.freedesktop.portal.Documents.service: document-portal/org.freedesktop.portal.Documents.service.in
 	mkdir -p tests/services
 	$(AM_V_GEN) $(SED) -e "s|\@libexecdir\@|$(abs_top_builddir)|" $< > $@
diff --git a/tests/can-use-fuse.c b/tests/can-use-fuse.c
new file mode 100644
index 0000000..dfe1bc2
--- /dev/null
+++ b/tests/can-use-fuse.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2019-2021 Collabora Ltd.
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include "config.h"
+
+#include "can-use-fuse.h"
+
+#include <errno.h>
+#include <unistd.h>
+
+#include <glib/gstdio.h>
+
+#define FUSE_USE_VERSION 26
+#include <fuse_lowlevel.h>
+
+gchar *cannot_use_fuse = NULL;
+
+/*
+ * If we cannot use FUSE, set cannot_use_fuse and return %FALSE.
+ */
+gboolean
+check_fuse (void)
+{
+  g_autofree gchar *fusermount = NULL;
+  g_autofree gchar *path = NULL;
+  char *argv[] = { "flatpak-fuse-test" };
+  struct fuse_args args = FUSE_ARGS_INIT (G_N_ELEMENTS (argv), argv);
+  struct fuse_chan *chan = NULL;
+  g_autoptr(GError) error = NULL;
+
+  if (cannot_use_fuse != NULL)
+    return FALSE;
+
+  if (access ("/dev/fuse", W_OK) != 0)
+    {
+      cannot_use_fuse = g_strdup_printf ("access /dev/fuse: %s",
+                                         g_strerror (errno));
+      return FALSE;
+    }
+
+  fusermount = g_find_program_in_path ("fusermount");
+
+  if (fusermount == NULL)
+    {
+      cannot_use_fuse = g_strdup ("fusermount not found in PATH");
+      return FALSE;
+    }
+
+  if (!g_file_test (fusermount, G_FILE_TEST_IS_EXECUTABLE))
+    {
+      cannot_use_fuse = g_strdup_printf ("%s not executable", fusermount);
+      return FALSE;
+    }
+
+  if (!g_file_test ("/etc/mtab", G_FILE_TEST_EXISTS))
+    {
+      cannot_use_fuse = g_strdup ("fusermount won't work without /etc/mtab");
+      return FALSE;
+    }
+
+  path = g_dir_make_tmp ("flatpak-test.XXXXXX", &error);
+  g_assert_no_error (error);
+
+  chan = fuse_mount (path, &args);
+
+  if (chan == NULL)
+    {
+      fuse_opt_free_args (&args);
+      cannot_use_fuse = g_strdup_printf ("fuse_mount: %s",
+                                         g_strerror (errno));
+      return FALSE;
+    }
+
+  g_test_message ("Successfully set up test FUSE fs on %s", path);
+
+  fuse_unmount (path, chan);
+
+  if (g_rmdir (path) != 0)
+    g_error ("rmdir %s: %s", path, g_strerror (errno));
+
+  fuse_opt_free_args (&args);
+
+  return TRUE;
+}
+
+gboolean
+check_fuse_or_skip_test (void)
+{
+  if (!check_fuse ())
+    {
+      g_assert (cannot_use_fuse != NULL);
+      g_test_skip (cannot_use_fuse);
+      return FALSE;
+    }
+
+  return TRUE;
+}
diff --git a/tests/can-use-fuse.h b/tests/can-use-fuse.h
new file mode 100644
index 0000000..bfc47e3
--- /dev/null
+++ b/tests/can-use-fuse.h
@@ -0,0 +1,12 @@
+/*
+ * Copyright 2019-2021 Collabora Ltd.
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#pragma once
+
+#include <glib.h>
+
+extern gchar *cannot_use_fuse;
+gboolean check_fuse (void);
+gboolean check_fuse_or_skip_test (void);
diff --git a/tests/test-doc-portal.c b/tests/test-doc-portal.c
index d1f875d..388cc17 100644
--- a/tests/test-doc-portal.c
+++ b/tests/test-doc-portal.c
@@ -13,11 +13,10 @@
 #include <gio/gunixfdlist.h>
 #include <glib/gstdio.h>
 
-#define FUSE_USE_VERSION 26
-#include <fuse_lowlevel.h>
-
 #include "document-portal/document-portal-dbus.h"
 
+#include "can-use-fuse.h"
+
 char outdir[] = "/tmp/xdp-test-XXXXXX";
 
 char fuse_status_file[] = "/tmp/test-xdp-fuse-XXXXXX";
@@ -26,7 +25,6 @@ GTestDBus *dbus;
 GDBusConnection *session_bus;
 XdpDbusDocuments *documents;
 char *mountpoint;
-static gchar *cannot_use_fuse = NULL;
 
 static gboolean
 set_contents_trunc (const gchar  *filename,
@@ -356,11 +354,8 @@ test_create_doc (void)
   const char *basename = "a-file";
   GError *error = NULL;
 
-  if (cannot_use_fuse != NULL)
-    {
-      g_test_skip (cannot_use_fuse);
-      return;
-    }
+  if (!check_fuse_or_skip_test ())
+    return;
 
   /* Export a document */
   id = export_new_file (basename, "content", FALSE);
@@ -471,11 +466,8 @@ test_recursive_doc (void)
   g_autofree char *path = NULL;
   g_autofree char *app_path = NULL;
 
-  if (cannot_use_fuse != NULL)
-    {
-      g_test_skip (cannot_use_fuse);
-      return;
-    }
+  if (!check_fuse_or_skip_test ())
+    return;
 
   id = export_new_file (basename, "recursive-content", FALSE);
 
@@ -513,11 +505,8 @@ test_create_docs (void)
   const char *basenames[] = { "doc1", "doc2" };
   int i;
 
-  if (cannot_use_fuse != NULL)
-    {
-      g_test_skip (cannot_use_fuse);
-      return;
-    }
+  if (!check_fuse_or_skip_test ())
+    return;
 
   path1 = g_build_filename (outdir, basenames[0], NULL);
   g_file_set_contents (path1, basenames[0], -1, &error);
@@ -585,11 +574,8 @@ test_add_named (void)
   GError *error = NULL;
   gboolean res;
 
-  if (cannot_use_fuse != NULL)
-    {
-      g_test_skip (cannot_use_fuse);
-      return;
-    }
+  if (!check_fuse_or_skip_test ())
+    return;
 
   id1 = export_named_file (outdir, basename1, FALSE);
 
@@ -699,68 +685,6 @@ test_add_named (void)
   assert_doc_not_exist (id1, basename1, "com.test.App2");
 }
 
-/*
- * If we cannot use FUSE, set cannot_use_fuse and return %FALSE.
- */
-static gboolean
-check_fuse (void)
-{
-  g_autofree gchar *fusermount = NULL;
-  g_autofree gchar *path = NULL;
-  char *argv[] = { "xdp-fuse-test" };
-  struct fuse_args args = FUSE_ARGS_INIT (G_N_ELEMENTS (argv), argv);
-  struct fuse_chan *chan = NULL;
-  g_autoptr(GError) error = NULL;
-
-  if (cannot_use_fuse != NULL)
-    return FALSE;
-
-  if (access ("/dev/fuse", W_OK) != 0)
-    {
-      cannot_use_fuse = g_strdup_printf ("access /dev/fuse: %s",
-                                         g_strerror (errno));
-      return FALSE;
-    }
-
-  fusermount = g_find_program_in_path ("fusermount");
-
-  if (fusermount == NULL)
-    {
-      cannot_use_fuse = g_strdup ("fusermount not found in PATH");
-      return FALSE;
-    }
-
-  if (!g_file_test (fusermount, G_FILE_TEST_IS_EXECUTABLE))
-    {
-      cannot_use_fuse = g_strdup_printf ("%s not executable", fusermount);
-      return FALSE;
-    }
-
-  path = g_dir_make_tmp ("xdp-test.XXXXXX", &error);
-  g_assert_no_error (error);
-
-  chan = fuse_mount (path, &args);
-
-  if (chan == NULL)
-    {
-      fuse_opt_free_args (&args);
-      cannot_use_fuse = g_strdup_printf ("fuse_mount: %s",
-                                         g_strerror (errno));
-      return FALSE;
-    }
-
-  g_test_message ("Successfully set up test FUSE fs on %s", path);
-
-  fuse_unmount (path, chan);
-
-  if (g_rmdir (path) != 0)
-    g_error ("rmdir %s: %s", path, g_strerror (errno));
-
-  fuse_opt_free_args (&args);
-
-  return TRUE;
-}
-
 static void
 global_setup (void)
 {
@@ -919,11 +843,8 @@ global_teardown (void)
 static void
 test_version (void)
 {
-  if (cannot_use_fuse != NULL)
-    {
-      g_test_skip (cannot_use_fuse);
-      return;
-    }
+  if (!check_fuse_or_skip_test ())
+    return;
 
   g_assert_cmpint (xdp_dbus_documents_get_version (documents), ==, 4);
 }
diff --git a/tests/test-xdp-utils.c b/tests/test-xdp-utils.c
new file mode 100644
index 0000000..f5e15a3
--- /dev/null
+++ b/tests/test-xdp-utils.c
@@ -0,0 +1,139 @@
+#include "config.h"
+
+#include <glib.h>
+
+#include "src/xdp-utils.h"
+
+static void
+test_parse_cgroup_unified (void)
+{
+  char data[] = "0::/user.slice/user-1000.slice/user at 1000.service/apps.slice/snap.something.scope\n";
+  FILE *f;
+  int res;
+  gboolean is_snap = FALSE;
+
+  f = fmemopen(data, sizeof(data), "r");
+
+  res = _xdp_parse_cgroup_file (f, &is_snap);
+  g_assert_cmpint (res, ==, 0);
+  g_assert_true (is_snap);
+  fclose(f);
+}
+
+static void
+test_parse_cgroup_freezer (void)
+{
+  char data[] =
+    "12:pids:/user.slice/user-1000.slice/user at 1000.service\n"
+    "11:perf_event:/\n"
+    "10:net_cls,net_prio:/\n"
+    "9:cpuset:/\n"
+    "8:memory:/user.slice/user-1000.slice/user at 1000.service/apps.slice/apps-org.gnome.Terminal.slice/vte-spawn-228ae109-a869-4533-8988-65ea4c10b492.scope\n"
+    "7:rdma:/\n"
+    "6:devices:/user.slice\n"
+    "5:blkio:/user.slice\n"
+    "4:hugetlb:/\n"
+    "3:freezer:/snap.portal-test\n"
+    "2:cpu,cpuacct:/user.slice\n"
+    "1:name=systemd:/user.slice/user-1000.slice/user at 1000.service/apps.slice/apps-org.gnome.Terminal.slice/vte-spawn-228ae109-a869-4533-8988-65ea4c10b492.scope\n"
+    "0::/user.slice/user-1000.slice/user at 1000.service/apps.slice/apps-org.gnome.Terminal.slice/vte-spawn-228ae109-a869-4533-8988-65ea4c10b492.scope\n";
+  FILE *f;
+  int res;
+  gboolean is_snap = FALSE;
+
+  f = fmemopen(data, sizeof(data), "r");
+
+  res = _xdp_parse_cgroup_file (f, &is_snap);
+  g_assert_cmpint (res, ==, 0);
+  g_assert_true (is_snap);
+  fclose(f);
+}
+
+static void
+test_parse_cgroup_systemd (void)
+{
+  char data[] = "1:name=systemd:/user.slice/user-1000.slice/user at 1000.service/apps.slice/snap.something.scope\n";
+  FILE *f;
+  int res;
+  gboolean is_snap = FALSE;
+
+  f = fmemopen(data, sizeof(data), "r");
+
+  res = _xdp_parse_cgroup_file (f, &is_snap);
+  g_assert_cmpint (res, ==, 0);
+  g_assert_true (is_snap);
+  fclose(f);
+}
+
+static void
+test_parse_cgroup_not_snap (void)
+{
+  char data[] =
+    "12:pids:/\n"
+    "11:perf_event:/\n"
+    "10:net_cls,net_prio:/\n"
+    "9:cpuset:/\n"
+    "8:memory:/\n"
+    "7:rdma:/\n"
+    "6:devices:/\n"
+    "5:blkio:/\n"
+    "4:hugetlb:/\n"
+    "3:freezer:/\n"
+    "2:cpu,cpuacct:/\n"
+    "1:name=systemd:/\n"
+    "0::/\n";
+
+  FILE *f;
+  int res;
+  gboolean is_snap = FALSE;
+
+  f = fmemopen(data, sizeof(data), "r");
+
+  res = _xdp_parse_cgroup_file (f, &is_snap);
+  g_assert_cmpint (res, ==, 0);
+  g_assert_false (is_snap);
+  fclose(f);
+}
+
+static void
+test_alternate_doc_path (void)
+{
+  g_autofree char *path = NULL;
+
+  xdp_set_documents_mountpoint (NULL);
+
+  /* If no documents mount point is set, there is no alternate path */
+  path = xdp_get_alternate_document_path ("/whatever", "app-id");
+  g_assert_cmpstr (path, ==, NULL);
+
+  xdp_set_documents_mountpoint ("/doc/portal");
+
+  /* Paths outside of the document portal do not have an alternate path */
+  path = xdp_get_alternate_document_path ("/whatever", "app-id");
+  g_assert_cmpstr (path, ==, NULL);
+
+  /* The doc portal mount point itself does not have an alternate path */
+  path = xdp_get_alternate_document_path ("/doc/portal", "app-id");
+  g_assert_cmpstr (path, ==, NULL);
+
+  /* Paths under the doc portal mount point have an alternate path */
+  path = xdp_get_alternate_document_path ("/doc/portal/foo/bar", "app-id");
+  g_assert_cmpstr (path, ==, "/doc/portal/by-app/app-id/foo/bar");
+
+  g_clear_pointer (&path, g_free);
+  path = xdp_get_alternate_document_path ("/doc/portal/foo/bar", "second-app");
+  g_assert_cmpstr (path, ==, "/doc/portal/by-app/second-app/foo/bar");
+
+  xdp_set_documents_mountpoint (NULL);
+}
+
+int main (int argc, char **argv)
+{
+  g_test_init (&argc, &argv, NULL);
+  g_test_add_func ("/parse-cgroup/unified", test_parse_cgroup_unified);
+  g_test_add_func ("/parse-cgroup/freezer", test_parse_cgroup_freezer);
+  g_test_add_func ("/parse-cgroup/systemd", test_parse_cgroup_systemd);
+  g_test_add_func ("/parse-cgroup/not-snap", test_parse_cgroup_not_snap);
+  g_test_add_func ("/alternate-doc-path", test_alternate_doc_path);
+  return g_test_run ();
+}



More information about the Neon-commits mailing list