Delete "compose sign"
We want people to use the libostree API for things like this. Further, the `rpm-sign` tool that this calls is Red Hat internal, so it doesn't make sense to have a public wrapper for it. Closes: https://github.com/projectatomic/rpm-ostree/pull/152 Closes: #607 Approved by: jlebon
This commit is contained in:
parent
687567d3ee
commit
5f7c5305ff
@ -49,7 +49,6 @@ rpm_ostree_SOURCES = src/app/main.c \
|
||||
if BUILDOPT_COMPOSE_TOOLING
|
||||
rpm_ostree_SOURCES += \
|
||||
src/app/rpmostree-compose-builtin-tree.c \
|
||||
src/app/rpmostree-compose-builtin-sign.c \
|
||||
src/app/rpmostree-builtin-compose.c \
|
||||
$(NULL)
|
||||
endif
|
||||
|
@ -35,7 +35,6 @@ typedef struct {
|
||||
|
||||
static RpmOstreeComposeCommand compose_subcommands[] = {
|
||||
{ "tree", rpmostree_compose_builtin_tree },
|
||||
{ "sign", rpmostree_compose_builtin_sign },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
@ -1,155 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||
*
|
||||
* Copyright (C) 2013,2014 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* This program 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 licence 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 <string.h>
|
||||
#include <glib-unix.h>
|
||||
|
||||
#include "rpmostree-compose-builtins.h"
|
||||
#include "rpmostree-libbuiltin.h"
|
||||
#include "rpmostree-util.h"
|
||||
|
||||
#include "libglnx.h"
|
||||
|
||||
static char *opt_repo_path;
|
||||
static char *opt_key_id;
|
||||
static char *opt_rev;
|
||||
|
||||
static GOptionEntry option_entries[] = {
|
||||
{ "repo", 0, 0, G_OPTION_ARG_STRING, &opt_repo_path, "Repository path", "REPO" },
|
||||
{ "key", 0, 0, G_OPTION_ARG_STRING, &opt_key_id, "Key ID", "KEY" },
|
||||
{ "rev", 0, 0, G_OPTION_ARG_STRING, &opt_rev, "Revision to sign", "REV" },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
int
|
||||
rpmostree_compose_builtin_sign (int argc,
|
||||
char **argv,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
int exit_status = EXIT_FAILURE;
|
||||
GOptionContext *context = g_option_context_new ("- Use rpm-sign to sign an OSTree commit");
|
||||
g_autoptr(GFile) repopath = NULL;
|
||||
glnx_unref_object OstreeRepo *repo = NULL;
|
||||
g_autoptr(GFile) tmp_commitdata_file = NULL;
|
||||
g_autoptr(GFileIOStream) tmp_sig_stream = NULL;
|
||||
g_autoptr(GFile) tmp_sig_file = NULL;
|
||||
g_autoptr(GFileIOStream) tmp_commitdata_stream = NULL;
|
||||
GOutputStream *tmp_commitdata_output = NULL;
|
||||
g_autoptr(GInputStream) commit_data = NULL;
|
||||
g_autofree char *checksum = NULL;
|
||||
g_autoptr(GVariant) commit_variant = NULL;
|
||||
g_autoptr(GBytes) commit_bytes = NULL;
|
||||
|
||||
if (!rpmostree_option_context_parse (context,
|
||||
option_entries,
|
||||
&argc, &argv,
|
||||
RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
|
||||
cancellable,
|
||||
NULL,
|
||||
error))
|
||||
goto out;
|
||||
|
||||
if (!(opt_repo_path && opt_key_id && opt_rev))
|
||||
{
|
||||
rpmostree_usage_error (context, "Missing required argument", error);
|
||||
goto out;
|
||||
}
|
||||
|
||||
repopath = g_file_new_for_path (opt_repo_path);
|
||||
repo = ostree_repo_new (repopath);
|
||||
if (!ostree_repo_open (repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_repo_resolve_rev (repo, opt_rev, FALSE, &checksum, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT,
|
||||
checksum, &commit_variant, error))
|
||||
goto out;
|
||||
|
||||
commit_bytes = g_variant_get_data_as_bytes (commit_variant);
|
||||
commit_data = (GInputStream*)g_memory_input_stream_new_from_bytes (commit_bytes);
|
||||
|
||||
tmp_commitdata_file = g_file_new_tmp ("tmpsigXXXXXX", &tmp_commitdata_stream,
|
||||
error);
|
||||
if (!tmp_commitdata_file)
|
||||
goto out;
|
||||
|
||||
tmp_commitdata_output = (GOutputStream*)g_io_stream_get_output_stream ((GIOStream*)tmp_commitdata_stream);
|
||||
if (g_output_stream_splice ((GOutputStream*)tmp_commitdata_output,
|
||||
commit_data,
|
||||
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE |
|
||||
G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
|
||||
cancellable, error) < 0)
|
||||
goto out;
|
||||
|
||||
tmp_sig_file = g_file_new_tmp ("tmpsigoutXXXXXX", &tmp_sig_stream, error);
|
||||
if (!tmp_sig_file)
|
||||
goto out;
|
||||
|
||||
(void) g_io_stream_close ((GIOStream*)tmp_sig_stream, NULL, NULL);
|
||||
|
||||
|
||||
{ const char *child_argv[] = { "rpm-sign",
|
||||
"--key", opt_key_id,
|
||||
"--detachsign", gs_file_get_path_cached (tmp_commitdata_file),
|
||||
"--output", gs_file_get_path_cached (tmp_sig_file),
|
||||
NULL };
|
||||
int estatus;
|
||||
|
||||
if (!g_spawn_sync (NULL, (char**)child_argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL,
|
||||
NULL, NULL, &estatus, error))
|
||||
goto out;
|
||||
if (!g_spawn_check_exit_status (estatus, error))
|
||||
goto out;
|
||||
}
|
||||
|
||||
{
|
||||
char *sigcontent = NULL;
|
||||
gsize len;
|
||||
g_autoptr(GBytes) sigbytes = NULL;
|
||||
|
||||
if (!g_file_load_contents (tmp_sig_file, cancellable, &sigcontent, &len, NULL,
|
||||
error))
|
||||
goto out;
|
||||
|
||||
sigbytes = g_bytes_new_take (sigcontent, len);
|
||||
|
||||
if (!ostree_repo_append_gpg_signature (repo, checksum, sigbytes,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
|
||||
g_print ("Successfully signed OSTree commit=%s with key=%s\n",
|
||||
checksum, opt_key_id);
|
||||
|
||||
exit_status = EXIT_SUCCESS;
|
||||
|
||||
out:
|
||||
if (tmp_commitdata_file)
|
||||
(void) unlink (gs_file_get_path_cached (tmp_commitdata_file));
|
||||
if (tmp_sig_file)
|
||||
(void) unlink (gs_file_get_path_cached (tmp_sig_file));
|
||||
|
||||
return exit_status;
|
||||
}
|
@ -27,7 +27,6 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gboolean rpmostree_compose_builtin_tree (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean rpmostree_compose_builtin_sign (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user