├── docs └── index.md ├── tests ├── kolainst │ ├── destructive │ │ ├── data │ │ ├── var-mount.sh │ │ ├── staged-delay.sh │ │ ├── itest-bare-root.sh │ │ └── itest-deploy-selinux.sh │ ├── nondestructive │ │ ├── data │ │ ├── libtest-core.sh │ │ ├── itest-remotes.sh │ │ ├── itest-bareuser-nouserxattrs.sh │ │ ├── itest-bare-unit.sh │ │ └── itest-bare-user-root.sh │ ├── README.md │ └── Makefile ├── gpghome │ ├── pubring.gpg │ ├── secring.gpg │ ├── trustdb.gpg │ ├── trusted │ │ └── pubring.gpg │ ├── revocations │ │ ├── key1.rev │ │ ├── key2.rev │ │ └── key3.rev │ ├── key1.asc │ ├── key2.asc │ └── key3.asc ├── inst │ ├── .gitignore │ ├── itest-macro │ │ ├── Cargo.toml │ │ └── src │ │ │ └── itest-macro.rs │ ├── src │ │ ├── sysroot.rs │ │ └── insttest.rs │ └── Cargo.toml ├── libtest-core.sh ├── ostree-grub-generator ├── kola │ └── nondestructive │ │ └── .gitignore ├── ostree.supp ├── coccinelle │ ├── raw-free.cocci │ └── README.md ├── fah-deltadata-new.tar.xz ├── fah-deltadata-old.tar.xz ├── gpg-verify-data │ ├── lgpl2.sig │ ├── lgpl2.sig0 │ ├── lgpl2.sig1 │ ├── lgpl2.sig2 │ ├── lgpl2.sig3 │ ├── lgpl2.sig4 │ ├── pubring.gpg │ ├── secring.gpg │ ├── trustdb.gpg │ ├── gpg.conf │ └── README.md ├── ostree-path-traverse.tar.gz ├── pre-signed-pull-data.tar.gz ├── pre-endian-deltas-repo-big.tar.xz ├── pre-endian-deltas-repo-little.tar.xz ├── get-byte-order.c ├── .gitignore ├── runkola ├── coccinelle.sh ├── test-pull-bare.sh ├── test-basic.sh ├── test-pull-bareuser.sh ├── test-pull2-bareuseronly.sh ├── test-pull-bareuseronly.sh ├── test-admin-deploy-grub2.sh ├── test-reset-nonlinear.sh ├── test-init-collections.sh ├── test-remote-add-collections.sh ├── test-include-ostree-h.c ├── test-oldstyle-partial.sh ├── test-pull-untrusted.sh ├── test-archivez.sh ├── libostreetest.h ├── test-admin-deploy-clean.sh ├── test-pull-commit-only.sh ├── test-pull-large-metadata.sh ├── test-admin-pull-deploy-commit.sh ├── test-pull-resume.sh ├── test-pre-signed-pull.sh ├── test-xattrs.sh ├── test-pull-depth.sh ├── test-basic-root.sh ├── test-parent.sh ├── test-ot-opt-utils.c ├── test-admin-deploy-nomerge.sh ├── test-pull-basicauth.sh └── test-remote-headers.sh ├── CONTRIBUTING.md ├── apidoc ├── ostree-experimental-sections.txt ├── .gitignore └── ostree-docs.xml ├── rust ├── .gitignore ├── cargo-vendor-config └── Cargo.toml ├── .dir-locals.el ├── ci ├── prow │ └── Dockerfile ├── travis-Dockerfile.in ├── fah29-insttests.sh ├── provision-prep.sh ├── rpmbuild-cwd ├── make-git-snapshot.sh ├── installdeps.sh ├── build.sh ├── build-rpm.sh ├── Makefile.dist-packaging ├── flatpak.sh ├── ci-release-build.sh ├── rpmostree.sh ├── libbuild.sh └── build-check.sh ├── src ├── boot │ ├── mkinitcpio │ │ ├── ostree-mkinitcpio.conf │ │ └── ostree │ ├── dracut │ │ ├── ostree.conf │ │ └── module-setup.sh │ ├── ostree-tmpfiles.conf │ ├── ostree-finalize-staged.path │ ├── ostree-prepare-root.service │ ├── ostree-remount.service │ └── ostree-finalize-staged.service ├── libostree │ ├── README-gpg │ ├── ostree-1.pc.in │ ├── ostree-lzma-common.h │ ├── ostree-dummy-enumtypes.h │ ├── ostree-gpg-verify-result-private.h │ ├── ostree-repo-finder-avahi-private.h │ ├── ostree-dummy-enumtypes.c │ ├── ostree-linuxfsutil.h │ ├── ostree-varint.h │ ├── ostree-enumtypes.h.template │ ├── libostree-devel.sym │ ├── ostree-bootloader-zipl.h │ ├── ostree-types.h │ ├── ostree-bootloader-syslinux.h │ ├── ostree-rollsum.h │ ├── ostree-bootloader-uboot.h │ ├── ostree-bootloader-grub2.h │ ├── ostree.h │ ├── ostree-sepolicy-private.h │ ├── ostree-deployment-private.h │ ├── ostree-enumtypes.c.template │ ├── ostree-remote.h │ ├── ostree-lzma-compressor.h │ ├── bupsplit.h │ ├── ostree-lzma-decompressor.h │ ├── ostree-cmdprivate.c │ ├── ostree-repo-finder-config.h │ ├── ostree-repo-finder-mount.h │ └── ostree-tls-cert-interaction.h ├── ostree │ ├── parse-datetime.h │ ├── ot-editor.h │ ├── ot-admin-instutil-builtins.h │ ├── ot-remote-cookie-util.h │ ├── ot-dump.h │ ├── ot-builtin-trivial-httpd.c │ ├── ot-remote-builtins.h │ ├── ot-admin-builtins.h │ ├── ot-admin-builtin-cleanup.c │ ├── ot-admin-functions.h │ ├── ot-builtins.h │ ├── ot-remote-builtin-show-url.c │ └── ot-remote-builtin-list-cookies.c ├── switchroot │ └── switchroot.sh ├── libotutil │ ├── ot-opt-utils.h │ ├── ot-opt-utils.c │ ├── ot-unix-utils.h │ ├── ot-tool-util.h │ ├── ot-variant-utils.h │ └── ot-gpg-utils.h └── rofiles-fuse │ ├── Makefile-inc.am │ └── README.md ├── .editorconfig ├── .gitmodules ├── coccinelle ├── README.md ├── newstyle.cocci └── new-error.cocci ├── .vimrc ├── OWNERS ├── mkdocs.yml ├── .travis.yml ├── Makefile-bash.am ├── autogen.sh ├── cfg.mk ├── ostree.doap ├── manual-tests └── static-delta-generate-crosscheck.sh ├── TODO ├── Makefile-decls.am └── Makefile-otutil.am /docs/index.md: -------------------------------------------------------------------------------- 1 | ../README.md -------------------------------------------------------------------------------- /tests/kolainst/destructive/data: -------------------------------------------------------------------------------- 1 | .. -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | docs/CONTRIBUTING.md -------------------------------------------------------------------------------- /tests/kolainst/nondestructive/data: -------------------------------------------------------------------------------- 1 | .. -------------------------------------------------------------------------------- /apidoc/ostree-experimental-sections.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rust/.gitignore: -------------------------------------------------------------------------------- 1 | Cargo.lock 2 | target/ 3 | -------------------------------------------------------------------------------- /tests/gpghome/pubring.gpg: -------------------------------------------------------------------------------- 1 | trusted/pubring.gpg -------------------------------------------------------------------------------- /tests/inst/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | Cargo.lock 3 | -------------------------------------------------------------------------------- /tests/libtest-core.sh: -------------------------------------------------------------------------------- 1 | kolainst/libtest-core.sh -------------------------------------------------------------------------------- /tests/kolainst/nondestructive/libtest-core.sh: -------------------------------------------------------------------------------- 1 | ../libtest-core.sh -------------------------------------------------------------------------------- /tests/ostree-grub-generator: -------------------------------------------------------------------------------- 1 | ../src/boot/grub2/ostree-grub-generator -------------------------------------------------------------------------------- /.dir-locals.el: -------------------------------------------------------------------------------- 1 | ((c-mode . ((indent-tabs-mode . nil) (c-file-style . "gnu")))) 2 | -------------------------------------------------------------------------------- /tests/kola/nondestructive/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by runkola.sh 2 | insttest-rs 3 | -------------------------------------------------------------------------------- /tests/ostree.supp: -------------------------------------------------------------------------------- 1 | # Use this to suppress "possibly lost" for global statics 2 | -------------------------------------------------------------------------------- /tests/kolainst/README.md: -------------------------------------------------------------------------------- 1 | This uses https://github.com/coreos/coreos-assembler/pull/1252 2 | -------------------------------------------------------------------------------- /tests/gpghome/secring.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjtug/ostree/master/tests/gpghome/secring.gpg -------------------------------------------------------------------------------- /tests/gpghome/trustdb.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjtug/ostree/master/tests/gpghome/trustdb.gpg -------------------------------------------------------------------------------- /tests/coccinelle/raw-free.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression p; 3 | @@ 4 | - g_error_free (p); 5 | + g_clear_error (&p); 6 | -------------------------------------------------------------------------------- /tests/fah-deltadata-new.tar.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjtug/ostree/master/tests/fah-deltadata-new.tar.xz -------------------------------------------------------------------------------- /tests/fah-deltadata-old.tar.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjtug/ostree/master/tests/fah-deltadata-old.tar.xz -------------------------------------------------------------------------------- /tests/gpg-verify-data/lgpl2.sig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjtug/ostree/master/tests/gpg-verify-data/lgpl2.sig -------------------------------------------------------------------------------- /ci/prow/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM registry.fedoraproject.org/fedora:30 2 | WORKDIR /src 3 | COPY . . 4 | RUN ./ci/build.sh 5 | -------------------------------------------------------------------------------- /tests/gpg-verify-data/lgpl2.sig0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjtug/ostree/master/tests/gpg-verify-data/lgpl2.sig0 -------------------------------------------------------------------------------- /tests/gpg-verify-data/lgpl2.sig1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjtug/ostree/master/tests/gpg-verify-data/lgpl2.sig1 -------------------------------------------------------------------------------- /tests/gpg-verify-data/lgpl2.sig2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjtug/ostree/master/tests/gpg-verify-data/lgpl2.sig2 -------------------------------------------------------------------------------- /tests/gpg-verify-data/lgpl2.sig3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjtug/ostree/master/tests/gpg-verify-data/lgpl2.sig3 -------------------------------------------------------------------------------- /tests/gpg-verify-data/lgpl2.sig4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjtug/ostree/master/tests/gpg-verify-data/lgpl2.sig4 -------------------------------------------------------------------------------- /tests/gpg-verify-data/pubring.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjtug/ostree/master/tests/gpg-verify-data/pubring.gpg -------------------------------------------------------------------------------- /tests/gpg-verify-data/secring.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjtug/ostree/master/tests/gpg-verify-data/secring.gpg -------------------------------------------------------------------------------- /tests/gpg-verify-data/trustdb.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjtug/ostree/master/tests/gpg-verify-data/trustdb.gpg -------------------------------------------------------------------------------- /tests/gpghome/trusted/pubring.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjtug/ostree/master/tests/gpghome/trusted/pubring.gpg -------------------------------------------------------------------------------- /tests/ostree-path-traverse.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjtug/ostree/master/tests/ostree-path-traverse.tar.gz -------------------------------------------------------------------------------- /tests/pre-signed-pull-data.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjtug/ostree/master/tests/pre-signed-pull-data.tar.gz -------------------------------------------------------------------------------- /src/boot/mkinitcpio/ostree-mkinitcpio.conf: -------------------------------------------------------------------------------- 1 | HOOKS="base systemd ostree autodetect modconf block filesystems keyboard fsck" 2 | -------------------------------------------------------------------------------- /tests/pre-endian-deltas-repo-big.tar.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjtug/ostree/master/tests/pre-endian-deltas-repo-big.tar.xz -------------------------------------------------------------------------------- /tests/coccinelle/README.md: -------------------------------------------------------------------------------- 1 | Add patches here which should never match in the code; i.e. the suggested 2 | replacement may be junk. 3 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.[ch]] 2 | indent_style = space 3 | indent_size = 2 4 | trim_trailing_whitespace = true 5 | indent_brace_style = gnu 6 | -------------------------------------------------------------------------------- /src/libostree/README-gpg: -------------------------------------------------------------------------------- 1 | Any GPG keyring files ending in ".gpg" placed in this directory will 2 | be automatically trusted by OSTree. 3 | -------------------------------------------------------------------------------- /tests/pre-endian-deltas-repo-little.tar.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjtug/ostree/master/tests/pre-endian-deltas-repo-little.tar.xz -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libglnx"] 2 | path = libglnx 3 | url = https://gitlab.gnome.org/GNOME/libglnx.git 4 | [submodule "bsdiff"] 5 | path = bsdiff 6 | url = https://github.com/mendsley/bsdiff 7 | -------------------------------------------------------------------------------- /tests/gpg-verify-data/gpg.conf: -------------------------------------------------------------------------------- 1 | # This prevents GPG from attempting to create lock files when accessing 2 | # the keyrings and trust database. Necessary for "distcheck", since the 3 | # GPG homedir will be read-only. 4 | lock-never 5 | -------------------------------------------------------------------------------- /tests/get-byte-order.c: -------------------------------------------------------------------------------- 1 | /* Helper for OSTree tests: return host byte order */ 2 | 3 | #include "config.h" 4 | 5 | #include 6 | 7 | int 8 | main (void) 9 | { 10 | g_print ("%d\n", G_BYTE_ORDER); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /rust/cargo-vendor-config: -------------------------------------------------------------------------------- 1 | # This is used after `cargo vendor` is run from `make dist` 2 | 3 | [source.crates-io] 4 | registry = 'https://github.com/rust-lang/crates.io-index' 5 | replace-with = 'vendored-sources' 6 | 7 | [source.vendored-sources] 8 | directory = './vendor' 9 | -------------------------------------------------------------------------------- /coccinelle/README.md: -------------------------------------------------------------------------------- 1 | This is a directory of semantic patches 2 | to apply with coccinelle, like the collection in systemd: 3 | https://github.com/systemd/systemd/tree/29f32655842a0712e8db482bcefc4da8908460c8/coccinelle 4 | 5 | See also the tests/coccinelle directory which 6 | has spatches which detect errors. 7 | -------------------------------------------------------------------------------- /tests/inst/itest-macro/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "itest-macro" 3 | version = "0.1.0" 4 | edition = "2018" 5 | 6 | [lib] 7 | proc-macro = true 8 | path = "src/itest-macro.rs" 9 | 10 | [dependencies] 11 | quote = "1.0.3" 12 | proc-macro2 = "1.0.10" 13 | syn = { version = "1.0.3", features = ["full"] } 14 | anyhow = "1.0" 15 | -------------------------------------------------------------------------------- /rust/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bupsplit" 3 | version = "0.0.1" 4 | authors = ["Colin Walters "] 5 | 6 | [dependencies] 7 | libc = "0.2" 8 | 9 | [lib] 10 | name = "bupsplit_rs" 11 | path = "src/bupsplit.rs" 12 | crate-type = ["staticlib"] 13 | 14 | [profile.release] 15 | panic = "abort" 16 | lto = true 17 | -------------------------------------------------------------------------------- /src/libostree/ostree-1.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | features=@OSTREE_FEATURES@ 6 | 7 | Name: OSTree 8 | Description: Git for operating system binaries 9 | Version: @VERSION@ 10 | Requires: gio-unix-2.0 11 | Libs: -L${libdir} -lostree-1 12 | Cflags: -I${includedir}/ostree-1 13 | -------------------------------------------------------------------------------- /ci/travis-Dockerfile.in: -------------------------------------------------------------------------------- 1 | FROM @ci_docker@ 2 | ENV container docker 3 | 4 | ADD ci/travis-install.sh /travis-install.sh 5 | RUN ci_suite="@ci_suite@" ci_distro="@ci_distro@" ci_pkgs="@ci_pkgs@" ci_in_docker=yes /travis-install.sh 6 | 7 | ADD . /home/user/ostree 8 | RUN chown -R user:user /home/user/ostree 9 | WORKDIR /home/user/ostree 10 | USER user 11 | -------------------------------------------------------------------------------- /ci/fah29-insttests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | set -xeuo pipefail 3 | 4 | ./tests/installed/provision.sh 5 | # TODO: enhance papr to have caching, a bit like https://docs.travis-ci.com/user/caching/ 6 | cd tests/installed 7 | curl -Lo fedora-atomic-host.qcow2 https://getfedora.org/atomic_qcow2_latest 8 | exec env "TEST_SUBJECTS=$(pwd)/fedora-atomic-host.qcow2" ./run.sh 9 | -------------------------------------------------------------------------------- /.vimrc: -------------------------------------------------------------------------------- 1 | set expandtab 2 | set tabstop=8 3 | set softtabstop=2 4 | set shiftwidth=2 5 | 6 | " Let's try to not go longer than 92 7 | set textwidth=92 8 | autocmd BufNewFile,BufRead *.c,*.h set textwidth=92 9 | 10 | " This is the same as the default minus 0{, which is really annoying otherwise 11 | " with our coding style. 12 | set cinkeys=0},0),:,0#,!^F,o,O,e 13 | -------------------------------------------------------------------------------- /tests/gpg-verify-data/README.md: -------------------------------------------------------------------------------- 1 | This is a GPG config directory for use with the OstreeGpgVerifyResult 2 | test cases. The test data (`lgpl2`) is signed with a variety of valid 3 | and invalid GPG keys in a detached signature file (`lgpl2.sig`). In 4 | addition, each detached signature is available in a separate file 5 | (`lgpgl2.sig`). 6 | 7 | The passphrase for all the keys is `redhat`. 8 | -------------------------------------------------------------------------------- /coccinelle/newstyle.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression p; 3 | @@ 4 | - glnx_set_error_from_errno (p); 5 | - goto out; 6 | + return glnx_throw_errno (p); 7 | @@ 8 | expression p; 9 | @@ 10 | - if (!p) 11 | - goto out; 12 | + if (!p) 13 | + return FALSE; 14 | @@ 15 | expression p; 16 | @@ 17 | - gboolean ret = FALSE; 18 | ... 19 | - ret = TRUE; 20 | - out: 21 | - return ret; 22 | + return TRUE; 23 | -------------------------------------------------------------------------------- /src/boot/mkinitcpio/ostree: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | build() { 4 | add_binary /usr/lib/ostree/ostree-prepare-root 5 | add_binary /usr/lib/ostree/ostree-remount 6 | 7 | add_file /usr/lib/systemd/system/ostree-prepare-root.service 8 | add_symlink /usr/lib/systemd/system/initrd-switch-root.target.wants/ostree-prepare-root.service \ 9 | /usr/lib/systemd/system/ostree-prepare-root.service 10 | } 11 | -------------------------------------------------------------------------------- /tests/kolainst/nondestructive/itest-remotes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Test that we didn't regress /etc/ostree/remotes.d handling 4 | 5 | set -xeuo pipefail 6 | 7 | . ${KOLA_EXT_DATA}/libinsttest.sh 8 | date 9 | 10 | prepare_tmpdir 11 | trap _tmpdir_cleanup EXIT 12 | 13 | ostree remote list > remotes.txt 14 | if ! test -s remotes.txt; then 15 | assert_not_reached "no ostree remotes" 16 | fi 17 | date 18 | -------------------------------------------------------------------------------- /ci/provision-prep.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | # Prepare the current environment 3 | 4 | set -xeuo pipefail 5 | 6 | dn=$(dirname $0) 7 | . ${dn}/libbuild.sh 8 | pkg_upgrade 9 | pkg_install_buildroot 10 | pkg_install sudo which attr fuse strace \ 11 | libubsan libasan libtsan PyYAML elfutils 12 | pkg_install_if_os fedora gjs gnome-desktop-testing parallel coccinelle clang 13 | 14 | if test -n "${CI_PKGS:-}"; then 15 | pkg_install ${CI_PKGS} 16 | fi 17 | -------------------------------------------------------------------------------- /tests/.gitignore: -------------------------------------------------------------------------------- 1 | !Makefile 2 | *.log 3 | *.test 4 | *.trs 5 | ostree-http-server 6 | repo-finder-mount 7 | run-apache 8 | tmpdir-lifecycle 9 | test-rollsum 10 | test-bloom 11 | test-bsdiff 12 | test-checksum 13 | test-gpg-verify-result 14 | test-include-ostree-h 15 | test-keyfile-utils 16 | test-mutable-tree 17 | test-ot-opt-utils 18 | test-ot-tool-util 19 | test-ot-unix-utils 20 | test-repo 21 | test-repo-finder-avahi 22 | test-repo-finder-config 23 | test-repo-finder-mount 24 | test-rollsum-cli 25 | test-kargs 26 | -------------------------------------------------------------------------------- /tests/runkola: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | # Generate a new qemu image and run tests 4 | top=$(git rev-parse --show-toplevel) 5 | cd ${top} 6 | make 7 | cosa build-fast 8 | image=$(ls fastbuild-*-qemu.qcow2 | head -1) 9 | if [ -z "${image}" ]; then 10 | echo "failed to find image"; exit 1 11 | fi 12 | if [ -z "$@" ]; then 13 | set -- 'ext.ostree.*' "$@" 14 | fi 15 | set -x 16 | make -C tests/kolainst 17 | sudo make -C tests/kolainst install 18 | exec kola run -p qemu --qemu-image "${image}" -E ${top} "$@" 19 | -------------------------------------------------------------------------------- /coccinelle/new-error.cocci: -------------------------------------------------------------------------------- 1 | // Conversion for G_IO_ERROR_FAILED that could be glnx_throw() 2 | @@ 3 | expression p; 4 | @@ 5 | - g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, p); 6 | - return FALSE; 7 | + return glnx_throw (error, "%s", p); 8 | @@ 9 | expression p; 10 | @@ 11 | - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, p); 12 | - return FALSE; 13 | + return glnx_throw (error, p); 14 | @@ 15 | expression p, q; 16 | @@ 17 | - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, p, q); 18 | - return FALSE; 19 | + return glnx_throw (error, p, q); 20 | -------------------------------------------------------------------------------- /ci/rpmbuild-cwd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # rpmbuild-cwd: 3 | # Run "rpmbuild", defining all RPM variables to use the current directory. 4 | # This matches Fedora's system. 5 | # 6 | # Licensed under the new-BSD license (http://www.opensource.org/licenses/bsd-license.php) 7 | # Copyright (C) 2010 Red Hat, Inc. 8 | # Written by Colin Walters 9 | 10 | pwd=$(pwd) 11 | exec rpmbuild --define "_sourcedir ${pwd}" --define "_specdir ${pwd}" --define "_builddir ${pwd}" --define "_srcrpmdir ${pwd}" --define "_rpmdir ${pwd}" --define "_buildrootdir ${pwd}/.build" "$@" 12 | -------------------------------------------------------------------------------- /tests/kolainst/Makefile: -------------------------------------------------------------------------------- 1 | DESTDIR ?= 2 | 3 | TESTDIRS := $(shell find -mindepth 1 -maxdepth 1 -type d) 4 | LIBSCRIPTS := $(shell ls *.sh) 5 | 6 | KOLA_TESTDIR = $(DESTDIR)/usr/lib/coreos-assembler/tests/kola/ostree/ 7 | 8 | all: 9 | for x in $(LIBSCRIPTS); do bash -n "$${x}"; done 10 | (cd ../inst && cargo build --release) 11 | 12 | install: all 13 | install -D -m 0644 -t $(KOLA_TESTDIR) $(LIBSCRIPTS) 14 | for x in $(TESTDIRS); do rsync -rlv ./$${x} $(KOLA_TESTDIR)/; done 15 | install -D -m 0755 -t $(KOLA_TESTDIR)/nondestructive-rs ../inst/target/release/ostree-test 16 | -------------------------------------------------------------------------------- /tests/gpghome/revocations/key1.rev: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | Comment: This is a revocation certificate 3 | 4 | iQE9BCABCgAnFiEEXmXedascUBhi1HY0f8oj2Ecs2voFAl0MvqgJHQBUZXN0aW5n 5 | AAoJEH/KI9hHLNr6/dQH/iPZjfJgFAc/TIR4xE4kB0yL4zdMqxgV1ef/atQDLEN4 6 | MBiqIltzb8WyG+cpNfNZgFmqXmCRN+1IAla9piixe76ZwOqcQ6S5MU/8nMcyMsD9 7 | edg+9sg0DH8SEzejVma3ZLfaJ/6ZpU7c6a4vCPNcRBC7PxAvAc0LnAN6KQYGU7GR 8 | gv2k/JsGYgvmUAajhVFy0jc4jGkhRBHMDksGGFdYY94RATFF4gWtlUXyRYMTXBCf 9 | eM3bxEeSMbU7lXCZg9zjoxP6XzJuNW1SLz3zL90GnO19uNh8Pf6pHmkCNTO/L1Ua 10 | Cc6fb3ubtdqgs6an84U/aod1VcK7BNASqZ2gYUsF2KE= 11 | =owvo 12 | -----END PGP PUBLIC KEY BLOCK----- 13 | -------------------------------------------------------------------------------- /tests/gpghome/revocations/key2.rev: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | Comment: This is a revocation certificate 3 | 4 | iQE9BCABCgAnFiEEezsQINdEeWh/2yJz2CKM/sqVDUEFAl0Mvs4JHQBUZXN0aW5n 5 | AAoJENgijP7KlQ1BzH4IAMUoTrW6XraDYq/d/b0qa3sZ1NTBPUXLp4gFaedZwKk/ 6 | AKSUCK05RWRQO3HrSvmhdSUF6/9tFLGpbu7P56ihjAnq2vpzRyeNTEGQ02IzfCpM 7 | SJup0R6iA7KmjiDutDoEgjhAzxCKbnU71SQ3PmjyaQT1KCBCDJVptcY6HDbo0dRN 8 | vcjTfjtFqkPgqbHyXwGv3rlm4uctSVfACrOS/fKF4Q9Fs4prsUXjQpGLaTHdxhiL 9 | pMRCTfZ4DBEMwAY7s9FpMpIh9rdOwE+zkv5CsE0uJVZq0WW5r0CBDCta6Sopt6uk 10 | pIA+QHL9GPOrG2E3SJxyIBC37Sl40MGAJQ1djmecIGk= 11 | =0KEe 12 | -----END PGP PUBLIC KEY BLOCK----- 13 | -------------------------------------------------------------------------------- /tests/gpghome/revocations/key3.rev: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | Comment: This is a revocation certificate 3 | 4 | iQE9BCABCgAnFiEEfSnPBguCac32O/vdDRX6599ETWcFAl0MvuYJHQBUZXN0aW5n 5 | AAoJEA0V+uffRE1n/p8H/3mmSK2gtbxJ5sfu1z44ra82fLRAUupJzf53dAvvJCEK 6 | 4RSJFtHYu+hoPVFd9bmToxo2YQWe67MMZW7cHtq9D/a755SYOrty//KpXsGS22W/ 7 | ZGatBjl36zuE6BoR18Q6VAMgVBwovPSlSuCEW+Ro8JZYyA/LbA95AnMprNod6Jw9 8 | VSsGC39au5rUlhEOHLL1Iw3dl4blxa6tf/roljbXzaN+Qh2/ez7Cy532oocak2FL 9 | bbblBGrIdfYLAXpLqhnQk2vgEHZ+ZylvStBndpLWwEskXhmaHpW7+WapFhLCUOr+ 10 | arzbc9XQ7ghhF9hSoKiToJqU5PRjaOex85BEDwE5gWY= 11 | =ykAF 12 | -----END PGP PUBLIC KEY BLOCK----- 13 | -------------------------------------------------------------------------------- /OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs: https://git.k8s.io/community/contributors/guide/owners.md 2 | 3 | # Keep these lists in alphabetical order (just to avoid ordering implying anything) 4 | # Changes to this list can be done via regular pull requests. A generally good 5 | # approach can be to just start reviewing pull requests - if you do that enough 6 | # and understand the libostree code base, feel free to submit a PR to add 7 | # yourself to one of these lists. 8 | # Use the responsibility to merge carefully. 9 | approvers: 10 | - cgwalters 11 | - jlebon 12 | - pwithnall 13 | - wmanley 14 | reviewers: 15 | - lucab 16 | - mwleeds 17 | - rfairley 18 | - d4s 19 | -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: OSTree 2 | pages: 3 | - Home: 'index.md' 4 | - Contributing: 'CONTRIBUTING.md' 5 | - Contributing Tutorial: 'contributing-tutorial.md' 6 | - Manual: 7 | - Introduction: 'manual/introduction.md' 8 | - Repository: 'manual/repo.md' 9 | - Deployments: 'manual/deployment.md' 10 | - Atomic Upgrades: 'manual/atomic-upgrades.md' 11 | - Adapting Existing Systems: 'manual/adapting-existing.md' 12 | - Formats: 'manual/formats.md' 13 | - Build Systems and Repos: 'manual/buildsystem-and-repos.md' 14 | - Repository Management: 'manual/repository-management.md' 15 | - Related Projects: 'manual/related-projects.md' 16 | -------------------------------------------------------------------------------- /tests/kolainst/destructive/var-mount.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # https://github.com/ostreedev/ostree/issues/1667 3 | set -xeuo pipefail 4 | 5 | . ${KOLA_EXT_DATA}/libinsttest.sh 6 | 7 | case "${AUTOPKGTEST_REBOOT_MARK:-}" in 8 | "") 9 | require_writable_sysroot 10 | # Hack this off for now 11 | chattr -i /sysroot 12 | cp -a /var /sysroot/myvar 13 | touch /sysroot/myvar/somenewfile 14 | echo '/sysroot/myvar /var none bind 0 0' >> /etc/fstab 15 | /tmp/autopkgtest-reboot "2" 16 | ;; 17 | "2") 18 | systemctl status var.mount 19 | test -f /var/somenewfile 20 | ;; 21 | *) fatal "Unexpected AUTOPKGTEST_REBOOT_MARK=${AUTOPKGTEST_REBOOT_MARK}" ;; 22 | esac 23 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | dist: trusty 3 | sudo: required 4 | 5 | env: 6 | # debian has libsodium-dev, ubuntu doesn't in core at least 7 | - ci_docker=debian:buster-slim ci_distro=debian ci_suite=stretch ci_configopts="--with-ed25519-libsodium" ci_pkgs="libsodium-dev" 8 | - ci_docker=debian:buster-slim ci_distro=debian ci_suite=stretch ci_configopts="--with-curl --with-ed25519-libsodium --without-gpgme" ci_pkgs="libsodium-dev" 9 | - ci_docker=ubuntu:xenial ci_distro=ubuntu ci_suite=xenial 10 | - ci_docker=ubuntu:bionic ci_distro=ubuntu ci_suite=bionic 11 | 12 | script: 13 | - ci/travis-install.sh 14 | - ci_parallel=2 ci_sudo=yes ci/travis-build.sh 15 | 16 | notifications: 17 | email: false 18 | -------------------------------------------------------------------------------- /tests/kolainst/nondestructive/itest-bareuser-nouserxattrs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Test that initializing a bare-user repo on tmpfs fails 4 | # Maybe at some point this will be fixed in the kernel 5 | # but I doubt it'll be soon 6 | # https://www.spinics.net/lists/linux-mm/msg109775.html 7 | 8 | set -xeuo pipefail 9 | 10 | . ${KOLA_EXT_DATA}/libinsttest.sh 11 | 12 | prepare_tmpdir 13 | trap _tmpdir_cleanup EXIT 14 | date 15 | 16 | mkdir mnt 17 | mount -t tmpfs tmpfs mnt 18 | if ostree --repo=mnt/repo init --mode=bare-user 2>err.txt; then 19 | umount mnt 20 | assert_not_reached "bare-user on tmpfs worked?" 21 | fi 22 | umount mnt 23 | assert_file_has_content err.txt "Operation not supported" 24 | date 25 | -------------------------------------------------------------------------------- /tests/coccinelle.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Run the .cocci files in the tests directory; these act 4 | # as a blacklist. 5 | 6 | set -euo pipefail 7 | 8 | . $(dirname $0)/libtest.sh 9 | 10 | if ! spatch --version 2>/dev/null; then 11 | skip "no spatch; get it from http://coccinelle.lip6.fr/" 12 | fi 13 | 14 | if test -z "${OSTREE_UNINSTALLED_SRCDIR:-}"; then 15 | skip "running installed?" 16 | fi 17 | 18 | coccitests=$(ls $(dirname $0)/coccinelle/*.cocci) 19 | echo "1.."$(echo ${coccitests} | wc -l) 20 | 21 | for cocci in $(dirname $0)/coccinelle/*.cocci; do 22 | echo "Running: ${cocci}" 23 | spatch --very-quiet --dir ${OSTREE_UNINSTALLED_SRCDIR} ${cocci} > cocci.out 24 | if test -s cocci.out; then 25 | sed -e 's/^/# /' < cocci.out >&2 26 | fatal "Failed semantic patch: ${cocci}" 27 | fi 28 | echo ok ${cocci} 29 | done 30 | -------------------------------------------------------------------------------- /apidoc/.gitignore: -------------------------------------------------------------------------------- 1 | *.lo 2 | *.o 3 | .deps 4 | .libs 5 | /*.bak 6 | /*.gcda 7 | /*.gcno 8 | /*.orig 9 | /*.rej 10 | /*.tab.c 11 | /*~ 12 | /.*.sw[nop] 13 | /.dirstamp 14 | /.gitignore 15 | /GPATH 16 | /GRTAGS 17 | /GSYMS 18 | /GTAGS 19 | /ID 20 | /Makefile 21 | /Makefile.in 22 | /TAGS 23 | /gtkdoc-check.test 24 | /html 25 | /html-build.stamp 26 | /html.stamp 27 | /ostree-decl-list.txt 28 | /ostree-decl.txt 29 | /ostree-undeclared.txt 30 | /ostree-undocumented.txt 31 | /ostree-unused.txt 32 | /ostree.args 33 | /ostree.hierarchy 34 | /ostree.interfaces 35 | /ostree-overrides.txt 36 | /ostree.pdf 37 | /ostree.prerequisites 38 | /ostree.signals 39 | /ostree.types 40 | /pdf-build.stamp 41 | /pdf.stamp 42 | /scan-build.stamp 43 | /setup-build.stamp 44 | /sgml-build.stamp 45 | /sgml.stamp 46 | /so_locations 47 | /tags 48 | /tmpl 49 | /tmpl/*.bak 50 | /tmpl/ostree-unused.sgml 51 | /xml 52 | /version.xml 53 | _libs 54 | -------------------------------------------------------------------------------- /src/boot/dracut/ostree.conf: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2013 Colin Walters 2 | # 3 | # This library is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU Lesser General Public 5 | # License as published by the Free Software Foundation; either 6 | # version 2 of the License, or (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public 14 | # License along with this library; if not, write to the 15 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 | # Boston, MA 02111-1307, USA. 17 | 18 | add_dracutmodules+=" ostree systemd " 19 | -------------------------------------------------------------------------------- /ci/make-git-snapshot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | srcdir=$1 4 | shift 5 | PKG_VER=$1 6 | shift 7 | GITREV=$1 8 | shift 9 | 10 | TARFILE=${PKG_VER}.tar 11 | TARFILE_TMP=${TARFILE}.tmp 12 | 13 | set -x 14 | set -e 15 | 16 | test -n "${srcdir}" 17 | test -n "${PKG_VER}" 18 | test -n "${GITREV}" 19 | 20 | TOP=$(git rev-parse --show-toplevel) 21 | 22 | echo "Archiving ${PKG_VER} at ${GITREV} to ${TARFILE_TMP}" 23 | (cd ${TOP}; git archive --format=tar --prefix=${PKG_VER}/ ${GITREV}) > ${TARFILE_TMP} 24 | ls -al ${TARFILE_TMP} 25 | (cd ${TOP}; git submodule status) | while read line; do 26 | rev=$(echo ${line} | cut -f 1 -d ' '); path=$(echo ${line} | cut -f 2 -d ' ') 27 | echo "Archiving ${path} at ${rev}" 28 | (cd ${srcdir}/${path}; git archive --format=tar --prefix=${PKG_VER}/${path}/ ${rev}) > submodule.tar 29 | tar -A -f ${TARFILE_TMP} submodule.tar 30 | rm submodule.tar 31 | done 32 | mv ${TARFILE_TMP} ${TARFILE} 33 | -------------------------------------------------------------------------------- /src/boot/ostree-tmpfiles.conf: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2017 Colin Walters 2 | # 3 | # This library is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU Lesser General Public 5 | # License as published by the Free Software Foundation; either 6 | # version 2 of the License, or (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public 14 | # License along with this library; if not, write to the 15 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 | # Boston, MA 02111-1307, USA. 17 | 18 | # https://github.com/ostreedev/ostree/issues/393 19 | R! /var/tmp/ostree-unlock-ovl.* 20 | -------------------------------------------------------------------------------- /ci/installdeps.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | # Install build dependencies. 3 | 4 | set -xeuo pipefail 5 | 6 | # This is used by our OpenShift Prow job; we use the 7 | # cosa buildroot container 8 | # https://github.com/coreos/coreos-assembler/pull/730 9 | # And using `yum` at all means we can flake on fetching rpm metadata 10 | if [ -n "${SKIP_INSTALLDEPS:-}" ]; then 11 | exit 0 12 | fi 13 | 14 | dn=$(dirname $0) 15 | . ${dn}/libbuild.sh 16 | 17 | pkg_upgrade 18 | pkg_install_buildroot 19 | pkg_builddep ostree 20 | pkg_install sudo which attr fuse strace \ 21 | libubsan libasan libtsan PyYAML redhat-rpm-config \ 22 | elfutils 23 | if test -n "${CI_PKGS:-}"; then 24 | pkg_install ${CI_PKGS} 25 | fi 26 | pkg_install_if_os fedora gjs gnome-desktop-testing parallel coccinelle clang \ 27 | python3-PyYAML 28 | if test "${OS_ID}" = "centos"; then 29 | rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 30 | pkg_install python34{,-PyYAML} 31 | fi 32 | -------------------------------------------------------------------------------- /src/ostree/parse-datetime.h: -------------------------------------------------------------------------------- 1 | /* Parse a string into an internal time stamp. 2 | 3 | Copyright (C) 1995, 1997-1998, 2003-2004, 2007, 2009-2015 Free Software 4 | Foundation, Inc. 5 | 6 | This program is free software: you can redistribute it and/or modify it 7 | under the terms of the GNU Lesser General Public License as published 8 | by the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . */ 18 | 19 | #include 20 | #include 21 | 22 | bool parse_datetime (struct timespec *, char const *, struct timespec const *); 23 | -------------------------------------------------------------------------------- /src/libostree/ostree-lzma-common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Colin Walters 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General 17 | * Public License along with this library; if not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | 25 | G_BEGIN_DECLS 26 | 27 | GConverterResult _ostree_lzma_return (lzma_ret value, GError **error); 28 | 29 | G_END_DECLS 30 | -------------------------------------------------------------------------------- /tests/test-pull-bare.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2011 Colin Walters 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | . $(dirname $0)/libtest.sh 25 | 26 | setup_fake_remote_repo1 "archive" 27 | 28 | repo_mode=bare 29 | . ${test_srcdir}/pull-test.sh 30 | -------------------------------------------------------------------------------- /ci/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | # Install build dependencies, run unit tests and installed tests. 3 | 4 | set -xeuo pipefail 5 | 6 | dn=$(dirname $0) 7 | . ${dn}/libbuild.sh 8 | 9 | if [ `umask` = 0000 ]; then 10 | echo 'Your umask is broken, please use e.g. `umask 0022`' 1>&2 11 | exit 1 12 | fi 13 | 14 | ${dn}/installdeps.sh 15 | 16 | # Default libcurl on by default in fedora unless libsoup is enabled 17 | if test "${OS_ID}" = 'fedora'; then 18 | case "${CONFIGOPTS:-}" in 19 | *--with-soup*|*--without-curl*) ;; 20 | *) CONFIGOPTS="${CONFIGOPTS:-} --with-curl" 21 | esac 22 | fi 23 | case "${CONFIGOPTS:-}" in 24 | *--with-curl*|--with-soup*) 25 | if test -x /usr/bin/gnome-desktop-testing-runner; then 26 | CONFIGOPTS="${CONFIGOPTS} --enable-installed-tests=exclusive" 27 | fi 28 | ;; 29 | esac 30 | 31 | # always fail on warnings; https://github.com/ostreedev/ostree/pull/971 32 | # NB: this disables the default set of flags from configure.ac 33 | export CFLAGS="-Wall -Werror ${CFLAGS:-}" 34 | 35 | build --enable-gtk-doc ${CONFIGOPTS:-} 36 | -------------------------------------------------------------------------------- /src/switchroot/switchroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This demonstration script is an implementation in shell 4 | # similar to ostree-prepare-root.c. For a bit more information, 5 | # see adapting-existing.md. 6 | 7 | ## the ostree boot parameter is avaialbe during the init 8 | env | grep ostree 9 | # ostree=/ostree/boot.1/.../.../0 10 | ## bind mount the ostree deployment to prepare it for move 11 | mount --bind $sysroot$ostree $sysroot$ostree 12 | ## bind mount read-only /usr 13 | mount --bind $sysroot$ostree/usr $sysroot$ostree/usr 14 | mount --bind -o remount,ro $sysroot$ostree/usr $sysroot$ostree/usr 15 | ## bind mount the physical root 16 | mount --bind $sysroot $sysroot$ostree/sysroot 17 | ## bind mount the var directory which is preserved between deployments 18 | mount --bind $sysroot/ostree/deploy/os/var $sysroot$ostree/var 19 | ## make sure target directories are present within var 20 | cd $sysroot$ostree/var 21 | mkdir -p roothome mnt opt home 22 | cd - 23 | ## move the deployment to the sysroot 24 | mount --move $sysroot$ostree $sysroot 25 | ## after these the init system should start the switch root process 26 | -------------------------------------------------------------------------------- /tests/inst/src/sysroot.rs: -------------------------------------------------------------------------------- 1 | //! Tests that mostly use the API and access the booted sysroot read-only. 2 | 3 | use anyhow::Result; 4 | use gio::prelude::*; 5 | use ostree::prelude::*; 6 | 7 | use crate::test::*; 8 | 9 | #[itest] 10 | fn test_sysroot_ro() -> Result<()> { 11 | // TODO add a skipped identifier 12 | if !std::path::Path::new("/run/ostree-booted").exists() { 13 | return Ok(()); 14 | } 15 | let cancellable = Some(gio::Cancellable::new()); 16 | let sysroot = ostree::Sysroot::new_default(); 17 | sysroot.load(cancellable.as_ref())?; 18 | assert!(sysroot.is_booted()); 19 | 20 | let booted = sysroot.get_booted_deployment().expect("booted deployment"); 21 | assert!(!booted.is_staged()); 22 | let repo = sysroot.repo().expect("repo"); 23 | 24 | let csum = booted.get_csum().expect("booted csum"); 25 | let csum = csum.as_str(); 26 | 27 | let (root, rev) = repo.read_commit(csum, cancellable.as_ref())?; 28 | assert_eq!(rev, csum); 29 | let root = root.downcast::().expect("downcast"); 30 | root.ensure_resolved()?; 31 | 32 | Ok(()) 33 | } 34 | -------------------------------------------------------------------------------- /tests/test-basic.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2011 Colin Walters 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | . $(dirname $0)/libtest.sh 25 | 26 | skip_without_no_selinux_or_relabel 27 | 28 | mode="bare" 29 | setup_test_repository "$mode" 30 | . $(dirname $0)/basic-test.sh 31 | -------------------------------------------------------------------------------- /tests/test-pull-bareuser.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2011 Colin Walters 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | . $(dirname $0)/libtest.sh 25 | 26 | skip_without_user_xattrs 27 | setup_fake_remote_repo1 "archive" 28 | 29 | repo_mode=bare-user 30 | . ${test_srcdir}/pull-test.sh 31 | -------------------------------------------------------------------------------- /tests/test-pull2-bareuseronly.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2017 Colin Walters 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | . $(dirname $0)/libtest.sh 25 | 26 | setup_fake_remote_repo2 "archive" "--canonical-permissions" 27 | 28 | repo_mode=bare-user-only 29 | . ${test_srcdir}/pull-test2.sh 30 | -------------------------------------------------------------------------------- /Makefile-bash.am: -------------------------------------------------------------------------------- 1 | # Makefile for bash/ 2 | # 3 | # Copyright (C) 2017 Red Hat Inc. 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | completionsdir = @BASH_COMPLETIONSDIR@ 23 | dist_completions_DATA = bash/ostree 24 | 25 | # Allow the distcheck install under $prefix test to pass 26 | AM_DISTCHECK_CONFIGURE_FLAGS += BASH_COMPLETIONSDIR='$${datadir}/bash-completion/completions' 27 | -------------------------------------------------------------------------------- /tests/test-pull-bareuseronly.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2017 Colin Walters 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | . $(dirname $0)/libtest.sh 25 | 26 | skip_without_user_xattrs 27 | setup_fake_remote_repo1 "archive" "--canonical-permissions" 28 | 29 | repo_mode=bare-user-only 30 | . ${test_srcdir}/pull-test.sh 31 | -------------------------------------------------------------------------------- /src/boot/ostree-finalize-staged.path: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2018 Red Hat, Inc. 2 | # 3 | # This library is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU Lesser General Public 5 | # License as published by the Free Software Foundation; either 6 | # version 2 of the License, or (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public 14 | # License along with this library; if not, write to the 15 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 | # Boston, MA 02111-1307, USA. 17 | 18 | # For some implementation discussion, see: 19 | # https://lists.freedesktop.org/archives/systemd-devel/2018-March/040557.html 20 | [Unit] 21 | Description=OSTree Monitor Staged Deployment 22 | Documentation=man:ostree(1) 23 | 24 | [Path] 25 | PathExists=/run/ostree/staged-deployment 26 | 27 | [Install] 28 | WantedBy=multi-user.target 29 | -------------------------------------------------------------------------------- /tests/test-admin-deploy-grub2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2011,2014 Colin Walters 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | . $(dirname $0)/libtest.sh 25 | 26 | # Exports OSTREE_SYSROOT so --sysroot not needed. 27 | setup_os_repository "archive" "grub2 ostree-grub-generator" 28 | 29 | extra_admin_tests=0 30 | 31 | . $(dirname $0)/admin-test.sh 32 | -------------------------------------------------------------------------------- /src/libotutil/ot-opt-utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Colin Walters . 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | * 21 | * Author: Colin Walters 22 | */ 23 | 24 | #pragma once 25 | 26 | #include 27 | 28 | G_BEGIN_DECLS 29 | 30 | void ot_util_usage_error (GOptionContext *context, const char *message, GError **error); 31 | 32 | G_END_DECLS 33 | -------------------------------------------------------------------------------- /src/ostree/ot-editor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Stef Walter 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | * 21 | * Author: Stef Walter 22 | */ 23 | 24 | #pragma once 25 | 26 | #include 27 | 28 | #include "ostree.h" 29 | 30 | char * ot_editor_prompt (OstreeRepo *repo, const char *input, 31 | GCancellable *cancellable, GError **error); 32 | -------------------------------------------------------------------------------- /tests/test-reset-nonlinear.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2015 Colin Walters 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | echo "1..1" 25 | 26 | . $(dirname $0)/libtest.sh 27 | 28 | setup_test_repository "archive" 29 | cd ${test_tmpdir}/files 30 | $OSTREE commit -b testx -s "Another Commit" 31 | cd ${test_tmpdir} 32 | $OSTREE reset test2 testx 33 | 34 | echo "ok reset nonlinear" 35 | -------------------------------------------------------------------------------- /src/libostree/ostree-dummy-enumtypes.h: -------------------------------------------------------------------------------- 1 | /* This file declares a stub function that is only exported 2 | * to pacify ABI checkers - no one could really have used it. 3 | * 4 | * Copyright (C) 2016 Red Hat, Inc. 5 | * 6 | * SPDX-License-Identifier: LGPL-2.0+ 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the 20 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 | * Boston, MA 02111-1307, USA. 22 | */ 23 | 24 | #pragma once 25 | 26 | #include 27 | 28 | #ifndef __GI_SCANNER__ 29 | _OSTREE_PUBLIC GType 30 | ostree_fetcher_config_flags_get_type (void); 31 | #endif 32 | -------------------------------------------------------------------------------- /tests/inst/itest-macro/src/itest-macro.rs: -------------------------------------------------------------------------------- 1 | extern crate proc_macro; 2 | 3 | use proc_macro::TokenStream; 4 | use proc_macro2::Span; 5 | use quote::quote; 6 | 7 | /// Wraps function using `procspawn` to allocate a new temporary directory, 8 | /// make it the process' working directory, and run the function. 9 | #[proc_macro_attribute] 10 | pub fn itest(attrs: TokenStream, input: TokenStream) -> TokenStream { 11 | let attrs = syn::parse_macro_input!(attrs as syn::AttributeArgs); 12 | if attrs.len() > 0 { 13 | return syn::Error::new_spanned(&attrs[0], "itest takes no attributes") 14 | .to_compile_error() 15 | .into(); 16 | } 17 | let func = syn::parse_macro_input!(input as syn::ItemFn); 18 | let fident = func.sig.ident.clone(); 19 | let varident = quote::format_ident!("ITEST_{}", fident); 20 | let fidentstrbuf = format!(r#"{}"#, fident); 21 | let fidentstr = syn::LitStr::new(&fidentstrbuf, Span::call_site()); 22 | let output = quote! { 23 | #[linkme::distributed_slice(TESTS)] 24 | #[allow(non_upper_case_globals)] 25 | static #varident : Test = Test { 26 | name: #fidentstr, 27 | f: #fident, 28 | }; 29 | #func 30 | }; 31 | output.into() 32 | } 33 | -------------------------------------------------------------------------------- /src/libostree/ostree-gpg-verify-result-private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Red Hat, Inc. 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "ostree-gpg-verify-result.h" 25 | 26 | #include "otutil.h" 27 | 28 | /** 29 | * OstreeGpgVerifyResult: 30 | * 31 | * Private instance structure. 32 | */ 33 | struct OstreeGpgVerifyResult { 34 | GObject parent; 35 | 36 | gpgme_ctx_t context; 37 | gpgme_verify_result_t details; 38 | }; 39 | -------------------------------------------------------------------------------- /src/libostree/ostree-repo-finder-avahi-private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2017 Endless Mobile, Inc. 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | * 21 | * Authors: 22 | * - Philip Withnall 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | GHashTable *_ostree_txt_records_parse (AvahiStringList *txt); 35 | 36 | G_END_DECLS 37 | -------------------------------------------------------------------------------- /tests/inst/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ostree-test" 3 | version = "0.1.0" 4 | authors = ["Colin Walters "] 5 | edition = "2018" 6 | 7 | [[bin]] 8 | name = "ostree-test" 9 | path = "src/insttest.rs" 10 | 11 | [dependencies] 12 | clap = "2.32.0" 13 | structopt = "0.2" 14 | commandspec = "0.12.2" 15 | anyhow = "1.0" 16 | tempfile = "3.1.0" 17 | gio = "0.8" 18 | ostree = { version = "0.7.1", features = ["v2020_1"] } 19 | libtest-mimic = "0.2.0" 20 | twoway = "0.2.1" 21 | hyper = "0.13" 22 | futures = "0.3.4" 23 | http = "0.2.0" 24 | hyper-staticfile = "0.5.1" 25 | tokio = { version = "0.2", features = ["full"] } 26 | futures-util = "0.3.1" 27 | base64 = "0.12.0" 28 | procspawn = "0.8" 29 | proc-macro2 = "0.4" 30 | quote = "0.6" 31 | syn = "0.15" 32 | linkme = "0.2" 33 | 34 | itest-macro = { path = "itest-macro" } 35 | 36 | with-procspawn-tempdir = { git = "https://github.com/cgwalters/with-procspawn-tempdir" } 37 | #with-procspawn-tempdir = { path = "/var/srv/walters/src/github/cgwalters/with-procspawn-tempdir" } 38 | 39 | # See https://github.com/tcr/commandspec/pulls?q=is%3Apr+author%3Acgwalters+ 40 | [patch.crates-io] 41 | commandspec = { git = "https://github.com/cgwalters/commandspec", branch = 'walters-master' } 42 | #commandspec = { path = "/var/srv/walters/src/github/tcr/commandspec" } 43 | -------------------------------------------------------------------------------- /src/libostree/ostree-dummy-enumtypes.c: -------------------------------------------------------------------------------- 1 | /* This file declares a stub function that is only exported 2 | * to pacify ABI checkers - no one could really have used it. 3 | * 4 | * Copyright (C) 2016 Red Hat, Inc. 5 | * 6 | * SPDX-License-Identifier: LGPL-2.0+ 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the 20 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 | * Boston, MA 02111-1307, USA. 22 | */ 23 | 24 | #include "ostree-dummy-enumtypes.h" 25 | 26 | /* Exported for backwards compat - see 27 | * https://bugzilla.gnome.org/show_bug.cgi?id=764131 28 | */ 29 | GType 30 | ostree_fetcher_config_flags_get_type (void) 31 | { 32 | return G_TYPE_INVALID; 33 | } 34 | -------------------------------------------------------------------------------- /tests/test-init-collections.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright © 2017 Endless Mobile, Inc. 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | . $(dirname $0)/libtest.sh 25 | 26 | echo '1..1' 27 | 28 | cd ${test_tmpdir} 29 | 30 | # Check that initialising a repository with a collection ID results in the ID being in the config. 31 | mkdir repo 32 | ostree_repo_init repo --collection-id org.example.Collection 33 | assert_file_has_content repo/config "^collection-id=org\.example\.Collection$" 34 | 35 | echo "ok init-collections" 36 | -------------------------------------------------------------------------------- /tests/inst/src/insttest.rs: -------------------------------------------------------------------------------- 1 | use anyhow::Result; 2 | // use structopt::StructOpt; 3 | // // https://github.com/clap-rs/clap/pull/1397 4 | // #[macro_use] 5 | // extern crate clap; 6 | 7 | mod repobin; 8 | mod sysroot; 9 | mod test; 10 | 11 | fn gather_tests() -> Vec { 12 | test::TESTS 13 | .iter() 14 | .map(|t| libtest_mimic::Test { 15 | name: t.name.into(), 16 | kind: "".into(), 17 | is_ignored: false, 18 | is_bench: false, 19 | data: t, 20 | }) 21 | .collect() 22 | } 23 | 24 | fn run_test(test: &test::TestImpl) -> libtest_mimic::Outcome { 25 | if let Err(e) = (test.data.f)() { 26 | libtest_mimic::Outcome::Failed { 27 | msg: Some(e.to_string()), 28 | } 29 | } else { 30 | libtest_mimic::Outcome::Passed 31 | } 32 | } 33 | 34 | fn main() -> Result<()> { 35 | procspawn::init(); 36 | 37 | // Ensure we're always in tempdir so we can rely on it globally 38 | let tmp_dir = tempfile::Builder::new() 39 | .prefix("ostree-insttest-top") 40 | .tempdir()?; 41 | std::env::set_current_dir(tmp_dir.path())?; 42 | 43 | let args = libtest_mimic::Arguments::from_args(); 44 | let tests = gather_tests(); 45 | libtest_mimic::run_tests(&args, tests, run_test).exit(); 46 | } 47 | -------------------------------------------------------------------------------- /src/rofiles-fuse/Makefile-inc.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2016 Colin Walters 2 | # 3 | # SPDX-License-Identifier: LGPL-2.0+ 4 | # 5 | # This library is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU Lesser General Public 7 | # License as published by the Free Software Foundation; either 8 | # version 2 of the License, or (at your option) any later version. 9 | # 10 | # This library is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public 16 | # License along with this library; if not, write to the 17 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | # Boston, MA 02111-1307, USA. 19 | 20 | bin_PROGRAMS += rofiles-fuse 21 | 22 | rofiles_fuse_SOURCES = src/rofiles-fuse/main.c 23 | 24 | rofiles_fuse_CFLAGS = $(AM_CFLAGS) -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 $(BUILDOPT_FUSE_CFLAGS) \ 25 | $(OT_INTERNAL_GIO_UNIX_CFLAGS) -I $(srcdir)/src/libostree -I $(builddir)/src/libostree \ 26 | -I$(srcdir)/libglnx 27 | rofiles_fuse_LDADD = libglnx.la $(BUILDOPT_FUSE_LIBS) $(OT_INTERNAL_GIO_UNIX_LIBS) libostree-1.la 28 | -------------------------------------------------------------------------------- /src/libostree/ostree-linuxfsutil.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Colin Walters 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "ostree-types.h" 25 | 26 | G_BEGIN_DECLS 27 | 28 | gboolean 29 | _ostree_linuxfs_fd_alter_immutable_flag (int fd, 30 | gboolean new_immutable_state, 31 | GCancellable *cancellable, 32 | GError **error); 33 | 34 | G_END_DECLS 35 | -------------------------------------------------------------------------------- /src/libostree/ostree-varint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Colin Walters 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #pragma once 23 | 24 | #include 25 | 26 | G_BEGIN_DECLS 27 | 28 | gboolean _ostree_read_varuint64 (const guint8 *buf, 29 | gsize buflen, 30 | guint64 *out_value, 31 | gsize *bytes_read); 32 | 33 | void _ostree_write_varuint64 (GString *buf, guint64 n); 34 | 35 | G_END_DECLS 36 | -------------------------------------------------------------------------------- /src/boot/ostree-prepare-root.service: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2013 Colin Walters 2 | # 3 | # This library is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU Lesser General Public 5 | # License as published by the Free Software Foundation; either 6 | # version 2 of the License, or (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public 14 | # License along with this library; if not, write to the 15 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 | # Boston, MA 02111-1307, USA. 17 | 18 | [Unit] 19 | Description=OSTree Prepare OS/ 20 | Documentation=man:ostree(1) 21 | DefaultDependencies=no 22 | ConditionKernelCommandLine=ostree 23 | ConditionPathExists=/etc/initrd-release 24 | OnFailure=emergency.target 25 | After=sysroot.mount 26 | Requires=sysroot.mount 27 | Before=initrd-root-fs.target 28 | 29 | [Service] 30 | Type=oneshot 31 | ExecStart=/usr/lib/ostree/ostree-prepare-root /sysroot 32 | StandardInput=null 33 | StandardOutput=syslog 34 | StandardError=syslog+console 35 | RemainAfterExit=yes 36 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | test -n "$srcdir" || srcdir=`dirname "$0"` 4 | test -n "$srcdir" || srcdir=. 5 | 6 | olddir=`pwd` 7 | cd $srcdir 8 | 9 | AUTORECONF=`which autoreconf` 10 | if test -z $AUTORECONF; then 11 | echo "*** No autoreconf found, please install it ***" 12 | exit 1 13 | fi 14 | 15 | set -e 16 | 17 | mkdir -p m4 18 | 19 | GTKDOCIZE=$(which gtkdocize 2>/dev/null || true) 20 | if test -z "$GTKDOCIZE"; then 21 | echo "You don't have gtk-doc installed, and thus won't be able to generate the documentation." 22 | rm -f gtk-doc.make 23 | cat > gtk-doc.make <libglnx/Makefile-libglnx.am.inc 37 | sed -e 's,$(libbsdiff_srcpath),bsdiff,g' < bsdiff/Makefile-bsdiff.am >bsdiff/Makefile-bsdiff.am.inc 38 | 39 | # FIXME - figure out how to get aclocal to find this by default 40 | ln -sf ../libglnx/libglnx.m4 buildutil/libglnx.m4 41 | 42 | autoreconf --force --install --verbose 43 | 44 | cd $olddir 45 | test -n "$NOCONFIGURE" || "$srcdir/configure" "$@" 46 | -------------------------------------------------------------------------------- /src/libotutil/ot-opt-utils.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Colin Walters 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | * 21 | * Author: Colin Walters 22 | */ 23 | 24 | #include "config.h" 25 | 26 | #include 27 | 28 | #include 29 | 30 | #include "otutil.h" 31 | 32 | void 33 | ot_util_usage_error (GOptionContext *context, const char *message, GError **error) 34 | { 35 | gchar *help = g_option_context_get_help (context, TRUE, NULL); 36 | g_printerr ("%s\n", help); 37 | g_free (help); 38 | g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, message); 39 | } 40 | -------------------------------------------------------------------------------- /tests/test-remote-add-collections.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright © 2017 Endless Mobile, Inc. 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | . $(dirname $0)/libtest.sh 25 | 26 | echo '1..1' 27 | 28 | cd ${test_tmpdir} 29 | 30 | # Check that adding a remote with a collection ID results in the ID being in the config. 31 | mkdir repo 32 | ostree_repo_init repo 33 | ${CMD_PREFIX} ostree --repo=repo remote add some-remote https://example.com/ --collection-id example-id --gpg-import=${test_tmpdir}/gpghome/key1.asc 34 | 35 | assert_file_has_content repo/config "^collection-id=example-id$" 36 | 37 | echo "ok remote-add-collections" 38 | -------------------------------------------------------------------------------- /src/libostree/ostree-enumtypes.h.template: -------------------------------------------------------------------------------- 1 | /*** BEGIN file-header ***/ 2 | /* 3 | * Copyright (C) 2015 Red Hat, Inc. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /*** END file-header ***/ 22 | 23 | /*** BEGIN file-production ***/ 24 | #pragma once 25 | 26 | #include 27 | 28 | G_BEGIN_DECLS 29 | 30 | /* Enumerations from "@filename@" */ 31 | 32 | /*** END file-production ***/ 33 | 34 | /*** BEGIN enumeration-production ***/ 35 | #define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (_@enum_name@_get_type ()) 36 | GType _@enum_name@_get_type (void) G_GNUC_CONST; 37 | 38 | /*** END enumeration-production ***/ 39 | 40 | /*** BEGIN file-tail ***/ 41 | G_END_DECLS 42 | 43 | /*** END file-tail ***/ 44 | -------------------------------------------------------------------------------- /cfg.mk: -------------------------------------------------------------------------------- 1 | export VC_LIST_EXCEPT_DEFAULT=^(docs/.*|git.mk|lib/.*|m4/.*|md5/.*|build-aux/.*|src/gettext\.h|.*ChangeLog|buildutil/.*)$$ 2 | 3 | local-checks-to-skip = \ 4 | sc_const_long_option \ 5 | sc_error_message_uppercase \ 6 | sc_file_system \ 7 | sc_immutable_NEWS \ 8 | sc_copyright_check \ 9 | sc_makefile_path_separator_check \ 10 | sc_require_config_h \ 11 | sc_require_config_h_first \ 12 | sc_two_space_separator_in_usage \ 13 | sc_useless_cpp_parens \ 14 | \ 15 | sc_prohibit_atoi_atof \ 16 | sc_prohibit_strcmp \ 17 | sc_cast_of_alloca_return_value \ 18 | sc_cast_of_x_alloc_return_value \ 19 | sc_prohibit_S_IS_definition \ 20 | \ 21 | sc_program_name \ 22 | sc_bindtextdomain \ 23 | sc_prohibit_path_max_allocation \ 24 | sc_trailing_blank \ 25 | 26 | sc_glnx_prefix_error_colon: 27 | @prohibit='\ 23 | */ 24 | 25 | #include "config.h" 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | static void 32 | test_include_ostree_h_compiled (void) 33 | { 34 | } 35 | 36 | /* Just ensure that we can compile with ostree.h included */ 37 | int main (int argc, char **argv) 38 | { 39 | setlocale (LC_ALL, ""); 40 | g_test_init (&argc, &argv, NULL); 41 | 42 | g_test_add_func ("/include-ostree-h/compiled", test_include_ostree_h_compiled); 43 | 44 | return g_test_run(); 45 | } 46 | -------------------------------------------------------------------------------- /ci/build-rpm.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | # Generate a src.rpm, then binary rpms in the current directory 3 | 4 | set -xeuo pipefail 5 | 6 | dn=$(dirname $0) 7 | . ${dn}/libbuild.sh 8 | 9 | # Auto-provision bootstrap resources if run as root (normally in CI) 10 | if test "$(id -u)" == 0; then 11 | pkg_install_buildroot 12 | pkg_install make /usr/bin/rpmbuild git 13 | fi 14 | 15 | # PAPR really should do this 16 | if ! test -f libglnx/README.md || ! test -f bsdiff/README.md; then 17 | git submodule update --init 18 | fi 19 | 20 | # Default libcurl on by default in fedora unless libsoup is enabled 21 | if test "${OS_ID}" = 'fedora'; then 22 | case "${CONFIGOPTS:-}" in 23 | *--with-soup*|*--without-curl*) ;; 24 | *) CONFIGOPTS="${CONFIGOPTS:-} --with-curl" 25 | esac 26 | fi 27 | case "${CONFIGOPTS:-}" in 28 | *--with-curl*|*--with-soup*) 29 | if test -x /usr/bin/gnome-desktop-testing-runner; then 30 | CONFIGOPTS="${CONFIGOPTS} --enable-installed-tests=exclusive" 31 | fi 32 | ;; 33 | esac 34 | 35 | # TODO: Use some form of rpm's --build-in-place to skip archive-then-unpack? 36 | make -f ${dn}/Makefile.dist-packaging srpm PACKAGE=libostree DISTGIT_NAME=ostree 37 | if test "$(id -u)" == 0; then 38 | pkg_builddep *.src.rpm 39 | else 40 | echo "NOTE: Running as non-root, assuming build dependencies are installed" 41 | fi 42 | if ! ${dn}/rpmbuild-cwd --rebuild *.src.rpm; then 43 | find . -type f -name config.log -exec cat {} \; 44 | exit 1 45 | fi 46 | -------------------------------------------------------------------------------- /ostree.doap: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | ostree 9 | ostree 10 | 11 | 12 | Git for operating system binaries 13 | 14 | 15 | OSTree is best summarized in a single sentence as "git for 16 | operating system binaries". At its core architecture is a 17 | userspace content-addressed filesystem, and layered on top of 18 | that is an administrative layer that is designed to atomically 19 | parallel install multiple bootable Unix-like operating systems. 20 | 21 | 22 | 23 | 24 | 25 | 26 | C 27 | 28 | 29 | 30 | Colin Walters 31 | 32 | walters 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/libostree/libostree-devel.sym: -------------------------------------------------------------------------------- 1 | /* DEVEL symbol file - add new symbols here 2 | Copyright (C) 2016 Colin Walters 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the 16 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | Boston, MA 02111-1307, USA. 18 | ***/ 19 | 20 | LIBOSTREE_2020.5 { 21 | global: 22 | /* Add symbols here, and uncomment the bits in 23 | * Makefile-libostree.am to enable this too. 24 | */ 25 | } LIBOSTREE_2020.4; 26 | 27 | /* Stub section for the stable release *after* this development one; don't 28 | * edit this other than to update the year. This is just a copy/paste 29 | * source. Replace $LASTSTABLE with the last stable version, and $NEWVERSION 30 | * with whatever the next version with new symbols will be. 31 | LIBOSTREE_2020.$NEWVERSION { 32 | global: 33 | someostree_symbol_deleteme; 34 | } LIBOSTREE_2020.$LASTSTABLE; 35 | */ 36 | -------------------------------------------------------------------------------- /src/ostree/ot-admin-instutil-builtins.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Colin Walters 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #pragma once 23 | 24 | #include 25 | 26 | G_BEGIN_DECLS 27 | 28 | gboolean ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error); 29 | gboolean ot_admin_instutil_builtin_set_kargs (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error); 30 | gboolean ot_admin_instutil_builtin_grub2_generate (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error); 31 | 32 | G_END_DECLS 33 | -------------------------------------------------------------------------------- /src/libotutil/ot-unix-utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Colin Walters . 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | * 21 | * Author: Colin Walters 22 | */ 23 | 24 | #pragma once 25 | 26 | #include 27 | 28 | /* I just put all this shit here. Sue me. */ 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | G_BEGIN_DECLS 39 | 40 | gboolean ot_util_filename_validate (const char *name, GError **error); 41 | 42 | gboolean ot_util_path_split_validate (const char *path, GPtrArray **out_components, GError **error); 43 | 44 | G_END_DECLS 45 | -------------------------------------------------------------------------------- /tests/kolainst/nondestructive/itest-bare-unit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Run test-basic.sh as root. 4 | # https://github.com/ostreedev/ostree/pull/1199 5 | 6 | set -xeuo pipefail 7 | 8 | . ${KOLA_EXT_DATA}/libinsttest.sh 9 | 10 | fatal "FIXME - need to also sync over the installed tests" 11 | 12 | date 13 | # These tests sort of bypass the installed-tests spec; 14 | # fixing that would require installing g-d-t-r, though 15 | # more ideally we architect things with a "control" container 16 | # distinct from the host. 17 | export G_TEST_SRCDIR=$(realpath $dn/../../..) 18 | 19 | # Use /var/tmp to hopefully use XFS + O_TMPFILE etc. 20 | prepare_tmpdir /var/tmp 21 | trap _tmpdir_cleanup EXIT 22 | /usr/libexec/installed-tests/libostree/test-basic.sh 23 | /usr/libexec/installed-tests/libostree/test-basic-c 24 | date 25 | 26 | # Test error message when opening a non-world-readable object 27 | # https://github.com/ostreedev/ostree/issues/1562 28 | rm repo files -rf 29 | chmod a+rx . 30 | ostree --repo=repo init --mode=bare 31 | mkdir files 32 | touch files/unreadable 33 | chmod 0 files/unreadable 34 | ostree --repo=repo commit -b testbranch --tree=dir=files 35 | # We should be able to read as root due to CAP_DAC_OVERRIDE 36 | ostree --repo=repo cat testbranch /unreadable >/dev/null 37 | if setpriv --reuid bin --regid bin --clear-groups ostree --repo=repo cat testbranch /unreadable 2>err.txt; then 38 | fatal "Listed unreadable object as non-root" 39 | fi 40 | assert_file_has_content err.txt "Opening content object.*openat: Permission denied" 41 | 42 | date 43 | -------------------------------------------------------------------------------- /tests/test-oldstyle-partial.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2015 Red Hat, Inc. 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | . $(dirname $0)/libtest.sh 25 | 26 | setup_fake_remote_repo1 "archive" 27 | 28 | echo '1..1' 29 | 30 | cd ${test_tmpdir} 31 | rm repo -rf 32 | mkdir repo 33 | ostree_repo_init repo 34 | ${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo 35 | 36 | ${CMD_PREFIX} ostree --repo=repo pull origin main --subpath /baz 37 | ${CMD_PREFIX} ostree fsck --repo=repo >fsck.out 38 | assert_file_has_content fsck.out 'Verifying content integrity of 0 commit objects' 39 | assert_file_has_content fsck.out '1 partial commits not verified' 40 | 41 | echo "ok" 42 | -------------------------------------------------------------------------------- /apidoc/ostree-docs.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | ]> 8 | 9 | 10 | OSTree API references 11 | for OSTree &version; 12 | 13 | 14 | 15 | API Reference 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | API Index 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/libostree/ostree-bootloader-zipl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Colin Walters 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation; either version 2 of the licence or (at 7 | * your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General 15 | * Public License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "ostree-bootloader.h" 23 | 24 | G_BEGIN_DECLS 25 | 26 | #define OSTREE_TYPE_BOOTLOADER_ZIPL (_ostree_bootloader_zipl_get_type ()) 27 | #define OSTREE_BOOTLOADER_ZIPL(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), OSTREE_TYPE_BOOTLOADER_ZIPL, OstreeBootloaderZipl)) 28 | #define OSTREE_IS_BOOTLOADER_ZIPL(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), OSTREE_TYPE_BOOTLOADER_ZIPL)) 29 | 30 | typedef struct _OstreeBootloaderZipl OstreeBootloaderZipl; 31 | 32 | GType _ostree_bootloader_zipl_get_type (void) G_GNUC_CONST; 33 | 34 | OstreeBootloaderZipl * _ostree_bootloader_zipl_new (OstreeSysroot *sysroot); 35 | 36 | G_END_DECLS 37 | -------------------------------------------------------------------------------- /tests/test-pull-untrusted.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2014 Alexander Larsson 4 | # Copyright (C) 2018 Red Hat, Inc. 5 | # 6 | # SPDX-License-Identifier: LGPL-2.0+ 7 | # 8 | # This library is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU Lesser General Public 10 | # License as published by the Free Software Foundation; either 11 | # version 2 of the License, or (at your option) any later version. 12 | # 13 | # This library is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | # Lesser General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Lesser General Public 19 | # License along with this library; if not, write to the 20 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 | # Boston, MA 02111-1307, USA. 22 | 23 | 24 | set -euo pipefail 25 | 26 | . $(dirname $0)/libtest.sh 27 | 28 | echo '1..1' 29 | 30 | setup_test_repository "bare" 31 | 32 | cd ${test_tmpdir} 33 | tar xf ${test_srcdir}/ostree-path-traverse.tar.gz 34 | rm -rf repo2 35 | ostree_repo_init repo2 --mode=archive 36 | if ${CMD_PREFIX} ostree --repo=repo2 pull-local --untrusted ostree-path-traverse/repo pathtraverse-test 2>err.txt; then 37 | fatal "pull-local unexpectedly succeeded" 38 | fi 39 | assert_file_has_content_literal err.txt 'Invalid / in filename ../afile' 40 | echo "ok untrusted pull-local path traversal" 41 | -------------------------------------------------------------------------------- /ci/Makefile.dist-packaging: -------------------------------------------------------------------------------- 1 | # -*- mode: Makefile -*- 2 | 3 | mypath = $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) 4 | topsrcdir = $(shell git rev-parse --show-toplevel) 5 | GITREV = $(shell git describe --always --tags) 6 | GITREV_FOR_PKG = $(shell echo "$(GITREV)" | sed -e 's,-,\.,g' -e 's,^v,,') 7 | 8 | PACKAGE ?= $(shell basename $(topsrcdir)) 9 | DISTGIT_NAME ?= $(PACKAGE) 10 | DISTGIT ?= https://src.fedoraproject.org/rpms/$(DISTGIT_NAME) 11 | SPEC ?= $(topsrcdir)/$(DISTGIT_NAME).spec 12 | 13 | PKG_VER = $(PACKAGE)-$(GITREV_FOR_PKG) 14 | PKG_CLIENT_VER = $(PACKAGE)-client-$(GITREV_FOR_PKG) 15 | 16 | dist-snapshot: 17 | if ! test -f $(PKG_VER).tar.xz; then \ 18 | $(mypath)/make-git-snapshot.sh "$(topsrcdir)" "$(PKG_VER)" "$(GITREV)" && \ 19 | rm -f $(PKG_VER).tar.xz && \ 20 | xz $(PKG_VER).tar; \ 21 | fi 22 | 23 | srpm: dist-snapshot 24 | if test -f "$(SPEC)"; then \ 25 | sed -e "s,^Version:.*,Version: $(GITREV_FOR_PKG)," $(SPEC) > $(DISTGIT_NAME).spec && \ 26 | $(mypath)/rpmbuild-cwd -bs $(DISTGIT_NAME).spec ; \ 27 | else \ 28 | test -d $(DISTGIT_NAME) || git clone --depth=1 $(DISTGIT) && \ 29 | mv $(PKG_VER).tar.xz $(DISTGIT_NAME) && \ 30 | origdir=$$(pwd); \ 31 | cd $(DISTGIT_NAME) && \ 32 | git stash && git pull -r && \ 33 | sed -i -e '/^Patch/d' -e "s,^Version:.*,Version: $(GITREV_FOR_PKG)," $(DISTGIT_NAME).spec && \ 34 | rm -f *.src.rpm && \ 35 | $(mypath)/rpmbuild-cwd -bs $(DISTGIT_NAME).spec && mv *.src.rpm $${origdir}; \ 36 | fi 37 | 38 | rpm: srpm 39 | ./rpmbuild-cwd --rebuild $(PKG_VER)*.src.rpm 40 | -------------------------------------------------------------------------------- /src/ostree/ot-remote-cookie-util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Colin Walters 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "libglnx.h" 25 | 26 | G_BEGIN_DECLS 27 | 28 | gboolean 29 | ot_add_cookie_at (int dfd, const char *jar_path, 30 | const char *domain, const char *path, 31 | const char *name, const char *value, 32 | GError **error); 33 | 34 | gboolean 35 | ot_delete_cookie_at (int dfd, const char *jar_path, 36 | const char *domain, const char *path, 37 | const char *name, 38 | GError **error); 39 | 40 | gboolean 41 | ot_list_cookies_at (int dfd, const char *jar_path, GError **error); 42 | 43 | G_END_DECLS 44 | -------------------------------------------------------------------------------- /tests/kolainst/destructive/staged-delay.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -xeuo pipefail 3 | 4 | # Add an artificial delay into ostree-finalize-staged.service 5 | # and verify it sees /boot; https://bugzilla.redhat.com/show_bug.cgi?id=1827712 6 | 7 | . ${KOLA_EXT_DATA}/libinsttest.sh 8 | 9 | require_writable_sysroot 10 | prepare_tmpdir 11 | 12 | case "${AUTOPKGTEST_REBOOT_MARK:-}" in 13 | "") 14 | dropin=/etc/systemd/system/ostree-finalize-staged.service.d/delay.conf 15 | mkdir -p $(dirname ${dropin}) 16 | cat >"${dropin}" << 'EOF' 17 | [Service] 18 | ExecStop=/bin/sh -c 'sleep 10 && if ! test -d /boot/loader/entries; then echo error: no /boot/loader/entries; exit 1; fi; echo ostree-finalize-staged found /boot/loader/entries' 19 | #ExecStop=/bin/false 20 | EOF 21 | systemctl daemon-reload 22 | rpm-ostree kargs --append=somedummykarg=1 23 | /tmp/autopkgtest-reboot 2 24 | ;; 25 | 26 | "2") 27 | journalctl -b -1 -u ostree-finalize-staged > logs.txt 28 | assert_file_has_content_literal logs.txt 'ostree-finalize-staged found /boot/loader/entries' 29 | # older systemd doesn't output the success message 30 | if systemctl --version | head -1 | grep -qF -e 'systemd 239'; then 31 | assert_file_has_content_literal logs.txt 'Stopped OSTree Finalize Staged Deployment' 32 | assert_not_file_has_content logs.txt 'Failed with result' 33 | else 34 | assert_file_has_content_literal logs.txt 'ostree-finalize-staged.service: Succeeded.' 35 | fi 36 | assert_file_has_content_literal /proc/cmdline somedummykarg=1 37 | ;; 38 | *) fatal "Unexpected AUTOPKGTEST_REBOOT_MARK=${AUTOPKGTEST_REBOOT_MARK}" ;; 39 | esac 40 | echo ok 41 | -------------------------------------------------------------------------------- /tests/test-archivez.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2011 Colin Walters 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | . $(dirname $0)/libtest.sh 25 | 26 | echo '1..13' 27 | 28 | setup_test_repository "archive" 29 | 30 | . ${test_srcdir}/archive-test.sh 31 | 32 | ${CMD_PREFIX} ostree --repo=repo-archive-z2 init --mode=archive-z2 33 | echo "ok did an init with archive-z2 alias" 34 | 35 | cd ${test_tmpdir} 36 | mkdir repo2 37 | ostree_repo_init repo2 38 | ${CMD_PREFIX} ostree --repo=repo2 remote add --set=gpg-verify=false aremote file://$(pwd)/repo test2 39 | ${CMD_PREFIX} ostree --repo=repo2 pull aremote 40 | ${CMD_PREFIX} ostree --repo=repo2 rev-parse aremote/test2 41 | ${CMD_PREFIX} ostree --repo=repo2 fsck 42 | echo "ok pull with from file:/// uri" 43 | -------------------------------------------------------------------------------- /src/libostree/ostree-types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Colin Walters 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | * 21 | * Author: Colin Walters 22 | */ 23 | 24 | #pragma once 25 | 26 | #include 27 | 28 | #ifndef _OSTREE_PUBLIC 29 | #define _OSTREE_PUBLIC extern 30 | #endif 31 | 32 | G_BEGIN_DECLS 33 | 34 | typedef struct OstreeRepo OstreeRepo; 35 | typedef struct OstreeRepoDevInoCache OstreeRepoDevInoCache; 36 | typedef struct OstreeSePolicy OstreeSePolicy; 37 | typedef struct OstreeSysroot OstreeSysroot; 38 | typedef struct OstreeSysrootUpgrader OstreeSysrootUpgrader; 39 | typedef struct OstreeMutableTree OstreeMutableTree; 40 | typedef struct OstreeRepoFile OstreeRepoFile; 41 | typedef struct OstreeRemote OstreeRemote; 42 | 43 | G_END_DECLS 44 | -------------------------------------------------------------------------------- /src/libostree/ostree-bootloader-syslinux.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Colin Walters 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation; either version 2 of the licence or (at 7 | * your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General 15 | * Public License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "ostree-bootloader.h" 23 | 24 | G_BEGIN_DECLS 25 | 26 | #define OSTREE_TYPE_BOOTLOADER_SYSLINUX (_ostree_bootloader_syslinux_get_type ()) 27 | #define OSTREE_BOOTLOADER_SYSLINUX(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), OSTREE_TYPE_BOOTLOADER_SYSLINUX, OstreeBootloaderSyslinux)) 28 | #define OSTREE_IS_BOOTLOADER_SYSLINUX(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), OSTREE_TYPE_BOOTLOADER_SYSLINUX)) 29 | 30 | typedef struct _OstreeBootloaderSyslinux OstreeBootloaderSyslinux; 31 | 32 | GType _ostree_bootloader_syslinux_get_type (void) G_GNUC_CONST; 33 | 34 | OstreeBootloaderSyslinux * _ostree_bootloader_syslinux_new (OstreeSysroot *sysroot); 35 | 36 | G_END_DECLS 37 | -------------------------------------------------------------------------------- /tests/kolainst/destructive/itest-bare-root.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Tests of the "raw ostree" functionality using the host's ostree repo as uid 0. 4 | 5 | set -xeuo pipefail 6 | 7 | . ${KOLA_EXT_DATA}/libinsttest.sh 8 | 9 | echo "1..2" 10 | date 11 | 12 | require_writable_sysroot 13 | 14 | cd /ostree/repo/tmp 15 | rm co -rf 16 | rm co-testref -rf 17 | ostree refs --delete testref 18 | ostree checkout -H ${host_refspec} co 19 | victim_symlink=/usr/bin/gtar # Seems likely to stick around 20 | # Copy the link to avoid corrupting it 21 | cp co/${victim_symlink}{,.tmp} 22 | mv co/${victim_symlink}{.tmp,} 23 | # Add another xattr to a symlink and a directory, since otherwise this is unusual 24 | setfattr -n security.biometric -v iris co/${victim_symlink} 25 | setfattr -n security.crunchy -v withketchup co/usr/bin 26 | csum=$(ostree commit -b testref --link-checkout-speedup --tree=dir=co) 27 | ostree fsck 28 | ostree ls -X testref ${victim_symlink} > ls.txt 29 | assert_file_has_content ls.txt 'security\.biometric' 30 | ostree ls -X ${host_refspec} ${victim_symlink} > ls.txt 31 | assert_not_file_has_content ls.txt 'security\.biometric' 32 | ostree ls -X testref usr/bin > ls.txt 33 | assert_file_has_content ls.txt 'security\.crunchy' 34 | 35 | ostree checkout -H testref co-testref 36 | getfattr -n security.biometric co-testref/${victim_symlink} > xattr.txt 37 | assert_file_has_content xattr.txt 'security\.biometric="iris"' 38 | getfattr -n security.crunchy co-testref/usr/bin > xattr.txt 39 | assert_file_has_content xattr.txt 'security\.crunchy="withketchup"' 40 | 41 | rm co -rf 42 | rm co-testref -rf 43 | 44 | echo "ok xattrs" 45 | date 46 | -------------------------------------------------------------------------------- /ci/flatpak.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Build and run flatpak's unit tests using the just-built ostree for this PR. 3 | 4 | set -xeuo pipefail 5 | 6 | # Keep this pinned to avoid arbitrary change for now; it's also 7 | # good to test building older code against newer ostree as it helps 8 | # us notice any API breaks. 9 | FLATPAK_TAG=1.4.1 10 | 11 | dn=$(dirname $0) 12 | . ${dn}/libbuild.sh 13 | 14 | codedir=$(pwd) 15 | 16 | # Build ostree, but we don't install it yet 17 | cd ${codedir} 18 | ci/build.sh 19 | 20 | # Build flatpak 21 | tmpd=$(mktemp -d) 22 | cd ${tmpd} 23 | git clone --recursive --depth=1 -b ${FLATPAK_TAG} https://github.com/flatpak/flatpak 24 | cd ${tmpd}/flatpak 25 | 26 | # Some of flatpak's tests assert GPG error strings from ostree, but 27 | # those have been changed. Patch the test assertions until this can get 28 | # into a tagged flatpak. 29 | git apply ${codedir}/ci/flatpak-1.4.1-ostree-gpg-errors.patch 30 | 31 | # This is a copy of flatpak/ci/build.sh, but we can't use that as we want to install 32 | # our built ostree over it. 33 | pkg_install sudo which attr fuse bison \ 34 | libubsan libasan libtsan clang python2 \ 35 | elfutils git gettext-devel libappstream-glib-devel hicolor-icon-theme \ 36 | /usr/bin/{update-mime-database,update-desktop-database,gtk-update-icon-cache} 37 | pkg_builddep flatpak 38 | # Now install ostree over the package version 39 | cd ${codedir} 40 | make install 41 | cd - 42 | # And build flatpak 43 | build 44 | # We want to capture automake results from flatpak 45 | cleanup() { 46 | mv test-suite.log ${codedir} || true 47 | } 48 | trap cleanup EXIT 49 | make -j 8 check 50 | -------------------------------------------------------------------------------- /src/libostree/ostree-rollsum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Colin Walters 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #pragma once 23 | 24 | #include 25 | #include "libglnx.h" 26 | 27 | G_BEGIN_DECLS 28 | 29 | typedef struct { 30 | GHashTable *from_rollsums; 31 | GHashTable *to_rollsums; 32 | guint crcmatches; 33 | guint bufmatches; 34 | guint total; 35 | guint64 match_size; 36 | GPtrArray *matches; 37 | } OstreeRollsumMatches; 38 | 39 | OstreeRollsumMatches * 40 | _ostree_compute_rollsum_matches (GBytes *from, 41 | GBytes *to); 42 | 43 | void _ostree_rollsum_matches_free (OstreeRollsumMatches *rollsum); 44 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(OstreeRollsumMatches, _ostree_rollsum_matches_free) 45 | 46 | G_END_DECLS 47 | -------------------------------------------------------------------------------- /src/libotutil/ot-tool-util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Colin Walters 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #pragma once 23 | 24 | #include 25 | 26 | G_BEGIN_DECLS 27 | 28 | gboolean 29 | ot_parse_boolean (const char *value, 30 | gboolean *out_parsed, 31 | GError **error); 32 | gboolean 33 | ot_parse_keyvalue (const char *keyvalue, 34 | char **out_key, 35 | char **out_value, 36 | GError **error); 37 | gboolean 38 | ot_ptr_array_find_with_equal_func (GPtrArray *haystack, 39 | gconstpointer needle, 40 | GEqualFunc equal_func, 41 | guint *index_); 42 | 43 | G_END_DECLS 44 | -------------------------------------------------------------------------------- /src/ostree/ot-dump.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Stef Walter 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | * 21 | * Author: Stef Walter 22 | */ 23 | 24 | #pragma once 25 | 26 | #include 27 | 28 | #include "ostree-core.h" 29 | 30 | typedef enum { 31 | OSTREE_DUMP_NONE = (1 << 0), 32 | OSTREE_DUMP_RAW = (1 << 1), 33 | OSTREE_DUMP_UNSWAPPED = (1 << 2), 34 | } OstreeDumpFlags; 35 | 36 | void ot_dump_variant (GVariant *variant); 37 | 38 | void ot_dump_object (OstreeObjectType objtype, 39 | const char *checksum, 40 | GVariant *variant, 41 | OstreeDumpFlags flags); 42 | 43 | void ot_dump_summary_bytes (GBytes *summary_bytes, 44 | OstreeDumpFlags flags); 45 | -------------------------------------------------------------------------------- /src/ostree/ot-builtin-trivial-httpd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Colin Walters 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #include "config.h" 23 | 24 | #include "ot-main.h" 25 | #include "ot-builtins.h" 26 | #include "ostree.h" 27 | #include "otutil.h" 28 | 29 | gboolean 30 | ostree_builtin_trivial_httpd (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error) 31 | { 32 | g_autoptr(GPtrArray) new_argv = g_ptr_array_new (); 33 | 34 | g_ptr_array_add (new_argv, PKGLIBEXECDIR "/ostree-trivial-httpd"); 35 | for (int i = 1; i < argc; i++) 36 | g_ptr_array_add (new_argv, argv[i]); 37 | g_ptr_array_add (new_argv, NULL); 38 | execvp (new_argv->pdata[0], (char**)new_argv->pdata); 39 | /* Fall through on error */ 40 | glnx_set_error_from_errno (error); 41 | return FALSE; 42 | } 43 | -------------------------------------------------------------------------------- /src/boot/dracut/module-setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- 3 | # ex: ts=8 sw=4 sts=4 et filetype=sh 4 | # 5 | # Copyright (C) 2013 Colin Walters 6 | # 7 | # SPDX-License-Identifier: LGPL-2.0+ 8 | # 9 | # This library is free software; you can redistribute it and/or 10 | # modify it under the terms of the GNU Lesser General Public 11 | # License as published by the Free Software Foundation; either 12 | # version 2 of the License, or (at your option) any later version. 13 | # 14 | # This library is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | # Lesser General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU Lesser General Public 20 | # License along with this library; if not, write to the 21 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 22 | # Boston, MA 02111-1307, USA. 23 | 24 | check() { 25 | if [[ -x $systemdutildir/systemd ]] && [[ -x /usr/lib/ostree/ostree-prepare-root ]]; then 26 | return 255 27 | fi 28 | 29 | return 1 30 | } 31 | 32 | depends() { 33 | return 0 34 | } 35 | 36 | install() { 37 | dracut_install /usr/lib/ostree/ostree-prepare-root 38 | inst_simple "${systemdsystemunitdir}/ostree-prepare-root.service" 39 | mkdir -p "${initdir}${systemdsystemconfdir}/initrd-root-fs.target.wants" 40 | ln_r "${systemdsystemunitdir}/ostree-prepare-root.service" \ 41 | "${systemdsystemconfdir}/initrd-root-fs.target.wants/ostree-prepare-root.service" 42 | } 43 | -------------------------------------------------------------------------------- /tests/libostreetest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Colin Walters 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | * 21 | * Author: Colin Walters 22 | */ 23 | 24 | #pragma once 25 | 26 | #include 27 | #include 28 | 29 | G_BEGIN_DECLS 30 | 31 | gboolean ot_test_run_libtest (const char *cmd, GError **error); 32 | 33 | OstreeRepo *ot_test_setup_repo (GCancellable *cancellable, 34 | GError **error); 35 | 36 | gboolean ot_check_relabeling (gboolean *can_relabel, 37 | GError **error); 38 | 39 | gboolean ot_check_user_xattrs (gboolean *has_user_xattrs, 40 | GError **error); 41 | 42 | OstreeSysroot *ot_test_setup_sysroot (GCancellable *cancellable, 43 | GError **error); 44 | 45 | G_END_DECLS 46 | -------------------------------------------------------------------------------- /src/boot/ostree-remount.service: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2013 Colin Walters 2 | # 3 | # This library is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU Lesser General Public 5 | # License as published by the Free Software Foundation; either 6 | # version 2 of the License, or (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public 14 | # License along with this library; if not, write to the 15 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 | # Boston, MA 02111-1307, USA. 17 | 18 | [Unit] 19 | Description=OSTree Remount OS/ Bind Mounts 20 | Documentation=man:ostree(1) 21 | DefaultDependencies=no 22 | ConditionKernelCommandLine=ostree 23 | OnFailure=emergency.target 24 | Conflicts=umount.target 25 | # Run after core mounts 26 | After=-.mount var.mount 27 | After=systemd-remount-fs.service 28 | # But we run *before* most other core bootup services that need write access to /etc and /var 29 | Before=local-fs.target umount.target 30 | Before=systemd-random-seed.service plymouth-read-write.service systemd-journal-flush.service 31 | Before=systemd-tmpfiles-setup.service 32 | 33 | [Service] 34 | Type=oneshot 35 | RemainAfterExit=yes 36 | ExecStart=/usr/lib/ostree/ostree-remount 37 | StandardInput=null 38 | StandardOutput=syslog 39 | StandardError=syslog+console 40 | 41 | [Install] 42 | WantedBy=local-fs.target 43 | -------------------------------------------------------------------------------- /src/ostree/ot-remote-builtins.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Red Hat, Inc. 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #pragma once 23 | 24 | #include 25 | 26 | G_BEGIN_DECLS 27 | 28 | #define BUILTINPROTO(name) gboolean ot_remote_builtin_ ## name (int argc, char **argv, \ 29 | OstreeCommandInvocation *invocation, \ 30 | GCancellable *cancellable, GError **error) 31 | 32 | BUILTINPROTO(add); 33 | BUILTINPROTO(delete); 34 | BUILTINPROTO(gpg_import); 35 | BUILTINPROTO(list); 36 | #ifdef HAVE_LIBCURL_OR_LIBSOUP 37 | BUILTINPROTO(add_cookie); 38 | BUILTINPROTO(list_cookies); 39 | BUILTINPROTO(delete_cookie); 40 | #endif 41 | BUILTINPROTO(show_url); 42 | BUILTINPROTO(refs); 43 | BUILTINPROTO(summary); 44 | 45 | #undef BUILTINPROTO 46 | 47 | G_END_DECLS 48 | -------------------------------------------------------------------------------- /tests/test-admin-deploy-clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2015 Colin Walters 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | . $(dirname $0)/libtest.sh 25 | 26 | # Exports OSTREE_SYSROOT so --sysroot not needed. 27 | setup_os_repository "archive" "syslinux" 28 | 29 | echo "1..1" 30 | 31 | ${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime 32 | rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime) 33 | export rev 34 | ${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime 35 | ${CMD_PREFIX} ostree admin undeploy 0 36 | ${CMD_PREFIX} ostree --repo=sysroot/ostree/repo refs > refs.txt 37 | assert_not_file_has_content refs.txt '^ostree/' 38 | 39 | echo "ok deploy + undeploy repo prune" 40 | -------------------------------------------------------------------------------- /src/libostree/ostree-bootloader-uboot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Collabora Ltd 3 | * 4 | * Based on ot-bootloader-syslinux.h by Colin Walters 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundation; either version 2 of the licence or (at 9 | * your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General 17 | * Public License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | * 21 | * Author: Javier Martinez Canillas 22 | */ 23 | 24 | #pragma once 25 | 26 | #include "ostree-bootloader.h" 27 | 28 | G_BEGIN_DECLS 29 | 30 | #define OSTREE_TYPE_BOOTLOADER_UBOOT (_ostree_bootloader_uboot_get_type ()) 31 | #define OSTREE_BOOTLOADER_UBOOT(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), OSTREE_TYPE_BOOTLOADER_UBOOT, OstreeBootloaderUboot)) 32 | #define OSTREE_IS_BOOTLOADER_UBOOT(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), OSTREE_TYPE_BOOTLOADER_UBOOT)) 33 | 34 | typedef struct _OstreeBootloaderUboot OstreeBootloaderUboot; 35 | 36 | GType _ostree_bootloader_uboot_get_type (void) G_GNUC_CONST; 37 | 38 | OstreeBootloaderUboot * _ostree_bootloader_uboot_new (OstreeSysroot *sysroot); 39 | 40 | G_END_DECLS 41 | -------------------------------------------------------------------------------- /src/libostree/ostree-bootloader-grub2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Colin Walters 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation; either version 2 of the licence or (at 7 | * your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General 15 | * Public License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "ostree-bootloader.h" 23 | 24 | G_BEGIN_DECLS 25 | 26 | #define OSTREE_TYPE_BOOTLOADER_GRUB2 (_ostree_bootloader_grub2_get_type ()) 27 | #define OSTREE_BOOTLOADER_GRUB2(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), OSTREE_TYPE_BOOTLOADER_GRUB2, OstreeBootloaderGrub2)) 28 | #define OSTREE_IS_BOOTLOADER_GRUB2(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), OSTREE_TYPE_BOOTLOADER_GRUB2)) 29 | 30 | typedef struct _OstreeBootloaderGrub2 OstreeBootloaderGrub2; 31 | 32 | GType _ostree_bootloader_grub2_get_type (void) G_GNUC_CONST; 33 | 34 | OstreeBootloaderGrub2 * _ostree_bootloader_grub2_new (OstreeSysroot *sysroot); 35 | 36 | gboolean _ostree_bootloader_grub2_generate_config (OstreeSysroot *sysroot, int bootversion, int target_fd, GCancellable *cancellable, GError **error); 37 | 38 | G_END_DECLS 39 | -------------------------------------------------------------------------------- /tests/test-pull-commit-only.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2015 Red Hat, Inc. 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | . $(dirname $0)/libtest.sh 25 | 26 | setup_fake_remote_repo1 "archive" 27 | 28 | echo '1..1' 29 | 30 | cd ${test_tmpdir} 31 | mkdir repo 32 | ostree_repo_init repo 33 | ${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo 34 | 35 | ${CMD_PREFIX} ostree --repo=repo pull --commit-metadata-only origin main 36 | find repo/objects -name '*.commit' | wc -l > commitcount 37 | assert_file_has_content commitcount "^1$" 38 | ${CMD_PREFIX} ostree --repo=repo fsck 39 | 40 | find repo/objects -name '*.file.*' | wc -l > commitcount 41 | assert_file_has_content commitcount "^0$" 42 | 43 | find repo/objects -name '*.dirtree' | wc -l > commitcount 44 | assert_file_has_content commitcount "^0$" 45 | 46 | echo "ok pull commit metadata only" 47 | -------------------------------------------------------------------------------- /ci/ci-release-build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | # Makes sure that is_release_build is only set to yes in a release commit. A 5 | # release commit must be titled: "Release $MAJOR.$MINOR". Also checks that the 6 | # release version in the build system matches the commit msg. 7 | 8 | # if running under PAPR, use the branch/PR HEAD actually 9 | # being tested rather than the merge sha 10 | HEAD=${PAPR_COMMIT:-HEAD} 11 | 12 | git log --format=%B -n 1 $HEAD > log.txt 13 | 14 | if grep -q ^is_release_build=yes configure.ac; then 15 | echo "*** is_release_build is set to yes ***" 16 | 17 | V=$(grep -Po '^#define PACKAGE_VERSION "\K[0-9]+\.[0-9]+(?=")' config.h) 18 | if [ -z "$V" ]; then 19 | echo "ERROR: couldn't read PACKAGE_VERSION" 20 | exit 1 21 | fi 22 | echo "OK: release version is $V" 23 | 24 | # check if the commit title indicates a release and has the correct version 25 | if ! grep -q "^Release $V" log.txt; then 26 | echo "ERROR: release commit doesn't match version" 27 | echo "Commit message:" 28 | cat log.txt 29 | echo "Build version: $V" 30 | exit 1 31 | fi 32 | echo "OK: release commit matches version" 33 | 34 | if grep -q "^LIBOSTREE_$V" src/libostree/libostree-devel.sym; then 35 | echo "ERROR: devel syms still references release version" 36 | exit 1 37 | fi 38 | echo "OK: devel syms no longer reference release version" 39 | 40 | else 41 | echo "*** is_release_build is set to no ***" 42 | 43 | if grep -qE "^Release [0-9]+\.[0-9]+" log.txt; then 44 | echo "ERROR: release commit does not have is_release_build=yes" 45 | exit 1 46 | fi 47 | echo "OK: commit is not a release" 48 | fi 49 | -------------------------------------------------------------------------------- /src/libostree/ostree.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011,2013 Colin Walters 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #pragma once 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | -------------------------------------------------------------------------------- /tests/test-pull-large-metadata.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2011 Colin Walters 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | . $(dirname $0)/libtest.sh 25 | 26 | setup_fake_remote_repo1 "archive" 27 | 28 | echo '1..1' 29 | 30 | # Overwrite the commit object with 20 M of 31 | cd ${test_tmpdir} 32 | rev=$(cd ostree-srv && ${CMD_PREFIX} ostree --repo=gnomerepo rev-parse main) 33 | dd if=/dev/zero bs=1M count=20 of=ostree-srv/gnomerepo/objects/$(echo $rev | cut -b 1-2)/$(echo $rev | cut -b 3-).commit 34 | 35 | cd ${test_tmpdir} 36 | mkdir repo 37 | ostree_repo_init repo 38 | ${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo 39 | 40 | if ${CMD_PREFIX} ostree --repo=repo pull origin main 2>pulllog.txt 1>&2; then 41 | assert_not_reached "pull unexpectedly succeeded!" 42 | fi 43 | assert_file_has_content pulllog.txt "exceeded maximum" 44 | 45 | echo "ok" 46 | -------------------------------------------------------------------------------- /ci/rpmostree.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Build and run rpm-ostree's unit tests using the just-built ostree for this PR. 3 | 4 | set -xeuo pipefail 5 | 6 | # Frozen to a tag for now to help predictability; it's 7 | # also useful to test building *older* versions since 8 | # that must work. 9 | RPMOSTREE_TAG=v2019.4 10 | 11 | dn=$(dirname $0) 12 | . ${dn}/libbuild.sh 13 | 14 | codedir=$(pwd) 15 | 16 | pkg_upgrade 17 | pkg_install_buildroot 18 | pkg_builddep ostree rpm-ostree 19 | pkg_install rpm-ostree && rpm -e rpm-ostree 20 | 21 | # Duplicate of deps from ci/installdeps.sh in rpm-ostree for tests 22 | pkg_install ostree{,-devel,-grub2} createrepo_c /usr/bin/jq python3-pyyaml \ 23 | libubsan libasan libtsan elfutils fuse sudo python3-gobject-base \ 24 | selinux-policy-devel selinux-policy-targeted python3-createrepo_c \ 25 | rsync python3-rpm parallel clang rustfmt-preview 26 | 27 | # From rpm-ostree/ci/vmcheck-provision.sh 28 | pkg_install openssh-clients ansible 29 | 30 | # build+install ostree 31 | cd ${codedir} 32 | build ${CONFIGOPTS:-} 33 | make install 34 | 35 | tmpd=$(mktemp -d) 36 | cd ${tmpd} 37 | git clone --recursive --depth=1 -b ${RPMOSTREE_TAG} https://github.com/projectatomic/rpm-ostree 38 | cd rpm-ostree 39 | build 40 | # We want to capture automake results 41 | cleanup() { 42 | mv test-suite.log ${codedir} || true 43 | mv vmcheck ${codedir} || true 44 | } 45 | trap cleanup EXIT 46 | make -j 8 check 47 | # Basic sanity test of rpm-ostree+new ostree by restarting rpm-ostreed 48 | if ! make vmsync; then 49 | ssh -o User=root vmcheck 'journalctl --no-pager | tail -1000' 50 | echo "vmsync failed"; exit 1 51 | fi 52 | # Now run tests; just a subset ⊂ for now to avoid CI overload 53 | make vmcheck TESTS="layering-basic-1 layering-basic-2" 54 | -------------------------------------------------------------------------------- /src/libostree/ostree-sepolicy-private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Colin Walters 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "ostree-types.h" 25 | 26 | G_BEGIN_DECLS 27 | 28 | typedef struct { 29 | gboolean initialized; 30 | } OstreeSepolicyFsCreatecon; 31 | 32 | void _ostree_sepolicy_fscreatecon_clear (OstreeSepolicyFsCreatecon *con); 33 | G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(OstreeSepolicyFsCreatecon, _ostree_sepolicy_fscreatecon_clear) 34 | 35 | gboolean _ostree_sepolicy_preparefscreatecon (OstreeSepolicyFsCreatecon *con, 36 | OstreeSePolicy *self, 37 | const char *path, 38 | guint32 mode, 39 | GError **error); 40 | 41 | GVariant *_ostree_filter_selinux_xattr (GVariant *xattrs); 42 | 43 | G_END_DECLS 44 | -------------------------------------------------------------------------------- /tests/test-admin-pull-deploy-commit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2015 Colin Walters 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | # See https://github.com/GNOME/ostree/pull/145 23 | 24 | set -euo pipefail 25 | 26 | . $(dirname $0)/libtest.sh 27 | 28 | echo "1..1" 29 | 30 | setup_os_repository "archive" "syslinux" 31 | 32 | cd ${test_tmpdir} 33 | ${CMD_PREFIX} ostree --repo=sysroot/ostree/repo remote add --set=gpg-verify=false testos $(cat httpd-address)/ostree/testos-repo 34 | ${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull testos testos/buildmaster/x86_64-runtime 35 | rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime) 36 | parent_rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse ${rev}^) 37 | ${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull testos ${parent_rev} 38 | ${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos ${parent_rev} 39 | 40 | echo 'ok deploy pulled commit' 41 | -------------------------------------------------------------------------------- /tests/gpghome/key1.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | Version: GnuPG v1 3 | 4 | mQENBFIuhBYBCADTbnocQsJgMfOELkFt3wRrAZShijoBPYZT9BrIuIKZxAbaxZJr 5 | Tbw8eIGgHZ51NCfdoikul0i82dt4hwtsACNVL5EGRmvTIKHPacb0yJMr1YBjcSwD 6 | Slo+niLPb/oVtLTbDWFt/msYKREF/lGJT9dJyXkQ5UOwWdipDaHIlwb0IKUvL7cu 7 | NpNthRFRm1M5d5M9OtqTCrCja6zckQ6OfvoStsbneHzfVWeH7vLcKBxxkfDhusVt 8 | y1iVaDk1EYT8ZxsrAWw4S7nRK/bjr86IYpFPjG2aKMd9qxyIo7hcX4r8od24jzfM 9 | v/ysOapnkTJuv8J6v7MakM1HkCz+TKF6gXxVABEBAAG0HU9zdHJlZSBUZXN0ZXIg 10 | PHRlc3RAdGVzdC5jb20+iQE5BBMBAgAjBQJSLoQWAhsDBwsJCAcDAgEGFQgCCQoL 11 | BBYCAwECHgECF4AACgkQf8oj2Ecs2vr/9wgAnme6WsWQy8CYeGH4q/5I6XFL6q1m 12 | S0+qdeGnYRmR0jJAGJ84vqDhnKxjeQzp+8Nq81DHGEJBszCkMW2o22neFi2Mo95h 13 | Dq3GWNZVldCDshjPs563AY6j7zACUN7Cy5XB3MK/vj5R/SrHBtJmSgPTx9WfmUgn 14 | n5Udg+fzSsS8z8DUtJFtexgrSnEmwH+nOmIfrsjIYL5EPg+CTTalhygROrERjINr 15 | pCYiShaFCKbuyt/XvyQ71y0JbB2yS7tDv0mL4SZjSuBQ1PkNE8ZQsymqBOJHA1Y3 16 | ppgPs1OenmtYgxaR8HQQv7uxHWZz0dmwQN93Qx8zMZwW40Odmdh1zLNQf7kBDQRS 17 | LoQWAQgA9i9QWg28qmFrPIzn90ZlNlUtFzoZy/8/lIk34awge1uO5aHydYBzkuWU 18 | jCDyBtQLWZQlwOKq8oHBbjENR2sfsmNkrYKcceQ02hSXqEJkc6jcDMCpB9eWy34K 19 | sPZmdl76Eo/vIIgRqJ9JPeGoMPaIBg2ouEz6Ft6jcX3EriYIKebCEA9wPk29z40x 20 | 7D8mBZn06WrZ3JyePfbCdNJlQANEnrk7KDMNwPhhE1wcfPkiVtqBR0/FwIoUP0jn 21 | PishIWOuFObYnXQQ2R8sxrw/V0hGqVTh+k+iNAjzEp4yPsAvB+LdMH9nCY5rU3Vo 22 | 1paEqVM1EHoBPu4NupRN0AjIJPr5UQARAQABiQEfBBgBAgAJBQJSLoQWAhsMAAoJ 23 | EH/KI9hHLNr68i4IAMdc+EgAaPZFWZcXFGBfhnOKQFC/u/W6Cu1JjqIYkGO0HxSh 24 | SfBkxArqlp37w4YVH4bUku6ja421bfGFNMtMfXjw2mU3HRdaDenP6OGv2jYmYmFt 25 | 6zi0JZZhvi8ZCcAQTStZ2Ms3hwstCMiBXPmYA7KW9Gzo4JQSKCW5haICGVSWl7kh 26 | n0OkhOTVI9uzNr7+LhYn2ib/ynSaMKeI4hZ8v1HDuY0V1E63vFPGLFBTPaoRPpnm 27 | 9yBnXMWhrbV97L6eEoe7faurSyPcF11LEFC5x8oENnbH+wtAXOayQo3lld+JRa9C 28 | JEZl8STdRU9o2NFwF8XM8BEOWntMS8aNpPoILC8= 29 | =ZNNc 30 | -----END PGP PUBLIC KEY BLOCK----- 31 | -------------------------------------------------------------------------------- /tests/gpghome/key2.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | Version: GnuPG v1 3 | 4 | mQENBFUIM4ABCADYBuvzGgzv5nMy2wICv79l+N4bN9/o9hTdFEOzyAeCEaF5Wugc 5 | L9nfTgUS9NRHsSpGt9DeZVEzRm5XzccgHOPs7MlYH0Irhc4Hb9ycOO2vBZ7ZiBK/ 6 | jbY+R5GN4Ut9XIRexbXWddOjJpRUTCWQeXw5iqV9Puqm1ge2Vcal+NZOi2AFRKKe 7 | p/QI9EXIIx7ca6OWtH2SS/qE2p9obDYsMNrW+Dk623dbNKQiWaWyfRD+hB91UNbt 8 | vK7agokTeU0hKr9C8dHrhepgl9B/Hz8SFibZQQiTxSiVH3fUu10eQsyuDC/01KHp 9 | z0MR28Lc4VlCs6dsJBmGMBayHHVzbyXgw6uZABEBAAG0IU9zdHJlZSBUZXN0ZXIg 10 | SUkgPHRlc3QyQHRlc3QuY29tPokBOAQTAQIAIgUCVQgzgAIbAwYLCQgHAwIGFQgC 11 | CQoLBBYCAwECHgECF4AACgkQ2CKM/sqVDUFpJAgAirtYbbkvnlKtBxDsCu+A6qyl 12 | 7r+cW8IH5U1P4MqxqQwkAe1ZalfjuTSHVKYqt/K6gt0+4NvCee3A2JxXTvLq1hdR 13 | DNMUFAjkbZv3Y6VS8Qtj3edsviNEB7s8uyWgR/EBB312YSZCwzk5uSLzM5E7AmvM 14 | 0/ZPIAAxjz8TpQKc8vJx1/4nqgt0Wjv5B74vuOQJT26zoFygCQM76YeN+ULzk/hN 15 | hW7aNp/S2STasvEv7NgwqAe6eWy45xTrvxhEhQV760/toLbI0DuuBGr6Ue/G+Id4 16 | P/R604HAbMg3GdCztyoD3WTuvcsY6oXD7GlSEX4DZ0LA2TqQDZB+Pqe2yF7Gi7kB 17 | DQRVCDOAAQgAsxH2E9JeQPbcdXGyxLCa4FyMeziCrxn7tOEsRkeqZmb76mAOn67Q 18 | ZuZ6SXcAQDjKOBu7QNEcFQ+bAW/urohzD/sjr09vKqibLh6v8t81DE79GHI1UZ7F 19 | SuYDLgcGUvOCJej8iftJcudWuzCW9SvoykNcgPcIOYEXbbJVRr2xvK4z2a34DyWL 20 | jEXU2r6g1KNwtGyT6hZ7Ax99MKAzCFX3to0V51EXcrnUojwz/8i4Lal9t3d4P3lu 21 | FZw3ITWh4e9zNxp8aSxsAN/vQ1EHccMPrNmO+d+yjhH7inTxf+vLErP3Cs5rPjxl 22 | FgoLvBCSCT0jQ0xP+8Aa2TDyXDcMHg85QwARAQABiQEfBBgBAgAJBQJVCDOAAhsM 23 | AAoJENgijP7KlQ1Bc68H/RBn5PpUe8CA1CJ8eN4LIfRee3DjacwvjGsdgiMzcLhb 24 | Hp/ke42kentYjT+gF1ABPbeUERDlhnZ8BguKGZV+jOGDWRI2KFrQXL444aNznjn8 25 | aTOQY/d4LibwSaQ3qzf4Zp4CyZq2X2Vg3+B3HoUM6pkIL/r2ao5TnFqKubCE3sEo 26 | St+LV4eHktoAS1GXmxYKo4Q67yMVekTZt7C/VQ2a20qfAXBn2U8UA3tUvNqKtyyJ 27 | XrxeTJ+T4MMv60zdC/B/UPNjjHLNyB6culIzyiYFglGw3ctx2erJN2d+aQLrw78E 28 | vIuMy+JcH6y3JlzVGdByWbC7628OcWWa+NL/CXnYMyQ= 29 | =j9RC 30 | -----END PGP PUBLIC KEY BLOCK----- 31 | -------------------------------------------------------------------------------- /tests/gpghome/key3.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | Version: GnuPG v1 3 | 4 | mQENBFUIM6EBCACr57QUYEEuxvkX20yM1LVt2jyYZRKKQsqXx/xCF+Pg1MNz6mYx 5 | Qz6R6+yZZmlADsfRdnEpRvl4Dq2g3cP0DqkjnIKwI7ffEsyXlves8OMlpwT2Vh4x 6 | 8Lx92eIEeqmb+PT8m88+x+EPVaR2R5KBHFkGXGyVgw+Ry8Oa9ZtJEKSkL/EQvzWv 7 | 5q+OR1Pm8rnIPe64XPh3yAx5SBJ2m7hykH/XMVrdGqaZvpuGBx77pmmqfMMjNWMC 8 | U09hURyuyGWUsj9lFWYgpBvAzASmJNpAf7FZTjzCwLJwqpxCYm6a3sp76yyjuY7q 9 | vgJOolRHp9F/XETsSLdy6966oBxclGNaD6gnABEBAAG0Ik9zdHJlZSBUZXN0ZXIg 10 | SUlJIDx0ZXN0M0B0ZXN0LmNvbT6JATgEEwECACIFAlUIM6ECGwMGCwkIBwMCBhUI 11 | AgkKCwQWAgMBAh4BAheAAAoJEA0V+uffRE1n0n4H/0Z8bC1cdr5cMFZ6YBaJlw4c 12 | b61krhan2qCrwQupwaXi6LHt0zMwgljOcN+X2sAlZj9Jv0CabU5S1vM1fh9DZ6OY 13 | 2OQ/Pq2lXGk22JjrbPPq5o//xTzo92Uxptuxq6O4frVzuGCo1yPlrHJh+TxbXIc8 14 | XOz9C9KTfcb9OwidSSW5LlUBzQ2e3oQLSUQPsdB3TZP5zlqPIYerWn+LdETKcOTr 15 | JyoaobFqX2BN223d3vkA1/GcuB17eBnzbnS0OWLJH+E3bsCqjtCJMEc1uTq97tyF 16 | XStIk9i0gVbA+GiK/ZFMt+a5kagR5dOUwpNZ0BE+Kzf0CtkSaSWkAh1vQV/j2E65 17 | AQ0EVQgzoQEIAMeXa6sp5kdmJn/fVw0Pk5oluBXif7BiFt+T7K03RxCOKRpne6dI 18 | SS98ruwZ1B5hn0lZO0UiL5RKpBQUrI9Y7251tz+oWohU2ZkUwwP3OcBlTXtErhe0 19 | LctcJ1nUA5NICVP5brhJR94durULiM+Rrhr12Ccs+a9bV268btNLN51z7ICMwNI6 20 | xuNxLt9orVJwP82a2eelQOgkPyFpiq7UxZ1erJg4aBVfWHP+rlxyQlzawVebbQMO 21 | gwYW+gAawTxd2x7PV9CC3KsaM+HI6wBvDOtcWlbzo+TxzcVocd5oern4Mr5Y86Gt 22 | lajuO9DVsuxxIfBrvHdRut613ShhOVlfy2MAEQEAAYkBHwQYAQIACQUCVQgzoQIb 23 | DAAKCRANFfrn30RNZyPVB/9jNFOjcNCAZSrz9vylaO0xHsPhIn4osmkiU6BvodwO 24 | n+qR4eEUw7BzoWC5QqGxUPYuDneQK7N7U31SFYjmY5Y1CDMsFtcYzjPgN5qWhtaN 25 | iNTtE9pb5f97PyLSUwcdW1y/cfDfqoAY6rpRXieo7hJv1xBtlEzJIbSSTS1SUEd1 26 | 4qwPCqNWMSM6qBcaFB5Yuw0Z/E6B1JfNTUw5J5jDxbGdOzkLx2mXCldte1axq9Lp 27 | 1V17jMTvn7Ml1QdoEAqzvt4VNQci/Su/qd3XjQ46b4dFFP03+jJv7mO6tHka2luZ 28 | RX0zfsk5q8wqbtV2k0XZFRD+22ddKMf1j4wID157lNQs 29 | =Dq+d 30 | -----END PGP PUBLIC KEY BLOCK----- 31 | -------------------------------------------------------------------------------- /manual-tests/static-delta-generate-crosscheck.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Generate multiple variants of static deltas in a repo, then use them 4 | # to upgrade in a test repository, verifying that fsck works. 5 | # 6 | # This test is manual so it's easy to run against arbitrary content. 7 | 8 | set -euo pipefail 9 | 10 | repo=$(pwd)/${1} 11 | shift 12 | branch=${1} 13 | shift 14 | 15 | from=$(ostree --repo=${repo} rev-parse "${branch}"^) 16 | to=$(ostree --repo=${repo} rev-parse ${branch}) 17 | 18 | tmpdir=$(mktemp -d /var/tmp/ostree-delta-check.XXXXXX) 19 | cd ${tmpdir} 20 | touch ${tmpdir}/.tmp 21 | echo "Using tmpdir ${tmpdir}" 22 | 23 | cleanup_tmpdir() { 24 | if test -f ${tmpdir}/.tmp; then 25 | rm -rf ${tmpdir} 26 | fi 27 | } 28 | 29 | if test -z "${PRESERVE_TMP:-}"; then 30 | trap cleanup_tmpdir EXIT 31 | fi 32 | 33 | fatal() { 34 | echo "$@" 35 | exit 1 36 | } 37 | 38 | assert_streq() { 39 | if ! test $1 = $2; then 40 | fatal "assertion failed: $1 = $2" 41 | fi 42 | } 43 | 44 | validate_delta_options() { 45 | ostree --repo=testrepo init --mode=bare-user 46 | echo 'fsync=false' >> testrepo/config 47 | ostree --repo=testrepo remote add --set=gpg-verify=false local file://${repo} 48 | ostree --repo=${repo} static-delta generate $@ --from=${from} --to=${to} 49 | ostree --repo=${repo} summary -u 50 | ostree --repo=testrepo pull local ${branch}@${from} 51 | assert_streq $(ostree --repo=testrepo rev-parse ${branch}) ${from} 52 | ostree --repo=testrepo pull --require-static-deltas local ${branch} 53 | assert_streq $(ostree --repo=testrepo rev-parse ${branch}) ${to} 54 | ostree --repo=testrepo fsck 55 | rm testrepo -rf 56 | } 57 | 58 | set -x 59 | 60 | validate_delta_options 61 | validate_delta_options --inline 62 | validate_delta_options --disable-bsdiff 63 | -------------------------------------------------------------------------------- /src/ostree/ot-admin-builtins.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Colin Walters 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | * 21 | * Author: Colin Walters 22 | */ 23 | 24 | #pragma once 25 | 26 | #include 27 | 28 | G_BEGIN_DECLS 29 | 30 | #define BUILTINPROTO(name) gboolean ot_admin_builtin_ ## name (int argc, char **argv, \ 31 | OstreeCommandInvocation *invocation, \ 32 | GCancellable *cancellable, GError **error) 33 | 34 | BUILTINPROTO(selinux_ensure_labeled); 35 | BUILTINPROTO(os_init); 36 | BUILTINPROTO(install); 37 | BUILTINPROTO(instutil); 38 | BUILTINPROTO(init_fs); 39 | BUILTINPROTO(undeploy); 40 | BUILTINPROTO(deploy); 41 | BUILTINPROTO(cleanup); 42 | BUILTINPROTO(pin); 43 | BUILTINPROTO(finalize_staged); 44 | BUILTINPROTO(unlock); 45 | BUILTINPROTO(status); 46 | BUILTINPROTO(set_origin); 47 | BUILTINPROTO(diff); 48 | BUILTINPROTO(switch); 49 | BUILTINPROTO(upgrade); 50 | 51 | #undef BUILTINPROTO 52 | 53 | G_END_DECLS 54 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | * Documentation 2 | - More gtk-doc 3 | 4 | * Local metadata packs 5 | - Just to avoid lots of little files on each client 6 | 7 | * Hybrid SSL pull (fetch refs over SSL, content via plain HTTP) 8 | 9 | * ostree-commit: multithreaded/async (basically compute sha256 in parallel) 10 | - Also speed up devino cache by having a big mmappable file that maps from 11 | (device, inode) -> checksum. We need to keep the cache up to date; 12 | investigate something like http://www.sqlite.org/wal.html for having 13 | a shared file. 14 | 15 | * https://bugzilla.gnome.org/show_bug.cgi?id=721799 16 | https://mail.gnome.org/archives/ostree-list/2013-July/msg00005.html 17 | Efficient delta format between commit objects, somewhat like 18 | Chromium autoupdate: set of operations to perform given previous 19 | object set to create new objects. 20 | 21 | * Flexible "prune" that allows keeping only a rolling subset of history. 22 | For example, keep the last week, keep at least 1 build a week up 23 | till a year ago, then 1 build a month, etc. Optionally rewrite commit 24 | parent history? 25 | 26 | * Tests of corrupted repositories, more error conditions 27 | 28 | * Structured output from commandline? ostree --output={table,gvariant} ? 29 | 30 | * Better output on a tty - progress bars 31 | Needs size metadata; see https://bugzilla.gnome.org/show_bug.cgi?id=709050 32 | https://bugzilla.gnome.org/show_bug.cgi?id=721799 33 | 34 | * Do HTTP requests as unprivileged user (particularly before we've 35 | done GPG verification) 36 | https://bugzilla.gnome.org/show_bug.cgi?id=730037 37 | 38 | * Reintroduce "ostree admin install": Could pull in host data, 39 | such as uids and /etc/fstab. 40 | 41 | * Possibly move all of the "regular" commands to be "ostree repo" ? Then 42 | we'd have: "ostree repo pull", "ostree repo ls", etc. 43 | 44 | * Multiple backends (BTRFS, etc.) 45 | 46 | * PackageKit backend 47 | -------------------------------------------------------------------------------- /tests/kolainst/nondestructive/itest-bare-user-root.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Tests of the "raw ostree" functionality using the host's ostree repo as uid 0. 4 | 5 | set -xeuo pipefail 6 | 7 | . ${KOLA_EXT_DATA}/libinsttest.sh 8 | 9 | echo "1..1" 10 | date 11 | 12 | prepare_tmpdir 13 | ostree --repo=repo init --mode=bare-user 14 | mkdir -p components/{dbus,systemd}/usr/{bin,lib} 15 | echo dbus binary > components/dbus/usr/bin/dbus-daemon 16 | chmod a+x components/dbus/usr/bin/dbus-daemon 17 | echo dbus lib > components/dbus/usr/lib/libdbus.so.1 18 | echo dbus helper > components/dbus/usr/lib/dbus-daemon-helper 19 | chmod a+x components/dbus/usr/lib/dbus-daemon-helper 20 | echo systemd binary > components/systemd/usr/bin/systemd 21 | chmod a+x components/systemd/usr/bin/systemd 22 | echo systemd lib > components/systemd/usr/lib/libsystemd.so.1 23 | 24 | # Make the gid on dbus 81 like fedora, also ensure no xattrs 25 | ostree --repo=repo commit --no-xattrs -b component-dbus --owner-uid 0 --owner-gid 81 --tree=dir=components/dbus 26 | ostree --repo=repo commit --no-xattrs -b component-systemd --owner-uid 0 --owner-gid 0 --tree=dir=components/systemd 27 | rm rootfs -rf 28 | for component in dbus systemd; do 29 | ostree --repo=repo checkout -U -H component-${component} --union rootfs 30 | done 31 | echo 'some rootfs data' > rootfs/usr/lib/cache.txt 32 | # Commit using the host's selinux policy 33 | ostree --repo=repo commit --selinux-policy / -b rootfs --link-checkout-speedup --tree=dir=rootfs 34 | ostree --repo=repo ls rootfs /usr/bin/systemd >ls.txt 35 | assert_file_has_content ls.txt '^-007.. 0 0 .*/usr/bin/systemd' 36 | ostree --repo=repo ls -X rootfs /usr/lib/dbus-daemon-helper >ls.txt 37 | assert_file_has_content ls.txt '^-007.. 0 81 .*security\.selinux.*/usr/lib/dbus-daemon-helper' 38 | assert_not_file_has_content ls.txt 'user\.ostreemeta' 39 | echo "ok bare-user link-checkout-speedup with modified xattrs maintains uids" 40 | date 41 | -------------------------------------------------------------------------------- /src/ostree/ot-admin-builtin-cleanup.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Colin Walters 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | * 21 | * Author: Colin Walters 22 | */ 23 | 24 | #include "config.h" 25 | 26 | #include "ot-main.h" 27 | #include "ot-admin-builtins.h" 28 | #include "ot-admin-functions.h" 29 | #include "ostree.h" 30 | 31 | #include 32 | 33 | static GOptionEntry options[] = { 34 | { NULL } 35 | }; 36 | 37 | gboolean 38 | ot_admin_builtin_cleanup (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error) 39 | { 40 | g_autoptr(GOptionContext) context = g_option_context_new (""); 41 | 42 | g_autoptr(OstreeSysroot) sysroot = NULL; 43 | if (!ostree_admin_option_context_parse (context, options, &argc, &argv, 44 | OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER, 45 | invocation, &sysroot, cancellable, error)) 46 | return FALSE; 47 | 48 | if (!ostree_sysroot_cleanup (sysroot, cancellable, error)) 49 | return FALSE; 50 | 51 | return TRUE; 52 | } 53 | -------------------------------------------------------------------------------- /tests/test-pull-resume.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2013 Jeremy Whiting 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | . $(dirname $0)/libtest.sh 25 | 26 | setup_fake_remote_repo1 "archive" "" "--force-range-requests" 27 | 28 | echo '1..1' 29 | 30 | repopath=${test_tmpdir}/ostree-srv/gnomerepo 31 | cp -a ${repopath} ${repopath}.orig 32 | 33 | cd ${test_tmpdir} 34 | rm repo -rf 35 | mkdir repo 36 | ostree_repo_init repo 37 | ${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo 38 | 39 | maxtries=`find ${repopath}/objects | wc -l` 40 | maxtries=`expr $maxtries \* 2` 41 | 42 | for ((i = 0; i < $maxtries; i=i+1)) 43 | do 44 | if ${CMD_PREFIX} ostree --repo=repo pull origin main 2>err.log; then 45 | break 46 | fi 47 | assert_file_has_content err.log 'error:.*\(Download incomplete\)\|\(Transferred a partial file\)' 48 | done 49 | if ${CMD_PREFIX} ostree --repo=repo fsck; then 50 | echo "ok, pull succeeded!" 51 | else 52 | assert_not_reached "pull failed!" 53 | fi 54 | rm -rf ${repopath} 55 | cp -a ${repopath}.orig ${repopath} 56 | -------------------------------------------------------------------------------- /Makefile-decls.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011,2014 Colin Walters 2 | # 3 | # SPDX-License-Identifier: LGPL-2.0+ 4 | # 5 | # This library is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU Lesser General Public 7 | # License as published by the Free Software Foundation; either 8 | # version 2 of the License, or (at your option) any later version. 9 | # 10 | # This library is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public 16 | # License along with this library; if not, write to the 17 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | # Boston, MA 02111-1307, USA. 19 | 20 | # Common variables 21 | AM_CPPFLAGS = 22 | AM_CFLAGS = 23 | AM_DISTCHECK_CONFIGURE_FLAGS = 24 | SUBDIRS = 25 | NULL = 26 | BUILT_SOURCES = 27 | MANPAGES = 28 | CLEANFILES = 29 | EXTRA_DIST = 30 | bin_PROGRAMS = 31 | sbin_PROGRAMS = 32 | bin_SCRIPTS = 33 | lib_LTLIBRARIES = 34 | libexec_PROGRAMS = 35 | pkglibexec_PROGRAMS = 36 | pkglibexec_SCRIPTS = 37 | noinst_LTLIBRARIES = 38 | noinst_PROGRAMS = 39 | privlibdir = $(pkglibdir) 40 | privlib_LTLIBRARIES = 41 | pkgconfigdir = $(libdir)/pkgconfig 42 | pkgconfig_DATA = 43 | INTROSPECTION_GIRS = 44 | girdir = $(datadir)/gir-1.0 45 | gir_DATA = 46 | typelibdir = $(libdir)/girepository-1.0 47 | typelib_DATA = 48 | gsettings_SCHEMAS = 49 | ostree_bootdir = $(prefix)/lib/ostree 50 | ostree_boot_SCRIPTS = 51 | ostree_boot_PROGRAMS = 52 | 53 | # This initializes some more variables 54 | include $(top_srcdir)/buildutil/glib-tap.mk 55 | 56 | # This is a special facility to chain together hooks easily 57 | INSTALL_DATA_HOOKS = 58 | install-data-hook: $(INSTALL_DATA_HOOKS) 59 | 60 | ALL_LOCAL_RULES = 61 | all-local: $(ALL_LOCAL_RULES) 62 | -------------------------------------------------------------------------------- /src/ostree/ot-admin-functions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Colin Walters 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | * 21 | * Author: Colin Walters 22 | */ 23 | 24 | #pragma once 25 | 26 | #include 27 | #include 28 | 29 | G_BEGIN_DECLS 30 | 31 | gboolean 32 | ot_admin_require_booted_deployment_or_osname (OstreeSysroot *sysroot, 33 | const char *osname, 34 | GCancellable *cancellable, 35 | GError **error); 36 | 37 | char * 38 | ot_admin_checksum_version (GVariant *checksum); 39 | 40 | OstreeDeployment * 41 | ot_admin_get_indexed_deployment (OstreeSysroot *sysroot, 42 | int index, 43 | GError **error); 44 | 45 | gboolean 46 | ot_admin_sysroot_lock (OstreeSysroot *sysroot, 47 | GError **error); 48 | 49 | gboolean 50 | ot_admin_execve_reboot (OstreeSysroot *sysroot, 51 | GError **error); 52 | 53 | G_END_DECLS 54 | -------------------------------------------------------------------------------- /tests/test-pre-signed-pull.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2020 Collabora Ltd. 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | . $(dirname $0)/libtest.sh 25 | 26 | echo "1..1" 27 | 28 | if ! has_sign_ed25519; then 29 | echo "ok pre-signed pull # SKIP due ed25519 unavailability" 30 | exit 0 31 | fi 32 | 33 | mkdir upstream 34 | cd upstream 35 | tar xzf $(dirname $0)/pre-signed-pull-data.tar.gz 36 | cd .. 37 | 38 | pubkey='45yzbkuEok0lLabxzdAHWUDSMZgYfxU40sN+LMfYHVA=' 39 | 40 | ostree --repo=repo init --mode=archive 41 | ostree --repo=repo remote add upstream --set=gpg-verify=false --sign-verify=ed25519=inline:${pubkey} file://$(pwd)/upstream/repo 42 | ostree --repo=repo pull upstream:testref 43 | 44 | wrongkey=$(gen_ed25519_random_public) 45 | rm repo -rf 46 | ostree --repo=repo init --mode=archive 47 | ostree --repo=repo remote add badupstream --set=gpg-verify=false --sign-verify=ed25519=inline:${wrongkey} file://$(pwd)/upstream/repo 48 | if ostree --repo=repo pull badupstream:testref 2>err.txt; then 49 | fatal "pulled with wrong key" 50 | fi 51 | assert_file_has_content err.txt 'error:.* ed25519: Signature couldn.t be verified with: key' 52 | echo "ok pre-signed pull" 53 | -------------------------------------------------------------------------------- /src/rofiles-fuse/README.md: -------------------------------------------------------------------------------- 1 | rofiles-fuse 2 | ============ 3 | 4 | Create a mountpoint that represents an underlying directory hierarchy, 5 | but where non-directory inodes cannot have content or xattrs changed. 6 | Files can still be unlinked, and new ones created. 7 | 8 | This filesystem is designed for OSTree and other systems that create 9 | "hardlink farms", i.e. filesystem trees deduplicated via hardlinks. 10 | 11 | Normally with hard links, if you change one, you change them all. 12 | 13 | There are two approaches to dealing with that: 14 | - Copy on write: implemented by BTRFS, overlayfs, and http://linux-vserver.org/util-vserver:Vhashify 15 | - Make them read-only: what this FUSE mount does 16 | 17 | Usage 18 | ===== 19 | 20 | Let's say that you have immutable data in `/srv/backups/20150410`, and 21 | you want to update it with a new version, storing the result in 22 | `/srv/backups/20150411`. Further assume that all software operating 23 | on the directory does the "create tempfile and `rename()`" dance 24 | rather than in-place edits. 25 | 26 | $ mkdir -p /srv/backups/mnt # Ensure we have a mount point 27 | $ cp -al /srv/backups/20150410 /srv/backups/20150411 28 | $ rofiles-fuse /srv/backups/20150411 /srv/backups/mnt 29 | 30 | Now we have a "rofiles" mount at `/srv/backups/mnt`. If we try this: 31 | 32 | $ echo new doc content > /srv/backups/mnt/document 33 | bash: /srv/backups/mnt/document: Read-only file system 34 | 35 | It failed because the `>` redirection operator will try to truncate 36 | the existing file. If instead we create `document.tmp` and then 37 | rename it atomically over the old one, it will work: 38 | 39 | $ echo new doc content > /srv/backups/mnt/document.tmp 40 | $ mv /srv/backups/mnt/document.tmp /srv/backups/mnt/document 41 | 42 | Let's unmount: 43 | 44 | $ fusermount -u /srv/backups/mnt 45 | 46 | Now we have two directories `/srv/backups/20150410` 47 | `/srv/backups/20150411` which share all file storage except for the 48 | new document. 49 | -------------------------------------------------------------------------------- /src/libostree/ostree-deployment-private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Colin Walters 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation; either version 2 of the licence or (at 7 | * your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General 15 | * Public License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "ostree-deployment.h" 23 | 24 | G_BEGIN_DECLS 25 | 26 | 27 | /** 28 | * OstreeDeployment: 29 | * @parent_instance: 30 | * @index: Global offset 31 | * @osname: 32 | * @csum: OSTree checksum of tree 33 | * @deployserial: How many times this particular csum appears in deployment list 34 | * @bootcsum: Checksum of kernel+initramfs 35 | * @bootserial: An integer assigned to this tree per its ${bootcsum} 36 | * @bootconfig: Bootloader configuration 37 | * @origin: How to construct an upgraded version of this tree 38 | * @unlocked: The unlocked state 39 | * @staged: TRUE iff this deployment is staged 40 | */ 41 | struct _OstreeDeployment 42 | { 43 | GObject parent_instance; 44 | 45 | int index; 46 | char *osname; 47 | char *csum; 48 | int deployserial; 49 | char *bootcsum; 50 | int bootserial; 51 | OstreeBootconfigParser *bootconfig; 52 | GKeyFile *origin; 53 | OstreeDeploymentUnlockedState unlocked; 54 | gboolean staged; 55 | }; 56 | 57 | void _ostree_deployment_set_bootcsum (OstreeDeployment *self, const char *bootcsum); 58 | 59 | G_END_DECLS 60 | -------------------------------------------------------------------------------- /src/libostree/ostree-enumtypes.c.template: -------------------------------------------------------------------------------- 1 | /*** BEGIN file-header ***/ 2 | /* 3 | * Copyright (C) 2015 Red Hat, Inc. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #include "config.h" 22 | #include 23 | 24 | #include "ostree-enumtypes.h" 25 | 26 | /*** END file-header ***/ 27 | 28 | /*** BEGIN file-production ***/ 29 | 30 | /* enumerations from "@filename@" */ 31 | #include "@filename@" 32 | 33 | /*** END file-production ***/ 34 | 35 | /*** BEGIN value-header ***/ 36 | GType 37 | _@enum_name@_get_type (void) 38 | { 39 | static volatile gsize the_type__volatile = 0; 40 | 41 | if (g_once_init_enter (&the_type__volatile)) 42 | { 43 | static const G@Type@Value values[] = { 44 | /*** END value-header ***/ 45 | 46 | /*** BEGIN value-production ***/ 47 | { @VALUENAME@, 48 | "@VALUENAME@", 49 | "@valuenick@" }, 50 | /*** END value-production ***/ 51 | 52 | /*** BEGIN value-tail ***/ 53 | { 0, NULL, NULL } 54 | }; 55 | 56 | GType the_type = g_@type@_register_static ( 57 | g_intern_static_string ("@EnumName@"), 58 | values); 59 | 60 | g_once_init_leave (&the_type__volatile, the_type); 61 | } 62 | 63 | return the_type__volatile; 64 | } 65 | 66 | /*** END value-tail ***/ 67 | -------------------------------------------------------------------------------- /src/libostree/ostree-remote.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2011 Colin Walters 3 | * Copyright © 2015 Red Hat, Inc. 4 | * Copyright © 2017 Endless Mobile, Inc. 5 | * 6 | * SPDX-License-Identifier: LGPL-2.0+ 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the 20 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 | * Boston, MA 02111-1307, USA. 22 | * 23 | * Authors: 24 | * - Colin Walters 25 | * - Philip Withnall 26 | */ 27 | 28 | #pragma once 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #include "ostree-types.h" 35 | 36 | G_BEGIN_DECLS 37 | 38 | /** 39 | * OstreeRemote: 40 | * 41 | * This represents the configuration for a single remote repository. Currently, 42 | * remotes can only be passed around as (reference counted) opaque handles. In 43 | * future, more API may be added to create and interrogate them. 44 | * 45 | * Since: 2018.6 46 | */ 47 | 48 | _OSTREE_PUBLIC 49 | GType ostree_remote_get_type (void) G_GNUC_CONST; 50 | _OSTREE_PUBLIC 51 | OstreeRemote *ostree_remote_ref (OstreeRemote *remote); 52 | _OSTREE_PUBLIC 53 | void ostree_remote_unref (OstreeRemote *remote); 54 | 55 | _OSTREE_PUBLIC 56 | const gchar *ostree_remote_get_name (OstreeRemote *remote); 57 | 58 | _OSTREE_PUBLIC 59 | gchar *ostree_remote_get_url (OstreeRemote *remote); 60 | 61 | G_END_DECLS 62 | -------------------------------------------------------------------------------- /src/libotutil/ot-variant-utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Colin Walters . 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | * 21 | * Author: Colin Walters 22 | */ 23 | 24 | #pragma once 25 | 26 | #include 27 | 28 | G_BEGIN_DECLS 29 | 30 | GVariant *ot_gvariant_new_bytearray (const guchar *data, 31 | gsize len); 32 | 33 | GVariant *ot_gvariant_new_ay_bytes (GBytes *bytes); 34 | 35 | GVariant *ot_gvariant_new_empty_string_dict (void); 36 | 37 | gboolean ot_variant_read_fd (int fd, 38 | goffset offset, 39 | const GVariantType *type, 40 | gboolean trusted, 41 | GVariant **out_variant, 42 | GError **error); 43 | 44 | GVariantBuilder *ot_util_variant_builder_from_variant (GVariant *variant, 45 | const GVariantType *type); 46 | 47 | gboolean 48 | ot_variant_bsearch_str (GVariant *array, 49 | const char *str, 50 | int *out_pos); 51 | 52 | G_END_DECLS 53 | -------------------------------------------------------------------------------- /src/libostree/ostree-lzma-compressor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Colin Walters 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General 17 | * Public License along with this library; if not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | G_BEGIN_DECLS 25 | 26 | #define OSTREE_TYPE_LZMA_COMPRESSOR (_ostree_lzma_compressor_get_type ()) 27 | #define OSTREE_LZMA_COMPRESSOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), OSTREE_TYPE_LZMA_COMPRESSOR, OstreeLzmaCompressor)) 28 | #define OSTREE_LZMA_COMPRESSOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), OSTREE_TYPE_LZMA_COMPRESSOR, OstreeLzmaCompressorClass)) 29 | #define OSTREE_IS_LZMA_COMPRESSOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), OSTREE_TYPE_LZMA_COMPRESSOR)) 30 | #define OSTREE_IS_LZMA_COMPRESSOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), OSTREE_TYPE_LZMA_COMPRESSOR)) 31 | #define OSTREE_LZMA_COMPRESSOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), OSTREE_TYPE_LZMA_COMPRESSOR, OstreeLzmaCompressorClass)) 32 | 33 | typedef struct _OstreeLzmaCompressorClass OstreeLzmaCompressorClass; 34 | typedef struct _OstreeLzmaCompressor OstreeLzmaCompressor; 35 | 36 | struct _OstreeLzmaCompressorClass 37 | { 38 | GObjectClass parent_class; 39 | }; 40 | 41 | GType _ostree_lzma_compressor_get_type (void) G_GNUC_CONST; 42 | 43 | OstreeLzmaCompressor *_ostree_lzma_compressor_new (GVariant *params); 44 | 45 | G_END_DECLS 46 | -------------------------------------------------------------------------------- /src/libotutil/ot-gpg-utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Red Hat, Inc. 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #pragma once 23 | 24 | #include 25 | #include 26 | #include "libglnx.h" 27 | 28 | G_BEGIN_DECLS 29 | 30 | G_DEFINE_AUTO_CLEANUP_FREE_FUNC(gpgme_data_t, gpgme_data_release, NULL) 31 | G_DEFINE_AUTO_CLEANUP_FREE_FUNC(gpgme_ctx_t, gpgme_release, NULL) 32 | G_DEFINE_AUTO_CLEANUP_FREE_FUNC(gpgme_key_t, gpgme_key_unref, NULL) 33 | 34 | gboolean ot_gpgme_throw (gpgme_error_t gpg_error, GError **error, 35 | const char *fmt, ...) G_GNUC_PRINTF (3, 4); 36 | 37 | gboolean ot_gpgme_ctx_tmp_home_dir (gpgme_ctx_t gpgme_ctx, 38 | char **out_tmp_home_dir, 39 | GOutputStream **out_pubring_stream, 40 | GCancellable *cancellable, 41 | GError **error); 42 | 43 | gpgme_data_t ot_gpgme_data_input (GInputStream *input_stream); 44 | gpgme_data_t ot_gpgme_data_output (GOutputStream *output_stream); 45 | 46 | gpgme_ctx_t ot_gpgme_new_ctx (const char *homedir, 47 | GError **error); 48 | 49 | void ot_gpgme_kill_agent (const char *homedir); 50 | 51 | G_END_DECLS 52 | -------------------------------------------------------------------------------- /src/libostree/bupsplit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Avery Pennarun. All rights reserved. 3 | * 4 | * (This license applies to bupsplit.c and bupsplit.h only.) 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are 8 | * met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY AVERY PENNARUN ``AS IS'' AND ANY 19 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef __BUPSPLIT_H 31 | #define __BUPSPLIT_H 32 | 33 | #include 34 | #include 35 | 36 | #define BUP_BLOBBITS (13) 37 | #define BUP_BLOBSIZE (1< 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | . $(dirname $0)/libtest.sh 25 | 26 | skip "We don't really have a use case for committing user. xattrs right now. See also https://github.com/ostreedev/ostree/issues/758" 27 | 28 | # Dead code below 29 | skip_without_user_xattrs 30 | 31 | echo "1..2" 32 | 33 | setup_test_repository "archive" 34 | 35 | cd ${test_tmpdir} 36 | ${CMD_PREFIX} ostree --repo=repo checkout test2 test2-checkout1 37 | setfattr -n user.ostree-test -v testvalue test2-checkout1/firstfile 38 | setfattr -n user.test0 -v moo test2-checkout1/firstfile 39 | ${CMD_PREFIX} ostree --repo=repo commit -b test2 -s xattrs --tree=dir=test2-checkout1 40 | rm test2-checkout1 -rf 41 | echo "ok commit with xattrs" 42 | 43 | ${CMD_PREFIX} ostree --repo=repo checkout test2 test2-checkout2 44 | getfattr -m . test2-checkout2/firstfile > attrs 45 | assert_file_has_content attrs '^user\.ostree-test' 46 | assert_file_has_content attrs '^user\.test0' 47 | getfattr -n user.ostree-test --only-values test2-checkout2/firstfile > v0 48 | assert_file_has_content v0 '^testvalue$' 49 | getfattr -n user.test0 --only-values test2-checkout2/firstfile > v1 50 | assert_file_has_content v1 '^moo$' 51 | echo "ok checkout with xattrs" 52 | -------------------------------------------------------------------------------- /src/ostree/ot-builtins.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Colin Walters 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | * 21 | * Author: Colin Walters 22 | */ 23 | 24 | #pragma once 25 | 26 | #include "config.h" 27 | 28 | #include "ostree.h" 29 | 30 | G_BEGIN_DECLS 31 | 32 | #define BUILTINPROTO(name) gboolean ostree_builtin_ ## name (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error) 33 | 34 | BUILTINPROTO(admin); 35 | BUILTINPROTO(cat); 36 | BUILTINPROTO(config); 37 | BUILTINPROTO(checkout); 38 | BUILTINPROTO(checksum); 39 | BUILTINPROTO(commit); 40 | BUILTINPROTO(diff); 41 | BUILTINPROTO(export); 42 | BUILTINPROTO(find_remotes); 43 | BUILTINPROTO(create_usb); 44 | #ifndef OSTREE_DISABLE_GPGME 45 | BUILTINPROTO(gpg_sign); 46 | #endif 47 | BUILTINPROTO(init); 48 | BUILTINPROTO(log); 49 | BUILTINPROTO(pull); 50 | BUILTINPROTO(pull_local); 51 | BUILTINPROTO(ls); 52 | BUILTINPROTO(prune); 53 | BUILTINPROTO(refs); 54 | BUILTINPROTO(reset); 55 | BUILTINPROTO(fsck); 56 | BUILTINPROTO(sign); 57 | BUILTINPROTO(show); 58 | BUILTINPROTO(static_delta); 59 | BUILTINPROTO(summary); 60 | BUILTINPROTO(rev_parse); 61 | BUILTINPROTO(remote); 62 | BUILTINPROTO(write_refs); 63 | BUILTINPROTO(trivial_httpd); 64 | 65 | #undef BUILTINPROTO 66 | 67 | G_END_DECLS 68 | -------------------------------------------------------------------------------- /tests/kolainst/destructive/itest-deploy-selinux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Verify our /etc merge works with selinux 4 | 5 | set -xeuo pipefail 6 | 7 | . ${KOLA_EXT_DATA}/libinsttest.sh 8 | 9 | require_writable_sysroot 10 | 11 | date 12 | # Create a new deployment 13 | ostree admin deploy --karg-proc-cmdline ${host_refspec} 14 | new_deployment_path=/ostree/deploy/${host_osname}/deploy/${host_commit}.1 15 | 16 | # Test /etc directory mtime 17 | if ! test ${new_deployment_path}/etc/NetworkManager -nt /etc/NetworkManager; then 18 | ls -al ${new_deployment_path}/etc/NetworkManager /etc/NetworkManager 19 | fatal "/etc directory mtime not newer" 20 | fi 21 | 22 | # A set of files that have a variety of security contexts 23 | for file in fstab passwd exports hostname sysctl.conf yum.repos.d \ 24 | NetworkManager/dispatcher.d/hook-network-manager; do 25 | if ! test -e /etc/${file}; then 26 | continue 27 | fi 28 | 29 | current=$(cd /etc && ls -Z ${file}) 30 | new=$(cd ${new_deployment_path}/etc && ls -Z ${file}) 31 | assert_streq "${current}" "${new}" 32 | done 33 | 34 | # Cleanup 35 | ostree admin undeploy 0 36 | 37 | cd /ostree/repo/tmp 38 | ostree checkout --fsync=0 -H ${host_commit} test-label 39 | rm -vf test-label/usr/lib/ostree-boot/vmlinuz* 40 | rm -vf test-label/usr/lib/ostree-boot/initramfs* 41 | cd test-label/usr/lib/modules/* 42 | rm initramfs.img 43 | echo new initramfs > initramfs.img 44 | cd - 45 | ostree commit --link-checkout-speedup --selinux-policy=test-label -b test-label --consume --tree=dir=test-label 46 | 47 | ostree admin deploy --karg-proc-cmdline test-label 48 | 49 | # This captures all of the boot entries; it'd be slightly annoying 50 | # to try to figure out the accurate one, so let's just ensure that at least 51 | # one entry is boot_t. 52 | # https://bugzilla.redhat.com/show_bug.cgi?id=1536991 53 | ls -Z /boot/ostree/*/ > bootlsz.txt 54 | assert_file_has_content_literal bootlsz.txt 'system_u:object_r:boot_t:s0 vmlinuz-' 55 | assert_file_has_content_literal bootlsz.txt 'system_u:object_r:boot_t:s0 initramfs-' 56 | 57 | ostree admin undeploy 0 58 | ostree refs --delete test-label 59 | date 60 | -------------------------------------------------------------------------------- /tests/test-pull-depth.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2014 Colin Walters 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | . $(dirname $0)/libtest.sh 25 | 26 | setup_fake_remote_repo1 "archive" 27 | 28 | echo '1..1' 29 | 30 | cd ${test_tmpdir} 31 | mkdir repo 32 | ostree_repo_init repo 33 | ${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo 34 | 35 | ${CMD_PREFIX} ostree --repo=repo pull --depth=0 origin main 36 | find repo/objects -name '*.commit' | wc -l > commitcount 37 | assert_file_has_content commitcount "^1$" 38 | 39 | ${CMD_PREFIX} ostree --repo=repo pull --depth=0 origin main 40 | find repo/objects -name '*.commit' | wc -l > commitcount 41 | assert_file_has_content commitcount "^1$" 42 | 43 | ${CMD_PREFIX} ostree --repo=repo pull --depth=1 origin main 44 | find repo/objects -name '*.commit' | wc -l > commitcount 45 | assert_file_has_content commitcount "^2$" 46 | 47 | ${CMD_PREFIX} ostree --repo=repo pull --depth=1 origin main 48 | find repo/objects -name '*.commit' | wc -l > commitcount 49 | assert_file_has_content commitcount "^2$" 50 | 51 | ${CMD_PREFIX} ostree --repo=repo pull --depth=-1 origin main 52 | find repo/objects -name '*.commit' | wc -l > commitcount 53 | assert_file_has_content commitcount "^3$" 54 | 55 | echo "ok pull depth" 56 | -------------------------------------------------------------------------------- /src/boot/ostree-finalize-staged.service: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2018 Red Hat, Inc. 2 | # 3 | # This library is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU Lesser General Public 5 | # License as published by the Free Software Foundation; either 6 | # version 2 of the License, or (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public 14 | # License along with this library; if not, write to the 15 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 | # Boston, MA 02111-1307, USA. 17 | 18 | # For some implementation discussion, see: 19 | # https://lists.freedesktop.org/archives/systemd-devel/2018-March/040557.html 20 | [Unit] 21 | Description=OSTree Finalize Staged Deployment 22 | Documentation=man:ostree(1) 23 | ConditionPathExists=/run/ostree-booted 24 | DefaultDependencies=no 25 | 26 | RequiresMountsFor=/sysroot /boot 27 | After=local-fs.target 28 | Before=basic.target final.target 29 | # We want to make sure the transaction logs are persisted to disk: 30 | # https://bugzilla.redhat.com/show_bug.cgi?id=1751272 31 | After=systemd-journal-flush.service 32 | Conflicts=final.target 33 | 34 | [Service] 35 | Type=oneshot 36 | RemainAfterExit=yes 37 | ExecStop=/usr/bin/ostree admin finalize-staged 38 | # This is a quite long timeout intentionally; the failure mode 39 | # here is that people don't get an upgrade. We need to handle 40 | # cases with slow rotational media, etc. 41 | TimeoutStopSec=5m 42 | # OSTree should never touch /var at all...except, we need to remove 43 | # the /var/.updated flag, so we can't just `InaccessiblePaths=/var` right now. 44 | # For now, let's at least use ProtectHome just so we have some sandboxing 45 | # of that. 46 | ProtectHome=yes 47 | # And we shouldn't affect the current deployment's /etc. 48 | ReadOnlyPaths=/etc 49 | # We write to /sysroot and /boot of course. 50 | -------------------------------------------------------------------------------- /src/libostree/ostree-lzma-decompressor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Colin Walters 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General 17 | * Public License along with this library; if not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | G_BEGIN_DECLS 25 | 26 | #define OSTREE_TYPE_LZMA_DECOMPRESSOR (_ostree_lzma_decompressor_get_type ()) 27 | #define OSTREE_LZMA_DECOMPRESSOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), OSTREE_TYPE_LZMA_DECOMPRESSOR, OstreeLzmaDecompressor)) 28 | #define OSTREE_LZMA_DECOMPRESSOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), OSTREE_TYPE_LZMA_DECOMPRESSOR, OstreeLzmaDecompressorClass)) 29 | #define OSTREE_IS_LZMA_DECOMPRESSOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), OSTREE_TYPE_LZMA_DECOMPRESSOR)) 30 | #define OSTREE_IS_LZMA_DECOMPRESSOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), OSTREE_TYPE_LZMA_DECOMPRESSOR)) 31 | #define OSTREE_LZMA_DECOMPRESSOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), OSTREE_TYPE_LZMA_DECOMPRESSOR, OstreeLzmaDecompressorClass)) 32 | 33 | typedef struct _OstreeLzmaDecompressorClass OstreeLzmaDecompressorClass; 34 | typedef struct _OstreeLzmaDecompressor OstreeLzmaDecompressor; 35 | 36 | struct _OstreeLzmaDecompressorClass 37 | { 38 | GObjectClass parent_class; 39 | }; 40 | 41 | GLIB_AVAILABLE_IN_ALL 42 | GType _ostree_lzma_decompressor_get_type (void) G_GNUC_CONST; 43 | 44 | GLIB_AVAILABLE_IN_ALL 45 | OstreeLzmaDecompressor *_ostree_lzma_decompressor_new (void); 46 | 47 | G_END_DECLS 48 | -------------------------------------------------------------------------------- /src/libostree/ostree-cmdprivate.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Colin Walters 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #include "config.h" 23 | 24 | #include "ostree-cmdprivate.h" 25 | #include "ostree-repo-private.h" 26 | #include "ostree-core-private.h" 27 | #include "ostree-repo-static-delta-private.h" 28 | #include "ostree-sysroot-private.h" 29 | #include "ostree-bootloader-grub2.h" 30 | 31 | #include "otutil.h" 32 | 33 | static gboolean 34 | impl_ostree_generate_grub2_config (OstreeSysroot *sysroot, int bootversion, int target_fd, GCancellable *cancellable, GError **error) 35 | { 36 | return _ostree_bootloader_grub2_generate_config (sysroot, bootversion, target_fd, cancellable, error); 37 | } 38 | 39 | /** 40 | * ostree_cmdprivate: (skip) 41 | * 42 | * Do not call this function; it is used to share private API between 43 | * the OSTree commandline and the library. 44 | */ 45 | const OstreeCmdPrivateVTable * 46 | ostree_cmd__private__ (void) 47 | { 48 | static OstreeCmdPrivateVTable table = { 49 | _ostree_impl_system_generator, 50 | impl_ostree_generate_grub2_config, 51 | _ostree_repo_static_delta_dump, 52 | _ostree_repo_static_delta_query_exists, 53 | _ostree_repo_static_delta_delete, 54 | _ostree_repo_verify_bindings, 55 | _ostree_sysroot_finalize_staged, 56 | }; 57 | 58 | return &table; 59 | } 60 | -------------------------------------------------------------------------------- /tests/test-basic-root.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2011 Colin Walters 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | . $(dirname $0)/libtest.sh 25 | 26 | id=$(id -u) 27 | 28 | if test ${id} != 0; then 29 | skip "continued basic tests must be run as root (possibly in a container)" 30 | fi 31 | 32 | setup_test_repository "bare" 33 | 34 | echo "1..1" 35 | 36 | nextid=$(($id + 1)) 37 | 38 | rm checkout-test2 -rf 39 | $OSTREE checkout test2 checkout-test2 40 | $OSTREE commit ${COMMIT_ARGS} -b test2 --tree=ref=test2 --owner-uid=$nextid 41 | $OSTREE ls test2 baz/cow > ls.txt 42 | assert_file_has_content ls.txt '-00644 '${nextid}' '${id} 43 | # As bare and running as root (e.g. Docker container), do some ownership tests 44 | # https://github.com/ostreedev/ostree/pull/801 45 | # Both hardlinks and copies should respect ownership, but we don't have -C yet; 46 | # add it when we do. 47 | for opt in -H; do 48 | rm test2-co -rf 49 | $OSTREE checkout ${opt} test2 test2-co 50 | assert_streq "$(stat -c '%u' test2-co/baz/cow)" ${nextid} 51 | assert_streq "$(stat -c '%u' test2-co/baz/alink)" ${nextid} 52 | done 53 | rm test2-co -rf 54 | # But user mode doesn't 55 | $OSTREE checkout -U test2 test2-co 56 | assert_streq "$(stat -c '%u' test2-co/baz/cow)" ${id} 57 | assert_streq "$(stat -c '%u' test2-co/baz/alink)" ${id} 58 | echo "ok ownership" 59 | -------------------------------------------------------------------------------- /tests/test-parent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2016 Alexander Larsson 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | . $(dirname $0)/libtest.sh 25 | 26 | skip_without_user_xattrs 27 | 28 | skip_without_gpgme 29 | 30 | echo '1..2' 31 | 32 | setup_test_repository "archive" 33 | 34 | export OSTREE_GPG_SIGN="${OSTREE} gpg-sign --gpg-homedir=${TEST_GPG_KEYHOME}" 35 | 36 | cd ${test_tmpdir} 37 | 38 | # Create a repo 39 | ostree_repo_init repo2 40 | ${CMD_PREFIX} ostree --repo=repo2 remote add --gpg-import=${test_tmpdir}/gpghome/trusted/pubring.gpg --set=gpg-verify=true aremote file://$(pwd)/repo test2 41 | 42 | # Create a repo with repo2 as parent 43 | ${CMD_PREFIX} ostree init --repo=repo3 --mode=bare-user 44 | ${CMD_PREFIX} ostree config --repo=repo3 set core.parent `pwd`/repo2 45 | 46 | # Ensure the unsigned pull fails so we know we imported the gpg config correctly 47 | if ${CMD_PREFIX} ostree --repo=repo3 pull aremote; then 48 | assert_not_reached "GPG verification unexpectedly succeeded" 49 | fi 50 | echo "ok unsigned pull w/parent" 51 | 52 | # Make a signed commit and ensure we can now pull 53 | ${OSTREE} commit -b test2 -s "A GPG signed commit" -m "Signed commit body" --gpg-sign=${TEST_GPG_KEYID_1} --gpg-homedir=${TEST_GPG_KEYHOME} --tree=dir=files 54 | ${CMD_PREFIX} ostree --repo=repo3 pull aremote 55 | 56 | echo "ok signed pull w/parent" 57 | -------------------------------------------------------------------------------- /tests/test-ot-opt-utils.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Red Hat, Inc. 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #include "config.h" 23 | #include "ostree-mutable-tree.h" 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include "ot-opt-utils.h" 29 | #include "libglnx.h" 30 | 31 | static GString *printerr_str = NULL; 32 | 33 | static void 34 | util_usage_error_printerr (const gchar *string) 35 | { 36 | if (printerr_str == NULL) 37 | printerr_str = g_string_new (NULL); 38 | g_string_append (printerr_str, string); 39 | } 40 | 41 | static void 42 | test_ot_util_usage_error (void) 43 | { 44 | g_autoptr(GError) error = NULL; 45 | g_autoptr(GOptionContext) context = g_option_context_new ("[TEST]"); 46 | GPrintFunc old_printerr = g_set_printerr_handler (util_usage_error_printerr); 47 | 48 | ot_util_usage_error (context, "find_me", &error); 49 | 50 | g_assert_nonnull (strstr (printerr_str->str, "[TEST]")); 51 | g_assert_nonnull (strstr (error->message, "find_me")); 52 | g_clear_error (&error); 53 | 54 | g_set_printerr_handler (old_printerr); 55 | g_string_free (printerr_str, TRUE); 56 | printerr_str = NULL; 57 | } 58 | 59 | int main (int argc, char **argv) 60 | { 61 | g_test_init (&argc, &argv, NULL); 62 | g_test_add_func ("/ot-opt-utils/ot-util-usage-error", test_ot_util_usage_error); 63 | return g_test_run(); 64 | } 65 | -------------------------------------------------------------------------------- /tests/test-admin-deploy-nomerge.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2020 Red Hat, Inc. 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | . $(dirname $0)/libtest.sh 25 | 26 | # Exports OSTREE_SYSROOT so --sysroot not needed. 27 | setup_os_repository "archive" "syslinux" 28 | ${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime 29 | 30 | echo "1..1" 31 | ${CMD_PREFIX} ostree admin deploy --os=testos --karg=root=LABEL=foo --karg=testkarg=1 testos:testos/buildmaster/x86_64-runtime 32 | origdeployment=$(${CMD_PREFIX} ostree admin --sysroot=sysroot --print-current-dir) 33 | testconfig=etc/modified-config-file-that-will-be-removed 34 | touch "${origdeployment}"/"${testconfig}" 35 | assert_file_has_content sysroot/boot/loader/entries/ostree-1-testos.conf "^options.*root=LABEL=foo.*testkarg" 36 | ${CMD_PREFIX} ostree admin deploy --os=testos --no-merge --karg=root=LABEL=bar testos:testos/buildmaster/x86_64-runtime 37 | deployment=$(${CMD_PREFIX} ostree admin --sysroot=sysroot --print-current-dir) 38 | assert_not_streq "${origdeployment}" "${deployment}" 39 | assert_not_has_file "${deployment}/${testconfig}" 40 | assert_file_has_content sysroot/boot/loader/entries/ostree-1-testos.conf "^options root=LABEL=bar" 41 | assert_not_file_has_content sysroot/boot/loader/entries/ostree-1-testos.conf "^options .*testkarg" 42 | echo "ok no merge deployment" 43 | -------------------------------------------------------------------------------- /ci/libbuild.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | dn=$(cd $(dirname $0) && pwd) 4 | 5 | OS_ID=$(. /etc/os-release; echo $ID) 6 | OS_VERSION_ID=$(. /etc/os-release; echo $VERSION_ID) 7 | 8 | pkg_upgrade() { 9 | yum -y distro-sync 10 | } 11 | 12 | make() { 13 | /usr/bin/make -j ${MAKE_JOBS:-$(getconf _NPROCESSORS_ONLN)} "$@" 14 | } 15 | 16 | build() { 17 | env NOCONFIGURE=1 ./autogen.sh 18 | ./configure --sysconfdir=/etc --prefix=/usr --libdir=/usr/lib64 "$@" 19 | make V=1 20 | } 21 | 22 | pkg_install() { 23 | yum -y install "$@" 24 | } 25 | 26 | pkg_install_if_os() { 27 | local os=$1 28 | shift 29 | if test "${os}" = "${OS_ID}"; then 30 | pkg_install "$@" 31 | else 32 | echo "Skipping installation targeted for ${os} (current OS: ${OS_ID}): $@" 33 | fi 34 | } 35 | 36 | pkg_install_buildroot() { 37 | case "${OS_ID}" in 38 | fedora) 39 | # https://github.com/projectatomic/rpm-ostree/pull/1889/commits/9ff611758bea22b0ad4892cc16182dd1f7f47e89 40 | # https://fedoraproject.org/wiki/Common_F30_bugs#Conflicts_between_fedora-release_packages_when_installing_package_groups 41 | if rpm -q fedora-release-container; then 42 | yum -y swap fedora-release{-container,} 43 | fi 44 | pkg_install dnf-plugins-core @buildsys-build;; 45 | centos) pkg_install yum-utils 46 | # Base buildroot, copied from the mock config sadly 47 | pkg_install bash bzip2 coreutils cpio diffutils system-release findutils gawk gcc gcc-c++ \ 48 | grep gzip info make patch redhat-rpm-config rpm-build sed shadow-utils tar \ 49 | unzip util-linux which xz;; 50 | *) fatal "pkg_install_buildroot(): Unhandled OS ${OS_ID}";; 51 | esac 52 | } 53 | 54 | pkg_builddep() { 55 | # This is sadly the only case where it's a different command 56 | if test -x /usr/bin/dnf; then 57 | dnf builddep -y "$@" 58 | else 59 | yum-builddep -y "$@" 60 | fi 61 | } 62 | 63 | # Install both build and runtime dependencies for $pkg 64 | pkg_builddep_runtimedep() { 65 | local pkg=$1 66 | pkg_builddep $pkg 67 | pkg_install $pkg 68 | rpm -e $pkg 69 | } 70 | -------------------------------------------------------------------------------- /ci/build-check.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | # Install build dependencies, run unit tests and installed tests. 3 | 4 | set -xeuo pipefail 5 | 6 | dn=$(dirname $0) 7 | . ${dn}/libbuild.sh 8 | ${dn}/build.sh 9 | topdir=$(git rev-parse --show-toplevel) 10 | resultsdir=$(mktemp -d) 11 | make check 12 | make syntax-check # TODO: do syntax-check under check 13 | # See comment below 14 | for x in test-suite.log config.log; do 15 | mv ${x} ${resultsdir} 16 | done 17 | # And now install; we'll run the test suite after we do a clang build first 18 | # (But we don't install that one) 19 | make install 20 | 21 | # And now a clang build to find unused variables because it does a better 22 | # job than gcc for vars with cleanups; perhaps in the future these could 23 | # parallelize 24 | if test -x /usr/bin/clang; then 25 | if grep -q -e 'static inline.*_GLIB_AUTOPTR_LIST_FUNC_NAME' /usr/include/glib-2.0/glib/gmacros.h; then 26 | echo 'Skipping clang check, see https://bugzilla.gnome.org/show_bug.cgi?id=796346' 27 | else 28 | export CFLAGS="-Wall -Werror ${CFLAGS:-}" 29 | git clean -dfx && git submodule foreach git clean -dfx 30 | export CC=clang 31 | build 32 | fi 33 | fi 34 | 35 | copy_out_gdtr_artifacts() { 36 | # Keep this in sync with papr.yml 37 | # TODO; Split the main/clang builds into separate build dirs 38 | local artifactdir 39 | artifactdir=${ARTIFACTS:-${topdir}} 40 | mkdir -p "${artifactdir}" 41 | for x in test-suite.log config.log gdtr-results; do 42 | if test -e ${resultsdir}/${x}; then 43 | mv ${resultsdir}/${x} ${artifactdir} 44 | fi 45 | done 46 | } 47 | 48 | if test -x /usr/bin/gnome-desktop-testing-runner; then 49 | mkdir ${resultsdir}/gdtr-results 50 | # Temporary hack 51 | (git clone --depth=1 https://git.gnome.org/browse/gnome-desktop-testing 52 | cd gnome-desktop-testing 53 | env NOCONFIGURE=1 ./autogen.sh 54 | ./configure --prefix=/usr --libdir=/usr/lib64 55 | make && rm -f /usr/bin/ginsttest-runner && make install) 56 | # set a trap in case a test fails 57 | trap copy_out_gdtr_artifacts EXIT 58 | # Use the new -L option 59 | gnome-desktop-testing-runner -L ${resultsdir}/gdtr-results -p 0 ${INSTALLED_TESTS_PATTERN:-libostree/} 60 | fi 61 | -------------------------------------------------------------------------------- /tests/test-pull-basicauth.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2017 Colin Walters 4 | # 5 | # This library is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU Lesser General Public 7 | # License as published by the Free Software Foundation; either 8 | # version 2 of the License, or (at your option) any later version. 9 | # 10 | # This library is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public 16 | # License along with this library; if not, write to the 17 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | # Boston, MA 02111-1307, USA. 19 | 20 | set -euo pipefail 21 | 22 | . $(dirname $0)/libtest.sh 23 | 24 | setup_fake_remote_repo1 "archive" "" "--require-basic-auth" 25 | 26 | echo '1..3' 27 | 28 | repopath=${test_tmpdir}/ostree-srv/gnomerepo 29 | cp -a ${repopath} ${repopath}.orig 30 | 31 | cd ${test_tmpdir} 32 | rm repo -rf 33 | ostree_repo_init repo 34 | unauthaddress=$(cat httpd-address) 35 | badauthaddress=$(echo $unauthaddress | sed -e 's,http://,http://foo:bar@,') 36 | goodauthaddress=$(echo $unauthaddress | sed -e 's,http://,http://foouser:barpw@,') 37 | ${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin-unauth ${unauthaddress}/ostree/gnomerepo 38 | ${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin-badauth ${badauthaddress}/ostree/gnomerepo 39 | ${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin-goodauth ${goodauthaddress}/ostree/gnomerepo 40 | 41 | if ${CMD_PREFIX} ostree --repo=repo pull origin-unauth main 2>err.txt; then 42 | fatal "Pulled via unauth" 43 | fi 44 | assert_file_has_content err.txt "401" 45 | echo "ok unauth" 46 | rm -f err.txt 47 | if ${CMD_PREFIX} ostree --repo=repo pull origin-badauth main 2>err.txt; then 48 | fatal "Pulled via badauth" 49 | fi 50 | assert_file_has_content err.txt "401" 51 | rm -f err.txt 52 | echo "ok badauth" 53 | 54 | ${CMD_PREFIX} ostree --repo=repo pull origin-goodauth main 55 | echo "ok basic auth" 56 | -------------------------------------------------------------------------------- /tests/test-remote-headers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2016 Red Hat, Inc. 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | set -euo pipefail 23 | 24 | echo '1..2' 25 | 26 | . $(dirname $0)/libtest.sh 27 | 28 | V=$($CMD_PREFIX ostree --version | \ 29 | python3 -c 'import sys, yaml; print(yaml.safe_load(sys.stdin)["libostree"]["Version"])') 30 | 31 | setup_fake_remote_repo1 "archive" "" \ 32 | --expected-header foo=bar \ 33 | --expected-header baz=badger \ 34 | --expected-header "User-Agent=libostree/$V dodo/2.15" 35 | 36 | cd ${test_tmpdir} 37 | rm repo -rf 38 | mkdir repo 39 | ostree_repo_init repo 40 | ${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo 41 | 42 | # Sanity check the setup, without headers the pull should fail 43 | assert_fail ${CMD_PREFIX} ostree --repo=repo pull origin main 44 | 45 | # without proper User-Agent, the pull should fail 46 | assert_fail ${CMD_PREFIX} ostree --repo=repo pull origin main \ 47 | --http-header foo=bar \ 48 | --http-header baz=badger 49 | assert_fail ${CMD_PREFIX} ostree --repo=repo pull origin main \ 50 | --http-header foo=bar \ 51 | --http-header baz=badger \ 52 | --append-user-agent bar/1.2 53 | 54 | echo "ok setup done" 55 | 56 | # Now pull should succeed now 57 | ${CMD_PREFIX} ostree --repo=repo pull \ 58 | --http-header foo=bar \ 59 | --http-header baz=badger \ 60 | --append-user-agent dodo/2.15 \ 61 | origin main 62 | 63 | echo "ok pull succeeded" 64 | -------------------------------------------------------------------------------- /Makefile-otutil.am: -------------------------------------------------------------------------------- 1 | # Makefile for C source code 2 | # 3 | # Copyright (C) 2011 Colin Walters 4 | # 5 | # SPDX-License-Identifier: LGPL-2.0+ 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the 19 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | # Boston, MA 02111-1307, USA. 21 | 22 | noinst_LTLIBRARIES += libotutil.la 23 | 24 | libotutil_la_SOURCES = \ 25 | src/libotutil/ot-checksum-utils.c \ 26 | src/libotutil/ot-checksum-utils.h \ 27 | src/libotutil/ot-checksum-instream.c \ 28 | src/libotutil/ot-checksum-instream.h \ 29 | src/libotutil/ot-fs-utils.c \ 30 | src/libotutil/ot-fs-utils.h \ 31 | src/libotutil/ot-keyfile-utils.c \ 32 | src/libotutil/ot-keyfile-utils.h \ 33 | src/libotutil/ot-opt-utils.c \ 34 | src/libotutil/ot-opt-utils.h \ 35 | src/libotutil/ot-unix-utils.c \ 36 | src/libotutil/ot-unix-utils.h \ 37 | src/libotutil/ot-variant-utils.c \ 38 | src/libotutil/ot-variant-utils.h \ 39 | src/libotutil/ot-variant-builder.c \ 40 | src/libotutil/ot-variant-builder.h \ 41 | src/libotutil/ot-gio-utils.c \ 42 | src/libotutil/ot-gio-utils.h \ 43 | src/libotutil/otutil.h \ 44 | src/libotutil/ot-tool-util.c \ 45 | src/libotutil/ot-tool-util.h \ 46 | $(NULL) 47 | 48 | if USE_GPGME 49 | libotutil_la_SOURCES += \ 50 | src/libotutil/ot-gpg-utils.c \ 51 | src/libotutil/ot-gpg-utils.h \ 52 | $(NULL) 53 | endif 54 | 55 | libotutil_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/libglnx -I$(srcdir)/src/libotutil -DLOCALEDIR=\"$(datadir)/locale\" $(OT_INTERNAL_GIO_UNIX_CFLAGS) $(OT_INTERNAL_GPGME_CFLAGS) $(LIBSYSTEMD_CFLAGS) 56 | libotutil_la_LIBADD = $(OT_INTERNAL_GIO_UNIX_LIBS) $(OT_INTERNAL_GPGME_LIBS) $(LIBSYSTEMD_LIBS) 57 | -------------------------------------------------------------------------------- /src/ostree/ot-remote-builtin-show-url.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Red Hat, Inc. 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #include "config.h" 23 | 24 | #include "otutil.h" 25 | 26 | #include "ot-main.h" 27 | #include "ot-remote-builtins.h" 28 | 29 | /* ATTENTION: 30 | * Please remember to update the bash-completion script (bash/ostree) and 31 | * man page (man/ostree-remote.xml) when changing the option list. 32 | */ 33 | 34 | static GOptionEntry option_entries[] = { 35 | { NULL } 36 | }; 37 | 38 | gboolean 39 | ot_remote_builtin_show_url (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error) 40 | { 41 | g_autoptr(GOptionContext) context = NULL; 42 | g_autoptr(OstreeRepo) repo = NULL; 43 | const char *remote_name; 44 | g_autofree char *remote_url = NULL; 45 | gboolean ret = FALSE; 46 | 47 | context = g_option_context_new ("NAME"); 48 | 49 | if (!ostree_option_context_parse (context, option_entries, &argc, &argv, 50 | invocation, &repo, cancellable, error)) 51 | goto out; 52 | 53 | if (argc < 2) 54 | { 55 | ot_util_usage_error (context, "NAME must be specified", error); 56 | goto out; 57 | } 58 | 59 | remote_name = argv[1]; 60 | 61 | if (ostree_repo_remote_get_url (repo, remote_name, &remote_url, error)) 62 | { 63 | g_print ("%s\n", remote_url); 64 | ret = TRUE; 65 | } 66 | 67 | out: 68 | return ret; 69 | } 70 | -------------------------------------------------------------------------------- /src/libostree/ostree-repo-finder-config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2017 Endless Mobile, Inc. 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | * 21 | * Authors: 22 | * - Philip Withnall 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #include "ostree-repo-finder.h" 32 | #include "ostree-types.h" 33 | 34 | G_BEGIN_DECLS 35 | 36 | #define OSTREE_TYPE_REPO_FINDER_CONFIG (ostree_repo_finder_config_get_type ()) 37 | 38 | /* Manually expanded version of the following, omitting autoptr support (for GLib < 2.44): 39 | _OSTREE_PUBLIC 40 | G_DECLARE_FINAL_TYPE (OstreeRepoFinderConfig, ostree_repo_finder_config, OSTREE, REPO_FINDER_CONFIG, GObject) */ 41 | 42 | _OSTREE_PUBLIC 43 | GType ostree_repo_finder_config_get_type (void); 44 | 45 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS 46 | typedef struct _OstreeRepoFinderConfig OstreeRepoFinderConfig; 47 | typedef struct { GObjectClass parent_class; } OstreeRepoFinderConfigClass; 48 | 49 | static inline OstreeRepoFinderConfig *OSTREE_REPO_FINDER_CONFIG (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_CAST (ptr, ostree_repo_finder_config_get_type (), OstreeRepoFinderConfig); } 50 | static inline gboolean OSTREE_IS_REPO_FINDER_CONFIG (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_TYPE (ptr, ostree_repo_finder_config_get_type ()); } 51 | G_GNUC_END_IGNORE_DEPRECATIONS 52 | 53 | _OSTREE_PUBLIC 54 | OstreeRepoFinderConfig *ostree_repo_finder_config_new (void); 55 | 56 | G_END_DECLS 57 | -------------------------------------------------------------------------------- /src/libostree/ostree-repo-finder-mount.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2017 Endless Mobile, Inc. 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | * 21 | * Authors: 22 | * - Philip Withnall 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #include "ostree-repo-finder.h" 32 | #include "ostree-types.h" 33 | 34 | G_BEGIN_DECLS 35 | 36 | #define OSTREE_TYPE_REPO_FINDER_MOUNT (ostree_repo_finder_mount_get_type ()) 37 | 38 | /* Manually expanded version of the following, omitting autoptr support (for GLib < 2.44): 39 | _OSTREE_PUBLIC 40 | G_DECLARE_FINAL_TYPE (OstreeRepoFinderMount, ostree_repo_finder_mount, OSTREE, REPO_FINDER_MOUNT, GObject) */ 41 | 42 | _OSTREE_PUBLIC 43 | GType ostree_repo_finder_mount_get_type (void); 44 | 45 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS 46 | typedef struct _OstreeRepoFinderMount OstreeRepoFinderMount; 47 | typedef struct { GObjectClass parent_class; } OstreeRepoFinderMountClass; 48 | 49 | static inline OstreeRepoFinderMount *OSTREE_REPO_FINDER_MOUNT (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_CAST (ptr, ostree_repo_finder_mount_get_type (), OstreeRepoFinderMount); } 50 | static inline gboolean OSTREE_IS_REPO_FINDER_MOUNT (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_TYPE (ptr, ostree_repo_finder_mount_get_type ()); } 51 | G_GNUC_END_IGNORE_DEPRECATIONS 52 | 53 | _OSTREE_PUBLIC 54 | OstreeRepoFinderMount *ostree_repo_finder_mount_new (GVolumeMonitor *monitor); 55 | 56 | G_END_DECLS 57 | -------------------------------------------------------------------------------- /src/libostree/ostree-tls-cert-interaction.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Colin Walters 3 | * 4 | * SPDX-License-Identifier: LGPL-2.0+ 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "otutil.h" 23 | #include 24 | 25 | G_BEGIN_DECLS 26 | 27 | #define OSTREE_TYPE_TLS_CERT_INTERACTION (_ostree_tls_cert_interaction_get_type ()) 28 | #define OSTREE_TLS_CERT_INTERACTION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), OSTREE_TYPE_TLS_CERT_INTERACTION, OstreeTlsCertInteraction)) 29 | #define OSTREE_TLS_CERT_INTERACTION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), OSTREE_TYPE_TLS_CERT_INTERACTION, OstreeTlsCertInteractionClass)) 30 | #define OSTREE_IS_TLS_CERT_INTERACTION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), OSTREE_TYPE_TLS_CERT_INTERACTION)) 31 | #define OSTREE_IS_TLS_CERT_INTERACTION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), OSTREE_TYPE_TLS_CERT_INTERACTION)) 32 | #define OSTREE_TLS_CERT_INTERACTION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), OSTREE_TYPE_TLS_CERT_INTERACTION, OstreeTlsCertInteractionClass)) 33 | 34 | typedef struct _OstreeTlsCertInteraction OstreeTlsCertInteraction; 35 | typedef struct _OstreeTlsCertInteractionClass OstreeTlsCertInteractionClass; 36 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(OstreeTlsCertInteraction, g_object_unref) 37 | 38 | GType _ostree_tls_cert_interaction_get_type (void) G_GNUC_CONST; 39 | 40 | OstreeTlsCertInteraction * _ostree_tls_cert_interaction_new (const char *cert_path, 41 | const char *key_path); 42 | 43 | G_END_DECLS 44 | -------------------------------------------------------------------------------- /src/ostree/ot-remote-builtin-list-cookies.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Red Hat, Inc. 3 | * Copyright (C) 2016 Sjoerd Simons 4 | * 5 | * SPDX-License-Identifier: LGPL-2.0+ 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the 19 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | * Boston, MA 02111-1307, USA. 21 | */ 22 | 23 | #include "config.h" 24 | 25 | #include "otutil.h" 26 | 27 | #include "ot-main.h" 28 | #include "ot-remote-builtins.h" 29 | #include "ostree-repo-private.h" 30 | #include "ot-remote-cookie-util.h" 31 | 32 | /* ATTENTION: 33 | * Please remember to update the bash-completion script (bash/ostree) and 34 | * man page (man/ostree-remote.xml) when changing the option list. 35 | */ 36 | 37 | static GOptionEntry option_entries[] = { 38 | { NULL } 39 | }; 40 | 41 | gboolean 42 | ot_remote_builtin_list_cookies (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error) 43 | { 44 | g_autoptr(OstreeRepo) repo = NULL; 45 | g_autoptr(GOptionContext) context = g_option_context_new ("NAME"); 46 | 47 | if (!ostree_option_context_parse (context, option_entries, &argc, &argv, 48 | invocation, &repo, cancellable, error)) 49 | return FALSE; 50 | 51 | if (argc < 2) 52 | { 53 | ot_util_usage_error (context, "NAME must be specified", error); 54 | return FALSE; 55 | } 56 | 57 | const char *remote_name = argv[1]; 58 | g_autofree char *cookie_file = g_strdup_printf ("%s.cookies.txt", remote_name); 59 | if (!ot_list_cookies_at (ostree_repo_get_dfd (repo), cookie_file, error)) 60 | return FALSE; 61 | 62 | return TRUE; 63 | } 64 | --------------------------------------------------------------------------------