mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 01:02:24 +00:00
uxpty: give pty_backend_create a struct ssh_ttymodes.
This will be applied to the pty's termios settings at creation time, superseding the default settings uxpty has always used. It works by including the new sshttymodes.h with TTYMODES_LOCAL_ONLY defined, so that modes not supported by a particular Unix system are automatically quietly ignored. Of course, a struct ssh_ttymodes always has the option of representing "please make no change to the defaults", and of course, that's precisely what is done by the one that pty_init constructs for clients that aren't calling pty_backend_create directly.
This commit is contained in:
parent
105672e324
commit
f2edea161a
40
unix/uxpty.c
40
unix/uxpty.c
@ -21,8 +21,10 @@
|
|||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <termios.h>
|
||||||
|
|
||||||
#include "putty.h"
|
#include "putty.h"
|
||||||
|
#include "ssh.h"
|
||||||
#include "tree234.h"
|
#include "tree234.h"
|
||||||
|
|
||||||
#ifndef OMIT_UTMP
|
#ifndef OMIT_UTMP
|
||||||
@ -739,6 +741,35 @@ static void pty_uxsel_setup(Pty *pty)
|
|||||||
uxsel_set(pty_signal_pipe[0], 1, pty_select_result);
|
uxsel_set(pty_signal_pipe[0], 1, pty_select_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void copy_ttymodes_into_termios(
|
||||||
|
struct termios *attrs, struct ssh_ttymodes modes)
|
||||||
|
{
|
||||||
|
#define TTYMODE_CHAR(name, ssh_opcode, cc_index) { \
|
||||||
|
if (modes.have_mode[ssh_opcode]) \
|
||||||
|
attrs->c_cc[cc_index] = modes.mode_val[ssh_opcode]; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define TTYMODE_FLAG(flagval, ssh_opcode, field, flagmask) { \
|
||||||
|
if (modes.have_mode[ssh_opcode]) { \
|
||||||
|
attrs->c_##field##flag &= ~flagmask; \
|
||||||
|
if (modes.mode_val[ssh_opcode]) \
|
||||||
|
attrs->c_##field##flag |= flagval; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define TTYMODES_LOCAL_ONLY /* omit any that this platform doesn't know */
|
||||||
|
#include "sshttymodes.h"
|
||||||
|
|
||||||
|
#undef TTYMODES_LOCAL_ONLY
|
||||||
|
#undef TTYMODE_CHAR
|
||||||
|
#undef TTYMODE_FLAG
|
||||||
|
|
||||||
|
if (modes.have_mode[TTYMODE_ISPEED])
|
||||||
|
cfsetispeed(attrs, modes.mode_val[TTYMODE_ISPEED]);
|
||||||
|
if (modes.have_mode[TTYMODE_OSPEED])
|
||||||
|
cfsetospeed(attrs, modes.mode_val[TTYMODE_OSPEED]);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The main setup function for the pty back end. This doesn't match
|
* The main setup function for the pty back end. This doesn't match
|
||||||
* the signature of backend_init(), partly because it has to be able
|
* the signature of backend_init(), partly because it has to be able
|
||||||
@ -748,7 +779,8 @@ static void pty_uxsel_setup(Pty *pty)
|
|||||||
* and port numbers.
|
* and port numbers.
|
||||||
*/
|
*/
|
||||||
Backend *pty_backend_create(
|
Backend *pty_backend_create(
|
||||||
Seat *seat, LogContext *logctx, Conf *conf, char **argv)
|
Seat *seat, LogContext *logctx, Conf *conf, char **argv,
|
||||||
|
struct ssh_ttymodes ttymodes)
|
||||||
{
|
{
|
||||||
int slavefd;
|
int slavefd;
|
||||||
pid_t pid, pgrp;
|
pid_t pid, pgrp;
|
||||||
@ -902,6 +934,8 @@ Backend *pty_backend_create(
|
|||||||
attrs.c_iflag &= ~IUTF8;
|
attrs.c_iflag &= ~IUTF8;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
copy_ttymodes_into_termios(&attrs, ttymodes);
|
||||||
|
|
||||||
tcsetattr(0, TCSANOW, &attrs);
|
tcsetattr(0, TCSANOW, &attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1058,7 +1092,9 @@ static const char *pty_init(Seat *seat, Backend **backend_handle,
|
|||||||
const char *host, int port,
|
const char *host, int port,
|
||||||
char **realhost, int nodelay, int keepalive)
|
char **realhost, int nodelay, int keepalive)
|
||||||
{
|
{
|
||||||
*backend_handle= pty_backend_create(seat, logctx, conf, pty_argv);
|
struct ssh_ttymodes modes;
|
||||||
|
memset(&modes, 0, sizeof(modes));
|
||||||
|
*backend_handle= pty_backend_create(seat, logctx, conf, pty_argv, modes);
|
||||||
*realhost = dupstr("");
|
*realhost = dupstr("");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user