diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-10-10 12:03:23 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-10-10 12:03:23 +0000 |
commit | b7c03fa9d1013400ab642624bbdf7344154c5177 (patch) | |
tree | 7be5c55b88a7d50528c79865d291d0bd0cdd612a /usr.bin/tmux | |
parent | 16100c012ea7d914cb33cf2e80ab387b3b9851af (diff) |
Don't treat TMUX_TMPDIR as a potential file
The point of setting TMUX_TMPDIR is to then make any labels from -L go
to that directory. In the case of makesocketpath() with no TMUX_TMPDIR
set, would set both the path and the default socket to a file. The
checking of the permissions on the file worked fine in that case, but
when TMUX_TMPDIR is set, won't work on a directory.
This fixes the problem by ensuring the check on the permissions is
performed on directories only.
By Thomas Adam.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/tmux.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c index 597d2ea0799..6689d1095ad 100644 --- a/usr.bin/tmux/tmux.c +++ b/usr.bin/tmux/tmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.c,v 1.122 2013/10/05 10:40:49 nicm Exp $ */ +/* $OpenBSD: tmux.c,v 1.123 2013/10/10 12:03:22 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -189,7 +189,8 @@ makesocketpath(const char *label) errno = ENOTDIR; return (NULL); } - if (sb.st_uid != uid || (sb.st_mode & (S_IRWXG|S_IRWXO)) != 0) { + if (sb.st_uid != uid || (!S_ISDIR(sb.st_mode) && + sb.st_mode & (S_IRWXG|S_IRWXO)) != 0) { errno = EACCES; return (NULL); } @@ -389,7 +390,8 @@ main(int argc, char **argv) /* -L or default set. */ if (label != NULL) { if ((path = makesocketpath(label)) == NULL) { - fprintf(stderr, "can't create socket\n"); + fprintf(stderr, "can't create socket: %s\n", + strerror(errno)); exit(1); } } |