read/write/delete OS 文件可以用 plpgsql 吗?
Can read/write/delete OS files with plpgsql?
是否可以使用 PL/pgSQL 读取、写入、删除 OS 个文件?
我可以运行 OS 命令吗?
我看过一些示例,您可以复制 CSV 等文件,但是您可以 read/write/delete OS 文件吗?你能执行 OS 个命令吗?
不,那不可能。
PL/pgSQL 是一种受信任的语言,因此不允许访问服务器资源,更不用说 运行 OS 命令了。
Explanation of "trusted language"
The optional key word TRUSTED specifies that the language does not grant access to data that the user would not otherwise have. Trusted languages are designed for ordinary database users (those without superuser privilege) and allows them to safely create functions and procedures. Since PL functions are executed inside the database server, the TRUSTED flag should only be given for languages that do not allow access to database server internals or the file system
有一些 SQL functions 可用,使具有超级用户权限的角色能够 读取 服务器上的文件 - 但这独立于 PL/pgSQL。
如果您确实想为各种攻击打开您的数据库服务器,请使用不受信任的语言,例如 PL/Python or if you are really adventurous PL/sh
PostgreSQL 在数据目录中有一些 functions to read files:pg_read_file
和 pg_read_binary_file
“adminpack” extension有写入文件的功能:pg_file_write
也许您可以滥用 COPY ... TO PROGRAM
到 运行 服务器上的代码。
但聪明的做法是在PL/PerlU或PL/Python中写一个函数。
是否可以使用 PL/pgSQL 读取、写入、删除 OS 个文件?
我可以运行 OS 命令吗?
我看过一些示例,您可以复制 CSV 等文件,但是您可以 read/write/delete OS 文件吗?你能执行 OS 个命令吗?
不,那不可能。
PL/pgSQL 是一种受信任的语言,因此不允许访问服务器资源,更不用说 运行 OS 命令了。
Explanation of "trusted language"
The optional key word TRUSTED specifies that the language does not grant access to data that the user would not otherwise have. Trusted languages are designed for ordinary database users (those without superuser privilege) and allows them to safely create functions and procedures. Since PL functions are executed inside the database server, the TRUSTED flag should only be given for languages that do not allow access to database server internals or the file system
有一些 SQL functions 可用,使具有超级用户权限的角色能够 读取 服务器上的文件 - 但这独立于 PL/pgSQL。
如果您确实想为各种攻击打开您的数据库服务器,请使用不受信任的语言,例如 PL/Python or if you are really adventurous PL/sh
PostgreSQL 在数据目录中有一些 functions to read files:pg_read_file
和 pg_read_binary_file
“adminpack” extension有写入文件的功能:pg_file_write
也许您可以滥用 COPY ... TO PROGRAM
到 运行 服务器上的代码。
但聪明的做法是在PL/PerlU或PL/Python中写一个函数。