From 4a3d7473fdc8d7c090c93d04c7bc3defc83147d3 Mon Sep 17 00:00:00 2001 From: Devin Christensen Date: Tue, 25 Nov 2014 10:44:04 -0700 Subject: [PATCH 1/3] Fix syntax error --- database/postgresql/postgresql_user.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/postgresql/postgresql_user.py b/database/postgresql/postgresql_user.py index 0823bd7cd90..7839669cb1a 100644 --- a/database/postgresql/postgresql_user.py +++ b/database/postgresql/postgresql_user.py @@ -402,7 +402,7 @@ def parse_role_attrs(role_attr_flags): flag_set = frozenset(r.upper() for r in role_attr_flags.split(",")) else: flag_set = frozenset(role_attr_flags.upper()) - if not flag_set.is_subset(VALID_FLAGS): + if not flag_set.issubset(VALID_FLAGS): raise InvalidFlagsError('Invalid role_attr_flags specified: %s' % ' '.join(flag_set.difference(VALID_FLAGS))) o_flags = ' '.join(flag_set) From c77ab67274600aff72b0d10eebcd5b7b8c32b0c5 Mon Sep 17 00:00:00 2001 From: Devin Christensen Date: Tue, 25 Nov 2014 11:46:41 -0700 Subject: [PATCH 2/3] Fix user_add in postgresql_user --- database/postgresql/postgresql_user.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/postgresql/postgresql_user.py b/database/postgresql/postgresql_user.py index 7839669cb1a..d7cca2fcd68 100644 --- a/database/postgresql/postgresql_user.py +++ b/database/postgresql/postgresql_user.py @@ -191,7 +191,7 @@ def user_add(cursor, user, password, role_attr_flags, encrypted, expires): query.append("PASSWORD %(password)s") if expires is not None: query.append("VALID UNTIL %(expires)s") - query = query.append(role_attr_flags) + query.append(role_attr_flags) query = ' '.join(query) cursor.execute(query, query_password_data) return True From 06f1c1a97ec40aa78b0d413819ec6514f5c3ff88 Mon Sep 17 00:00:00 2001 From: Devin Christensen Date: Tue, 25 Nov 2014 12:04:47 -0700 Subject: [PATCH 3/3] Fix user_alter in postgresql_user --- database/postgresql/postgresql_user.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/postgresql/postgresql_user.py b/database/postgresql/postgresql_user.py index d7cca2fcd68..421831e8165 100644 --- a/database/postgresql/postgresql_user.py +++ b/database/postgresql/postgresql_user.py @@ -218,7 +218,7 @@ def user_alter(cursor, module, user, password, role_attr_flags, encrypted, expir # Grab current role attributes. current_role_attrs = cursor.fetchone() - alter = ['ALTER USER "%(user)s"' % {"user": pg_quote_identifier(user, 'role')}] + alter = ['ALTER USER %(user)s' % {"user": pg_quote_identifier(user, 'role')}] if password is not None: alter.append("WITH %(crypt)s" % {"crypt": encrypted}) alter.append("PASSWORD %(password)s") @@ -229,7 +229,7 @@ def user_alter(cursor, module, user, password, role_attr_flags, encrypted, expir alter.append("VALID UNTIL %(expires)s") try: - cursor.execute(alter, query_password_data) + cursor.execute(' '.join(alter), query_password_data) except psycopg2.InternalError, e: if e.pgcode == '25006': # Handle errors due to read-only transactions indicated by pgcode 25006