Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/tmux merge conflicts.
details: https://anonhg.NetBSD.org/src/rev/a8f438ab1927
branches: trunk
changeset: 342833:a8f438ab1927
user: christos <christos%NetBSD.org@localhost>
date: Sun Jan 10 19:02:13 2016 +0000
description:
merge conflicts.
diffstat:
external/bsd/tmux/dist/client.c | 251 +++-
external/bsd/tmux/dist/clock.c | 166 ---
external/bsd/tmux/dist/cmd-capture-pane.c | 94 +-
external/bsd/tmux/dist/cmd-choose-list.c | 97 --
external/bsd/tmux/dist/cmd-clock-mode.c | 50 -
external/bsd/tmux/dist/cmd-delete-buffer.c | 65 -
external/bsd/tmux/dist/cmd-display-message.c | 16 +-
external/bsd/tmux/dist/cmd-has-session.c | 47 -
external/bsd/tmux/dist/cmd-if-shell.c | 85 +-
external/bsd/tmux/dist/cmd-link-window.c | 64 -
external/bsd/tmux/dist/cmd-list-commands.c | 54 -
external/bsd/tmux/dist/cmd-load-buffer.c | 2 +-
external/bsd/tmux/dist/cmd-new-window.c | 2 +-
external/bsd/tmux/dist/cmd-paste-buffer.c | 73 +-
external/bsd/tmux/dist/cmd-send-keys.c | 49 +-
external/bsd/tmux/dist/cmd-show-messages.c | 91 +-
external/bsd/tmux/dist/cmd-split-window.c | 2 +-
external/bsd/tmux/dist/cmd-string.c | 21 +-
external/bsd/tmux/dist/cmd-suspend-client.c | 55 -
external/bsd/tmux/dist/cmd-unlink-window.c | 69 -
external/bsd/tmux/dist/cmd-wait-for.c | 124 +-
external/bsd/tmux/dist/colour.c | 400 ++++++--
external/bsd/tmux/dist/compat/imsg-buffer.c | 47 +-
external/bsd/tmux/dist/compat/imsg.c | 108 +-
external/bsd/tmux/dist/environ.c | 25 +-
external/bsd/tmux/dist/examples/tmux_backup.sh | 81 -
external/bsd/tmux/dist/format.c | 802 +++++++++++++---
external/bsd/tmux/dist/grid.c | 149 +-
external/bsd/tmux/dist/input-keys.c | 126 +-
external/bsd/tmux/dist/input.c | 397 +++++--
external/bsd/tmux/dist/job.c | 23 +-
external/bsd/tmux/dist/key-bindings.c | 2 +-
external/bsd/tmux/dist/log.c | 158 +--
external/bsd/tmux/dist/options.c | 22 +-
external/bsd/tmux/dist/paste.c | 2 +-
external/bsd/tmux/dist/screen-write.c | 34 +-
external/bsd/tmux/dist/screen.c | 39 +-
external/bsd/tmux/dist/server-fn.c | 90 +-
external/bsd/tmux/dist/server-window.c | 243 -----
external/bsd/tmux/dist/session.c | 172 +++-
external/bsd/tmux/dist/status.c | 839 +++++++++--------
external/bsd/tmux/dist/tmux.1 | 1139 +++++++++++++++--------
external/bsd/tmux/dist/tmux.c | 128 +-
external/bsd/tmux/dist/tmux.h | 1093 ++++++++++------------
external/bsd/tmux/dist/tty-acs.c | 4 +-
external/bsd/tmux/dist/tty-keys.c | 249 ++---
external/bsd/tmux/dist/tty-term.c | 447 +++++---
external/bsd/tmux/dist/window-copy.c | 609 +++++++----
external/bsd/tmux/dist/window.c | 724 ++++++++------
external/bsd/tmux/usr.bin/tmux/Makefile | 36 +-
50 files changed, 5151 insertions(+), 4514 deletions(-)
diffs (truncated from 15717 to 300 lines):
diff -r c113d529bfcc -r a8f438ab1927 external/bsd/tmux/dist/client.c
--- a/external/bsd/tmux/dist/client.c Sun Jan 10 17:55:36 2016 +0000
+++ b/external/bsd/tmux/dist/client.c Sun Jan 10 19:02:13 2016 +0000
@@ -1,4 +1,4 @@
-/* Id */
+/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm%users.sourceforge.net@localhost>
@@ -26,13 +26,14 @@
#include <errno.h>
#include <event.h>
#include <fcntl.h>
-#include <pwd.h>
+#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "tmux.h"
+int client_flags;
struct imsgbuf client_ibuf;
struct event client_event;
struct event client_stdin;
@@ -51,9 +52,10 @@
const char *client_exitsession;
int client_attached;
+__dead void client_exec(const char *);
int client_get_lock(char *);
-int client_connect(char *, int);
-void client_send_identify(int);
+int client_connect(struct event_base *, char *, int);
+void client_send_identify(const char *, int);
int client_write_one(enum msgtype, int, const void *, size_t);
int client_write_server(enum msgtype, const void *, size_t);
void client_update_event(void);
@@ -62,7 +64,7 @@
void client_write(int, const char *, size_t);
void client_callback(int, short, void *);
int client_dispatch_attached(void);
-int client_dispatch_wait(void *);
+int client_dispatch_wait(void);
const char *client_exit_message(void);
/*
@@ -78,25 +80,30 @@
if ((lockfd = open(lockfile, O_WRONLY|O_CREAT, 0600)) == -1)
fatal("open failed");
+ log_debug("lock file is %s", lockfile);
- if (lockf(lockfd, F_TLOCK, 0) == -1 && errno == EAGAIN) {
- while (lockf(lockfd, F_LOCK, 0) == -1 && errno == EINTR)
+ if (flock(lockfd, LOCK_EX|LOCK_NB) == -1) {
+ log_debug("flock failed: %s", strerror(errno));
+ if (errno != EAGAIN)
+ return (lockfd);
+ while (flock(lockfd, LOCK_EX) == -1 && errno == EINTR)
/* nothing */;
close(lockfd);
return (-1);
}
+ log_debug("flock succeeded");
return (lockfd);
}
/* Connect client to server. */
int
-client_connect(char *path, int start_server)
+client_connect(struct event_base *base, char *path, int start_server)
{
struct sockaddr_un sa;
size_t size;
- int fd, lockfd;
- char *lockfile;
+ int fd, lockfd = -1, locked = 0;
+ char *lockfile = NULL;
memset(&sa, 0, sizeof sa);
sa.sun_family = AF_UNIX;
@@ -105,37 +112,60 @@
errno = ENAMETOOLONG;
return (-1);
}
+ log_debug("socket is %s", path);
retry:
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
fatal("socket failed");
- if (connect(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) {
+ log_debug("trying connect");
+ if (connect(fd, (struct sockaddr *) &sa, sizeof(sa)) == -1) {
+ log_debug("connect failed: %s", strerror(errno));
if (errno != ECONNREFUSED && errno != ENOENT)
goto failed;
if (!start_server)
goto failed;
close(fd);
- xasprintf(&lockfile, "%s.lock", path);
- if ((lockfd = client_get_lock(lockfile)) == -1) {
- free(lockfile);
+ if (!locked) {
+ xasprintf(&lockfile, "%s.lock", path);
+ if ((lockfd = client_get_lock(lockfile)) == -1) {
+ log_debug("didn't get lock");
+ free(lockfile);
+ goto retry;
+ }
+ log_debug("got lock");
+
+ /*
+ * Always retry at least once, even if we got the lock,
+ * because another client could have taken the lock,
+ * started the server and released the lock between our
+ * connect() and flock().
+ */
+ locked = 1;
goto retry;
}
+
if (unlink(path) != 0 && errno != ENOENT) {
free(lockfile);
close(lockfd);
return (-1);
}
- fd = server_start(lockfd, lockfile);
+ fd = server_start(base, lockfd, lockfile);
+ }
+
+ if (locked) {
free(lockfile);
close(lockfd);
}
-
setblocking(fd, 0);
return (fd);
failed:
+ if (locked) {
+ free(lockfile);
+ close(lockfd);
+ }
close(fd);
return (-1);
}
@@ -179,18 +209,22 @@
/* Client main loop. */
int
-client_main(int argc, char **argv, int flags)
+client_main(struct event_base *base, int argc, char **argv, int flags)
{
struct cmd *cmd;
struct cmd_list *cmdlist;
struct msg_command_data *data;
- int cmdflags, fd, i;
+ int cmdflags, fd, i, cwd;
+ const char* ttynam;
pid_t ppid;
enum msgtype msg;
char *cause;
struct termios tio, saved_tio;
size_t size;
+ /* Save the flags. */
+ client_flags = flags;
+
/* Set up the initial command. */
cmdflags = 0;
if (shell_cmd != NULL) {
@@ -198,7 +232,7 @@
cmdflags = CMD_STARTSERVER;
} else if (argc == 0) {
msg = MSG_COMMAND;
- cmdflags = CMD_STARTSERVER|CMD_CANTNEST;
+ cmdflags = CMD_STARTSERVER;
} else {
msg = MSG_COMMAND;
@@ -216,31 +250,51 @@
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
if (cmd->entry->flags & CMD_STARTSERVER)
cmdflags |= CMD_STARTSERVER;
- if (cmd->entry->flags & CMD_CANTNEST)
- cmdflags |= CMD_CANTNEST;
}
cmd_list_free(cmdlist);
}
- /*
- * Check if this could be a nested session, if the command can't nest:
- * if the socket path matches $TMUX, this is probably the same server.
- */
- if (shell_cmd == NULL && environ_path != NULL &&
- (cmdflags & CMD_CANTNEST) &&
- strcmp(socket_path, environ_path) == 0) {
- fprintf(stderr, "sessions should be nested with care, "
- "unset $TMUX to force\n");
+ /* Establish signal handlers. */
+ set_signals(client_signal);
+
+ /* Initialize the client socket and start the server. */
+ fd = client_connect(base, socket_path, cmdflags & CMD_STARTSERVER);
+ if (fd == -1) {
+ if (errno == ECONNREFUSED) {
+ fprintf(stderr, "no server running on %s\n",
+ socket_path);
+ } else {
+ fprintf(stderr, "error connecting to %s (%s)\n",
+ socket_path, strerror(errno));
+ }
return (1);
}
- /* Initialise the client socket and start the server. */
- fd = client_connect(socket_path, cmdflags & CMD_STARTSERVER);
- if (fd == -1) {
- fprintf(stderr, "failed to connect to server: %s\n",
- strerror(errno));
- return (1);
- }
+ /* Save these before pledge(). */
+ if ((cwd = open(".", O_RDONLY)) == -1)
+ cwd = open("/", O_RDONLY);
+ if ((ttynam = ttyname(STDIN_FILENO)) == NULL)
+ ttynam = "";
+
+#ifdef __OpenBSD__
+ /*
+ * Drop privileges for client. "proc exec" is needed for -c and for
+ * locking (which uses system(3)).
+ *
+ * "tty" is needed to restore termios(4) and also for some reason -CC
+ * does not work properly without it (input is not recognised).
+ *
+ * "sendfd" is dropped later in client_dispatch_wait().
+ */
+ if (pledge("stdio unix sendfd proc exec tty", NULL) != 0)
+ fatal("pledge failed");
+#endif
+
+ /* Free stuff that is not used in the client. */
+ options_free(&global_options);
+ options_free(&global_s_options);
+ options_free(&global_w_options);
+ environ_free(&global_environ);
/* Set process title, log and signals now this is the client. */
#ifdef HAVE_SETPROCTITLE
@@ -250,13 +304,13 @@
/* Create imsg. */
imsg_init(&client_ibuf, fd);
- event_set(&client_event, fd, EV_READ, client_callback, shell_cmd);
+ event_set(&client_event, fd, EV_READ, client_callback, NULL);
/* Create stdin handler. */
setblocking(STDIN_FILENO, 0);
event_set(&client_stdin, STDIN_FILENO, EV_READ|EV_PERSIST,
client_stdin_callback, NULL);
- if (flags & CLIENT_CONTROLCONTROL) {
+ if (client_flags & CLIENT_CONTROLCONTROL) {
if (tcgetattr(STDIN_FILENO, &saved_tio) != 0) {
fprintf(stderr, "tcgetattr failed: %s\n",
strerror(errno));
@@ -276,11 +330,8 @@
tcsetattr(STDIN_FILENO, TCSANOW, &tio);
}
- /* Establish signal handlers. */
- set_signals(client_signal);
-
/* Send identify messages. */
- client_send_identify(flags);
+ client_send_identify(ttynam, cwd); /* closes cwd */
/* Send first command. */
if (msg == MSG_COMMAND) {
@@ -292,7 +343,7 @@
/* Prepare command for server. */
data->argc = argc;
- if (cmd_pack_argv(argc, argv, (char*)(data + 1), size) != 0) {
+ if (cmd_pack_argv(argc, argv, (char *)(data + 1), size) != 0) {
fprintf(stderr, "command too long\n");
free(data);
return (1);
@@ -315,13 +366,13 @@
/* Print the exit message, if any, and exit. */
if (client_attached) {
- if (client_exitreason != CLIENT_EXIT_NONE && !login_shell)
+ if (client_exitreason != CLIENT_EXIT_NONE)
printf("[%s]\n", client_exit_message());
Home |
Main Index |
Thread Index |
Old Index