Skip to content

Commit 99fffd6

Browse files
committed
Patch from Alejandro Sedeno, somewhat modified by me, which
reorganises the GSSAPI support so that it handles alternative implementations of the GSS-API. In particular, this means PuTTY can now talk to MIT Kerberos for Windows instead of being limited to SSPI. I don't know for sure whether further tweaking will be needed (to the UI, most likely, or to automatic selection of credentials), but testing reports suggest it's now at least worth committing to trunk to get it more widely tested. [originally from svn r8952]
1 parent f2b737c commit 99fffd6

21 files changed

+1140
-295
lines changed

Recipe

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@
100100
# Disables PuTTY's ability to use GSSAPI functions for
101101
# authentication and key exchange.
102102
#
103+
# - COMPAT=/DSTATIC_GSSAPI
104+
# Causes PuTTY to try to link statically against the GSSAPI
105+
# library instead of the default of doing it at run time.
106+
#
103107
# - COMPAT=/DMSVC4 (Windows only)
104108
# - RCFL=/DMSVC4
105109
# Makes a couple of minor changes so that PuTTY compiles using
@@ -261,9 +265,10 @@ NONSSH = telnet raw rlogin ldisc pinger
261265
SSH = ssh sshcrc sshdes sshmd5 sshrsa sshrand sshsha sshblowf
262266
+ sshdh sshcrcda sshpubk sshzlib sshdss x11fwd portfwd
263267
+ sshaes sshsh256 sshsh512 sshbn wildcard pinger ssharcf
268+
+ sshgssc pgssapi
264269
WINSSH = SSH winnoise winpgntc wingss
265270
UXSSH = SSH uxnoise uxagentc uxgss
266-
MACSSH = SSH macnoise
271+
MACSSH = SSH macnoise sshnogss
267272

268273
# SFTP implementation (pscp, psftp).
269274
SFTP = sftp int64 logging
@@ -304,7 +309,7 @@ U_BE_NOSSH = be_nos_s uxser nocproxy
304309
# X/GTK Unix app, [U] for command-line Unix app, [M] for Macintosh app.
305310

306311
putty : [G] GUITERM NONSSH WINSSH W_BE_ALL WINMISC winx11 putty.res LIBS
307-
puttytel : [G] GUITERM NONSSH W_BE_NOSSH WINMISC puttytel.res LIBS
312+
puttytel : [G] GUITERM NONSSH W_BE_NOSSH WINMISC puttytel.res nogss LIBS
308313
plink : [C] winplink wincons NONSSH WINSSH W_BE_ALL logging WINMISC
309314
+ winx11 plink.res LIBS
310315
pscp : [C] pscp winsftp wincons WINSSH BE_SSH SFTP wildcard WINMISC
@@ -323,11 +328,13 @@ puttygen : [G] winpgen sshrsag sshdssg sshprime sshdes sshbn sshmd5 version
323328

324329
pterm : [X] GTKTERM uxmisc misc ldisc settings uxpty uxsel BE_NONE uxstore
325330
+ uxsignal CHARSET cmdline uxpterm version time xpmpterm xpmptcfg
331+
+ nogss
326332
putty : [X] GTKTERM uxmisc misc ldisc settings uxsel U_BE_ALL uxstore
327333
+ uxsignal CHARSET uxputty NONSSH UXSSH UXMISC ux_x11 xpmputty
328334
+ xpmpucfg
329335
puttytel : [X] GTKTERM uxmisc misc ldisc settings uxsel U_BE_NOSSH
330336
+ uxstore uxsignal CHARSET uxputty NONSSH UXMISC xpmputty xpmpucfg
337+
+ nogss
331338

