Bug 1569893 - Privileged-access requiring aliases fail when executed as sudo-user.
Summary: Privileged-access requiring aliases fail when executed as sudo-user.
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: 28
Hardware: x86_64
OS: Linux
unspecified
low
Target Milestone: ---
Assignee: Siteshwar Vashisht
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-04-20 08:08 UTC by ricky.tigg
Modified: 2018-04-20 12:25 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-04-20 08:37:39 UTC
Type: Bug


Attachments (Terms of Use)

Description ricky.tigg 2018-04-20 08:08:15 UTC
Description of problem: privileged-access requiring aliases fail when executed as sudo-user.

Version-Release number of component: bash.x86_64 4.4.19-2.fc28 @fedora

Steps to Reproduce in terminal as sudo-user:
1. Edit hidden bashrc file, 'gedit ~/.bashrc', then add on their own lines '# Remove packages', 'alias remo='dnf -y remove''. Quit terminal.
2. $ su -c 'remo dnfdragora'
Password: (for root)
bash: remo: command not found
3. $ sudo remo dnfdragora
[sudo] password for yk: 
sudo: remo: command not found

Actual results: The use of privileged-access requiring aliases fail when subsequent commands are executed as sudo-user.
Expected results: Such aliases to be excecutable as sudo-user as well.

Comment 1 Kamil Dudka 2018-04-20 08:37:39 UTC
Aliases are expanded on the begin of your command line only.  So if your command line starts with 'su' or 'sudo' and none of them is an alias, no other aliases are expanded.  bash probably does not support what you are looking for but you can try zsh, which supports global aliases:

% alias -g remo='dnf -y remove'
% sudo remo ...

Global aliases expand anywhere on the command line.  Please use it with care.

Comment 2 ricky.tigg 2018-04-20 11:44:25 UTC
Existing entry is replaced by '% alias -g remo='dnf -y remove''. Messages resulting from implementation are:

– 'bash: fg: no job control' (displayed when opening the terminal).
– $ source ~/.bashrc
bash: fg: %: no such job

Comment 3 Kamil Dudka 2018-04-20 12:11:05 UTC
Please re-read comment #1.  The command to define global alias will not work in bash.  I was talking about zsh (another shell interpreter).  Moreover, the '%' sign was not supposed to be typed at all.  It just denotes the command prompt ('%' is the default prompt in zsh, similar to '$' in bash).

Comment 4 ricky.tigg 2018-04-20 12:25:13 UTC
Since comment #3 completed comment #1, solution is clear enough. Thanks


Note You need to log in before you can comment on or make changes to this bug.