Add ostree_ensure_repo_writable()
Commands that need to write files within the repo directory can call this early to ensure the directory is writable for the current user. If not, it fails with a helpful "You need to be root to perform this command" message.
This commit is contained in:
parent
a25c7fab12
commit
7941189dfd
|
|
@ -360,3 +360,17 @@ ostree_admin_option_context_parse (GOptionContext *context,
|
||||||
out:
|
out:
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
ostree_ensure_repo_writable (OstreeRepo *repo,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
|
ret = ostree_repo_is_writable (repo, error);
|
||||||
|
|
||||||
|
g_prefix_error (error, "Cannot write to repository: ");
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,3 +51,5 @@ gboolean ostree_admin_option_context_parse (GOptionContext *context,
|
||||||
int *argc, char ***argv,
|
int *argc, char ***argv,
|
||||||
OstreeSysroot **out_sysroot,
|
OstreeSysroot **out_sysroot,
|
||||||
GCancellable *cancellable, GError **error);
|
GCancellable *cancellable, GError **error);
|
||||||
|
|
||||||
|
gboolean ostree_ensure_repo_writable (OstreeRepo *repo, GError **error);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue