From: Daan De Meyer Date: Mon, 21 Nov 2022 10:10:34 +0000 (+0100) Subject: repart: Use fd based operations in partition_populate_directory() X-Git-Tag: v253-rc1~485^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=488bb758c074314b08293ae1501f6b53352f7d87;p=thirdparty%2Fsystemd.git repart: Use fd based operations in partition_populate_directory() --- diff --git a/src/partition/repart.c b/src/partition/repart.c index 9a6bbdfb32f..5bae5542585 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -3782,6 +3782,7 @@ static int do_make_directories(Partition *p, const char *root) { static int partition_populate_directory(Partition *p, const Set *denylist, char **ret) { _cleanup_(rm_rf_physical_and_freep) char *root = NULL; + _cleanup_close_ int rfd = -1; int r; assert(ret); @@ -3791,11 +3792,11 @@ static int partition_populate_directory(Partition *p, const Set *denylist, char return 0; } - r = mkdtemp_malloc("/var/tmp/repart-XXXXXX", &root); - if (r < 0) - return log_error_errno(r, "Failed to create temporary directory: %m"); + rfd = mkdtemp_open("/var/tmp/repart-XXXXXX", 0, &root); + if (rfd < 0) + return log_error_errno(rfd, "Failed to create temporary directory: %m"); - if (chmod(root, 0755) < 0) + if (fchmod(rfd, 0755) < 0) return log_error_errno(errno, "Failed to change mode of temporary directory: %m"); /* Make sure everything is owned by the user running repart so that make_filesystem() can map the