[skip ci] rename makeUserSudoerWithoutPasswordRequired
This commit is contained in:
parent
10a750fbf9
commit
482280574b
2 changed files with 7 additions and 7 deletions
|
@ -7,7 +7,7 @@ import org.domaindrivenarchitecture.provs.framework.core.local
|
|||
import org.domaindrivenarchitecture.provs.framework.core.remote
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.secret.secretSources.PromptSecretSource
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.user.base.currentUserCanSudoWithoutPassword
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.user.base.makeUserSudoerWithNoSudoPasswordRequired
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.user.base.makeUserSudoerWithoutPasswordRequired
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.user.base.whoami
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
|
@ -50,7 +50,7 @@ private fun createLocalProvInstance(): Prov {
|
|||
"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)
|
||||
prov.makeUserSudoerWithoutPasswordRequired(password)
|
||||
}
|
||||
return prov
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ private fun createRemoteProvInstance(
|
|||
require(
|
||||
password != null,
|
||||
{ "User ${prov.whoami()} not able to sudo on remote machine without password and no password available for the user." })
|
||||
prov.makeUserSudoerWithNoSudoPasswordRequired(password)
|
||||
prov.makeUserSudoerWithoutPasswordRequired(password)
|
||||
|
||||
// a new session is required after making the user a sudoer without password
|
||||
return remote(host, remoteUser, password)
|
||||
|
|
|
@ -33,7 +33,7 @@ fun Prov.createUser(
|
|||
}
|
||||
password?.let { cmdNoLog("sudo echo \"$userName:${password.plain()}\" | sudo chpasswd") } ?: ProvResult(true)
|
||||
if (userCanSudoWithoutPassword) {
|
||||
makeUserSudoerWithNoSudoPasswordRequired(userName)
|
||||
makeUserSudoerWithoutPasswordRequired(userName)
|
||||
}
|
||||
val authorizedKeysFile = userHome() + ".ssh/authorized_keys"
|
||||
if (copyAuthorizedSshKeysFromCurrentUser && checkFile(authorizedKeysFile)) {
|
||||
|
@ -85,7 +85,7 @@ fun Prov.deleteUser(userName: String, deleteHomeDir: Boolean = false): ProvResul
|
|||
* The current (executing) user must already be a sudoer. If he is a sudoer with password required then
|
||||
* his password must be provided.
|
||||
*/
|
||||
fun Prov.makeUserSudoerWithNoSudoPasswordRequired(
|
||||
fun Prov.makeUserSudoerWithoutPasswordRequired(
|
||||
userName: String,
|
||||
password: Secret? = null,
|
||||
overwriteFile: Boolean = false
|
||||
|
@ -108,10 +108,10 @@ fun Prov.makeUserSudoerWithNoSudoPasswordRequired(
|
|||
* IMPORTANT: Current user must already by sudoer when calling this function.
|
||||
*/
|
||||
@Suppress("unused") // used externally
|
||||
fun Prov.makeUserSudoerWithNoSudoPasswordRequired(password: Secret) = task {
|
||||
fun Prov.makeUserSudoerWithoutPasswordRequired(password: Secret) = task {
|
||||
val currentUser = whoami()
|
||||
if (currentUser != null) {
|
||||
makeUserSudoerWithNoSudoPasswordRequired(currentUser, password, overwriteFile = true)
|
||||
makeUserSudoerWithoutPasswordRequired(currentUser, password, overwriteFile = true)
|
||||
} else {
|
||||
ProvResult(false, "Current user could not be determined.")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue