Commit 5e90e4bd authored by Vitaly Lipatov's avatar Vitaly Lipatov

skip update checking for non root users have no nopassword sudo

parent 8ba99b83
...@@ -22,8 +22,7 @@ __is_repo_info_downloaded() ...@@ -22,8 +22,7 @@ __is_repo_info_downloaded()
case $PMTYPE in case $PMTYPE in
apt-*) apt-*)
if [ -r /var/cache/apt ] ; then if [ -r /var/cache/apt ] ; then
# FIXME: only if root permissions, now skip for user $SUDO test -r /var/cache/apt/pkgcache.bin || return
test -r /var/cache/apt/pkgcache.bin || return
fi fi
;; ;;
*) *)
...@@ -38,7 +37,6 @@ __is_repo_info_uptodate() ...@@ -38,7 +37,6 @@ __is_repo_info_uptodate()
apt-*) apt-*)
if $SUDO [ -r /var/lib/apt/lists ] ; then if $SUDO [ -r /var/lib/apt/lists ] ; then
local LOCKFILE=/var/lib/apt/lists/lock local LOCKFILE=/var/lib/apt/lists/lock
# FIXME: only if root permissions, now skip for user
$SUDO test -r $LOCKFILE || return $SUDO test -r $LOCKFILE || return
# if repo older than 1 day, return false # if repo older than 1 day, return false
# find print string if file is obsoleted # find print string if file is obsoleted
...@@ -53,6 +51,12 @@ __is_repo_info_uptodate() ...@@ -53,6 +51,12 @@ __is_repo_info_uptodate()
update_repo_if_needed() update_repo_if_needed()
{ {
# check if we need skip update checking
if [ "$1" = "soft" ] && [ -n "$SUDO" ] ; then
# if sudo requires a password, skip autoupdate
sudo -n true 2>/dev/null || { info "sudo requires a password, skip repo status checking" ; return 0 ; }
fi
if ! __is_repo_info_downloaded || ! __is_repo_info_uptodate ; then if ! __is_repo_info_downloaded || ! __is_repo_info_uptodate ; then
load_helper epm-update load_helper epm-update
epm_update epm_update
......
...@@ -155,7 +155,7 @@ epm_search() ...@@ -155,7 +155,7 @@ epm_search()
[ -n "$pkg_filenames" ] || fatal "Search: missing search argument(s)" [ -n "$pkg_filenames" ] || fatal "Search: missing search argument(s)"
# it is useful for first time running # it is useful for first time running
update_repo_if_needed update_repo_if_needed soft
# FIXME: do it better # FIXME: do it better
local MGS local MGS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment