无需归录
背景:一个 NAS 共享目录,A 系统可以写,B 系统只读。
问题:应用运维人员发现,B 系统的 cyuser 用户不能读取 A 系统生成的文件,揭示没有权限。
检查:在 B 系统中检查目录权限没有问题,文件的权限为:
-rw-r----- 1 506 506 249906 11月 27 03:40 xxx_20201127034000.txt
-rw-r----- 1 506 506 249906 11月 27 11:40 xxx_20201127114000.txt
506 用户与 506 组在 B 系统中并不存在。cyuser 没法读取这些文件也就在情理之中了。
登录 A 系统主机,查看到这些文件的属主是 tomcat.tomcat。
查看 tomcat 进程的相关信息:
$ ps -ef | grep -i tomcat
tomcat 29448 1 0 Jul09 ? 05:40:51 .....SecurityListener.UMASK=0027 ...
可以看到 UMASK=0027
查看 tomcat 的版本:
$ cd /home/tomcat/tomcatCyServer/bin
$ ./version.sh
Using CATALINA_BASE: /home/tomcat/tomcatCyServer
Using CATALINA_HOME: /home/tomcat/tomcatCyServer
Using CATALINA_TMPDIR: /home/tomcat/tomcatCyServer/temp
Using JRE_HOME: /usr
Using CLASSPATH: /home/tomcat/tomcatCyServer/bin/bootstrap.jar:/home/tomcat/tomcatCyServer/bin/tomcat-juli.jar
Server version: Apache Tomcat/8.5.xx
Server built: May 1 2019 11:45:20 UTC
Server number: 8.5.xx.y
OS Name: Linux
OS Version: 2.6.xx
Architecture: amd64
JVM Version: 1.7.xx
JVM Vendor: Oracle Corporation
查看 tomcat 的 umask 设置:
$ cd /home/tomcat/tomcatCyServer/bin
$ cat catalina.sh
.....
# UMASK (Optional) Override Tomcat's default UMASK of 0027
.....
# Set UMASK unless it has been overridden
if [ -z "$UMASK" ]; then
UMASK="0027"
fi
umask $UMASK
.....
可见 tomcat8 默认 umask 已改为 027。将这儿的 umask 值修改为 0022 即可。