1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-22 15:58:50 -05:00

paccache: allow running as root

The main motivation for this change is to allow this to be run as a cron
job.

Satisfies FS#29897 and some other undocumented requests for this.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
This commit is contained in:
Dave Reisner 2012-05-15 20:53:47 -04:00 committed by Dan McGee
parent 9a76a458b8
commit a64a8d6cea

View File

@ -130,7 +130,7 @@ size_to_human() {
} }
runcmd() { runcmd() {
if (( needsroot )); then if (( needsroot && EUID != 0 )); then
msg "Privilege escalation required" msg "Privilege escalation required"
if sudo -v &>/dev/null && sudo -l &>/dev/null; then if sudo -v &>/dev/null && sudo -l &>/dev/null; then
sudo "$@" sudo "$@"
@ -210,11 +210,6 @@ version() {
echo 'Copyright (C) 2011 Dave Reisner <dreisner@archlinux.org>' echo 'Copyright (C) 2011 Dave Reisner <dreisner@archlinux.org>'
} }
if (( ! UID )); then
error "Do not run this script as root. You will be prompted for privilege escalation."
exit 42
fi
OPT_SHORT=':a:c:dfhi:k:m:rsuVvz' OPT_SHORT=':a:c:dfhi:k:m:rsuVvz'
OPT_LONG=('arch:' 'cachedir:' 'dryrun' 'force' 'help' 'ignore:' 'keep:' 'move' OPT_LONG=('arch:' 'cachedir:' 'dryrun' 'force' 'help' 'ignore:' 'keep:' 'move'
'remove' 'uninstalled' 'version' 'verbose' 'null') 'remove' 'uninstalled' 'version' 'verbose' 'null')