Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:15-SP4
slurm.32299
U_07-Use-rmdir_recursive.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File U_07-Use-rmdir_recursive.patch of Package slurm.32299
From: Tim Wickberg <tim@schedmd.com> Date: Wed Oct 11 12:45:25 2023 -0600 Subject: [PATCH 7/19]Use rmdir_recursive(). Patch-mainline: Upstream Git-repo: https://github.com/SchedMD/slurm Git-commit: 444dc4085a4dfb4676f9ecf3dfb4689ee12f365d References: CVE-2022-29500, bsc#1216207 Signed-off-by: Egbert Eich <eich@suse.de> Instead of vulnerable local version. Co-authored-by: Alejandro Sanchez <alex@schedmd.com> --- src/plugins/mpi/cray_shasta/mpi_cray_shasta.c | 59 +-------------------------- 1 file changed, 2 insertions(+), 57 deletions(-) diff --git a/src/plugins/mpi/cray_shasta/mpi_cray_shasta.c b/src/plugins/mpi/cray_shasta/mpi_cray_shasta.c index 1001422e5a..c8e705cec8 100644 --- a/src/plugins/mpi/cray_shasta/mpi_cray_shasta.c +++ b/src/plugins/mpi/cray_shasta/mpi_cray_shasta.c @@ -45,6 +45,7 @@ #include "src/common/slurm_xlator.h" #include "src/common/env.h" +#include "src/common/fd.h" #include "src/common/slurm_mpi.h" #include "src/slurmd/slurmstepd/slurmstepd_job.h" @@ -180,62 +181,6 @@ static void _set_pmi_port(char ***env) env_array_overwrite_fmt(env, "PMI_CONTROL_PORT", "%lu", pmi_port); } -/* - * Determine whether the given path is a directory - */ -static int _is_dir(char *path) -{ - struct stat stat_buf; - - if (stat(path, &stat_buf)) { - error("%s: Cannot stat %s: %m", plugin_type, path); - return 1; - } else if (!S_ISDIR(stat_buf.st_mode)) { - return 0; - } - return 1; -} - -/* - * Recursively remove a directory - */ -static int _rmdir_recursive(char *path) -{ - char nested_path[PATH_MAX]; - DIR *dp; - struct dirent *ent; - - if (!(dp = opendir(path))) { - error("%s: Can't open directory %s: %m", plugin_type, path); - return SLURM_ERROR; - } - - while ((ent = readdir(dp))) { - if (!xstrcmp(ent->d_name, ".") || - !xstrcmp(ent->d_name, "..")) { - /* skip special dir's */ - continue; - } - snprintf(nested_path, sizeof(nested_path), "%s/%s", path, - ent->d_name); - if (_is_dir(nested_path)) { - _rmdir_recursive(nested_path); - } else { - debug("%s: Removed file %s", plugin_type, nested_path); - unlink(nested_path); - } - } - closedir(dp); - - if (rmdir(path) == -1) { - error("%s: Can't remove directory %s: %m", - plugin_type, path); - return SLURM_ERROR; - } - - debug("%s: Removed directory %s", plugin_type, path); - return SLURM_SUCCESS; -} extern int p_mpi_hook_slurmstepd_prefork( const stepd_step_rec_t *job, char ***env) @@ -293,7 +238,7 @@ extern int fini(void) { // Remove application spool directory if (appdir) - _rmdir_recursive(appdir); + rmdir_recursive(appdir, true); // Free allocated storage xfree(appdir);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor