我有一个运行 Kubernetes 的 Debian 机器,我的所有生产环境都在那里,有近 50 个部署。我的问题是,在以非特权用户身份运行 Odoo 服务器的其中一个 pod 中,一些文件(不是全部)是以 root 用户为所有者创建的。
这是我的部署 yaml:
---
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
namespace: odoo
name: app
spec:
selector:
matchLabels:
app: odoo
strategy:
type: Recreate
template:
metadata:
labels:
app: odoo
spec:
securityContext:
fsGroup: 1000
containers:
- name: odoo
image: my-odoo
command:
- /docker-entrypoint.sh
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
name: odoo
- containerPort: 110
name: pop3
- containerPort: 995
name: pop3s
- containerPort: 25
name: smtp
- containerPort: 993
name: imaps
volumeMounts:
- name: home
mountPath: /home
- name: maildir
mountPath: /var/mail
volumes:
- name: maildir
hostPath:
path: /mnt/odoo/maildir
- name: home
hostPath:
path: /mnt/odoo/home
在我的入口点脚本中,我使用supervisord运行odoo,这是我的配置:
[group:odoo]
programs = odoo-web, odoo-monitor, odoo-beat, odoo-worker-default-0, odoo-worker-cdr-1, odoo-worker-notifications-2, odoo-worker-default-notifications-3
[program:odoo-web]
user = odoo
directory = /home/odoo/var/run
command = /home/odoo/bin/odoo-bin --proxy-mode
[program:odoo-worker-default-0]
user = odoo
directory = /home/odoo/var/run
command = /home/odoo/bin/odoo-bin celery worker -l INFO -n default-0@%%h -c4 -Q odoo-10.0.default
[program:odoo-worker-cdr-1]
user = odoo
directory = /home/odoo/var/run
command = /home/odoo/bin/odoo-bin celery worker -l INFO -n cdr-1@%%h -c1 -Q odoo-10.0.cdr
[program:odoo-worker-notifications-2]
user = odoo
directory = /home/odoo/var/run
command = /home/odoo/bin/odoo-bin celery worker -l INFO -n notifications-2@%%h -c2 -Q odoo-10.0.notifications
[program:odoo-worker-default-notifications-3]
user = odoo
directory = /home/odoo/var/run
command = /home/odoo/bin/odoo-bin celery worker -l INFO -n default-notifications-3@%%h -c2 -Q odoo-10.0.default,odoo-10.0.notifications
[program:odoo-beat]
user = odoo
directory = /home/odoo/var/run
command = /home/odoo/bin/odoo-bin celery beat -s /home/odoo/var/celerybeat-schedule
[program:odoo-monitor]
user = odoo
directory = /home/odoo/var/run
command = /home/odoo/bin/odoo-bin celery flower`
如您所见,所有进程都以 uid 为 1000 的用户 odoo 运行。
我的底层docker文件系统是overlay2。
有人能告诉我为什么非 root 进程创建的文件中的所有者会混乱吗?
答案1
答案2
好吧,我找到了一个解决方法:我用来运行 odoo 的用户无需密码即可执行 sudo。我已将其删除。现在文件没有获得错误的权限,因此,如果在 sudoers 中指定了 NOPASSWD,则可能是 Odoo 或其依赖项之一或 python 本身中的一个错误,允许普通用户使用 sudo 成为超级用户。