From 482280574b54ca47a9d25e40f07b4ed998e0bbaf Mon Sep 17 00:00:00 2001 From: az Date: Sun, 26 Feb 2023 19:18:25 +0100 Subject: [PATCH] [skip ci] rename makeUserSudoerWithoutPasswordRequired --- .../provs/framework/core/cli/CliUtils.kt | 6 +++--- .../provs/framework/ubuntu/user/base/User.kt | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/cli/CliUtils.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/cli/CliUtils.kt index f8b3df9..f3be177 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/cli/CliUtils.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/cli/CliUtils.kt @@ -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) diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/user/base/User.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/user/base/User.kt index 5da27f4..cd5978b 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/user/base/User.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/user/base/User.kt @@ -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.") }