18.7: /var/lib/postgresql is 755 instead of 1777, breaks running as an arbitrary user

未关闭 适合新手
#1,427 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
docker, postgresql
领域
databases

调研方向

首先阅读 Dockerfile 中将 /var/lib/postgresql 设置为模式 1777 的部分,以及 issue 中关于 postgresql-common 的 tmpfiles 配置和安装后步骤的说明。使用任意 UID 构建并运行基于 Debian 的 postgres:18.7 镜像,检查目录模式以及能否成功启动。完成标准是该目录仍可供任意 UID 使用,并且容器能够成功启动。

由索引模型根据 Issue 内容生成。

描述

We noticed this when our CI broke after postgres:18 moved to 18.7. We run the image as a service container on OpenShift, which starts it with an arbitrary UID, and it now exits at once:

$ docker run --rm --user 1000770000:0 -e POSTGRES_PASSWORD=x postgres:18.7
mkdir: cannot create directory ‘/var/lib/postgresql/18’: Permission denied

/var/lib/postgresql was 1777 and is now 755:

$ docker run --rm --entrypoint stat postgres:18.6 -c %a /var/lib/postgresql
1777
$ docker run --rm --entrypoint stat postgres:18.7 -c %a /var/lib/postgresql
755

It looks like postgresql-common 294 resets it: it now ships /usr/lib/tmpfiles.d/postgresql-common.conf with d /var/lib/postgresql 0755 postgres postgres, and its postinst runs systemd-tmpfiles --create, after the Dockerfile's install --mode 1777. The alpine variant still has 1777.

主要语言
Shell
星标
2.5k
派生
1.2k
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

docker-library/postgres 的其他 Issue

查看 docker-library/postgres 的全部 Issue

相似的 Issue

更多 Shell/Bash Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。