зеркало из https://github.com/github/putty.git
Fairly major hackery to get SSH going on the Mac. Half the support
functions are only dummy stubs, but it's still minimally usable. At least, as long as you don't want to do anything complex like logging out. [originally from svn r2500]
This commit is contained in:
Родитель
3d90359d10
Коммит
697794abbf
8
Recipe
8
Recipe
|
@ -101,6 +101,7 @@ SSH = ssh sshcrc sshdes sshmd5 sshrsa sshrand sshsha sshblowf
|
|||
+ sshaes sshsh512 sshbn wildcard
|
||||
WINSSH = SSH noise pageantc
|
||||
UXSSH = SSH uxnoise uxagentc
|
||||
MACSSH = SSH macnoise
|
||||
|
||||
# SFTP implementation (pscp, psftp).
|
||||
SFTP = sftp int64 logging
|
||||
|
@ -109,7 +110,7 @@ SFTP = sftp int64 logging
|
|||
# Pageant or PuTTYgen).
|
||||
WINMISC = misc version winstore settings tree234 winnet proxy cmdline
|
||||
UXMISC = misc version uxstore settings tree234 uxnet proxy cmdline
|
||||
MACMISC = misc macstore settings tree234 mtcpnet proxy
|
||||
MACMISC = misc version macstore settings tree234 mtcpnet proxy
|
||||
|
||||
# Character set library, for use in pterm.
|
||||
CHARSET = sbcsdat slookup sbcs utf8 toucs fromucs xenc mimeenc macenc
|
||||
|
@ -145,6 +146,9 @@ pterm : [X] pterm terminal wcwidth uxucs uxmisc tree234 misc ldisc ldiscucs
|
|||
|
||||
plink : [U] uxplink uxcons NONSSH UXSSH be_all logging UXMISC
|
||||
|
||||
PuTTY : [M] terminal wcwidth ldisc ldiscucs logging be_nossh mac macdlg
|
||||
PuTTY : [M] terminal wcwidth ldiscucs logging be_all mac macdlg
|
||||
+ macterm macucs mac_res.rsrc testback NONSSH MACSSH MACMISC CHARSET
|
||||
+ stricmp vsnprint
|
||||
PuTTYtel : [M] terminal wcwidth ldiscucs logging be_none mac macdlg
|
||||
+ macterm macucs mac_res.rsrc testback NONSSH MACMISC CHARSET
|
||||
+ stricmp vsnprint
|
||||
|
|
57
mac/mac.c
57
mac/mac.c
|
@ -1,4 +1,4 @@
|
|||
/* $Id: mac.c,v 1.19 2003/01/05 12:53:38 ben Exp $ */
|
||||
/* $Id: mac.c,v 1.20 2003/01/08 22:46:12 ben Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1999 Ben Harris
|
||||
* All rights reserved.
|
||||
|
@ -57,10 +57,13 @@
|
|||
|
||||
#include "macresid.h"
|
||||
#include "putty.h"
|
||||
#include "ssh.h"
|
||||
#include "mac.h"
|
||||
|
||||
QDGlobals qd;
|
||||
|
||||
Session *sesslist;
|
||||
|
||||
static int cold = 1;
|
||||
struct mac_gestalts mac_gestalts;
|
||||
|
||||
|
@ -84,7 +87,7 @@ static void mac_adjustmenus(void);
|
|||
static void mac_closewindow(WindowPtr);
|
||||
static void mac_zoomwindow(WindowPtr, short);
|
||||
static void mac_shutdown(void);
|
||||
#pragma noreturn (mac_shutdown)
|
||||
#pragma noreturn (cleanup_exit)
|
||||
|
||||
struct mac_windows {
|
||||
WindowPtr about;
|
||||
|
@ -186,6 +189,15 @@ static void mac_startup(void) {
|
|||
|
||||
default_protocol = DEFAULT_PROTOCOL;
|
||||
default_port = DEFAULT_PORT;
|
||||
flags = FLAG_INTERACTIVE;
|
||||
|
||||
/*
|
||||
* Really grotty hack to ensure that anything that looks at the
|
||||
* global "cfg" variable gets something vaguely sensible.
|
||||
* Obviously, nothing should actually be using it, but that will
|
||||
* take a while to arrange.
|
||||
*/
|
||||
do_defaults(NULL, &cfg);
|
||||
|
||||
{
|
||||
short vol;
|
||||
|
@ -214,6 +226,7 @@ static void mac_eventloop(void) {
|
|||
if (gotevent)
|
||||
mac_event(&event);
|
||||
mactcp_poll();
|
||||
mac_pollterm();
|
||||
}
|
||||
DisposeRgn(cursrgn);
|
||||
}
|
||||
|
@ -457,7 +470,7 @@ static void mac_menucommand(long result) {
|
|||
mac_closewindow(window);
|
||||
goto done;
|
||||
case iQuit:
|
||||
mac_shutdown();
|
||||
cleanup_exit(0);
|
||||
goto done;
|
||||
}
|
||||
break;
|
||||
|
@ -597,14 +610,15 @@ static void mac_adjustcursor(RgnHandle cursrgn) {
|
|||
}
|
||||
}
|
||||
|
||||
static void mac_shutdown(void) {
|
||||
void cleanup_exit(int status)
|
||||
{
|
||||
|
||||
#if !TARGET_RT_MAC_CFM
|
||||
if (mac_gestalts.encvvers != 0)
|
||||
TerminateUnicodeConverter();
|
||||
#endif
|
||||
mactcp_shutdown();
|
||||
exit(0);
|
||||
exit(status);
|
||||
}
|
||||
|
||||
void fatalbox(char *fmt, ...) {
|
||||
|
@ -647,6 +661,39 @@ void connection_fatal(void *fontend, char *fmt, ...) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
/* Null SSH agent client -- never finds an agent. */
|
||||
|
||||
int agent_exists(void)
|
||||
{
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void agent_query(void *in, int inlen, void **out, int *outlen)
|
||||
{
|
||||
|
||||
*out = NULL;
|
||||
*outlen = 0;
|
||||
}
|
||||
|
||||
/* Temporary null routines for testing. */
|
||||
|
||||
void verify_ssh_host_key(void *frontend, char *host, int port, char *keytype,
|
||||
char *keystr, char *fingerprint)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void askcipher(void *frontend, char *ciphername, int cs)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void old_keyfile_warning(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* c-file-style: "simon"
|
||||
|
|
|
@ -34,7 +34,9 @@ extern struct mac_gestalts mac_gestalts;
|
|||
#define HAVE_COLOR_QD() (mac_gestalts.qdvers > gestaltOriginalQD)
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
typedef struct Session {
|
||||
struct Session *next;
|
||||
struct Session **prev;
|
||||
/* Config that created this session */
|
||||
Config cfg;
|
||||
/* Terminal emulator internal state */
|
||||
|
@ -65,6 +67,8 @@ typedef struct {
|
|||
charset_t font_charset; /* font_charset is used at a time. */
|
||||
} Session;
|
||||
|
||||
extern Session *sesslist;
|
||||
|
||||
/* from macdlg.c */
|
||||
extern void mac_newsession(void);
|
||||
extern void mac_clickdlg(WindowPtr, EventRecord *);
|
||||
|
@ -72,6 +76,7 @@ extern void mac_activatedlg(WindowPtr, EventRecord *);
|
|||
/* from macterm.c */
|
||||
extern void mac_opensession(void);
|
||||
extern void mac_startsession(Session *);
|
||||
extern void mac_pollterm(void);
|
||||
extern void mac_activateterm(WindowPtr, Boolean);
|
||||
extern void mac_adjusttermcursor(WindowPtr, Point, RgnHandle);
|
||||
extern void mac_adjusttermmenus(WindowPtr);
|
||||
|
@ -81,6 +86,7 @@ extern void mac_growterm(WindowPtr, EventRecord *);
|
|||
extern void mac_keyterm(WindowPtr, EventRecord *);
|
||||
extern void mac_menuterm(WindowPtr, short, short);
|
||||
/* from macstore.c */
|
||||
extern OSErr get_putty_dir(Boolean makeit, short *pVRefNum, long *pDirID);
|
||||
extern OSErr get_session_dir(Boolean makeit, short *pVRefNum, long *pDirID);
|
||||
extern void *open_settings_r_fsp(FSSpec *);
|
||||
/* from macucs.c */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: macstore.c,v 1.6 2002/12/30 18:21:17 ben Exp $ */
|
||||
/* $Id: macstore.c,v 1.7 2003/01/08 22:46:12 ben Exp $ */
|
||||
|
||||
/*
|
||||
* macstore.c: Macintosh-specific impementation of the interface
|
||||
|
@ -19,6 +19,7 @@
|
|||
|
||||
#define PUTTY_CREATOR FOUR_CHAR_CODE('pTTY')
|
||||
#define SESS_TYPE FOUR_CHAR_CODE('Sess')
|
||||
#define SEED_TYPE FOUR_CHAR_CODE('Seed')
|
||||
|
||||
|
||||
OSErr FSpGetDirID(FSSpec *f, long *idp, Boolean makeit);
|
||||
|
@ -28,11 +29,12 @@ OSErr FSpGetDirID(FSSpec *f, long *idp, Boolean makeit);
|
|||
* preferences folder. Each (key,value) pair is stored as a resource.
|
||||
*/
|
||||
|
||||
OSErr get_session_dir(Boolean makeit, short *pVRefNum, long *pDirID) {
|
||||
OSErr get_putty_dir(Boolean makeit, short *pVRefNum, long *pDirID)
|
||||
{
|
||||
OSErr error = noErr;
|
||||
short prefVRefNum;
|
||||
FSSpec puttydir, sessdir;
|
||||
long prefDirID, puttyDirID, sessDirID;
|
||||
FSSpec puttydir;
|
||||
long prefDirID, puttyDirID;
|
||||
|
||||
error = FindFolder(kOnSystemDisk, kPreferencesFolderType, makeit,
|
||||
&prefVRefNum, &prefDirID);
|
||||
|
@ -43,13 +45,28 @@ OSErr get_session_dir(Boolean makeit, short *pVRefNum, long *pDirID) {
|
|||
error = FSpGetDirID(&puttydir, &puttyDirID, makeit);
|
||||
if (error != noErr) goto out;
|
||||
|
||||
error = FSMakeFSSpec(prefVRefNum, puttyDirID, "\pSaved Sessions",
|
||||
*pVRefNum = prefVRefNum;
|
||||
*pDirID = puttyDirID;
|
||||
|
||||
out:
|
||||
return error;
|
||||
}
|
||||
|
||||
OSErr get_session_dir(Boolean makeit, short *pVRefNum, long *pDirID) {
|
||||
OSErr error = noErr;
|
||||
short puttyVRefNum;
|
||||
FSSpec sessdir;
|
||||
long puttyDirID, sessDirID;
|
||||
|
||||
error = get_putty_dir(makeit, &puttyVRefNum, &puttyDirID);
|
||||
if (error != noErr) goto out;
|
||||
error = FSMakeFSSpec(puttyVRefNum, puttyDirID, "\pSaved Sessions",
|
||||
&sessdir);
|
||||
if (error != noErr && error != fnfErr) goto out;
|
||||
error = FSpGetDirID(&sessdir, &sessDirID, makeit);
|
||||
if (error != noErr) goto out;
|
||||
|
||||
*pVRefNum = prefVRefNum;
|
||||
*pVRefNum = puttyVRefNum;
|
||||
*pDirID = sessDirID;
|
||||
|
||||
out:
|
||||
|
@ -350,6 +367,74 @@ void enum_settings_finish(void *handle) {
|
|||
safefree(handle);
|
||||
}
|
||||
|
||||
#define SEED_SIZE 512
|
||||
|
||||
void read_random_seed(noise_consumer_t consumer)
|
||||
{
|
||||
short puttyVRefNum;
|
||||
long puttyDirID;
|
||||
OSErr error;
|
||||
char buf[SEED_SIZE];
|
||||
short refnum;
|
||||
long count = SEED_SIZE;
|
||||
|
||||
if (get_putty_dir(kDontCreateFolder, &puttyVRefNum, &puttyDirID) != noErr)
|
||||
return;
|
||||
if (HOpenDF(puttyVRefNum, puttyDirID, "\pPuTTY Random Seed", fsRdPerm,
|
||||
&refnum) != noErr)
|
||||
return;
|
||||
error = FSRead(refnum, &count, buf);
|
||||
if (error != noErr && error != eofErr)
|
||||
return;
|
||||
(*consumer)(buf, count);
|
||||
FSClose(refnum);
|
||||
}
|
||||
|
||||
void write_random_seed(void *data, int len)
|
||||
{
|
||||
short puttyVRefNum, tmpVRefNum;
|
||||
long puttyDirID, tmpDirID;
|
||||
OSErr error;
|
||||
FSSpec dstfile, tmpfile;
|
||||
short refnum;
|
||||
long count = len;
|
||||
|
||||
if (get_putty_dir(kCreateFolder, &puttyVRefNum, &puttyDirID) != noErr)
|
||||
return;
|
||||
|
||||
error = FSMakeFSSpec(puttyVRefNum, puttyDirID, "\pPuTTY Random Seed",
|
||||
&dstfile);
|
||||
if (error != noErr && error != fnfErr) return;
|
||||
|
||||
/* Create a temporary file to save to first. */
|
||||
error = FindFolder(puttyVRefNum, kTemporaryFolderType, kCreateFolder,
|
||||
&tmpVRefNum, &tmpDirID);
|
||||
if (error != noErr) return;
|
||||
error = FSMakeFSSpec(tmpVRefNum, tmpDirID, "\pPuTTY Random Seed",
|
||||
&tmpfile);
|
||||
if (error != noErr && error != fnfErr) return;
|
||||
if (error == noErr) {
|
||||
error = FSpDelete(&tmpfile);
|
||||
if (error != noErr) return;
|
||||
}
|
||||
error = FSpCreate(&tmpfile, PUTTY_CREATOR, SEED_TYPE, smRoman);
|
||||
if (error != noErr) return;
|
||||
|
||||
if (FSpOpenDF(&tmpfile, fsWrPerm, &refnum) != noErr) goto fail;
|
||||
|
||||
if (FSWrite(refnum, &count, data) != noErr) goto fail2;
|
||||
if (FSClose(refnum) != noErr) goto fail;
|
||||
|
||||
if (FSpExchangeFiles(&tmpfile, &dstfile) != noErr) goto fail;
|
||||
if (FSpDelete(&tmpfile) != noErr) return;
|
||||
|
||||
return;
|
||||
|
||||
fail2:
|
||||
FSClose(refnum);
|
||||
fail:
|
||||
FSpDelete(&tmpfile);
|
||||
}
|
||||
|
||||
/*
|
||||
* Emacs magic:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: macterm.c,v 1.35 2003/01/05 11:31:51 ben Exp $ */
|
||||
/* $Id: macterm.c,v 1.36 2003/01/08 22:46:12 ben Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1999 Simon Tatham
|
||||
* Copyright (c) 1999, 2002 Ben Harris
|
||||
|
@ -223,6 +223,10 @@ void mac_startsession(Session *s)
|
|||
sprintf(msg, "Elapsed ticks: %d\015\012", TickCount() - starttime);
|
||||
inbuf_putstr(s, msg);
|
||||
term_out(s->term);
|
||||
s->next = sesslist;
|
||||
s->prev = s->next->prev;
|
||||
s->next->prev = &s->next;
|
||||
sesslist = s;
|
||||
}
|
||||
|
||||
static UnicodeToTextFallbackUPP uni_to_font_fallback_upp;
|
||||
|
@ -300,6 +304,18 @@ static pascal OSStatus uni_to_font_fallback(UniChar *ucp,
|
|||
return noErr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called every time round the event loop.
|
||||
*/
|
||||
void mac_pollterm(void)
|
||||
{
|
||||
Session *s;
|
||||
|
||||
for (s = sesslist; s != NULL; s = s->next) {
|
||||
term_out(s->term);
|
||||
term_update(s->term);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* To be called whenever the window size changes.
|
||||
|
|
|
@ -244,7 +244,6 @@ SockAddr sk_namelookup(char *host, char **canonicalname)
|
|||
volatile int done = FALSE;
|
||||
char *realhost;
|
||||
|
||||
fprintf(stderr, "Resolving %s...\n", host);
|
||||
/* Clear the structure. */
|
||||
memset(ret, 0, sizeof(struct SockAddr_tag));
|
||||
if (mactcp_lookupdone_upp == NULL)
|
||||
|
@ -266,7 +265,6 @@ SockAddr sk_namelookup(char *host, char **canonicalname)
|
|||
realhost = "";
|
||||
*canonicalname = smalloc(1+strlen(realhost));
|
||||
strcpy(*canonicalname, realhost);
|
||||
fprintf(stderr, "canonical name = %s\n", realhost);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -361,6 +359,12 @@ static void mactcp_flush(Socket s)
|
|||
fatalbox("sk_tcp_flush");
|
||||
}
|
||||
|
||||
Socket sk_register(void *sock, Plug plug)
|
||||
{
|
||||
|
||||
fatalbox("sk_register");
|
||||
}
|
||||
|
||||
Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
|
||||
int nodelay, Plug plug)
|
||||
{
|
||||
|
@ -381,7 +385,6 @@ Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
|
|||
ip_addr dstaddr;
|
||||
size_t buflen;
|
||||
|
||||
fprintf(stderr, "Opening socket, port = %d\n", port);
|
||||
/*
|
||||
* Create Socket structure.
|
||||
*/
|
||||
|
@ -417,9 +420,7 @@ Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
|
|||
upb.csParam.mtu.remoteHost = dstaddr;
|
||||
upb.csParam.mtu.userDataPtr = NULL;
|
||||
ret->err = PBControlSync((ParmBlkPtr)&upb);
|
||||
fprintf(stderr, "getting mtu, err = %d\n", ret->err);
|
||||
if (ret->err != noErr) return (Socket)ret;
|
||||
fprintf(stderr, "Got MTU = %d\n", upb.csParam.mtu.mtuSize);
|
||||
|
||||
buflen = upb.csParam.mtu.mtuSize * 4 + 1024;
|
||||
if (buflen < 4096) buflen = 4096;
|
||||
|
@ -432,7 +433,6 @@ Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
|
|||
ret->err = PBControlSync((ParmBlkPtr)&pb);
|
||||
if (ret->err != noErr) return (Socket)ret;
|
||||
ret->s = pb.tcpStream;
|
||||
fprintf(stderr, "stream opened\n");
|
||||
|
||||
/*
|
||||
* Open the connection.
|
||||
|
@ -466,12 +466,18 @@ Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
|
|||
/* Add this to the list of all sockets */
|
||||
ret->next = mactcp.socklist;
|
||||
ret->prev = &mactcp.socklist;
|
||||
ret->next->prev = &ret->next;
|
||||
mactcp.socklist = ret;
|
||||
|
||||
fprintf(stderr, "Socket connected\n");
|
||||
return (Socket)ret;
|
||||
}
|
||||
|
||||
Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only)
|
||||
{
|
||||
|
||||
fatalbox("sk_newlistener");
|
||||
}
|
||||
|
||||
static void mactcp_close(Socket sock)
|
||||
{
|
||||
Actual_Socket s = (Actual_Socket)sock;
|
||||
|
@ -755,6 +761,14 @@ OSErr CloseResolver(void)
|
|||
return noErr;
|
||||
}
|
||||
|
||||
/* MacTCP doesn't have a services database. */
|
||||
int net_service_lookup(char *service)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* c-file-style: "simon"
|
||||
|
|
Загрузка…
Ссылка в новой задаче