[pacman-dev] [PATCH] Fix FS#8905 (-Sp as non-root)
From 80e66dda0239c04e75cda0771bd4627921aa098e Mon Sep 17 00:00:00 2001 From: Nagy Gabor <ngaba@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@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
From c268ac9ee0afa9413ce4c91d4fcc8cb3c91ee0b1 Mon Sep 17 00:00:00 2001 From: Nagy Gabor <ngaba@bibl.u-szeged.hu> Date: Sat, 8 Mar 2008 18:57:26 +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@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..a19fb28 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; @@ -200,10 +203,15 @@ int SYMEXPORT alpm_trans_release() ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); ASSERT(trans->state != STATE_IDLE, RET_ERR(PM_ERR_TRANS_NULL, -1)); + nolock = (trans->type == PM_TRANS_TYPE_SYNC) && (trans->flags & PM_TRANS_FLAG_PRINTURIS); + _alpm_trans_free(trans); handle->trans = NULL; /* unlock db */ + if(nolock) { + return(0); + } if(handle->lckfd != -1) { close(handle->lckfd); handle->lckfd = -1; -- 1.5.3.8
On Sat, Mar 08, 2008 at 06:58:07PM +0100, Nagy Gabor wrote:
From c268ac9ee0afa9413ce4c91d4fcc8cb3c91ee0b1 Mon Sep 17 00:00:00 2001 From: Nagy Gabor <ngaba@bibl.u-szeged.hu> Date: Sat, 8 Mar 2008 18:57:26 +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@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..a19fb28 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;
@@ -200,10 +203,15 @@ int SYMEXPORT alpm_trans_release() ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); ASSERT(trans->state != STATE_IDLE, RET_ERR(PM_ERR_TRANS_NULL, -1));
+ nolock = (trans->type == PM_TRANS_TYPE_SYNC) && (trans->flags & PM_TRANS_FLAG_PRINTURIS); + _alpm_trans_free(trans); handle->trans = NULL;
/* unlock db */ + if(nolock) { + return(0); + } if(handle->lckfd != -1) { close(handle->lckfd); handle->lckfd = -1; -- 1.5.3.8
I was thinking about doing something like that as a quick fix for a 3.1.x release, since some users were not happy. I didn't test it yet but it looks fine. We agree that this is a ugly hack though.
On Sat, Mar 08, 2008 at 06:58:07PM +0100, Nagy Gabor wrote:
From c268ac9ee0afa9413ce4c91d4fcc8cb3c91ee0b1 Mon Sep 17 00:00:00 2001 From: Nagy Gabor <ngaba@bibl.u-szeged.hu> Date: Sat, 8 Mar 2008 18:57:26 +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@bibl.u-szeged.hu> --- lib/libalpm/trans.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-)
But this patch is apparently based on the master branch. If it's a fix for 3.2, you shouldn't worry about breaking the API, if that allows you to provide a cleaner patch.
On Sat, Mar 08, 2008 at 06:58:07PM +0100, Nagy Gabor wrote:
From c268ac9ee0afa9413ce4c91d4fcc8cb3c91ee0b1 Mon Sep 17 00:00:00 2001 From: Nagy Gabor <ngaba@bibl.u-szeged.hu> Date: Sat, 8 Mar 2008 18:57:26 +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@bibl.u-szeged.hu> --- lib/libalpm/trans.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-)
But this patch is apparently based on the master branch. If it's a fix for 3.2, you shouldn't worry about breaking the API, if that allows you to provide a cleaner patch.
How can I get maint? :-S Bye ---------------------------------------------------- SZTE Egyetemi Könyvtár - http://www.bibl.u-szeged.hu This mail sent through IMP: http://horde.org/imp/
On Mon, Mar 10, 2008 at 04:22:03PM +0100, Nagy Gabor wrote:
How can I get maint? :-S
git branch -r git checkout -b maint origin/maint
On Mon, Mar 10, 2008 at 04:22:03PM +0100, Nagy Gabor wrote:
How can I get maint? :-S
git branch -r git checkout -b maint origin/maint
thx ---------------------------------------------------- SZTE Egyetemi Könyvtár - http://www.bibl.u-szeged.hu This mail sent through IMP: http://horde.org/imp/
participants (2)
-
Nagy Gabor
-
Xavier