Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't revoke functions from user #687

Closed
DPatFrance opened this issue Apr 11, 2024 · 6 comments · Fixed by #690
Closed

Can't revoke functions from user #687

DPatFrance opened this issue Apr 11, 2024 · 6 comments · Fixed by #690
Labels
easyfix help wanted Extra attention is needed

Comments

@DPatFrance
Copy link

SUMMARY

Can't revoke the functions from user with community.postgresql.postgresql_privs.

ISSUE TYPE

  • Bug Report

COMPONENT NAME

postgresql_privs

COLLECTION VERSION

community.general 8.5.0

ACTUAL RESULTS

The revoke FUNCTIONS is missing in the queries.

"changed": false,
  "invocation": {
      "module_args": {
          "ca_cert": null,
          "connect_params": {},
          "database": "pgappli",
          "db": "appli",
          "fail_on_role": true,
          "grant_option": null,
          "login_host": "localhost",
          "login_password": "",
          "login_port": 5432,
          "login_unix_socket": "",
          "login_user": "postgres",
          "objs": "FUNCTIONS",
          "password": "",
          "port": 5432,
          "privs": "ALL",
          "role": "testTOUp",
          "roles": "testTOUp",
          "schema": "public",
          "session_role": null,
          "ssl_cert": null,
          "ssl_key": null,
          "ssl_mode": "prefer",
          "state": "absent",
          "target_roles": null,
          "trust_input": true,
          "type": "default_privs"
      }
  },
  "queries": [
      "ALTER DEFAULT PRIVILEGES IN SCHEMA \"public\" REVOKE ALL ON TABLES FROM \"testTOUp\";\nALTER DEFAULT PRIVILEGES IN SCHEMA \"public\" REVOKE ALL ON SEQUENCES FROM \"testTOUp\";\nALTER DEFAULT PRIVILEGES IN SCHEMA \"public\" REVOKE ALL ON TYPES FROM \"testTOUp\";" 

PROPOSED SOLUTION

In the module postgresql_privs.py : add FUNCTIONS at the line 975:

 972     def build_absent(self):
 973         if self._obj_type == 'default_privs':
 974             self.query = []
 975             for obj in ['TABLES', 'FUNCTIONS', 'SEQUENCES', 'TYPES']:
 976                 if self._as_who:
 977                     self.query.append(
 978                         'ALTER DEFAULT PRIVILEGES FOR ROLE {0}{1} REVOKE ALL ON {2} FROM {3};'.format(self._as_who,
 979                                                                                                       self._schema, obj,
 980                                                                                                       self._for_whom))
 981                 else:
 982                     self.query.append(
 983                         'ALTER DEFAULT PRIVILEGES{0} REVOKE ALL ON {1} FROM {2};'.format(self._schema, obj,
 984                                                                                          self._for_whom))
 985         else:
 986             self.query.append('REVOKE {0} FROM {1};'.format(self._set_what, self._for_whom))
@DPatFrance DPatFrance changed the title Can't revoke functions from a user Can't revoke functions from user Apr 11, 2024
@hunleyd
Copy link
Collaborator

hunleyd commented Apr 12, 2024

Thanks for the issue @DPatFrance ! Would you be interested in making a PR with your proposed fix? If not, someone else will pick this up eventually.

@DPatFrance
Copy link
Author

Hello,
Thank you for your reply, I'll let you make the correction. 😃

@Andersson007 Andersson007 added help wanted Extra attention is needed easyfix labels Apr 15, 2024
@Andersson007
Copy link
Collaborator

@DPatFrance hello, thanks for reporting the bug!
Looks like an easyfix to me. I'll put the help wanted and easyfix labels on the issue.
If someone wants to fix it, please before starting add a comment. There's also a quick start guide for new folks

@SlamChillz
Copy link
Contributor

@Andersson007 @DPatFrance I would work on this fix.

@Andersson007
Copy link
Collaborator

@SlamChillz hello, cool, thanks!

@Andersson007
Copy link
Collaborator

@DPatFrance thanks for the bug report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easyfix help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants