diff --git a/apidoc/html/index.html b/apidoc/html/index.html
index 9abed893..4dd0bde2 100644
--- a/apidoc/html/index.html
+++ b/apidoc/html/index.html
@@ -14,7 +14,7 @@
diff --git a/apidoc/version.xml b/apidoc/version.xml
index 36d21d4f..8d52ac12 100644
--- a/apidoc/version.xml
+++ b/apidoc/version.xml
@@ -1 +1 @@
-2019.7
\ No newline at end of file
+2020.3
\ No newline at end of file
diff --git a/configure b/configure
index 0544942f..4e903470 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for libostree 2020.2.
+# Generated by GNU Autoconf 2.69 for libostree 2020.3.
#
# Report bugs to .
#
@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='libostree'
PACKAGE_TARNAME='libostree'
-PACKAGE_VERSION='2020.2'
-PACKAGE_STRING='libostree 2020.2'
+PACKAGE_VERSION='2020.3'
+PACKAGE_STRING='libostree 2020.3'
PACKAGE_BUGREPORT='walters@verbum.org'
PACKAGE_URL=''
@@ -1552,7 +1552,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures libostree 2020.2 to adapt to many kinds of systems.
+\`configure' configures libostree 2020.3 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1622,7 +1622,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of libostree 2020.2:";;
+ short | recursive ) echo "Configuration of libostree 2020.3:";;
esac
cat <<\_ACEOF
@@ -1881,7 +1881,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-libostree configure 2020.2
+libostree configure 2020.3
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2353,7 +2353,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by libostree $as_me 2020.2, which was
+It was created by libostree $as_me 2020.3, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -3221,7 +3221,7 @@ fi
# Define the identity of the package.
PACKAGE='libostree'
- VERSION='2020.2'
+ VERSION='2020.3'
# Some tools Automake needs.
@@ -5955,9 +5955,9 @@ test -n "$YACC" || YACC="yacc"
YEAR_VERSION=2020
-RELEASE_VERSION=2
+RELEASE_VERSION=3
-PACKAGE_VERSION=2020.2
+PACKAGE_VERSION=2020.3
if echo "$CFLAGS" | grep -q -E -e '-Werror($| )'; then :
@@ -18844,7 +18844,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by libostree $as_me 2020.2, which was
+This file was extended by libostree $as_me 2020.3, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -18910,7 +18910,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-libostree config.status 2020.2
+libostree config.status 2020.3
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/configure.ac b/configure.ac
index 36995403..f8d7b2be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,7 +7,7 @@ dnl Seed the release notes with `git-shortlog-with-prs ..`. Th
dnl `git-evtag` to create the tag and push it. Finally, create a GitHub release and attach
dnl the tarball from `make dist`.
m4_define([year_version], [2020])
-m4_define([release_version], [2])
+m4_define([release_version], [3])
m4_define([package_version], [year_version.release_version])
AC_INIT([libostree], [package_version], [walters@verbum.org])
is_release_build=yes
diff --git a/src/libostree/ostree-version.h b/src/libostree/ostree-version.h
index be52a9d9..4ed20af1 100644
--- a/src/libostree/ostree-version.h
+++ b/src/libostree/ostree-version.h
@@ -43,7 +43,7 @@
*
* Since: 2017.4
*/
-#define OSTREE_RELEASE_VERSION (2)
+#define OSTREE_RELEASE_VERSION (3)
/**
* OSTREE_VERSION
@@ -52,7 +52,7 @@
*
* Since: 2017.4
*/
-#define OSTREE_VERSION (2020.2)
+#define OSTREE_VERSION (2020.3)
/**
* OSTREE_VERSION_S:
@@ -62,7 +62,7 @@
*
* Since: 2017.4
*/
-#define OSTREE_VERSION_S "2020.2"
+#define OSTREE_VERSION_S "2020.3"
#define OSTREE_ENCODE_VERSION(year,release) \
((year) << 16 | (release))
diff --git a/src/ostree/ot-main.c b/src/ostree/ot-main.c
index a044cef2..bffa40c4 100644
--- a/src/ostree/ot-main.c
+++ b/src/ostree/ot-main.c
@@ -28,6 +28,8 @@
#include
#include
#include
+#include
+#include
#include "ot-main.h"
#include "ostree.h"
@@ -100,6 +102,49 @@ ostree_usage (OstreeCommand *commands,
return (is_error ? 1 : 0);
}
+/* If we're running as root, booted into an OSTree system and have a read-only
+ * /sysroot, then assume we may need write access. Create a new mount namespace
+ * if so, and return *out_ns = TRUE. Otherwise, *out_ns = FALSE.
+ */
+static gboolean
+maybe_setup_mount_namespace (gboolean *out_ns,
+ GError **error)
+{
+ *out_ns = FALSE;
+
+ /* If we're not root, then we almost certainly can't be remounting anything */
+ if (getuid () != 0)
+ return TRUE;
+
+ /* If the system isn't booted via libostree, also nothing to do */
+ if (!glnx_fstatat_allow_noent (AT_FDCWD, "/run/ostree-booted", NULL, 0, error))
+ return FALSE;
+ if (errno == ENOENT)
+ return TRUE;
+
+ glnx_autofd int sysroot_subdir_fd = glnx_opendirat_with_errno (AT_FDCWD, "/sysroot", TRUE);
+ if (sysroot_subdir_fd < 0)
+ {
+ if (errno != ENOENT)
+ return glnx_throw_errno_prefix (error, "opendirat");
+ /* No /sysroot - nothing to do */
+ return TRUE;
+ }
+
+ struct statvfs stvfs;
+ if (fstatvfs (sysroot_subdir_fd, &stvfs) < 0)
+ return glnx_throw_errno_prefix (error, "fstatvfs");
+ if (stvfs.f_flag & ST_RDONLY)
+ {
+ if (unshare (CLONE_NEWNS) < 0)
+ return glnx_throw_errno_prefix (error, "preparing writable sysroot: unshare (CLONE_NEWNS)");
+
+ *out_ns = TRUE;
+ }
+
+ return TRUE;
+}
+
static void
message_handler (const gchar *log_domain,
GLogLevelFlags log_level,
@@ -220,6 +265,19 @@ parse_repo_option (GOptionContext *context,
{
g_autoptr(OstreeRepo) repo = NULL;
+ /* This is a bit of a brutal hack; we set up a mount
+ * namespace if it appears that we may need it. It'd
+ * be better to do this more precisely in the future.
+ */
+ gboolean setup_ns = FALSE;
+ if (!maybe_setup_mount_namespace (&setup_ns, error))
+ return FALSE;
+ if (setup_ns)
+ {
+ if (mount ("/sysroot", "/sysroot", NULL, MS_REMOUNT | MS_SILENT, NULL) < 0)
+ return glnx_null_throw_errno_prefix (error, "Remounting /sysroot read-write");
+ }
+
if (repo_path == NULL)
{
g_autoptr(GError) local_error = NULL;
@@ -452,27 +510,11 @@ ostree_admin_option_context_parse (GOptionContext *context,
*/
if (ostree_sysroot_is_booted (sysroot))
{
- int sysroot_fd = ostree_sysroot_get_fd (sysroot);
- g_assert_cmpint (sysroot_fd, !=, -1);
-
- glnx_autofd int sysroot_subdir_fd = glnx_opendirat_with_errno (sysroot_fd, "sysroot", TRUE);
- if (sysroot_subdir_fd < 0)
- {
- if (errno != ENOENT)
- return glnx_throw_errno_prefix (error, "opendirat");
- }
- else if (getuid () == 0)
- {
- struct statvfs stvfs;
- if (fstatvfs (sysroot_subdir_fd, &stvfs) < 0)
- return glnx_throw_errno_prefix (error, "fstatvfs");
- if (stvfs.f_flag & ST_RDONLY)
- {
- if (unshare (CLONE_NEWNS) < 0)
- return glnx_throw_errno_prefix (error, "preparing writable sysroot: unshare (CLONE_NEWNS)");
- ostree_sysroot_set_mount_namespace_in_use (sysroot);
- }
- }
+ gboolean setup_ns = FALSE;
+ if (!maybe_setup_mount_namespace (&setup_ns, error))
+ return FALSE;
+ if (setup_ns)
+ ostree_sysroot_set_mount_namespace_in_use (sysroot);
}
/* Released when sysroot is finalized, or on process exit */