{
guint32 canonical_mode;
/* Silently ignore world-writable directories (plus sticky, suid bits,
- * etc.) when doing a checkout for bare-user-only repos. This is related
- * to the logic in ostree-repo-commit.c for files.
+ * etc.) when doing a checkout for bare-user-only repos, or if requested explicitly.
+ * This is related to the logic in ostree-repo-commit.c for files.
* See also: https://github.com/ostreedev/ostree/pull/909 i.e. 0c4b3a2b6da950fd78e63f9afec602f6188f1ab0
*/
- if (self->mode == OSTREE_REPO_MODE_BARE_USER_ONLY)
+ if (self->mode == OSTREE_REPO_MODE_BARE_USER_ONLY || options->bareuseronly_dirs)
canonical_mode = (mode & 0775) | S_IFDIR;
else
canonical_mode = mode;
static gboolean opt_disable_fsync;
static gboolean opt_require_hardlinks;
static gboolean opt_force_copy;
+static gboolean opt_bareuseronly_dirs;
static gboolean
parse_fsync_cb (const char *option_name,
{ "fsync", 0, 0, G_OPTION_ARG_CALLBACK, parse_fsync_cb, "Specify how to invoke fsync()", "POLICY" },
{ "require-hardlinks", 'H', 0, G_OPTION_ARG_NONE, &opt_require_hardlinks, "Do not fall back to full copies if hardlinking fails", NULL },
{ "force-copy", 'C', 0, G_OPTION_ARG_NONE, &opt_force_copy, "Never hardlink (but may reflink if available)", NULL },
+ { "bareuseronly-dirs", 'M', 0, G_OPTION_ARG_NONE, &opt_bareuseronly_dirs, "Suppress mode bits outside of 0775 for directories (suid, world writable, etc.)", NULL },
{ NULL }
};
* `ostree_repo_checkout_at` until such time as we have a more
* convenient infrastructure for testing C APIs with data.
*/
- if (opt_disable_cache || opt_whiteouts || opt_require_hardlinks || opt_union_add || opt_force_copy)
+ if (opt_disable_cache || opt_whiteouts || opt_require_hardlinks ||
+ opt_union_add || opt_force_copy || opt_bareuseronly_dirs)
{
OstreeRepoCheckoutAtOptions options = { 0, };
options.subpath = subpath;
options.no_copy_fallback = opt_require_hardlinks;
options.force_copy = opt_force_copy;
+ options.bareuseronly_dirs = opt_bareuseronly_dirs;
if (!ostree_repo_checkout_at (repo, &options,
AT_FDCWD, destination,
set -euo pipefail
-echo "1..$((68 + ${extra_basic_tests:-0}))"
+echo "1..$((69 + ${extra_basic_tests:-0}))"
$CMD_PREFIX ostree --version > version.yaml
python -c 'import yaml; yaml.safe_load(open("version.yaml"))'
assert_file_has_content checkout-test-union-add/union-add-test2 'another file for union add testing'
echo "ok checkout union add"
+cd ${test_tmpdir}
+rm files -rf && mkdir files
+mkdir files/worldwritable-dir
+chmod a+w files/worldwritable-dir
+$CMD_PREFIX ostree --repo=repo commit -b content-with-dir-world-writable --tree=dir=files
+rm dir-co -rf
+$CMD_PREFIX ostree --repo=repo checkout -U -H -M content-with-dir-world-writable dir-co
+assert_file_has_mode dir-co/worldwritable-dir 775
+if ! is_bare_user_only_repo repo; then
+ rm dir-co -rf
+ $CMD_PREFIX ostree --repo=repo checkout -U -H content-with-dir-world-writable dir-co
+ assert_file_has_mode dir-co/worldwritable-dir 777
+fi
+rm dir-co -rf
+echo "ok checkout bareuseronly dir"
+
cd ${test_tmpdir}
rm -rf shadow-repo
mkdir shadow-repo