We need to develop a Python library and a tool that will handle password prompts in a GUI for sudo command execution using the SUDO_ASKPASS mechanism. The goal is to ensure the tool behaves like pkexec or gksu, but using sudo and honoring the sudoers configuration, including NOPASSWD rules.
Requirements
Python Library:
A library that:
Launches a GUI prompt to ask for the user's password.
Sets the SUDO_ASKPASS environment variable only within the Python session (it should not be visible outside of the session or to other processes).
Executes the sudo command using the SUDO_ASKPASS mechanism.
Supports sudo options such as -u (to specify user) and -i (to run as a login shell).
Ensures the password prompt respects the sudoers file, meaning it only asks for a password if required. If NOPASSWD is set, it should not prompt the user.
Tool:
A command-line tool that:
Acts similarly to pkexec or gksu, but uses sudo.
Checks if the user is in the sudoers file before prompting for a password.
Honors the NOPASSWD directive in sudoers (if set, no password prompt should be shown).
Supports common sudo options like:
-u: Execute the command as a different user.
-i: Execute the command as a login shell.
Deliverables
A Python library that can be integrated into other projects and codebases.
A standalone tool that behaves like pkexec/gksu but works with sudo.
Acceptance Criteria
Password is only prompted when required (i.e., if NOPASSWD is not set).
The tool checks sudoers for user permissions.
SUDO_ASKPASS is only visible within the Python session and not accessible from other processes.
Support for sudo options -u and -i in both the library and the tool.
Works correctly on systems with a properly configured sudoers file.
Description
We need to develop a Python library and a tool that will handle password prompts in a GUI for
sudo
command execution using theSUDO_ASKPASS
mechanism. The goal is to ensure the tool behaves likepkexec
orgksu
, but usingsudo
and honoring thesudoers
configuration, includingNOPASSWD
rules.Requirements
Python Library:
SUDO_ASKPASS
environment variable only within the Python session (it should not be visible outside of the session or to other processes).sudo
command using theSUDO_ASKPASS
mechanism.sudo
options such as-u
(to specify user) and-i
(to run as a login shell).sudoers
file, meaning it only asks for a password if required. IfNOPASSWD
is set, it should not prompt the user.Tool:
pkexec
orgksu
, but usessudo
.sudoers
file before prompting for a password.NOPASSWD
directive insudoers
(if set, no password prompt should be shown).sudo
options like:-u
: Execute the command as a different user.-i
: Execute the command as a login shell.Deliverables
pkexec
/gksu
but works withsudo
.Acceptance Criteria
NOPASSWD
is not set).sudoers
for user permissions.SUDO_ASKPASS
is only visible within the Python session and not accessible from other processes.sudo
options-u
and-i
in both the library and the tool.sudoers
file.