1 Star 0 Fork 38

zhuguodong/rsyslog

forked from src-openEuler/rsyslog 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
rsyslog-8.24.0-set-permission-of-syslogd-dot-pid-to-0644.patch 1.50 KB
一键复制 编辑 原始数据 按行查看 历史
From 1b1efc640a57a757d1c7c64fd60d2187e3940060 Mon Sep 17 00:00:00 2001
From: guoxiaoqi <guoxiaoqi2@huawei.com>
Date: Sat, 26 Jan 2019 15:27:29 +0000
Subject: [PATCH] rsyslog-8.24.0, set permission of syslogd dot pid to 0644
reason: rsyslog-8.24.0, set permission of syslogd dot pid to 0644
Signed-off-by: guoxiaoqi <guoxiaoqi2@huawei.com>
---
tools/rsyslogd.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/tools/rsyslogd.c b/tools/rsyslogd.c
index d2e4833..834fc08 100644
--- a/tools/rsyslogd.c
+++ b/tools/rsyslogd.c
@@ -28,6 +28,7 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
+#include <fcntl.h>
#include <errno.h>
#ifdef ENABLE_LIBLOGGING_STDLOG
# include <liblogging/stdlog.h>
@@ -265,6 +266,7 @@ static rsRetVal
writePidFile(void)
{
FILE *fp;
+ int fd;
DEFiRet;
const char *tmpPidFile;
@@ -278,10 +280,15 @@ writePidFile(void)
if(tmpPidFile == NULL)
tmpPidFile = PidFile;
DBGPRINTF("rsyslogd: writing pidfile '%s'.\n", tmpPidFile);
- if((fp = fopen((char*) tmpPidFile, "w")) == NULL) {
+ if ( (fd = open(tmpPidFile, O_WRONLY|O_CREAT|O_CLOEXEC, 0644)) == -1) {
perror("rsyslogd: error writing pid file (creation stage)\n");
ABORT_FINALIZE(RS_RET_ERR);
}
+ if ((fp = fdopen(fd, "w")) == NULL) {
+ close(fd);
+ perror("rsyslogd: error writing pid file (fp binding stage)\n");
+ ABORT_FINALIZE(RS_RET_ERR);
+ }
if(fprintf(fp, "%d", (int) glblGetOurPid()) < 0) {
LogError(errno, iRet, "rsyslog: error writing pid file");
}
--
1.8.3.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhuguodong/rsyslog.git
git@gitee.com:zhuguodong/rsyslog.git
zhuguodong
rsyslog
rsyslog
master

搜索帮助