diff options
author | Aaron Griffin <aaronmgriffin@gmail.com> | 2007-09-28 06:03:35 +0200 |
---|---|---|
committer | Aaron Griffin <aaronmgriffin@gmail.com> | 2007-09-28 07:25:57 +0200 |
commit | 4942d216323cbe2f099c43893cc95368a3cd1197 (patch) | |
tree | ec99167060320472eb637a0ae99f7c3872bc6435 /src/pacman/util.c | |
parent | 50bb16e0151e31479cb2602c9749ffe18f7a3592 (diff) | |
download | pacman-4942d216323cbe2f099c43893cc95368a3cd1197.tar.gz pacman-4942d216323cbe2f099c43893cc95368a3cd1197.tar.xz |
Break out transaction test to a separate function
Added needs_transaction, putting out "hey do we need root?" tests in one place.
Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
Diffstat (limited to 'src/pacman/util.c')
-rw-r--r-- | src/pacman/util.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/pacman/util.c b/src/pacman/util.c index 8bf4ec14..4cb93156 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -45,6 +45,25 @@ extern config_t *config; +int needs_transaction() +{ + if(config->op != PM_OP_MAIN && config->op != PM_OP_QUERY && config->op != PM_OP_DEPTEST) { + if((config->op == PM_OP_SYNC && !config->op_s_sync && + (config->op_s_search || config->group || config->op_q_list || config->op_q_info + || config->flags & PM_TRANS_FLAG_PRINTURIS)) + || config->op == PM_OP_DEPTEST + || (strcmp(alpm_option_get_root(), "/") != 0)) { + /* special case: PM_OP_SYNC can be used w/ config->op_s_search by any user */ + /* special case: ignore root user check if -r is specified, fall back on + * normal FS checking */ + return(0); + } else { + return(1); + } + } + return(0); +} + /* gets the current screen column width */ int getcols() { |