selinux boolean allow_user_postgresql_connect 无效

selinux boolean allow_user_postgresql_connect 无效

我正在建立一个包含 postgresql 数据库的新系统,并尝试锁定哪些机器能够打开与数据库的连接。

我正在尝试使用 allow_user_postgresql_connect 布尔值来实现这一点,但到目前为止还无法让它阻止任何连接。

我正在使用以下 2 台服务器 DB 和 Client 进行测试。两者都是运行 postgres 8.4.7-2 的 RHEL6u2;

DB# getenforce
Enforcing
DB# getsebool allow_user_postgresql_connect
allow_user_postgresql_connect --> on
DB# service postgresql start
starting postgresql service:              [  OK  ]

Client# getenforce
Enforcing
Client# getsebool allow_user_postgresql_connect
allow_user_postgresql_connect --> off

Client-> psql -h DB "sslmode=require dbname=mydb" postgres
connects

我已经尝试了两台机器上 allow_user_postgresql_connect on/off 的所有组合,但都无法导致它拒绝连接。

应如何设置此布尔值以防止机器上的用户连接到数据库?

我对 SElinux 还很陌生,所以可能忽略了一些显而易见的东西。

答案1

你为什么要尝试使用 SELinux 来实现这一点?Postgres 已经有了一个完美的混合身份验证和授权系统,这就是您应该为此使用的(除其他原因外,因为它将失败的登录放在合乎逻辑的位置:Postgres 日志)。

如果您试图通过不让未经授权的系统连接到 Postgres 端口来进一步保护系统,那么假设您有一个授权系统(IP 地址)列表,并且可以配置阻止未经授权主机的流量的防火墙规则。

对于我来说,试图迫使 SELinux 屈服于这样的事情就像是试图将方形钉子插入信用卡插槽一样。

相关内容