change update user password on mysql

This commit is contained in:
Jorge Pastor 2023-09-19 13:54:56 +02:00 committed by pedro
parent 38a671a18a
commit 465862e444
1 changed files with 6 additions and 14 deletions

View File

@ -89,20 +89,12 @@ class MySQLUserController(ServiceController):
if user.type != user.MYSQL: if user.type != user.MYSQL:
return return
context = self.get_context(user) context = self.get_context(user)
if user.target_server.name != "mysql.pangea.lan":
self.append(textwrap.dedent("""\ self.append(textwrap.dedent("""\
# Create user %(username)s # Create user %(username)s
mysql -e 'CREATE USER IF NOT EXISTS "%(username)s"@"%(host)s";' mysql -e 'CREATE USER IF NOT EXISTS "%(username)s"@"%(host)s";'
mysql -e 'ALTER USER IF EXISTS "%(username)s"@"%(host)s" IDENTIFIED BY PASSWORD "%(password)s";'\ mysql -e 'ALTER USER IF EXISTS "%(username)s"@"%(host)s" IDENTIFIED BY PASSWORD "%(password)s";'\
""") % context """) % context
) )
else:
self.append(textwrap.dedent("""\
# Create user %(username)s
mysql -e 'CREATE USER "%(username)s"@"%(host)s";' || true # User already exists
mysql -e 'UPDATE mysql.user SET Password="%(password)s" WHERE User="%(username)s";'\
""") % context
)
def delete(self, user): def delete(self, user):
if user.type != user.MYSQL: if user.type != user.MYSQL: