summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2015-10-31 23:56:35 +0000
committerThomas Adam <thomas@xteddy.org>2015-10-31 23:56:35 +0000
commitc975de2e07bdb21c85fc4f2c14a17bc00ca63aff (patch)
tree70ff97109da24dc7273b59df6ef6a9f298e16c48
parent17f6c3be8eeb0b67d07f916026dab918795c0317 (diff)
parentba7fb49fb9b972a03547381783abe91be3fcfa37 (diff)
Merge branch 'obsd-master'
Conflicts: server.c
-rw-r--r--client.c2
-rw-r--r--cmd-attach-session.c6
-rw-r--r--cmd-new-session.c7
-rw-r--r--cmd-new-window.c7
-rw-r--r--cmd-split-window.c7
-rw-r--r--proc.c1
-rw-r--r--server-client.c1
-rw-r--r--server.c3
-rw-r--r--tmux.h3
-rw-r--r--tty.c43
10 files changed, 25 insertions, 55 deletions
diff --git a/client.c b/client.c
index db29fdec..ccc58fb4 100644
--- a/client.c
+++ b/client.c
@@ -601,7 +601,7 @@ client_dispatch_wait(struct imsg *imsg)
fprintf(stderr, "protocol version mismatch "
"(client %d, server %u)\n", PROTOCOL_VERSION,
- imsg->hdr.peerid);
+ imsg->hdr.peerid & 0xff);
client_exitval = 1;
proc_exit(client_proc);
break;
diff --git a/cmd-attach-session.c b/cmd-attach-session.c
index b339b890..e5589277 100644
--- a/cmd-attach-session.c
+++ b/cmd-attach-session.c
@@ -99,12 +99,6 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
cwd = format_expand(ft, cflag);
format_free(ft);
- if (access(cwd, X_OK) != 0) {
- free((void *)cwd);
- cmdq_error(cmdq, "bad working directory: %s",
- strerror(errno));
- return (CMD_RETURN_ERROR);
- }
free((void *)s->cwd);
s->cwd = cwd;
}
diff --git a/cmd-new-session.c b/cmd-new-session.c
index 90bb2e0e..65dc6cf5 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -124,13 +124,6 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
NULL);
to_free = cwd = format_expand(ft, args_get(args, 'c'));
format_free(ft);
-
- if (access(cwd, X_OK) != 0) {
- free((void *)cwd);
- cmdq_error(cmdq, "bad working directory: %s",
- strerror(errno));
- return (CMD_RETURN_ERROR);
- }
} else if (c != NULL && c->session == NULL)
cwd = c->cwd;
else if ((c0 = cmd_find_client(cmdq, NULL, 1)) != NULL)
diff --git a/cmd-new-window.c b/cmd-new-window.c
index a5085fff..fb89e24f 100644
--- a/cmd-new-window.c
+++ b/cmd-new-window.c
@@ -99,13 +99,6 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
NULL);
cwd = format_expand(ft, args_get(args, 'c'));
format_free(ft);
-
- if (access(cwd, X_OK) != 0) {
- free((void *)cwd);
- cmdq_error(cmdq, "bad working directory: %s",
- strerror(errno));
- return (CMD_RETURN_ERROR);
- }
} else if (cmdq->client != NULL && cmdq->client->session == NULL)
cwd = cmdq->client->cwd;
else
diff --git a/cmd-split-window.c b/cmd-split-window.c
index b8a03953..d5b3e775 100644
--- a/cmd-split-window.c
+++ b/cmd-split-window.c
@@ -92,13 +92,6 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
NULL);
to_free = cwd = format_expand(ft, args_get(args, 'c'));
format_free(ft);
-
- if (access(cwd, X_OK) != 0) {
- free((void *)cwd);
- cmdq_error(cmdq, "bad working directory: %s",
- strerror(errno));
- return (CMD_RETURN_ERROR);
- }
} else if (cmdq->client != NULL && cmdq->client->session == NULL)
cwd = cmdq->client->cwd;
else
diff --git a/proc.c b/proc.c
index f7007935..30997a21 100644
--- a/proc.c
+++ b/proc.c
@@ -121,7 +121,6 @@ peer_check_version(struct tmuxpeer *peer, struct imsg *imsg)
return (-1);
}
- imsg->hdr.peerid >>= 8;
return (0);
}
diff --git a/server-client.c b/server-client.c
index a800a1aa..eeec51d0 100644
--- a/server-client.c
+++ b/server-client.c
@@ -1191,7 +1191,6 @@ server_client_dispatch_identify(struct client *c, struct imsg *imsg)
proc_send(c->peer, MSG_STDIN, -1, NULL, 0);
c->tty.fd = -1;
- c->tty.log_fd = -1;
close(c->fd);
c->fd = -1;
diff --git a/server.c b/server.c
index ca1b9b1f..3bd51cac 100644
--- a/server.c
+++ b/server.c
@@ -172,6 +172,9 @@ server_start(struct event_base *base, int lockfd, char *lockfile)
}
close(pair[0]);
+ if (debug_level > 3)
+ tty_create_log();
+
#ifdef __OpenBSD__
if (pledge("stdio rpath wpath cpath fattr unix recvfd proc exec tty "
"ps", NULL) != 0)
diff --git a/tmux.h b/tmux.h
index 6f54b1da..b16b27ff 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1105,8 +1105,6 @@ struct tty {
int fd;
struct bufferevent *event;
- int log_fd;
-
struct termios tio;
struct grid_cell cell;
@@ -1558,6 +1556,7 @@ void environ_update(const char *, struct environ *, struct environ *);
void environ_push(struct environ *);
/* tty.c */
+void tty_create_log(void);
void tty_init_termios(int, struct termios *, struct bufferevent *);
void tty_raw(struct tty *, const char *);
void tty_attributes(struct tty *, const struct grid_cell *,
diff --git a/tty.c b/tty.c
index 6b6343c8..c0ae79bb 100644
--- a/tty.c
+++ b/tty.c
@@ -31,6 +31,8 @@
#include "tmux.h"
+static int tty_log_fd = -1;
+
void tty_read_callback(struct bufferevent *, void *);
void tty_error_callback(struct bufferevent *, short, void *);
@@ -59,6 +61,18 @@ void tty_default_colours(struct grid_cell *, const struct window_pane *);
#define tty_pane_full_width(tty, ctx) \
((ctx)->xoff == 0 && screen_size_x((ctx)->wp->screen) >= (tty)->sx)
+void
+tty_create_log(void)
+{
+ char name[64];
+
+ xsnprintf(name, sizeof name, "tmux-out-%ld.log", (long)getpid());
+
+ tty_log_fd = open(name, O_WRONLY|O_CREAT|O_TRUNC, 0644);
+ if (tty_log_fd != -1 && fcntl(tty_log_fd, F_SETFD, FD_CLOEXEC) == -1)
+ fatal("fcntl failed");
+}
+
int
tty_init(struct tty *tty, struct client *c, int fd, char *term)
{
@@ -68,7 +82,6 @@ tty_init(struct tty *tty, struct client *c, int fd, char *term)
return (-1);
memset(tty, 0, sizeof *tty);
- tty->log_fd = -1;
if (term == NULL || *term == '\0')
tty->termname = xstrdup("unknown");
@@ -139,17 +152,6 @@ tty_set_size(struct tty *tty, u_int sx, u_int sy) {
int
tty_open(struct tty *tty, char **cause)
{
- char out[64];
- int fd;
-
- if (debug_level > 3) {
- xsnprintf(out, sizeof out, "tmux-out-%ld.log", (long) getpid());
- fd = open(out, O_WRONLY|O_CREAT|O_TRUNC, 0644);
- if (fd != -1 && fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
- fatal("fcntl failed");
- tty->log_fd = fd;
- }
-
tty->term = tty_term_find(tty->termname, tty->fd, cause);
if (tty->term == NULL) {
tty_close(tty);
@@ -308,11 +310,6 @@ tty_stop_tty(struct tty *tty)
void
tty_close(struct tty *tty)
{
- if (tty->log_fd != -1) {
- close(tty->log_fd);
- tty->log_fd = -1;
- }
-
if (event_initialized(&tty->key_timer))
evtimer_del(&tty->key_timer);
tty_stop_tty(tty);
@@ -406,8 +403,8 @@ tty_puts(struct tty *tty, const char *s)
return;
bufferevent_write(tty->event, s, strlen(s));
- if (tty->log_fd != -1)
- write(tty->log_fd, s, strlen(s));
+ if (tty_log_fd != -1)
+ write(tty_log_fd, s, strlen(s));
}
void
@@ -438,16 +435,16 @@ tty_putc(struct tty *tty, u_char ch)
tty->cx++;
}
- if (tty->log_fd != -1)
- write(tty->log_fd, &ch, 1);
+ if (tty_log_fd != -1)
+ write(tty_log_fd, &ch, 1);
}
void
tty_putn(struct tty *tty, const void *buf, size_t len, u_int width)
{
bufferevent_write(tty->event, buf, len);
- if (tty->log_fd != -1)
- write(tty->log_fd, buf, len);
+ if (tty_log_fd != -1)
+ write(tty_log_fd, buf, len);
tty->cx += width;
}