[pacman-dev] [PATCH] restrict transaction package origins
This moves the "wrong args" error up from trans_commit to add_pkg when used with a local pkg and adds the error for remove_pkg when used with a sync pkg, which currently just removes the db entry. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> --- lib/libalpm/add.c | 2 ++ lib/libalpm/remove.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index f38afef..2aa5bae 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -57,6 +57,8 @@ int SYMEXPORT alpm_add_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg) /* Sanity checks */ CHECK_HANDLE(handle, return -1); ASSERT(pkg != NULL, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1)); + ASSERT(pkg->origin != ALPM_PKG_FROM_LOCALDB, + RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1)); ASSERT(handle == pkg->handle, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1)); trans = handle->trans; ASSERT(trans != NULL, RET_ERR(handle, ALPM_ERR_TRANS_NULL, -1)); diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index 6fb82ee..a1dd123 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -63,6 +63,8 @@ int SYMEXPORT alpm_remove_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg) /* Sanity checks */ CHECK_HANDLE(handle, return -1); ASSERT(pkg != NULL, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1)); + ASSERT(pkg->origin == ALPM_PKG_FROM_LOCALDB, + RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1)); ASSERT(handle == pkg->handle, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1)); trans = handle->trans; ASSERT(trans != NULL, RET_ERR(handle, ALPM_ERR_TRANS_NULL, -1)); -- 1.8.5.3
On 08/02/14 04:04, Andrew Gregory wrote:
This moves the "wrong args" error up from trans_commit to add_pkg when used with a local pkg and adds the error for remove_pkg when used with a sync pkg, which currently just removes the db entry.
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> ---
Ack.
participants (2)
-
Allan McRae
-
Andrew Gregory