Re: psql remote shell command

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Dennis <dennisr(at)visi(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: psql remote shell command
Date: 2016-06-03 00:10:09
Message-ID: CAKFQuwYg6OggMTwRc-dgJurSY-4hG1ZEAnU2V70xg9tDa4ycXQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jun 2, 2016 at 7:54 PM, Stephen Frost <sfrost(at)snowman(dot)net> wrote:

> * Dennis (dennisr(at)visi(dot)com) wrote:
> > Is it possible to execute command in on system the is hosting postgresql
> remotely using psql or other mechanism? I know I can use \! in psql but
> that executes the commands on the host where I am running psql from. Also,
> is it possible for a postgres login/user to stop or restart a running
> postgres instance from in side psql or similar client. e.g. psql -c “pg_ctl
> stop -D some_data_dir”
>
You can use COPY with PROGRAM, assuming you're a superuser.
>
> COPY (select 1) TO PROGRAM 'whatever command';
>

​That's thinking outside the box.

​Took me a while to find the documentation of the superuser limitation
buried in the notes.

https://www.postgresql.org/docs/devel/static/sql-copy.html

I see why SELinux and its ilk are necessary evils in situations where finer
grained control is needed.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2016-06-03 00:32:45 Re: PL/PGSQL + inserts+updates+limit - Postgres 9.3
Previous Message Stephen Frost 2016-06-02 23:56:08 Re: psql remote shell command