Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add docker UMASK, PUID, PGID setting support #588

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

mouyase
Copy link

@mouyase mouyase commented Apr 23, 2024

利用gosu实现账户切换,增加Docker镜像的UMASK,PUID,PGID的设置,从而更好的支持linux系统的权限管理。

默认UMASK为022,文件创建后权限为-rw-r--r-,仅当前用户可读写,其他用户仅可读,而docker内默认用户为root,所以会导致录播文件写入到宿主机后,宿主机非root用户无法写入编辑。
增加了新设置后,可以通过环境变量指定UMASK,如果将UMASK设置为000则全部用户可读写录播文件,002则为当前用户组的所有用户可读写录播文件。
同时可以使用PUID,和PGID设置文件所有者的用户,在某些系统中该设置可以更好的帮助管理权限。例如在unRaid系统内,PUID设置为99,PGID设置为100,UMASK设置为002。则可以实现文件创建后,共享文件用户可读写,文件所有者为nobody。

Copy link
Member

@Genteure Genteure left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

总体看起来没有问题,谢谢。

方便在 https://github.com/BililiveRecorder/website 仓库里发一个 PR 加一下相关的文档说明吗?😂
你不想写的话我合并 PR 的时候自己去改一下也可以。

Dockerfile.GitHubActions Show resolved Hide resolved
Dockerfile.GitHubActions Show resolved Hide resolved
Add files via upload

Update Dockerfile.GitHubActions

feat: 删除Docker中无用文件

Co-authored-by: Genteure <genteure@gmail.com>
@Genteure
Copy link
Member

看起来没有问题了,等两天我运行测试一下之后合并。

@mouyase
Copy link
Author

mouyase commented Apr 26, 2024

我这边目前也在测试运行中,已经录了几场,暂时还没遇到什么问题

@kira1928
Copy link
Contributor

不太懂用户权限,但是有一个疑问,就是这个PR里默认PUID和PGID是1000,是不是和至今为止默认的root用户不同了?
如果有些需要默认设置才能运行的docker环境的用户,升级后会不会遇到文件权限问题,而且他们不会改权限配置?

如果我的理解是正确的,我觉得默认PUID和PGID设为和至今为止的值一样(0和0),保持向后兼容性。只有有修改需求的用户设置其他值时才会改变docker的行为比较好?
参考我们之前合并的类似PR,我们用了默认值为 0 和 0,目前还没有遇到问题反馈。

@mouyase
Copy link
Author

mouyase commented May 12, 2024

@kira1928 虽然理论上如果按默认配置,创建出目录和文件的权限应该是root:root,所以宿主一定是具有root权限的,所以不会产生权限问题(因为root权限具有最高权限)

不过看起来您所提到的su-exec的运行方式似乎是一种更优秀的方案,我认为可以试着用相同的方案来更新一下这个patch

如果按我目前的实现方式,设置默认用户和用户组为0,则会导致下面的问题

#588 (comment)

如果设置为0,则会导致脚本尝试将user用户的UID修改为0,但由于UID0被root用户占用,所以会导致脚本启动失败,所以最好还是将UID设置为Linux保留数字之外的数字(500-60000),设置为1000算是比较常见的做法。

@kira1928
Copy link
Contributor

啊,原来已经讨论过这个问题了!
我进来的时候看那里是折叠的,没注意到不好意思。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants