diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2021-07-06 08:26:01 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2021-07-06 08:26:01 +0000 |
commit | ef144d8658923d8fc94398b9fc957f20cc23395d (patch) | |
tree | b9189df9f7bec85c15f8655987103b53d11cddf7 /usr.bin | |
parent | aff3b927d4cb825b01830b5212cac314f2120a43 (diff) |
Improve error reporting when the tmux /tmp directory cannot be created
or used, GitHub issue 2765 from Uwe Kleine-Koenig.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/tmux.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c index 01a992ac715..a76e966b95e 100644 --- a/usr.bin/tmux/tmux.c +++ b/usr.bin/tmux/tmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.c,v 1.207 2021/06/10 07:52:29 nicm Exp $ */ +/* $OpenBSD: tmux.c,v 1.208 2021/07/06 08:26:00 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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); } |