mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
First stab at the ability to compile puttytel.exe, an SSH-free
variant which is patent-safe in the US and legal in France and Russia. This is a horrible hack in some ways: it's shown up serious deficiencies in the module boundaries. Needs further work, probably once the SSH implementations are recombined. [originally from svn r410]
This commit is contained in:
parent
7aa84c296f
commit
96dbf9c6e6
91
Makefile
91
Makefile
@ -37,23 +37,31 @@ CFLAGS = /nologo /W3 /YX /O2 /Yd /D_WINDOWS /DDEBUG /ML /Fd
|
||||
OBJ=obj
|
||||
RES=res
|
||||
|
||||
##-- objects putty puttytel
|
||||
GOBJS1 = window.$(OBJ) windlg.$(OBJ) terminal.$(OBJ) telnet.$(OBJ) raw.$(OBJ)
|
||||
GOBJS2 = xlat.$(OBJ) ldisc.$(OBJ) sizetip.$(OBJ)
|
||||
##-- objects putty
|
||||
POBJS1 = window.$(OBJ) windlg.$(OBJ) terminal.$(OBJ) telnet.$(OBJ) raw.$(OBJ)
|
||||
POBJS2 = xlat.$(OBJ) ldisc.$(OBJ) sizetip.$(OBJ) ssh.$(OBJ)
|
||||
POBJS = ssh.$(OBJ) be_all.$(OBJ)
|
||||
##-- objects puttytel
|
||||
TOBJS = be_nossh.$(OBJ)
|
||||
##-- objects pscp
|
||||
SOBJS = scp.$(OBJ) windlg.$(OBJ) scpssh.$(OBJ)
|
||||
SOBJS = scp.$(OBJ) windlg.$(OBJ) scpssh.$(OBJ) be_none.$(OBJ)
|
||||
##-- objects putty puttytel pscp
|
||||
MOBJS = misc.$(OBJ) version.$(OBJ)
|
||||
##-- objects putty pscp
|
||||
OBJS1 = misc.$(OBJ) noise.$(OBJ)
|
||||
OBJS2 = sshcrc.$(OBJ) sshdes.$(OBJ) sshmd5.$(OBJ) sshrsa.$(OBJ) sshrand.$(OBJ)
|
||||
OBJS3 = sshsha.$(OBJ) sshblowf.$(OBJ) version.$(OBJ)
|
||||
OBJS1 = sshcrc.$(OBJ) sshdes.$(OBJ) sshmd5.$(OBJ) sshrsa.$(OBJ) sshrand.$(OBJ)
|
||||
OBJS2 = sshsha.$(OBJ) sshblowf.$(OBJ) noise.$(OBJ)
|
||||
##-- resources putty
|
||||
PRESRC = win_res.$(RES)
|
||||
##-- resources puttytel
|
||||
TRESRC = nossh_res.$(RES)
|
||||
##-- resources pscp
|
||||
SRESRC = scp.$(RES)
|
||||
##--
|
||||
|
||||
##-- gui-apps
|
||||
# putty
|
||||
# puttytel
|
||||
##-- console-apps
|
||||
# pscp
|
||||
##--
|
||||
@ -61,34 +69,48 @@ SRESRC = scp.$(RES)
|
||||
LIBS1 = advapi32.lib user32.lib gdi32.lib
|
||||
LIBS2 = wsock32.lib comctl32.lib comdlg32.lib
|
||||
|
||||
all: putty.exe pscp.exe
|
||||
all: putty.exe puttytel.exe pscp.exe
|
||||
|
||||
putty.exe: $(POBJS1) $(POBJS2) $(OBJS1) $(OBJS2) $(OBJS3) $(PRESRC) link.rsp
|
||||
link /debug -out:putty.exe @link.rsp
|
||||
putty.exe: $(GOBJS1) $(GOBJS2) $(POBJS) $(MOBJS) $(OBJS1) $(OBJS2) $(PRESRC) putty.rsp
|
||||
link /debug -out:putty.exe @putty.rsp
|
||||
|
||||
pscp.exe: $(SOBJS) $(OBJS1) $(OBJS2) $(OBJS3) $(SRESRC) scp.rsp
|
||||
link /debug -out:pscp.exe @scp.rsp
|
||||
puttytel.exe: $(GOBJS1) $(GOBJS2) $(TOBJS) $(MOBJS) $(PRESRC) puttytel.rsp
|
||||
link /debug -out:puttytel.exe @puttytel.rsp
|
||||
|
||||
link.rsp: makefile
|
||||
echo /nologo /subsystem:windows > link.rsp
|
||||
echo $(POBJS1) >> link.rsp
|
||||
echo $(POBJS2) >> link.rsp
|
||||
echo $(OBJS1) >> link.rsp
|
||||
echo $(OBJS2) >> link.rsp
|
||||
echo $(OBJS3) >> link.rsp
|
||||
echo $(PRESRC) >> link.rsp
|
||||
echo $(LIBS1) >> link.rsp
|
||||
echo $(LIBS2) >> link.rsp
|
||||
pscp.exe: $(SOBJS) $(OBJS1) $(OBJS2) $(OBJS3) $(SRESRC) pscp.rsp
|
||||
link /debug -out:pscp.exe @pscp.rsp
|
||||
|
||||
scp.rsp: makefile
|
||||
echo /nologo /subsystem:console > scp.rsp
|
||||
echo $(SOBJS) >> scp.rsp
|
||||
echo $(OBJS1) >> scp.rsp
|
||||
echo $(OBJS2) >> scp.rsp
|
||||
echo $(OBJS3) >> scp.rsp
|
||||
echo $(SRESRC) >> scp.rsp
|
||||
echo $(LIBS1) >> scp.rsp
|
||||
echo $(LIBS2) >> scp.rsp
|
||||
putty.rsp: makefile
|
||||
echo /nologo /subsystem:windows > putty.rsp
|
||||
echo $(GOBJS1) >> putty.rsp
|
||||
echo $(GOBJS2) >> putty.rsp
|
||||
echo $(POBJS) >> putty.rsp
|
||||
echo $(MOBJS) >> putty.rsp
|
||||
echo $(OBJS1) >> putty.rsp
|
||||
echo $(OBJS2) >> putty.rsp
|
||||
echo $(PRESRC) >> putty.rsp
|
||||
echo $(LIBS1) >> putty.rsp
|
||||
echo $(LIBS2) >> putty.rsp
|
||||
|
||||
puttytel.rsp: makefile
|
||||
echo /nologo /subsystem:windows > puttytel.rsp
|
||||
echo $(GOBJS1) >> puttytel.rsp
|
||||
echo $(GOBJS2) >> puttytel.rsp
|
||||
echo $(TOBJS) >> puttytel.rsp
|
||||
echo $(MOBJS) >> puttytel.rsp
|
||||
echo $(TRESRC) >> puttytel.rsp
|
||||
echo $(LIBS1) >> puttytel.rsp
|
||||
echo $(LIBS2) >> puttytel.rsp
|
||||
|
||||
pscp.rsp: makefile
|
||||
echo /nologo /subsystem:console > pscp.rsp
|
||||
echo $(SOBJS) >> pscp.rsp
|
||||
echo $(MOBJS) >> pscp.rsp
|
||||
echo $(OBJS1) >> pscp.rsp
|
||||
echo $(OBJS2) >> pscp.rsp
|
||||
echo $(SRESRC) >> pscp.rsp
|
||||
echo $(LIBS1) >> pscp.rsp
|
||||
echo $(LIBS2) >> pscp.rsp
|
||||
|
||||
##-- dependencies
|
||||
window.$(OBJ): window.c putty.h win_res.h
|
||||
@ -112,6 +134,9 @@ sshblowf.$(OBJ): sshblowf.c ssh.h
|
||||
scp.$(OBJ): scp.c putty.h scp.h
|
||||
scpssh.$(OBJ): scpssh.c putty.h ssh.h scp.h
|
||||
version.$(OBJ): version.c
|
||||
be_all.$(OBJ): be_all.c
|
||||
be_nossh.$(OBJ): be_nossh.c
|
||||
be_none.$(OBJ): be_none.c
|
||||
##--
|
||||
|
||||
# Hack to force version.obj to be rebuilt always
|
||||
@ -126,6 +151,12 @@ win_res.$(RES): win_res.rc win_res.h putty.ico
|
||||
win_res.$(RES):
|
||||
rc $(FWHACK) $(RCFL) -r -DWIN32 -D_WIN32 -DWINVER=0x0400 win_res.rc
|
||||
|
||||
##-- dependencies
|
||||
nossh_res.$(RES): nossh_res.rc win_res.h putty.ico
|
||||
##--
|
||||
nossh_res.$(RES):
|
||||
rc $(FWHACK) $(RCFL) -r -DWIN32 -D_WIN32 -DWINVER=0x0400 nossh_res.rc
|
||||
|
||||
##-- dependencies
|
||||
scp.$(RES): scp.rc scp.ico
|
||||
##--
|
||||
|
15
be_all.c
Normal file
15
be_all.c
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Linking module for PuTTY proper: list the available backends
|
||||
* including ssh.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include "putty.h"
|
||||
|
||||
struct backend_list backends[] = {
|
||||
{PROT_SSH, "ssh", &ssh_backend},
|
||||
{PROT_TELNET, "telnet", &telnet_backend},
|
||||
{PROT_RAW, "raw", &raw_backend},
|
||||
{0, NULL}
|
||||
};
|
13
be_none.c
Normal file
13
be_none.c
Normal file
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Linking module for PSCP: list no available backends. This is
|
||||
* only present to satisfy linker requirements. I should really
|
||||
* untangle the whole lot a bit better.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include "putty.h"
|
||||
|
||||
struct backend_list backends[] = {
|
||||
{0, NULL}
|
||||
};
|
23
be_nossh.c
Normal file
23
be_nossh.c
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Linking module for PuTTYtel: list the available backends not
|
||||
* including ssh.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include "putty.h"
|
||||
|
||||
struct backend_list backends[] = {
|
||||
{PROT_TELNET, "telnet", &telnet_backend},
|
||||
{PROT_RAW, "raw", &raw_backend},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
/*
|
||||
* Stub implementations of functions not used in non-ssh versions.
|
||||
*/
|
||||
void random_save_seed(void) {
|
||||
}
|
||||
|
||||
void noise_ultralight(DWORD data) {
|
||||
}
|
3
nossh_res.rc
Normal file
3
nossh_res.rc
Normal file
@ -0,0 +1,3 @@
|
||||
/* Stub rc file for the PuTTYtel ssh-free binary */
|
||||
#define NO_SSH
|
||||
#include "win_res.rc"
|
8
putty.h
8
putty.h
@ -104,6 +104,12 @@ typedef struct {
|
||||
|
||||
GLOBAL Backend *back;
|
||||
|
||||
GLOBAL struct backend_list {
|
||||
int protocol;
|
||||
char *name;
|
||||
Backend *backend;
|
||||
} backends[];
|
||||
|
||||
typedef struct {
|
||||
void (*send) (char *buf, int len);
|
||||
} Ldisc;
|
||||
@ -215,7 +221,7 @@ void do_defaults (char *);
|
||||
void logevent (char *);
|
||||
void showeventlog (HWND);
|
||||
void showabout (HWND);
|
||||
void verify_ssh_host_key(char *host, struct RSAKey *key);
|
||||
void verify_ssh_host_key(char *host, char *keystr);
|
||||
void get_sesslist(int allocate);
|
||||
|
||||
GLOBAL int nsessions;
|
||||
|
16
scpssh.c
16
scpssh.c
@ -281,7 +281,21 @@ static void ssh_login(char *username, char *cmd)
|
||||
if (!rsabuf)
|
||||
fatalbox("Out of memory");
|
||||
|
||||
verify_ssh_host_key(savedhost, &hostkey);
|
||||
/*
|
||||
* Verify the host key.
|
||||
*/
|
||||
{
|
||||
/*
|
||||
* First format the key into a string.
|
||||
*/
|
||||
int len = rsastr_len(&hostkey);
|
||||
char *keystr = malloc(len);
|
||||
if (!keystr)
|
||||
fatalbox("Out of memory");
|
||||
rsastr_fmt(keystr, &hostkey);
|
||||
verify_ssh_host_key(savedhost, keystr);
|
||||
free(keystr);
|
||||
}
|
||||
|
||||
for (i=0; i<32; i++) {
|
||||
rsabuf[i] = session_key[i];
|
||||
|
16
ssh.c
16
ssh.c
@ -385,7 +385,21 @@ static void ssh_protocol(unsigned char *in, int inlen, int ispkt) {
|
||||
if (!rsabuf)
|
||||
fatalbox("Out of memory");
|
||||
|
||||
verify_ssh_host_key(savedhost, &hostkey);
|
||||
/*
|
||||
* Verify the host key.
|
||||
*/
|
||||
{
|
||||
/*
|
||||
* First format the key into a string.
|
||||
*/
|
||||
int len = rsastr_len(&hostkey);
|
||||
char *keystr = malloc(len);
|
||||
if (!keystr)
|
||||
fatalbox("Out of memory");
|
||||
rsastr_fmt(keystr, &hostkey);
|
||||
verify_ssh_host_key(savedhost, keystr);
|
||||
free(keystr);
|
||||
}
|
||||
|
||||
for (i=0; i<32; i++) {
|
||||
rsabuf[i] = session_key[i];
|
||||
|
@ -75,7 +75,9 @@ BEGIN
|
||||
RTEXT "Protocol:", IDC0_PROTSTATIC, 3, 29, 52, 8
|
||||
AUTORADIOBUTTON "&Raw", IDC0_PROTRAW, 61, 29, 33, 10, WS_GROUP
|
||||
AUTORADIOBUTTON "&Telnet", IDC0_PROTTELNET, 96, 29, 33, 10
|
||||
#ifndef NO_SSH
|
||||
AUTORADIOBUTTON "SS&H", IDC0_PROTSSH, 132, 29, 33, 10
|
||||
#endif
|
||||
#endif
|
||||
LTEXT "Stor&ed Sessions", IDC0_SESSSTATIC, 3, 40, 122, 8
|
||||
EDITTEXT IDC0_SESSEDIT, 3, 48, 122, 12, ES_AUTOHSCROLL
|
||||
|
38
windlg.c
38
windlg.c
@ -116,9 +116,13 @@ static void save_settings (char *section, int do_host) {
|
||||
if (do_host) {
|
||||
wpps (sesskey, "HostName", cfg.host);
|
||||
wppi (sesskey, "PortNumber", cfg.port);
|
||||
wpps (sesskey, "Protocol",
|
||||
cfg.protocol == PROT_SSH ? "ssh" :
|
||||
cfg.protocol == PROT_TELNET ? "telnet" : "raw" );
|
||||
p = "raw";
|
||||
for (i = 0; backends[i].backend != NULL; i++)
|
||||
if (backends[i].protocol == cfg.protocol) {
|
||||
p = backends[i].name;
|
||||
break;
|
||||
}
|
||||
wpps (sesskey, "Protocol", p);
|
||||
}
|
||||
wppi (sesskey, "CloseOnExit", !!cfg.close_on_exit);
|
||||
wppi (sesskey, "WarnOnClose", !!cfg.warn_on_close);
|
||||
@ -235,15 +239,14 @@ static void load_settings (char *section, int do_host) {
|
||||
|
||||
gpps (sesskey, "HostName", "", cfg.host, sizeof(cfg.host));
|
||||
gppi (sesskey, "PortNumber", default_port, &cfg.port);
|
||||
|
||||
gpps (sesskey, "Protocol", "default", prot, 10);
|
||||
if (!strcmp(prot, "ssh"))
|
||||
cfg.protocol = PROT_SSH;
|
||||
else if (!strcmp(prot, "telnet"))
|
||||
cfg.protocol = PROT_TELNET;
|
||||
else if (!strcmp(prot, "raw"))
|
||||
cfg.protocol = PROT_RAW;
|
||||
else
|
||||
cfg.protocol = default_protocol;
|
||||
cfg.protocol = default_protocol;
|
||||
for (i = 0; backends[i].backend != NULL; i++)
|
||||
if (!strcmp(prot, backends[i].name)) {
|
||||
cfg.protocol = backends[i].protocol;
|
||||
break;
|
||||
}
|
||||
|
||||
gppi (sesskey, "CloseOnExit", 1, &cfg.close_on_exit);
|
||||
gppi (sesskey, "WarnOnClose", 1, &cfg.warn_on_close);
|
||||
@ -1433,19 +1436,12 @@ void showabout (HWND hwnd) {
|
||||
}
|
||||
}
|
||||
|
||||
void verify_ssh_host_key(char *host, struct RSAKey *key) {
|
||||
char *keystr, *otherstr, *mungedhost;
|
||||
void verify_ssh_host_key(char *host, char *keystr) {
|
||||
char *otherstr, *mungedhost;
|
||||
int len;
|
||||
HKEY rkey;
|
||||
|
||||
/*
|
||||
* Format the key into a string.
|
||||
*/
|
||||
len = rsastr_len(key);
|
||||
keystr = malloc(len);
|
||||
if (!keystr)
|
||||
fatalbox("Out of memory");
|
||||
rsastr_fmt(keystr, key);
|
||||
len = 1 + strlen(keystr);
|
||||
|
||||
/*
|
||||
* Now read a saved key in from the registry and see what it
|
||||
|
22
window.c
22
window.c
@ -186,9 +186,25 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) {
|
||||
}
|
||||
}
|
||||
|
||||
back = (cfg.protocol == PROT_SSH ? &ssh_backend :
|
||||
cfg.protocol == PROT_TELNET ? &telnet_backend :
|
||||
&raw_backend);
|
||||
/*
|
||||
* Select protocol. This is farmed out into a table in a
|
||||
* separate file to enable an ssh-free variant.
|
||||
*/
|
||||
{
|
||||
int i;
|
||||
back = NULL;
|
||||
for (i = 0; backends[i].backend != NULL; i++)
|
||||
if (backends[i].protocol == cfg.protocol) {
|
||||
back = backends[i].backend;
|
||||
break;
|
||||
}
|
||||
if (back == NULL) {
|
||||
MessageBox(NULL, "Unsupported protocol number found",
|
||||
"PuTTY Internal Error", MB_OK | MB_ICONEXCLAMATION);
|
||||
WSACleanup();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
ldisc = (cfg.ldisc_term ? &ldisc_term : &ldisc_simple);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user