Ruby - >将pg_hba.conf的PostgreSQL连接设置为“ident sameuser”而不是“信任” [英] Ruby -> PostgreSQL connection with pg_hba.conf set to "ident sameuser" instead of "trust"

查看:385
本文介绍了Ruby - >将pg_hba.conf的PostgreSQL连接设置为“ident sameuser”而不是“信任”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试过每一个Google搜寻字词,但我发现的一切都不断地在 pg_hba中设定与 trust 的连结。 conf (似乎一个安全漏洞,如果任何本地用户都可以登录并访问数据库,因为任何人都说他们是)。



pg_hba.conf 本地连接设置为 ident sameuser 。该脚本应该作为该用户运行,但我收到此错误:

 发生数据库错误:
fe_sendauth:没有提供密码

Ruby代码很通用:


$ b b

  conn_str =DBI:pg:dbname = mydb; host =+ localhost 
@connection = DBI.connect(conn_str,myuser,' b $ b

我可以通过创建一个〜/ .pgpass 文件如此处所述
,但



任何人都可以获得PostgreSQL的 ident sameuser

code>

解决方案

我怀疑这是:


在pg_hba.conf 本地连接中设置为ident sameuser。脚本应该作为该用户运行,但我收到此错误[...]




  conn_str =DBI:pg:dbname = mydb; host =+ localhost 
@connection = DBI.connect(conn_str,myuser,'')
pre>

请注意,本地连接与连接到localhost不同。只要在连接URL中提到localhost,就会创建一个TCP / IP套接字。这些是由pg_hba.conf中的 host 规则管理的。



使用真正的本地连接Unix必须使用域套接字。但我不知道Ruby DBI连接器是否支持它们。


I've tried every Google search term I can think of but everything I dig up keeps saying to set local connections to trust in pg_hba.conf (seems like a security hole if anyone locally can log in and access the DB as anyone they say they are).

In pg_hba.conf local connections are set to ident sameuser. The script should be running as that user, but I get this error:

A database error occurred: 
fe_sendauth: no password supplied

The Ruby code is pretty generic:

conn_str = "DBI:pg:dbname=mydb;host=" + localhost
@connection = DBI.connect(conn_str, "myuser", '')

I can work around this by creating a ~/.pgpass file as described here, but I'd prefer being able to let users log in and just access the DB server.

Anyone ever been able to get PostgreSQL's ident sameuser to work properly for local scripts?

解决方案

I suspect this:

In pg_hba.conf local connections are set to ident sameuser. The script should be running as that user, but I get this error [...]

conn_str = "DBI:pg:dbname=mydb;host=" + localhost
@connection = DBI.connect(conn_str, "myuser", '')

Please note that a "local" connection is not the same as a connection to "localhost". As soon as you mention "localhost" in the connection URL a TCP/IP socket is created. These are managed by the host rules in `pg_hba.conf.

To use a real "local" connection Unix Domain Sockets must be used. But I don't know whether or not the Ruby DBI connector supports them.

这篇关于Ruby - >将pg_hba.conf的PostgreSQL连接设置为“ident sameuser”而不是“信任”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