commit: 41cba96403764a1c6db5a35d9e9bd15b0f328200
parent b26b52d4f7479f0485d52dcc1ed2565d8dc397c9
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Tue, 22 Oct 2024 05:13:33 +0200
cmd/mktemp: add template to file/directory creation error
Diffstat:
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/cmd/mktemp.c b/cmd/mktemp.c
@@ -126,6 +126,9 @@ main(int argc, char *argv[])
printf("%s/", tmpdir);
}
+ char template_copy[PATH_MAX] = "";
+ memcpy(template_copy, template, PATH_MAX);
+
if(o_unsafe) return unsafe_mktemp(template);
if(o_create_dir)
@@ -134,8 +137,11 @@ main(int argc, char *argv[])
if(dir == NULL)
{
if(!o_quiet)
- fprintf(
- stderr, "%s: error: Failed creating random directory: %s\n", argv0, strerror(errno));
+ fprintf(stderr,
+ "%s: error: Failed creating random directory with template '%s': %s\n",
+ argv0,
+ template_copy,
+ strerror(errno));
return 1;
}
@@ -149,7 +155,11 @@ main(int argc, char *argv[])
if(fd < 0)
{
if(!o_quiet)
- fprintf(stderr, "%s: error: Failed creating random file: %s\n", argv0, strerror(errno));
+ fprintf(stderr,
+ "%s: error: Failed creating random file with template '%s': %s\n",
+ argv0,
+ template_copy,
+ strerror(errno));
return 1;
}