You are not logged in.

#1 2014-08-10 20:12:50

DVNO
Member
Registered: 2014-08-10
Posts: 19

[SOLVED] alias with sudo: Password request malfunction

Okay so here are two cool little system-maintenance related aliases, as suggested by "pacman tips" Wiki:

Show dirs not owned by any package:

alias pacman-disowned-dirs="comm -23 <(sudo find / \( -path '/dev' -o -path '/sys' -o -path '/run' -o -path '/tmp' -o -path '/mnt' -o -path '/srv' -o -path '/proc' -o -path '/boot' -o -path '/home' -o -path '/root' -o -path '/media' -o -path '/var/lib/pacman' -o -path '/var/cache/pacman' \) -prune -o -type d -print | sed 's/\([^/]\)$/\1\//' | sort -u) <(pacman -Qlq | sort -u)"

Show files not owned by any package:

alias pacman-disowned-files="comm -23 <(sudo find / \( -path '/dev' -o -path '/sys' -o -path '/run' -o -path '/tmp' -o -path '/mnt' -o -path '/srv' -o -path '/proc' -o -path '/boot' -o -path '/home' -o -path '/root' -o -path '/media' -o -path '/var/lib/pacman' -o -path '/var/cache/pacman' \) -prune -o -type f -print | sort -u) <(pacman -Qlq | sort -u)"

typically I edit those into my "/etc/bash.bashrc" instead of "~/.bashrc", but there's no difference there. The thing is, when I invoke this alias,
as regular user, it promptly requests [sudo] password, as it should, but after a brief moment the console returns to normal, there's no time for to even input the password, like this:

[danilo@dandelion ~]$ pacman-disowned-dirs
[sudo] password for danilo: 
[danilo@dandelion ~]$ 

PS: If my password is still cached, it will work normally (my timeout is set to 30 min).

here's my "/etc/bash.bashrc" at any rate:

#
# /etc/bash.bashrc
#

## If not running interactively, don't do anything ##
# [[ $- != *i* ]] && return

## Prompt display configurations ##
set_prompt () {
    	local last_command=$?  # Must come first!
	PS1='\[\e[1;33m\]'
	
	if [[ $last_command != 0 ]]; then
		PS1+='$?'
	fi

	if [[ $EUID == 0 ]]; then
    		PS1+='\[\e[1;31m\][\u@\h \W]\$\[\e[0m\] '
	else
		PS1+='\[\e[1;34m\][\u@\h \W]\$\[\e[0m\] '
	fi
}
PROMPT_COMMAND='set_prompt'
PS2='> '
PS3='> '
PS4='+ '

## Original default configs ##
case ${TERM} in
  xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
    PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'

    ;;
  screen)
    PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033_%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
    ;;
esac

## File sourcing  ##
[ -r /usr/share/bash-completion/bash_completion   ] && . /usr/share/bash-completion/bash_completion

## Functions ## {{{



## }}}

## Aliases ## {{{

# Privileged access #
if [ $UID -ne 0 ]; then
    alias sudo='sudo '
    alias scat='sudo cat'
    alias svim='sudoedit'
    alias root='sudo -i'
    alias reboot='sudo systemctl reboot'
    alias poweroff='sudo systemctl poweroff'
    alias update='sudo pacman -Su'
    alias netctl='sudo netctl'
fi

# listing #
alias ls='ls -hF --color=auto'
alias lr='ls -R'                    # recursive ls
alias ll='ls -l'
alias lall='ls -la'
alias la='ll -A'
alias lx='ll -BX'                   # sort by extension
alias lz='ll -rS'                   # sort by size
alias lt='ll -rt'                   # sort by date
alias lm='la | more'


# Show dirs that do not belong to any package #
	alias pacman-disowned-dirs="comm -23 <(sudo find / \( -path '/dev' -o -path '/sys' -o -path '/run' -o -path '/tmp' -o -path '/mnt' -o -path '/srv' -o -path '/proc' -o -path '/boot' -o -path '/home' -o -path '/root' -o -path '/media' -o -path '/var/lib/pacman' -o -path '/var/cache/pacman' \) -prune -o -type d -print | sed 's/\([^/]\)$/\1\//' | sort -u) <(pacman -Qlq | sort -u)"

