summaryrefslogtreecommitdiff
path: root/src/import/pull-job.c
Commit message (Collapse)AuthorAgeFilesLines
* import: use CURLINFO_SCHEME instead of CURLINFO_PROTOCOLFrantisek Sumsal2023-01-091-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | CURLINFO_PROTOCOL has been deprecated in curl 7.85.0 causing compilation warnings/errors: ../build/src/import/pull-job.c: In function ‘pull_job_curl_on_finished’: ../build/src/import/pull-job.c:142:9: error: ‘CURLINFO_PROTOCOL’ is deprecated: since 7.85.0. Use CURLINFO_SCHEME [-Werror=deprecated-declarations] 142 | code = curl_easy_getinfo(curl, CURLINFO_PROTOCOL, &protocol); | ^~~~ In file included from ../build/src/import/curl-util.h:4, from ../build/src/import/pull-job.h:6, from ../build/src/import/pull-common.h:7, from ../build/src/import/pull-job.c:16: /usr/include/curl/curl.h:2896:3: note: declared here 2896 | CURLINFO_PROTOCOL CURL_DEPRECATED(7.85.0, "Use CURLINFO_SCHEME") | ^~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Since both CURLINFO_SCHEME and CURLINFO_PROTOCOL were introduced in the same curl version (7.52.0 [0][1]) we don't have to worry about backwards compatibility. [0] https://curl.se/libcurl/c/CURLINFO_SCHEME.html [1] https://curl.se/libcurl/c/CURLINFO_PROTOCOL.html
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-2/+2
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* tree-wide: use ASSERT_PTR moreDavid Tardon2022-09-131-9/+4
|
* import: port importd from libgcrypt to openssl^gcryptZbigniew Jędrzejewski-Szmek2021-11-301-12/+53
| | | | | | | | | | | | | | | | | | This is heavily based on Kevin Kuehler's work, but the logic is also significantly changed: instead of a straighforward port to openssl, both versions of the code are kept, and at compile time we pick one or the other. The code is purposefully kept "dumb" — the idea is that the libgcrypt codepaths are only temporary and will be removed after everybody upgrades to openssl 3. Thus, a separate abstraction layer is not introduced. Instead, very simple ifdefs are used to select one or the other. If we added an abstraction layer, we'd have to remove it again afterwards, and it don't think it makes sense to do that for a temporary solution. Co-authored-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> # Conflicts: # meson.build
* basic: split out sync() family of calls from fs-util.[ch] into new c/h fileLennart Poettering2021-10-051-1/+1
| | | | No changes in code, just some splitting out.
* import: enable sparse file writing logic only for files we createLennart Poettering2021-08-201-1/+1
| | | | | | | | | | | Only if we create a file we know for sure that it is empty and hence our sparse file logic of skipping over NUL bytes can can work. If we hwoever are called to write data to some existing file/block device, we must do regular writes to override everything that might be in place before. Hence, conditionalize sparse file writing on the write offset not being configured (which is how we internally distinguish write to existing file and write to new file)
* import: when completed, say how many bytes we wrote/acquiredLennart Poettering2021-08-201-0/+2
| | | | This is just too useful.
* import: allow file:// in addition to HTTP(S)Lennart Poettering2021-08-201-32/+44
| | | | | | | | | Previously we only allows http/https urls, let's open this up a bit. Why? Because it makes testing *so* *much* *easier* as we don't need to run a HTTP server all the time. CURL mostly abstracts the differences of http/https away from us, hence we can get away with very little extra work.
* pull: add --direct mode + make various eatures optional + explicit checksum ↵Lennart Poettering2021-08-171-63/+114
| | | | | | | | | | | | | | verification This does what the previous commit did for systemd-import the same way for systemd-pull. It also adds one more thing: the checksum validation is extended, in addition of doing SHA256SUMS/gpg verification it is now possible to immediately specify a hash value on the command line that the download needs to match. This is particularly useful in --direct mode as we can download/decompress/unpack arbitrary files and check the hash of the downloaded file on-the-fly.
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-031-1/+1
| | | | | | | | | | | | | | | | | In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument.
* import: use SYNTHETIC_ERRNO in one more placeZbigniew Jędrzejewski-Szmek2021-07-091-2/+1
|
* tree-wide: add FORMAT_BYTES()Zbigniew Jędrzejewski-Szmek2021-07-091-5/+2
|
* tree-wide: add FORMAT_TIMESPAN()Zbigniew Jędrzejewski-Szmek2021-07-091-2/+1
|
* alloc-util: simplify GREEDY_REALLOC() logic by relying on malloc_usable_size()Lennart Poettering2021-05-191-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | We recently started making more use of malloc_usable_size() and rely on it (see the string_erase() story). Given that we don't really support sytems where malloc_usable_size() cannot be trusted beyond statistics anyway, let's go fully in and rework GREEDY_REALLOC() on top of it: instead of passing around and maintaining the currenly allocated size everywhere, let's just derive it automatically from malloc_usable_size(). I am mostly after this for the simplicity this brings. It also brings minor efficiency improvements I guess, but things become so much nicer to look at if we can avoid these allocation size variables everywhere. Note that the malloc_usable_size() man page says relying on it wasn't "good programming practice", but I think it does this for reasons that don't apply here: the greedy realloc logic specifically doesn't rely on the returned extra size, beyond the fact that it is equal or larger than what was requested. (This commit was supposed to be a quick patch btw, but apparently we use the greedy realloc stuff quite a bit across the codebase, so this ends up touching *a*lot* of code.)
* tree-wide: use UINT64_MAX or friendsYu Watanabe2021-03-051-4/+4
|
* import: fix etag detection supportLennart Poettering2021-02-041-16/+29
| | | | | | | | Let's make sure we still look at the etags reported by http 304 (i.e. the cache management code). Otherwise we won't properly realize we already downloaded this before. This fixes a bug introduced in 6792cbbcf84b730f465decbeaf247c6b1ccf1c18
* import: ignore non-successful HTTP codes for collecing image metadataLennart Poettering2021-01-191-1/+15
| | | | | | Previously we'd collect the data from redirects too, which wasn't particularly terrible, since these typically don't carry the data we were interested in, but it's still incorrect to do so.
* import: small memory management simplificationLennart Poettering2021-01-191-4/+2
|
* import: reset PullJob properlyLennart Poettering2021-01-191-0/+19
| | | | | | Properly reset all fields that have to do with the current GET job when we restart things. Previously we freed/reset only some stuff, leaking some memory even.
* import: rework how verification worksLennart Poettering2021-01-191-18/+25
| | | | | | | | | | | | | | | | | | | | | | Previously the PullJob object took internal care of rerequested the SHA256SUMS file, if requesting <image>.sha256 didn't work. This was a weird a non-abstraction only used when actually getting the checksum files. Let's move this out of the PullJob, so that it is generic again, and does roughly the same stuff for all resources it is used for: let's define a generic .on_not_found() handler that can be set on a PullJob object, and is called whenever with see HTTP 404, and may be used to provide a new URL to try if the first didn't work. This is also preparation for later work to support PKCS#7 signatures instead of gpg signatures, where a similar logic is needed, and we thus should have a generic infrastructure place. This gets rid of the VerificationStyle field in the PullJob object: instead of storing this non-generic field we just derive the same information from the URL itself, which is safe, since we generated it ourselves earlier.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* tree-wide: get rid of strappend()Lennart Poettering2019-07-121-1/+1
| | | | | It's a special case of strjoin(), so no need to keep both. In particular as typing strjoin() is even shoert than strappend().
* util: introduce format_bytes_full()Yu Watanabe2019-06-191-0/+1
| | | | And move it into format-util.c.
* headers: remove unneeded includes from util.hZbigniew Jędrzejewski-Szmek2019-03-271-0/+2
| | | | | This means we need to include many more headers in various files that simply included util.h before, but it seems cleaner to do it this way.
* pull: fix invalid error checkYu Watanabe2019-02-061-1/+1
| | | | This fixes a bug introduced by 0d94088e4e9e00f5ca9afdb8e68c94558fe23268.
* import: drop logic of setting up /var/lib/machines as btrfs loopback mountLennart Poettering2018-11-261-10/+0
| | | | | | | | | | | | | | | | | | | Let's simplify things and drop the logic that /var/lib/machines is setup as auto-growing btrfs loopback file /var/lib/machines.raw. THis was done in order to make quota available for machine management, but quite frankly never really worked properly, as we couldn't grow the file system in sync with its use properly. Moreover philosophically it's problematic overriding the admin's choice of file system like this. Let's hence drop this, and simplify things. Deleting code is a good feeling. Now that regular file systems provide project quota we could probably add per-machine quota support based on that, hence the btrfs quota argument is not that interesting anymore (though btrfs quota is a bit more powerful as it allows recursive quota, i.e. that the machine pool gets an overall quota in addition to per-machine quota).
* import: use structured initializersYu Watanabe2018-11-241-13/+18
|
* coccinelle: make use of SYNTHETIC_ERRNOZbigniew Jędrzejewski-Szmek2018-11-221-28/+18
| | | | | | | | | | | Ideally, coccinelle would strip unnecessary braces too. But I do not see any option in coccinelle for this, so instead, I edited the patch text using search&replace to remove the braces. Unfortunately this is not fully automatic, in particular it didn't deal well with if-else-if-else blocks and ifdefs, so there is an increased likelikehood be some bugs in such spots. I also removed part of the patch that coccinelle generated for udev, where we returns -1 for failure. This should be fixed independently.
* import: sparse_write() returns negative errnoYu Watanabe2018-10-011-2/+5
|
* pull: initialize libgcrypt before calling any functions provided by libgcryptYu Watanabe2018-07-131-0/+3
| | | | | | | This fixes the following warning: ``` systemd-pull[4065]: Libgcrypt warning: missing initialization - please fix the application ```
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-04-051-2/+1
|
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* tree-wide: use IN_SET macro (#6977)Yu Watanabe2017-10-041-1/+1
|
* tree-wide: use IN_SET where possibleAndreas Rammhold2017-10-021-3/+2
| | | | | In addition to the changes from #6933 this handles cases that could be matched with the included cocci file.
* importd: support SUSE style checksums supplementary (#5800)tblume2017-04-251-5/+3
| | | some small changes to make the code look better
* importd: support SUSE style checksums (#5206)tblume2017-04-241-0/+50
| | | | | | | | | | | In order to verify a pulled container or disk image, importd only supports SHA256SUMS files with the detached signature in SHA256SUMS.gpg. SUSE is using an inline signed file with the name of the image itself and the suffix .sha256 instead. This commit adds support for this type of signature files. It is first attempted to pull the .sha256 file. If this fails with error 404, the SHA256SUMS and SHA256SUMS.gpg files are pulled and used for verification.
* import: bump image size safety limit for machinectl pull (#5535)Dax Kelson2017-03-051-1/+1
| | | We currenly use 40GB images in our environment
* tree-wide: use mfree moreZbigniew Jędrzejewski-Szmek2016-10-161-3/+1
|
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split xattr-related calls into xattr-util.[ch]Lennart Poettering2015-10-271-1/+2
|
* util-lib: split out hex/dec/oct encoding/decoding into its own fileLennart Poettering2015-10-271-0/+1
|
* util-lib: split string parsing related calls from util.[ch] into parse-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split out IO related calls to io-util.[ch]Lennart Poettering2015-10-261-0/+1
|
* util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering2015-10-251-1/+2
| | | | | There are more than enough to deserve their own .c file, hence move them over.
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-1/+2
| | | | | | | | | | | | | | string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
* fix gcc warnings about uninitialized variablesHarald Hoyer2015-03-271-1/+1
| | | | | | | | | | | | | like: src/shared/install.c: In function ‘unit_file_lookup_state’: src/shared/install.c:1861:16: warning: ‘r’ may be used uninitialized in this function [-Wmaybe-uninitialized] return r < 0 ? r : state; ^ src/shared/install.c:1796:13: note: ‘r’ was declared here int r; ^