Check repo permission prior to attempting to modify it

Fail early with a helpful message if the user does not have sufficient
permission to modify an OSTree repository.
This commit is contained in:
Matthew Barnes 2015-01-16 13:28:36 -05:00 committed by Colin Walters
parent 7941189dfd
commit 1d5e2682fd
7 changed files with 24 additions and 0 deletions

View File

@ -313,6 +313,9 @@ ostree_builtin_commit (int argc, char **argv, GCancellable *cancellable, GError
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
goto out;
if (!ostree_ensure_repo_writable (repo, error))
goto out;
if (opt_statoverride_file)
{
if (!parse_statoverride_file (&mode_adds, cancellable, error))

View File

@ -55,6 +55,9 @@ ostree_builtin_prune (int argc, char **argv, GCancellable *cancellable, GError *
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
goto out;
if (!opt_no_prune && !ostree_ensure_repo_writable (repo, error))
goto out;
if (opt_refs_only)
pruneflags |= OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY;
if (opt_no_prune)

View File

@ -58,6 +58,9 @@ ostree_builtin_pull_local (int argc, char **argv, GCancellable *cancellable, GEr
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
goto out;
if (!ostree_ensure_repo_writable (repo, error))
goto out;
if (argc < 2)
{
gchar *help = g_option_context_get_help (context, TRUE, NULL);

View File

@ -57,6 +57,9 @@ ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
goto out;
if (!ostree_ensure_repo_writable (repo, error))
goto out;
if (argc < 2)
{
ot_util_usage_error (context, "REMOTE must be specified", error);

View File

@ -100,6 +100,9 @@ ostree_builtin_reset (int argc,
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
goto out;
if (!ostree_ensure_repo_writable (repo, error))
goto out;
if (argc <= 2)
{
ot_util_usage_error (context, "A ref and commit argument is required", error);

View File

@ -140,6 +140,9 @@ ot_static_delta_builtin_generate (int argc, char **argv, GCancellable *cancellab
if (!ostree_option_context_parse (context, generate_options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
goto out;
if (!ostree_ensure_repo_writable (repo, error))
goto out;
if (argc >= 3 && opt_to_rev == NULL)
opt_to_rev = argv[2];
@ -248,6 +251,9 @@ ot_static_delta_builtin_apply_offline (int argc, char **argv, GCancellable *canc
if (!ostree_option_context_parse (context, apply_offline_options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
goto out;
if (!ostree_ensure_repo_writable (repo, error))
goto out;
if (argc < 3)
{
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,

View File

@ -46,6 +46,9 @@ ostree_builtin_summary (int argc, char **argv, GCancellable *cancellable, GError
if (opt_update)
{
if (!ostree_ensure_repo_writable (repo, error))
goto out;
if (!ostree_repo_regenerate_summary (repo, NULL, cancellable, error))
goto out;
}