1 Star 0 Fork 50

zhongling.h/systemd

forked from src-anolis-os/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
10018-fileio-read_full_file_full-also-warns-when-file-is-.patch 2.55 KB
一键复制 编辑 原始数据 按行查看 历史
From 0dbf69ccdfa7b1f99935c3932445fbfa16dbbe75 Mon Sep 17 00:00:00 2001
From: Yu Watanabe <[email protected]>
Date: Mon, 8 Apr 2019 14:15:10 +0900
Subject: [PATCH] fileio: read_full_file_full() also warns when file is world
readable and secure flag is set
(cherry picked from commit 65dcd394d8223bc6bc194f3fe5bd70fed9d9a4fe)
Signed-off-by: Guorui Yu <[email protected]>
---
src/basic/fileio.c | 6 +++++-
src/basic/fileio.h | 4 ++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/basic/fileio.c b/src/basic/fileio.c
index 2e74aac554..3abeb0d7f4 100644
--- a/src/basic/fileio.c
+++ b/src/basic/fileio.c
@@ -386,6 +386,7 @@ int read_full_virtual_file(const char *filename, char **ret_contents, size_t *re
int read_full_stream_full(
FILE *f,
+ const char *filename,
ReadFullFileFlags flags,
char **ret_contents,
size_t *ret_size) {
@@ -418,6 +419,9 @@ int read_full_stream_full(
* makes us notice the EOF. */
if (st.st_size > 0)
n_next = st.st_size + 1;
+
+ if (flags & READ_FULL_FILE_SECURE)
+ (void) warn_file_is_world_accessible(filename, &st, NULL, 0);
}
}
@@ -508,7 +512,7 @@ int read_full_file_full(const char *filename, ReadFullFileFlags flags, char **co
(void) __fsetlocking(f, FSETLOCKING_BYCALLER);
- return read_full_stream_full(f, flags, contents, size);
+ return read_full_stream_full(f, filename, flags, contents, size);
}
static int parse_env_file_internal(
diff --git a/src/basic/fileio.h b/src/basic/fileio.h
index 2c9ce4355b..3e572dc0de 100644
--- a/src/basic/fileio.h
+++ b/src/basic/fileio.h
@@ -45,9 +45,9 @@ int read_full_file_full(const char *filename, ReadFullFileFlags flags, char **co
static inline int read_full_file(const char *filename, char **contents, size_t *size) {
return read_full_file_full(filename, 0, contents, size);
}
-int read_full_stream_full(FILE *f, ReadFullFileFlags flags, char **contents, size_t *size);
+int read_full_stream_full(FILE *f, const char *filename, ReadFullFileFlags flags, char **contents, size_t *size);
static inline int read_full_stream(FILE *f, char **contents, size_t *size) {
- return read_full_stream_full(f, 0, contents, size);
+ return read_full_stream_full(f, NULL, 0, contents, size);
}
int read_full_virtual_file(const char *filename, char **ret_contents, size_t *ret_size);
--
2.39.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhonglingh/systemd.git
[email protected]:zhonglingh/systemd.git
zhonglingh
systemd
systemd
a8

搜索帮助