[pacman-dev] [PATCH] Fix FS#8905 (-Sp as non-root)
Nagy Gabor
ngaba at bibl.u-szeged.hu
Sat Mar 8 12:41:07 EST 2008
From 80e66dda0239c04e75cda0771bd4627921aa098e Mon Sep 17 00:00:00 2001
From: Nagy Gabor <ngaba at bibl.u-szeged.hu>
Date: Sat, 8 Mar 2008 18:35:44 +0100
Subject: [PATCH] Fix FS#8905 (-Sp as non-root)
This patch is quite ugly, but solves the issue without API change.
Signed-off-by: Nagy Gabor <ngaba at bibl.u-szeged.hu>
---
lib/libalpm/trans.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 52dbe7a..79a33f0 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -72,9 +72,11 @@ int SYMEXPORT alpm_trans_init(pmtranstype_t type, pmtransflag_t flags,
ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, -1));
/* lock db */
- handle->lckfd = _alpm_lckmk();
- if(handle->lckfd == -1) {
- RET_ERR(PM_ERR_HANDLE_LOCK, -1);
+ if(!(type == PM_TRANS_TYPE_SYNC && flags & PM_TRANS_FLAG_PRINTURIS)) {
+ handle->lckfd = _alpm_lckmk();
+ if(handle->lckfd == -1) {
+ RET_ERR(PM_ERR_HANDLE_LOCK, -1);
+ }
}
handle->trans = _alpm_trans_new();
@@ -190,6 +192,7 @@ int SYMEXPORT alpm_trans_interrupt()
int SYMEXPORT alpm_trans_release()
{
pmtrans_t *trans;
+ int nolock;
ALPM_LOG_FUNC;
@@ -197,6 +200,8 @@ int SYMEXPORT alpm_trans_release()
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
trans = handle->trans;
+ nolock = (trans->type == PM_TRANS_TYPE_SYNC) && (trans->flags & PM_TRANS_FLAG_PRINTURIS);
+
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
ASSERT(trans->state != STATE_IDLE, RET_ERR(PM_ERR_TRANS_NULL, -1));
@@ -204,6 +209,9 @@ int SYMEXPORT alpm_trans_release()
handle->trans = NULL;
/* unlock db */
+ if(nolock) {
+ return(0);
+ }
if(handle->lckfd != -1) {
close(handle->lckfd);
handle->lckfd = -1;
--
1.5.3.8
More information about the pacman-dev
mailing list