ostree/src/libostree
Colin Walters 8e6e64a5ad lib: Validate metadata structure more consistently during pull
Previously we were doing e.g. `ot_util_filename_validate()` specifically inline
in dirtree objects, but only *after* writing them into the staging directory (by
default). In (non-default) cases such as not using a transaction, such an object
could be written directly into the repo.

A notable gap here is that `pull-local --untrusted` was *not* doing
this verification, just checksums.  We harden that (and also the
static delta writing path, really *everything* that calls
`ostree_repo_write_metadata()` to also do "structure" validation
which includes path traversal checks.  Basically, let's try hard
to avoid having badly structured objects even in the repo.

One thing that sucks in this patch is that we need to allocate a "bounce buffer"
for metadata in the static delta path, because GVariant imposes alignment
requirements, which I screwed up and didn't fulfill when designing deltas. It
actually didn't matter before because we weren't parsing them, but now we are.
In theory we could check alignment but ...eh, not worth it, at least not until
we change the delta compiler to emit aligned metadata which actually may be
quite tricky.  (Big picture I doubt this really matters much right now
but I'm not going to pull out a profiler yet for this)

The pull test was extended to check we didn't even write a dirtree
with path traversal into the staging directory.

There's a bit of code motion in extracting
`_ostree_validate_structureof_metadata()` from `fsck_metadata_object()`.

Then `_ostree_verify_metadata_object()` builds on that to do checksum
verification too.

Closes: #1412
Approved by: jlebon
2018-01-12 19:38:34 +00:00
..
README-gpg pull: Verify commits with gpg signatures from detached metadata 2013-09-29 14:49:47 -04:00
README.md core: Associate branches with remotes, move trigger runs into checkout 2012-04-03 23:46:34 -04:00
bupsplit.c lib: Move the bupsplit selftest into our test framework 2017-02-02 16:51:36 +00:00
bupsplit.h lib: Move the bupsplit selftest into our test framework 2017-02-02 16:51:36 +00:00
libostree-devel.sym Release 2017.15 2017-12-19 16:10:26 +00:00
libostree-experimental.sym lib/repo: Add locking auto cleanup handler 2017-12-05 02:32:47 +00:00
libostree-released.sym Release 2017.15 2017-12-19 16:10:26 +00:00
ostree-1.pc.in libostree: Expose $OSTREE_FEATURES in the pkg-config file 2017-05-08 18:48:07 +00:00
ostree-async-progress.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-async-progress.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-autocleanups.h lib/repo: Add locking auto cleanup handler 2017-12-05 02:32:47 +00:00
ostree-bloom-private.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-bloom.c lib/bloom: Add some missing preconditions on n_bytes 2017-10-02 18:08:55 +00:00
ostree-bootconfig-parser.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-bootconfig-parser.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-bootloader-grub2.c tree-wide: Update to new libglnx fd APIs 2017-10-11 19:26:10 +00:00
ostree-bootloader-grub2.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-bootloader-syslinux.c lib/syslinux: Port to fd-relative 2017-10-02 16:19:59 +00:00
ostree-bootloader-syslinux.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-bootloader-uboot.c tree-wide: Use autoptr for OstreeKernelArgs 2017-10-25 01:48:56 +00:00
ostree-bootloader-uboot.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-bootloader.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-bootloader.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-chain-input-stream.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-chain-input-stream.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-checksum-input-stream.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-checksum-input-stream.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-cmdprivate.c lib/pull: Split verify_bindings() out into a cmdprivate method 2017-12-14 14:18:44 +00:00
ostree-cmdprivate.h lib/pull: Split verify_bindings() out into a cmdprivate method 2017-12-14 14:18:44 +00:00
ostree-core-private.h lib: Validate metadata structure more consistently during pull 2018-01-12 19:38:34 +00:00
ostree-core.c lib: Validate metadata structure more consistently during pull 2018-01-12 19:38:34 +00:00
ostree-core.h lib/core: Add a "break hardlink" API 2017-12-14 21:56:26 +00:00
ostree-deployment-private.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-deployment.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-deployment.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-diff.c lib/diff: Add compile-time ABI check on 64 bit arches 2017-09-27 18:20:10 +00:00
ostree-diff.h lib/diff: Add compile-time ABI check on 64 bit arches 2017-09-27 18:20:10 +00:00
ostree-dummy-enumtypes.c build: Don't run glib-mkenums if there's nothing to do 2016-05-12 17:15:50 +00:00
ostree-dummy-enumtypes.h build: Don't run glib-mkenums if there's nothing to do 2016-05-12 17:15:50 +00:00
ostree-enumtypes.c.template build: Add -Werror=undef by default, fix fallout 2017-11-06 15:30:14 +00:00
ostree-enumtypes.h.template Make enum generation private by default, export stub symbol 2016-05-12 17:15:50 +00:00
ostree-fetcher-curl.c lib/fetcher: Add version to USER_AGENT string 2018-01-11 14:06:16 +00:00
ostree-fetcher-soup.c lib/fetcher: Add version to USER_AGENT string 2018-01-11 14:06:16 +00:00
ostree-fetcher-uri.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-fetcher-util.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-fetcher-util.h lib/fetcher: Add version to USER_AGENT string 2018-01-11 14:06:16 +00:00
ostree-fetcher.h pull: Add http2=false remote config option 2017-12-07 19:08:01 +00:00
ostree-gpg-verifier.c tree-wide: Update to new libglnx fd APIs 2017-10-11 19:26:10 +00:00
ostree-gpg-verifier.h lib/gpg: Print debug info when reading GPG keys 2017-10-03 13:09:33 +00:00
ostree-gpg-verify-result-private.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-gpg-verify-result.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-gpg-verify-result.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-impl-system-generator.c tree-wide: Update to new libglnx fd APIs 2017-10-11 19:26:10 +00:00
ostree-kernel-args.c tree-wide: Use autoptr for OstreeKernelArgs 2017-10-25 01:48:56 +00:00
ostree-kernel-args.h tree-wide: Use autoptr for OstreeKernelArgs 2017-10-25 01:48:56 +00:00
ostree-libarchive-input-stream.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-libarchive-input-stream.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-libarchive-private.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-linuxfsutil.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-linuxfsutil.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-lzma-common.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-lzma-common.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-lzma-compressor.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-lzma-compressor.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-lzma-decompressor.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-lzma-decompressor.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-metalink.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-metalink.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-mutable-tree.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-mutable-tree.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-ref.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-ref.h lib: Include OstreeRemote and OstreeCollectionRef in GIR 2017-11-10 10:03:44 +00:00
ostree-remote-private.h lib/remote: Store name of remote providing keyring for dynamic remotes 2017-09-27 16:38:07 +00:00
ostree-remote.c lib/remote: Add a method to return the URL 2017-11-28 18:53:25 +00:00
ostree-remote.h lib/remote: Add a method to return the URL 2017-11-28 18:53:25 +00:00
ostree-repo-checkout.c lib/checkout: Validate pathnames during checkout 2018-01-12 19:38:34 +00:00
ostree-repo-commit.c lib: Validate metadata structure more consistently during pull 2018-01-12 19:38:34 +00:00
ostree-repo-deprecated.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-repo-file-enumerator.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-repo-file-enumerator.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-repo-file.c lib/repo-file: Add casts to appease GLib g_object_ref cast PR 2017-12-07 20:04:47 +00:00
ostree-repo-file.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-repo-finder-avahi-parser.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-repo-finder-avahi-private.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-repo-finder-avahi.c lib/repo-finder-avahi: Fix memory corruption of a GVariantIter 2017-10-24 12:55:24 +00:00
ostree-repo-finder-avahi.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-repo-finder-config.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-repo-finder-config.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-repo-finder-mount.c lib/repo-finder-mount: Ignore mounts which have a ‘system’ file system 2017-10-26 01:34:14 +00:00
ostree-repo-finder-mount.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-repo-finder-override.c lib/repo-finder: Add OstreeRepoFinderOverride 2017-10-19 19:11:58 +00:00
ostree-repo-finder-override.h lib/repo-finder: Add OstreeRepoFinderOverride 2017-10-19 19:11:58 +00:00
ostree-repo-finder.c lib/repo: Add (transfer) annotations to various GHashTable arguments 2017-11-14 23:13:14 +00:00
ostree-repo-finder.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-repo-libarchive.c libarchive: Fix assertion error if used with CANONICAL_PERMISSIONS 2017-09-28 19:59:24 +00:00
ostree-repo-private.h lib/repo: Make locking timeout configurable 2017-12-14 15:48:38 +00:00
ostree-repo-prune.c lib/repo: Add an API to mark a commit as partial 2017-12-14 15:51:07 +00:00
ostree-repo-pull-private.h lib/pull: Split verify_bindings() out into a cmdprivate method 2017-12-14 14:18:44 +00:00
ostree-repo-pull.c lib: Validate metadata structure more consistently during pull 2018-01-12 19:38:34 +00:00
ostree-repo-refs.c lib/repo: Clarify documentation for ostree_repo_list_refs{,_ext}() 2017-12-14 14:18:44 +00:00
ostree-repo-static-delta-compilation-analysis.c deltas: Don't try to rollsum/bsdiff .xz files 2017-11-09 03:10:49 +00:00
ostree-repo-static-delta-compilation.c deltas: Add an if0'd bit to print bsdiff objects 2017-11-01 17:38:26 +00:00
ostree-repo-static-delta-core.c tree-wide: Update to new libglnx fd APIs 2017-10-11 19:26:10 +00:00
ostree-repo-static-delta-private.h lib/static-delta: Drop duplicated declaration from private header 2017-12-14 14:18:44 +00:00
ostree-repo-static-delta-processing.c lib: Validate metadata structure more consistently during pull 2018-01-12 19:38:34 +00:00
ostree-repo-traverse.c lib/traverse: Port to new style 2017-11-13 03:33:25 +00:00
ostree-repo.c lib: Validate metadata structure more consistently during pull 2018-01-12 19:38:34 +00:00
ostree-repo.h lib/repo: Add an API to mark a commit as partial 2017-12-14 15:51:07 +00:00
ostree-rollsum.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-rollsum.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-sepolicy-private.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-sepolicy.c tree-wide: Update to new libglnx fd APIs 2017-10-11 19:26:10 +00:00
ostree-sepolicy.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-soup-form.c lib/repo: Add (transfer) annotations to various GHashTable arguments 2017-11-14 23:13:14 +00:00
ostree-soup-uri.c lib/repo: Add (transfer) annotations to various GHashTable arguments 2017-11-14 23:13:14 +00:00
ostree-soup-uri.h libcurl backend 2017-02-09 16:37:45 +00:00
ostree-sysroot-cleanup.c tree-wide: Update to new libglnx fd APIs 2017-10-11 19:26:10 +00:00
ostree-sysroot-deploy.c Support for booting without initramfs 2018-01-10 13:52:58 +00:00
ostree-sysroot-private.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-sysroot-upgrader.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-sysroot-upgrader.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-sysroot.c tree-wide: Use autoptr for OstreeKernelArgs 2017-10-25 01:48:56 +00:00
ostree-sysroot.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-tls-cert-interaction.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-tls-cert-interaction.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-types.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-varint.c tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-varint.h tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree-version.h.in tree-wide: Remove Emacs modelines 2017-09-21 21:38:34 +00:00
ostree.h lib/repo-finder: Add OstreeRepoFinderOverride 2017-10-19 19:11:58 +00:00

README.md

Repository design

At the heart of OSTree is the repository. It's very similar to git, with the idea of content-addressed storage. However, OSTree is designed to store operating system binaries, not source code. There are several consequences to this. The key difference as compared to git is that the OSTree definition of "content" includes key Unix metadata such as owner uid/gid, as well as all extended attributes.

Essentially OSTree is designed so that if two files have the same OSTree checksum, it's safe to replace them with a hard link. This fundamental design means that an OSTree repository imposes negligible overhead. In contrast, a git repository stores copies of zlib-compressed data.

Key differences versus git

  • As mentioned above, extended attributes and owner uid/gid are versioned
  • Optimized for Unix hardlinks between repository and checkout
  • SHA256 instead of SHA1
  • Support for empty directories

Binary files

While this is still in planning, I plan to heavily optimize OSTree for versioning ELF operating systems. In industry jargon, this would be "content-aware storage".

Trimming history

OSTree will also be optimized to trim intermediate history; in theory one can regenerate binaries from corresponding (git) source code, so we don't need to keep all possible builds over time.

MILESTONE 1

  • Basic pack files (like git)

MILESTONE 2

  • Store checksums as ay
  • Drop version/metadata from tree/dirmeta objects
  • Add index size to superindex, pack size to index
    • So pull can calculate how much we need to download
  • Split pack files into metadata/data
  • pull: Extract all we can from each packfile one at a time, then delete it
  • Restructure repository so that links can be generated as a cache; i.e. objects/raw, pack files are now the canonical
  • For files, checksum combination of metadata variant + raw data
    • i.e. there is only OSTREE_OBJECT_TYPE_FILE (again)

MILESTONE 3

  • Drop archive/raw distinction - archive repositories always generate packfiles per commit
  • Include git packv4 ideas:
    • metadata packfiles have string dictionary (tree filenames and checksums)
    • data packfiles match up similar objects
  • Rolling checksums for partitioning large files? Kernel debuginfo
  • Improved pack clustering
    • file fingerprinting?
  • ELF-x86 aware deltas

git: http://git-scm.com/ Venti: http://plan9.bell-labs.com/magic/man2html/6/venti Elephant FS: http://www.hpl.hp.com/personal/Alistair_Veitch/papers/elephant-hotos/index.html

Compression

xdelta: http://xdelta.org/ Bsdiff: http://www.daemonology.net/bsdiff/ xz: http://tukaani.org/xz/