通过 tomcat.service 为 tomcat8 设置 umask [英] set umask for tomcat8 via tomcat.service

查看:100
本文介绍了通过 tomcat.service 为 tomcat8 设置 umask的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 tomcat 8 实例设置自定义 umask,试图通过在 systemd tomcat 单元中使用 UMask 指令使其成为一种好方法,如这里运气不好.

I am trying to set a custom umask for a tomcat 8 instance, tried to make it the good way by using the UMask directive in systemd tomcat unit as seen here without luck.

我想设置一个 022 umask 因为公司开发人员需要访问 tomcat/应用程序日志,并且他们与 tomcat 用户不在同一个组....

I'd like to set a 022 umask cause the company dev needs to access tomcat / application logs and they are not in the same group as the tomcat user....

最疯狂的是 systemd 文档说:

the crazy thing is that the systemd doc says :

控制文件模式创建掩码.采用八进制表示法的访问模式.有关详细信息,请参阅 umask(2).默认为 0022.

但是日志(应用程序/tomcat)设置为 640(不是预期的 755):

But the logs (application / tomcat) are set to 640 (not the expected 755) :

-rw-r----- 1 top top 21416 Feb  1 09:58 catalina.out

我的服务文件:

# Systemd unit file for tomcat
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target

[...]

User=top
Group=top
UMask=0022

[Install]
WantedBy=multi-user.target

对此有什么想法吗?

谢谢

推荐答案

尝试将 UMASK 作为环境变量添加到 tomcat 的服务文件中:

Try adding UMASK as Environment variable into tomcat's service file:

[Service]
...
Environment='UMASK=0022'
...

默认 catalina.sh 正在检查环境的 $UMASK:

Default catalina.sh is checking for environment's $UMASK:

# Set UMASK unless it has been overridden
 if [ -z "$UMASK" ]; then
  UMASK="0027"
 fi
 umask $UMASK

(在我看来,来自 systemd 的 UMask 不被 Tomcat 使用,但我不完全确定.)

(It seems to me, that UMask from systemd is not used by Tomcat, but I am not completely sure.)

这篇关于通过 tomcat.service 为 tomcat8 设置 umask的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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