mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-06 17:18:25 +03:00
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:
parent
7941189dfd
commit
1d5e2682fd
@ -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))
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user