# Show files that do not belong to any package #
	alias pacman-disowned-files="comm -23 <(sudo find / \( -path '/dev' -o -path '/sys' -o -path '/run' -o -path '/tmp' -o -path '/mnt' -o -path '/srv' -o -path '/proc' -o -path '/boot' -o -path '/home' -o -path '/root' -o -path '/media' -o -path '/var/lib/pacman' -o -path '/var/cache/pacman' \) -prune -o -type f -print | sort -u) && <(pacman -Qlq | sort -u)"

## }}}

Last edited by DVNO (2014-08-12 05:12:57)

Offline

#2 2014-08-10 21:44:23

karkhaz
Member
Registered: 2014-01-25
Posts: 79

Re: [SOLVED] alias with sudo: Password request malfunction

Sorry if this is obvious, but did you try writing and executing the whole command directly on the shell instead of invoking the alias?

The second script doesn't actually work for me by the way. It terminates with "/dev/fd/63: Permission denied". Nevertheless, I don't get the same problem as you do.

Offline

#3 2014-08-10 22:01:50

DVNO
Member
Registered: 2014-08-10
Posts: 19

Re: [SOLVED] alias with sudo: Password request malfunction

You'd suppose it would work, but no, same error... Perhaps it traces back to some other configuration file...

By the way, the second command, I didn't paste it correctly; There's no "&&" before the pacman query part of the command. Fixing the post now...

Well, anyways, I believe I got'em working, I appended a useless command that requires elevation AND works properly, like this:

alias pacman-disowned-dirs="sudo true && comm -23 <(sudo find / \( -path '/dev' -o -path '/sys' -o -path '/run' -o -path '/tmp' -o -path '/mnt' -o -path '/srv' -o -path '/proc' -o -path '/boot' -o -path '/home' -o -path '/root' -o -path '/media' -o -path '/var/lib/pacman' -o -path '/var/cache/pacman' \) -prune -o -type d -print | sed 's/\([^/]\)$/\1\//' | sort -u) <(pacman -Qlq | sort -u)"

And:

alias pacman-disowned-files="sudo true && comm -23 <(sudo find / \( -path '/dev' -o -path '/sys' -o -path '/run' -o -path '/tmp' -o -path '/mnt' -o -path '/srv' -o -path '/proc' -o -path '/boot' -o -path '/home' -o -path '/root' -o -path '/media' -o -path '/var/lib/pacman' -o -path '/var/cache/pacman' \) -prune -o -type f -print | sort -u) <(pacman -Qlq | sort -u)"

...Still, it's a r@t workaround, not a proper solution, so I'll ask to not mark this as solved yet. Maybe someone can backtrack this properly.

Thank you, for the quick reply, much appreciated. big_smile

Offline

#4 2014-08-10 22:16:31

karkhaz
Member
Registered: 2014-01-25
Posts: 79

Re: [SOLVED] alias with sudo: Password request malfunction

You might try creating a new user and trying the alias there. Remove the alias from /etc/bash.bashrc and put it in the new user's ~/.bashrc... That way you're free of other configuration files that might be influencing the command. This is what I did, in fact, since I don't use bash and wanted a clean slate to work on.

The new script you posted didn't work for me either. The script gets suspended for some reason. Note that htop is telling me that several of the processes are suspended, and none of them are running...it's rather strange, I don't know why. (S means idle, T means suspended)

2014_08_10_231044_4480x2224_scrot.png

Offline

#5 2014-08-10 22:49:29

DVNO
Member
Registered: 2014-08-10
Posts: 19

Re: [SOLVED] alias with sudo: Password request malfunction

Hmmm, I see... The versions with the appended "sudo true..." at the beginning do work for me, though... We should have someone check the excerpt from the Wiki that makes mention of the aliases; But it's very weird indeed, the process being suspended and all...

I'll probably add a new user, as you suggested, and edit a clean "~/.bashrc". I'm also considering migrating to Z shell, as there is some particularities that I miss from it and are not present in the current bash...

Thanks for the attention, Mate big_smile.

Offline

Board footer

Powered by FluxBB