Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.2:Update
sarg
sarg-2.4.0-when-recursively-creating-a-director...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File sarg-2.4.0-when-recursively-creating-a-directory-make-sure-the.patch of Package sarg
From 0bede2a5b0924862c026694b29d3ac430218eaad Mon Sep 17 00:00:00 2001 From: Frederic Marchal <fmarchal@users.sourceforge.net> Date: Tue, 24 Dec 2019 13:56:01 +0100 Subject: [PATCH] When recursively creating a directory, make sure the path is a directory The function to recursively create a temporary directory was succeeding if the requested path existed even though the path was not a directory. Sarg was then failing with a somewhat unrelated error. Now, an error message is reported if the path to create exists and is not a directory. --- util.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/util.c b/util.c index 9bb7574..08fc029 100644 --- a/util.c +++ b/util.c @@ -422,6 +422,7 @@ bool my_mkdir(const char *name) int i; int chars; bool created = false; + struct stat st; if(!is_absolute(name)) { debuga(_("Invalid path \"%s\". Please, use absolute paths only.\n"),name); @@ -455,6 +456,19 @@ bool my_mkdir(const char *name) } created = true; } + if (!created) { + /* + * Check the final path is a directory (symlink to a directory is ok). + */ + if (stat(name, &st)) { + debuga(__FILE__,__LINE__,_("Cannot stat \"%s\": %s\n"), name, strerror(errno)); + exit(EXIT_FAILURE); + } + if (!S_ISDIR(st.st_mode)) { + debuga(__FILE__,__LINE__,_("Directory \"%s\" can't be created because the path already exists and is not a directory\n"), name); + exit(EXIT_FAILURE); + } + } return created; } -- 2.16.4
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