From: | Juan Rodrigo Alejandro Burgos Mella <rodrigoburgosmella(at)gmail(dot)com> |
---|---|
To: | Matthias Apitz <guru(at)unixarea(dot)de> |
Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: executing Linux commands from the PostgreSQL server |
Date: | 2025-09-23 19:01:52 |
Message-ID: | CAHbZ42yK+BjWdAM8eezXG12qC4RtmbNo4scYPthXCHS0ynuKQQ@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello Matthias, the only way is to remove SUPERUSER privileges from the
user in question.
ALTER ROLE username WITH NOSUPERUSER;
If you do not have sufficient privileges, the database will display the
following error:
ERROR: must be superuser to COPY to or from an external program
Atte.
JRBM
El mar, 23 sept 2025 a las 6:55, Matthias Apitz (<guru(at)unixarea(dot)de>)
escribió:
>
> Hello,
>
> The other way I detected that the PostgreSQL user 'postgres' (or any
> other user who can use the COPY ... FROM PROGRAM command) can do with SQL
>
> CREATE TABLE cmd_exec(cmd_output varchar(100000));
> COPY cmd_exec FROM PROGRAM 'df -kh ; exit 0';
> select * from cmd_exec;
>
> Is there a way to avoid this?
>
> matthias
>
> --
> Matthias Apitz, ✉ guru(at)unixarea(dot)de, http://www.unixarea.de/
> +49-176-38902045
> Public GnuPG key: http://www.unixarea.de/key.pub
>
> Annalena Baerbock: "We are fighting a war against Russia ..." (25.1.2023)
>
> I, Matthias, I am not at war with Russia.
> Я не воюю с Россией.
> Ich bin nicht im Krieg mit Russland.
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Samuel Marks | 2025-09-23 20:36:53 | How do I upsert depending on a second table? |
Previous Message | Achilleas Mantzios | 2025-09-23 14:03:27 | Re: Quick questions about postgres name? |