From 7ab295a76ba627ca3e8fd5e550595fb84b3506ed Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 27 Jan 2020 10:54:39 +0200 Subject: [PATCH] kiss: Run as root where needed --- kiss | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/kiss b/kiss index 2528e3d..47744b7 100755 --- a/kiss +++ b/kiss @@ -61,10 +61,10 @@ root_cache() { # Validate the password now with a simple 'true' command # as we don't yet need to elevate permissions. - root_run true + dosu true } -root_run() { +dosu() { # Run a command as root using the cached password. The 'su' # command allows you to input a password via stdin. To hide # the prompt, the command's output is sent to '/dev/tty' @@ -719,9 +719,9 @@ pkg_remove() { [ "${file##/etc/*}" ] || continue if [ -d "$KISS_ROOT/$file" ]; then - rmdir "$KISS_ROOT/$file" 2>/dev/null || continue + dosu rmdir "$KISS_ROOT/$file" 2>/dev/null || continue else - rm -f "$KISS_ROOT/$file" + dosu rm -f "$KISS_ROOT/$file" fi done < "$sys_db/$1/manifest" @@ -797,7 +797,7 @@ pkg_install() { # This is repeated multiple times. Better to make it a function. pkg_rsync() { - rsync --chown=root:root --chmod=Du-s,Dg-s,Do-s \ + dosu rsync --chown=root:root --chmod=Du-s,Dg-s,Do-s \ -WhHKa --no-compress "$1" --exclude /etc \ "$tar_dir/$pkg_name/" "$KISS_ROOT/" } @@ -808,7 +808,7 @@ pkg_install() { # If '/etc/' exists in the package, install it but don't overwrite. [ -d "$tar_dir/$pkg_name/etc" ] && - rsync --chown=root:root -WhHKa --no-compress --ignore-existing \ + dosu rsync --chown=root:root -WhHKa --no-compress --ignore-existing \ "$tar_dir/$pkg_name/etc" "$KISS_ROOT/" # Remove any leftover files if this is an upgrade. @@ -826,18 +826,18 @@ pkg_install() { # Remove files. if [ -f "$file" ] && [ ! -L "$file" ]; then - rm -f "$file" + dosu rm -f "$file" # Remove file symlinks. elif [ -L "$file" ] && [ ! -d "$file" ]; then - unlink "$file" ||: + dosu unlink "$file" ||: # Skip directory symlinks. elif [ -L "$file" ] && [ -d "$file" ]; then : # Remove directories if empty. elif [ -d "$file" ]; then - rmdir "$file" 2>/dev/null ||: + dosu rmdir "$file" 2>/dev/null ||: fi done ||: } @@ -853,7 +853,7 @@ pkg_install() { if [ -x "$sys_db/$pkg_name/post-install" ]; then log "$pkg_name" "Running post-install script" - "$sys_db/$pkg_name/post-install" ||: + dosu "$sys_db/$pkg_name/post-install" ||: fi log "$pkg_name" "Installed successfully" @@ -907,8 +907,8 @@ pkg_updates() { git fetch git merge else - root_run git fetch - root_run git merge + dosu git fetch + dosu git merge fi } done