pull-common.c revision 1f9aa80a59e581dee9fc886eb6d7f3ca40bc609a
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poettering This file is part of systemd.
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poettering Copyright 2015 Lennart Poettering
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poettering systemd is free software; you can redistribute it and/or modify it
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poettering under the terms of the GNU Lesser General Public License as published by
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poettering (at your option) any later version.
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poettering systemd is distributed in the hope that it will be useful, but
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poettering Lesser General Public License for more details.
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poettering You should have received a copy of the GNU Lesser General Public License
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poettering#define HASH_URL_THRESHOLD_LENGTH (_POSIX_PATH_MAX - 16)
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poettering escaped_url = xescape(url, FILENAME_ESCAPE);
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poettering FOREACH_DIRENT_ALL(de, d, return -errno) {
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poettering const char *a, *b;
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poettering r = cunescape_length(a, b - a, 0, &u);
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poetteringint pull_make_local_copy(const char *final, const char *image_root, const char *local, bool force_local) {
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poettering const char *p;
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poettering (void) rm_rf(p, REMOVE_ROOT|REMOVE_PHYSICAL|REMOVE_SUBVOLUME);
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poettering r = btrfs_subvol_snapshot(final, p, BTRFS_SNAPSHOT_QUOTA);
uint64_t h;
return -ENOMEM;
int pull_make_path(const char *url, const char *etag, const char *image_root, const char *prefix, const char *suffix, char **ret) {
char *path;
if (!image_root)
if (!escaped_url)
return -ENOMEM;
if (etag) {
if (!escaped_etag)
return -ENOMEM;
if (!path)
return -ENOMEM;
if (!path)
return -ENOMEM;
const char *url,
void *userdata) {
const char *url,
void *userdata) {
const char *p, *line;
bool gpg_home_created = false;
if (!checksum_job)
return -EBADMSG;
return log_oom();
return -EBADMSG;
line,
return -EBADMSG;
if (settings_job &&
return log_oom();
return -EBADMSG;
line,
log_error("DOWNLOAD INVALID: Checksum of settings file did not checkout, settings file has been tampered with.");
return -EBADMSG;
if (!signature_job)
return -EBADMSG;
if (sig_file < 0)
goto finish;
goto finish;
gpg_home_created = true;
if (pid < 0)
if (pid == 0) {
const char *cmd[] = {
int null_fd;
(void) reset_all_signal_handlers();
(void) reset_signal_mask();
if (null_fd < 0) {
goto finish;
pid = 0;
goto finish;
r = -EBADMSG;
if (sig_file >= 0)
if (gpg_home_created)