fix ConditionDirectoryNotEmpty,ConditionPathIsReadWrite and DirectoryNotEmpty

This commit is contained in:
yangmingtaip 2022-01-26 19:51:35 +08:00
parent 5df72320d1
commit 29fed11a74
4 changed files with 91 additions and 1 deletions

View File

@ -0,0 +1,26 @@
rom 193105f2d0408e2d96265935174b3cf0f100ef2e Mon Sep 17 00:00:00 2001
From: jiangchuangang <jiangchuangang@huawei.com>
Date: Mon, 29 Nov 2021 22:30:37 +0800
Subject: [PATCH] fix ConditionDirectoryNotEmpty when it comes to a
Non-directory file
---
src/shared/condition.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/shared/condition.c b/src/shared/condition.c
index e5e6c6c..bbe137a 100644
--- a/src/shared/condition.c
+++ b/src/shared/condition.c
@@ -682,7 +682,7 @@ static int condition_test_directory_not_empty(Condition *c) {
assert(c->type == CONDITION_DIRECTORY_NOT_EMPTY);
r = dir_is_empty(c->parameter);
- return r <= 0 && r != -ENOENT;
+ return r <= 0 && !IN_SET(r, -ENOENT, -ENOTDIR);
}
static int condition_test_file_not_empty(Condition *c) {
--
2.27.0

View File

@ -0,0 +1,33 @@
From 7c4c9948d02ceda903ed4e4deea0d0084612625a Mon Sep 17 00:00:00 2001
From: jiangchuangang <jiangchuangang@huawei.com>
Date: Tue, 30 Nov 2021 15:25:27 +0800
Subject: [PATCH] fix ConditionPathIsReadWrite when path does not exist.
---
src/shared/condition.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/shared/condition.c b/src/shared/condition.c
index bbe137a..8d460f9 100644
--- a/src/shared/condition.c
+++ b/src/shared/condition.c
@@ -667,11 +667,15 @@ static int condition_test_path_is_mount_point(Condition *c) {
}
static int condition_test_path_is_read_write(Condition *c) {
+ int r;
+
assert(c);
assert(c->parameter);
assert(c->type == CONDITION_PATH_IS_READ_WRITE);
- return path_is_read_only_fs(c->parameter) <= 0;
+ r = path_is_read_only_fs(c->parameter);
+
+ return r <= 0 && r != -ENOENT;
}
static int condition_test_directory_not_empty(Condition *c) {
--
2.27.0

View File

@ -0,0 +1,25 @@
From 5896a9ebdbe4d38c01390d0a5e82f9fcb4971059 Mon Sep 17 00:00:00 2001
From: yangmingtai <961612727@qq.com>
Date: Mon, 6 Dec 2021 17:06:13 +0800
Subject: [PATCH] fix DirectoryNotEmpty when it comes to a Non-directory file
---
src/core/path.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/core/path.c b/src/core/path.c
index 29ec66fd4d..bcd922901b 100644
--- a/src/core/path.c
+++ b/src/core/path.c
@@ -215,7 +215,7 @@ static bool path_spec_check_good(PathSpec *s, bool initial, bool from_trigger_no
int k;
k = dir_is_empty(s->path);
- good = !(k == -ENOENT || k > 0);
+ good = !(IN_SET(k, -ENOENT, -ENOTDIR) || k > 0);
break;
}
--
2.27.0

View File

@ -16,7 +16,7 @@
Name: systemd
Url: https://www.freedesktop.org/wiki/Software/systemd
Version: 243
Release: 52
Release: 53
License: MIT and LGPLv2+ and GPLv2+
Summary: System and Service Manager
@ -153,6 +153,9 @@ Patch0105: backport-0009-CVE-2021-3997-shared-rm-rf-loop-over-nested-direct
Patch0106: backport-cgroup-Also-set-blkio.bfq.weight.patch
Patch0107: backport-dbus-socket-fix-check-of-Listen-arguments.patch
Patch0108: backport-udevadm-fix-tag-match-help-description.patch
Patch0109: backport-fix-ConditionDirectoryNotEmpty-when-it-comes-to-a-No.patch
Patch0110: backport-fix-ConditionPathIsReadWrite-when-path-does-not-exis.patch
Patch0111: backport-fix-DirectoryNotEmpty-when-it-comes-to-a-Non-directo.patch
#openEuler
Patch9002: 1509-fix-journal-file-descriptors-leak-problems.patch
@ -1541,6 +1544,9 @@ fi
%exclude /usr/share/man/man3/*
%changelog
* Wed Jan 26 2021 yangmingtai <yangmingtai@huawei.com> - 243-53
- fix ConditionDirectoryNotEmpty,ConditionPathIsReadWrite and DirectoryNotEmpty
* Wed Jan 26 2021 yangmingtai <yangmingtai@huawei.com> - 243-52
- fix some issue: 1.fix set blkio.bfq.weight
2.udevadm fix --tag-match