我正在 TinyCore64 机器上配置 postgresql 服务器,尽管我已更改了所有内容的权限、所有权和组,但仍有一些文件和文件夹无法由用户 postgres 访问。以下是命令和文件夹结构:
sudo -u postgres ls /etc/ssl/
# success
# Permissions: drwxr-xr-x 6 root root
sudo -u postgres ls /etc/ssl/private
# ls: cannot open directory /etc/ssl/private/: Permission denied
# Permissions: drwxr-xr-x 2 postgres postgres
我被难住了。我做错了什么?
编辑:
发布了准确的记录。
root@121e7b1cdaa4:~# sudo -u postgres ls -al /etc/ssl
total 28
drwxr-xr-x 6 root root 4096 Jun 12 08:33 .
drwxr-xr-x 161 root root 4096 Jun 12 08:33 ..
drwxr-xr-x 2 root root 4096 Jun 12 08:33 certs
-rw-r--r-- 1 root root 10835 May 2 20:29 openssl.cnf
drwxr-xr-x 2 postgres postgres 4096 Jun 12 08:33 private
root@121e7b1cdaa4:~# sudo -u postgres ls -al /etc/ssl/private/
ls: cannot open directory /etc/ssl/private/: Permission denied
编辑:
发布了 strace 输出:
root@121e7b1cdaa4:~# strace -f sudo -u postgres ls -al /etc/ssl/private/
....
[pid 4270] close(3) = 0
[pid 4270] openat(AT_FDCWD, "/etc/ssl/private/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 EACCES (Permission denied)
[pid 4270] write(2, "ls: ", 4ls: ) = 4
[pid 4270] write(2, "cannot open directory /etc/ssl/p"..., 39cannot open directory /etc/ssl/private/) = 39
[pid 4270] write(2, ": Permission denied", 19: Permission denied) = 19
[pid 4270] write(2, "\n", 1
) = 1
....
inode 检查输出:
root@121e7b1cdaa4:/etc/ssl# sudo ls -ila /etc/ssl | grep private
19259 drwxr-xr-x 2 postgres postgres 4096 Jun 12 08:33 private
root@121e7b1cdaa4:/etc/ssl# sudo ls -ila /etc/ssl/private | egrep ' \.$'
19259 drwxr-xr-x 2 postgres postgres 4096 Jun 12 08:33 .
答案1
你确定是同一个目录吗?即同一个 inode?你可以用下面的结果来验证:
# sudo ls -ila /etc/ssl | grep private
# sudo ls -ila /etc/ssl/private | egrep ' \.$'
我要尝试的另一件事是检查磁盘是否存在 inode 问题。运行以下命令:
# sudo touch /forcefsck
然后,重新启动系统并fsck
运行。