332339
plink : [U] uxplink uxcons NONSSH UXSSH U_BE_ALL logging UXMISC uxsignal
333340
+ ux_x11
@@ -345,7 +352,7 @@ PuTTY : [M] terminal wcwidth ldiscucs logging BE_ALL mac macdlg macevlog
345352
+ stricmp vsnprint dialog config macctrls minibidi
346353
PuTTYtel : [M] terminal wcwidth ldiscucs logging BE_NOSSH mac macdlg
347354
+ macevlog macterm macucs mac_res.rsrc testback NONSSH MACMISC
348-
+ CHARSET stricmp vsnprint dialog config macctrls minibidi
355+
+ CHARSET stricmp vsnprint dialog config macctrls minibidi nogss
349356
PuTTYgen : [M] macpgen sshrsag sshdssg sshprime sshdes sshbn sshmd5 version
350357
+ sshrand macnoise sshsha macstore misc sshrsa sshdss macmisc sshpubk
351358
+ sshaes sshsh256 sshsh512 import macpgen.rsrc macpgkey macabout

config.c

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,33 @@ static void cipherlist_handler(union control *ctrl, void *dlg,
236236
}
237237
}
238238

239+
#ifndef NO_GSSAPI
240+
static void gsslist_handler(union control *ctrl, void *dlg,
241+
void *data, int event)
242+
{
243+
Config *cfg = (Config *)data;
244+
if (event == EVENT_REFRESH) {
245+
int i;
246+
247+
dlg_update_start(ctrl, dlg);
248+
dlg_listbox_clear(ctrl, dlg);
249+
for (i = 0; i < ngsslibs; i++) {
250+
int id = cfg->ssh_gsslist[i];
251+
assert(id >= 0 && id < ngsslibs);
252+
dlg_listbox_addwithid(ctrl, dlg, gsslibnames[id], id);
253+
}
254+
dlg_update_done(ctrl, dlg);
255+
256+
} else if (event == EVENT_VALCHANGE) {
257+
int i;
258+
259+
/* Update array to match the list box. */
260+
for (i=0; i < ngsslibs; i++)
261+
cfg->ssh_gsslist[i] = dlg_listbox_getid(ctrl, dlg, i);
262+
}
263+
}
264+
#endif
265+
239266
static void kexlist_handler(union control *ctrl, void *dlg,
240267
void *data, int event)
241268
{
@@ -2089,7 +2116,7 @@ void setup_config_box(struct controlbox *b, int midsession,
20892116
ctrl_checkbox(s, "Allow agent forwarding", 'f',
20902117
HELPCTX(ssh_auth_agentfwd),
20912118
dlg_stdcheckbox_handler, I(offsetof(Config,agentfwd)));
2092-
ctrl_checkbox(s, "Allow attempted changes of username in SSH-2", 'u',
2119+
ctrl_checkbox(s, "Allow attempted changes of username in SSH-2", NO_SHORTCUT,
20932120
HELPCTX(ssh_auth_changeuser),
20942121
dlg_stdcheckbox_handler,
20952122
I(offsetof(Config,change_username)));
@@ -2103,6 +2130,18 @@ void setup_config_box(struct controlbox *b, int midsession,
21032130
FILTER_KEY_FILES, FALSE, "Select private key file",
21042131
HELPCTX(ssh_auth_privkey),
21052132
dlg_stdfilesel_handler, I(offsetof(Config, keyfile)));
2133+
2134+
#ifndef NO_GSSAPI
2135+
/*
2136+
* GSSAPI library selection.
2137+
*/
2138+
if (ngsslibs > 1) {
2139+
c = ctrl_draglist(s, "Preference order for GSSAPI libraries:", NO_SHORTCUT,
2140+
HELPCTX(no_help),
2141+
gsslist_handler, P(NULL));
2142+
c->listbox.height = ngsslibs;
2143+
}
2144+
#endif
21062145
}
21072146

21082147
if (!midsession) {

mac/macstuff.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ struct FontSpec {
4444
#define BYTE UInt8
4545
#define DWORD UInt32
4646

47+
typedef UInt32 uint32;
48+
#define PUTTY_UINT32_DEFINED
49+
4750
#define OPTIMISE_SCROLL
4851

4952
/*

mkfiles.pl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -944,9 +944,14 @@ sub manpages {
944944
"XLDFLAGS = \$(LDFLAGS) \$(shell \$(GTK_CONFIG) --libs)\n".
945945
"ULDFLAGS = \$(LDFLAGS)\n".
946946
"ifeq (,\$(findstring NO_GSSAPI,\$(COMPAT)))\n".
947-
"CFLAGS+= \$(shell \$(KRB5CONFIG) --cflags gssapi)\n".
947+
"ifeq (,\$(findstring STATIC_GSSAPI,\$(COMPAT)))\n".
948+
"XLDFLAGS+= -ldl\n".
949+
"ULDFLAGS+= -ldl\n".
950+
"else\n".
951+
"CFLAGS+= -DNO_LIBDL \$(shell \$(KRB5CONFIG) --cflags gssapi)\n".
948952
"XLDFLAGS+= \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
949-
"ULDFLAGS = \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
953+
"ULDFLAGS+= \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
954+
"endif\n".
950955
"endif\n".
951956
"INSTALL=install\n".
952957
"INSTALL_PROGRAM=\$(INSTALL)\n".
@@ -1006,8 +1011,6 @@ sub manpages {
10061011
"# You can define this path to point at your tools if you need to\n".
10071012
"# TOOLPATH = /opt/gcc/bin\n".
10081013
"CC = \$(TOOLPATH)cc\n".
1009-
"# If necessary set the path to krb5-config here\n".
1010-
"KRB5CONFIG=krb5-config\n".
10111014
"\n".
10121015
"-include Makefile.local\n".
10131016
"\n".
@@ -1017,10 +1020,6 @@ sub manpages {
10171020
(join " ", map {"-I$dirpfx$_"} @srcdirs)).
10181021
" -D _FILE_OFFSET_BITS=64\n".
10191022
"ULDFLAGS = \$(LDFLAGS)\n".
1020-
"ifeq (,\$(findstring NO_GSSAPI,\$(COMPAT)))\n".
1021-
"CFLAGS+= \$(shell \$(KRB5CONFIG) --cflags gssapi)\n".
1022-
"ULDFLAGS = \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
1023-
"endif\n".
10241023
"INSTALL=install\n".
10251024
"INSTALL_PROGRAM=\$(INSTALL)\n".
10261025
"INSTALL_DATA=\$(INSTALL)\n".

nogss.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* Stub definitions of the GSSAPI library list, for Unix pterm and
3+
* any other application that needs the symbols defined but has no
4+
* use for them.
5+
*/
6+
7+
const int ngsslibs = 0;
8+
const char *const gsslibnames[1] = { "dummy" };
9+
const char *const gsslibkeywords[1] = { "dummy" };
10+

pgssapi.c

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/* This file actually defines the GSSAPI function pointers for
2+
* functions we plan to import from a GSSAPI library.
3+
*/
4+
#include "putty.h"
5+
6+
#ifndef NO_GSSAPI
7+
8+
#include "pgssapi.h"
9+
10+
#ifndef NO_LIBDL
11+
12+
/* Reserved static storage for GSS_oids. Comments are quotes from RFC 2744. */
13+
static const gss_OID_desc oids[] = {
14+
/* The implementation must reserve static storage for a
15+
* gss_OID_desc object containing the value */
16+
{10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x01"},
17+
/* corresponding to an object-identifier value of
18+
* {iso(1) member-body(2) United States(840) mit(113554)
19+
* infosys(1) gssapi(2) generic(1) user_name(1)}. The constant
20+
* GSS_C_NT_USER_NAME should be initialized to point
21+
* to that gss_OID_desc.
22+
23+
* The implementation must reserve static storage for a
24+
* gss_OID_desc object containing the value */
25+
{10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x02"},
26+
/* corresponding to an object-identifier value of
27+
* {iso(1) member-body(2) United States(840) mit(113554)
28+
* infosys(1) gssapi(2) generic(1) machine_uid_name(2)}.
29+
* The constant GSS_C_NT_MACHINE_UID_NAME should be
30+
* initialized to point to that gss_OID_desc.
31+
32+
* The implementation must reserve static storage for a
33+
* gss_OID_desc object containing the value */
34+
{10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x03"},
35+
/* corresponding to an object-identifier value of
36+
* {iso(1) member-body(2) United States(840) mit(113554)
37+
* infosys(1) gssapi(2) generic(1) string_uid_name(3)}.
38+
* The constant GSS_C_NT_STRING_UID_NAME should be
39+
* initialized to point to that gss_OID_desc.
40+
*
41+
* The implementation must reserve static storage for a
42+
* gss_OID_desc object containing the value */
43+
{6, (void *)"\x2b\x06\x01\x05\x06\x02"},
44+
/* corresponding to an object-identifier value of
45+
* {iso(1) org(3) dod(6) internet(1) security(5)
46+
* nametypes(6) gss-host-based-services(2)). The constant
47+
* GSS_C_NT_HOSTBASED_SERVICE_X should be initialized to point
48+
* to that gss_OID_desc. This is a deprecated OID value, and
49+
* implementations wishing to support hostbased-service names
50+
* should instead use the GSS_C_NT_HOSTBASED_SERVICE OID,
51+
* defined below, to identify such names;
52+
* GSS_C_NT_HOSTBASED_SERVICE_X should be accepted a synonym
53+
* for GSS_C_NT_HOSTBASED_SERVICE when presented as an input
54+
* parameter, but should not be emitted by GSS-API
55+
* implementations
56+
*
57+
* The implementation must reserve static storage for a
58+
* gss_OID_desc object containing the value */
59+
{10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04"},
60+
/* corresponding to an object-identifier value of {iso(1)
61+
* member-body(2) Unites States(840) mit(113554) infosys(1)
62+
* gssapi(2) generic(1) service_name(4)}. The constant
63+
* GSS_C_NT_HOSTBASED_SERVICE should be initialized
64+
* to point to that gss_OID_desc.
65+
*
66+
* The implementation must reserve static storage for a
67+
* gss_OID_desc object containing the value */
68+
{6, (void *)"\x2b\x06\01\x05\x06\x03"},
69+
/* corresponding to an object identifier value of
70+
* {1(iso), 3(org), 6(dod), 1(internet), 5(security),
71+
* 6(nametypes), 3(gss-anonymous-name)}. The constant
72+
* and GSS_C_NT_ANONYMOUS should be initialized to point
73+
* to that gss_OID_desc.
74+
*
75+
* The implementation must reserve static storage for a
76+
* gss_OID_desc object containing the value */
77+
{6, (void *)"\x2b\x06\x01\x05\x06\x04"},
78+
/* corresponding to an object-identifier value of
79+
* {1(iso), 3(org), 6(dod), 1(internet), 5(security),
80+
* 6(nametypes), 4(gss-api-exported-name)}. The constant
81+
* GSS_C_NT_EXPORT_NAME should be initialized to point
82+
* to that gss_OID_desc.
83+
*/
84+
};
85+
86+
/* Here are the constants which point to the static structure above.
87+
*
88+
* Constants of the form GSS_C_NT_* are specified by rfc 2744.
89+
*/
90+
const_gss_OID GSS_C_NT_USER_NAME = oids+0;
91+
const_gss_OID GSS_C_NT_MACHINE_UID_NAME = oids+1;
92+
const_gss_OID GSS_C_NT_STRING_UID_NAME = oids+2;
93+
const_gss_OID GSS_C_NT_HOSTBASED_SERVICE_X = oids+3;
94+
const_gss_OID GSS_C_NT_HOSTBASED_SERVICE = oids+4;
95+
const_gss_OID GSS_C_NT_ANONYMOUS = oids+5;
96+
const_gss_OID GSS_C_NT_EXPORT_NAME = oids+6;
97+
98+
#endif /* NO_LIBDL */
99+
100+
static gss_OID_desc gss_mech_krb5_desc =
101+
{ 9, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x02" };
102+
/* iso(1) member-body(2) United States(840) mit(113554) infosys(1) gssapi(2) krb5(2)*/
103+
const gss_OID GSS_MECH_KRB5 = &gss_mech_krb5_desc;
104+
105+
#endif /* NO_GSSAPI */

0 commit comments

Comments
 (0)