diff --git a/hardware/virtualization/bubblewrap/pspec.xml b/hardware/virtualization/bubblewrap/pspec.xml
index 1f12c4b468..d1be848eca 100644
--- a/hardware/virtualization/bubblewrap/pspec.xml
+++ b/hardware/virtualization/bubblewrap/pspec.xml
@@ -11,7 +11,7 @@
LGPLv2
Unprivileged sandboxing tool
is a core execution engine for unprivileged containers that works as a setuid binary on kernels without user namespaces.
- https://github.com/projectatomic/bubblewrap/archive/v0.2.0.tar.gz
+ https://github.com/projectatomic/bubblewrap/archive/v0.2.1.tar.gz
libcap-devel
bash-completion
@@ -34,6 +34,13 @@
+
+ 2018-05-29
+ 0.2.1
+ Version bump.
+ Ertuğrul Erata
+ ertugrulerata@gmail.com
+
2018-02-03
0.2.0
diff --git a/hardware/virtualization/flatpak-builder/files/libglnx_submodule.patch b/hardware/virtualization/flatpak-builder/files/libglnx_submodule.patch
index 0cb68a075f..094a7d35ca 100644
--- a/hardware/virtualization/flatpak-builder/files/libglnx_submodule.patch
+++ b/hardware/virtualization/flatpak-builder/files/libglnx_submodule.patch
@@ -1,6 +1,6 @@
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/COPYING flatpak-builder-0.10.6/libglnx/COPYING
---- flatpak-builder-0.10.6.orig/libglnx/COPYING 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/COPYING 2018-02-11 12:03:43.448373307 +0300
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/COPYING flatpak-builder-0.10.10/libglnx/COPYING
+--- flatpak-builder-0.10.10.orig/libglnx/COPYING 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/COPYING 2018-02-11 12:03:43.448373307 +0300
@@ -0,0 +1,502 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
@@ -504,14 +504,14 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/COPYING flatpak-builder-0.10.6/li
+ Ty Coon, President of Vice
+
+That's all there is to it!
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/.git flatpak-builder-0.10.6/libglnx/.git
---- flatpak-builder-0.10.6.orig/libglnx/.git 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/.git 2018-02-11 12:03:43.426373306 +0300
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/.git flatpak-builder-0.10.10/libglnx/.git
+--- flatpak-builder-0.10.10.orig/libglnx/.git 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/.git 2018-02-11 12:03:43.426373306 +0300
@@ -0,0 +1 @@
+gitdir: ../.git/modules/libglnx
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/.gitignore flatpak-builder-0.10.6/libglnx/.gitignore
---- flatpak-builder-0.10.6.orig/libglnx/.gitignore 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/.gitignore 2018-02-11 12:03:43.447373307 +0300
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/.gitignore flatpak-builder-0.10.10/libglnx/.gitignore
+--- flatpak-builder-0.10.10.orig/libglnx/.gitignore 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/.gitignore 2018-02-11 12:03:43.447373307 +0300
@@ -0,0 +1,16 @@
+# A path ostree writes to work around automake bug with
+# subdir-objects
@@ -529,9 +529,9 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/.gitignore flatpak-builder-0.10.6
+*.stamp
+*~
+
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-backport-autocleanups.h flatpak-builder-0.10.6/libglnx/glnx-backport-autocleanups.h
---- flatpak-builder-0.10.6.orig/libglnx/glnx-backport-autocleanups.h 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-backport-autocleanups.h 2018-02-11 12:03:43.448373307 +0300
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-backport-autocleanups.h flatpak-builder-0.10.10/libglnx/glnx-backport-autocleanups.h
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-backport-autocleanups.h 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-backport-autocleanups.h 2018-02-11 12:03:43.448373307 +0300
@@ -0,0 +1,124 @@
+/*
+ * Copyright © 2015 Canonical Limited
@@ -657,9 +657,9 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-backport-autocleanups.h flat
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GString, g_autoptr_cleanup_gstring_free)
+
+#endif
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-backport-autoptr.h flatpak-builder-0.10.6/libglnx/glnx-backport-autoptr.h
---- flatpak-builder-0.10.6.orig/libglnx/glnx-backport-autoptr.h 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-backport-autoptr.h 2018-02-11 12:03:43.448373307 +0300
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-backport-autoptr.h flatpak-builder-0.10.10/libglnx/glnx-backport-autoptr.h
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-backport-autoptr.h 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-backport-autoptr.h 2018-02-11 12:03:43.448373307 +0300
@@ -0,0 +1,133 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
@@ -794,9 +794,9 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-backport-autoptr.h flatpak-b
+#endif /* !GLIB_CHECK_VERSION(2, 43, 3) */
+
+G_END_DECLS
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-backports.c flatpak-builder-0.10.6/libglnx/glnx-backports.c
---- flatpak-builder-0.10.6.orig/libglnx/glnx-backports.c 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-backports.c 2018-02-11 12:03:43.448373307 +0300
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-backports.c flatpak-builder-0.10.10/libglnx/glnx-backports.c
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-backports.c 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-backports.c 2018-02-11 12:03:43.448373307 +0300
@@ -0,0 +1,61 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
@@ -859,9 +859,9 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-backports.c flatpak-builder-
+ return TRUE;
+}
+#endif
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-backports.h flatpak-builder-0.10.6/libglnx/glnx-backports.h
---- flatpak-builder-0.10.6.orig/libglnx/glnx-backports.h 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-backports.h 2018-02-11 12:03:43.448373307 +0300
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-backports.h flatpak-builder-0.10.10/libglnx/glnx-backports.h
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-backports.h 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-backports.h 2018-02-11 12:03:43.448373307 +0300
@@ -0,0 +1,46 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
@@ -909,10 +909,10 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-backports.h flatpak-builder-
+#endif /* !GLIB_CHECK_VERSION(2, 44, 0) */
+
+G_END_DECLS
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-console.c flatpak-builder-0.10.6/libglnx/glnx-console.c
---- flatpak-builder-0.10.6.orig/libglnx/glnx-console.c 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-console.c 2018-02-11 12:03:43.448373307 +0300
-@@ -0,0 +1,309 @@
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-console.c flatpak-builder-0.10.10/libglnx/glnx-console.c
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-console.c 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-console.c 2018-05-26 01:11:39.785067515 +0300
+@@ -0,0 +1,359 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2013,2014,2015 Colin Walters
@@ -944,12 +944,25 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-console.c flatpak-builder-0.
+#include
+#include
+
-+static char *current_text = NULL;
-+static gint current_percent = -1;
-+static gboolean locked;
++/* For people with widescreen monitors and maximized terminals, it looks pretty
++ * bad to have an enormous progress bar. For much the same reason as web pages
++ * tend to have a maximum width;
++ * https://ux.stackexchange.com/questions/48982/suggest-good-max-width-for-fluid-width-design
++ */
++#define MAX_PROGRESSBAR_COLUMNS 20
+
-+static gboolean
-+stdout_is_tty (void)
++/* Max updates output per second. On a tty there's no point to rendering
++ * extremely fast; and for a non-tty we're probably in a Jenkins job
++ * or whatever and having percentages spam multiple lines there is annoying.
++ */
++#define MAX_TTY_UPDATE_HZ (5)
++#define MAX_NONTTY_UPDATE_HZ (1)
++
++static gboolean locked;
++static guint64 last_update_ms; /* monotonic time in millis we last updated */
++
++gboolean
++glnx_stdout_is_tty (void)
+{
+ static gsize initialized = 0;
+ static gboolean stdout_is_tty_v;
@@ -1058,12 +1071,10 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-console.c flatpak-builder-0.
+ g_return_if_fail (!locked);
+ g_return_if_fail (!console->locked);
+
-+ console->is_tty = stdout_is_tty ();
++ console->is_tty = glnx_stdout_is_tty ();
+
+ locked = console->locked = TRUE;
+
-+ current_percent = 0;
-+
+ if (console->is_tty)
+ {
+ if (g_once_init_enter (&sigwinch_initialized))
@@ -1096,6 +1107,26 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-console.c flatpak-builder-0.
+text_percent_internal (const char *text,
+ int percentage)
+{
++ /* Check whether we're trying to render too fast; unless percentage is 100, in
++ * which case we assume this is the last call, so we always render it.
++ */
++ const guint64 current_ms = g_get_monotonic_time () / 1000;
++ if (percentage != 100)
++ {
++ const guint64 diff_ms = current_ms - last_update_ms;
++ if (glnx_stdout_is_tty ())
++ {
++ if (diff_ms < (1000/MAX_TTY_UPDATE_HZ))
++ return;
++ }
++ else
++ {
++ if (diff_ms < (1000/MAX_NONTTY_UPDATE_HZ))
++ return;
++ }
++ }
++ last_update_ms = current_ms;
++
+ static const char equals[] = "====================";
+ const guint n_equals = sizeof (equals) - 1;
+ static const char spaces[] = " ";
@@ -1108,11 +1139,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-console.c flatpak-builder-0.
+
+ const guint input_textlen = text ? strlen (text) : 0;
+
-+ if (percentage == current_percent
-+ && g_strcmp0 (text, current_text) == 0)
-+ return;
-+
-+ if (!stdout_is_tty ())
++ if (!glnx_stdout_is_tty ())
+ {
+ if (text)
+ fprintf (stdout, "%s", text);
@@ -1147,7 +1174,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-console.c flatpak-builder-0.
+ else
+ {
+ const guint textlen = MIN (input_textlen, ncolumns - bar_min);
-+ const guint barlen = ncolumns - (textlen + 1);;
++ const guint barlen = MIN (MAX_PROGRESSBAR_COLUMNS, ncolumns - (textlen + 1));
+
+ if (textlen > 0)
+ {
@@ -1160,7 +1187,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-console.c flatpak-builder-0.
+ const guint textpercent_len = 5;
+ const guint bar_internal_len = barlen - nbraces - textpercent_len;
+ const guint eqlen = bar_internal_len * (percentage / 100.0);
-+ const guint spacelen = bar_internal_len - eqlen;
++ const guint spacelen = bar_internal_len - eqlen;
+
+ fputc ('[', stdout);
+ printpad (equals, n_equals, eqlen);
@@ -1195,6 +1222,32 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-console.c flatpak-builder-0.
+ text_percent_internal (text, percentage);
+}
+
++/**
++ * glnx_console_progress_n_items:
++ * @text: Show this text before the progress bar
++ * @current: An integer for how many items have been processed
++ * @total: An integer for how many items there are total
++ *
++ * On a tty, print to the console @text followed by [@current/@total],
++ * then an ASCII art progress bar, like glnx_console_progress_text_percent().
++ *
++ * You must have called glnx_console_lock() before invoking this
++ * function.
++ */
++void
++glnx_console_progress_n_items (const char *text,
++ guint current,
++ guint total)
++{
++ g_return_if_fail (current <= total);
++ g_return_if_fail (total > 0);
++
++ g_autofree char *newtext = g_strdup_printf ("%s (%u/%u)", text, current, total);
++ /* Special case current == total to ensure we end at 100% */
++ int percentage = (current == total) ? 100 : (((double)current) / total * 100);
++ glnx_console_progress_text_percent (newtext, percentage);
++}
++
+void
+glnx_console_text (const char *text)
+{
@@ -1214,18 +1267,15 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-console.c flatpak-builder-0.
+ g_return_if_fail (locked);
+ g_return_if_fail (console->locked);
+
-+ current_percent = -1;
-+ g_clear_pointer (¤t_text, g_free);
-+
+ if (console->is_tty)
+ fputc ('\n', stdout);
+
+ locked = console->locked = FALSE;
+}
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-console.h flatpak-builder-0.10.6/libglnx/glnx-console.h
---- flatpak-builder-0.10.6.orig/libglnx/glnx-console.h 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-console.h 2018-02-11 12:03:43.448373307 +0300
-@@ -0,0 +1,55 @@
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-console.h flatpak-builder-0.10.10/libglnx/glnx-console.h
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-console.h 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-console.h 2018-05-26 01:11:39.785067515 +0300
+@@ -0,0 +1,61 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2013,2014,2015 Colin Walters
@@ -1259,12 +1309,18 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-console.h flatpak-builder-0.
+
+typedef struct GLnxConsoleRef GLnxConsoleRef;
+
++gboolean glnx_stdout_is_tty (void);
++
+void glnx_console_lock (GLnxConsoleRef *ref);
+
+void glnx_console_text (const char *text);
+
+void glnx_console_progress_text_percent (const char *text,
-+ guint percentage);
++ guint percentage);
++
++void glnx_console_progress_n_items (const char *text,
++ guint current,
++ guint total);
+
+void glnx_console_unlock (GLnxConsoleRef *ref);
+
@@ -1281,10 +1337,10 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-console.h flatpak-builder-0.
+G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GLnxConsoleRef, glnx_console_ref_cleanup)
+
+G_END_DECLS
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-dirfd.c flatpak-builder-0.10.6/libglnx/glnx-dirfd.c
---- flatpak-builder-0.10.6.orig/libglnx/glnx-dirfd.c 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-dirfd.c 2018-02-11 12:03:43.448373307 +0300
-@@ -0,0 +1,390 @@
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-dirfd.c flatpak-builder-0.10.10/libglnx/glnx-dirfd.c
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-dirfd.c 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-dirfd.c 2018-05-26 01:11:39.785067515 +0300
+@@ -0,0 +1,425 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2014,2015 Colin Walters .
@@ -1310,8 +1366,10 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-dirfd.c flatpak-builder-0.10
+#include
+
+#include
++#include
+#include
+#include
++#include
+
+/**
+ * glnx_opendirat_with_errno:
@@ -1384,7 +1442,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-dirfd.c flatpak-builder-0.10
+ GLnxDirFdIterator *out_dfd_iter,
+ GError **error)
+{
-+ glnx_fd_close int fd = -1;
++ glnx_autofd int fd = -1;
+ if (!glnx_opendirat (dfd, path, follow, &fd, error))
+ return FALSE;
+
@@ -1475,23 +1533,20 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-dirfd.c flatpak-builder-0.10
+ GCancellable *cancellable,
+ GError **error)
+{
-+ struct dirent *ret_dent;
-+
+ g_return_val_if_fail (out_dent, FALSE);
+
+ if (!glnx_dirfd_iterator_next_dent (dfd_iter, out_dent, cancellable, error))
+ return FALSE;
+
-+ ret_dent = *out_dent;
-+
++ struct dirent *ret_dent = *out_dent;
+ if (ret_dent)
+ {
+
+ if (ret_dent->d_type == DT_UNKNOWN)
+ {
+ struct stat stbuf;
-+ if (TEMP_FAILURE_RETRY (fstatat (dfd_iter->fd, ret_dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW)) != 0)
-+ return glnx_throw_errno (error);
++ if (!glnx_fstatat (dfd_iter->fd, ret_dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW, error))
++ return FALSE;
+ ret_dent->d_type = IFTODT (stbuf.st_mode);
+ }
+ }
@@ -1550,47 +1605,52 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-dirfd.c flatpak-builder-0.10
+void
+glnx_gen_temp_name (gchar *tmpl)
+{
-+ size_t len;
-+ char *XXXXXX;
-+ int i;
++ g_return_if_fail (tmpl != NULL);
++ const size_t len = strlen (tmpl);
++ g_return_if_fail (len >= 6);
++
+ static const char letters[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+ static const int NLETTERS = sizeof (letters) - 1;
+
-+ g_return_if_fail (tmpl != NULL);
-+ len = strlen (tmpl);
-+ g_return_if_fail (len >= 6);
-+
-+ XXXXXX = tmpl + (len - 6);
-+
-+ for (i = 0; i < 6; i++)
++ char *XXXXXX = tmpl + (len - 6);
++ for (int i = 0; i < 6; i++)
+ XXXXXX[i] = letters[g_random_int_range(0, NLETTERS)];
+}
+
+/**
+ * glnx_mkdtempat:
+ * @dfd: Directory fd
-+ * @tmpl: (type filename): template directory name, last 6 characters will be replaced
-+ * @mode: permissions to create the temporary directory with
++ * @tmpl: (type filename): Initial template directory name, last 6 characters will be replaced
++ * @mode: permissions with which to create the temporary directory
++ * @out_tmpdir: (out caller-allocates): Initialized tempdir structure
+ * @error: Error
+ *
-+ * Similar to g_mkdtemp_full, but using openat.
++ * Somewhat similar to g_mkdtemp_full(), but fd-relative, and returns a
++ * structure that uses autocleanups. Note that the supplied @dfd lifetime
++ * must match or exceed that of @out_tmpdir in order to remove the directory.
+ */
+gboolean
-+glnx_mkdtempat (int dfd,
-+ gchar *tmpl,
-+ int mode,
-+ GError **error)
++glnx_mkdtempat (int dfd, const char *tmpl, int mode,
++ GLnxTmpDir *out_tmpdir, GError **error)
+{
-+ int count;
++ g_return_val_if_fail (tmpl != NULL, FALSE);
++ g_return_val_if_fail (out_tmpdir != NULL, FALSE);
++ g_return_val_if_fail (!out_tmpdir->initialized, FALSE);
+
-+ g_return_val_if_fail (tmpl != NULL, -1);
++ dfd = glnx_dirfd_canonicalize (dfd);
+
-+ for (count = 0; count < 100; count++)
++ g_autofree char *path = g_strdup (tmpl);
++ for (int count = 0; count < 100; count++)
+ {
-+ glnx_gen_temp_name (tmpl);
++ glnx_gen_temp_name (path);
+
-+ if (mkdirat (dfd, tmpl, mode) == -1)
++ /* Ideally we could use openat(O_DIRECTORY | O_CREAT | O_EXCL) here
++ * to create and open the directory atomically, but that’s not supported by
++ * current kernel versions: http://www.openwall.com/lists/oss-security/2014/11/26/14
++ * (Tested on kernel 4.10.10-200.fc25.x86_64). For the moment, accept a
++ * TOCTTOU race here. */
++ if (mkdirat (dfd, path, mode) == -1)
+ {
+ if (errno == EEXIST)
+ continue;
@@ -1601,84 +1661,115 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-dirfd.c flatpak-builder-0.10
+ return glnx_throw_errno_prefix (error, "mkdirat");
+ }
+
++ /* And open it */
++ glnx_autofd int ret_dfd = -1;
++ if (!glnx_opendirat (dfd, path, FALSE, &ret_dfd, error))
++ {
++ /* If we fail to open, let's try to clean up */
++ (void)unlinkat (dfd, path, AT_REMOVEDIR);
++ return FALSE;
++ }
++
++ /* Return the initialized directory struct */
++ out_tmpdir->initialized = TRUE;
++ out_tmpdir->src_dfd = dfd; /* referenced; see above docs */
++ out_tmpdir->fd = glnx_steal_fd (&ret_dfd);
++ out_tmpdir->path = g_steal_pointer (&path);
+ return TRUE;
+ }
+
++ /* Failure */
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_EXISTS,
-+ "mkstempat ran out of combinations to try.");
++ "glnx_mkdtempat ran out of combinations to try");
+ return FALSE;
+}
+
+/**
-+ * glnx_mkdtempat_open:
-+ * @dfd: Directory FD
-+ * @tmpl: (type filename): template directory name, last 6 characters will be replaced
++ * glnx_mkdtemp:
++ * @tmpl: (type filename): Source template directory name, last 6 characters will be replaced
+ * @mode: permissions to create the temporary directory with
-+ * @out_dfd: (out caller-allocates): Return location for an FD for the new
-+ * temporary directory, or `-1` on error
++ * @out_tmpdir: (out caller-allocates): Return location for tmpdir data
+ * @error: Return location for a #GError, or %NULL
+ *
-+ * Similar to glnx_mkdtempat(), except it will open the resulting temporary
-+ * directory and return a directory FD to it.
++ * Similar to glnx_mkdtempat(), but will use g_get_tmp_dir() as the parent
++ * directory to @tmpl.
+ *
+ * Returns: %TRUE on success, %FALSE otherwise
+ * Since: UNRELEASED
+ */
+gboolean
-+glnx_mkdtempat_open (int dfd,
-+ gchar *tmpl,
-+ int mode,
-+ int *out_dfd,
-+ GError **error)
++glnx_mkdtemp (const gchar *tmpl,
++ int mode,
++ GLnxTmpDir *out_tmpdir,
++ GError **error)
+{
-+ /* FIXME: Ideally we could use openat(O_DIRECTORY | O_CREAT | O_EXCL) here
-+ * to create and open the directory atomically, but that’s not supported by
-+ * current kernel versions: http://www.openwall.com/lists/oss-security/2014/11/26/14
-+ * (Tested on kernel 4.10.10-200.fc25.x86_64). For the moment, accept a
-+ * TOCTTOU race here. */
-+ *out_dfd = -1;
++ g_autofree char *path = g_build_filename (g_get_tmp_dir (), tmpl, NULL);
++ return glnx_mkdtempat (AT_FDCWD, path, mode,
++ out_tmpdir, error);
++}
+
-+ if (!glnx_mkdtempat (dfd, tmpl, mode, error))
-+ return FALSE;
-+
-+ return glnx_opendirat (dfd, tmpl, FALSE, out_dfd, error);
++static gboolean
++_glnx_tmpdir_free (GLnxTmpDir *tmpd,
++ gboolean delete_dir,
++ GCancellable *cancellable,
++ GError **error)
++{
++ /* Support being passed NULL so we work nicely in a GPtrArray */
++ if (!(tmpd && tmpd->initialized))
++ return TRUE;
++ g_assert_cmpint (tmpd->fd, !=, -1);
++ glnx_close_fd (&tmpd->fd);
++ g_assert (tmpd->path);
++ g_assert_cmpint (tmpd->src_dfd, !=, -1);
++ g_autofree char *path = tmpd->path; /* Take ownership */
++ tmpd->initialized = FALSE;
++ if (delete_dir)
++ {
++ if (!glnx_shutil_rm_rf_at (tmpd->src_dfd, path, cancellable, error))
++ return FALSE;
++ }
++ return TRUE;
+}
+
+/**
-+ * glnx_mkdtempat_open_in_system:
-+ * @tmpl: (type filename): template directory name, last 6 characters will be replaced
-+ * @mode: permissions to create the temporary directory with
-+ * @out_dfd: (out caller-allocates): Return location for an FD for the new
-+ * temporary directory, or `-1` on error
-+ * @error: Return location for a #GError, or %NULL
++ * glnx_tmpdir_delete:
++ * @tmpf: Temporary dir
++ * @cancellable: Cancellable
++ * @error: Error
+ *
-+ * Similar to glnx_mkdtempat_open(), except it will use the system temporary
-+ * directory (from g_get_tmp_dir()) as the parent directory to @tmpl.
++ * Deallocate a tmpdir, closing the fd and recursively deleting the path. This
++ * is normally called indirectly via glnx_tmpdir_cleanup() by the autocleanup
++ * attribute, but you can also invoke this directly.
+ *
-+ * Returns: %TRUE on success, %FALSE otherwise
-+ * Since: UNRELEASED
++ * If an error occurs while deleting the filesystem path, @tmpf will still have
++ * been deallocated and should not be reused.
++ *
++ * See also `glnx_tmpdir_unset` to avoid deleting the path.
+ */
+gboolean
-+glnx_mkdtempat_open_in_system (gchar *tmpl,
-+ int mode,
-+ int *out_dfd,
-+ GError **error)
++glnx_tmpdir_delete (GLnxTmpDir *tmpf, GCancellable *cancellable, GError **error)
+{
-+ glnx_fd_close int tmp_dfd = -1;
-+
-+ *out_dfd = -1;
-+
-+ if (!glnx_opendirat (-1, g_get_tmp_dir (), TRUE, &tmp_dfd, error))
-+ return FALSE;
-+
-+ return glnx_mkdtempat_open (tmp_dfd, tmpl, mode, out_dfd, error);
++ return _glnx_tmpdir_free (tmpf, TRUE, cancellable, error);
+}
+
-+
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-dirfd.h flatpak-builder-0.10.6/libglnx/glnx-dirfd.h
---- flatpak-builder-0.10.6.orig/libglnx/glnx-dirfd.h 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-dirfd.h 2018-02-11 12:03:43.448373307 +0300
-@@ -0,0 +1,132 @@
++/**
++ * glnx_tmpdir_unset:
++ * @tmpf: Temporary dir
++ * @cancellable: Cancellable
++ * @error: Error
++ *
++ * Deallocate a tmpdir, but do not delete the filesystem path. See also
++ * `glnx_tmpdir_delete()`.
++ */
++void
++glnx_tmpdir_unset (GLnxTmpDir *tmpf)
++{
++ (void) _glnx_tmpdir_free (tmpf, FALSE, NULL, NULL);
++}
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-dirfd.h flatpak-builder-0.10.10/libglnx/glnx-dirfd.h
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-dirfd.h 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-dirfd.h 2018-05-26 01:11:39.785067515 +0300
+@@ -0,0 +1,137 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2014,2015 Colin Walters .
@@ -1773,7 +1864,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-dirfd.h flatpak-builder-0.10
+ * @mode: Mode
+ * @error: Return location for a #GError, or %NULL
+ *
-+ * Wrapper around mkdirat() which ignores adds #GError support, ensures that
++ * Wrapper around mkdirat() which adds #GError support, ensures that
+ * it retries on %EINTR, and also ignores `EEXIST`.
+ *
+ * See also `glnx_shutil_mkdir_p_at()` for recursive handling.
@@ -1794,27 +1885,32 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-dirfd.h flatpak-builder-0.10
+ return TRUE;
+}
+
-+gboolean glnx_mkdtempat (int dfd,
-+ gchar *tmpl,
-+ int mode,
-+ GError **error);
++typedef struct {
++ gboolean initialized;
++ int src_dfd;
++ int fd;
++ char *path;
++} GLnxTmpDir;
++gboolean glnx_tmpdir_delete (GLnxTmpDir *tmpf, GCancellable *cancellable, GError **error);
++void glnx_tmpdir_unset (GLnxTmpDir *tmpf);
++static inline void
++glnx_tmpdir_cleanup (GLnxTmpDir *tmpf)
++{
++ (void)glnx_tmpdir_delete (tmpf, NULL, NULL);
++}
++G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GLnxTmpDir, glnx_tmpdir_cleanup)
+
-+gboolean glnx_mkdtempat_open (int dfd,
-+ gchar *tmpl,
-+ int mode,
-+ int *out_dfd,
-+ GError **error);
++gboolean glnx_mkdtempat (int dfd, const char *tmpl, int mode,
++ GLnxTmpDir *out_tmpdir, GError **error);
+
-+gboolean glnx_mkdtempat_open_in_system (gchar *tmpl,
-+ int mode,
-+ int *out_dfd,
-+ GError **error);
++gboolean glnx_mkdtemp (const char *tmpl, int mode,
++ GLnxTmpDir *out_tmpdir, GError **error);
+
+G_END_DECLS
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-errors.c flatpak-builder-0.10.6/libglnx/glnx-errors.c
---- flatpak-builder-0.10.6.orig/libglnx/glnx-errors.c 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-errors.c 2018-02-11 12:03:43.448373307 +0300
-@@ -0,0 +1,56 @@
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-errors.c flatpak-builder-0.10.10/libglnx/glnx-errors.c
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-errors.c 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-errors.c 2018-05-26 01:11:39.785067515 +0300
+@@ -0,0 +1,131 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2014,2015 Colin Walters .
@@ -1840,6 +1936,32 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-errors.c flatpak-builder-0.1
+#include
+#include
+
++/* Set @error with G_IO_ERROR/G_IO_ERROR_FAILED.
++ *
++ * This function returns %FALSE so it can be used conveniently in a single
++ * statement:
++ *
++ * ```
++ * if (strcmp (foo, "somevalue") != 0)
++ * return glnx_throw (error, "key must be somevalue, not '%s'", foo);
++ * ```
++ */
++gboolean
++glnx_throw (GError **error,
++ const char *fmt,
++ ...)
++{
++ if (error == NULL)
++ return FALSE;
++
++ va_list args;
++ va_start (args, fmt);
++ GError *new = g_error_new_valist (G_IO_ERROR, G_IO_ERROR_FAILED, fmt, args);
++ va_end (args);
++ g_propagate_error (error, g_steal_pointer (&new));
++ return FALSE;
++}
++
+void
+glnx_real_set_prefix_error_va (GError *error,
+ const char *format,
@@ -1856,6 +1978,30 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-errors.c flatpak-builder-0.1
+ error->message = g_string_free (g_steal_pointer (&buf), FALSE);
+}
+
++/* Prepend to @error's message by `$prefix: ` where `$prefix` is computed via
++ * printf @fmt. Returns %FALSE so it can be used conveniently in a single
++ * statement:
++ *
++ * ```
++ * if (!function_that_fails (s, error))
++ * return glnx_throw_prefix (error, "while handling '%s'", s);
++ * ```
++ * */
++gboolean
++glnx_prefix_error (GError **error,
++ const char *fmt,
++ ...)
++{
++ if (error == NULL)
++ return FALSE;
++
++ va_list args;
++ va_start (args, fmt);
++ glnx_real_set_prefix_error_va (*error, fmt, args);
++ va_end (args);
++ return FALSE;
++}
++
+void
+glnx_real_set_prefix_error_from_errno_va (GError **error,
+ gint errsv,
@@ -1871,10 +2017,35 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-errors.c flatpak-builder-0.1
+ g_strerror (errsv));
+ glnx_real_set_prefix_error_va (*error, format, args);
+}
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-errors.h flatpak-builder-0.10.6/libglnx/glnx-errors.h
---- flatpak-builder-0.10.6.orig/libglnx/glnx-errors.h 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-errors.h 2018-02-11 12:03:43.448373307 +0300
-@@ -0,0 +1,197 @@
++
++/* Set @error using the value of `$prefix: g_strerror (errno)` where `$prefix`
++ * is computed via printf @fmt.
++ *
++ * This function returns %FALSE so it can be used conveniently in a single
++ * statement:
++ *
++ * ```
++ * return glnx_throw_errno_prefix (error, "unlinking %s", pathname);
++ * ```
++ */
++gboolean
++glnx_throw_errno_prefix (GError **error,
++ const char *fmt,
++ ...)
++{
++ int errsv = errno;
++ va_list args;
++ va_start (args, fmt);
++ glnx_real_set_prefix_error_from_errno_va (error, errsv, fmt, args);
++ va_end (args);
++ /* See comment in glnx_throw_errno() about preserving errno */
++ errno = errsv;
++ return FALSE;
++}
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-errors.h flatpak-builder-0.10.10/libglnx/glnx-errors.h
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-errors.h 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-errors.h 2018-05-26 01:11:39.785067515 +0300
+@@ -0,0 +1,134 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2014,2015 Colin Walters .
@@ -1902,29 +2073,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-errors.h flatpak-builder-0.1
+
+G_BEGIN_DECLS
+
-+/* Set @error with G_IO_ERROR/G_IO_ERROR_FAILED.
-+ *
-+ * This function returns %FALSE so it can be used conveniently in a single
-+ * statement:
-+ *
-+ * ```
-+ * if (strcmp (foo, "somevalue") != 0)
-+ * return glnx_throw (error, "key must be somevalue, not '%s'", foo);
-+ * ```
-+ */
-+static inline gboolean G_GNUC_PRINTF (2,3)
-+glnx_throw (GError **error, const char *fmt, ...)
-+{
-+ if (error == NULL)
-+ return FALSE;
-+
-+ va_list args;
-+ va_start (args, fmt);
-+ GError *new = g_error_new_valist (G_IO_ERROR, G_IO_ERROR_FAILED, fmt, args);
-+ va_end (args);
-+ g_propagate_error (error, g_steal_pointer (&new));
-+ return FALSE;
-+}
++gboolean glnx_throw (GError **error, const char *fmt, ...) G_GNUC_PRINTF (2,3);
+
+/* Like `glnx_throw ()`, but returns %NULL. */
+#define glnx_null_throw(error, args...) \
@@ -1935,27 +2084,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-errors.h flatpak-builder-0.1
+ const char *format,
+ va_list args) G_GNUC_PRINTF (2,0);
+
-+/* Prepend to @error's message by `$prefix: ` where `$prefix` is computed via
-+ * printf @fmt. Returns %FALSE so it can be used conveniently in a single
-+ * statement:
-+ *
-+ * ```
-+ * if (!function_that_fails (s, error))
-+ * return glnx_throw_prefix (error, "while handling '%s'", s);
-+ * ```
-+ * */
-+static inline gboolean G_GNUC_PRINTF (2,3)
-+glnx_prefix_error (GError **error, const char *fmt, ...)
-+{
-+ if (error == NULL)
-+ return FALSE;
-+
-+ va_list args;
-+ va_start (args, fmt);
-+ glnx_real_set_prefix_error_va (*error, fmt, args);
-+ va_end (args);
-+ return FALSE;
-+}
++gboolean glnx_prefix_error (GError **error, const char *fmt, ...) G_GNUC_PRINTF (2,3);
+
+/* Like `glnx_prefix_error ()`, but returns %NULL. */
+#define glnx_prefix_error_null(error, args...) \
@@ -2032,28 +2161,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-errors.h flatpak-builder-0.1
+ const char *format,
+ va_list args) G_GNUC_PRINTF (3,0);
+
-+/* Set @error using the value of `$prefix: g_strerror (errno)` where `$prefix`
-+ * is computed via printf @fmt.
-+ *
-+ * This function returns %FALSE so it can be used conveniently in a single
-+ * statement:
-+ *
-+ * ```
-+ * return glnx_throw_errno_prefix (error, "unlinking %s", pathname);
-+ * ```
-+ */
-+static inline gboolean G_GNUC_PRINTF (2,3)
-+glnx_throw_errno_prefix (GError **error, const char *fmt, ...)
-+{
-+ int errsv = errno;
-+ va_list args;
-+ va_start (args, fmt);
-+ glnx_real_set_prefix_error_from_errno_va (error, errsv, fmt, args);
-+ va_end (args);
-+ /* See comment above about preserving errno */
-+ errno = errsv;
-+ return FALSE;
-+}
++gboolean glnx_throw_errno_prefix (GError **error, const char *fmt, ...) G_GNUC_PRINTF (2,3);
+
+/* Like glnx_throw_errno_prefix(), but yields a NULL pointer. */
+#define glnx_null_throw_errno_prefix(error, args...) \
@@ -2072,10 +2180,10 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-errors.h flatpak-builder-0.1
+ } while (0);
+
+G_END_DECLS
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.6/libglnx/glnx-fdio.c
---- flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-fdio.c 2018-02-11 12:03:43.449373307 +0300
-@@ -0,0 +1,1111 @@
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.10/libglnx/glnx-fdio.c
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-fdio.c 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-fdio.c 2018-05-26 01:11:39.785067515 +0300
+@@ -0,0 +1,1106 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2014,2015 Colin Walters .
@@ -2190,7 +2298,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.
+ return TRUE;
+ }
+ else
-+ return glnx_throw_errno (error);
++ return glnx_throw_errno_prefix (error, "renameat");
+ }
+ return TRUE;
+}
@@ -2219,7 +2327,14 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.
+#endif
+
+ /* Fallback */
-+ { const char *old_tmp_name = glnx_strjoina (oldpath, ".XXXXXX");
++ { char *old_tmp_name_buf = glnx_strjoina (oldpath, ".XXXXXX");
++ /* This obviously isn't race-free, but doing better gets tricky, since if
++ * we're here the kernel isn't likely to support RENAME_NOREPLACE either.
++ * Anyways, upgrade the kernel. Failing that, avoid use of this function in
++ * shared subdirectories like /tmp.
++ */
++ glnx_gen_temp_name (old_tmp_name_buf);
++ const char *old_tmp_name = old_tmp_name_buf;
+
+ /* Move old out of the way */
+ if (renameat (olddirfd, oldpath, olddirfd, old_tmp_name) < 0)
@@ -2246,9 +2361,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.
+ return;
+ if (!tmpf->initialized)
+ return;
-+ if (tmpf->fd == -1)
-+ return;
-+ (void) close (tmpf->fd);
++ glnx_close_fd (&tmpf->fd);
+ /* If ->path is set, we're likely aborting due to an error. Clean it up */
+ if (tmpf->path)
+ {
@@ -2258,30 +2371,17 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.
+ tmpf->initialized = FALSE;
+}
+
-+/* Allocate a temporary file, using Linux O_TMPFILE if available. The file mode
-+ * will be 0600.
-+ *
-+ * The result will be stored in @out_tmpf, which is caller allocated
-+ * so you can store it on the stack in common scenarios.
-+ *
-+ * The directory fd @dfd must live at least as long as the output @out_tmpf.
-+ */
-+gboolean
-+glnx_open_tmpfile_linkable_at (int dfd,
-+ const char *subpath,
-+ int flags,
-+ GLnxTmpfile *out_tmpf,
-+ GError **error)
++static gboolean
++open_tmpfile_core (int dfd, const char *subpath,
++ int flags,
++ GLnxTmpfile *out_tmpf,
++ GError **error)
+{
++ /* Picked this to match mkstemp() */
+ const guint mode = 0600;
-+ glnx_fd_close int fd = -1;
-+ int count;
+
+ dfd = glnx_dirfd_canonicalize (dfd);
+
-+ /* Don't allow O_EXCL, as that has a special meaning for O_TMPFILE */
-+ g_return_val_if_fail ((flags & O_EXCL) == 0, FALSE);
-+
+ /* Creates a temporary file, that shall be renamed to "target"
+ * later. If possible, this uses O_TMPFILE – in which case
+ * "ret_path" will be returned as NULL. If not possible a the
@@ -2289,33 +2389,35 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.
+ * link_tmpfile() below to rename the result after writing the file
+ * in full. */
+#if defined(O_TMPFILE) && !defined(DISABLE_OTMPFILE) && !defined(ENABLE_WRPSEUDO_COMPAT)
-+ fd = openat (dfd, subpath, O_TMPFILE|flags, mode);
-+ if (fd == -1 && !(G_IN_SET(errno, ENOSYS, EISDIR, EOPNOTSUPP)))
-+ return glnx_throw_errno_prefix (error, "open(O_TMPFILE)");
-+ if (fd != -1)
-+ {
-+ /* Workaround for https://sourceware.org/bugzilla/show_bug.cgi?id=17523
-+ * See also https://github.com/ostreedev/ostree/issues/991
-+ */
-+ if (fchmod (fd, mode) < 0)
-+ return glnx_throw_errno_prefix (error, "fchmod");
-+ out_tmpf->initialized = TRUE;
-+ out_tmpf->src_dfd = dfd; /* Copied; caller must keep open */
-+ out_tmpf->fd = glnx_steal_fd (&fd);
-+ out_tmpf->path = NULL;
-+ return TRUE;
-+ }
++ {
++ glnx_autofd int fd = openat (dfd, subpath, O_TMPFILE|flags, mode);
++ if (fd == -1 && !(G_IN_SET(errno, ENOSYS, EISDIR, EOPNOTSUPP)))
++ return glnx_throw_errno_prefix (error, "open(O_TMPFILE)");
++ if (fd != -1)
++ {
++ /* Workaround for https://sourceware.org/bugzilla/show_bug.cgi?id=17523
++ * See also https://github.com/ostreedev/ostree/issues/991
++ */
++ if (fchmod (fd, mode) < 0)
++ return glnx_throw_errno_prefix (error, "fchmod");
++ out_tmpf->initialized = TRUE;
++ out_tmpf->src_dfd = dfd; /* Copied; caller must keep open */
++ out_tmpf->fd = glnx_steal_fd (&fd);
++ out_tmpf->path = NULL;
++ return TRUE;
++ }
++ }
+ /* Fallthrough */
+#endif
+
++ const guint count_max = 100;
+ { g_autofree char *tmp = g_strconcat (subpath, "/tmp.XXXXXX", NULL);
-+ const guint count_max = 100;
+
-+ for (count = 0; count < count_max; count++)
++ for (int count = 0; count < count_max; count++)
+ {
+ glnx_gen_temp_name (tmp);
+
-+ fd = openat (dfd, tmp, O_CREAT|O_EXCL|O_NOFOLLOW|O_NOCTTY|flags, mode);
++ glnx_autofd int fd = openat (dfd, tmp, O_CREAT|O_EXCL|O_NOFOLLOW|O_NOCTTY|flags, mode);
+ if (fd < 0)
+ {
+ if (errno == EEXIST)
@@ -2334,10 +2436,33 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.
+ }
+ }
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_EXISTS,
-+ "Exhausted %u attempts to create temporary file", count);
++ "Exhausted %u attempts to create temporary file", count_max);
+ return FALSE;
+}
+
++/* Allocate a temporary file, using Linux O_TMPFILE if available. The file mode
++ * will be 0600.
++ *
++ * The result will be stored in @out_tmpf, which is caller allocated
++ * so you can store it on the stack in common scenarios.
++ *
++ * The directory fd @dfd must live at least as long as the output @out_tmpf.
++ */
++gboolean
++glnx_open_tmpfile_linkable_at (int dfd,
++ const char *subpath,
++ int flags,
++ GLnxTmpfile *out_tmpf,
++ GError **error)
++{
++ /* Don't allow O_EXCL, as that has a special meaning for O_TMPFILE;
++ * it's used for glnx_open_anonymous_tmpfile().
++ */
++ g_return_val_if_fail ((flags & O_EXCL) == 0, FALSE);
++
++ return open_tmpfile_core (dfd, subpath, flags, out_tmpf, error);
++}
++
+/* A variant of `glnx_open_tmpfile_linkable_at()` which doesn't support linking.
+ * Useful for true temporary storage. The fd will be allocated in /var/tmp to
+ * ensure maximum storage space.
@@ -2347,7 +2472,8 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.
+ GLnxTmpfile *out_tmpf,
+ GError **error)
+{
-+ if (!glnx_open_tmpfile_linkable_at (AT_FDCWD, "/var/tmp", flags, out_tmpf, error))
++ /* Add in O_EXCL */
++ if (!open_tmpfile_core (AT_FDCWD, "/var/tmp", flags | O_EXCL, out_tmpf, error))
+ return FALSE;
+ if (out_tmpf->path)
+ {
@@ -2420,9 +2546,9 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.
+ char *dnbuf = strdupa (target);
+ const char *dn = dirname (dnbuf);
+ char *tmpname_buf = glnx_strjoina (dn, "/tmp.XXXXXX");
-+ guint count;
-+ const guint count_max = 100;
+
++ const guint count_max = 100;
++ guint count;
+ for (count = 0; count < count_max; count++)
+ {
+ glnx_gen_temp_name (tmpname_buf);
@@ -2506,8 +2632,8 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.
+ const guint maxreadlen = 4096;
+
+ struct stat stbuf;
-+ if (TEMP_FAILURE_RETRY (fstat (fd, &stbuf)) < 0)
-+ return glnx_null_throw_errno (error);
++ if (!glnx_fstat (fd, &stbuf, error))
++ return FALSE;
+
+ gsize buf_allocated;
+ if (S_ISREG (stbuf.st_mode) && stbuf.st_size > 0)
@@ -2633,7 +2759,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.
+{
+ dfd = glnx_dirfd_canonicalize (dfd);
+
-+ glnx_fd_close int fd = -1;
++ glnx_autofd int fd = -1;
+ if (!glnx_openat_rdonly (dfd, subpath, TRUE, &fd, error))
+ return NULL;
+
@@ -2663,19 +2789,15 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.
+ GCancellable *cancellable,
+ GError **error)
+{
-+ size_t l = 100;
-+
+ dfd = glnx_dirfd_canonicalize (dfd);
+
++ size_t l = 100;
+ for (;;)
+ {
-+ g_autofree char *c = NULL;
-+ ssize_t n;
-+
-+ c = g_malloc (l);
-+ n = TEMP_FAILURE_RETRY (readlinkat (dfd, subpath, c, l-1));
++ g_autofree char *c = g_malloc (l);
++ ssize_t n = TEMP_FAILURE_RETRY (readlinkat (dfd, subpath, c, l-1));
+ if (n < 0)
-+ return glnx_null_throw_errno (error);
++ return glnx_null_throw_errno_prefix (error, "readlinkat");
+
+ if ((size_t) n < l-1)
+ {
@@ -2722,7 +2844,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.
+ if (TEMP_FAILURE_RETRY (fchownat (dest_dfd, dest_subpath,
+ src_stbuf->st_uid, src_stbuf->st_gid,
+ AT_SYMLINK_NOFOLLOW)) != 0)
-+ return glnx_throw_errno (error);
++ return glnx_throw_errno_prefix (error, "fchownat");
+
+ return TRUE;
+}
@@ -2743,18 +2865,15 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.
+int
+glnx_loop_write(int fd, const void *buf, size_t nbytes)
+{
-+ const uint8_t *p = buf;
-+
-+ g_return_val_if_fail(fd >= 0, -1);
-+ g_return_val_if_fail(buf, -1);
++ g_return_val_if_fail (fd >= 0, -1);
++ g_return_val_if_fail (buf, -1);
+
+ errno = 0;
+
++ const uint8_t *p = buf;
+ while (nbytes > 0)
+ {
-+ ssize_t k;
-+
-+ k = write(fd, p, nbytes);
++ ssize_t k = write(fd, p, nbytes);
+ if (k < 0)
+ {
+ if (errno == EINTR)
@@ -2930,17 +3049,22 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.
+ * glnx_file_copy_at:
+ * @src_dfd: Source directory fd
+ * @src_subpath: Subpath relative to @src_dfd
++ * @src_stbuf: (allow-none): Optional stat buffer for source; if a stat() has already been done
+ * @dest_dfd: Target directory fd
+ * @dest_subpath: Destination name
+ * @copyflags: Flags
+ * @cancellable: cancellable
+ * @error: Error
+ *
-+ * Perform a full copy of the regular file or
-+ * symbolic link from @src_subpath to @dest_subpath.
++ * Perform a full copy of the regular file or symbolic link from @src_subpath to
++ * @dest_subpath; if @src_subpath is anything other than a regular file or
++ * symbolic link, an error will be returned.
+ *
-+ * If @src_subpath is anything other than a regular
-+ * file or symbolic link, an error will be returned.
++ * If the source is a regular file and the destination exists as a symbolic
++ * link, the symbolic link will not be followed; rather the link itself will be
++ * replaced. Related to this: for regular files, when `GLNX_FILE_COPY_OVERWRITE`
++ * is specified, this function always uses `O_TMPFILE` (if available) and does a
++ * rename-into-place rather than `open(O_TRUNC)`.
+ */
+gboolean
+glnx_file_copy_at (int src_dfd,
@@ -2952,31 +3076,23 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.
+ GCancellable *cancellable,
+ GError **error)
+{
-+ gboolean ret = FALSE;
-+ int r;
-+ int dest_open_flags;
-+ struct timespec ts[2];
-+ glnx_fd_close int src_fd = -1;
-+ glnx_fd_close int dest_fd = -1;
-+ struct stat local_stbuf;
-+
-+ if (g_cancellable_set_error_if_cancelled (cancellable, error))
-+ goto out;
-+
++ /* Canonicalize dfds */
+ src_dfd = glnx_dirfd_canonicalize (src_dfd);
+ dest_dfd = glnx_dirfd_canonicalize (dest_dfd);
+
++ if (g_cancellable_set_error_if_cancelled (cancellable, error))
++ return FALSE;
++
+ /* Automatically do stat() if no stat buffer was supplied */
++ struct stat local_stbuf;
+ if (!src_stbuf)
+ {
-+ if (fstatat (src_dfd, src_subpath, &local_stbuf, AT_SYMLINK_NOFOLLOW) != 0)
-+ {
-+ glnx_set_error_from_errno (error);
-+ goto out;
-+ }
++ if (!glnx_fstatat (src_dfd, src_subpath, &local_stbuf, AT_SYMLINK_NOFOLLOW, error))
++ return FALSE;
+ src_stbuf = &local_stbuf;
+ }
+
++ /* For symlinks, defer entirely to copy_symlink_at() */
+ if (S_ISLNK (src_stbuf->st_mode))
+ {
+ return copy_symlink_at (src_dfd, src_subpath, src_stbuf,
@@ -2988,47 +3104,31 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ "Cannot copy non-regular/non-symlink file: %s", src_subpath);
-+ goto out;
++ return FALSE;
+ }
+
++ /* Regular file path below here */
++
++ glnx_autofd int src_fd = -1;
+ if (!glnx_openat_rdonly (src_dfd, src_subpath, FALSE, &src_fd, error))
-+ goto out;
++ return FALSE;
+
-+ dest_open_flags = O_WRONLY | O_CREAT | O_CLOEXEC | O_NOCTTY;
-+ if (!(copyflags & GLNX_FILE_COPY_OVERWRITE))
-+ dest_open_flags |= O_EXCL;
-+ else
-+ dest_open_flags |= O_TRUNC;
++ /* Open a tmpfile for dest. Particularly for AT_FDCWD calls, we really want to
++ * open in the target directory, otherwise we may not be able to link.
++ */
++ g_auto(GLnxTmpfile) tmp_dest = { 0, };
++ { char *dnbuf = strdupa (dest_subpath);
++ const char *dn = dirname (dnbuf);
++ if (!glnx_open_tmpfile_linkable_at (dest_dfd, dn, O_WRONLY | O_CLOEXEC,
++ &tmp_dest, error))
++ return FALSE;
++ }
+
-+ dest_fd = TEMP_FAILURE_RETRY (openat (dest_dfd, dest_subpath, dest_open_flags, src_stbuf->st_mode));
-+ if (dest_fd == -1)
-+ {
-+ glnx_set_error_from_errno (error);
-+ goto out;
-+ }
++ if (glnx_regfile_copy_bytes (src_fd, tmp_dest.fd, (off_t) -1) < 0)
++ return glnx_throw_errno_prefix (error, "regfile copy");
+
-+ r = glnx_regfile_copy_bytes (src_fd, dest_fd, (off_t) -1);
-+ if (r < 0)
-+ {
-+ glnx_set_error_from_errno (error);
-+ goto out;
-+ }
-+
-+ if (fchown (dest_fd, src_stbuf->st_uid, src_stbuf->st_gid) != 0)
-+ {
-+ glnx_set_error_from_errno (error);
-+ goto out;
-+ }
-+
-+ if (fchmod (dest_fd, src_stbuf->st_mode & 07777) != 0)
-+ {
-+ glnx_set_error_from_errno (error);
-+ goto out;
-+ }
-+
-+ ts[0] = src_stbuf->st_atim;
-+ ts[1] = src_stbuf->st_mtim;
-+ (void) futimens (dest_fd, ts);
++ if (fchown (tmp_dest.fd, src_stbuf->st_uid, src_stbuf->st_gid) != 0)
++ return glnx_throw_errno_prefix (error, "fchown");
+
+ if (!(copyflags & GLNX_FILE_COPY_NOXATTRS))
+ {
@@ -3036,35 +3136,40 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.
+
+ if (!glnx_fd_get_all_xattrs (src_fd, &xattrs,
+ cancellable, error))
-+ goto out;
++ return FALSE;
+
-+ if (!glnx_fd_set_all_xattrs (dest_fd, xattrs,
++ if (!glnx_fd_set_all_xattrs (tmp_dest.fd, xattrs,
+ cancellable, error))
-+ goto out;
++ return FALSE;
+ }
+
++ /* Always chmod after setting xattrs, in case the file has mode 0400 or less,
++ * like /etc/shadow. Linux currently allows write() on non-writable open files
++ * but not fsetxattr().
++ */
++ if (fchmod (tmp_dest.fd, src_stbuf->st_mode & 07777) != 0)
++ return glnx_throw_errno_prefix (error, "fchmod");
++
++ struct timespec ts[2];
++ ts[0] = src_stbuf->st_atim;
++ ts[1] = src_stbuf->st_mtim;
++ (void) futimens (tmp_dest.fd, ts);
++
+ if (copyflags & GLNX_FILE_COPY_DATASYNC)
+ {
-+ if (fdatasync (dest_fd) < 0)
-+ {
-+ glnx_set_error_from_errno (error);
-+ goto out;
-+ }
-+ }
-+
-+ r = close (dest_fd);
-+ dest_fd = -1;
-+ if (r < 0)
-+ {
-+ glnx_set_error_from_errno (error);
-+ goto out;
++ if (fdatasync (tmp_dest.fd) < 0)
++ return glnx_throw_errno_prefix (error, "fdatasync");
+ }
+
-+ ret = TRUE;
-+ out:
-+ if (!ret)
-+ (void) unlinkat (dest_dfd, dest_subpath, 0);
-+ return ret;
++ const GLnxLinkTmpfileReplaceMode replacemode =
++ (copyflags & GLNX_FILE_COPY_OVERWRITE) ?
++ GLNX_LINK_TMPFILE_REPLACE :
++ GLNX_LINK_TMPFILE_NOREPLACE;
++
++ if (!glnx_link_tmpfile_at (&tmp_dest, replacemode, dest_dfd, dest_subpath, error))
++ return FALSE;
++
++ return TRUE;
+}
+
+/**
@@ -3149,19 +3254,17 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.
+ return FALSE;
+
+ if (glnx_loop_write (tmpf.fd, buf, len) < 0)
-+ return glnx_throw_errno (error);
++ return glnx_throw_errno_prefix (error, "write");
+
+ if (!(flags & GLNX_FILE_REPLACE_NODATASYNC))
+ {
+ struct stat stbuf;
+ gboolean do_sync;
+
-+ if (fstatat (dfd, subpath, &stbuf, AT_SYMLINK_NOFOLLOW) != 0)
-+ {
-+ if (errno != ENOENT)
-+ return glnx_throw_errno (error);
-+ do_sync = (flags & GLNX_FILE_REPLACE_DATASYNC_NEW) > 0;
-+ }
++ if (!glnx_fstatat_allow_noent (dfd, subpath, &stbuf, AT_SYMLINK_NOFOLLOW, error))
++ return FALSE;
++ if (errno == ENOENT)
++ do_sync = (flags & GLNX_FILE_REPLACE_DATASYNC_NEW) > 0;
+ else
+ do_sync = TRUE;
+
@@ -3175,11 +3278,11 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.
+ if (uid != (uid_t) -1)
+ {
+ if (fchown (tmpf.fd, uid, gid) != 0)
-+ return glnx_throw_errno (error);
++ return glnx_throw_errno_prefix (error, "fchown");
+ }
+
+ if (fchmod (tmpf.fd, mode) != 0)
-+ return glnx_throw_errno (error);
++ return glnx_throw_errno_prefix (error, "fchmod");
+
+ if (!glnx_link_tmpfile_at (&tmpf, GLNX_LINK_TMPFILE_REPLACE,
+ dfd, subpath, error))
@@ -3187,10 +3290,10 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.c flatpak-builder-0.10.
+
+ return TRUE;
+}
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.h flatpak-builder-0.10.6/libglnx/glnx-fdio.h
---- flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.h 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-fdio.h 2018-02-11 12:03:43.449373307 +0300
-@@ -0,0 +1,333 @@
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-fdio.h flatpak-builder-0.10.10/libglnx/glnx-fdio.h
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-fdio.h 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-fdio.h 2018-05-26 01:11:39.785067515 +0300
+@@ -0,0 +1,369 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2014,2015 Colin Walters .
@@ -3222,12 +3325,8 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.h flatpak-builder-0.10.
+#include
+#include
+#include
-+/* From systemd/src/shared/util.h */
-+/* When we include libgen.h because we need dirname() we immediately
-+ * undefine basename() since libgen.h defines it as a macro to the XDG
-+ * version which is really broken. */
++// For dirname(), and previously basename()
+#include
-+#undef basename
+
+#include
+#include
@@ -3240,7 +3339,12 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.h flatpak-builder-0.10.
+static inline
+const char *glnx_basename (const char *path)
+{
-+ return (basename) (path);
++ gchar *base = strrchr (path, G_DIR_SEPARATOR);
++
++ if (base)
++ return base + 1;
++
++ return path;
+}
+
+/* Utilities for standard FILE* */
@@ -3489,6 +3593,41 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.h flatpak-builder-0.10.
+}
+
+/**
++ * glnx_fstatat_allow_noent:
++ * @dfd: Directory FD to stat beneath
++ * @path: Path to stat beneath @dfd
++ * @buf: (out caller-allocates) (allow-none): Return location for stat details
++ * @flags: Flags to pass to fstatat()
++ * @error: Return location for a #GError, or %NULL
++ *
++ * Like glnx_fstatat(), but handles `ENOENT` in a non-error way. Instead,
++ * on success `errno` will be zero, otherwise it will be preserved. Hence
++ * you can test `if (errno == 0)` to conditionalize on the file existing,
++ * or `if (errno == ENOENT)` for non-existence.
++ *
++ * Returns: %TRUE on success, %FALSE otherwise (errno is preserved)
++ * Since: UNRELEASED
++ */
++static inline gboolean
++glnx_fstatat_allow_noent (int dfd,
++ const char *path,
++ struct stat *out_buf,
++ int flags,
++ GError **error)
++{
++ G_GNUC_UNUSED struct stat unused_stbuf;
++ if (TEMP_FAILURE_RETRY (fstatat (dfd, path, out_buf ? out_buf : &unused_stbuf, flags)) != 0)
++ {
++ if (errno != ENOENT)
++ return glnx_throw_errno_prefix (error, "fstatat(%s)", path);
++ /* Note we preserve errno as ENOENT */
++ }
++ else
++ errno = 0;
++ return TRUE;
++}
++
++/**
+ * glnx_renameat:
+ *
+ * Wrapper around renameat() which adds #GError support and ensures that it
@@ -3524,9 +3663,9 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-fdio.h flatpak-builder-0.10.
+}
+
+G_END_DECLS
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-local-alloc.c flatpak-builder-0.10.6/libglnx/glnx-local-alloc.c
---- flatpak-builder-0.10.6.orig/libglnx/glnx-local-alloc.c 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-local-alloc.c 2018-02-11 12:03:43.449373307 +0300
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-local-alloc.c flatpak-builder-0.10.10/libglnx/glnx-local-alloc.c
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-local-alloc.c 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-local-alloc.c 2018-02-11 12:03:43.449373307 +0300
@@ -0,0 +1,72 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
@@ -3600,10 +3739,10 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-local-alloc.c flatpak-builde
+ *
+ *
+ */
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-local-alloc.h flatpak-builder-0.10.6/libglnx/glnx-local-alloc.h
---- flatpak-builder-0.10.6.orig/libglnx/glnx-local-alloc.h 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-local-alloc.h 2018-02-11 12:03:43.449373307 +0300
-@@ -0,0 +1,77 @@
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-local-alloc.h flatpak-builder-0.10.10/libglnx/glnx-local-alloc.h
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-local-alloc.h 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-local-alloc.h 2018-05-26 01:11:39.785067515 +0300
+@@ -0,0 +1,91 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2012,2015 Colin Walters .
@@ -3648,14 +3787,30 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-local-alloc.h flatpak-builde
+}
+#define glnx_unref_object __attribute__ ((cleanup(glnx_local_obj_unref)))
+
-+static inline void
-+glnx_cleanup_close_fdp (int *fdp)
++static inline int
++glnx_steal_fd (int *fdp)
+{
-+ int fd, errsv;
++ int fd = *fdp;
++ *fdp = -1;
++ return fd;
++}
++
++/**
++ * glnx_close_fd:
++ * @fdp: Pointer to fd
++ *
++ * Effectively `close (glnx_steal_fd (&fd))`. Also
++ * asserts that `close()` did not raise `EBADF` - encountering
++ * that error is usually a critical bug in the program.
++ */
++static inline void
++glnx_close_fd (int *fdp)
++{
++ int errsv;
+
+ g_assert (fdp);
+
-+ fd = *fdp;
++ int fd = glnx_steal_fd (fdp);
+ if (fd >= 0)
+ {
+ errsv = errno;
@@ -3668,23 +3823,21 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-local-alloc.h flatpak-builde
+/**
+ * glnx_fd_close:
+ *
++ * Deprecated in favor of `glnx_autofd`.
++ */
++#define glnx_fd_close __attribute__((cleanup(glnx_close_fd)))
++/**
++ * glnx_autofd:
++ *
+ * Call close() on a variable location when it goes out of scope.
+ */
-+#define glnx_fd_close __attribute__((cleanup(glnx_cleanup_close_fdp)))
-+
-+static inline int
-+glnx_steal_fd (int *fdp)
-+{
-+ int fd = *fdp;
-+ *fdp = -1;
-+ return fd;
-+}
++#define glnx_autofd __attribute__((cleanup(glnx_close_fd)))
+
+G_END_DECLS
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-lockfile.c flatpak-builder-0.10.6/libglnx/glnx-lockfile.c
---- flatpak-builder-0.10.6.orig/libglnx/glnx-lockfile.c 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-lockfile.c 2018-02-11 12:03:43.449373307 +0300
-@@ -0,0 +1,185 @@
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-lockfile.c flatpak-builder-0.10.10/libglnx/glnx-lockfile.c
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-lockfile.c 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-lockfile.c 2018-05-26 01:11:39.786067515 +0300
+@@ -0,0 +1,179 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
@@ -3748,7 +3901,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-lockfile.c flatpak-builder-0
+ */
+gboolean
+glnx_make_lock_file(int dfd, const char *p, int operation, GLnxLockFile *out_lock, GError **error) {
-+ glnx_fd_close int fd = -1;
++ glnx_autofd int fd = -1;
+ g_autofree char *t = NULL;
+ int r;
+
@@ -3792,7 +3945,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-lockfile.c flatpak-builder-0
+ r = flock(fd, operation);
+
+ if (r < 0)
-+ return glnx_throw_errno(error);
++ return glnx_throw_errno_prefix (error, "flock");
+ }
+
+ /* If we acquired the lock, let's check if the file
@@ -3801,34 +3954,29 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-lockfile.c flatpak-builder-0
+ * it. In such a case our acquired lock is worthless,
+ * hence try again. */
+
-+ r = fstat(fd, &st);
-+ if (r < 0)
-+ return glnx_throw_errno(error);
++ if (!glnx_fstat (fd, &st, error))
++ return FALSE;
+ if (st.st_nlink > 0)
+ break;
+
-+ (void) close(fd);
-+ fd = -1;
++ glnx_close_fd (&fd);
+ }
+
+ /* Note that if this is not AT_FDCWD, the caller takes responsibility
+ * for the fd's lifetime being >= that of the lock.
+ */
++ out_lock->initialized = TRUE;
+ out_lock->dfd = dfd;
-+ out_lock->path = t;
-+ out_lock->fd = fd;
++ out_lock->path = g_steal_pointer (&t);
++ out_lock->fd = glnx_steal_fd (&fd);
+ out_lock->operation = operation;
-+
-+ fd = -1;
-+ t = NULL;
-+
+ return TRUE;
+}
+
+void glnx_release_lock_file(GLnxLockFile *f) {
+ int r;
+
-+ if (!f)
++ if (!(f && f->initialized))
+ return;
+
+ if (f->path) {
@@ -3865,15 +4013,14 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-lockfile.c flatpak-builder-0
+ f->path = NULL;
+ }
+
-+ if (f->fd != -1)
-+ (void) close (f->fd);
-+ f->fd = -1;
++ glnx_close_fd (&f->fd);
+ f->operation = 0;
++ f->initialized = FALSE;
+}
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-lockfile.h flatpak-builder-0.10.6/libglnx/glnx-lockfile.h
---- flatpak-builder-0.10.6.orig/libglnx/glnx-lockfile.h 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-lockfile.h 2018-02-11 12:03:43.449373307 +0300
-@@ -0,0 +1,41 @@
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-lockfile.h flatpak-builder-0.10.10/libglnx/glnx-lockfile.h
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-lockfile.h 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-lockfile.h 2018-05-26 01:11:39.786067515 +0300
+@@ -0,0 +1,40 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+#pragma once
@@ -3903,6 +4050,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-lockfile.h flatpak-builder-0
+#include "glnx-backport-autoptr.h"
+
+typedef struct GLnxLockFile {
++ gboolean initialized;
+ int dfd;
+ char *path;
+ int fd;
@@ -3913,11 +4061,9 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-lockfile.h flatpak-builder-0
+void glnx_release_lock_file(GLnxLockFile *f);
+
+G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GLnxLockFile, glnx_release_lock_file)
-+
-+#define GLNX_LOCK_FILE_INIT { .fd = -1, .dfd = AT_FDCWD, .path = NULL }
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-macros.h flatpak-builder-0.10.6/libglnx/glnx-macros.h
---- flatpak-builder-0.10.6.orig/libglnx/glnx-macros.h 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-macros.h 2018-02-11 12:03:43.449373307 +0300
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-macros.h flatpak-builder-0.10.10/libglnx/glnx-macros.h
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-macros.h 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-macros.h 2018-05-26 01:11:39.786067515 +0300
@@ -0,0 +1,189 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
@@ -3959,7 +4105,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-macros.h flatpak-builder-0.1
+ ({ \
+ const char *_appendees_[] = { a, __VA_ARGS__ }; \
+ char *_d_, *_p_; \
-+ int _len_ = 0; \
++ size_t _len_ = 0; \
+ unsigned _i_; \
+ for (_i_ = 0; _i_ < G_N_ELEMENTS(_appendees_) && _appendees_[_i_]; _i_++) \
+ _len_ += strlen(_appendees_[_i_]); \
@@ -4108,10 +4254,10 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-macros.h flatpak-builder-0.1
+#endif /* GI_SCANNER */
+
+G_END_DECLS
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-missing.h flatpak-builder-0.10.6/libglnx/glnx-missing.h
---- flatpak-builder-0.10.6.orig/libglnx/glnx-missing.h 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-missing.h 2018-02-11 12:03:43.449373307 +0300
-@@ -0,0 +1,55 @@
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-missing.h flatpak-builder-0.10.10/libglnx/glnx-missing.h
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-missing.h 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-missing.h 2018-05-26 01:11:39.786067515 +0300
+@@ -0,0 +1,95 @@
+#pragma once
+
+/***
@@ -4133,7 +4279,17 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-missing.h flatpak-builder-0.
+ along with systemd; If not, see .
+***/
+
-+/* Missing glibc definitions to access certain kernel APIs */
++/* Missing glibc definitions to access certain kernel APIs.
++ This file is last updated from systemd git:
++
++ commit 71e5200f94b22589922704aa4abdf95d4fe2e528
++ Author: Daniel Mack
++ AuthorDate: Tue Oct 18 17:57:10 2016 +0200
++ Commit: Lennart Poettering
++ CommitDate: Fri Sep 22 15:24:54 2017 +0200
++
++ Add abstraction model for BPF programs
++*/
+
+#include
+#include
@@ -4143,22 +4299,30 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-missing.h flatpak-builder-0.
+#include
+#include
+
-+#if defined(__i386__) || defined(__x86_64__)
-+
-+/* The precise definition of __O_TMPFILE is arch specific, so let's
-+ * just define this on x86 where we know the value. */
++/* The precise definition of __O_TMPFILE is arch specific; use the
++ * values defined by the kernel (note: some are hexa, some are octal,
++ * duplicated as-is from the kernel definitions):
++ * - alpha, parisc, sparc: each has a specific value;
++ * - others: they use the "generic" value.
++ */
+
+#ifndef __O_TMPFILE
++#if defined(__alpha__)
++#define __O_TMPFILE 0100000000
++#elif defined(__parisc__) || defined(__hppa__)
++#define __O_TMPFILE 0400000000
++#elif defined(__sparc__) || defined(__sparc64__)
++#define __O_TMPFILE 0x2000000
++#else
+#define __O_TMPFILE 020000000
+#endif
++#endif
+
+/* a horrid kludge trying to make sure that this will fail on old kernels */
+#ifndef O_TMPFILE
+#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
+#endif
+
-+#endif
-+
+#ifndef RENAME_NOREPLACE
+#define RENAME_NOREPLACE (1 << 0)
+#endif
@@ -4166,11 +4330,33 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-missing.h flatpak-builder-0.
+#define RENAME_EXCHANGE (1 << 1)
+#endif
+
++#ifndef F_LINUX_SPECIFIC_BASE
++#define F_LINUX_SPECIFIC_BASE 1024
++#endif
++
++#ifndef F_ADD_SEALS
++#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
++#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
++
++#define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */
++#define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */
++#define F_SEAL_GROW 0x0004 /* prevent file from growing */
++#define F_SEAL_WRITE 0x0008 /* prevent writes */
++#endif
++
++#ifndef MFD_ALLOW_SEALING
++#define MFD_ALLOW_SEALING 0x0002U
++#endif
++
++#ifndef MFD_CLOEXEC
++#define MFD_CLOEXEC 0x0001U
++#endif
++
+#include "glnx-missing-syscall.h"
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-missing-syscall.h flatpak-builder-0.10.6/libglnx/glnx-missing-syscall.h
---- flatpak-builder-0.10.6.orig/libglnx/glnx-missing-syscall.h 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-missing-syscall.h 2018-02-11 12:03:43.449373307 +0300
-@@ -0,0 +1,95 @@
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-missing-syscall.h flatpak-builder-0.10.10/libglnx/glnx-missing-syscall.h
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-missing-syscall.h 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-missing-syscall.h 2018-05-26 01:11:39.786067515 +0300
+@@ -0,0 +1,154 @@
+/***
+ This file was originally part of systemd.
+
@@ -4191,7 +4377,19 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-missing-syscall.h flatpak-bu
+ along with systemd; If not, see .
+***/
+
-+/* Missing glibc definitions to access certain kernel APIs */
++/* Missing glibc definitions to access certain kernel APIs.
++ This file is last updated from systemd git:
++
++ commit 71e5200f94b22589922704aa4abdf95d4fe2e528
++ Author: Daniel Mack
++ AuthorDate: Tue Oct 18 17:57:10 2016 +0200
++ Commit: Lennart Poettering
++ CommitDate: Fri Sep 22 15:24:54 2017 +0200
++
++ Add abstraction model for BPF programs
++*/
++
++#include "config.h"
+
+#if !HAVE_DECL_RENAMEAT2
+# ifndef __NR_renameat2
@@ -4199,6 +4397,8 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-missing-syscall.h flatpak-bu
+# define __NR_renameat2 316
+# elif defined __arm__
+# define __NR_renameat2 382
++# elif defined __aarch64__
++# define __NR_renameat2 276
+# elif defined _MIPS_SIM
+# if _MIPS_SIM == _MIPS_SIM_ABI32
+# define __NR_renameat2 4351
@@ -4211,6 +4411,12 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-missing-syscall.h flatpak-bu
+# endif
+# elif defined __i386__
+# define __NR_renameat2 353
++# elif defined __powerpc64__
++# define __NR_renameat2 357
++# elif defined __s390__ || defined __s390x__
++# define __NR_renameat2 347
++# elif defined __arc__
++# define __NR_renameat2 276
+# else
+# warning "__NR_renameat2 unknown for your architecture"
+# endif
@@ -4226,6 +4432,45 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-missing-syscall.h flatpak-bu
+}
+#endif
+
++#if !HAVE_DECL_MEMFD_CREATE
++# ifndef __NR_memfd_create
++# if defined __x86_64__
++# define __NR_memfd_create 319
++# elif defined __arm__
++# define __NR_memfd_create 385
++# elif defined __aarch64__
++# define __NR_memfd_create 279
++# elif defined __s390__
++# define __NR_memfd_create 350
++# elif defined _MIPS_SIM
++# if _MIPS_SIM == _MIPS_SIM_ABI32
++# define __NR_memfd_create 4354
++# endif
++# if _MIPS_SIM == _MIPS_SIM_NABI32
++# define __NR_memfd_create 6318
++# endif
++# if _MIPS_SIM == _MIPS_SIM_ABI64
++# define __NR_memfd_create 5314
++# endif
++# elif defined __i386__
++# define __NR_memfd_create 356
++# elif defined __arc__
++# define __NR_memfd_create 279
++# else
++# warning "__NR_memfd_create unknown for your architecture"
++# endif
++# endif
++
++static inline int memfd_create(const char *name, unsigned int flags) {
++# ifdef __NR_memfd_create
++ return syscall(__NR_memfd_create, name, flags);
++# else
++ errno = ENOSYS;
++ return -1;
++# endif
++}
++#endif
++
+/* Copied from systemd git:
+ commit 6bda23dd6aaba50cf8e3e6024248cf736cc443ca
+ Author: Yu Watanabe
@@ -4266,10 +4511,10 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-missing-syscall.h flatpak-bu
+# endif
+}
+#endif
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-shutil.c flatpak-builder-0.10.6/libglnx/glnx-shutil.c
---- flatpak-builder-0.10.6.orig/libglnx/glnx-shutil.c 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-shutil.c 2018-02-11 12:03:43.449373307 +0300
-@@ -0,0 +1,252 @@
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-shutil.c flatpak-builder-0.10.10/libglnx/glnx-shutil.c
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-shutil.c 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-shutil.c 2018-05-26 01:11:39.786067515 +0300
+@@ -0,0 +1,260 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2014,2015 Colin Walters .
@@ -4356,14 +4601,12 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-shutil.c flatpak-builder-0.1
+ GCancellable *cancellable,
+ GError **error)
+{
-+ glnx_fd_close int target_dfd = -1;
-+ g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
-+
+ dfd = glnx_dirfd_canonicalize (dfd);
+
++
+ /* With O_NOFOLLOW first */
-+ target_dfd = openat (dfd, path,
-+ O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW);
++ glnx_autofd int target_dfd =
++ openat (dfd, path, O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW);
+
+ if (target_dfd == -1)
+ {
@@ -4382,6 +4625,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-shutil.c flatpak-builder-0.1
+ }
+ else
+ {
++ g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
+ if (!glnx_dirfd_iterator_init_take_fd (&target_dfd, &dfd_iter, error))
+ return FALSE;
+
@@ -4420,7 +4664,13 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-shutil.c flatpak-builder-0.1
+ g_assert (!did_recurse);
+
+ lastslash = strrchr (path, '/');
-+ g_assert (lastslash != NULL);
++ if (lastslash == NULL)
++ {
++ /* This can happen if @dfd was deleted between being opened and
++ * passed to mkdir_p_at_internal(). */
++ return glnx_throw_errno_prefix (error, "mkdir(%s)", path);
++ }
++
+ /* Note we can mutate the buffer as we dup'd it */
+ *lastslash = '\0';
+
@@ -4459,6 +4709,9 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-shutil.c flatpak-builder-0.1
+ * directory fd @dfd.
+ *
+ * See also glnx_ensure_dir() for a non-recursive version.
++ *
++ * This will return %G_IO_ERROR_NOT_FOUND if @dfd has been deleted since being
++ * opened. It may return other errors from mkdirat() in other situations.
+ */
+gboolean
+glnx_shutil_mkdir_p_at (int dfd,
@@ -4522,9 +4775,9 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-shutil.c flatpak-builder-0.1
+
+ return glnx_opendirat (dfd, path, TRUE, out_dfd, error);
+}
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-shutil.h flatpak-builder-0.10.6/libglnx/glnx-shutil.h
---- flatpak-builder-0.10.6.orig/libglnx/glnx-shutil.h 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-shutil.h 2018-02-11 12:03:43.449373307 +0300
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-shutil.h flatpak-builder-0.10.10/libglnx/glnx-shutil.h
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-shutil.h 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-shutil.h 2018-02-11 12:03:43.449373307 +0300
@@ -0,0 +1,48 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
@@ -4574,9 +4827,9 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-shutil.h flatpak-builder-0.1
+ GError **error);
+
+G_END_DECLS
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-xattrs.c flatpak-builder-0.10.6/libglnx/glnx-xattrs.c
---- flatpak-builder-0.10.6.orig/libglnx/glnx-xattrs.c 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-xattrs.c 2018-02-11 12:03:43.449373307 +0300
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-xattrs.c flatpak-builder-0.10.10/libglnx/glnx-xattrs.c
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-xattrs.c 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-xattrs.c 2018-02-11 12:03:43.449373307 +0300
@@ -0,0 +1,444 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
@@ -5022,9 +5275,9 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-xattrs.c flatpak-builder-0.1
+ return TRUE;
+}
+
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-xattrs.h flatpak-builder-0.10.6/libglnx/glnx-xattrs.h
---- flatpak-builder-0.10.6.orig/libglnx/glnx-xattrs.h 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/glnx-xattrs.h 2018-02-11 12:03:43.449373307 +0300
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/glnx-xattrs.h flatpak-builder-0.10.10/libglnx/glnx-xattrs.h
+--- flatpak-builder-0.10.10.orig/libglnx/glnx-xattrs.h 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/glnx-xattrs.h 2018-02-11 12:03:43.449373307 +0300
@@ -0,0 +1,78 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
@@ -5104,9 +5357,9 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/glnx-xattrs.h flatpak-builder-0.1
+ GError **error);
+
+G_END_DECLS
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/libglnx.doap flatpak-builder-0.10.6/libglnx/libglnx.doap
---- flatpak-builder-0.10.6.orig/libglnx/libglnx.doap 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/libglnx.doap 2018-02-11 12:03:43.449373307 +0300
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/libglnx.doap flatpak-builder-0.10.10/libglnx/libglnx.doap
+--- flatpak-builder-0.10.10.orig/libglnx/libglnx.doap 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/libglnx.doap 2018-02-11 12:03:43.449373307 +0300
@@ -0,0 +1,31 @@
+
+
+
+
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/libglnx.h flatpak-builder-0.10.6/libglnx/libglnx.h
---- flatpak-builder-0.10.6.orig/libglnx/libglnx.h 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/libglnx.h 2018-02-11 12:03:43.449373307 +0300
-@@ -0,0 +1,39 @@
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/libglnx.h flatpak-builder-0.10.10/libglnx/libglnx.h
+--- flatpak-builder-0.10.10.orig/libglnx/libglnx.h 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/libglnx.h 2018-05-26 01:11:39.786067515 +0300
+@@ -0,0 +1,40 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2012,2013,2015 Colin Walters .
@@ -5170,6 +5423,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/libglnx.h flatpak-builder-0.10.6/
+G_BEGIN_DECLS
+
+#include
++#include
+#include
+#include
+#include
@@ -5182,15 +5436,16 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/libglnx.h flatpak-builder-0.10.6/
+#include
+
+G_END_DECLS
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/libglnx.m4 flatpak-builder-0.10.6/libglnx/libglnx.m4
---- flatpak-builder-0.10.6.orig/libglnx/libglnx.m4 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/libglnx.m4 2018-02-11 12:03:43.449373307 +0300
-@@ -0,0 +1,31 @@
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/libglnx.m4 flatpak-builder-0.10.10/libglnx/libglnx.m4
+--- flatpak-builder-0.10.10.orig/libglnx/libglnx.m4 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/libglnx.m4 2018-05-26 01:11:39.807067515 +0300
+@@ -0,0 +1,33 @@
+AC_DEFUN([LIBGLNX_CONFIGURE],
+[
+AC_CHECK_DECLS([
+ renameat2,
-+ ],
++ memfd_create,
++ copy_file_range],
+ [], [], [[
+#include
+#include
@@ -5199,6 +5454,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/libglnx.m4 flatpak-builder-0.10.6
+#include
+#include
+#include
++#include
+]])
+
+AC_ARG_ENABLE(otmpfile,
@@ -5217,10 +5473,10 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/libglnx.m4 flatpak-builder-0.10.6
+
+dnl end LIBGLNX_CONFIGURE
+])
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/Makefile-libglnx.am flatpak-builder-0.10.6/libglnx/Makefile-libglnx.am
---- flatpak-builder-0.10.6.orig/libglnx/Makefile-libglnx.am 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/Makefile-libglnx.am 2018-02-11 12:03:43.448373307 +0300
-@@ -0,0 +1,73 @@
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/Makefile-libglnx.am flatpak-builder-0.10.10/libglnx/Makefile-libglnx.am
+--- flatpak-builder-0.10.10.orig/libglnx/Makefile-libglnx.am 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/Makefile-libglnx.am 2018-05-26 01:11:39.785067515 +0300
+@@ -0,0 +1,78 @@
+# Copyright (C) 2015 Colin Walters
+#
+# This library is free software; you can redistribute it and/or
@@ -5269,13 +5525,14 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/Makefile-libglnx.am flatpak-build
+ $(libglnx_srcpath)/glnx-shutil.h \
+ $(libglnx_srcpath)/glnx-shutil.c \
+ $(libglnx_srcpath)/libglnx.h \
++ $(libglnx_srcpath)/tests/libglnx-testlib.h \
+ $(NULL)
+
+libglnx_la_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
+libglnx_la_LDFLAGS = -avoid-version -Bsymbolic-functions -export-symbols-regex "^glnx_" -no-undefined -export-dynamic
+libglnx_la_LIBADD = $(libglnx_libs)
+
-+libglnx_tests = test-libglnx-xattrs test-libglnx-fdio test-libglnx-errors test-libglnx-macros
++libglnx_tests = test-libglnx-xattrs test-libglnx-fdio test-libglnx-errors test-libglnx-macros test-libglnx-shutil
+TESTS += $(libglnx_tests)
+
+check_PROGRAMS += $(libglnx_tests)
@@ -5294,9 +5551,13 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/Makefile-libglnx.am flatpak-build
+test_libglnx_macros_SOURCES = $(libglnx_srcpath)/tests/test-libglnx-macros.c
+test_libglnx_macros_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
+test_libglnx_macros_LDADD = $(libglnx_libs) libglnx.la
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/README.md flatpak-builder-0.10.6/libglnx/README.md
---- flatpak-builder-0.10.6.orig/libglnx/README.md 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/README.md 2018-02-11 12:03:43.448373307 +0300
++
++test_libglnx_shutil_SOURCES = $(libglnx_srcpath)/tests/test-libglnx-shutil.c
++test_libglnx_shutil_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
++test_libglnx_shutil_LDADD = $(libglnx_libs) libglnx.la
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/README.md flatpak-builder-0.10.10/libglnx/README.md
+--- flatpak-builder-0.10.10.orig/libglnx/README.md 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/README.md 2018-05-26 01:11:39.785067515 +0300
@@ -0,0 +1,52 @@
+libglnx is the successor to libgsystem: https://git.gnome.org/browse/libgsystem
+
@@ -5337,7 +5598,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/README.md flatpak-builder-0.10.6/
+
+For local allocation macros, you should start using the `g_auto`
+macros from GLib. A backport is included in libglnx. There are a few
-+APIs not defined in GLib yet, such as `glnx_fd_close`.
++APIs not defined in GLib yet, such as `glnx_autofd`.
+
+`gs_transfer_out_value` is replaced by `g_steal_pointer`.
+
@@ -5350,9 +5611,47 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/README.md flatpak-builder-0.10.6/
+https://github.com/GNOME/libglnx/pulls
+
+Or alternatively, email one of the maintainers directly.
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/tests/test-libglnx-errors.c flatpak-builder-0.10.6/libglnx/tests/test-libglnx-errors.c
---- flatpak-builder-0.10.6.orig/libglnx/tests/test-libglnx-errors.c 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/tests/test-libglnx-errors.c 2018-02-11 12:03:43.450373307 +0300
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/tests/libglnx-testlib.h flatpak-builder-0.10.10/libglnx/tests/libglnx-testlib.h
+--- flatpak-builder-0.10.10.orig/libglnx/tests/libglnx-testlib.h 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/tests/libglnx-testlib.h 2018-05-26 01:11:39.807067515 +0300
+@@ -0,0 +1,34 @@
++/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
++ *
++ * Copyright (C) 2017 Red Hat, Inc.
++ *
++ * This library is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2 of the License, or (at your option) any later version.
++ *
++ * This library is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with this library; if not, write to the
++ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
++ * Boston, MA 02111-1307, USA.
++ */
++
++#pragma once
++
++typedef GError _GLnxTestAutoError;
++static inline void
++_glnx_test_auto_error_cleanup (_GLnxTestAutoError *autoerror)
++{
++ g_assert_no_error (autoerror);
++ /* We could add a clear call here, but no point...we'll have aborted */
++}
++G_DEFINE_AUTOPTR_CLEANUP_FUNC(_GLnxTestAutoError, _glnx_test_auto_error_cleanup);
++
++#define _GLNX_TEST_DECLARE_ERROR(local_error, error) \
++ g_autoptr(_GLnxTestAutoError) local_error = NULL; \
++ GError **error = &local_error
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/tests/test-libglnx-errors.c flatpak-builder-0.10.10/libglnx/tests/test-libglnx-errors.c
+--- flatpak-builder-0.10.10.orig/libglnx/tests/test-libglnx-errors.c 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/tests/test-libglnx-errors.c 2018-02-11 12:03:43.450373307 +0300
@@ -0,0 +1,183 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
@@ -5537,10 +5836,10 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/tests/test-libglnx-errors.c flatp
+
+ return ret;
+}
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/tests/test-libglnx-fdio.c flatpak-builder-0.10.6/libglnx/tests/test-libglnx-fdio.c
---- flatpak-builder-0.10.6.orig/libglnx/tests/test-libglnx-fdio.c 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/tests/test-libglnx-fdio.c 2018-02-11 12:03:43.450373307 +0300
-@@ -0,0 +1,206 @@
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/tests/test-libglnx-fdio.c flatpak-builder-0.10.10/libglnx/tests/test-libglnx-fdio.c
+--- flatpak-builder-0.10.10.orig/libglnx/tests/test-libglnx-fdio.c 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/tests/test-libglnx-fdio.c 2018-05-26 01:11:39.822067516 +0300
+@@ -0,0 +1,254 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2017 Red Hat, Inc.
@@ -5569,12 +5868,14 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/tests/test-libglnx-fdio.c flatpak
+#include
+#include
+
++#include "libglnx-testlib.h"
++
+static gboolean
+renameat_test_setup (int *out_srcfd, int *out_destfd,
+ GError **error)
+{
-+ glnx_fd_close int srcfd = -1;
-+ glnx_fd_close int destfd = -1;
++ glnx_autofd int srcfd = -1;
++ glnx_autofd int destfd = -1;
+
+ (void) glnx_shutil_rm_rf_at (AT_FDCWD, "srcdir", NULL, NULL);
+ if (mkdir ("srcdir", 0755) < 0)
@@ -5602,14 +5903,13 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/tests/test-libglnx-fdio.c flatpak
+static void
+test_renameat2_noreplace (void)
+{
-+ g_autoptr(GError) local_error = NULL;
-+ GError **error = &local_error;
-+ glnx_fd_close int srcfd = -1;
-+ glnx_fd_close int destfd = -1;
++ _GLNX_TEST_DECLARE_ERROR(local_error, error);
++ glnx_autofd int srcfd = -1;
++ glnx_autofd int destfd = -1;
+ struct stat stbuf;
+
+ if (!renameat_test_setup (&srcfd, &destfd, error))
-+ goto out;
++ return;
+
+ if (glnx_renameat2_noreplace (srcfd, "foo", destfd, "bar") == 0)
+ g_assert_not_reached ();
@@ -5619,117 +5919,162 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/tests/test-libglnx-fdio.c flatpak
+ }
+
+ if (glnx_renameat2_noreplace (srcfd, "foo", destfd, "baz") < 0)
-+ {
-+ glnx_set_error_from_errno (error);
-+ goto out;
-+ }
++ return (void)glnx_throw_errno_prefix (error, "renameat");
+ if (!glnx_fstatat (destfd, "bar", &stbuf, AT_SYMLINK_NOFOLLOW, error))
-+ goto out;
++ return;
+
+ if (fstatat (srcfd, "foo", &stbuf, AT_SYMLINK_NOFOLLOW) == 0)
+ g_assert_not_reached ();
+ else
+ g_assert_cmpint (errno, ==, ENOENT);
-+
-+ out:
-+ g_assert_no_error (local_error);
+}
+
+static void
+test_renameat2_exchange (void)
+{
-+ g_autoptr(GError) local_error = NULL;
-+ GError **error = &local_error;
-+ glnx_fd_close int srcfd = -1;
-+ glnx_fd_close int destfd = -1;
-+ struct stat stbuf;
++ _GLNX_TEST_DECLARE_ERROR(local_error, error);
+
++ glnx_autofd int srcfd = -1;
++ glnx_autofd int destfd = -1;
+ if (!renameat_test_setup (&srcfd, &destfd, error))
-+ goto out;
++ return;
+
+ if (glnx_renameat2_exchange (AT_FDCWD, "srcdir", AT_FDCWD, "destdir") < 0)
-+ {
-+ glnx_set_error_from_errno (error);
-+ goto out;
-+ }
++ return (void)glnx_throw_errno_prefix (error, "renameat");
+
+ /* Ensure the dir fds are the same */
-+ if (fstatat (srcfd, "foo", &stbuf, AT_SYMLINK_NOFOLLOW) < 0)
-+ {
-+ glnx_set_error_from_errno (error);
-+ goto out;
-+ }
-+ if (fstatat (destfd, "bar", &stbuf, AT_SYMLINK_NOFOLLOW) < 0)
-+ {
-+ glnx_set_error_from_errno (error);
-+ goto out;
-+ }
++ struct stat stbuf;
++ if (!glnx_fstatat (srcfd, "foo", &stbuf, AT_SYMLINK_NOFOLLOW, error))
++ return;
++ if (!glnx_fstatat (destfd, "bar", &stbuf, AT_SYMLINK_NOFOLLOW, error))
++ return;
+ /* But the dirs should be swapped */
-+ if (fstatat (AT_FDCWD, "destdir/foo", &stbuf, AT_SYMLINK_NOFOLLOW) < 0)
-+ {
-+ glnx_set_error_from_errno (error);
-+ goto out;
-+ }
-+ if (fstatat (AT_FDCWD, "srcdir/bar", &stbuf, AT_SYMLINK_NOFOLLOW) < 0)
-+ {
-+ glnx_set_error_from_errno (error);
-+ goto out;
-+ }
-+
-+ out:
-+ g_assert_no_error (local_error);
++ if (!glnx_fstatat (AT_FDCWD, "destdir/foo", &stbuf, AT_SYMLINK_NOFOLLOW, error))
++ return;
++ if (!glnx_fstatat (AT_FDCWD, "srcdir/bar", &stbuf, AT_SYMLINK_NOFOLLOW, error))
++ return;
+}
+
+static void
+test_tmpfile (void)
+{
-+ g_autoptr(GError) local_error = NULL;
-+ GError **error = &local_error;
++ _GLNX_TEST_DECLARE_ERROR(local_error, error);
++
+ g_auto(GLnxTmpfile) tmpf = { 0, };
-+
+ if (!glnx_open_tmpfile_linkable_at (AT_FDCWD, ".", O_WRONLY|O_CLOEXEC, &tmpf, error))
-+ goto out;
-+
++ return;
+ if (glnx_loop_write (tmpf.fd, "foo", strlen ("foo")) < 0)
-+ {
-+ (void)glnx_throw_errno_prefix (error, "write");
-+ goto out;
-+ }
-+
++ return (void)glnx_throw_errno_prefix (error, "write");
+ if (glnx_link_tmpfile_at (&tmpf, GLNX_LINK_TMPFILE_NOREPLACE, AT_FDCWD, "foo", error))
-+ goto out;
-+
-+ out:
-+ g_assert_no_error (local_error);
++ return;
+}
+
+static void
+test_stdio_file (void)
+{
-+ g_autoptr(GError) local_error = NULL;
-+ GError **error = &local_error;
++ _GLNX_TEST_DECLARE_ERROR(local_error, error);
+ g_auto(GLnxTmpfile) tmpf = { 0, };
+ g_autoptr(FILE) f = NULL;
+
+ if (!glnx_open_anonymous_tmpfile (O_RDWR|O_CLOEXEC, &tmpf, error))
-+ goto out;
++ return;
+ f = fdopen (tmpf.fd, "w");
++ tmpf.fd = -1; /* Ownership was transferred via fdopen() */
+ if (!f)
-+ {
-+ (void)glnx_throw_errno_prefix (error, "fdopen");
-+ goto out;
-+ }
-+
++ return (void)glnx_throw_errno_prefix (error, "fdopen");
+ if (fwrite ("hello", 1, strlen ("hello"), f) != strlen ("hello"))
-+ {
-+ (void)glnx_throw_errno_prefix (error, "fwrite");
-+ goto out;
-+ }
++ return (void)glnx_throw_errno_prefix (error, "fwrite");
+ if (!glnx_stdio_file_flush (f, error))
-+ goto out;
++ return;
++}
+
-+ out:
++static void
++test_fstatat (void)
++{
++ _GLNX_TEST_DECLARE_ERROR(local_error, error);
++ struct stat stbuf = { 0, };
++
++ if (!glnx_fstatat_allow_noent (AT_FDCWD, ".", &stbuf, 0, error))
++ return;
++ g_assert_cmpint (errno, ==, 0);
+ g_assert_no_error (local_error);
++ g_assert (S_ISDIR (stbuf.st_mode));
++ if (!glnx_fstatat_allow_noent (AT_FDCWD, "nosuchfile", &stbuf, 0, error))
++ return;
++ g_assert_cmpint (errno, ==, ENOENT);
++ g_assert_no_error (local_error);
++
++ /* test NULL parameter for stat */
++ if (!glnx_fstatat_allow_noent (AT_FDCWD, ".", NULL, 0, error))
++ return;
++ g_assert_cmpint (errno, ==, 0);
++ g_assert_no_error (local_error);
++ if (!glnx_fstatat_allow_noent (AT_FDCWD, "nosuchfile", NULL, 0, error))
++ return;
++ g_assert_cmpint (errno, ==, ENOENT);
++ g_assert_no_error (local_error);
++}
++
++static void
++test_filecopy (void)
++{
++ _GLNX_TEST_DECLARE_ERROR(local_error, error);
++ const char foo[] = "foo";
++ struct stat stbuf;
++
++ if (!glnx_ensure_dir (AT_FDCWD, "subdir", 0755, error))
++ return;
++
++ if (!glnx_file_replace_contents_at (AT_FDCWD, foo, (guint8*)foo, sizeof (foo),
++ GLNX_FILE_REPLACE_NODATASYNC, NULL, error))
++ return;
++
++ /* Copy it into both the same dir and a subdir */
++ if (!glnx_file_copy_at (AT_FDCWD, foo, NULL, AT_FDCWD, "bar",
++ GLNX_FILE_COPY_NOXATTRS, NULL, error))
++ return;
++ if (!glnx_file_copy_at (AT_FDCWD, foo, NULL, AT_FDCWD, "subdir/bar",
++ GLNX_FILE_COPY_NOXATTRS, NULL, error))
++ return;
++ if (!glnx_fstatat (AT_FDCWD, "subdir/bar", &stbuf, 0, error))
++ return;
++
++ if (glnx_file_copy_at (AT_FDCWD, foo, NULL, AT_FDCWD, "bar",
++ GLNX_FILE_COPY_NOXATTRS, NULL, error))
++ g_assert_not_reached ();
++ g_assert_error (local_error, G_IO_ERROR, G_IO_ERROR_EXISTS);
++ g_clear_error (&local_error);
++
++ if (!glnx_file_copy_at (AT_FDCWD, foo, NULL, AT_FDCWD, "bar",
++ GLNX_FILE_COPY_NOXATTRS | GLNX_FILE_COPY_OVERWRITE,
++ NULL, error))
++ return;
++
++ if (symlinkat ("nosuchtarget", AT_FDCWD, "link") < 0)
++ return (void) glnx_throw_errno_prefix (error, "symlinkat");
++
++ /* Shouldn't be able to overwrite a symlink without GLNX_FILE_COPY_OVERWRITE */
++ if (glnx_file_copy_at (AT_FDCWD, foo, NULL, AT_FDCWD, "link",
++ GLNX_FILE_COPY_NOXATTRS,
++ NULL, error))
++ g_assert_not_reached ();
++ g_assert_error (local_error, G_IO_ERROR, G_IO_ERROR_EXISTS);
++ g_clear_error (&local_error);
++
++ /* Test overwriting symlink */
++ if (!glnx_file_copy_at (AT_FDCWD, foo, NULL, AT_FDCWD, "link",
++ GLNX_FILE_COPY_NOXATTRS | GLNX_FILE_COPY_OVERWRITE,
++ NULL, error))
++ return;
++
++ if (!glnx_fstatat_allow_noent (AT_FDCWD, "nosuchtarget", &stbuf, AT_SYMLINK_NOFOLLOW, error))
++ return;
++ g_assert_cmpint (errno, ==, ENOENT);
++ g_assert_no_error (local_error);
++
++ if (!glnx_fstatat (AT_FDCWD, "link", &stbuf, AT_SYMLINK_NOFOLLOW, error))
++ return;
++ g_assert (S_ISREG (stbuf.st_mode));
+}
+
+int main (int argc, char **argv)
@@ -5740,16 +6085,18 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/tests/test-libglnx-fdio.c flatpak
+
+ g_test_add_func ("/tmpfile", test_tmpfile);
+ g_test_add_func ("/stdio-file", test_stdio_file);
++ g_test_add_func ("/filecopy", test_filecopy);
+ g_test_add_func ("/renameat2-noreplace", test_renameat2_noreplace);
+ g_test_add_func ("/renameat2-exchange", test_renameat2_exchange);
++ g_test_add_func ("/fstat", test_fstatat);
+
+ ret = g_test_run();
+
+ return ret;
+}
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/tests/test-libglnx-macros.c flatpak-builder-0.10.6/libglnx/tests/test-libglnx-macros.c
---- flatpak-builder-0.10.6.orig/libglnx/tests/test-libglnx-macros.c 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/tests/test-libglnx-macros.c 2018-02-11 12:03:43.450373307 +0300
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/tests/test-libglnx-macros.c flatpak-builder-0.10.10/libglnx/tests/test-libglnx-macros.c
+--- flatpak-builder-0.10.10.orig/libglnx/tests/test-libglnx-macros.c 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/tests/test-libglnx-macros.c 2018-02-11 12:03:43.450373307 +0300
@@ -0,0 +1,109 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
@@ -5860,10 +6207,77 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/tests/test-libglnx-macros.c flatp
+ g_test_add_func ("/hash_table_foreach", test_hash_table_foreach);
+ return g_test_run();
+}
-diff -Nuar flatpak-builder-0.10.6.orig/libglnx/tests/test-libglnx-xattrs.c flatpak-builder-0.10.6/libglnx/tests/test-libglnx-xattrs.c
---- flatpak-builder-0.10.6.orig/libglnx/tests/test-libglnx-xattrs.c 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-builder-0.10.6/libglnx/tests/test-libglnx-xattrs.c 2018-02-11 12:03:43.450373307 +0300
-@@ -0,0 +1,287 @@
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/tests/test-libglnx-shutil.c flatpak-builder-0.10.10/libglnx/tests/test-libglnx-shutil.c
+--- flatpak-builder-0.10.10.orig/libglnx/tests/test-libglnx-shutil.c 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/tests/test-libglnx-shutil.c 2018-05-26 01:11:39.822067516 +0300
+@@ -0,0 +1,63 @@
++/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
++ *
++ * Copyright © 2017 Endless Mobile, Inc.
++ *
++ * This library is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2 of the License, or (at your option) any later version.
++ *
++ * This library is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with this library; if not, write to the
++ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
++ * Boston, MA 02111-1307, USA.
++ */
++
++#include "config.h"
++#include "libglnx.h"
++#include
++#include
++#include
++#include
++#include
++
++#include "libglnx-testlib.h"
++
++static void
++test_mkdir_p_enoent (void)
++{
++ _GLNX_TEST_DECLARE_ERROR(local_error, error);
++ glnx_autofd int dfd = -1;
++
++ if (!glnx_ensure_dir (AT_FDCWD, "test", 0755, error))
++ return;
++ if (!glnx_opendirat (AT_FDCWD, "test", FALSE, &dfd, error))
++ return;
++ if (rmdir ("test") < 0)
++ return (void) glnx_throw_errno_prefix (error, "rmdir(%s)", "test");
++
++ /* This should fail with ENOENT. */
++ glnx_shutil_mkdir_p_at (dfd, "blah/baz", 0755, NULL, error);
++ g_assert_error (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND);
++ g_clear_error (&local_error);
++}
++
++int
++main (int argc,
++ char **argv)
++{
++ int ret;
++
++ g_test_init (&argc, &argv, NULL);
++
++ g_test_add_func ("/mkdir-p/enoent", test_mkdir_p_enoent);
++
++ ret = g_test_run();
++
++ return ret;
++}
+diff -Nuar flatpak-builder-0.10.10.orig/libglnx/tests/test-libglnx-xattrs.c flatpak-builder-0.10.10/libglnx/tests/test-libglnx-xattrs.c
+--- flatpak-builder-0.10.10.orig/libglnx/tests/test-libglnx-xattrs.c 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-builder-0.10.10/libglnx/tests/test-libglnx-xattrs.c 2018-05-26 01:11:39.822067516 +0300
+@@ -0,0 +1,283 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2017 Red Hat, Inc.
@@ -5948,7 +6362,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/tests/test-libglnx-xattrs.c flatp
+ {
+ guint32 randname_v = g_random_int ();
+ g_autofree char *randname = g_strdup_printf ("file%u", randname_v);
-+ glnx_fd_close int fd = -1;
++ glnx_autofd int fd = -1;
+
+ again:
+ fd = openat (dfd_iter->fd, randname, O_CREAT | O_EXCL, 0644);
@@ -5979,7 +6393,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/tests/test-libglnx-xattrs.c flatp
+ if (!dent)
+ break;
+
-+ glnx_fd_close int fd = -1;
++ glnx_autofd int fd = -1;
+ if (!glnx_openat_rdonly (dfd_iter->fd, dent->d_name, FALSE, &fd, error))
+ return FALSE;
+
@@ -6023,7 +6437,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/tests/test-libglnx-xattrs.c flatp
+ if (!dent)
+ break;
+
-+ glnx_fd_close int fd = -1;
++ glnx_autofd int fd = -1;
+ if (!glnx_openat_rdonly (dfd_iter->fd, dent->d_name, FALSE, &fd, error))
+ return FALSE;
+
@@ -6089,19 +6503,17 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/tests/test-libglnx-xattrs.c flatp
+ GThread *threads[nprocs];
+ g_autoptr(GError) local_error = NULL;
+ GError **error = &local_error;
-+ glnx_fd_close int dfd = -1;
-+ g_autofree char *tmpdir = g_strdup_printf ("%s/libglnx-xattrs-XXXXXX",
-+ getenv ("TMPDIR") ?: "/var/tmp");
++ g_auto(GLnxTmpDir) tmpdir = { 0, };
++ g_autofree char *tmpdir_path = g_strdup_printf ("%s/libglnx-xattrs-XXXXXX",
++ getenv ("TMPDIR") ?: "/var/tmp");
+ guint nread = 0;
+
-+ if (!glnx_mkdtempat (AT_FDCWD, tmpdir, 0700, error))
-+ goto out;
-+
-+ if (!glnx_opendirat (AT_FDCWD, tmpdir, TRUE, &dfd, error))
++ if (!glnx_mkdtempat (AT_FDCWD, tmpdir_path, 0700,
++ &tmpdir, error))
+ goto out;
+
+ /* Support people building/testing on tmpfs https://github.com/flatpak/flatpak/issues/686 */
-+ if (fsetxattr (dfd, "user.test", "novalue", strlen ("novalue"), 0) < 0)
++ if (fsetxattr (tmpdir.fd, "user.test", "novalue", strlen ("novalue"), 0) < 0)
+ {
+ if (errno == EOPNOTSUPP)
+ {
@@ -6118,7 +6530,7 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/tests/test-libglnx-xattrs.c flatp
+ for (guint i = 0; i < nprocs; i++)
+ {
+ struct XattrWorker *worker = &wdata[i];
-+ worker->dfd = dfd;
++ worker->dfd = tmpdir.fd;
+ worker->is_writer = i % 2 == 0;
+ threads[i] = g_thread_new (NULL, xattr_thread, worker);
+ }
@@ -6133,8 +6545,6 @@ diff -Nuar flatpak-builder-0.10.6.orig/libglnx/tests/test-libglnx-xattrs.c flatp
+
+ g_print ("Read %u xattrs race free!\n", nread);
+
-+ (void) glnx_shutil_rm_rf_at (AT_FDCWD, tmpdir, NULL, NULL);
-+
+ out:
+ g_assert_no_error (local_error);
+}
diff --git a/hardware/virtualization/flatpak-builder/pspec.xml b/hardware/virtualization/flatpak-builder/pspec.xml
index 1aaa8ae36c..a11a26fdd1 100644
--- a/hardware/virtualization/flatpak-builder/pspec.xml
+++ b/hardware/virtualization/flatpak-builder/pspec.xml
@@ -12,10 +12,10 @@
app:console
Tool to build flatpaks from sources
Tool for building flatpaks from sources
- https://github.com/flatpak/flatpak-builder/archive/0.10.8.tar.gz
+ https://github.com/flatpak/flatpak-builder/archive/0.10.10.tar.gz
- flatpak-devel
- ostree-devel
+ flatpak-devel
+ ostree-devel
util-linux
libxslt
xmlto
@@ -24,6 +24,7 @@
elfutils
glib2-devel
libxml2-devel
+ libyaml-devel
libglnx_submodule.patch
@@ -33,13 +34,14 @@
flatpak-builder
- flatpak
- ostree
+ flatpak
+ ostree
libsoup
elfutils
glib2
libxml2
json-glib
+ libyaml
/usr/bin
@@ -49,6 +51,13 @@
+
+ 2018-05-26
+ 0.10.10
+ Version bump.
+ Ertuğrul Erata
+ ertugrulerata@gmail.com
+
2018-02-16
0.10.8
diff --git a/hardware/virtualization/flatpak/actions.py b/hardware/virtualization/flatpak/actions.py
index d9d41a72ff..6045087cb1 100644
--- a/hardware/virtualization/flatpak/actions.py
+++ b/hardware/virtualization/flatpak/actions.py
@@ -18,6 +18,7 @@ def setup():
--enable-xauth \
--with-system-bubblewrap \
--enable-docbook-docs \
+ --disable-static \
--enable-sandboxed-triggers")
pisitools.dosed("libtool", " -shared ", " -Wl,-O1,--as-needed -shared ")
diff --git a/hardware/virtualization/flatpak/files/bubblewrap_libglnx_submodule.patch b/hardware/virtualization/flatpak/files/bubblewrap_libglnx_submodule.patch
index a3570fff27..6112240639 100644
--- a/hardware/virtualization/flatpak/files/bubblewrap_libglnx_submodule.patch
+++ b/hardware/virtualization/flatpak/files/bubblewrap_libglnx_submodule.patch
@@ -1,6 +1,6 @@
-diff -Nuar flatpak-0.10.3.orig/bubblewrap/autogen.sh flatpak-0.10.3/bubblewrap/autogen.sh
---- flatpak-0.10.3.orig/bubblewrap/autogen.sh 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-0.10.3/bubblewrap/autogen.sh 2018-02-03 21:26:06.272233339 +0300
+diff -Nuar flatpak-0.11.7.orig/bubblewrap/autogen.sh flatpak-0.11.7/bubblewrap/autogen.sh
+--- flatpak-0.11.7.orig/bubblewrap/autogen.sh 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-0.11.7/bubblewrap/autogen.sh 2018-02-03 21:26:06.272233339 +0300
@@ -0,0 +1,19 @@
+#!/bin/sh
+
@@ -21,9 +21,9 @@ diff -Nuar flatpak-0.10.3.orig/bubblewrap/autogen.sh flatpak-0.10.3/bubblewrap/a
+
+cd $olddir
+test -n "$NOCONFIGURE" || "$srcdir/configure" "$@"
-diff -Nuar flatpak-0.10.3.orig/bubblewrap/bind-mount.c flatpak-0.10.3/bubblewrap/bind-mount.c
---- flatpak-0.10.3.orig/bubblewrap/bind-mount.c 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-0.10.3/bubblewrap/bind-mount.c 2018-02-03 21:26:06.272233339 +0300
+diff -Nuar flatpak-0.11.7.orig/bubblewrap/bind-mount.c flatpak-0.11.7/bubblewrap/bind-mount.c
+--- flatpak-0.11.7.orig/bubblewrap/bind-mount.c 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-0.11.7/bubblewrap/bind-mount.c 2018-02-03 21:26:06.272233339 +0300
@@ -0,0 +1,440 @@
+/* bubblewrap
+ * Copyright (C) 2016 Alexander Larsson
@@ -465,9 +465,9 @@ diff -Nuar flatpak-0.10.3.orig/bubblewrap/bind-mount.c flatpak-0.10.3/bubblewrap
+
+ return 0;
+}
-diff -Nuar flatpak-0.10.3.orig/bubblewrap/bind-mount.h flatpak-0.10.3/bubblewrap/bind-mount.h
---- flatpak-0.10.3.orig/bubblewrap/bind-mount.h 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-0.10.3/bubblewrap/bind-mount.h 2018-02-03 21:26:06.272233339 +0300
+diff -Nuar flatpak-0.11.7.orig/bubblewrap/bind-mount.h flatpak-0.11.7/bubblewrap/bind-mount.h
+--- flatpak-0.11.7.orig/bubblewrap/bind-mount.h 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-0.11.7/bubblewrap/bind-mount.h 2018-02-03 21:26:06.272233339 +0300
@@ -0,0 +1,30 @@
+/* bubblewrap
+ * Copyright (C) 2016 Alexander Larsson
@@ -499,9 +499,9 @@ diff -Nuar flatpak-0.10.3.orig/bubblewrap/bind-mount.h flatpak-0.10.3/bubblewrap
+ const char *src,
+ const char *dest,
+ bind_option_t options);
-diff -Nuar flatpak-0.10.3.orig/bubblewrap/bubblewrap.c flatpak-0.10.3/bubblewrap/bubblewrap.c
---- flatpak-0.10.3.orig/bubblewrap/bubblewrap.c 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-0.10.3/bubblewrap/bubblewrap.c 2018-02-03 21:26:06.272233339 +0300
+diff -Nuar flatpak-0.11.7.orig/bubblewrap/bubblewrap.c flatpak-0.11.7/bubblewrap/bubblewrap.c
+--- flatpak-0.11.7.orig/bubblewrap/bubblewrap.c 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-0.11.7/bubblewrap/bubblewrap.c 2018-02-03 21:26:06.272233339 +0300
@@ -0,0 +1,2223 @@
+/* bubblewrap
+ * Copyright (C) 2016 Alexander Larsson
@@ -2726,9 +2726,9 @@ diff -Nuar flatpak-0.10.3.orig/bubblewrap/bubblewrap.c flatpak-0.10.3/bubblewrap
+
+ return 0;
+}
-diff -Nuar flatpak-0.10.3.orig/bubblewrap/bubblewrap.jpg flatpak-0.10.3/bubblewrap/bubblewrap.jpg
---- flatpak-0.10.3.orig/bubblewrap/bubblewrap.jpg 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-0.10.3/bubblewrap/bubblewrap.jpg 2018-02-03 21:26:06.273233339 +0300
+diff -Nuar flatpak-0.11.7.orig/bubblewrap/bubblewrap.jpg flatpak-0.11.7/bubblewrap/bubblewrap.jpg
+--- flatpak-0.11.7.orig/bubblewrap/bubblewrap.jpg 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-0.11.7/bubblewrap/bubblewrap.jpg 2018-02-03 21:26:06.273233339 +0300
@@ -0,0 +1,143 @@
+ JFIF H H C C
+ c6M5G?ory-=:I.l֯ v+ܐjJN턐1%=UɮP|5q6`:y/M=.q$ l_ӛg7} <
@@ -2874,9 +2874,9 @@ diff -Nuar flatpak-0.10.3.orig/bubblewrap/bubblewrap.jpg flatpak-0.10.3/bubblewr
+6Tk`)kj}Ҫ tu )ՇTf,sB ,fţy[6(#hMjkEMkE/\alu-X$_\ r_X
5u97sN=X;Y$1w(yB́lWV%@|xа2:A ˢo=4^d1K9I"5E6;f3 .26 Yv|7B%ڀ꺾xhk3)iPd#,l6\C =RN#x9Ă:3leS`.2 >4EdPt'
+vɲ]0>g+
\ Dosya sonunda yenisatır yok.
-diff -Nuar flatpak-0.10.3.orig/bubblewrap/bwrap.xml flatpak-0.10.3/bubblewrap/bwrap.xml
---- flatpak-0.10.3.orig/bubblewrap/bwrap.xml 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-0.10.3/bubblewrap/bwrap.xml 2018-02-03 21:26:06.273233339 +0300
+diff -Nuar flatpak-0.11.7.orig/bubblewrap/bwrap.xml flatpak-0.11.7/bubblewrap/bwrap.xml
+--- flatpak-0.11.7.orig/bubblewrap/bwrap.xml 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-0.11.7/bubblewrap/bwrap.xml 2018-02-03 21:26:06.273233339 +0300
@@ -0,0 +1,320 @@
+
+
+
+
-diff -Nuar flatpak-0.10.3.orig/bubblewrap/ci/redhat-ci.sh flatpak-0.10.3/bubblewrap/ci/redhat-ci.sh
---- flatpak-0.10.3.orig/bubblewrap/ci/redhat-ci.sh 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-0.10.3/bubblewrap/ci/redhat-ci.sh 2018-02-03 21:26:06.273233339 +0300
+diff -Nuar flatpak-0.11.7.orig/bubblewrap/ci/redhat-ci.sh flatpak-0.11.7/bubblewrap/ci/redhat-ci.sh
+--- flatpak-0.11.7.orig/bubblewrap/ci/redhat-ci.sh 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-0.11.7/bubblewrap/ci/redhat-ci.sh 2018-02-03 21:26:06.273233339 +0300
@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+
@@ -3249,9 +3249,9 @@ diff -Nuar flatpak-0.10.3.orig/bubblewrap/ci/redhat-ci.sh flatpak-0.10.3/bubblew
+else
+ buildinstall_to_host
+fi
-diff -Nuar flatpak-0.10.3.orig/bubblewrap/completions/bash/bwrap flatpak-0.10.3/bubblewrap/completions/bash/bwrap
---- flatpak-0.10.3.orig/bubblewrap/completions/bash/bwrap 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-0.10.3/bubblewrap/completions/bash/bwrap 2018-02-03 21:26:06.273233339 +0300
+diff -Nuar flatpak-0.11.7.orig/bubblewrap/completions/bash/bwrap flatpak-0.11.7/bubblewrap/completions/bash/bwrap
+--- flatpak-0.11.7.orig/bubblewrap/completions/bash/bwrap 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-0.11.7/bubblewrap/completions/bash/bwrap 2018-02-03 21:26:06.273233339 +0300
@@ -0,0 +1,60 @@
+#!/bin/bash
+#
@@ -3313,9 +3313,9 @@ diff -Nuar flatpak-0.10.3.orig/bubblewrap/completions/bash/bwrap flatpak-0.10.3/
+ return 0
+}
+complete -F _bwrap bwrap
-diff -Nuar flatpak-0.10.3.orig/bubblewrap/configure.ac flatpak-0.10.3/bubblewrap/configure.ac
---- flatpak-0.10.3.orig/bubblewrap/configure.ac 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-0.10.3/bubblewrap/configure.ac 2018-02-03 21:26:06.273233339 +0300
+diff -Nuar flatpak-0.11.7.orig/bubblewrap/configure.ac flatpak-0.11.7/bubblewrap/configure.ac
+--- flatpak-0.11.7.orig/bubblewrap/configure.ac 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-0.11.7/bubblewrap/configure.ac 2018-02-03 21:26:06.273233339 +0300
@@ -0,0 +1,127 @@
+AC_PREREQ([2.63])
+AC_INIT([bubblewrap], [0.1.8], [atomic-devel@projectatomic.io])
@@ -3444,9 +3444,9 @@ diff -Nuar flatpak-0.10.3.orig/bubblewrap/configure.ac flatpak-0.10.3/bubblewrap
+ require default userns: $enable_require_userns
+ mysteriously satisfying to pop: yes"
+echo ""
-diff -Nuar flatpak-0.10.3.orig/bubblewrap/COPYING flatpak-0.10.3/bubblewrap/COPYING
---- flatpak-0.10.3.orig/bubblewrap/COPYING 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-0.10.3/bubblewrap/COPYING 2018-02-03 21:26:06.271233339 +0300
+diff -Nuar flatpak-0.11.7.orig/bubblewrap/COPYING flatpak-0.11.7/bubblewrap/COPYING
+--- flatpak-0.11.7.orig/bubblewrap/COPYING 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-0.11.7/bubblewrap/COPYING 2018-02-03 21:26:06.271233339 +0300
@@ -0,0 +1,481 @@
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ Version 2, June 1991
@@ -3929,9 +3929,9 @@ diff -Nuar flatpak-0.10.3.orig/bubblewrap/COPYING flatpak-0.10.3/bubblewrap/COPY
+ Ty Coon, President of Vice
+
+That's all there is to it!
-diff -Nuar flatpak-0.10.3.orig/bubblewrap/demos/bubblewrap-shell.sh flatpak-0.10.3/bubblewrap/demos/bubblewrap-shell.sh
---- flatpak-0.10.3.orig/bubblewrap/demos/bubblewrap-shell.sh 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-0.10.3/bubblewrap/demos/bubblewrap-shell.sh 2018-02-03 21:26:06.273233339 +0300
+diff -Nuar flatpak-0.11.7.orig/bubblewrap/demos/bubblewrap-shell.sh flatpak-0.11.7/bubblewrap/demos/bubblewrap-shell.sh
+--- flatpak-0.11.7.orig/bubblewrap/demos/bubblewrap-shell.sh 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-0.11.7/bubblewrap/demos/bubblewrap-shell.sh 2018-02-03 21:26:06.273233339 +0300
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+# Use bubblewrap to run /bin/sh reusing the host OS binaries (/usr), but with
@@ -3966,16 +3966,16 @@ diff -Nuar flatpak-0.10.3.orig/bubblewrap/demos/bubblewrap-shell.sh flatpak-0.10
+ /bin/sh) \
+ 11< <(getent passwd $UID 65534) \
+ 12< <(getent group $(id -g) 65534)
-diff -Nuar flatpak-0.10.3.orig/bubblewrap/demos/flatpak.bpf flatpak-0.10.3/bubblewrap/demos/flatpak.bpf
---- flatpak-0.10.3.orig/bubblewrap/demos/flatpak.bpf 1970-01-01 02:00:00.000000000 +0200
-+++ flatpak-0.10.3/bubblewrap/demos/flatpak.bpf 2018-02-03 21:26:06.273233339 +0300
+diff -Nuar flatpak-0.11.7.orig/bubblewrap/demos/flatpak.bpf flatpak-0.11.7/bubblewrap/demos/flatpak.bpf
+--- flatpak-0.11.7.orig/bubblewrap/demos/flatpak.bpf 1970-01-01 02:00:00.000000000 +0200
++++ flatpak-0.11.7/bubblewrap/demos/flatpak.bpf 2018-02-03 21:26:06.273233339 +0300
@@ -0,0 +1,2 @@
+ >> W e V g U T S R Q P O N M L K J I H * G g @ F @ E @ D @ C @ B @ A @ @ @ ? @ > @ = @ <