=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/client.c,v retrieving revision 1.154 retrieving revision 1.155 diff -c -r1.154 -r1.155 *** src/usr.bin/tmux/client.c 2021/02/12 06:52:48 1.154 --- src/usr.bin/tmux/client.c 2021/02/17 07:18:36 1.155 *************** *** 1,4 **** ! /* $OpenBSD: client.c,v 1.154 2021/02/12 06:52:48 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: client.c,v 1.155 2021/02/17 07:18:36 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 62,68 **** static int client_get_lock(char *); static int client_connect(struct event_base *, const char *, uint64_t); ! static void client_send_identify(const char *, const char *, int); static void client_signal(int); static void client_dispatch(struct imsg *, void *); static void client_dispatch_attached(struct imsg *); --- 62,69 ---- static int client_get_lock(char *); static int client_connect(struct event_base *, const char *, uint64_t); ! static void client_send_identify(const char *, const char *, ! char **, u_int, const char *, int); static void client_signal(int); static void client_dispatch(struct imsg *, void *); static void client_dispatch_attached(struct imsg *); *************** *** 235,247 **** struct cmd_parse_result *pr; struct msg_command *data; int fd, i; ! const char *ttynam, *cwd; pid_t ppid; enum msgtype msg; struct termios tio, saved_tio; size_t size, linesize = 0; ssize_t linelen; ! char *line = NULL; /* Ignore SIGCHLD now or daemon() in the server will leave a zombie. */ signal(SIGCHLD, SIG_IGN); --- 236,249 ---- struct cmd_parse_result *pr; struct msg_command *data; int fd, i; ! const char *ttynam, *termname, *cwd; pid_t ppid; enum msgtype msg; struct termios tio, saved_tio; size_t size, linesize = 0; ssize_t linelen; ! char *line = NULL, **caps = NULL, *cause; ! u_int ncaps = 0; /* Ignore SIGCHLD now or daemon() in the server will leave a zombie. */ signal(SIGCHLD, SIG_IGN); *************** *** 297,302 **** --- 299,306 ---- cwd = "/"; if ((ttynam = ttyname(STDIN_FILENO)) == NULL) ttynam = ""; + if ((termname = getenv("TERM")) == NULL) + termname = ""; /* * Drop privileges for client. "proc exec" is needed for -c and for *************** *** 312,317 **** --- 316,331 ---- NULL) != 0) fatal("pledge failed"); + /* Load terminfo entry if any. */ + if (isatty(STDIN_FILENO) && + *termname != '\0' && + tty_term_read_list(termname, STDIN_FILENO, &caps, &ncaps, + &cause) != 0) { + fprintf(stderr, "%s\n", cause); + free(cause); + return (1); + } + /* Free stuff that is not used in the client. */ if (ptm_fd != -1) close(ptm_fd); *************** *** 340,346 **** } /* Send identify messages. */ ! client_send_identify(ttynam, cwd, feat); /* Send first command. */ if (msg == MSG_COMMAND) { --- 354,361 ---- } /* Send identify messages. */ ! client_send_identify(ttynam, termname, caps, ncaps, cwd, feat); ! tty_term_free_list(caps, ncaps); /* Send first command. */ if (msg == MSG_COMMAND) { *************** *** 423,448 **** /* Send identify messages to server. */ static void ! client_send_identify(const char *ttynam, const char *cwd, int feat) { ! const char *s; ! char **ss; ! size_t sslen; ! int fd, flags = client_flags; ! pid_t pid; proc_send(client_peer, MSG_IDENTIFY_FLAGS, -1, &flags, sizeof flags); proc_send(client_peer, MSG_IDENTIFY_LONGFLAGS, -1, &client_flags, sizeof client_flags); ! if ((s = getenv("TERM")) == NULL) ! s = ""; ! proc_send(client_peer, MSG_IDENTIFY_TERM, -1, s, strlen(s) + 1); proc_send(client_peer, MSG_IDENTIFY_FEATURES, -1, &feat, sizeof feat); proc_send(client_peer, MSG_IDENTIFY_TTYNAME, -1, ttynam, strlen(ttynam) + 1); proc_send(client_peer, MSG_IDENTIFY_CWD, -1, cwd, strlen(cwd) + 1); if ((fd = dup(STDIN_FILENO)) == -1) fatal("dup failed"); --- 438,468 ---- /* Send identify messages to server. */ static void ! client_send_identify(const char *ttynam, const char *termname, char **caps, ! u_int ncaps, const char *cwd, int feat) { ! char **ss; ! size_t sslen; ! int fd, flags = client_flags; ! pid_t pid; ! u_int i; proc_send(client_peer, MSG_IDENTIFY_FLAGS, -1, &flags, sizeof flags); proc_send(client_peer, MSG_IDENTIFY_LONGFLAGS, -1, &client_flags, sizeof client_flags); ! proc_send(client_peer, MSG_IDENTIFY_TERM, -1, termname, ! strlen(termname) + 1); proc_send(client_peer, MSG_IDENTIFY_FEATURES, -1, &feat, sizeof feat); proc_send(client_peer, MSG_IDENTIFY_TTYNAME, -1, ttynam, strlen(ttynam) + 1); proc_send(client_peer, MSG_IDENTIFY_CWD, -1, cwd, strlen(cwd) + 1); + + for (i = 0; i < ncaps; i++) { + proc_send(client_peer, MSG_IDENTIFY_TERMINFO, -1, + caps[i], strlen(caps[i]) + 1); + } if ((fd = dup(STDIN_FILENO)) == -1) fatal("dup failed");