Ce problème me préoccupe depuis un certain temps déjà.
De temps en temps, j'ai besoin d'écrire un fichier script qui doit exécuter sudo
des commandes. Je ne sais pas nécessairement à l'avance que je vais m'exécuter en tant que sudo
Je suis donc sûr qu'il existe un moyen d'ouvrir une interface graphique agréable (comme celle qui apparaît lors de l'installation d'un logiciel), mais comment ?
Le site man sudo
dit :
-A Normally, if sudo requires a password, it will read it from the current terminal. If the -A (askpass) option is specified, a (possibly
graphical) helper program is executed to read the user's password and output the password to the standard output. If the SUDO_ASKPASS
environment variable is set, it specifies the path to the helper program. Otherwise, the value specified by the askpass option in
sudoers(5) is used
Donc je suis presque sûr que la solution réside dans ce -A
y SUDO_ASKPASS
tuple mais j'ai réussi à trouver ce qu'il faut y mettre.