postgreSQL:权限被拒绝使用\i读取文件 [英] postgreSQL: permission denied reading a file using \i

查看:69
本文介绍了postgreSQL:权限被拒绝使用\i读取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将其发布为对
提出的原始问题的答案使用\i命令从文件中读取时,PostgreSQL的权限被拒绝了。
但是我现在意识到我应该把它作为一个单独的问题发布。

I posted this as an answer on the original question posed on postgreSQL permission denied when reading from file with \i command But I now realise I should have posted as a separate question.

我的操作系统是Fedora 21,我已经安装了PostgreSQL-9.4

My OS is Fedora 21, I have installed PostgreSQL-9.4

我正在尝试使用\i命令读取文件,并且错误消息是Permission否认。我的文件上有 chmod a + r
在我的系统上有3个用户[root,damo,postgres],我建立了一个有2个成员[damo,postgres]的组[project]。我在所有相关目录上使用了 chgrp (我相信)应该向用户[postgres]授予访问各种文件的权限。
我用用户[postgres]访问pqsql,但是我所有的其他工作都在用户[damo]下。在pgsql中,使用选项卡从命令导航:\i在

I am trying to read a file using the \i command and error message is Permission denied. I have chmod a+r on the file. On my system there are 3 users [root, damo, postgres] and I have established a group [project] that has 2 members [damo, postgres]. I have used chgrp on all relevant directories which (I believe) should grant permission to user [postgres] to access various files. I access pqsql with the user [postgres] but all of my other work is under user [damo]. Within pgsql using the tab to navigate from the command \i stops after

    ../../home/damo

我无法走了。这显然很重要,但我不知道这意味着什么。因此,我将文件移至该位置,但仍无法加载。这是 ls -l <​​/ code>和 stat

and I can go no further. This obviously important but I don't know what it means. So I moved the file to that location and it still does not load. This is the output from ls -l and stat

    $ ls -l testScript.sql 
    -rw-r--r--. 1 damo project 76 Nov  5 18:18 testScript.sql

    $ stat testScript.sql 
      File: ‘testScript.sql’
      Size: 76          Blocks: 8          IO Block: 4096   regular file
    Device: fd02h/64770d    Inode: 2623547     Links: 1
    Access: (0644/-rw-r--r--)  Uid: ( 1000/    damo)   Gid: ( 1001/ project)
    Context: unconfined_u:object_r:user_home_t:s0
    Access: 2015-11-05 18:18:06.082928881 +0000
    Modify: 2015-11-05 18:18:06.084928866 +0000
    Change: 2015-11-05 18:25:57.041183384 +0000
    Birth: -

有人可以提出一些建议吗?

Can anyone advance some suggestions?

推荐答案

您使用的是Fedora 21,因此默认情况下您可能已启用SELinux。 postgres 用户可能没有权限访问安全上下文 user_home_t 。安全上下文由您的 stat 输出显示。您可以使用 ls -lZ 将其包含在 ls 中。

You're on Fedora 21, so you likely have SELinux enabled by default. The postgres user probably doesn't have the rights to access the security context user_home_t. The security context is shown by your stat output. You can include it in ls using ls -lZ.

selinux布尔 postgresql_selinux_unconfined_dbadm 看起来像您想要的,每 getsebool -a

The selinux boolean postgresql_selinux_unconfined_dbadm looks like what you want for that, per getsebool -a.

检查

getsebool postgresql_selinux_unconfined_dbadm

,如果 off ,请尝试:

setsebool postgresql_selinux_unconfined_dbadm on

另外,确定selinux是否是什么拒绝访问,检查系统日志或运行 sealert 工具(SELinux警报浏览器)。

Also, to determine whether selinux is what's denying access, check the system logs or run the sealert tool (SELinux alert browser).

这篇关于postgreSQL:权限被拒绝使用\i读取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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