|
|
2aacef |
From a1ab44a859080aebd79355f58e57739ce4225e97 Mon Sep 17 00:00:00 2001
|
|
|
2aacef |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
2aacef |
Date: Fri, 20 Jan 2023 14:54:44 +0900
|
|
|
2aacef |
Subject: [PATCH] test-unit-name: fix fd leak
|
|
|
2aacef |
|
|
|
2aacef |
Fixes an issue reported at https://github.com/systemd/systemd/issues/22576#issuecomment-1396774385.
|
|
|
2aacef |
|
|
|
2aacef |
(cherry picked from commit 36f73b6c67afd9c826e612b751ea8f9249da7985)
|
|
|
2aacef |
|
|
|
2aacef |
Related: #2138081
|
|
|
2aacef |
---
|
|
|
2aacef |
src/test/test-unit-name.c | 4 +++-
|
|
|
2aacef |
1 file changed, 3 insertions(+), 1 deletion(-)
|
|
|
2aacef |
|
|
|
2aacef |
diff --git a/src/test/test-unit-name.c b/src/test/test-unit-name.c
|
|
|
2aacef |
index 43fdb15d1c..eec4831b4e 100644
|
|
|
2aacef |
--- a/src/test/test-unit-name.c
|
|
|
2aacef |
+++ b/src/test/test-unit-name.c
|
|
|
2aacef |
@@ -241,11 +241,13 @@ TEST_RET(unit_printf, .sd_booted = true) {
|
|
|
2aacef |
*user, *group, *uid, *gid, *home, *shell,
|
|
|
2aacef |
*tmp_dir, *var_tmp_dir;
|
|
|
2aacef |
_cleanup_(manager_freep) Manager *m = NULL;
|
|
|
2aacef |
+ _cleanup_close_ int fd = -EBADF;
|
|
|
2aacef |
Unit *u;
|
|
|
2aacef |
int r;
|
|
|
2aacef |
|
|
|
2aacef |
_cleanup_(unlink_tempfilep) char filename[] = "/tmp/test-unit_printf.XXXXXX";
|
|
|
2aacef |
- assert_se(mkostemp_safe(filename) >= 0);
|
|
|
2aacef |
+ fd = mkostemp_safe(filename);
|
|
|
2aacef |
+ assert_se(fd >= 0);
|
|
|
2aacef |
|
|
|
2aacef |
/* Using the specifier functions is admittedly a bit circular, but we don't want to reimplement the
|
|
|
2aacef |
* logic a second time. We're at least testing that the hookup works. */
|