Disable prompt for authentication on autocompletion of a command which needs root privileges
Clash Royale CLAN TAG#URR8PPP
up vote
4
down vote
favorite
When I use e.g. firewall-cmd, which correctly needs root privileges to execute, I get prompted in a window (so not in the terminal as with sudo) to give my password when I try to autocomplete an option (e.g. write "--perm" and hit TAB). This happens every time I use autocompletion, even if I already entered my password before and/or ran a command with sudo (which is configured to not prompt me a second time for a certain time).
Is there any way to either make entering the password permanent for a certain time or complete disable authentication for mere autocompletion (I still want authentication for actually running the program)?
The obvious solution is to login as root (use su or sudo -i), but I'd like to avoid doing that.
I am using bash and my .bashrc
sources the standard bash_completion
file shipped with the bash-completion
package in Debian.
I can reproduce this with just . /etc/bash_completion
in my .bashrc
.
Running complete -p firewall-cmd
results inbash: complete: firewall-cmd: no completion specification
The reason I thought polkit was involved (see original tags) is, that when I abort the authentication dialogue I get the following on stdout:
Authorization failed.
Make sure polkit agent is running or run the application as superuser.
bash sudo autocomplete
add a comment |Â
up vote
4
down vote
favorite
When I use e.g. firewall-cmd, which correctly needs root privileges to execute, I get prompted in a window (so not in the terminal as with sudo) to give my password when I try to autocomplete an option (e.g. write "--perm" and hit TAB). This happens every time I use autocompletion, even if I already entered my password before and/or ran a command with sudo (which is configured to not prompt me a second time for a certain time).
Is there any way to either make entering the password permanent for a certain time or complete disable authentication for mere autocompletion (I still want authentication for actually running the program)?
The obvious solution is to login as root (use su or sudo -i), but I'd like to avoid doing that.
I am using bash and my .bashrc
sources the standard bash_completion
file shipped with the bash-completion
package in Debian.
I can reproduce this with just . /etc/bash_completion
in my .bashrc
.
Running complete -p firewall-cmd
results inbash: complete: firewall-cmd: no completion specification
The reason I thought polkit was involved (see original tags) is, that when I abort the authentication dialogue I get the following on stdout:
Authorization failed.
Make sure polkit agent is running or run the application as superuser.
bash sudo autocomplete
What shell do you use and how is completion configured? The shell is probably invoking the command to list possible completions, but it's weird that it would run sudo. Do you have an alias or function?
â Gilles
Nov 6 '16 at 20:54
@Gilles I am using bash and my .bashrc sources the standard "bash_completion" file shipped with the bash-completion package in debian (upstream is github.com/scop/bash-completion). I didn't think of that: Does the shell have to invoke the actual command for autocompletion? In that case it is clear why I am asked to authenticate (the executable in question needs root privs), but still not clear why entering the password once is not cached for some time.
â imsodin
Nov 6 '16 at 21:55
The shell doesn't have to invoke the actual command, but it sometimes does. For example it might invoke the command with--help
and parse the output to get the exact list of supported options on that particular version of the command. I don't see anything specific tofirewall-cmd
in the bash_completion code. Can you reproduce this if your.bashrc
contains nothing apart from. /etc/bash_completion
? If not, post your.bashrc
.
â Gilles
Nov 6 '16 at 22:14
@Gilles, icarus: I added this information to the question. Thanks for looking into this!
â imsodin
Nov 6 '16 at 23:05
add a comment |Â
up vote
4
down vote
favorite
up vote
4
down vote
favorite
When I use e.g. firewall-cmd, which correctly needs root privileges to execute, I get prompted in a window (so not in the terminal as with sudo) to give my password when I try to autocomplete an option (e.g. write "--perm" and hit TAB). This happens every time I use autocompletion, even if I already entered my password before and/or ran a command with sudo (which is configured to not prompt me a second time for a certain time).
Is there any way to either make entering the password permanent for a certain time or complete disable authentication for mere autocompletion (I still want authentication for actually running the program)?
The obvious solution is to login as root (use su or sudo -i), but I'd like to avoid doing that.
I am using bash and my .bashrc
sources the standard bash_completion
file shipped with the bash-completion
package in Debian.
I can reproduce this with just . /etc/bash_completion
in my .bashrc
.
Running complete -p firewall-cmd
results inbash: complete: firewall-cmd: no completion specification
The reason I thought polkit was involved (see original tags) is, that when I abort the authentication dialogue I get the following on stdout:
Authorization failed.
Make sure polkit agent is running or run the application as superuser.
bash sudo autocomplete
When I use e.g. firewall-cmd, which correctly needs root privileges to execute, I get prompted in a window (so not in the terminal as with sudo) to give my password when I try to autocomplete an option (e.g. write "--perm" and hit TAB). This happens every time I use autocompletion, even if I already entered my password before and/or ran a command with sudo (which is configured to not prompt me a second time for a certain time).
Is there any way to either make entering the password permanent for a certain time or complete disable authentication for mere autocompletion (I still want authentication for actually running the program)?
The obvious solution is to login as root (use su or sudo -i), but I'd like to avoid doing that.
I am using bash and my .bashrc
sources the standard bash_completion
file shipped with the bash-completion
package in Debian.
I can reproduce this with just . /etc/bash_completion
in my .bashrc
.
Running complete -p firewall-cmd
results inbash: complete: firewall-cmd: no completion specification
The reason I thought polkit was involved (see original tags) is, that when I abort the authentication dialogue I get the following on stdout:
Authorization failed.
Make sure polkit agent is running or run the application as superuser.
bash sudo autocomplete
bash sudo autocomplete
edited Sep 15 at 16:33
Jeff Schaller
33.1k849111
33.1k849111
asked Nov 6 '16 at 19:01
imsodin
1786
1786
What shell do you use and how is completion configured? The shell is probably invoking the command to list possible completions, but it's weird that it would run sudo. Do you have an alias or function?
â Gilles
Nov 6 '16 at 20:54
@Gilles I am using bash and my .bashrc sources the standard "bash_completion" file shipped with the bash-completion package in debian (upstream is github.com/scop/bash-completion). I didn't think of that: Does the shell have to invoke the actual command for autocompletion? In that case it is clear why I am asked to authenticate (the executable in question needs root privs), but still not clear why entering the password once is not cached for some time.
â imsodin
Nov 6 '16 at 21:55
The shell doesn't have to invoke the actual command, but it sometimes does. For example it might invoke the command with--help
and parse the output to get the exact list of supported options on that particular version of the command. I don't see anything specific tofirewall-cmd
in the bash_completion code. Can you reproduce this if your.bashrc
contains nothing apart from. /etc/bash_completion
? If not, post your.bashrc
.
â Gilles
Nov 6 '16 at 22:14
@Gilles, icarus: I added this information to the question. Thanks for looking into this!
â imsodin
Nov 6 '16 at 23:05
add a comment |Â
What shell do you use and how is completion configured? The shell is probably invoking the command to list possible completions, but it's weird that it would run sudo. Do you have an alias or function?
â Gilles
Nov 6 '16 at 20:54
@Gilles I am using bash and my .bashrc sources the standard "bash_completion" file shipped with the bash-completion package in debian (upstream is github.com/scop/bash-completion). I didn't think of that: Does the shell have to invoke the actual command for autocompletion? In that case it is clear why I am asked to authenticate (the executable in question needs root privs), but still not clear why entering the password once is not cached for some time.
â imsodin
Nov 6 '16 at 21:55
The shell doesn't have to invoke the actual command, but it sometimes does. For example it might invoke the command with--help
and parse the output to get the exact list of supported options on that particular version of the command. I don't see anything specific tofirewall-cmd
in the bash_completion code. Can you reproduce this if your.bashrc
contains nothing apart from. /etc/bash_completion
? If not, post your.bashrc
.
â Gilles
Nov 6 '16 at 22:14
@Gilles, icarus: I added this information to the question. Thanks for looking into this!
â imsodin
Nov 6 '16 at 23:05
What shell do you use and how is completion configured? The shell is probably invoking the command to list possible completions, but it's weird that it would run sudo. Do you have an alias or function?
â Gilles
Nov 6 '16 at 20:54
What shell do you use and how is completion configured? The shell is probably invoking the command to list possible completions, but it's weird that it would run sudo. Do you have an alias or function?
â Gilles
Nov 6 '16 at 20:54
@Gilles I am using bash and my .bashrc sources the standard "bash_completion" file shipped with the bash-completion package in debian (upstream is github.com/scop/bash-completion). I didn't think of that: Does the shell have to invoke the actual command for autocompletion? In that case it is clear why I am asked to authenticate (the executable in question needs root privs), but still not clear why entering the password once is not cached for some time.
â imsodin
Nov 6 '16 at 21:55
@Gilles I am using bash and my .bashrc sources the standard "bash_completion" file shipped with the bash-completion package in debian (upstream is github.com/scop/bash-completion). I didn't think of that: Does the shell have to invoke the actual command for autocompletion? In that case it is clear why I am asked to authenticate (the executable in question needs root privs), but still not clear why entering the password once is not cached for some time.
â imsodin
Nov 6 '16 at 21:55
The shell doesn't have to invoke the actual command, but it sometimes does. For example it might invoke the command with
--help
and parse the output to get the exact list of supported options on that particular version of the command. I don't see anything specific to firewall-cmd
in the bash_completion code. Can you reproduce this if your .bashrc
contains nothing apart from . /etc/bash_completion
? If not, post your .bashrc
.â Gilles
Nov 6 '16 at 22:14
The shell doesn't have to invoke the actual command, but it sometimes does. For example it might invoke the command with
--help
and parse the output to get the exact list of supported options on that particular version of the command. I don't see anything specific to firewall-cmd
in the bash_completion code. Can you reproduce this if your .bashrc
contains nothing apart from . /etc/bash_completion
? If not, post your .bashrc
.â Gilles
Nov 6 '16 at 22:14
@Gilles, icarus: I added this information to the question. Thanks for looking into this!
â imsodin
Nov 6 '16 at 23:05
@Gilles, icarus: I added this information to the question. Thanks for looking into this!
â imsodin
Nov 6 '16 at 23:05
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
4
down vote
accepted
Normally to see the completion associated with a command like firewall-cmd one would use complete -p firewall-cmd
and expect to see something like complete -F _firewall_cmd firewall-cmd
coming back. One would then examine the _firewall_cmd
function using type _firewall_cmd
.
The bash completion package for Debian uses a complete -D
command to set up a default completion function, which looks to see if there is a specific completion available the first time it is used, and if so loads it.
Therefore it is important to attempt completion once before looking to see how completion is set up.
For firewall-cmd
this
file defines the completion function which currently starts
_firewall_cmd()
{
local cur prev words cword split
_init_completion -s || return
firewall-cmd --state 1> /dev/null || return
The /usr/bin/firewall-cmd program itself is a python script, which ends up needing root privileges and asking for authentication. A call of firewall-cmd --state
returns true if the firewall is running. The intention of the completion code therefore seems to be to not do completion if the firewall isn't running. However it is written to need the privileges to see if the firewall is running, and this is causing the unwanted prompts.
Deleting the firwall-cmd --state 1> /dev/null || return
line from the completion function makes completion faster, not prompt for password, and other general goodness.
add a comment |Â
up vote
-2
down vote
You can use nopasswd option of sudo. Just add nopasswd option in suoders file for your user.
e.g. if your user name is imosdin, then modify entry in sudoers by executing command visduo
, and add/modify below mentioned entry.
imsodin ALL=(ALL) NOPASSWD: ALL
Now, system will allow imsodin user to execute any command via sudo without prompting for password.
I know about that option, but I don't want to give that kind of access. I want authentication including using my password to execute the program, I just don't want to be prompted to give the password whenever I use the autocompletion.
â imsodin
Nov 6 '16 at 19:24
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
Normally to see the completion associated with a command like firewall-cmd one would use complete -p firewall-cmd
and expect to see something like complete -F _firewall_cmd firewall-cmd
coming back. One would then examine the _firewall_cmd
function using type _firewall_cmd
.
The bash completion package for Debian uses a complete -D
command to set up a default completion function, which looks to see if there is a specific completion available the first time it is used, and if so loads it.
Therefore it is important to attempt completion once before looking to see how completion is set up.
For firewall-cmd
this
file defines the completion function which currently starts
_firewall_cmd()
{
local cur prev words cword split
_init_completion -s || return
firewall-cmd --state 1> /dev/null || return
The /usr/bin/firewall-cmd program itself is a python script, which ends up needing root privileges and asking for authentication. A call of firewall-cmd --state
returns true if the firewall is running. The intention of the completion code therefore seems to be to not do completion if the firewall isn't running. However it is written to need the privileges to see if the firewall is running, and this is causing the unwanted prompts.
Deleting the firwall-cmd --state 1> /dev/null || return
line from the completion function makes completion faster, not prompt for password, and other general goodness.
add a comment |Â
up vote
4
down vote
accepted
Normally to see the completion associated with a command like firewall-cmd one would use complete -p firewall-cmd
and expect to see something like complete -F _firewall_cmd firewall-cmd
coming back. One would then examine the _firewall_cmd
function using type _firewall_cmd
.
The bash completion package for Debian uses a complete -D
command to set up a default completion function, which looks to see if there is a specific completion available the first time it is used, and if so loads it.
Therefore it is important to attempt completion once before looking to see how completion is set up.
For firewall-cmd
this
file defines the completion function which currently starts
_firewall_cmd()
{
local cur prev words cword split
_init_completion -s || return
firewall-cmd --state 1> /dev/null || return
The /usr/bin/firewall-cmd program itself is a python script, which ends up needing root privileges and asking for authentication. A call of firewall-cmd --state
returns true if the firewall is running. The intention of the completion code therefore seems to be to not do completion if the firewall isn't running. However it is written to need the privileges to see if the firewall is running, and this is causing the unwanted prompts.
Deleting the firwall-cmd --state 1> /dev/null || return
line from the completion function makes completion faster, not prompt for password, and other general goodness.
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
Normally to see the completion associated with a command like firewall-cmd one would use complete -p firewall-cmd
and expect to see something like complete -F _firewall_cmd firewall-cmd
coming back. One would then examine the _firewall_cmd
function using type _firewall_cmd
.
The bash completion package for Debian uses a complete -D
command to set up a default completion function, which looks to see if there is a specific completion available the first time it is used, and if so loads it.
Therefore it is important to attempt completion once before looking to see how completion is set up.
For firewall-cmd
this
file defines the completion function which currently starts
_firewall_cmd()
{
local cur prev words cword split
_init_completion -s || return
firewall-cmd --state 1> /dev/null || return
The /usr/bin/firewall-cmd program itself is a python script, which ends up needing root privileges and asking for authentication. A call of firewall-cmd --state
returns true if the firewall is running. The intention of the completion code therefore seems to be to not do completion if the firewall isn't running. However it is written to need the privileges to see if the firewall is running, and this is causing the unwanted prompts.
Deleting the firwall-cmd --state 1> /dev/null || return
line from the completion function makes completion faster, not prompt for password, and other general goodness.
Normally to see the completion associated with a command like firewall-cmd one would use complete -p firewall-cmd
and expect to see something like complete -F _firewall_cmd firewall-cmd
coming back. One would then examine the _firewall_cmd
function using type _firewall_cmd
.
The bash completion package for Debian uses a complete -D
command to set up a default completion function, which looks to see if there is a specific completion available the first time it is used, and if so loads it.
Therefore it is important to attempt completion once before looking to see how completion is set up.
For firewall-cmd
this
file defines the completion function which currently starts
_firewall_cmd()
{
local cur prev words cword split
_init_completion -s || return
firewall-cmd --state 1> /dev/null || return
The /usr/bin/firewall-cmd program itself is a python script, which ends up needing root privileges and asking for authentication. A call of firewall-cmd --state
returns true if the firewall is running. The intention of the completion code therefore seems to be to not do completion if the firewall isn't running. However it is written to need the privileges to see if the firewall is running, and this is causing the unwanted prompts.
Deleting the firwall-cmd --state 1> /dev/null || return
line from the completion function makes completion faster, not prompt for password, and other general goodness.
edited Sep 16 at 22:35
answered Nov 12 '16 at 22:03
icarus
4,7981725
4,7981725
add a comment |Â
add a comment |Â
up vote
-2
down vote
You can use nopasswd option of sudo. Just add nopasswd option in suoders file for your user.
e.g. if your user name is imosdin, then modify entry in sudoers by executing command visduo
, and add/modify below mentioned entry.
imsodin ALL=(ALL) NOPASSWD: ALL
Now, system will allow imsodin user to execute any command via sudo without prompting for password.
I know about that option, but I don't want to give that kind of access. I want authentication including using my password to execute the program, I just don't want to be prompted to give the password whenever I use the autocompletion.
â imsodin
Nov 6 '16 at 19:24
add a comment |Â
up vote
-2
down vote
You can use nopasswd option of sudo. Just add nopasswd option in suoders file for your user.
e.g. if your user name is imosdin, then modify entry in sudoers by executing command visduo
, and add/modify below mentioned entry.
imsodin ALL=(ALL) NOPASSWD: ALL
Now, system will allow imsodin user to execute any command via sudo without prompting for password.
I know about that option, but I don't want to give that kind of access. I want authentication including using my password to execute the program, I just don't want to be prompted to give the password whenever I use the autocompletion.
â imsodin
Nov 6 '16 at 19:24
add a comment |Â
up vote
-2
down vote
up vote
-2
down vote
You can use nopasswd option of sudo. Just add nopasswd option in suoders file for your user.
e.g. if your user name is imosdin, then modify entry in sudoers by executing command visduo
, and add/modify below mentioned entry.
imsodin ALL=(ALL) NOPASSWD: ALL
Now, system will allow imsodin user to execute any command via sudo without prompting for password.
You can use nopasswd option of sudo. Just add nopasswd option in suoders file for your user.
e.g. if your user name is imosdin, then modify entry in sudoers by executing command visduo
, and add/modify below mentioned entry.
imsodin ALL=(ALL) NOPASSWD: ALL
Now, system will allow imsodin user to execute any command via sudo without prompting for password.
answered Nov 6 '16 at 19:14
sssdexp
1123
1123
I know about that option, but I don't want to give that kind of access. I want authentication including using my password to execute the program, I just don't want to be prompted to give the password whenever I use the autocompletion.
â imsodin
Nov 6 '16 at 19:24
add a comment |Â
I know about that option, but I don't want to give that kind of access. I want authentication including using my password to execute the program, I just don't want to be prompted to give the password whenever I use the autocompletion.
â imsodin
Nov 6 '16 at 19:24
I know about that option, but I don't want to give that kind of access. I want authentication including using my password to execute the program, I just don't want to be prompted to give the password whenever I use the autocompletion.
â imsodin
Nov 6 '16 at 19:24
I know about that option, but I don't want to give that kind of access. I want authentication including using my password to execute the program, I just don't want to be prompted to give the password whenever I use the autocompletion.
â imsodin
Nov 6 '16 at 19:24
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f321478%2fdisable-prompt-for-authentication-on-autocompletion-of-a-command-which-needs-roo%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
What shell do you use and how is completion configured? The shell is probably invoking the command to list possible completions, but it's weird that it would run sudo. Do you have an alias or function?
â Gilles
Nov 6 '16 at 20:54
@Gilles I am using bash and my .bashrc sources the standard "bash_completion" file shipped with the bash-completion package in debian (upstream is github.com/scop/bash-completion). I didn't think of that: Does the shell have to invoke the actual command for autocompletion? In that case it is clear why I am asked to authenticate (the executable in question needs root privs), but still not clear why entering the password once is not cached for some time.
â imsodin
Nov 6 '16 at 21:55
The shell doesn't have to invoke the actual command, but it sometimes does. For example it might invoke the command with
--help
and parse the output to get the exact list of supported options on that particular version of the command. I don't see anything specific tofirewall-cmd
in the bash_completion code. Can you reproduce this if your.bashrc
contains nothing apart from. /etc/bash_completion
? If not, post your.bashrc
.â Gilles
Nov 6 '16 at 22:14
@Gilles, icarus: I added this information to the question. Thanks for looking into this!
â imsodin
Nov 6 '16 at 23:05