1 Star 0 Fork 50

苏峰/systemd

forked from src-anolis-os/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0361-test-fs-util-skip-some-tests-when-running-in-unprivi.patch 1.73 KB
一键复制 编辑 原始数据 按行查看 历史
geliwei 提交于 2021-06-16 16:46 . update to systemd-239-45.el8.src.rpm
From 15ab55eca3d1f7feb86e55bdc147069f36d198eb Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Fri, 14 Sep 2018 15:51:04 +0900
Subject: [PATCH] test-fs-util: skip some tests when running in unprivileged
container
(cherry picked from commit 9590065f37be040996f1c2b9a246b9952fdc0c0b)
Resolves: #1823767
---
src/test/test-fs-util.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/test/test-fs-util.c b/src/test/test-fs-util.c
index 7b7990bb70..e3338ea440 100644
--- a/src/test/test-fs-util.c
+++ b/src/test/test-fs-util.c
@@ -17,6 +17,7 @@
#include "strv.h"
#include "user-util.h"
#include "util.h"
+#include "virt.h"
static void test_chase_symlinks(void) {
_cleanup_free_ char *result = NULL;
@@ -468,6 +469,7 @@ static void test_touch_file(void) {
struct stat st;
const char *a;
usec_t test_mtime;
+ int r;
test_uid = geteuid() == 0 ? 65534 : getuid();
test_gid = geteuid() == 0 ? 65534 : getgid();
@@ -517,7 +519,12 @@ static void test_touch_file(void) {
if (geteuid() == 0) {
a = strjoina(p, "/cdev");
- assert_se(mknod(a, 0775 | S_IFCHR, makedev(0, 0)) >= 0);
+ r = mknod(a, 0775 | S_IFCHR, makedev(0, 0));
+ if (r < 0 && errno == EPERM && detect_container() > 0) {
+ log_notice("Running in unprivileged container? Skipping remaining tests in %s", __func__);
+ return;
+ }
+ assert_se(r >= 0);
assert_se(touch_file(a, false, test_mtime, test_uid, test_gid, 0640) >= 0);
assert_se(lstat(a, &st) >= 0);
assert_se(st.st_uid == test_uid);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/su-feng-nmg/systemd.git
git@gitee.com:su-feng-nmg/systemd.git
su-feng-nmg
systemd
systemd
a8

搜索帮助