summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-08-12 09:14:26 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-08-12 09:14:26 +0000
commit055698d913f2dab1954c11d1e1519de672098990 (patch)
tree0e69bd3280e4c3c208d481c63bd90c9c7b473655
parentaf3ddbaa22c79abbc7ab905ee17b964ebca7fc30 (diff)
When started as the shell, __progname contains a leading -, so hardcode "tmux"
for socket path and log files, and strip it when working out the shell.
-rw-r--r--usr.bin/tmux/tmux.c7
-rw-r--r--usr.bin/tmux/window.c8
2 files changed, 9 insertions, 6 deletions
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c
index ccdf009ca83..6fc6028e299 100644
--- a/usr.bin/tmux/tmux.c
+++ b/usr.bin/tmux/tmux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.c,v 1.31 2009/08/11 17:18:35 nicm Exp $ */
+/* $OpenBSD: tmux.c,v 1.32 2009/08/12 09:14:25 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -79,8 +79,7 @@ logfile(const char *name)
log_close();
if (debug_level > 0) {
- xasprintf(
- &path, "%s-%s-%ld.log", __progname, name, (long) getpid());
+ xasprintf(&path, "tmux-%s-%ld.log", name, (long) getpid());
log_open_file(debug_level, path);
xfree(path);
}
@@ -184,7 +183,7 @@ makesockpath(const char *label)
u_int uid;
uid = getuid();
- xsnprintf(base, MAXPATHLEN, "%s/%s-%d", _PATH_TMP, __progname, uid);
+ xsnprintf(base, MAXPATHLEN, "%s/tmux-%d", _PATH_TMP, uid);
if (mkdir(base, S_IRWXU) != 0 && errno != EEXIST)
return (NULL);
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index 11ff9ec610c..71e0622428e 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.19 2009/08/11 21:28:11 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.20 2009/08/12 09:14:25 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -62,6 +62,7 @@ const char *
window_default_command(void)
{
const char *shell, *ptr;
+ char *progname;
struct passwd *pw;
shell = getenv("SHELL");
@@ -81,7 +82,10 @@ found:
ptr++;
else
ptr = shell;
- if (strcmp(ptr, __progname) == 0)
+ progname = __progname;
+ if (*progname == '-')
+ progname++;
+ if (strcmp(ptr, progname) == 0)
return (_PATH_BSHELL);
return (shell);
}