diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-03-27 11:24:19 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-03-27 11:24:19 +0000 |
commit | 677ede0b2017a13684d89796b3a54baf43185d02 (patch) | |
tree | f2782ea9629d2dea558e869fccf64abad63527a1 /usr.bin/tmux | |
parent | c7c73f63cda79a16f447d7091e5c368487df67e5 (diff) |
Add TMUX_TMPDIR variable to put the socket directory outside
TMPDIR. From Ben Boeckel.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/tmux.1 | 11 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.c | 10 |
2 files changed, 12 insertions, 9 deletions
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index cf6dd8c96ad..7a028687c02 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.354 2013/03/27 11:17:12 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.355 2013/03/27 11:24:18 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" @@ -141,11 +141,12 @@ session created, and continues to process the rest of the configuration file. .It Fl L Ar socket-name .Nm stores the server socket in a directory under -.Pa /tmp -(or +.Ev TMUX_TMPDIR , .Ev TMPDIR -if set); -the default socket is named +if it is unset, or +.Pa /tmp +if both are unset. +The default socket is named .Em default . This option allows a different socket name to be specified, allowing several independent diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c index 0a908d083f0..94c1f3cdaa7 100644 --- a/usr.bin/tmux/tmux.c +++ b/usr.bin/tmux/tmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.c,v 1.117 2013/03/27 11:17:12 nicm Exp $ */ +/* $OpenBSD: tmux.c,v 1.118 2013/03/27 11:24:18 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -164,10 +164,12 @@ makesocketpath(const char *label) u_int uid; uid = getuid(); - if ((s = getenv("TMPDIR")) == NULL || *s == '\0') - xsnprintf(base, sizeof base, "%s/tmux-%u", _PATH_TMP, uid); - else + if ((s = getenv("TMUX_TMPDIR")) != NULL && *s != '\0') + xsnprintf(base, sizeof base, "%s/", s); + else if ((s = getenv("TMPDIR")) != NULL && *s != '\0') xsnprintf(base, sizeof base, "%s/tmux-%u", s, uid); + else + xsnprintf(base, sizeof base, "%s/tmux-%u", _PATH_TMP, uid); if (mkdir(base, S_IRWXU) != 0 && errno != EEXIST) return (NULL); |