From 677ede0b2017a13684d89796b3a54baf43185d02 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 27 Mar 2013 11:24:19 +0000 Subject: Add TMUX_TMPDIR variable to put the socket directory outside TMPDIR. From Ben Boeckel. --- usr.bin/tmux/tmux.1 | 11 ++++++----- usr.bin/tmux/tmux.c | 10 ++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'usr.bin/tmux') 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 .\" @@ -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 @@ -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); -- cgit v1.2.3