New upstream version 2016.13

This commit is contained in:
Simon McVittie committed 2016-11-20 15:41:33 +00:00
commit d02ef65cdc
110 files changed
+1924 -390

No files matched your search

+3 -2
View File
@@ -357,14 +357,15 @@ global:
/* No new symbols in 2016.10 */
/* No new symbols in 2016.11 */
/* No new symbols in 2016.12 */
/* No new symbols in 2016.13 */
/* NOTE NOTE NOTE
* Versions above here are released. Only add symbols below this line.
* NOTE NOTE NOTE
*/
/* Remove comment when first new symbol is added
LIBOSTREE_2016.12
/* Remove comment when first new symbol is added, replace XX with new stable version.
LIBOSTREE_2016.XX
global:
someostree_symbol_deleteme;
} LIBOSTREE_2016.8;
-3
View File
@@ -54,7 +54,6 @@ _ostree_bootloader_grub2_query (OstreeBootloader *bootloader,
gboolean ret = FALSE;
OstreeBootloaderGrub2 *self = OSTREE_BOOTLOADER_GRUB2 (bootloader);
g_autoptr(GFile) efi_basedir = NULL;
g_autoptr(GFileInfo) file_info = NULL;
if (g_file_query_exists (self->config_path_bios, NULL))
{
@@ -290,8 +289,6 @@ _ostree_bootloader_grub2_write_config (OstreeBootloader *bootloader,
{
OstreeBootloaderGrub2 *self = OSTREE_BOOTLOADER_GRUB2 (bootloader);
gboolean ret = FALSE;
g_autoptr(GFile) efi_new_config_temp = NULL;
g_autoptr(GFile) efi_orig_config = NULL;
g_autoptr(GFile) new_config_path = NULL;
GSubprocessFlags subp_flags = 0;
glnx_unref_object GSubprocessLauncher *launcher = NULL;
+28 -1
View File
@@ -326,6 +326,16 @@ session_thread_set_proxy_cb (ThreadClosure *thread_closure,
}
}
static void
session_thread_set_cookie_jar_cb (ThreadClosure *thread_closure,
gpointer data)
{
SoupCookieJar *jar = data;
soup_session_add_feature (thread_closure->session,
SOUP_SESSION_FEATURE (jar));
}
#ifdef HAVE_LIBSOUP_CLIENT_CERTS
static void
session_thread_set_tls_interaction_cb (ThreadClosure *thread_closure,
@@ -746,6 +756,23 @@ _ostree_fetcher_set_proxy (OstreeFetcher *self,
}
}
void
_ostree_fetcher_set_cookie_jar (OstreeFetcher *self,
const char *jar_path)
{
SoupCookieJar *jar;
g_return_if_fail (OSTREE_IS_FETCHER (self));
g_return_if_fail (jar_path != NULL);
jar = soup_cookie_jar_text_new (jar_path, TRUE);
session_thread_idle_add (self->thread_closure,
session_thread_set_cookie_jar_cb,
jar, /* takes ownership */
(GDestroyNotify) g_object_unref);
}
void
_ostree_fetcher_set_client_cert (OstreeFetcher *self,
GTlsCertificate *cert)
@@ -1030,6 +1057,7 @@ on_request_sent (GObject *object,
switch (msg->status_code)
{
case 404:
case 403:
case 410:
code = G_IO_ERROR_NOT_FOUND;
break;
@@ -1282,7 +1310,6 @@ _ostree_fetcher_mirrored_request_to_membuf (OstreeFetcher *fetcher,
{
gboolean ret = FALSE;
const guint8 nulchar = 0;
g_autofree char *ret_contents = NULL;
g_autoptr(GMemoryOutputStream) buf = NULL;
g_autoptr(GMainContext) mainctx = NULL;
FetchUriSyncData data;
+3
View File
@@ -59,6 +59,9 @@ OstreeFetcher *_ostree_fetcher_new (int tmpdir_dfd,
int _ostree_fetcher_get_dfd (OstreeFetcher *fetcher);
void _ostree_fetcher_set_cookie_jar (OstreeFetcher *self,
const char *jar_path);
void _ostree_fetcher_set_proxy (OstreeFetcher *fetcher,
const char *proxy);
+52 -8
View File
@@ -53,6 +53,23 @@ split_keyeq (char *arg)
}
}
static gboolean
_arg_has_prefix (const char *arg,
char **prefixes)
{
char **strviter;
for (strviter = prefixes; strviter && *strviter; strviter++)
{
const char *prefix = *strviter;
if (g_str_has_prefix (arg, prefix))
return TRUE;
}
return FALSE;
}
OstreeKernelArgs *
_ostree_kernel_args_new (void)
{
@@ -87,12 +104,21 @@ _ostree_kernel_args_replace_take (OstreeKernelArgs *kargs,
gboolean existed;
GPtrArray *values = g_ptr_array_new_with_free_func (g_free);
const char *value = split_keyeq (arg);
gpointer old_key;
existed = g_hash_table_remove (kargs->table, arg);
if (!existed)
g_ptr_array_add (kargs->order, arg);
g_ptr_array_add (values, g_strdup (value));
g_hash_table_replace (kargs->table, arg, values);
existed = g_hash_table_lookup_extended (kargs->table, arg, &old_key, NULL);
if (existed)
{
g_hash_table_replace (kargs->table, old_key, values);
g_free (arg);
}
else
{
g_ptr_array_add (kargs->order, arg);
g_hash_table_replace (kargs->table, arg, values);
}
}
void
@@ -145,18 +171,28 @@ _ostree_kernel_args_replace_argv (OstreeKernelArgs *kargs,
}
void
_ostree_kernel_args_append_argv (OstreeKernelArgs *kargs,
char **argv)
_ostree_kernel_args_append_argv_filtered (OstreeKernelArgs *kargs,
char **argv,
char **prefixes)
{
char **strviter;
for (strviter = argv; strviter && *strviter; strviter++)
{
const char *arg = *strviter;
_ostree_kernel_args_append (kargs, arg);
if (!_arg_has_prefix (arg, prefixes))
_ostree_kernel_args_append (kargs, arg);
}
}
void
_ostree_kernel_args_append_argv (OstreeKernelArgs *kargs,
char **argv)
{
_ostree_kernel_args_append_argv_filtered (kargs, argv, NULL);
}
gboolean
_ostree_kernel_args_append_proc_cmdline (OstreeKernelArgs *kargs,
GCancellable *cancellable,
@@ -166,6 +202,13 @@ _ostree_kernel_args_append_proc_cmdline (OstreeKernelArgs *kargs,
g_autofree char *proc_cmdline = NULL;
gsize proc_cmdline_len = 0;
g_auto(GStrv) proc_cmdline_args = NULL;
/* When updating the filter list don't forget to update the list in the tests
* e.g. tests/test-admin-deploy-karg.sh and
* tests/test-admin-instutil-set-kargs.sh
*/
char *filtered_prefixes[] = { "BOOT_IMAGE=", /* GRUB 2 */
"initrd=", /* sd-boot */
NULL };
if (!g_file_load_contents (proc_cmdline_path, cancellable,
&proc_cmdline, &proc_cmdline_len,
@@ -175,7 +218,8 @@ _ostree_kernel_args_append_proc_cmdline (OstreeKernelArgs *kargs,
g_strchomp (proc_cmdline);
proc_cmdline_args = g_strsplit (proc_cmdline, " ", -1);
_ostree_kernel_args_append_argv (kargs, proc_cmdline_args);
_ostree_kernel_args_append_argv_filtered (kargs, proc_cmdline_args,
filtered_prefixes);
return TRUE;
}
+3
View File
@@ -39,6 +39,9 @@ void _ostree_kernel_args_append (OstreeKernelArgs *kargs,
const char *key);
void _ostree_kernel_args_append_argv (OstreeKernelArgs *kargs,
char **argv);
void _ostree_kernel_args_append_argv_filtered (OstreeKernelArgs *kargs,
char **argv,
char **prefixes);
gboolean _ostree_kernel_args_append_proc_cmdline (OstreeKernelArgs *kargs,
GCancellable *cancellable,
-5
View File
@@ -592,7 +592,6 @@ write_object (OstreeRepo *self,
gboolean do_commit;
OstreeRepoMode repo_mode;
g_autofree char *temp_filename = NULL;
g_autoptr(GFile) stored_path = NULL;
g_autofree guchar *ret_csum = NULL;
glnx_unref_object OstreeChecksumInputStream *checksum_input = NULL;
g_autoptr(GInputStream) file_input = NULL;
@@ -1093,9 +1092,6 @@ ostree_repo_prepare_transaction (OstreeRepo *self,
{
gboolean ret = FALSE;
gboolean ret_transaction_resume = FALSE;
g_autofree char *stagedir_name = NULL;
glnx_fd_close int stagedir_fd = -1;
g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
g_return_val_if_fail (self->in_transaction == FALSE, FALSE);
@@ -2529,7 +2525,6 @@ write_directory_to_mtree_internal (OstreeRepo *self,
gboolean ret = FALSE;
OstreeRepoCommitFilterResult filter_result;
OstreeRepoFile *repo_dir = NULL;
g_autoptr(GFileEnumerator) dir_enum = NULL;
g_autoptr(GFileInfo) child_info = NULL;
if (dir)
-2
View File
@@ -300,7 +300,6 @@ aic_apply_modifier_filter (OstreeRepoArchiveImportContext *ctx,
const char *relpath,
GFileInfo **out_file_info)
{
g_autofree char *hardlink = aic_get_final_entry_hardlink (ctx);
g_autoptr(GFileInfo) file_info = NULL;
g_autofree char *abspath = NULL;
const char *cb_path = NULL;
@@ -915,7 +914,6 @@ ostree_repo_write_archive_to_mtree (OstreeRepo *self,
#ifdef HAVE_LIBARCHIVE
gboolean ret = FALSE;
struct archive *a = NULL;
g_autoptr(GFileInfo) tmp_dir_info = NULL;
OstreeRepoImportArchiveOptions opts = { 0, };
a = archive_read_new ();
+4 -40
View File
@@ -311,29 +311,11 @@ ostree_repo_prune (OstreeRepo *self,
while (g_hash_table_iter_next (&hash_iter, &key, &value))
{
const char *checksum = value;
OstreeRepoCommitState commitstate;
GError *local_error = NULL;
if (!ostree_repo_load_commit (self, checksum, NULL, &commitstate,
error))
goto out;
g_debug ("Finding objects to keep for commit %s", checksum);
if (!ostree_repo_traverse_commit_union (self, checksum, depth, data.reachable,
cancellable, &local_error))
{
/* Don't fail traversing a partial commit */
if ((commitstate & OSTREE_REPO_COMMIT_STATE_PARTIAL) > 0 &&
g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
{
g_clear_error (&local_error);
}
else
{
g_propagate_error (error, local_error);
goto out;
}
}
cancellable, error))
goto out;
}
}
@@ -349,34 +331,16 @@ ostree_repo_prune (OstreeRepo *self,
GVariant *serialized_key = key;
const char *checksum;
OstreeObjectType objtype;
OstreeRepoCommitState commitstate;
GError *local_error = NULL;
ostree_object_name_deserialize (serialized_key, &checksum, &objtype);
if (objtype != OSTREE_OBJECT_TYPE_COMMIT)
continue;
if (!ostree_repo_load_commit (self, checksum, NULL, &commitstate,
error))
goto out;
g_debug ("Finding objects to keep for commit %s", checksum);
if (!ostree_repo_traverse_commit_union (self, checksum, depth, data.reachable,
cancellable, &local_error))
{
/* Don't fail traversing a partial commit */
if ((commitstate & OSTREE_REPO_COMMIT_STATE_PARTIAL) > 0 &&
g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
{
g_clear_error (&local_error);
}
else
{
g_propagate_error (error, local_error);
goto out;
}
}
cancellable, error))
goto out;
}
}
+15 -9
View File
@@ -608,10 +608,8 @@ lookup_commit_checksum_from_summary (OtPullData *pull_data,
g_autoptr(GVariant) refs = g_variant_get_child_value (pull_data->summary, 0);
g_autoptr(GVariant) refdata = NULL;
g_autoptr(GVariant) reftargetdata = NULL;
g_autoptr(GVariant) commit_data = NULL;
guint64 commit_size;
g_autoptr(GVariant) commit_csum_v = NULL;
g_autoptr(GBytes) commit_bytes = NULL;
int i;
if (!ot_variant_bsearch_str (refs, ref, &i))
@@ -973,7 +971,6 @@ static_deltapart_fetch_on_complete (GObject *object,
OstreeFetcher *fetcher = (OstreeFetcher *)object;
FetchStaticDeltaData *fetch_data = user_data;
OtPullData *pull_data = fetch_data->pull_data;
g_autoptr(GVariant) metadata = NULL;
g_autofree char *temp_path = NULL;
g_autoptr(GInputStream) in = NULL;
g_autoptr(GVariant) part = NULL;
@@ -1430,8 +1427,6 @@ request_static_delta_superblock_sync (OtPullData *pull_data,
g_autofree char *delta_name =
_ostree_get_relative_static_delta_superblock_path (from_revision, to_revision);
g_autoptr(GBytes) delta_superblock_data = NULL;
g_autoptr(GBytes) delta_meta_data = NULL;
g_autoptr(GVariant) delta_superblock = NULL;
if (!_ostree_fetcher_mirrored_request_to_membuf (pull_data->fetcher,
pull_data->content_mirrorlist,
@@ -1969,6 +1964,19 @@ _ostree_repo_remote_new_fetcher (OstreeRepo *self,
_ostree_fetcher_set_proxy (fetcher, http_proxy);
}
{
g_autofree char *jar_path = NULL;
g_autofree char *cookie_file = g_strdup_printf ("%s.cookies.txt",
remote_name);
jar_path = g_build_filename (g_file_get_path (self->repodir), cookie_file,
NULL);
if (g_file_test(jar_path, G_FILE_TEST_IS_REGULAR))
_ostree_fetcher_set_cookie_jar (fetcher, jar_path);
}
success = TRUE;
out:
@@ -2335,8 +2343,6 @@ ostree_repo_pull_with_options (OstreeRepo *self,
gboolean opt_gpg_verify_set = FALSE;
gboolean opt_gpg_verify_summary_set = FALSE;
const char *url_override = NULL;
g_autofree char *base_meta_url = NULL;
g_autofree char *base_content_url = NULL;
gboolean mirroring_into_archive;
gboolean inherit_transaction = FALSE;
int i;
@@ -2641,7 +2647,6 @@ ostree_repo_pull_with_options (OstreeRepo *self,
{
g_autoptr(GBytes) bytes_sig = NULL;
g_autofree char *ret_contents = NULL;
gsize i, n;
g_autoptr(GVariant) refs = NULL;
g_autoptr(GVariant) deltas = NULL;
@@ -2934,7 +2939,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
&from_revision, error))
goto out;
if (!disable_static_deltas && !mirroring_into_archive &&
if (!(disable_static_deltas || mirroring_into_archive || pull_data->is_commit_only) &&
(from_revision == NULL || g_strcmp0 (from_revision, to_revision) != 0))
{
if (!request_static_delta_superblock_sync (pull_data, from_revision, to_revision,
@@ -3131,6 +3136,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
g_clear_pointer (&pull_data->requested_content, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&pull_data->requested_metadata, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&pull_data->idle_src, (GDestroyNotify) g_source_destroy);
g_clear_pointer (&pull_data->dirs, (GDestroyNotify) g_ptr_array_unref);
g_clear_pointer (&remote_config, (GDestroyNotify) g_key_file_unref);
return ret;
}
@@ -189,18 +189,30 @@ build_content_sizenames_filtered (OstreeRepo *repo,
static gboolean
string_array_nonempty_intersection (GPtrArray *a,
GPtrArray *b)
GPtrArray *b,
gboolean fuzzy)
{
guint i;
for (i = 0; i < a->len; i++)
{
guint j;
const char *a_str = a->pdata[i];
const char *a_dot = strchr (a_str, '.');
for (j = 0; j < b->len; j++)
{
const char *b_str = b->pdata[j];
if (strcmp (a_str, b_str) == 0)
return TRUE;
const char *b_dot = strchr (b_str, '.');
/* When doing fuzzy comparison, just compare the part before the '.' if it exists. */
if (fuzzy && a_dot && b_dot && b_dot - b_str && b_dot - b_str == a_dot - a_str)
{
if (strncmp (a_str, b_str, a_dot - a_str) == 0)
return TRUE;
}
else
{
if (strcmp (a_str, b_str) == 0)
return TRUE;
}
}
}
return FALSE;
@@ -258,6 +270,8 @@ _ostree_delta_compute_similar_objects (OstreeRepo *repo,
upper = from_sizes->len;
for (i = 0; i < to_sizes->len; i++)
{
int fuzzy;
gboolean found = FALSE;
OstreeDeltaContentSizeNames *to_sizenames = to_sizes->pdata[i];
const guint64 min_threshold = to_sizenames->size *
(1.0-similarity_percent_threshold/100.0);
@@ -268,31 +282,41 @@ _ostree_delta_compute_similar_objects (OstreeRepo *repo,
if (to_sizenames->size == 0)
continue;
for (j = lower; j < upper; j++)
for (fuzzy = 0; fuzzy < 2 && !found; fuzzy++)
{
OstreeDeltaContentSizeNames *from_sizenames = from_sizes->pdata[j];
/* Don't build candidates for the empty object */
if (from_sizenames->size == 0)
continue;
if (from_sizenames->size < min_threshold)
for (j = lower; j < upper; j++)
{
lower++;
continue;
OstreeDeltaContentSizeNames *from_sizenames = from_sizes->pdata[j];
/* Don't build candidates for the empty object */
if (from_sizenames->size == 0)
{
continue;
}
if (from_sizenames->size < min_threshold)
{
lower++;
continue;
}
if (from_sizenames->size > max_threshold)
break;
if (!string_array_nonempty_intersection (from_sizenames->basenames,
to_sizenames->basenames,
fuzzy == 1))
{
continue;
}
/* Only one candidate right now */
g_hash_table_insert (ret_modified_regfile_content,
g_strdup (to_sizenames->checksum),
g_strdup (from_sizenames->checksum));
found = TRUE;
break;
}
if (from_sizenames->size > max_threshold)
break;
if (!string_array_nonempty_intersection (from_sizenames->basenames, to_sizenames->basenames))
continue;
/* Only one candidate right now */
g_hash_table_insert (ret_modified_regfile_content,
g_strdup (to_sizenames->checksum),
g_strdup (from_sizenames->checksum));
break;
}
}
@@ -32,6 +32,7 @@
#include "ostree-diff.h"
#include "ostree-rollsum.h"
#include "otutil.h"
#include "libglnx.h"
#include "ostree-varint.h"
#include "bsdiff/bsdiff.h"
@@ -413,15 +414,11 @@ process_one_object (OstreeRepo *repo,
typedef struct {
char *from_checksum;
GBytes *tmp_from;
GBytes *tmp_to;
} ContentBsdiff;
typedef struct {
char *from_checksum;
OstreeRollsumMatches *matches;
GBytes *tmp_from;
GBytes *tmp_to;
} ContentRollsum;
static void
@@ -429,8 +426,6 @@ content_rollsums_free (ContentRollsum *rollsum)
{
g_free (rollsum->from_checksum);
_ostree_rollsum_matches_free (rollsum->matches);
g_clear_pointer (&rollsum->tmp_from, g_bytes_unref);
g_clear_pointer (&rollsum->tmp_to, g_bytes_unref);
g_free (rollsum);
}
@@ -438,8 +433,6 @@ static void
content_bsdiffs_free (ContentBsdiff *bsdiff)
{
g_free (bsdiff->from_checksum);
g_clear_pointer (&bsdiff->tmp_from, g_bytes_unref);
g_clear_pointer (&bsdiff->tmp_to, g_bytes_unref);
g_free (bsdiff);
}
@@ -450,50 +443,40 @@ static gboolean
get_unpacked_unlinked_content (OstreeRepo *repo,
const char *checksum,
GBytes **out_content,
GFileInfo **out_finfo,
GCancellable *cancellable,
GError **error)
{
gboolean ret = FALSE;
g_autofree char *tmpname = g_strdup ("/var/tmp/tmpostree-deltaobj-XXXXXX");
g_autofree char *tmpname = NULL;
glnx_fd_close int fd = -1;
g_autoptr(GBytes) ret_content = NULL;
g_autoptr(GInputStream) istream = NULL;
g_autoptr(GFileInfo) ret_finfo = NULL;
g_autoptr(GOutputStream) out = NULL;
fd = g_mkstemp (tmpname);
if (fd == -1)
{
glnx_set_error_from_errno (error);
goto out;
}
/* Doesn't need a name */
(void) unlink (tmpname);
if (!glnx_open_tmpfile_linkable_at (AT_FDCWD, "/tmp", O_RDWR | O_CLOEXEC,
&fd, &tmpname, error))
return FALSE;
/* We don't need the file name */
if (tmpname)
(void) unlinkat (AT_FDCWD, tmpname, 0);
if (!ostree_repo_load_file (repo, checksum, &istream, &ret_finfo, NULL,
if (!ostree_repo_load_file (repo, checksum, &istream, NULL, NULL,
cancellable, error))
goto out;
return FALSE;
g_assert (g_file_info_get_file_type (ret_finfo) == G_FILE_TYPE_REGULAR);
out = g_unix_output_stream_new (fd, FALSE);
if (g_output_stream_splice (out, istream, G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
cancellable, error) < 0)
goto out;
{ GMappedFile *mfile = g_mapped_file_new_from_fd (fd, FALSE, error);
return FALSE;
{ g_autoptr(GMappedFile) mfile = g_mapped_file_new_from_fd (fd, FALSE, error);
if (!mfile)
goto out;
return FALSE;
ret_content = g_mapped_file_get_bytes (mfile);
g_mapped_file_unref (mfile);
}
ret = TRUE;
if (out_content)
*out_content = g_steal_pointer (&ret_content);
out:
return ret;
return TRUE;
}
static gboolean
@@ -506,24 +489,20 @@ try_content_bsdiff (OstreeRepo *repo,
GError **error)
{
gboolean ret = FALSE;
g_autoptr(GHashTable) from_bsdiff = NULL;
g_autoptr(GHashTable) to_bsdiff = NULL;
g_autoptr(GBytes) tmp_from = NULL;
g_autoptr(GBytes) tmp_to = NULL;
g_autoptr(GFileInfo) from_finfo = NULL;
g_autoptr(GFileInfo) to_finfo = NULL;
ContentBsdiff *ret_bsdiff = NULL;
*out_bsdiff = NULL;
if (!get_unpacked_unlinked_content (repo, from, &tmp_from, &from_finfo,
cancellable, error))
goto out;
if (!get_unpacked_unlinked_content (repo, to, &tmp_to, &to_finfo,
cancellable, error))
goto out;
if (!ostree_repo_load_file (repo, from, NULL, &from_finfo, NULL,
cancellable, error))
return FALSE;
if (!ostree_repo_load_file (repo, to, NULL, &to_finfo, NULL,
cancellable, error))
return FALSE;
if (g_bytes_get_size (tmp_to) + g_bytes_get_size (tmp_from) > max_bsdiff_size_bytes)
if (g_file_info_get_size (to_finfo) + g_file_info_get_size (from_finfo) > max_bsdiff_size_bytes)
{
ret = TRUE;
goto out;
@@ -531,8 +510,6 @@ try_content_bsdiff (OstreeRepo *repo,
ret_bsdiff = g_new0 (ContentBsdiff, 1);
ret_bsdiff->from_checksum = g_strdup (from);
ret_bsdiff->tmp_from = tmp_from; tmp_from = NULL;
ret_bsdiff->tmp_to = tmp_to; tmp_to = NULL;
ret = TRUE;
if (out_bsdiff)
@@ -551,12 +528,8 @@ try_content_rollsum (OstreeRepo *repo,
GError **error)
{
gboolean ret = FALSE;
g_autoptr(GHashTable) from_rollsum = NULL;
g_autoptr(GHashTable) to_rollsum = NULL;
g_autoptr(GBytes) tmp_from = NULL;
g_autoptr(GBytes) tmp_to = NULL;
g_autoptr(GFileInfo) from_finfo = NULL;
g_autoptr(GFileInfo) to_finfo = NULL;
OstreeRollsumMatches *matches = NULL;
ContentRollsum *ret_rollsum = NULL;
@@ -565,11 +538,9 @@ try_content_rollsum (OstreeRepo *repo,
/* Load the content objects, splice them to uncompressed temporary files that
* we can just mmap() and seek around in conveniently.
*/
if (!get_unpacked_unlinked_content (repo, from, &tmp_from, &from_finfo,
cancellable, error))
if (!get_unpacked_unlinked_content (repo, from, &tmp_from, cancellable, error))
goto out;
if (!get_unpacked_unlinked_content (repo, to, &tmp_to, &to_finfo,
cancellable, error))
if (!get_unpacked_unlinked_content (repo, to, &tmp_to, cancellable, error))
goto out;
matches = _ostree_compute_rollsum_matches (tmp_from, tmp_to);
@@ -596,10 +567,8 @@ try_content_rollsum (OstreeRepo *repo,
ret_rollsum = g_new0 (ContentRollsum, 1);
ret_rollsum->from_checksum = g_strdup (from);
ret_rollsum->matches = matches; matches = NULL;
ret_rollsum->tmp_from = tmp_from; tmp_from = NULL;
ret_rollsum->tmp_to = tmp_to; tmp_to = NULL;
ret_rollsum->matches = g_steal_pointer (&matches);
ret = TRUE;
if (out_rollsum)
*out_rollsum = g_steal_pointer (&ret_rollsum);
@@ -655,7 +624,7 @@ process_one_rollsum (OstreeRepo *repo,
{
gboolean ret = FALSE;
guint64 content_size;
g_autoptr(GInputStream) content_stream = NULL;
g_autoptr(GBytes) tmp_to = NULL;
g_autoptr(GFileInfo) content_finfo = NULL;
g_autoptr(GVariant) content_xattrs = NULL;
OstreeStaticDeltaPartBuilder *current_part = *current_part_val;
@@ -669,9 +638,13 @@ process_one_rollsum (OstreeRepo *repo,
*current_part_val = current_part = allocate_part (builder);
}
tmp_to_buf = g_bytes_get_data (rollsum->tmp_to, &tmp_to_len);
if (!get_unpacked_unlinked_content (repo, to_checksum, &tmp_to,
cancellable, error))
goto out;
if (!ostree_repo_load_file (repo, to_checksum, &content_stream,
tmp_to_buf = g_bytes_get_data (tmp_to, &tmp_to_len);
if (!ostree_repo_load_file (repo, to_checksum, NULL,
&content_finfo, &content_xattrs,
cancellable, error))
goto out;
@@ -758,9 +731,6 @@ process_one_rollsum (OstreeRepo *repo,
g_string_append_c (current_part->operations, (gchar)OSTREE_STATIC_DELTA_OP_CLOSE);
}
g_clear_pointer (&rollsum->tmp_from, g_bytes_unref);
g_clear_pointer (&rollsum->tmp_to, g_bytes_unref);
ret = TRUE;
out:
return ret;
@@ -777,10 +747,11 @@ process_one_bsdiff (OstreeRepo *repo,
{
gboolean ret = FALSE;
guint64 content_size;
g_autoptr(GInputStream) content_stream = NULL;
g_autoptr(GFileInfo) content_finfo = NULL;
g_autoptr(GVariant) content_xattrs = NULL;
OstreeStaticDeltaPartBuilder *current_part = *current_part_val;
g_autoptr(GBytes) tmp_from = NULL;
g_autoptr(GBytes) tmp_to = NULL;
const guint8 *tmp_to_buf;
gsize tmp_to_len;
const guint8 *tmp_from_buf;
@@ -793,10 +764,17 @@ process_one_bsdiff (OstreeRepo *repo,
*current_part_val = current_part = allocate_part (builder);
}
tmp_to_buf = g_bytes_get_data (bsdiff_content->tmp_to, &tmp_to_len);
tmp_from_buf = g_bytes_get_data (bsdiff_content->tmp_from, &tmp_from_len);
if (!get_unpacked_unlinked_content (repo, bsdiff_content->from_checksum, &tmp_from,
cancellable, error))
goto out;
if (!get_unpacked_unlinked_content (repo, to_checksum, &tmp_to,
cancellable, error))
goto out;
if (!ostree_repo_load_file (repo, to_checksum, &content_stream,
tmp_to_buf = g_bytes_get_data (tmp_to, &tmp_to_len);
tmp_from_buf = g_bytes_get_data (tmp_from, &tmp_from_len);
if (!ostree_repo_load_file (repo, to_checksum, NULL,
&content_finfo, &content_xattrs,
cancellable, error))
goto out;
@@ -857,9 +835,6 @@ process_one_bsdiff (OstreeRepo *repo,
g_string_append_c (current_part->operations, (gchar)OSTREE_STATIC_DELTA_OP_UNSET_READ_SOURCE);
g_clear_pointer (&bsdiff_content->tmp_from, g_bytes_unref);
g_clear_pointer (&bsdiff_content->tmp_to, g_bytes_unref);
ret = TRUE;
out:
return ret;
@@ -884,14 +859,12 @@ generate_delta_lowlatency (OstreeRepo *repo,
g_autoptr(GVariant) to_commit = NULL;
g_autoptr(GHashTable) to_reachable_objects = NULL;
g_autoptr(GHashTable) from_reachable_objects = NULL;
g_autoptr(GHashTable) from_regfile_content = NULL;
g_autoptr(GHashTable) new_reachable_metadata = NULL;
g_autoptr(GHashTable) new_reachable_regfile_content = NULL;
g_autoptr(GHashTable) new_reachable_symlink_content = NULL;
g_autoptr(GHashTable) modified_regfile_content = NULL;
g_autoptr(GHashTable) rollsum_optimized_content_objects = NULL;
g_autoptr(GHashTable) bsdiff_optimized_content_objects = NULL;
g_autoptr(GHashTable) content_object_to_size = NULL;
if (from != NULL)
{
@@ -1261,7 +1234,7 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
guint min_fallback_size;
guint max_bsdiff_size;
guint max_chunk_size;
g_auto(GVariantBuilder) metadata_builder = {{0,}};
g_auto(GVariantBuilder) metadata_builder = OT_VARIANT_BUILDER_INITIALIZER;
DeltaOpts delta_opts = DELTAOPT_FLAG_NONE;
guint64 total_compressed_size = 0;
guint64 total_uncompressed_size = 0;
@@ -1273,7 +1246,6 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
const char *opt_filename;
g_autofree char *descriptor_name = NULL;
glnx_fd_close int descriptor_dfd = -1;
g_autoptr(GVariant) tmp_metadata = NULL;
g_autoptr(GVariant) fallback_headers = NULL;
g_autoptr(GVariant) detached = NULL;
gboolean inline_parts;
@@ -1387,7 +1359,6 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
GBytes *payload_b;
GBytes *operations_b;
g_autofree guchar *part_checksum = NULL;
g_autoptr(GChecksum) checksum = NULL;
g_autoptr(GBytes) objtype_checksum_array = NULL;
g_autoptr(GBytes) checksum_bytes = NULL;
g_autoptr(GOutputStream) part_temp_outstream = NULL;
@@ -1399,8 +1370,8 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
g_autoptr(GVariant) delta_part_content = NULL;
g_autoptr(GVariant) delta_part = NULL;
g_autoptr(GVariant) delta_part_header = NULL;
g_auto(GVariantBuilder) mode_builder = {{0,}};
g_auto(GVariantBuilder) xattr_builder = {{0,}};
g_auto(GVariantBuilder) mode_builder = OT_VARIANT_BUILDER_INITIALIZER;
g_auto(GVariantBuilder) xattr_builder = OT_VARIANT_BUILDER_INITIALIZER;
guint8 compression_type_char;
g_variant_builder_init (&mode_builder, G_VARIANT_TYPE ("a(uuu)"));
@@ -356,7 +356,6 @@ ostree_repo_static_delta_execute_offline (OstreeRepo *self,
char checksum[OSTREE_SHA256_STRING_LEN+1];
gboolean have_all;
g_autoptr(GInputStream) part_in = NULL;
g_autoptr(GBytes) delta_data = NULL;
g_autoptr(GVariant) inline_part_data = NULL;
g_autoptr(GVariant) header = NULL;
g_autoptr(GVariant) csum_v = NULL;
@@ -765,7 +764,7 @@ _ostree_delta_get_endianness (GVariant *superblock,
}
}
return G_BYTE_ORDER;
return OSTREE_DELTA_ENDIAN_INVALID;
}
}
@@ -864,7 +863,6 @@ _ostree_repo_static_delta_dump (OstreeRepo *self,
g_autofree char *from = NULL;
g_autofree char *to = NULL;
g_autofree char *superblock_path = NULL;
glnx_fd_close int superblock_fd = -1;
g_autoptr(GVariant) delta_superblock = NULL;
guint64 total_size = 0, total_usize = 0;
guint64 total_fallback_size = 0, total_fallback_usize = 0;
@@ -188,7 +188,6 @@ _ostree_static_delta_part_execute (OstreeRepo *repo,
{
gboolean ret = FALSE;
guint8 *checksums_data;
g_autoptr(GVariant) checksums = NULL;
g_autoptr(GVariant) mode_dict = NULL;
g_autoptr(GVariant) xattr_dict = NULL;
g_autoptr(GVariant) payload = NULL;
@@ -471,7 +470,6 @@ dispatch_bspatch (OstreeRepo *repo,
{
gboolean ret = FALSE;
guint64 offset, length;
g_autoptr(GInputStream) in_stream = NULL;
g_autoptr(GMappedFile) input_mfile = NULL;
g_autofree guchar *buf = NULL;
struct bspatch_stream stream;
+50 -10
View File
@@ -301,6 +301,7 @@ static gboolean
traverse_dirtree (OstreeRepo *repo,
const char *checksum,
GHashTable *inout_reachable,
gboolean ignore_missing_dirs,
GCancellable *cancellable,
GError **error);
@@ -308,6 +309,7 @@ static gboolean
traverse_iter (OstreeRepo *repo,
OstreeRepoCommitTraverseIter *iter,
GHashTable *inout_reachable,
gboolean ignore_missing_dirs,
GCancellable *cancellable,
GError **error)
{
@@ -316,11 +318,26 @@ traverse_iter (OstreeRepo *repo,
while (TRUE)
{
g_autoptr(GVariant) key = NULL;
g_autoptr(GError) local_error = NULL;
OstreeRepoCommitIterResult iterres =
ostree_repo_commit_traverse_iter_next (iter, cancellable, error);
ostree_repo_commit_traverse_iter_next (iter, cancellable, &local_error);
if (iterres == OSTREE_REPO_COMMIT_ITER_RESULT_ERROR)
goto out;
{
/* There is only one kind of not-found error, which is
failing to load the dirmeta itself, if so, we ignore that
(and the whole subtree) if told to. */
if (ignore_missing_dirs &&
g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
{
g_debug ("Ignoring not-found dirmeta");
ret = TRUE;
}
else
g_propagate_error (error, g_steal_pointer (&local_error));
goto out;
}
else if (iterres == OSTREE_REPO_COMMIT_ITER_RESULT_END)
break;
else if (iterres == OSTREE_REPO_COMMIT_ITER_RESULT_FILE)
@@ -357,7 +374,7 @@ traverse_iter (OstreeRepo *repo,
key = NULL;
if (!traverse_dirtree (repo, content_checksum, inout_reachable,
cancellable, error))
ignore_missing_dirs, cancellable, error))
goto out;
}
}
@@ -374,6 +391,7 @@ static gboolean
traverse_dirtree (OstreeRepo *repo,
const char *checksum,
GHashTable *inout_reachable,
gboolean ignore_missing_dirs,
GCancellable *cancellable,
GError **error)
{
@@ -381,10 +399,22 @@ traverse_dirtree (OstreeRepo *repo,
g_autoptr(GVariant) dirtree = NULL;
ostree_cleanup_repo_commit_traverse_iter
OstreeRepoCommitTraverseIter iter = { 0, };
g_autoptr(GError) local_error = NULL;
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_DIR_TREE, checksum,
&dirtree, error))
goto out;
&dirtree, &local_error))
{
if (ignore_missing_dirs &&
g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
{
g_print ("Ignoring not-found dirmeta %s", checksum);
ret = TRUE;
}
else
g_propagate_error (error, g_steal_pointer (&local_error));
goto out;
}
g_debug ("Traversing dirtree %s", checksum);
if (!ostree_repo_commit_traverse_iter_init_dirtree (&iter, repo, dirtree,
@@ -392,7 +422,7 @@ traverse_dirtree (OstreeRepo *repo,
error))
goto out;
if (!traverse_iter (repo, &iter, inout_reachable, cancellable, error))
if (!traverse_iter (repo, &iter, inout_reachable, ignore_missing_dirs, cancellable, error))
goto out;
ret = TRUE;
@@ -430,6 +460,8 @@ ostree_repo_traverse_commit_union (OstreeRepo *repo,
g_autoptr(GVariant) commit = NULL;
ostree_cleanup_repo_commit_traverse_iter
OstreeRepoCommitTraverseIter iter = { 0, };
OstreeRepoCommitState commitstate;
gboolean ignore_missing_dirs = FALSE;
key = ostree_object_name_serialize (commit_checksum, OSTREE_OBJECT_TYPE_COMMIT);
@@ -440,13 +472,21 @@ ostree_repo_traverse_commit_union (OstreeRepo *repo,
commit_checksum, &commit,
error))
goto out;
/* Just return if the parent isn't found; we do expect most
* people to have partial repositories.
*/
if (!commit)
break;
/* See if the commit is partial, if so it's not an error to lack objects */
if (!ostree_repo_load_commit (repo, commit_checksum, NULL, &commitstate,
error))
goto out;
if ((commitstate & OSTREE_REPO_COMMIT_STATE_PARTIAL) != 0)
ignore_missing_dirs = TRUE;
g_hash_table_add (inout_reachable, key);
key = NULL;
@@ -456,9 +496,9 @@ ostree_repo_traverse_commit_union (OstreeRepo *repo,
error))
goto out;
if (!traverse_iter (repo, &iter, inout_reachable, cancellable, error))
if (!traverse_iter (repo, &iter, inout_reachable, ignore_missing_dirs, cancellable, error))
goto out;
if (maxdepth == -1 || maxdepth > 0)
{
g_free (tmp_checksum);
+13 -7
View File
@@ -936,7 +936,7 @@ keyfile_set_from_vardict (GKeyFile *keyfile,
else if (g_variant_is_of_type (child, G_VARIANT_TYPE_STRING_ARRAY))
{
gsize len;
const char *const*strv_child = g_variant_get_strv (child, &len);
g_autofree const gchar **strv_child = g_variant_get_strv (child, &len);
g_key_file_set_string_list (keyfile, section, key, strv_child, len);
}
else
@@ -2593,7 +2593,7 @@ load_metadata_internal (OstreeRepo *self,
}
else
{
GBytes *data = glnx_fd_readall_bytes (fd, cancellable, error);
g_autoptr(GBytes) data = glnx_fd_readall_bytes (fd, cancellable, error);
if (!data)
goto out;
ret_variant = g_variant_new_from_bytes (ostree_metadata_variant_type (objtype),
@@ -3164,7 +3164,7 @@ ostree_repo_delete_object (OstreeRepo *self,
if (tombstone_commits)
{
g_auto(GVariantBuilder) builder = {{0,}};
g_auto(GVariantBuilder) builder = OT_VARIANT_BUILDER_INITIALIZER;
g_autoptr(GVariant) variant = NULL;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
@@ -4653,7 +4653,7 @@ ostree_repo_regenerate_summary (OstreeRepo *self,
g_autoptr(GVariant) summary = NULL;
GList *ordered_keys = NULL;
GList *iter = NULL;
g_auto(GVariantDict) additional_metadata_builder = {{0,}};
g_auto(GVariantDict) additional_metadata_builder = OT_VARIANT_BUILDER_INITIALIZER;
if (!ostree_repo_list_refs (self, NULL, &refs, cancellable, error))
goto out;
@@ -4668,10 +4668,18 @@ ostree_repo_regenerate_summary (OstreeRepo *self,
{
const char *ref = iter->data;
const char *commit = g_hash_table_lookup (refs, ref);
g_autofree char *remotename = NULL;
g_autoptr(GVariant) commit_obj = NULL;
g_assert (commit);
if (!ostree_parse_refspec (ref, &remotename, NULL, NULL))
g_assert_not_reached ();
/* Don't put remote refs in the summary */
if (remotename != NULL)
continue;
if (!ostree_repo_load_variant (self, OSTREE_OBJECT_TYPE_COMMIT, commit, &commit_obj, error))
goto out;
@@ -4686,8 +4694,7 @@ ostree_repo_regenerate_summary (OstreeRepo *self,
{
guint i;
g_autoptr(GPtrArray) delta_names = NULL;
g_auto(GVariantDict) deltas_builder = {{0,}};
g_autoptr(GVariant) deltas = NULL;
g_auto(GVariantDict) deltas_builder = OT_VARIANT_BUILDER_INITIALIZER;
if (!ostree_repo_list_static_delta_names (self, &delta_names, cancellable, error))
goto out;
@@ -4890,7 +4897,6 @@ _ostree_repo_allocate_tmpdir (int tmpdir_dfd,
{
g_autofree char *tmpdir_name_template = g_strconcat (tmpdir_prefix, "XXXXXX", NULL);
glnx_fd_close int new_tmpdir_fd = -1;
g_autoptr(GError) local_error = NULL;
/* No existing tmpdir found, create a new */
+4 -3
View File
@@ -534,7 +534,6 @@ checkout_deployment_tree (OstreeSysroot *sysroot,
const char *csum = ostree_deployment_get_csum (deployment);
g_autofree char *checkout_target_name = NULL;
g_autofree char *osdeploy_path = NULL;
g_autoptr(GFile) ret_deploy_target_path = NULL;
glnx_fd_close int osdeploy_dfd = -1;
int ret_fd;
@@ -1199,7 +1198,6 @@ swap_bootlinks (OstreeSysroot *self,
gboolean ret = FALSE;
int old_subbootversion, new_subbootversion;
glnx_fd_close int ostree_dfd = -1;
glnx_fd_close int ostree_subbootdir_dfd = -1;
g_autofree char *ostree_bootdir_name = NULL;
g_autofree char *ostree_subbootdir_name = NULL;
@@ -1749,7 +1747,7 @@ _ostree_sysroot_write_deployments_internal (OstreeSysroot *self,
/* Assign a bootserial to each new deployment.
*/
assign_bootserials (new_deployments);
g_hash_table_unref (assign_bootserials (new_deployments));
/* Determine whether or not we need to touch the bootloader
* configuration. If we have an equal number of deployments with
@@ -2148,7 +2146,10 @@ ostree_sysroot_deploy_tree (OstreeSysroot *self,
goto out;
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
{ ostree_cleanup_sepolicy_fscreatecon gpointer dummy = NULL;
#pragma GCC diagnostic pop
/* Explicitly override the label for the origin file to ensure
* it's system_conf_t.
+1 -1
View File
@@ -188,6 +188,7 @@ ostree_sysroot_upgrader_finalize (GObject *object)
g_free (self->origin_remote);
g_free (self->origin_ref);
g_free (self->override_csum);
g_free (self->new_revision);
G_OBJECT_CLASS (ostree_sysroot_upgrader_parent_class)->finalize (object);
}
@@ -530,7 +531,6 @@ ostree_sysroot_upgrader_pull_one_dir (OstreeSysrootUpgrader *self,
glnx_unref_object OstreeRepo *repo = NULL;
char *refs_to_fetch[] = { NULL, NULL };
const char *from_revision = NULL;
g_autofree char *new_revision = NULL;
g_autofree char *origin_refspec = NULL;
if (self->override_csum != NULL)
-1
View File
@@ -689,7 +689,6 @@ parse_deployment (OstreeSysroot *self,
glnx_fd_close int deployment_dfd = -1;
const char *deploy_basename;
g_autofree char *treebootserial_target = NULL;
g_autofree char *deploy_dir = NULL;
GKeyFile *origin = NULL;
g_autofree char *unlocked_development_path = NULL;
struct stat stbuf;
-3
View File
@@ -73,9 +73,6 @@ ot_gpgme_ctx_tmp_home_dir (gpgme_ctx_t gpgme_ctx,
GCancellable *cancellable,
GError **error)
{
g_autoptr(GFile) pubring_file = NULL;
g_autoptr(GOutputStream) target_stream = NULL;
g_autofree char *pubring_path = NULL;
g_autofree char *tmp_home_dir = NULL;
gpgme_error_t gpg_error;
gboolean ret = FALSE;
+1 -1
View File
@@ -26,6 +26,6 @@ G_BEGIN_DECLS
void ot_log_structured_print_id_v (const char *message_id,
const char *format,
...);
...) G_GNUC_PRINTF(2, 3);
G_END_DECLS
+1 -2
View File
@@ -33,8 +33,7 @@
GVariant *
ot_gvariant_new_empty_string_dict (void)
{
g_auto(GVariantBuilder) builder = {{0,}};
g_auto(GVariantBuilder) builder = OT_VARIANT_BUILDER_INITIALIZER;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
return g_variant_builder_end (&builder);
}
+7
View File
@@ -26,6 +26,13 @@
#include <string.h> /* Yeah...let's just do that here. */
#include <libglnx.h>
/* https://bugzilla.gnome.org/show_bug.cgi?id=766370 */
#if !GLIB_CHECK_VERSION(2, 49, 3)
#define OT_VARIANT_BUILDER_INITIALIZER {{0,}}
#else
#define OT_VARIANT_BUILDER_INITIALIZER {{{0,}}}
#endif
#define ot_gobject_refz(o) (o ? g_object_ref (o) : o)
#define ot_transfer_out_value(outp, srcp) G_STMT_START { \
-1
View File
@@ -58,7 +58,6 @@ ot_admin_builtin_deploy (int argc, char **argv, GCancellable *cancellable, GErro
glnx_unref_object OstreeSysroot *sysroot = NULL;
GKeyFile *origin = NULL;
glnx_unref_object OstreeRepo *repo = NULL;
g_autoptr(GPtrArray) new_deployments = NULL;
glnx_unref_object OstreeDeployment *new_deployment = NULL;
glnx_unref_object OstreeDeployment *merge_deployment = NULL;
g_autofree char *revision = NULL;
+5 -4
View File
@@ -96,6 +96,7 @@ ot_admin_builtin_set_origin (int argc, char **argv, GCancellable *cancellable, G
{ char **iter;
g_autoptr(GVariantBuilder) optbuilder =
g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
g_autoptr(GVariant) options = NULL;
for (iter = opt_set; iter && *iter; iter++)
{
@@ -109,18 +110,19 @@ ot_admin_builtin_set_origin (int argc, char **argv, GCancellable *cancellable, G
g_variant_builder_add (optbuilder, "{s@v}",
subkey, g_variant_new_variant (g_variant_new_string (subvalue)));
}
options = g_variant_ref_sink (g_variant_builder_end (optbuilder));
if (!ostree_repo_remote_change (repo, NULL,
OSTREE_REPO_REMOTE_CHANGE_ADD_IF_NOT_EXISTS,
remotename, url,
g_variant_builder_end (optbuilder),
options,
cancellable, error))
goto out;
}
{ GKeyFile *old_origin = ostree_deployment_get_origin (target_deployment);
g_autofree char *origin_refspec = g_key_file_get_string (old_origin, "origin", "refspec", NULL);
g_autofree char *new_refspec = NULL;
g_autofree char *origin_remote = NULL;
g_autofree char *origin_ref = NULL;
@@ -129,7 +131,6 @@ ot_admin_builtin_set_origin (int argc, char **argv, GCancellable *cancellable, G
{ g_autofree char *new_refspec = g_strconcat (remotename, ":", branch ? branch : origin_ref, NULL);
g_autoptr(GKeyFile) new_origin = NULL;
g_autoptr(GFile) origin_path = NULL;
new_origin = ostree_sysroot_origin_new_from_refspec (sysroot, new_refspec);
-5
View File
@@ -53,11 +53,6 @@ ot_admin_builtin_switch (int argc, char **argv, GCancellable *cancellable, GErro
g_autofree char *new_remote = NULL;
g_autofree char *new_ref = NULL;
g_autofree char *new_refspec = NULL;
g_autofree char *new_revision = NULL;
g_autoptr(GFile) deployment_path = NULL;
g_autoptr(GFile) deployment_origin_path = NULL;
glnx_unref_object OstreeDeployment *merge_deployment = NULL;
glnx_unref_object OstreeDeployment *new_deployment = NULL;
glnx_unref_object OstreeSysrootUpgrader *upgrader = NULL;
glnx_unref_object OstreeAsyncProgress *progress = NULL;
gboolean changed;
-1
View File
@@ -41,7 +41,6 @@ ot_admin_builtin_undeploy (int argc, char **argv, GCancellable *cancellable, GEr
const char *deploy_index_str;
int deploy_index;
g_autoptr(GPtrArray) current_deployments = NULL;
glnx_unref_object OstreeDeployment *booted_deployment = NULL;
glnx_unref_object OstreeDeployment *target_deployment = NULL;
context = g_option_context_new ("INDEX - Delete deployment INDEX");
-3
View File
@@ -44,9 +44,6 @@ ot_admin_builtin_unlock (int argc, char **argv, GCancellable *cancellable, GErro
gboolean ret = FALSE;
GOptionContext *context;
glnx_unref_object OstreeSysroot *sysroot = NULL;
glnx_unref_object OstreeRepo *repo = NULL;
g_autoptr(GPtrArray) new_deployments = NULL;
glnx_unref_object OstreeDeployment *merge_deployment = NULL;
OstreeDeployment *booted_deployment = NULL;
OstreeDeploymentUnlockedState target_state;
-2
View File
@@ -52,8 +52,6 @@ ot_admin_builtin_upgrade (int argc, char **argv, GCancellable *cancellable, GErr
GOptionContext *context;
glnx_unref_object OstreeSysroot *sysroot = NULL;
glnx_unref_object OstreeSysrootUpgrader *upgrader = NULL;
g_autoptr(GFile) deployment_path = NULL;
g_autoptr(GFile) deployment_origin_path = NULL;
g_autoptr(GKeyFile) origin = NULL;
glnx_unref_object OstreeAsyncProgress *progress = NULL;
gboolean changed;
@@ -38,12 +38,8 @@ ot_admin_instutil_builtin_grub2_generate (int argc, char **argv, GCancellable *c
{
gboolean ret = FALSE;
guint bootversion;
g_autoptr(GFile) subpath = NULL;
glnx_unref_object OstreeSePolicy *sepolicy = NULL;
g_autoptr(GPtrArray) deployments = NULL;
GOptionContext *context = NULL;
glnx_unref_object OstreeSysroot *sysroot = NULL;
g_autoptr(GFile) deployment_path = NULL;
context = g_option_context_new ("[BOOTVERSION] - generate GRUB2 configuration from given BLS entries");
-1
View File
@@ -60,7 +60,6 @@ ostree_builtin_pull_local (int argc, char **argv, GCancellable *cancellable, GEr
g_autofree char *src_repo_uri = NULL;
glnx_unref_object OstreeAsyncProgress *progress = NULL;
g_autoptr(GPtrArray) refs_to_fetch = NULL;
g_autoptr(GHashTable) source_objects = NULL;
OstreeRepoPullFlags pullflags = 0;
context = g_option_context_new ("SRC_REPO [REFS...] - Copy data from SRC_REPO");
+5 -2
View File
@@ -198,7 +198,7 @@ ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **
else
{
char *ref_to_fetch;
refs_to_fetch = g_ptr_array_new ();
refs_to_fetch = g_ptr_array_new_with_free_func (g_free);
if (!ostree_parse_refspec (argv[1], &remote, &ref_to_fetch, error))
goto out;
/* Transfer ownership */
@@ -208,6 +208,7 @@ ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **
{
GVariantBuilder builder;
g_autoptr(GVariant) options = NULL;
g_auto(GLnxConsoleRef) console = { 0, };
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
@@ -265,7 +266,9 @@ ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **
&console);
}
if (!ostree_repo_pull_with_options (repo, remote, g_variant_builder_end (&builder),
options = g_variant_ref_sink (g_variant_builder_end (&builder));
if (!ostree_repo_pull_with_options (repo, remote, options,
progress, cancellable, error))
goto out;
+3
View File
@@ -33,9 +33,12 @@ typedef struct {
static OstreeRemoteCommand remote_subcommands[] = {
{ "add", ot_remote_builtin_add },
{ "add-cookie", ot_remote_builtin_add_cookie },
{ "delete", ot_remote_builtin_delete },
{ "delete-cookie", ot_remote_builtin_delete_cookie },
{ "show-url", ot_remote_builtin_show_url },
{ "list", ot_remote_builtin_list },
{ "list-cookies", ot_remote_builtin_list_cookies },
{ "gpg-import", ot_remote_builtin_gpg_import },
{ "refs", ot_remote_builtin_refs },
{ "summary", ot_remote_builtin_summary },
-1
View File
@@ -399,7 +399,6 @@ ostree_builtin_static_delta (int argc, char **argv, GCancellable *cancellable, G
gboolean ret = FALSE;
OstreeCommand *command = NULL;
const char *cmdname = NULL;
glnx_unref_object OstreeRepo *repo = NULL;
int i;
gboolean want_help = FALSE;
+39
View File
@@ -44,6 +44,8 @@ static int opt_random_500s_percentage;
static int opt_random_500s_max = 100;
static gint opt_port = 0;
static gchar **opt_expected_cookies;
static guint emitted_random_500s_count = 0;
typedef struct {
@@ -61,6 +63,7 @@ static GOptionEntry options[] = {
{ "random-500s", 0, 0, G_OPTION_ARG_INT, &opt_random_500s_percentage, "Generate random HTTP 500 errors approximately for PERCENTAGE requests", "PERCENTAGE" },
{ "random-500s-max", 0, 0, G_OPTION_ARG_INT, &opt_random_500s_max, "Limit HTTP 500 errors to MAX (default 100)", "MAX" },
{ "log-file", 0, 0, G_OPTION_ARG_FILENAME, &opt_log, "Put logs here", "PATH" },
{ "expected-cookies", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_expected_cookies, "Expect given cookies in the http request", "KEY=VALUE" },
{ NULL }
};
@@ -199,6 +202,42 @@ do_get (OtTrivialHttpd *self,
struct stat stbuf;
httpd_log (self, "serving %s\n", path);
if (opt_expected_cookies)
{
GSList *cookies = soup_cookies_from_request (msg);
GSList *l;
int i;
for (i = 0 ; opt_expected_cookies[i] != NULL; i++)
{
gboolean found = FALSE;
gchar *k = opt_expected_cookies[i];
gchar *v = strchr (k, '=') + 1;
for (l = cookies; l != NULL ; l = g_slist_next (l))
{
SoupCookie *c = l->data;
if (!strncmp (k, soup_cookie_get_name (c), v - k - 1) &&
!strcmp (v, soup_cookie_get_value (c)))
{
found = TRUE;
break;
}
}
if (!found)
{
httpd_log (self, "Expected cookie not found %s\n", k);
soup_message_set_status (msg, SOUP_STATUS_FORBIDDEN);
soup_cookies_free (cookies);
goto out;
}
}
soup_cookies_free (cookies);
}
if (strstr (path, "../") != NULL)
{
soup_message_set_status (msg, SOUP_STATUS_FORBIDDEN);
+7
View File
@@ -366,6 +366,13 @@ ostree_admin_option_context_parse (GOptionContext *context,
g_print ("%s\n", deployment_path);
/* The g_autoptr, g_autofree etc. don't happen when we explicitly
* exit, making valgrind complain about leaks */
g_clear_object (&sysroot);
g_clear_object (&sysroot_path);
g_clear_object (&deployment_file);
g_clear_pointer (&deployments, g_ptr_array_unref);
g_clear_pointer (&deployment_path, g_free);
exit (EXIT_SUCCESS);
}
+84
View File
@@ -0,0 +1,84 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2015 Red Hat, Inc.
* Copyright (C) 2016 Sjoerd Simons <sjoerd@luon.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <libsoup/soup.h>
#include "otutil.h"
#include "ot-main.h"
#include "ot-remote-builtins.h"
#include "ostree-repo-private.h"
static GOptionEntry option_entries[] = {
{ NULL }
};
gboolean
ot_remote_builtin_add_cookie (int argc, char **argv, GCancellable *cancellable, GError **error)
{
GOptionContext *context;
glnx_unref_object OstreeRepo *repo = NULL;
const char *remote_name;
const char *domain;
const char *path;
const char *cookie_name;
const char *value;
g_autofree char *jar_path = NULL;
g_autofree char *cookie_file = NULL;
glnx_unref_object SoupCookieJar *jar = NULL;
SoupCookie *cookie;
context = g_option_context_new ("NAME DOMAIN PATH COOKIE_NAME VALUE - Add a cookie to remote");
if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
return FALSE;
if (argc < 6)
{
ot_util_usage_error (context, "NAME, DOMAIN, PATH, COOKIE_NAME and VALUE must be specified", error);
return FALSE;
}
remote_name = argv[1];
domain = argv[2];
path = argv[3];
cookie_name = argv[4];
value = argv[5];
cookie_file = g_strdup_printf ("%s.cookies.txt", remote_name);
jar_path = g_build_filename (g_file_get_path (repo->repodir), cookie_file, NULL);
jar = soup_cookie_jar_text_new (jar_path, FALSE);
/* Pick a silly long expire time, we're just storing the cookies in the
* jar and on pull the jar is read-only so expiry has little actual value */
cookie = soup_cookie_new (cookie_name, value, domain, path,
SOUP_COOKIE_MAX_AGE_ONE_YEAR * 25);
/* jar takes ownership of cookie */
soup_cookie_jar_add_cookie (jar, cookie);
return TRUE;
}
+4 -3
View File
@@ -49,9 +49,8 @@ ot_remote_builtin_add (int argc, char **argv, GCancellable *cancellable, GError
const char *remote_name;
const char *remote_url;
char **iter;
g_autofree char *target_name = NULL;
g_autoptr(GFile) target_conf = NULL;
g_autoptr(GVariantBuilder) optbuilder = NULL;
g_autoptr(GVariant) options = NULL;
gboolean ret = FALSE;
context = g_option_context_new ("NAME [metalink=|mirrorlist=]URL [BRANCH...] - Add a remote repository");
@@ -111,11 +110,13 @@ ot_remote_builtin_add (int argc, char **argv, GCancellable *cancellable, GError
"gpg-verify",
g_variant_new_variant (g_variant_new_boolean (FALSE)));
options = g_variant_ref_sink (g_variant_builder_end (optbuilder));
if (!ostree_repo_remote_change (repo, NULL,
opt_if_not_exists ? OSTREE_REPO_REMOTE_CHANGE_ADD_IF_NOT_EXISTS :
OSTREE_REPO_REMOTE_CHANGE_ADD,
remote_name, remote_url,
g_variant_builder_end (optbuilder),
options,
cancellable, error))
goto out;
@@ -0,0 +1,96 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2015 Red Hat, Inc.
* Copyright (C) 2016 Sjoerd Simons <sjoerd@luon.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <libsoup/soup.h>
#include "otutil.h"
#include "ot-main.h"
#include "ot-remote-builtins.h"
#include "ostree-repo-private.h"
static GOptionEntry option_entries[] = {
{ NULL }
};
gboolean
ot_remote_builtin_delete_cookie (int argc, char **argv, GCancellable *cancellable, GError **error)
{
GOptionContext *context;
glnx_unref_object OstreeRepo *repo = NULL;
const char *remote_name;
const char *domain;
const char *path;
const char *cookie_name;
g_autofree char *jar_path = NULL;
g_autofree char *cookie_file = NULL;
glnx_unref_object SoupCookieJar *jar = NULL;
GSList *cookies;
gboolean found = FALSE;
context = g_option_context_new ("NAME DOMAIN PATH COOKIE_NAME- Remote one cookie from remote");
if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
return FALSE;
if (argc < 5)
{
ot_util_usage_error (context, "NAME, DOMAIN, PATH and COOKIE_NAME must be specified", error);
return FALSE;
}
remote_name = argv[1];
domain = argv[2];
path = argv[3];
cookie_name = argv[4];
cookie_file = g_strdup_printf ("%s.cookies.txt", remote_name);
jar_path = g_build_filename (g_file_get_path (repo->repodir), cookie_file, NULL);
jar = soup_cookie_jar_text_new (jar_path, FALSE);
cookies = soup_cookie_jar_all_cookies (jar);
while (cookies != NULL)
{
SoupCookie *cookie = cookies->data;
if (!strcmp (domain, soup_cookie_get_domain (cookie)) &&
!strcmp (path, soup_cookie_get_path (cookie)) &&
!strcmp (cookie_name, soup_cookie_get_name (cookie)))
{
soup_cookie_jar_delete_cookie (jar, cookie);
found = TRUE;
}
soup_cookie_free (cookie);
cookies = g_slist_delete_link (cookies, cookies);
}
if (!found)
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Cookie not found in jar");
return found;
}
@@ -0,0 +1,86 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2015 Red Hat, Inc.
* Copyright (C) 2016 Sjoerd Simons <sjoerd@luon.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <libsoup/soup.h>
#include "otutil.h"
#include "ot-main.h"
#include "ot-remote-builtins.h"
#include "ostree-repo-private.h"
static GOptionEntry option_entries[] = {
{ NULL }
};
gboolean
ot_remote_builtin_list_cookies (int argc, char **argv, GCancellable *cancellable, GError **error)
{
GOptionContext *context;
glnx_unref_object OstreeRepo *repo = NULL;
const char *remote_name;
g_autofree char *jar_path = NULL;
g_autofree char *cookie_file = NULL;
glnx_unref_object SoupCookieJar *jar = NULL;
GSList *cookies;
context = g_option_context_new ("NAME - Show remote repository cookies");
if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
return FALSE;
if (argc < 2)
{
ot_util_usage_error (context, "NAME must be specified", error);
return FALSE;
}
remote_name = argv[1];
cookie_file = g_strdup_printf ("%s.cookies.txt", remote_name);
jar_path = g_build_filename (g_file_get_path (repo->repodir), cookie_file, NULL);
jar = soup_cookie_jar_text_new (jar_path, TRUE);
cookies = soup_cookie_jar_all_cookies (jar);
while (cookies != NULL)
{
SoupCookie *cookie = cookies->data;
SoupDate *expiry = soup_cookie_get_expires (cookie);
g_print ("--\n");
g_print ("Domain: %s\n", soup_cookie_get_domain (cookie));
g_print ("Path: %s\n", soup_cookie_get_path (cookie));
g_print ("Name: %s\n", soup_cookie_get_name (cookie));
g_print ("Secure: %s\n", soup_cookie_get_secure (cookie) ? "yes" : "no");
g_print ("Expires: %s\n", soup_date_to_string (expiry, SOUP_DATE_COOKIE));
g_print ("Value: %s\n", soup_cookie_get_value (cookie));
soup_cookie_free (cookie);
cookies = g_slist_delete_link (cookies, cookies);
}
return TRUE;
}
+1
View File
@@ -29,6 +29,7 @@ static char* opt_cache_dir;
static GOptionEntry option_entries[] = {
{ "cache-dir", 0, 0, G_OPTION_ARG_STRING, &opt_cache_dir, "Use custom cache dir", NULL },
{ NULL }
};
gboolean
+1 -1
View File
@@ -32,7 +32,7 @@ static GOptionEntry option_entries[] = {
gboolean
ot_remote_builtin_show_url (int argc, char **argv, GCancellable *cancellable, GError **error)
{
GOptionContext *context;
g_autoptr(GOptionContext) context = NULL;
glnx_unref_object OstreeRepo *repo = NULL;
const char *remote_name;
g_autofree char *remote_url = NULL;
+3
View File
@@ -25,9 +25,12 @@
G_BEGIN_DECLS
gboolean ot_remote_builtin_add (int argc, char **argv, GCancellable *cancellable, GError **error);
gboolean ot_remote_builtin_add_cookie (int argc, char **argv, GCancellable *cancellable, GError **error);
gboolean ot_remote_builtin_delete (int argc, char **argv, GCancellable *cancellable, GError **error);
gboolean ot_remote_builtin_delete_cookie (int argc, char **argv, GCancellable *cancellable, GError **error);
gboolean ot_remote_builtin_gpg_import (int argc, char **argv, GCancellable *cancellable, GError **error);
gboolean ot_remote_builtin_list (int argc, char **argv, GCancellable *cancellable, GError **error);
gboolean ot_remote_builtin_list_cookies (int argc, char **argv, GCancellable *cancellable, GError **error);
gboolean ot_remote_builtin_show_url (int argc, char **argv, GCancellable *cancellable, GError **error);
gboolean ot_remote_builtin_refs (int argc, char **argv, GCancellable *cancellable, GError **error);
gboolean ot_remote_builtin_summary (int argc, char **argv, GCancellable *cancellable, GError **error);
+1 -1
View File
@@ -2620,7 +2620,7 @@ time_zone_hhmm (parser_control *pc, textint s, long int mm)
/* If the absolute number of minutes is larger than 24 hours,
arrange to reject it by incrementing pc->zones_seen. Thus,
we allow only values in the range UTC-24:00 to UTC+24:00. */
if (24 * 60 < abs (n_minutes))
if (24 * 60 < labs (n_minutes))
pc->zones_seen++;
return n_minutes;
+1 -1
View File
@@ -896,7 +896,7 @@ time_zone_hhmm (parser_control *pc, textint s, long int mm)
/* If the absolute number of minutes is larger than 24 hours,
arrange to reject it by incrementing pc->zones_seen. Thus,
we allow only values in the range UTC-24:00 to UTC+24:00. */
if (24 * 60 < abs (n_minutes))
if (24 * 60 < labs (n_minutes))
pc->zones_seen++;
return n_minutes;