dalibo/pg_activity

psycopg2.errors.InsufficientPrivilege error when using an installation from github

adityabaradwaj opened this issue · 5 comments

Steps to reproduce:

  1. Follow the "Installation from the git repository" steps in the README:
$ git clone https://github.com/dalibo/pg_activity.git
$ cd pg_activity
$ python3 -m venv .venv
$ . .venv/bin/activate
(.venv) $ pip install psycopg2-binary .
(.venv) $ pg_activity
  1. Run sudo $(which pg_activity) --rds [connection_string]
    where connection_string is of the format postgresql://[user[:password]@][netloc][:port][/dbname]

Expected result: connects to the postgres RDS database
Actual result:

Traceback (most recent call last):
  File "/home/ubuntu/pg_activity/.venv/bin/pg_activity", line 8, in <module>
    sys.exit(main())
  File "/home/ubuntu/pg_activity/.venv/lib/python3.7/site-packages/pgactivity/cli.py", line 347, in main
    ui.main(term, dataobj, host, args)
  File "/home/ubuntu/pg_activity/.venv/lib/python3.7/site-packages/pgactivity/ui.py", line 32, in main
    skip_sizes=options.nodbsize,
  File "/home/ubuntu/pg_activity/.venv/lib/python3.7/site-packages/pgactivity/data.py", line 231, in pg_get_server_information
    "using_rds": using_rds,
  File "/home/ubuntu/pg_activity/.venv/lib/python3.7/site-packages/psycopg2/extras.py", line 146, in execute
    return super().execute(query, vars)
psycopg2.errors.InsufficientPrivilege: permission denied for function pg_ls_dir

Note: this issue does not happen when using the pg_activity installed from the postgresql APT repo: sudo pg_activity --rds postgresql://[user[:password]@][netloc][:port][/dbname]

The reason I need to install from git is because I am facing this bug (I am able to connect to the db, but the connection drops after about 10 seconds due to the exception psycopg2.errors.InvalidTextRepresentation: invalid input syntax for type bytea)

It looks like that bug was fixed in May, so I'm assuming the fix didn't get included in the April release of 2.3.1

blogh commented

Hi,

Sorry for the delayed answer.
Thanks for reporting this. I have a patch in progress to Fix all theses privileges issues.

blogh commented

It should be out soon..ish.

blogh commented

Hi,

Master should fix your problem. The tempfile check is disabled if it fails or if you add --no-tempfiles or --rds.

blogh commented

Feel free to reopen if not.

Works now, thanks!