mirror of
https://github.com/moparisthebest/pacman
synced 2025-03-01 09:51:50 -05:00
We don't need root with -Sp
FS#8905 is fixed. The front-end passes PM_TRANS_FLAG_NOLOCK to the back-end, so it doesn't lock the database. That's why we don't need root anymore. I reworked (and renamed) needs_transaction() accordingly. I also added missing -Sc check there (for example, -Sci didn't print non-root error, but pacman wanted to lock the database). Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
c520d38451
commit
f4ecc908ec
@ -481,6 +481,7 @@ static int parseargs(int argc, char *argv[])
|
|||||||
config->op_q_isfile = 1;
|
config->op_q_isfile = 1;
|
||||||
config->op_s_printuris = 1;
|
config->op_s_printuris = 1;
|
||||||
config->flags |= PM_TRANS_FLAG_NOCONFLICTS;
|
config->flags |= PM_TRANS_FLAG_NOCONFLICTS;
|
||||||
|
config->flags |= PM_TRANS_FLAG_NOLOCK;
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
config->quiet = 1;
|
config->quiet = 1;
|
||||||
@ -900,7 +901,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
#if defined(HAVE_GETEUID) && !defined(CYGWIN)
|
#if defined(HAVE_GETEUID) && !defined(CYGWIN)
|
||||||
/* check if we have sufficient permission for the requested operation */
|
/* check if we have sufficient permission for the requested operation */
|
||||||
if(myuid > 0 && needs_transaction()) {
|
if(myuid > 0 && needs_root()) {
|
||||||
pm_printf(PM_LOG_ERROR, _("you cannot perform this operation unless you are root.\n"));
|
pm_printf(PM_LOG_ERROR, _("you cannot perform this operation unless you are root.\n"));
|
||||||
cleanup(EXIT_FAILURE);
|
cleanup(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -69,19 +69,16 @@ int trans_release(void)
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int needs_transaction(void)
|
int needs_root(void)
|
||||||
{
|
{
|
||||||
if(config->op != PM_OP_MAIN && config->op != PM_OP_QUERY && config->op != PM_OP_DEPTEST) {
|
if(config->op == PM_OP_UPGRADE || config->op == PM_OP_REMOVE || /* -U, -R */
|
||||||
if((config->op == PM_OP_SYNC && !config->op_s_sync &&
|
(config->op == PM_OP_SYNC && (config->op_s_clean || config->op_s_sync || /* -Sc, -Sy */
|
||||||
(config->op_s_search || config->group || config->op_q_list || config->op_q_info))
|
(!config->group && !config->op_s_info && !config->op_q_list /* all other -S combinations, where */
|
||||||
|| config->op == PM_OP_DEPTEST) {
|
&& !config->op_s_search && !config->op_s_printuris)))) { /* -g, -i, -l, -s, -p is not set */
|
||||||
/* special case: PM_OP_SYNC can be used w/ config->op_s_search by any user */
|
|
||||||
return(0);
|
|
||||||
} else {
|
|
||||||
return(1);
|
return(1);
|
||||||
}
|
} else {
|
||||||
}
|
|
||||||
return(0);
|
return(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* gets the current screen column width */
|
/* gets the current screen column width */
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
int trans_init(pmtranstype_t type, pmtransflag_t flags);
|
int trans_init(pmtranstype_t type, pmtransflag_t flags);
|
||||||
int trans_release(void);
|
int trans_release(void);
|
||||||
int needs_transaction(void);
|
int needs_root(void);
|
||||||
int getcols(void);
|
int getcols(void);
|
||||||
int makepath(const char *path);
|
int makepath(const char *path);
|
||||||
int rmrf(const char *path);
|
int rmrf(const char *path);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user