Commit Graph

40 Commits (ca047c3881128e5163d380080dc44964ed4d90ab)

Author SHA1 Message Date
John R Barker 5945b19ad3 double quotes for consistency 2016-12-08 11:25:29 -05:00
John R Barker 1d00dd80f1 Need to quote if there is a `:` 2016-12-08 11:25:29 -05:00
Sam Doran 6d06f80097 Change examples syntax on postgresql_user module 2016-12-08 11:25:28 -05:00
Sam Doran 13c827a31c Change examples syntax on postgresql_privs module 2016-12-08 11:25:28 -05:00
Sam Doran 8edd2673b2 > Change examples syntax on postgresql_db module 2016-12-08 11:25:28 -05:00
Michael Scherer 5e1dfa9485 Do not leak the password in log (#5189) 2016-12-08 11:25:20 -05:00
Michael Scherer 996ccca82f Do not leak various passwords in log (#5202) 2016-12-08 11:25:20 -05:00
Marius Gedminas 9509224768 postgresql_db: fix inverted 'changed' logic when state=absent (#4934)
Fixes #4933.
2016-12-08 11:25:12 -05:00
Michael Scherer f59af7d29e Port postgresql module to python3 (#4579)
Iteritems is no longer a dict method in Python3, replace it with
the six wrapper.
2016-12-08 11:24:56 -05:00
Michael Scherer 09066f1518 Convert all databases modules to python3 and 2.4 syntax (#3688) 2016-12-08 11:24:29 -05:00
Toshio Kuratomi f6aa1ff9a4 Remove duplicate documentation fields 2016-12-08 11:24:01 -05:00
Greg DeKoenigsberg 742b452dc1 @lorin stepping down as maintainer 2016-12-08 11:23:45 -05:00
Will Thames e5d96dc934 Correct handling of empty role_attr_flags
role_attr_flags is the empty string by default, not None.
2016-12-08 11:23:24 -05:00
ToBeReplaced 5e259a8dd9 Make ALL_IN_SCHEMA for tables affect views
ALL TABLES is considered to include views, so we must check for reltypes
'r' and 'v', not just 'r'. This bug was introduced due to using a
custom, backwards-compatible version of "ALL TABLES IN SCHEMA".
2016-12-08 11:23:15 -05:00
Greg DeKoenigsberg eb881d7d5d Proper author info for all remaining modules 2016-12-08 11:23:07 -05:00
Toshio Kuratomi fa60891f68 Fix a problem introduced with #1101 and optimize privilege handling
* If a db user belonged to a role which had a privilege, the user would
  not have the privilege added as the role gave the appearance that the
  user already had it.  Fixed to always check the privileges specific to
  the user.
* Make fewer db queries to determine if privileges need to be changed
  and change them (was four for each privilege.  Now two for each object
  that has a set of privileges changed).
2016-12-08 11:23:03 -05:00
Will Thames 34e0e17090 Perform privilege grants/revokes only when required
Use `has_table_privileges` and `has_database_privileges`
to test whether a user already has a privilege before
granting it, or whether a user doesn't have  a privilege
before revoking it.
2016-12-08 11:23:03 -05:00
Toshio Kuratomi 5c96c5c9c2 Fix splitting of role_attrs 2016-12-08 11:23:00 -05:00
Will Thames 9aff204f63 Usage is not a valid database or table privilege
Remove `USAGE` from the `VALID_PRIVS` dict for both database and
table because it is not a valid privilege for either (and
breaks the implementation of `has_table_privilege` and
`has_database_privilege`

See http://www.postgresql.org/docs/9.0/static/sql-grant.html
2016-12-08 11:22:57 -05:00
Will Thames 43bad27948 Update postgresql users only when necessary
For read-only databases, users should not change when no changes
are required.

Don't issue ALTER ROLE when role attribute flags, users password
or expiry time is not changing.

In certain cases (hashed passwords in the DB, but the password
argument is not hashed) passlib.hash is required to avoid
running ALTER ROLE.
2016-12-08 11:22:56 -05:00
tedder 9fd568f655 code review fixes per #957 2016-12-08 11:22:52 -05:00
tedder 35ce9fb095 skip password changes so pg_authid isn't needed
Some places ([AWS RDS](https://forums.aws.amazon.com/thread.jspa?threadID=151248)) don't have, or don't allow, access to the `pg_authid` table. The only reason that is necessary is to check for a password change.

This flag is a workaround so passwords can only be set at creation time. It isn't as elegant as changing the password down the line, but it fixes the longstanding issue #297 that prevented this from being useful on AWS RDS.
2016-12-08 11:22:52 -05:00
Johannes Steger 1a440d6a06 Fix function identifier quoting 2016-12-08 11:22:39 -05:00
Michael J. Schultz 588d03db8d Build the db connection on `"postgres"` instead of `"template1"`
According to the postgresql docs[1], you should not have a connection with
`"template1"` when copying multiple databases.

[1]: http://www.postgresql.org/docs/9.1/static/manage-ag-templatedbs.html
2016-12-08 11:22:36 -05:00
kustodian 8621f9a7cd Fixed postgresql_db failing on Python 2.4 with --check
This reverts commit 81cbdb6c8cf54c41ba2ee3330c968e2feea05a5c and adds ignoring of the SystemExit exception because of Python 2.4.
2016-12-08 11:22:33 -05:00
Toshio Kuratomi 9fde3c2dc5 Add USAGE as a valid privilege 2016-12-08 11:22:31 -05:00
Toshio Kuratomi cd7cc07e85 Gixes to doc formatting 2016-12-08 11:22:31 -05:00
Toshio Kuratomi 307116b838 Fix typo so docs will build 2016-12-08 11:22:31 -05:00
Dan fe787f1bc9 Adds a login_unix_socket option to the postgresql_privs module. 2016-12-08 11:22:29 -05:00
Dan ee65c55fb0 Adds a unix_socket/login_unix_socket option to the postgresql_user module. 2016-12-08 11:22:29 -05:00
Dan 789ee410f1 Adds a login_unix_socket option to the postgresql_db module. 2016-12-08 11:22:29 -05:00
Toshio Kuratomi e8081baca9 Fix for single role_attr 2016-12-08 11:22:28 -05:00
Devin Christensen b2829cf6b9 Fix user_alter in postgresql_user 2016-12-08 11:22:28 -05:00
Devin Christensen ff7a9eb625 Fix user_add in postgresql_user 2016-12-08 11:22:28 -05:00
Toshio Kuratomi 87b2afc272 Correct new function name 2016-12-08 11:22:28 -05:00
Toshio Kuratomi 3e9771f544 Normalize privs and flags to uppercase so comparisons against allowed names will work 2016-12-08 11:22:28 -05:00
Toshio Kuratomi e0ac340f59 Make sure we quote or confirm good all user provided identifiers 2016-12-08 11:22:28 -05:00
Toshio Kuratomi d3787840a4 Audit escaping of identifiers in the postgresql_user module 2016-12-08 11:22:28 -05:00
Toshio Kuratomi 32aaa07325 More robust quoting of database identifiers
Note: These aren't database values, those are already using the
appropriate Pyhton DB API method for quoting.
2016-12-08 11:22:27 -05:00
Michael DeHaan 5d814d9fb2 Some more module categorization. 2016-12-08 11:22:25 -05:00