1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3 
4 #include <stdbool.h>
5 
6 #include "import-util.h"
7 #include "pull-job.h"
8 
9 typedef enum PullFlags {
10         PULL_FORCE              = 1 << 0, /* replace existing image */
11         PULL_READ_ONLY          = 1 << 1, /* make generated image read-only */
12         PULL_SETTINGS           = 1 << 1, /* download .nspawn settings file */
13         PULL_ROOTHASH           = 1 << 2, /* only for raw: download .roothash file for verity */
14         PULL_ROOTHASH_SIGNATURE = 1 << 3, /* only for raw: download .roothash.p7s file for verity */
15         PULL_VERITY             = 1 << 4, /* only for raw: download .verity file for verity */
16         PULL_BTRFS_SUBVOL       = 1 << 2, /* tar: preferably create images as btrfs subvols */
17         PULL_BTRFS_QUOTA        = 1 << 3, /* tar: set up btrfs quota for new subvolume as child of parent subvolume */
18         PULL_CONVERT_QCOW2      = 1 << 4, /* raw: if we detect a qcow2 image, unpack it */
19         PULL_DIRECT             = 1 << 5, /* download without rename games */
20         PULL_SYNC               = 1 << 6, /* fsync() right before we are done */
21 
22         /* The supported flags for the tar and the raw pulling */
23         PULL_FLAGS_MASK_TAR     = PULL_FORCE|PULL_READ_ONLY|PULL_SETTINGS|PULL_BTRFS_SUBVOL|PULL_BTRFS_QUOTA|PULL_DIRECT|PULL_SYNC,
24         PULL_FLAGS_MASK_RAW     = PULL_FORCE|PULL_READ_ONLY|PULL_SETTINGS|PULL_ROOTHASH|PULL_ROOTHASH_SIGNATURE|PULL_VERITY|PULL_CONVERT_QCOW2|PULL_DIRECT|PULL_SYNC,
25 } PullFlags;
26 
27 int pull_find_old_etags(const char *url, const char *root, int dt, const char *prefix, const char *suffix, char ***etags);
28 
29 int pull_make_path(const char *url, const char *etag, const char *image_root, const char *prefix, const char *suffix, char **ret);
30 
31 int pull_make_auxiliary_job(PullJob **ret, const char *url, int (*strip_suffixes)(const char *name, char **ret), const char *suffix, ImportVerify verify, CurlGlue *glue, PullJobOpenDisk on_open_disk, PullJobFinished on_finished, void *userdata);
32 int pull_make_verification_jobs(PullJob **ret_checksum_job, PullJob **ret_signature_job, ImportVerify verify, const char *checksum, const char *url, CurlGlue *glue, PullJobFinished on_finished, void *userdata);
33 
34 int pull_verify(ImportVerify verify, const char *checksum, PullJob *main_job, PullJob *checksum_job, PullJob *signature_job, PullJob *settings_job, PullJob *roothash_job, PullJob *roothash_signature_job, PullJob *verity_job);
35 
36 typedef enum VerificationStyle {
37         VERIFICATION_PER_FILE,      /* SuSE-style ".sha256" files with inline gpg signature */
38         VERIFICATION_PER_DIRECTORY, /* Ubuntu-style SHA256SUM files with detached SHA256SUM.gpg signatures */
39         _VERIFICATION_STYLE_MAX,
40         _VERIFICATION_STYLE_INVALID = -EINVAL,
41 } VerificationStyle;
42 
43 int verification_style_from_url(const char *url, VerificationStyle *style);
44 
45 int pull_job_restart_with_sha256sum(PullJob *job, char **ret);
46 
47 bool pull_validate_local(const char *name, PullFlags flags);
48 
49 int pull_url_needs_checksum(const char *url);
50