From 1529ed262113c9b582a794430465acc4913e3fba Mon Sep 17 00:00:00 2001 From: Christoph Moench-Tegeder Date: Wed, 16 May 2018 22:21:10 +0200 Subject: [PATCH] postgres: remove all references to "CREATEUSER" role flag The CREATEUSER flag has been an alias of the SUPERUSER flag, but was already declared obsolete in PostgreSQL 8.1 (see the documentation https://www.postgresql.org/docs/8.1/static/sql-createrole.html for reference). PostgreSQL 8.1 has been EoLed in November 2010 ( https://www.postgresql.org/support/versioning/ ), which is a long time ago. In PostgreSQL 9.6 (released September 2016), support for the CREATEUSER keyword has finally been removed: https://www.postgresql.org/docs/current/static/release-9-6.html The state modules state.postgres_group and state.postgres_user use the "createuser" flag as an alias to the "createroles" flag (and their documentation notes that this use differs from the PostgreSQL usage of the flag of the same name). To add to the confusion, the execution module modules.postgresql uses the "createuser" flag to set the "superuser" flag if "superuser" is set to None. This patch removes all mentions of "createuser" from the state and execution module and from associated tests (docstrings have been fixed, too). This should reduce confusion by a fair amount and brings the Saltstack interface to PostgreSQL's own terms. --- salt/modules/postgres.py | 15 --------------- salt/states/postgres_group.py | 7 ------- salt/states/postgres_user.py | 6 ------ tests/unit/modules/test_postgres.py | 7 ------- 4 files changed, 35 deletions(-) diff --git a/salt/modules/postgres.py b/salt/modules/postgres.py index 36969b5154..a300e1b1d8 100644 --- a/salt/modules/postgres.py +++ b/salt/modules/postgres.py @@ -995,7 +995,6 @@ def _role_cmd_args(name, connlimit=None, inherit=None, createdb=None, - createuser=None, createroles=None, superuser=None, groups=None, @@ -1003,8 +1002,6 @@ def _role_cmd_args(name, rolepassword=None, valid_until=None, db_role=None): - if createuser is not None and superuser is None: - superuser = createuser if inherit is None: if typ_ in ['user', 'group']: inherit = True @@ -1088,7 +1085,6 @@ def _role_create(name, password=None, createdb=None, createroles=None, - createuser=None, encrypted=None, superuser=None, login=None, @@ -1121,7 +1117,6 @@ def _role_create(name, inherit=inherit, createdb=createdb, createroles=createroles, - createuser=createuser, superuser=superuser, groups=groups, replication=replication, @@ -1143,7 +1138,6 @@ def user_create(username, maintenance_db=None, password=None, createdb=None, - createuser=None, createroles=None, inherit=None, login=None, @@ -1174,7 +1168,6 @@ def user_create(username, maintenance_db=maintenance_db, password=password, createdb=createdb, - createuser=createuser, createroles=createroles, inherit=inherit, login=login, @@ -1195,7 +1188,6 @@ def _role_update(name, maintenance_db=None, password=None, createdb=None, - createuser=None, typ_='role', createroles=None, inherit=None, @@ -1235,7 +1227,6 @@ def _role_update(name, connlimit=connlimit, inherit=inherit, createdb=createdb, - createuser=createuser, createroles=createroles, superuser=superuser, groups=groups, @@ -1259,7 +1250,6 @@ def user_update(username, maintenance_db=None, password=None, createdb=None, - createuser=None, createroles=None, encrypted=None, superuser=None, @@ -1293,7 +1283,6 @@ def user_update(username, login=login, connlimit=connlimit, createdb=createdb, - createuser=createuser, createroles=createroles, encrypted=encrypted, superuser=superuser, @@ -1740,7 +1729,6 @@ def group_create(groupname, maintenance_db=None, password=None, createdb=None, - createuser=None, createroles=None, encrypted=None, login=None, @@ -1771,7 +1759,6 @@ def group_create(groupname, password=password, createdb=createdb, createroles=createroles, - createuser=createuser, encrypted=encrypted, login=login, inherit=inherit, @@ -1790,7 +1777,6 @@ def group_update(groupname, password=None, createdb=None, createroles=None, - createuser=None, encrypted=None, inherit=None, login=None, @@ -1819,7 +1805,6 @@ def group_update(groupname, createdb=createdb, typ_='group', createroles=createroles, - createuser=createuser, encrypted=encrypted, login=login, inherit=inherit, diff --git a/salt/states/postgres_group.py b/salt/states/postgres_group.py index d0db38b0b3..77ab9424ac 100644 --- a/salt/states/postgres_group.py +++ b/salt/states/postgres_group.py @@ -36,7 +36,6 @@ def __virtual__(): def present(name, createdb=None, createroles=None, - createuser=None, encrypted=None, superuser=None, inherit=None, @@ -66,10 +65,6 @@ def present(name, createroles Is the group allowed to create other roles/users - createuser - Alias to create roles, and history problem, in pgsql normally - createuser == superuser - encrypted Should the password be encrypted in the system catalog? @@ -131,8 +126,6 @@ def present(name, 'result': True, 'comment': 'Group {0} is already present'.format(name)} - if createuser: - createroles = True # default to encrypted passwords if encrypted is not False: encrypted = postgres._DEFAULT_PASSWORDS_ENCRYPTION diff --git a/salt/states/postgres_user.py b/salt/states/postgres_user.py index c93b39b954..f1eadab30d 100644 --- a/salt/states/postgres_user.py +++ b/salt/states/postgres_user.py @@ -37,7 +37,6 @@ def __virtual__(): def present(name, createdb=None, createroles=None, - createuser=None, encrypted=None, superuser=None, replication=None, @@ -69,9 +68,6 @@ def present(name, createroles Is the user allowed to create other users? - createuser - Alias to create roles - encrypted Should the password be encrypted in the system catalog? @@ -142,8 +138,6 @@ def present(name, 'result': True, 'comment': 'User {0} is already present'.format(name)} - if createuser: - createroles = True # default to encrypted passwords if encrypted is not False: encrypted = postgres._DEFAULT_PASSWORDS_ENCRYPTION diff --git a/tests/unit/modules/test_postgres.py b/tests/unit/modules/test_postgres.py index 7094767d0f..3aac392218 100644 --- a/tests/unit/modules/test_postgres.py +++ b/tests/unit/modules/test_postgres.py @@ -249,7 +249,6 @@ class PostgresTestCase(TestCase, LoaderModuleMockMixin): maintenance_db='maint_db', password='foo', createdb=False, - createuser=False, encrypted=False, superuser=False, replication=False, @@ -299,7 +298,6 @@ class PostgresTestCase(TestCase, LoaderModuleMockMixin): maintenance_db='maint_db', password='foo', createdb=False, - createuser=False, encrypted=False, replication=False, rolepassword='test_role_pass', @@ -331,7 +329,6 @@ class PostgresTestCase(TestCase, LoaderModuleMockMixin): login=True, createdb=False, createroles=False, - createuser=False, encrypted=False, superuser=False, replication=False, @@ -466,7 +463,6 @@ class PostgresTestCase(TestCase, LoaderModuleMockMixin): password='test_pass', createdb=False, createroles=False, - createuser=False, encrypted=False, inherit=True, login=True, @@ -505,7 +501,6 @@ class PostgresTestCase(TestCase, LoaderModuleMockMixin): password='test_pass', createdb=False, createroles=True, - createuser=False, encrypted=False, inherit=True, login=True, @@ -540,7 +535,6 @@ class PostgresTestCase(TestCase, LoaderModuleMockMixin): password='test_pass', createdb=False, createroles=True, - createuser=False, encrypted=False, inherit=True, login=True, @@ -576,7 +570,6 @@ class PostgresTestCase(TestCase, LoaderModuleMockMixin): password='test_pass', createdb=False, createroles=True, - createuser=False, encrypted=True, inherit=True, login=True,