summaryrefslogtreecommitdiffstats
path: root/tmux.c
diff options
context:
space:
mode:
authornicm <nicm>2021-07-06 08:26:00 +0000
committernicm <nicm>2021-07-06 08:26:00 +0000
commit32f2d9d089ced7d693aa412821f1d66134877cf0 (patch)
tree397d09c656d6bc88f16f980c566b18cd19fd74d8 /tmux.c
parent35c2958ae4caf70a3074f59fbceeb24cfe82f902 (diff)
Improve error reporting when the tmux /tmp directory cannot be created
or used, GitHub issue 2765 from Uwe Kleine-Koenig.
Diffstat (limited to 'tmux.c')
-rw-r--r--tmux.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/tmux.c b/tmux.c
index 16877407..55ab9751 100644
--- a/tmux.c
+++ b/tmux.c
@@ -211,16 +211,22 @@ make_label(const char *label, char **cause)
free(paths);
xasprintf(&base, "%s/tmux-%ld", path, (long)uid);
- if (mkdir(base, S_IRWXU) != 0 && errno != EEXIST)
+ if (mkdir(base, S_IRWXU) != 0 && errno != EEXIST) {
+ xasprintf(cause, "couldn't create directory %s (%s)", base,
+ strerror(errno));
goto fail;
- if (lstat(base, &sb) != 0)
+ }
+ if (lstat(base, &sb) != 0) {
+ xasprintf(cause, "couldn't read directory %s (%s)", base,
+ strerror(errno));
goto fail;
+ }
if (!S_ISDIR(sb.st_mode)) {
- errno = ENOTDIR;
+ xasprintf(cause, "%s is not a directory", base);
goto fail;
}
if (sb.st_uid != uid || (sb.st_mode & S_IRWXO) != 0) {
- errno = EACCES;
+ xasprintf(cause, "directory %s has unsafe permissions", base);
goto fail;
}
xasprintf(&path, "%s/%s", base, label);
@@ -228,7 +234,6 @@ make_label(const char *label, char **cause)
return (path);
fail:
- xasprintf(cause, "error creating %s (%s)", base, strerror(errno));
free(base);
return (NULL);
}