Read password from stdin

Add warning to password prompt.
This commit is contained in:
erik 2023-02-01 11:36:53 +01:00
parent b25729e910
commit 860dcb2fd8
2 changed files with 4 additions and 4 deletions

View file

@ -47,11 +47,12 @@ fun createProvInstance(
}
}
private fun createLocalProvInstance(): Prov {
val prov = local()
prov.cmd("sudo -K") // revoke any temporary sudo privileges
if (!prov.currentUserCanSudo()) {
val password = PromptSecretSource("Please enter password to configure sudo without password in the future.").secret()
val password = PromptSecretSource("Please enter password to configure sudo without password in the future." +
"\nWarning: This will permanently allow your user to use sudo privileges without a password.").secret()
prov.makeUserSudoerWithNoSudoPasswordRequired(password)
}
return prov

View file

@ -132,10 +132,9 @@ fun Prov.userIsInGroupSudo(userName: String): Boolean {
*/
@Suppress("unused")
fun Prov.currentUserCanSudo(): Boolean {
return chk("timeout 1 sudo id")
return chk("timeout 1 sudo -S id")
}
/**
* Returns username of current user if it can be determined
*/