diff --git a/openssh-6.2p1-vendor.patch b/openssh-6.2p1-vendor.patch index 67769f0..cb95e5f 100644 --- a/openssh-6.2p1-vendor.patch +++ b/openssh-6.2p1-vendor.patch @@ -1,7 +1,7 @@ -diff -up openssh-6.8p1/configure.ac.vendor openssh-6.8p1/configure.ac ---- openssh-6.8p1/configure.ac.vendor 2015-03-18 11:17:56.670880303 +0100 -+++ openssh-6.8p1/configure.ac 2015-03-18 11:17:56.695880243 +0100 -@@ -4743,6 +4743,12 @@ AC_ARG_WITH([lastlog], +diff -up openssh/configure.ac.vendor openssh/configure.ac +--- openssh/configure.ac.vendor 2015-06-24 11:05:39.805679794 +0200 ++++ openssh/configure.ac 2015-06-24 11:05:39.835679719 +0200 +@@ -4751,6 +4751,12 @@ AC_ARG_WITH([lastlog], fi ] ) @@ -14,7 +14,7 @@ diff -up openssh-6.8p1/configure.ac.vendor openssh-6.8p1/configure.ac dnl lastlog, [uw]tmpx? detection dnl NOTE: set the paths in the platform section to avoid the -@@ -5005,6 +5011,7 @@ echo " Translate v4 in v6 hack +@@ -5013,6 +5019,7 @@ echo " Translate v4 in v6 hack echo " BSD Auth support: $BSD_AUTH_MSG" echo " Random number source: $RAND_MSG" echo " Privsep sandbox style: $SANDBOX_STYLE" @@ -22,10 +22,10 @@ diff -up openssh-6.8p1/configure.ac.vendor openssh-6.8p1/configure.ac echo "" -diff -up openssh-6.8p1/servconf.c.vendor openssh-6.8p1/servconf.c ---- openssh-6.8p1/servconf.c.vendor 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/servconf.c 2015-03-18 11:19:16.279691126 +0100 -@@ -145,6 +145,7 @@ initialize_server_options(ServerOptions +diff -up openssh/servconf.c.vendor openssh/servconf.c +--- openssh/servconf.c.vendor 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/servconf.c 2015-06-24 11:07:07.689460890 +0200 +@@ -147,6 +147,7 @@ initialize_server_options(ServerOptions options->max_authtries = -1; options->max_sessions = -1; options->banner = NULL; @@ -33,7 +33,7 @@ diff -up openssh-6.8p1/servconf.c.vendor openssh-6.8p1/servconf.c options->use_dns = -1; options->client_alive_interval = -1; options->client_alive_count_max = -1; -@@ -327,6 +328,8 @@ fill_default_server_options(ServerOption +@@ -335,6 +336,8 @@ fill_default_server_options(ServerOption options->ip_qos_bulk = IPTOS_THROUGHPUT; if (options->version_addendum == NULL) options->version_addendum = xstrdup(""); @@ -42,7 +42,7 @@ diff -up openssh-6.8p1/servconf.c.vendor openssh-6.8p1/servconf.c if (options->fwd_opts.streamlocal_bind_mask == (mode_t)-1) options->fwd_opts.streamlocal_bind_mask = 0177; if (options->fwd_opts.streamlocal_bind_unlink == -1) -@@ -388,7 +391,7 @@ typedef enum { +@@ -397,7 +400,7 @@ typedef enum { sIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile, sGatewayPorts, sPubkeyAuthentication, sPubkeyAcceptedKeyTypes, sXAuthLocation, sSubsystem, sMaxStartups, sMaxAuthTries, sMaxSessions, @@ -50,8 +50,8 @@ diff -up openssh-6.8p1/servconf.c.vendor openssh-6.8p1/servconf.c + sBanner, sShowPatchLevel, sUseDNS, sHostbasedAuthentication, sHostbasedUsesNameFromPacketOnly, sHostbasedAcceptedKeyTypes, sClientAliveInterval, sClientAliveCountMax, sAuthorizedKeysFile, - sGssAuthentication, sGssCleanupCreds, sAcceptEnv, sPermitTunnel, -@@ -504,6 +507,7 @@ static struct { + sGssAuthentication, sGssCleanupCreds, sGssStrictAcceptor, +@@ -517,6 +520,7 @@ static struct { { "maxauthtries", sMaxAuthTries, SSHCFG_ALL }, { "maxsessions", sMaxSessions, SSHCFG_ALL }, { "banner", sBanner, SSHCFG_ALL }, @@ -59,7 +59,7 @@ diff -up openssh-6.8p1/servconf.c.vendor openssh-6.8p1/servconf.c { "usedns", sUseDNS, SSHCFG_GLOBAL }, { "verifyreversemapping", sDeprecated, SSHCFG_GLOBAL }, { "reversemappingcheck", sDeprecated, SSHCFG_GLOBAL }, -@@ -1320,6 +1324,10 @@ process_server_config_line(ServerOptions +@@ -1372,6 +1376,10 @@ process_server_config_line(ServerOptions multistate_ptr = multistate_privsep; goto parse_multistate; @@ -70,18 +70,18 @@ diff -up openssh-6.8p1/servconf.c.vendor openssh-6.8p1/servconf.c case sAllowUsers: while ((arg = strdelim(&cp)) && *arg != '\0') { if (options->num_allow_users >= MAX_ALLOW_USERS) -@@ -2145,6 +2153,7 @@ dump_config(ServerOptions *o) +@@ -2249,6 +2257,7 @@ dump_config(ServerOptions *o) dump_cfg_fmtint(sUseLogin, o->use_login); dump_cfg_fmtint(sCompression, o->compression); dump_cfg_fmtint(sGatewayPorts, o->fwd_opts.gateway_ports); + dump_cfg_fmtint(sShowPatchLevel, o->show_patchlevel); dump_cfg_fmtint(sUseDNS, o->use_dns); dump_cfg_fmtint(sAllowTcpForwarding, o->allow_tcp_forwarding); - dump_cfg_fmtint(sAllowStreamLocalForwarding, o->allow_streamlocal_forwarding); -diff -up openssh-6.8p1/servconf.h.vendor openssh-6.8p1/servconf.h ---- openssh-6.8p1/servconf.h.vendor 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/servconf.h 2015-03-18 11:17:56.696880241 +0100 -@@ -151,6 +151,7 @@ typedef struct { + dump_cfg_fmtint(sAllowAgentForwarding, o->allow_agent_forwarding); +diff -up openssh/servconf.h.vendor openssh/servconf.h +--- openssh/servconf.h.vendor 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/servconf.h 2015-06-24 11:05:39.837679714 +0200 +@@ -154,6 +154,7 @@ typedef struct { int max_authtries; int max_sessions; char *banner; /* SSH-2 banner message */ @@ -137,10 +137,10 @@ diff -up openssh-6.8p1/sshd_config.0.vendor openssh-6.8p1/sshd_config.0 StreamLocalBindMask Sets the octal file creation mode mask (umask) used when creating a Unix-domain socket file for local or remote port forwarding. -diff -up openssh-6.8p1/sshd_config.5.vendor openssh-6.8p1/sshd_config.5 ---- openssh-6.8p1/sshd_config.5.vendor 2015-03-18 11:17:56.691880253 +0100 -+++ openssh-6.8p1/sshd_config.5 2015-03-18 11:17:56.697880239 +0100 -@@ -1276,6 +1276,13 @@ This option applies to protocol version +diff -up openssh/sshd_config.5.vendor openssh/sshd_config.5 +--- openssh/sshd_config.5.vendor 2015-06-24 11:05:39.831679729 +0200 ++++ openssh/sshd_config.5 2015-06-24 11:05:39.837679714 +0200 +@@ -1344,6 +1344,13 @@ This option applies to protocol version .It Cm ServerKeyBits Defines the number of bits in the ephemeral protocol version 1 server key. The minimum value is 512, and the default is 1024. diff --git a/openssh-6.6.1p1-servconf-parser.patch b/openssh-6.6.1p1-servconf-parser.patch index b93f6f3..1439e80 100644 --- a/openssh-6.6.1p1-servconf-parser.patch +++ b/openssh-6.6.1p1-servconf-parser.patch @@ -1,31 +1,12 @@ -diff --git a/servconf.c b/servconf.c -index b7f3294..bc1e909 100644 ---- a/servconf.c -+++ b/servconf.c -@@ -1550,7 +1550,7 @@ process_server_config_line(ServerOptions *options, char *line, - break; - - case sForceCommand: -- if (cp == NULL) -+ if (cp == NULL || *cp == '\0') - fatal("%.200s line %d: Missing argument.", filename, - linenum); - len = strspn(cp, WHITESPACE); -@@ -1595,7 +1595,7 @@ process_server_config_line(ServerOptions *options, char *line, - break; - - case sVersionAddendum: -- if (cp == NULL) -+ if (cp == NULL || *cp == '\0') - fatal("%.200s line %d: Missing argument.", filename, - linenum); - len = strspn(cp, WHITESPACE); -@@ -1630,6 +1630,8 @@ process_server_config_line(ServerOptions *options, char *line, +diff -up openssh/servconf.c.servconf openssh/servconf.c +--- openssh/servconf.c.servconf 2015-06-24 11:26:26.186527736 +0200 ++++ openssh/servconf.c 2015-06-24 11:26:39.847493075 +0200 +@@ -1815,6 +1815,8 @@ process_server_config_line(ServerOptions break; case sAuthenticationMethods: + if (cp == NULL || *cp == '\0') + fatal("%.200s line %d: Missing argument.", filename, linenum); - if (*activep && options->num_auth_methods == 0) { + if (options->num_auth_methods == 0) { while ((arg = strdelim(&cp)) && *arg != '\0') { if (options->num_auth_methods >= diff --git a/openssh-6.6p1-GSSAPIEnablek5users.patch b/openssh-6.6p1-GSSAPIEnablek5users.patch index cf01dd5..fc8f59d 100644 --- a/openssh-6.6p1-GSSAPIEnablek5users.patch +++ b/openssh-6.6p1-GSSAPIEnablek5users.patch @@ -1,6 +1,6 @@ -diff -up openssh-6.8p1/gss-serv-krb5.c.GSSAPIEnablek5users openssh-6.8p1/gss-serv-krb5.c ---- openssh-6.8p1/gss-serv-krb5.c.GSSAPIEnablek5users 2015-03-18 13:04:21.505306818 +0100 -+++ openssh-6.8p1/gss-serv-krb5.c 2015-03-18 13:04:21.527306764 +0100 +diff -up openssh/gss-serv-krb5.c.GSSAPIEnablek5users openssh/gss-serv-krb5.c +--- openssh/gss-serv-krb5.c.GSSAPIEnablek5users 2015-06-24 11:40:03.716448353 +0200 ++++ openssh/gss-serv-krb5.c 2015-06-24 11:40:03.739448295 +0200 @@ -260,7 +260,6 @@ ssh_gssapi_krb5_cmdok(krb5_principal pri FILE *fp; char file[MAXPATHLEN]; @@ -18,10 +18,10 @@ diff -up openssh-6.8p1/gss-serv-krb5.c.GSSAPIEnablek5users openssh-6.8p1/gss-ser return ssh_krb5_kuserok(krb_context, principal, luser, k5login_exists); } -diff -up openssh-6.8p1/servconf.c.GSSAPIEnablek5users openssh-6.8p1/servconf.c ---- openssh-6.8p1/servconf.c.GSSAPIEnablek5users 2015-03-18 13:04:21.516306791 +0100 -+++ openssh-6.8p1/servconf.c 2015-03-18 13:05:26.846146608 +0100 -@@ -168,6 +168,7 @@ initialize_server_options(ServerOptions +diff -up openssh/servconf.c.GSSAPIEnablek5users openssh/servconf.c +--- openssh/servconf.c.GSSAPIEnablek5users 2015-06-24 11:40:03.728448323 +0200 ++++ openssh/servconf.c 2015-06-24 11:40:03.740448292 +0200 +@@ -171,6 +171,7 @@ initialize_server_options(ServerOptions options->version_addendum = NULL; options->fingerprint_hash = -1; options->use_kuserok = -1; @@ -29,7 +29,7 @@ diff -up openssh-6.8p1/servconf.c.GSSAPIEnablek5users openssh-6.8p1/servconf.c } /* Returns 1 if a string option is unset or set to "none" or 0 otherwise. */ -@@ -348,6 +349,8 @@ fill_default_server_options(ServerOption +@@ -353,6 +354,8 @@ fill_default_server_options(ServerOption options->fingerprint_hash = SSH_FP_HASH_DEFAULT; if (options->use_kuserok == -1) options->use_kuserok = 1; @@ -38,7 +38,7 @@ diff -up openssh-6.8p1/servconf.c.GSSAPIEnablek5users openssh-6.8p1/servconf.c /* Turn privilege separation on by default */ if (use_privsep == -1) use_privsep = PRIVSEP_NOSANDBOX; -@@ -406,7 +409,7 @@ typedef enum { +@@ -412,7 +415,7 @@ typedef enum { sBanner, sShowPatchLevel, sUseDNS, sHostbasedAuthentication, sHostbasedUsesNameFromPacketOnly, sHostbasedAcceptedKeyTypes, sClientAliveInterval, sClientAliveCountMax, sAuthorizedKeysFile, @@ -47,7 +47,7 @@ diff -up openssh-6.8p1/servconf.c.GSSAPIEnablek5users openssh-6.8p1/servconf.c sGssKeyEx, sGssStoreRekey, sAcceptEnv, sPermitTunnel, sMatch, sPermitOpen, sForceCommand, sChrootDirectory, sUsePrivilegeSeparation, sAllowAgentForwarding, -@@ -484,6 +487,7 @@ static struct { +@@ -490,12 +493,14 @@ static struct { { "gssapistrictacceptorcheck", sGssStrictAcceptor, SSHCFG_GLOBAL }, { "gssapikeyexchange", sGssKeyEx, SSHCFG_GLOBAL }, { "gssapistorecredentialsonrekey", sGssStoreRekey, SSHCFG_GLOBAL }, @@ -55,7 +55,6 @@ diff -up openssh-6.8p1/servconf.c.GSSAPIEnablek5users openssh-6.8p1/servconf.c #else { "gssapiauthentication", sUnsupported, SSHCFG_ALL }, { "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL }, -@@ -491,6 +495,7 @@ static struct { { "gssapistrictacceptorcheck", sUnsupported, SSHCFG_GLOBAL }, { "gssapikeyexchange", sUnsupported, SSHCFG_GLOBAL }, { "gssapistorecredentialsonrekey", sUnsupported, SSHCFG_GLOBAL }, @@ -63,7 +62,7 @@ diff -up openssh-6.8p1/servconf.c.GSSAPIEnablek5users openssh-6.8p1/servconf.c #endif { "gssusesessionccache", sUnsupported, SSHCFG_GLOBAL }, { "gssapiusesessioncredcache", sUnsupported, SSHCFG_GLOBAL }, -@@ -1623,6 +1628,10 @@ process_server_config_line(ServerOptions +@@ -1663,6 +1668,10 @@ process_server_config_line(ServerOptions intptr = &options->use_kuserok; goto parse_flag; @@ -74,7 +73,7 @@ diff -up openssh-6.8p1/servconf.c.GSSAPIEnablek5users openssh-6.8p1/servconf.c case sPermitOpen: arg = strdelim(&cp); if (!arg || *arg == '\0') -@@ -1947,6 +1956,7 @@ copy_set_server_options(ServerOptions *d +@@ -2018,6 +2027,7 @@ copy_set_server_options(ServerOptions *d M_CP_INTOPT(ip_qos_interactive); M_CP_INTOPT(ip_qos_bulk); M_CP_INTOPT(use_kuserok); @@ -82,7 +81,7 @@ diff -up openssh-6.8p1/servconf.c.GSSAPIEnablek5users openssh-6.8p1/servconf.c M_CP_INTOPT(rekey_limit); M_CP_INTOPT(rekey_interval); -@@ -2207,6 +2217,7 @@ dump_config(ServerOptions *o) +@@ -2300,6 +2310,7 @@ dump_config(ServerOptions *o) dump_cfg_fmtint(sUsePrivilegeSeparation, use_privsep); dump_cfg_fmtint(sFingerprintHash, o->fingerprint_hash); dump_cfg_fmtint(sKerberosUseKuserok, o->use_kuserok); @@ -90,10 +89,10 @@ diff -up openssh-6.8p1/servconf.c.GSSAPIEnablek5users openssh-6.8p1/servconf.c /* string arguments */ dump_cfg_string(sPidFile, o->pid_file); -diff -up openssh-6.8p1/servconf.h.GSSAPIEnablek5users openssh-6.8p1/servconf.h ---- openssh-6.8p1/servconf.h.GSSAPIEnablek5users 2015-03-18 13:04:21.506306815 +0100 -+++ openssh-6.8p1/servconf.h 2015-03-18 13:04:21.528306762 +0100 -@@ -177,7 +177,8 @@ typedef struct { +diff -up openssh/servconf.h.GSSAPIEnablek5users openssh/servconf.h +--- openssh/servconf.h.GSSAPIEnablek5users 2015-06-24 11:40:03.717448351 +0200 ++++ openssh/servconf.h 2015-06-24 11:40:03.740448292 +0200 +@@ -179,7 +179,8 @@ typedef struct { int num_permitted_opens; @@ -103,21 +102,10 @@ diff -up openssh-6.8p1/servconf.h.GSSAPIEnablek5users openssh-6.8p1/servconf.h char *chroot_directory; char *revoked_keys_file; char *trusted_user_ca_keys; -diff -up openssh-6.8p1/sshd_config.GSSAPIEnablek5users openssh-6.8p1/sshd_config ---- openssh-6.8p1/sshd_config.GSSAPIEnablek5users 2015-03-18 13:04:21.506306815 +0100 -+++ openssh-6.8p1/sshd_config 2015-03-18 13:04:21.528306762 +0100 -@@ -94,6 +94,7 @@ GSSAPIAuthentication yes - GSSAPICleanupCredentials no - #GSSAPIStrictAcceptorCheck yes - #GSSAPIKeyExchange no -+#GSSAPIEnablek5users no - - # Set this to 'yes' to enable PAM authentication, account processing, - # and session processing. If this is enabled, PAM authentication will -diff -up openssh-6.8p1/sshd_config.5.GSSAPIEnablek5users openssh-6.8p1/sshd_config.5 ---- openssh-6.8p1/sshd_config.5.GSSAPIEnablek5users 2015-03-18 13:04:21.506306815 +0100 -+++ openssh-6.8p1/sshd_config.5 2015-03-18 13:04:21.528306762 +0100 -@@ -576,6 +576,12 @@ on logout. +diff -up openssh/sshd_config.5.GSSAPIEnablek5users openssh/sshd_config.5 +--- openssh/sshd_config.5.GSSAPIEnablek5users 2015-06-24 11:40:03.741448290 +0200 ++++ openssh/sshd_config.5 2015-06-24 11:40:40.707354263 +0200 +@@ -628,6 +628,12 @@ on logout. The default is .Dq yes . Note that this option applies to protocol version 2 only. @@ -128,5 +116,16 @@ diff -up openssh-6.8p1/sshd_config.5.GSSAPIEnablek5users openssh-6.8p1/sshd_conf +The default is +.Dq no . .It Cm GSSAPIStrictAcceptorCheck - Determines whether to be strict about the identity of the GSSAPI acceptor - a client authenticates against. If + Determines whether to be strict about the identity of the GSSAPI acceptor + a client authenticates against. +diff -up openssh/sshd_config.GSSAPIEnablek5users openssh/sshd_config +--- openssh/sshd_config.GSSAPIEnablek5users 2015-06-24 11:40:03.717448351 +0200 ++++ openssh/sshd_config 2015-06-24 11:40:03.740448292 +0200 +@@ -94,6 +94,7 @@ GSSAPIAuthentication yes + GSSAPICleanupCredentials no + #GSSAPIStrictAcceptorCheck yes + #GSSAPIKeyExchange no ++#GSSAPIEnablek5users no + + # Set this to 'yes' to enable PAM authentication, account processing, + # and session processing. If this is enabled, PAM authentication will diff --git a/openssh-6.6p1-ctr-cavstest.patch b/openssh-6.6p1-ctr-cavstest.patch index 6f4f1e8..48bb1d0 100644 --- a/openssh-6.6p1-ctr-cavstest.patch +++ b/openssh-6.6p1-ctr-cavstest.patch @@ -133,7 +133,7 @@ diff -up openssh-6.8p1/ctr-cavstest.c.ctr-cavs openssh-6.8p1/ctr-cavstest.c + break; + + total += n; -+ buf = xrealloc(buf, total + READ_CHUNK, 1); ++ buf = xreallocarray(buf, total + READ_CHUNK, 1); + } while(total < MAX_READ_SIZE); + return buf; +} diff --git a/openssh-6.6p1-force_krb.patch b/openssh-6.6p1-force_krb.patch index 6703c15..19f075e 100644 --- a/openssh-6.6p1-force_krb.patch +++ b/openssh-6.6p1-force_krb.patch @@ -163,7 +163,7 @@ index 413b845..54dd383 100644 + k5users_allowed_cmds[ncommands-1] = + xstrdup(pw->pw_shell); + k5users_allowed_cmds = -+ xrealloc(k5users_allowed_cmds, ++ncommands, ++ xreallocarray(k5users_allowed_cmds, ++ncommands, + sizeof(*k5users_allowed_cmds)); + break; + } @@ -176,7 +176,7 @@ index 413b845..54dd383 100644 + k5users_allowed_cmds[ncommands-1] = + xstrdup(token); + k5users_allowed_cmds = -+ xrealloc(k5users_allowed_cmds, ++ncommands, ++ xreallocarray(k5users_allowed_cmds, ++ncommands, + sizeof(*k5users_allowed_cmds)); + token = strtok(NULL, " \t\n"); + } diff --git a/openssh-6.6p1-gsskex.patch b/openssh-6.6p1-gsskex.patch index 42b6a10..1cfd53f 100644 --- a/openssh-6.6p1-gsskex.patch +++ b/openssh-6.6p1-gsskex.patch @@ -1,26 +1,25 @@ -diff -up openssh-6.8p1/Makefile.in.gsskex openssh-6.8p1/Makefile.in ---- openssh-6.8p1/Makefile.in.gsskex 2015-03-18 11:24:48.875900767 +0100 -+++ openssh-6.8p1/Makefile.in 2015-03-18 12:34:36.468748216 +0100 -@@ -90,6 +90,7 @@ LIBSSH_OBJS=${LIBOPENSSH_OBJS} \ - readpass.o rsa.o ttymodes.o xmalloc.o addrmatch.o \ - atomicio.o key.o dispatch.o mac.o uidswap.o uuencode.o misc.o \ - monitor_fdpass.o rijndael.o ssh-dss.o ssh-ecdsa.o ssh-rsa.o dh.o \ -+ kexgssc.o \ - msg.o progressmeter.o dns.o entropy.o gss-genr.o umac.o umac128.o \ - ssh-pkcs11.o smult_curve25519_ref.o \ - poly1305.o chacha.o cipher-chachapoly.o \ -@@ -111,7 +112,7 @@ SSHDOBJS=sshd.o auth-rhosts.o auth-passw - auth-skey.o auth-bsdauth.o auth2-hostbased.o auth2-kbdint.o \ - auth2-none.o auth2-passwd.o auth2-pubkey.o \ - monitor_mm.o monitor.o monitor_wrap.o auth-krb5.o \ -- auth2-gss.o gss-serv.o gss-serv-krb5.o \ -+ auth2-gss.o gss-serv.o gss-serv-krb5.o kexgsss.o \ - loginrec.o auth-pam.o auth-shadow.o auth-sia.o md5crypt.o \ - sftp-server.o sftp-common.o \ - roaming_common.o roaming_serv.o \ -diff -up openssh-6.8p1/auth2-gss.c.gsskex openssh-6.8p1/auth2-gss.c ---- openssh-6.8p1/auth2-gss.c.gsskex 2015-03-18 11:24:48.832900869 +0100 -+++ openssh-6.8p1/auth2-gss.c 2015-03-18 12:32:50.584011552 +0100 +diff -up openssh/auth2.c.gsskex openssh/auth2.c +--- openssh/auth2.c.gsskex 2015-06-24 11:07:36.180389924 +0200 ++++ openssh/auth2.c 2015-06-24 11:07:36.228389804 +0200 +@@ -70,6 +70,7 @@ extern Authmethod method_passwd; + extern Authmethod method_kbdint; + extern Authmethod method_hostbased; + #ifdef GSSAPI ++extern Authmethod method_gsskeyex; + extern Authmethod method_gssapi; + #endif + +@@ -77,6 +78,7 @@ Authmethod *authmethods[] = { + &method_none, + &method_pubkey, + #ifdef GSSAPI ++ &method_gsskeyex, + &method_gssapi, + #endif + &method_passwd, +diff -up openssh/auth2-gss.c.gsskex openssh/auth2-gss.c +--- openssh/auth2-gss.c.gsskex 2015-06-24 11:07:36.179389926 +0200 ++++ openssh/auth2-gss.c 2015-06-24 11:07:36.228389804 +0200 @@ -31,6 +31,7 @@ #include @@ -103,28 +102,9 @@ diff -up openssh-6.8p1/auth2-gss.c.gsskex openssh-6.8p1/auth2-gss.c Authmethod method_gssapi = { "gssapi-with-mic", userauth_gssapi, -diff -up openssh-6.8p1/auth2.c.gsskex openssh-6.8p1/auth2.c ---- openssh-6.8p1/auth2.c.gsskex 2015-03-18 11:24:48.832900869 +0100 -+++ openssh-6.8p1/auth2.c 2015-03-18 11:24:48.875900767 +0100 -@@ -70,6 +70,7 @@ extern Authmethod method_passwd; - extern Authmethod method_kbdint; - extern Authmethod method_hostbased; - #ifdef GSSAPI -+extern Authmethod method_gsskeyex; - extern Authmethod method_gssapi; - #endif - -@@ -77,6 +78,7 @@ Authmethod *authmethods[] = { - &method_none, - &method_pubkey, - #ifdef GSSAPI -+ &method_gsskeyex, - &method_gssapi, - #endif - &method_passwd, -diff -up openssh-6.8p1/clientloop.c.gsskex openssh-6.8p1/clientloop.c ---- openssh-6.8p1/clientloop.c.gsskex 2015-03-18 11:24:48.875900767 +0100 -+++ openssh-6.8p1/clientloop.c 2015-03-18 12:30:42.647329654 +0100 +diff -up openssh/clientloop.c.gsskex openssh/clientloop.c +--- openssh/clientloop.c.gsskex 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/clientloop.c 2015-06-24 11:07:36.228389804 +0200 @@ -114,6 +114,10 @@ #include "ssherr.h" #include "hostfile.h" @@ -152,10 +132,10 @@ diff -up openssh-6.8p1/clientloop.c.gsskex openssh-6.8p1/clientloop.c if (need_rekeying || packet_need_rekeying()) { debug("need rekeying"); active_state->kex->done = 0; -diff -up openssh-6.8p1/configure.ac.gsskex openssh-6.8p1/configure.ac ---- openssh-6.8p1/configure.ac.gsskex 2015-03-18 11:24:48.866900788 +0100 -+++ openssh-6.8p1/configure.ac 2015-03-18 11:24:48.876900765 +0100 -@@ -620,6 +620,30 @@ main() { if (NSVersionOfRunTimeLibrary(" +diff -up openssh/configure.ac.gsskex openssh/configure.ac +--- openssh/configure.ac.gsskex 2015-06-24 11:07:36.214389839 +0200 ++++ openssh/configure.ac 2015-06-24 11:07:36.229389802 +0200 +@@ -625,6 +625,30 @@ main() { if (NSVersionOfRunTimeLibrary(" [Use tunnel device compatibility to OpenBSD]) AC_DEFINE([SSH_TUN_PREPEND_AF], [1], [Prepend the address family to IP tunnel traffic]) @@ -186,10 +166,10 @@ diff -up openssh-6.8p1/configure.ac.gsskex openssh-6.8p1/configure.ac m4_pattern_allow([AU_IPv]) AC_CHECK_DECL([AU_IPv4], [], AC_DEFINE([AU_IPv4], [0], [System only supports IPv4 audit records]) -diff -up openssh-6.8p1/gss-genr.c.gsskex openssh-6.8p1/gss-genr.c ---- openssh-6.8p1/gss-genr.c.gsskex 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/gss-genr.c 2015-03-18 11:24:48.876900765 +0100 -@@ -40,12 +40,167 @@ +diff -up openssh/gss-genr.c.gsskex openssh/gss-genr.c +--- openssh/gss-genr.c.gsskex 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/gss-genr.c 2015-06-24 11:07:36.229389802 +0200 +@@ -41,12 +41,167 @@ #include "buffer.h" #include "log.h" #include "ssh2.h" @@ -357,7 +337,7 @@ diff -up openssh-6.8p1/gss-genr.c.gsskex openssh-6.8p1/gss-genr.c /* Check that the OID in a data stream matches that in the context */ int ssh_gssapi_check_oid(Gssctxt *ctx, void *data, size_t len) -@@ -198,7 +353,7 @@ ssh_gssapi_init_ctx(Gssctxt *ctx, int de +@@ -199,7 +354,7 @@ ssh_gssapi_init_ctx(Gssctxt *ctx, int de } ctx->major = gss_init_sec_context(&ctx->minor, @@ -366,7 +346,7 @@ diff -up openssh-6.8p1/gss-genr.c.gsskex openssh-6.8p1/gss-genr.c GSS_C_MUTUAL_FLAG | GSS_C_INTEG_FLAG | deleg_flag, 0, NULL, recv_tok, NULL, send_tok, flags, NULL); -@@ -228,8 +383,42 @@ ssh_gssapi_import_name(Gssctxt *ctx, con +@@ -229,8 +384,42 @@ ssh_gssapi_import_name(Gssctxt *ctx, con } OM_uint32 @@ -409,7 +389,7 @@ diff -up openssh-6.8p1/gss-genr.c.gsskex openssh-6.8p1/gss-genr.c if ((ctx->major = gss_get_mic(&ctx->minor, ctx->context, GSS_C_QOP_DEFAULT, buffer, hash))) ssh_gssapi_error(ctx); -@@ -237,6 +426,19 @@ ssh_gssapi_sign(Gssctxt *ctx, gss_buffer +@@ -238,6 +427,19 @@ ssh_gssapi_sign(Gssctxt *ctx, gss_buffer return (ctx->major); } @@ -429,7 +409,7 @@ diff -up openssh-6.8p1/gss-genr.c.gsskex openssh-6.8p1/gss-genr.c void ssh_gssapi_buildmic(Buffer *b, const char *user, const char *service, const char *context) -@@ -250,11 +452,16 @@ ssh_gssapi_buildmic(Buffer *b, const cha +@@ -251,11 +453,16 @@ ssh_gssapi_buildmic(Buffer *b, const cha } int @@ -447,7 +427,7 @@ diff -up openssh-6.8p1/gss-genr.c.gsskex openssh-6.8p1/gss-genr.c /* RFC 4462 says we MUST NOT do SPNEGO */ if (oid->length == spnego_oid.length && -@@ -264,6 +471,10 @@ ssh_gssapi_check_mechanism(Gssctxt **ctx +@@ -265,6 +472,10 @@ ssh_gssapi_check_mechanism(Gssctxt **ctx ssh_gssapi_build_ctx(ctx); ssh_gssapi_set_oid(*ctx, oid); major = ssh_gssapi_import_name(*ctx, host); @@ -458,7 +438,7 @@ diff -up openssh-6.8p1/gss-genr.c.gsskex openssh-6.8p1/gss-genr.c if (!GSS_ERROR(major)) { major = ssh_gssapi_init_ctx(*ctx, 0, GSS_C_NO_BUFFER, &token, NULL); -@@ -273,10 +484,66 @@ ssh_gssapi_check_mechanism(Gssctxt **ctx +@@ -274,10 +485,66 @@ ssh_gssapi_check_mechanism(Gssctxt **ctx GSS_C_NO_BUFFER); } @@ -526,9 +506,294 @@ diff -up openssh-6.8p1/gss-genr.c.gsskex openssh-6.8p1/gss-genr.c +} + #endif /* GSSAPI */ -diff -up openssh-6.8p1/gss-serv-krb5.c.gsskex openssh-6.8p1/gss-serv-krb5.c ---- openssh-6.8p1/gss-serv-krb5.c.gsskex 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/gss-serv-krb5.c 2015-03-18 11:24:48.876900765 +0100 +diff -up openssh/gss-serv.c.gsskex openssh/gss-serv.c +--- openssh/gss-serv.c.gsskex 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/gss-serv.c 2015-06-24 11:11:53.171742794 +0200 +@@ -45,17 +45,19 @@ + #include "session.h" + #include "misc.h" + #include "servconf.h" ++#include "uidswap.h" + + #include "ssh-gss.h" ++#include "monitor_wrap.h" + + extern ServerOptions options; + + static ssh_gssapi_client gssapi_client = + { GSS_C_EMPTY_BUFFER, GSS_C_EMPTY_BUFFER, +- GSS_C_NO_CREDENTIAL, NULL, {NULL, NULL, NULL, NULL}}; ++ GSS_C_NO_CREDENTIAL, GSS_C_NO_NAME, {NULL, NULL, NULL}, 0, 0}; + + ssh_gssapi_mech gssapi_null_mech = +- { NULL, NULL, {0, NULL}, NULL, NULL, NULL, NULL}; ++ { NULL, NULL, {0, NULL}, NULL, NULL, NULL, NULL, NULL}; + + #ifdef KRB5 + extern ssh_gssapi_mech gssapi_kerberos_mech; +@@ -142,6 +144,29 @@ ssh_gssapi_server_ctx(Gssctxt **ctx, gss + } + + /* Unprivileged */ ++char * ++ssh_gssapi_server_mechanisms() { ++ gss_OID_set supported; ++ ++ ssh_gssapi_supported_oids(&supported); ++ return (ssh_gssapi_kex_mechs(supported, &ssh_gssapi_server_check_mech, ++ NULL, NULL)); ++} ++ ++/* Unprivileged */ ++int ++ssh_gssapi_server_check_mech(Gssctxt **dum, gss_OID oid, const char *data, ++ const char *dummy) { ++ Gssctxt *ctx = NULL; ++ int res; ++ ++ res = !GSS_ERROR(PRIVSEP(ssh_gssapi_server_ctx(&ctx, oid))); ++ ssh_gssapi_delete_ctx(&ctx); ++ ++ return (res); ++} ++ ++/* Unprivileged */ + void + ssh_gssapi_supported_oids(gss_OID_set *oidset) + { +@@ -151,7 +176,9 @@ ssh_gssapi_supported_oids(gss_OID_set *o + gss_OID_set supported; + + gss_create_empty_oid_set(&min_status, oidset); +- gss_indicate_mechs(&min_status, &supported); ++ ++ if (GSS_ERROR(gss_indicate_mechs(&min_status, &supported))) ++ return; + + while (supported_mechs[i]->name != NULL) { + if (GSS_ERROR(gss_test_oid_set_member(&min_status, +@@ -277,8 +304,48 @@ OM_uint32 + ssh_gssapi_getclient(Gssctxt *ctx, ssh_gssapi_client *client) + { + int i = 0; ++ int equal = 0; ++ gss_name_t new_name = GSS_C_NO_NAME; ++ gss_buffer_desc ename = GSS_C_EMPTY_BUFFER; ++ ++ if (options.gss_store_rekey && client->used && ctx->client_creds) { ++ if (client->mech->oid.length != ctx->oid->length || ++ (memcmp(client->mech->oid.elements, ++ ctx->oid->elements, ctx->oid->length) !=0)) { ++ debug("Rekeyed credentials have different mechanism"); ++ return GSS_S_COMPLETE; ++ } ++ ++ if ((ctx->major = gss_inquire_cred_by_mech(&ctx->minor, ++ ctx->client_creds, ctx->oid, &new_name, ++ NULL, NULL, NULL))) { ++ ssh_gssapi_error(ctx); ++ return (ctx->major); ++ } + +- gss_buffer_desc ename; ++ ctx->major = gss_compare_name(&ctx->minor, client->name, ++ new_name, &equal); ++ ++ if (GSS_ERROR(ctx->major)) { ++ ssh_gssapi_error(ctx); ++ return (ctx->major); ++ } ++ ++ if (!equal) { ++ debug("Rekeyed credentials have different name"); ++ return GSS_S_COMPLETE; ++ } ++ ++ debug("Marking rekeyed credentials for export"); ++ ++ gss_release_name(&ctx->minor, &client->name); ++ gss_release_cred(&ctx->minor, &client->creds); ++ client->name = new_name; ++ client->creds = ctx->client_creds; ++ ctx->client_creds = GSS_C_NO_CREDENTIAL; ++ client->updated = 1; ++ return GSS_S_COMPLETE; ++ } + + client->mech = NULL; + +@@ -293,6 +360,13 @@ ssh_gssapi_getclient(Gssctxt *ctx, ssh_g + if (client->mech == NULL) + return GSS_S_FAILURE; + ++ if (ctx->client_creds && ++ (ctx->major = gss_inquire_cred_by_mech(&ctx->minor, ++ ctx->client_creds, ctx->oid, &client->name, NULL, NULL, NULL))) { ++ ssh_gssapi_error(ctx); ++ return (ctx->major); ++ } ++ + if ((ctx->major = gss_display_name(&ctx->minor, ctx->client, + &client->displayname, NULL))) { + ssh_gssapi_error(ctx); +@@ -310,6 +384,8 @@ ssh_gssapi_getclient(Gssctxt *ctx, ssh_g + return (ctx->major); + } + ++ gss_release_buffer(&ctx->minor, &ename); ++ + /* We can't copy this structure, so we just move the pointer to it */ + client->creds = ctx->client_creds; + ctx->client_creds = GSS_C_NO_CREDENTIAL; +@@ -320,11 +396,20 @@ ssh_gssapi_getclient(Gssctxt *ctx, ssh_g + void + ssh_gssapi_cleanup_creds(void) + { +- if (gssapi_client.store.filename != NULL) { +- /* Unlink probably isn't sufficient */ +- debug("removing gssapi cred file\"%s\"", +- gssapi_client.store.filename); +- unlink(gssapi_client.store.filename); ++ krb5_ccache ccache = NULL; ++ krb5_error_code problem; ++ ++ if (gssapi_client.store.data != NULL) { ++ if ((problem = krb5_cc_resolve(gssapi_client.store.data, gssapi_client.store.envval, &ccache))) { ++ debug("%s: krb5_cc_resolve(): %.100s", __func__, ++ krb5_get_err_text(gssapi_client.store.data, problem)); ++ } else if ((problem = krb5_cc_destroy(gssapi_client.store.data, ccache))) { ++ debug("%s: krb5_cc_resolve(): %.100s", __func__, ++ krb5_get_err_text(gssapi_client.store.data, problem)); ++ } else { ++ krb5_free_context(gssapi_client.store.data); ++ gssapi_client.store.data = NULL; ++ } + } + } + +@@ -357,7 +442,7 @@ ssh_gssapi_do_child(char ***envp, u_int + + /* Privileged */ + int +-ssh_gssapi_userok(char *user) ++ssh_gssapi_userok(char *user, struct passwd *pw) + { + OM_uint32 lmin; + +@@ -367,9 +452,11 @@ ssh_gssapi_userok(char *user) + return 0; + } + if (gssapi_client.mech && gssapi_client.mech->userok) +- if ((*gssapi_client.mech->userok)(&gssapi_client, user)) ++ if ((*gssapi_client.mech->userok)(&gssapi_client, user)) { ++ gssapi_client.used = 1; ++ gssapi_client.store.owner = pw; + return 1; +- else { ++ } else { + /* Destroy delegated credentials if userok fails */ + gss_release_buffer(&lmin, &gssapi_client.displayname); + gss_release_buffer(&lmin, &gssapi_client.exportedname); +@@ -383,14 +470,90 @@ ssh_gssapi_userok(char *user) + return (0); + } + +-/* Privileged */ +-OM_uint32 +-ssh_gssapi_checkmic(Gssctxt *ctx, gss_buffer_t gssbuf, gss_buffer_t gssmic) ++/* These bits are only used for rekeying. The unpriviledged child is running ++ * as the user, the monitor is root. ++ * ++ * In the child, we want to : ++ * *) Ask the monitor to store our credentials into the store we specify ++ * *) If it succeeds, maybe do a PAM update ++ */ ++ ++/* Stuff for PAM */ ++ ++#ifdef USE_PAM ++static int ssh_gssapi_simple_conv(int n, const struct pam_message **msg, ++ struct pam_response **resp, void *data) + { +- ctx->major = gss_verify_mic(&ctx->minor, ctx->context, +- gssbuf, gssmic, NULL); ++ return (PAM_CONV_ERR); ++} ++#endif + +- return (ctx->major); ++void ++ssh_gssapi_rekey_creds() { ++ int ok; ++ int ret; ++#ifdef USE_PAM ++ pam_handle_t *pamh = NULL; ++ struct pam_conv pamconv = {ssh_gssapi_simple_conv, NULL}; ++ char *envstr; ++#endif ++ ++ if (gssapi_client.store.filename == NULL && ++ gssapi_client.store.envval == NULL && ++ gssapi_client.store.envvar == NULL) ++ return; ++ ++ ok = PRIVSEP(ssh_gssapi_update_creds(&gssapi_client.store)); ++ ++ if (!ok) ++ return; ++ ++ debug("Rekeyed credentials stored successfully"); ++ ++ /* Actually managing to play with the ssh pam stack from here will ++ * be next to impossible. In any case, we may want different options ++ * for rekeying. So, use our own :) ++ */ ++#ifdef USE_PAM ++ if (!use_privsep) { ++ debug("Not even going to try and do PAM with privsep disabled"); ++ return; ++ } ++ ++ ret = pam_start("sshd-rekey", gssapi_client.store.owner->pw_name, ++ &pamconv, &pamh); ++ if (ret) ++ return; ++ ++ xasprintf(&envstr, "%s=%s", gssapi_client.store.envvar, ++ gssapi_client.store.envval); ++ ++ ret = pam_putenv(pamh, envstr); ++ if (!ret) ++ pam_setcred(pamh, PAM_REINITIALIZE_CRED); ++ pam_end(pamh, PAM_SUCCESS); ++#endif ++} ++ ++int ++ssh_gssapi_update_creds(ssh_gssapi_ccache *store) { ++ int ok = 0; ++ ++ /* Check we've got credentials to store */ ++ if (!gssapi_client.updated) ++ return 0; ++ ++ gssapi_client.updated = 0; ++ ++ temporarily_use_uid(gssapi_client.store.owner); ++ if (gssapi_client.mech && gssapi_client.mech->updatecreds) ++ ok = (*gssapi_client.mech->updatecreds)(store, &gssapi_client); ++ else ++ debug("No update function for this mechanism"); ++ ++ restore_uid(); ++ ++ return ok; + } + + #endif +diff -up openssh/gss-serv-krb5.c.gsskex openssh/gss-serv-krb5.c +--- openssh/gss-serv-krb5.c.gsskex 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/gss-serv-krb5.c 2015-06-24 11:07:36.229389802 +0200 @@ -121,7 +121,7 @@ ssh_gssapi_krb5_storecreds(ssh_gssapi_cl krb5_error_code problem; krb5_principal princ; @@ -656,343 +921,9 @@ diff -up openssh-6.8p1/gss-serv-krb5.c.gsskex openssh-6.8p1/gss-serv-krb5.c }; #endif /* KRB5 */ -diff -up openssh-6.8p1/gss-serv.c.gsskex openssh-6.8p1/gss-serv.c ---- openssh-6.8p1/gss-serv.c.gsskex 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/gss-serv.c 2015-03-18 11:24:48.877900762 +0100 -@@ -44,15 +44,20 @@ - #include "channels.h" - #include "session.h" - #include "misc.h" -+#include "servconf.h" -+#include "uidswap.h" - - #include "ssh-gss.h" -+#include "monitor_wrap.h" -+ -+extern ServerOptions options; - - static ssh_gssapi_client gssapi_client = - { GSS_C_EMPTY_BUFFER, GSS_C_EMPTY_BUFFER, -- GSS_C_NO_CREDENTIAL, NULL, {NULL, NULL, NULL, NULL}}; -+ GSS_C_NO_CREDENTIAL, GSS_C_NO_NAME, NULL, {NULL, NULL, NULL}, 0, 0}; - - ssh_gssapi_mech gssapi_null_mech = -- { NULL, NULL, {0, NULL}, NULL, NULL, NULL, NULL}; -+ { NULL, NULL, {0, NULL}, NULL, NULL, NULL, NULL, NULL}; - - #ifdef KRB5 - extern ssh_gssapi_mech gssapi_kerberos_mech; -@@ -99,25 +104,32 @@ ssh_gssapi_acquire_cred(Gssctxt *ctx) - char lname[NI_MAXHOST]; - gss_OID_set oidset; - -- gss_create_empty_oid_set(&status, &oidset); -- gss_add_oid_set_member(&status, ctx->oid, &oidset); -- -- if (gethostname(lname, sizeof(lname))) { -- gss_release_oid_set(&status, &oidset); -- return (-1); -- } -+ if (options.gss_strict_acceptor) { -+ gss_create_empty_oid_set(&status, &oidset); -+ gss_add_oid_set_member(&status, ctx->oid, &oidset); -+ -+ if (gethostname(lname, sizeof(lname))) { -+ gss_release_oid_set(&status, &oidset); -+ return (-1); -+ } -+ -+ if (GSS_ERROR(ssh_gssapi_import_name(ctx, lname))) { -+ gss_release_oid_set(&status, &oidset); -+ return (ctx->major); -+ } -+ -+ if ((ctx->major = gss_acquire_cred(&ctx->minor, -+ ctx->name, 0, oidset, GSS_C_ACCEPT, &ctx->creds, NULL, NULL))) -+ ssh_gssapi_error(ctx); - -- if (GSS_ERROR(ssh_gssapi_import_name(ctx, lname))) { - gss_release_oid_set(&status, &oidset); - return (ctx->major); -- } -+ } else { -+ ctx->name = GSS_C_NO_NAME; -+ ctx->creds = GSS_C_NO_CREDENTIAL; -+ return GSS_S_COMPLETE; -+ } - -- if ((ctx->major = gss_acquire_cred(&ctx->minor, -- ctx->name, 0, oidset, GSS_C_ACCEPT, &ctx->creds, NULL, NULL))) -- ssh_gssapi_error(ctx); -- -- gss_release_oid_set(&status, &oidset); -- return (ctx->major); - } - - /* Privileged */ -@@ -132,6 +144,29 @@ ssh_gssapi_server_ctx(Gssctxt **ctx, gss - } - - /* Unprivileged */ -+char * -+ssh_gssapi_server_mechanisms() { -+ gss_OID_set supported; -+ -+ ssh_gssapi_supported_oids(&supported); -+ return (ssh_gssapi_kex_mechs(supported, &ssh_gssapi_server_check_mech, -+ NULL, NULL)); -+} -+ -+/* Unprivileged */ -+int -+ssh_gssapi_server_check_mech(Gssctxt **dum, gss_OID oid, const char *data, -+ const char *dummy) { -+ Gssctxt *ctx = NULL; -+ int res; -+ -+ res = !GSS_ERROR(PRIVSEP(ssh_gssapi_server_ctx(&ctx, oid))); -+ ssh_gssapi_delete_ctx(&ctx); -+ -+ return (res); -+} -+ -+/* Unprivileged */ - void - ssh_gssapi_supported_oids(gss_OID_set *oidset) - { -@@ -141,7 +176,9 @@ ssh_gssapi_supported_oids(gss_OID_set *o - gss_OID_set supported; - - gss_create_empty_oid_set(&min_status, oidset); -- gss_indicate_mechs(&min_status, &supported); -+ -+ if (GSS_ERROR(gss_indicate_mechs(&min_status, &supported))) -+ return; - - while (supported_mechs[i]->name != NULL) { - if (GSS_ERROR(gss_test_oid_set_member(&min_status, -@@ -267,8 +304,48 @@ OM_uint32 - ssh_gssapi_getclient(Gssctxt *ctx, ssh_gssapi_client *client) - { - int i = 0; -+ int equal = 0; -+ gss_name_t new_name = GSS_C_NO_NAME; -+ gss_buffer_desc ename = GSS_C_EMPTY_BUFFER; -+ -+ if (options.gss_store_rekey && client->used && ctx->client_creds) { -+ if (client->mech->oid.length != ctx->oid->length || -+ (memcmp(client->mech->oid.elements, -+ ctx->oid->elements, ctx->oid->length) !=0)) { -+ debug("Rekeyed credentials have different mechanism"); -+ return GSS_S_COMPLETE; -+ } -+ -+ if ((ctx->major = gss_inquire_cred_by_mech(&ctx->minor, -+ ctx->client_creds, ctx->oid, &new_name, -+ NULL, NULL, NULL))) { -+ ssh_gssapi_error(ctx); -+ return (ctx->major); -+ } - -- gss_buffer_desc ename; -+ ctx->major = gss_compare_name(&ctx->minor, client->name, -+ new_name, &equal); -+ -+ if (GSS_ERROR(ctx->major)) { -+ ssh_gssapi_error(ctx); -+ return (ctx->major); -+ } -+ -+ if (!equal) { -+ debug("Rekeyed credentials have different name"); -+ return GSS_S_COMPLETE; -+ } -+ -+ debug("Marking rekeyed credentials for export"); -+ -+ gss_release_name(&ctx->minor, &client->name); -+ gss_release_cred(&ctx->minor, &client->creds); -+ client->name = new_name; -+ client->creds = ctx->client_creds; -+ ctx->client_creds = GSS_C_NO_CREDENTIAL; -+ client->updated = 1; -+ return GSS_S_COMPLETE; -+ } - - client->mech = NULL; - -@@ -283,6 +360,13 @@ ssh_gssapi_getclient(Gssctxt *ctx, ssh_g - if (client->mech == NULL) - return GSS_S_FAILURE; - -+ if (ctx->client_creds && -+ (ctx->major = gss_inquire_cred_by_mech(&ctx->minor, -+ ctx->client_creds, ctx->oid, &client->name, NULL, NULL, NULL))) { -+ ssh_gssapi_error(ctx); -+ return (ctx->major); -+ } -+ - if ((ctx->major = gss_display_name(&ctx->minor, ctx->client, - &client->displayname, NULL))) { - ssh_gssapi_error(ctx); -@@ -300,6 +384,8 @@ ssh_gssapi_getclient(Gssctxt *ctx, ssh_g - return (ctx->major); - } - -+ gss_release_buffer(&ctx->minor, &ename); -+ - /* We can't copy this structure, so we just move the pointer to it */ - client->creds = ctx->client_creds; - ctx->client_creds = GSS_C_NO_CREDENTIAL; -@@ -310,11 +396,20 @@ ssh_gssapi_getclient(Gssctxt *ctx, ssh_g - void - ssh_gssapi_cleanup_creds(void) - { -- if (gssapi_client.store.filename != NULL) { -- /* Unlink probably isn't sufficient */ -- debug("removing gssapi cred file\"%s\"", -- gssapi_client.store.filename); -- unlink(gssapi_client.store.filename); -+ krb5_ccache ccache = NULL; -+ krb5_error_code problem; -+ -+ if (gssapi_client.store.data != NULL) { -+ if ((problem = krb5_cc_resolve(gssapi_client.store.data, gssapi_client.store.envval, &ccache))) { -+ debug("%s: krb5_cc_resolve(): %.100s", __func__, -+ krb5_get_err_text(gssapi_client.store.data, problem)); -+ } else if ((problem = krb5_cc_destroy(gssapi_client.store.data, ccache))) { -+ debug("%s: krb5_cc_resolve(): %.100s", __func__, -+ krb5_get_err_text(gssapi_client.store.data, problem)); -+ } else { -+ krb5_free_context(gssapi_client.store.data); -+ gssapi_client.store.data = NULL; -+ } - } - } - -@@ -347,7 +442,7 @@ ssh_gssapi_do_child(char ***envp, u_int - - /* Privileged */ - int --ssh_gssapi_userok(char *user) -+ssh_gssapi_userok(char *user, struct passwd *pw) - { - OM_uint32 lmin; - -@@ -357,9 +452,11 @@ ssh_gssapi_userok(char *user) - return 0; - } - if (gssapi_client.mech && gssapi_client.mech->userok) -- if ((*gssapi_client.mech->userok)(&gssapi_client, user)) -+ if ((*gssapi_client.mech->userok)(&gssapi_client, user)) { -+ gssapi_client.used = 1; -+ gssapi_client.store.owner = pw; - return 1; -- else { -+ } else { - /* Destroy delegated credentials if userok fails */ - gss_release_buffer(&lmin, &gssapi_client.displayname); - gss_release_buffer(&lmin, &gssapi_client.exportedname); -@@ -373,14 +470,90 @@ ssh_gssapi_userok(char *user) - return (0); - } - --/* Privileged */ --OM_uint32 --ssh_gssapi_checkmic(Gssctxt *ctx, gss_buffer_t gssbuf, gss_buffer_t gssmic) -+/* These bits are only used for rekeying. The unpriviledged child is running -+ * as the user, the monitor is root. -+ * -+ * In the child, we want to : -+ * *) Ask the monitor to store our credentials into the store we specify -+ * *) If it succeeds, maybe do a PAM update -+ */ -+ -+/* Stuff for PAM */ -+ -+#ifdef USE_PAM -+static int ssh_gssapi_simple_conv(int n, const struct pam_message **msg, -+ struct pam_response **resp, void *data) - { -- ctx->major = gss_verify_mic(&ctx->minor, ctx->context, -- gssbuf, gssmic, NULL); -+ return (PAM_CONV_ERR); -+} -+#endif - -- return (ctx->major); -+void -+ssh_gssapi_rekey_creds() { -+ int ok; -+ int ret; -+#ifdef USE_PAM -+ pam_handle_t *pamh = NULL; -+ struct pam_conv pamconv = {ssh_gssapi_simple_conv, NULL}; -+ char *envstr; -+#endif -+ -+ if (gssapi_client.store.filename == NULL && -+ gssapi_client.store.envval == NULL && -+ gssapi_client.store.envvar == NULL) -+ return; -+ -+ ok = PRIVSEP(ssh_gssapi_update_creds(&gssapi_client.store)); -+ -+ if (!ok) -+ return; -+ -+ debug("Rekeyed credentials stored successfully"); -+ -+ /* Actually managing to play with the ssh pam stack from here will -+ * be next to impossible. In any case, we may want different options -+ * for rekeying. So, use our own :) -+ */ -+#ifdef USE_PAM -+ if (!use_privsep) { -+ debug("Not even going to try and do PAM with privsep disabled"); -+ return; -+ } -+ -+ ret = pam_start("sshd-rekey", gssapi_client.store.owner->pw_name, -+ &pamconv, &pamh); -+ if (ret) -+ return; -+ -+ xasprintf(&envstr, "%s=%s", gssapi_client.store.envvar, -+ gssapi_client.store.envval); -+ -+ ret = pam_putenv(pamh, envstr); -+ if (!ret) -+ pam_setcred(pamh, PAM_REINITIALIZE_CRED); -+ pam_end(pamh, PAM_SUCCESS); -+#endif -+} -+ -+int -+ssh_gssapi_update_creds(ssh_gssapi_ccache *store) { -+ int ok = 0; -+ -+ /* Check we've got credentials to store */ -+ if (!gssapi_client.updated) -+ return 0; -+ -+ gssapi_client.updated = 0; -+ -+ temporarily_use_uid(gssapi_client.store.owner); -+ if (gssapi_client.mech && gssapi_client.mech->updatecreds) -+ ok = (*gssapi_client.mech->updatecreds)(store, &gssapi_client); -+ else -+ debug("No update function for this mechanism"); -+ -+ restore_uid(); -+ -+ return ok; - } - - #endif -diff -up openssh-6.8p1/kex.c.gsskex openssh-6.8p1/kex.c ---- openssh-6.8p1/kex.c.gsskex 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/kex.c 2015-03-18 12:29:33.452501699 +0100 +diff -up openssh/kex.c.gsskex openssh/kex.c +--- openssh/kex.c.gsskex 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/kex.c 2015-06-24 11:07:36.230389799 +0200 @@ -55,6 +55,10 @@ #include "sshbuf.h" #include "digest.h" @@ -1029,48 +960,9 @@ diff -up openssh-6.8p1/kex.c.gsskex openssh-6.8p1/kex.c } return NULL; } -diff -up openssh-6.8p1/kex.h.gsskex openssh-6.8p1/kex.h ---- openssh-6.8p1/kex.h.gsskex 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/kex.h 2015-03-18 12:28:17.600690296 +0100 -@@ -93,6 +93,11 @@ enum kex_exchange { - KEX_DH_GEX_SHA256, - KEX_ECDH_SHA2, - KEX_C25519_SHA256, -+#ifdef GSSAPI -+ KEX_GSS_GRP1_SHA1, -+ KEX_GSS_GRP14_SHA1, -+ KEX_GSS_GEX_SHA1, -+#endif - KEX_MAX - }; - -@@ -139,6 +144,12 @@ struct kex { - u_int flags; - int hash_alg; - int ec_nid; -+#ifdef GSSAPI -+ int gss_deleg_creds; -+ int gss_trust_dns; -+ char *gss_host; -+ char *gss_client; -+#endif - char *client_version_string; - char *server_version_string; - int (*verify_host_key)(struct sshkey *, struct ssh *); -@@ -183,6 +194,10 @@ int kexecdh_client(struct ssh *); - int kexecdh_server(struct ssh *); - int kexc25519_client(struct ssh *); - int kexc25519_server(struct ssh *); -+#ifdef GSSAPI -+int kexgss_client(struct ssh *); -+int kexgss_server(struct ssh *); -+#endif - - int kex_dh_hash(const char *, const char *, - const u_char *, size_t, const u_char *, size_t, const u_char *, size_t, -diff -up openssh-6.8p1/kexgssc.c.gsskex openssh-6.8p1/kexgssc.c ---- openssh-6.8p1/kexgssc.c.gsskex 2015-03-18 11:24:48.877900762 +0100 -+++ openssh-6.8p1/kexgssc.c 2015-03-18 11:24:48.877900762 +0100 +diff -up openssh/kexgssc.c.gsskex openssh/kexgssc.c +--- openssh/kexgssc.c.gsskex 2015-06-24 11:07:36.231389797 +0200 ++++ openssh/kexgssc.c 2015-06-24 11:07:36.230389799 +0200 @@ -0,0 +1,338 @@ +/* + * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved. @@ -1410,9 +1302,9 @@ diff -up openssh-6.8p1/kexgssc.c.gsskex openssh-6.8p1/kexgssc.c +} + +#endif /* GSSAPI */ -diff -up openssh-6.8p1/kexgsss.c.gsskex openssh-6.8p1/kexgsss.c ---- openssh-6.8p1/kexgsss.c.gsskex 2015-03-18 11:24:48.878900760 +0100 -+++ openssh-6.8p1/kexgsss.c 2015-03-18 11:24:48.878900760 +0100 +diff -up openssh/kexgsss.c.gsskex openssh/kexgsss.c +--- openssh/kexgsss.c.gsskex 2015-06-24 11:07:36.231389797 +0200 ++++ openssh/kexgsss.c 2015-06-24 11:07:36.231389797 +0200 @@ -0,0 +1,295 @@ +/* + * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved. @@ -1709,9 +1601,68 @@ diff -up openssh-6.8p1/kexgsss.c.gsskex openssh-6.8p1/kexgsss.c + return 0; +} +#endif /* GSSAPI */ -diff -up openssh-6.8p1/monitor.c.gsskex openssh-6.8p1/monitor.c ---- openssh-6.8p1/monitor.c.gsskex 2015-03-18 11:24:48.834900865 +0100 -+++ openssh-6.8p1/monitor.c 2015-03-18 12:24:38.971233895 +0100 +diff -up openssh/kex.h.gsskex openssh/kex.h +--- openssh/kex.h.gsskex 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/kex.h 2015-06-24 11:07:36.230389799 +0200 +@@ -93,6 +93,11 @@ enum kex_exchange { + KEX_DH_GEX_SHA256, + KEX_ECDH_SHA2, + KEX_C25519_SHA256, ++#ifdef GSSAPI ++ KEX_GSS_GRP1_SHA1, ++ KEX_GSS_GRP14_SHA1, ++ KEX_GSS_GEX_SHA1, ++#endif + KEX_MAX + }; + +@@ -139,6 +144,12 @@ struct kex { + u_int flags; + int hash_alg; + int ec_nid; ++#ifdef GSSAPI ++ int gss_deleg_creds; ++ int gss_trust_dns; ++ char *gss_host; ++ char *gss_client; ++#endif + char *client_version_string; + char *server_version_string; + int (*verify_host_key)(struct sshkey *, struct ssh *); +@@ -183,6 +194,10 @@ int kexecdh_client(struct ssh *); + int kexecdh_server(struct ssh *); + int kexc25519_client(struct ssh *); + int kexc25519_server(struct ssh *); ++#ifdef GSSAPI ++int kexgss_client(struct ssh *); ++int kexgss_server(struct ssh *); ++#endif + + int kex_dh_hash(const char *, const char *, + const u_char *, size_t, const u_char *, size_t, const u_char *, size_t, +diff -up openssh/Makefile.in.gsskex openssh/Makefile.in +--- openssh/Makefile.in.gsskex 2015-06-24 11:07:36.223389817 +0200 ++++ openssh/Makefile.in 2015-06-24 11:07:36.228389804 +0200 +@@ -90,6 +90,7 @@ LIBSSH_OBJS=${LIBOPENSSH_OBJS} \ + readpass.o rsa.o ttymodes.o xmalloc.o addrmatch.o \ + atomicio.o key.o dispatch.o mac.o uidswap.o uuencode.o misc.o \ + monitor_fdpass.o rijndael.o ssh-dss.o ssh-ecdsa.o ssh-rsa.o dh.o \ ++ kexgssc.o \ + msg.o progressmeter.o dns.o entropy.o gss-genr.o umac.o umac128.o \ + ssh-pkcs11.o smult_curve25519_ref.o \ + poly1305.o chacha.o cipher-chachapoly.o \ +@@ -111,7 +112,7 @@ SSHDOBJS=sshd.o auth-rhosts.o auth-passw + auth-skey.o auth-bsdauth.o auth2-hostbased.o auth2-kbdint.o \ + auth2-none.o auth2-passwd.o auth2-pubkey.o \ + monitor_mm.o monitor.o monitor_wrap.o auth-krb5.o \ +- auth2-gss.o gss-serv.o gss-serv-krb5.o \ ++ auth2-gss.o gss-serv.o gss-serv-krb5.o kexgsss.o \ + loginrec.o auth-pam.o auth-shadow.o auth-sia.o md5crypt.o \ + sftp-server.o sftp-common.o \ + roaming_common.o roaming_serv.o \ +diff -up openssh/monitor.c.gsskex openssh/monitor.c +--- openssh/monitor.c.gsskex 2015-06-24 11:07:36.180389924 +0200 ++++ openssh/monitor.c 2015-06-24 11:07:36.231389797 +0200 @@ -160,6 +160,8 @@ int mm_answer_gss_setup_ctx(int, Buffer int mm_answer_gss_accept_ctx(int, Buffer *); int mm_answer_gss_userok(int, Buffer *); @@ -1762,7 +1713,7 @@ diff -up openssh-6.8p1/monitor.c.gsskex openssh-6.8p1/monitor.c } else { mon_dispatch = mon_dispatch_postauth15; monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1); -@@ -1892,6 +1909,13 @@ monitor_apply_keystate(struct monitor *p +@@ -1896,6 +1913,13 @@ monitor_apply_keystate(struct monitor *p # endif #endif /* WITH_OPENSSL */ kex->kex[KEX_C25519_SHA256] = kexc25519_server; @@ -1776,7 +1727,7 @@ diff -up openssh-6.8p1/monitor.c.gsskex openssh-6.8p1/monitor.c kex->load_host_public_key=&get_hostkey_public_by_type; kex->load_host_private_key=&get_hostkey_private_by_type; kex->host_key_index=&get_hostkey_index; -@@ -1991,6 +2015,9 @@ mm_answer_gss_setup_ctx(int sock, Buffer +@@ -1995,6 +2019,9 @@ mm_answer_gss_setup_ctx(int sock, Buffer OM_uint32 major; u_int len; @@ -1786,7 +1737,7 @@ diff -up openssh-6.8p1/monitor.c.gsskex openssh-6.8p1/monitor.c goid.elements = buffer_get_string(m, &len); goid.length = len; -@@ -2018,6 +2045,9 @@ mm_answer_gss_accept_ctx(int sock, Buffe +@@ -2022,6 +2049,9 @@ mm_answer_gss_accept_ctx(int sock, Buffe OM_uint32 flags = 0; /* GSI needs this */ u_int len; @@ -1796,7 +1747,7 @@ diff -up openssh-6.8p1/monitor.c.gsskex openssh-6.8p1/monitor.c in.value = buffer_get_string(m, &len); in.length = len; major = ssh_gssapi_accept_ctx(gsscontext, &in, &out, &flags); -@@ -2035,6 +2065,7 @@ mm_answer_gss_accept_ctx(int sock, Buffe +@@ -2039,6 +2069,7 @@ mm_answer_gss_accept_ctx(int sock, Buffe monitor_permit(mon_dispatch, MONITOR_REQ_GSSSTEP, 0); monitor_permit(mon_dispatch, MONITOR_REQ_GSSUSEROK, 1); monitor_permit(mon_dispatch, MONITOR_REQ_GSSCHECKMIC, 1); @@ -1804,7 +1755,7 @@ diff -up openssh-6.8p1/monitor.c.gsskex openssh-6.8p1/monitor.c } return (0); } -@@ -2046,6 +2077,9 @@ mm_answer_gss_checkmic(int sock, Buffer +@@ -2050,6 +2081,9 @@ mm_answer_gss_checkmic(int sock, Buffer OM_uint32 ret; u_int len; @@ -1814,7 +1765,7 @@ diff -up openssh-6.8p1/monitor.c.gsskex openssh-6.8p1/monitor.c gssbuf.value = buffer_get_string(m, &len); gssbuf.length = len; mic.value = buffer_get_string(m, &len); -@@ -2072,7 +2106,11 @@ mm_answer_gss_userok(int sock, Buffer *m +@@ -2076,7 +2110,11 @@ mm_answer_gss_userok(int sock, Buffer *m { int authenticated; @@ -1827,7 +1778,7 @@ diff -up openssh-6.8p1/monitor.c.gsskex openssh-6.8p1/monitor.c buffer_clear(m); buffer_put_int(m, authenticated); -@@ -2085,5 +2123,73 @@ mm_answer_gss_userok(int sock, Buffer *m +@@ -2089,5 +2127,73 @@ mm_answer_gss_userok(int sock, Buffer *m /* Monitor loop will terminate if authenticated */ return (authenticated); } @@ -1901,9 +1852,9 @@ diff -up openssh-6.8p1/monitor.c.gsskex openssh-6.8p1/monitor.c + #endif /* GSSAPI */ -diff -up openssh-6.8p1/monitor.h.gsskex openssh-6.8p1/monitor.h ---- openssh-6.8p1/monitor.h.gsskex 2015-03-18 11:24:48.834900865 +0100 -+++ openssh-6.8p1/monitor.h 2015-03-18 11:24:48.878900760 +0100 +diff -up openssh/monitor.h.gsskex openssh/monitor.h +--- openssh/monitor.h.gsskex 2015-06-24 11:07:36.181389921 +0200 ++++ openssh/monitor.h 2015-06-24 11:07:36.231389797 +0200 @@ -60,6 +60,8 @@ enum monitor_reqtype { #ifdef WITH_SELINUX MONITOR_REQ_AUTHROLE = 80, @@ -1913,10 +1864,10 @@ diff -up openssh-6.8p1/monitor.h.gsskex openssh-6.8p1/monitor.h MONITOR_REQ_PAM_START = 100, MONITOR_REQ_PAM_ACCOUNT = 102, MONITOR_ANS_PAM_ACCOUNT = 103, -diff -up openssh-6.8p1/monitor_wrap.c.gsskex openssh-6.8p1/monitor_wrap.c ---- openssh-6.8p1/monitor_wrap.c.gsskex 2015-03-18 11:24:48.834900865 +0100 -+++ openssh-6.8p1/monitor_wrap.c 2015-03-18 11:24:48.878900760 +0100 -@@ -1087,7 +1087,7 @@ mm_ssh_gssapi_checkmic(Gssctxt *ctx, gss +diff -up openssh/monitor_wrap.c.gsskex openssh/monitor_wrap.c +--- openssh/monitor_wrap.c.gsskex 2015-06-24 11:07:36.181389921 +0200 ++++ openssh/monitor_wrap.c 2015-06-24 11:07:36.231389797 +0200 +@@ -1088,7 +1088,7 @@ mm_ssh_gssapi_checkmic(Gssctxt *ctx, gss } int @@ -1925,7 +1876,7 @@ diff -up openssh-6.8p1/monitor_wrap.c.gsskex openssh-6.8p1/monitor_wrap.c { Buffer m; int authenticated = 0; -@@ -1104,5 +1104,50 @@ mm_ssh_gssapi_userok(char *user) +@@ -1105,5 +1105,50 @@ mm_ssh_gssapi_userok(char *user) debug3("%s: user %sauthenticated",__func__, authenticated ? "" : "not "); return (authenticated); } @@ -1976,9 +1927,9 @@ diff -up openssh-6.8p1/monitor_wrap.c.gsskex openssh-6.8p1/monitor_wrap.c + #endif /* GSSAPI */ -diff -up openssh-6.8p1/monitor_wrap.h.gsskex openssh-6.8p1/monitor_wrap.h ---- openssh-6.8p1/monitor_wrap.h.gsskex 2015-03-18 11:24:48.834900865 +0100 -+++ openssh-6.8p1/monitor_wrap.h 2015-03-18 11:24:48.878900760 +0100 +diff -up openssh/monitor_wrap.h.gsskex openssh/monitor_wrap.h +--- openssh/monitor_wrap.h.gsskex 2015-06-24 11:07:36.181389921 +0200 ++++ openssh/monitor_wrap.h 2015-06-24 11:07:36.232389794 +0200 @@ -61,8 +61,10 @@ BIGNUM *mm_auth_rsa_generate_challenge(K OM_uint32 mm_ssh_gssapi_server_ctx(Gssctxt **, gss_OID); OM_uint32 mm_ssh_gssapi_accept_ctx(Gssctxt *, @@ -1991,9 +1942,9 @@ diff -up openssh-6.8p1/monitor_wrap.h.gsskex openssh-6.8p1/monitor_wrap.h #endif #ifdef USE_PAM -diff -up openssh-6.8p1/readconf.c.gsskex openssh-6.8p1/readconf.c ---- openssh-6.8p1/readconf.c.gsskex 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/readconf.c 2015-03-18 11:24:48.879900758 +0100 +diff -up openssh/readconf.c.gsskex openssh/readconf.c +--- openssh/readconf.c.gsskex 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/readconf.c 2015-06-24 11:07:36.232389794 +0200 @@ -147,6 +147,8 @@ typedef enum { oClearAllForwardings, oNoHostAuthenticationForLocalhost, oEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout, @@ -2082,9 +2033,9 @@ diff -up openssh-6.8p1/readconf.c.gsskex openssh-6.8p1/readconf.c if (options->password_authentication == -1) options->password_authentication = 1; if (options->kbd_interactive_authentication == -1) -diff -up openssh-6.8p1/readconf.h.gsskex openssh-6.8p1/readconf.h ---- openssh-6.8p1/readconf.h.gsskex 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/readconf.h 2015-03-18 11:24:48.879900758 +0100 +diff -up openssh/readconf.h.gsskex openssh/readconf.h +--- openssh/readconf.h.gsskex 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/readconf.h 2015-06-24 11:07:36.232389794 +0200 @@ -45,7 +45,12 @@ typedef struct { int challenge_response_authentication; /* Try S/Key or TIS, authentication. */ @@ -2098,9 +2049,9 @@ diff -up openssh-6.8p1/readconf.h.gsskex openssh-6.8p1/readconf.h int password_authentication; /* Try password * authentication. */ int kbd_interactive_authentication; /* Try keyboard-interactive auth. */ -diff -up openssh-6.8p1/regress/cert-hostkey.sh.gsskex openssh-6.8p1/regress/cert-hostkey.sh ---- openssh-6.8p1/regress/cert-hostkey.sh.gsskex 2015-03-18 11:24:48.879900758 +0100 -+++ openssh-6.8p1/regress/cert-hostkey.sh 2015-03-18 12:15:49.556546478 +0100 +diff -up openssh/regress/cert-hostkey.sh.gsskex openssh/regress/cert-hostkey.sh +--- openssh/regress/cert-hostkey.sh.gsskex 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/regress/cert-hostkey.sh 2015-06-24 11:07:36.232389794 +0200 @@ -25,7 +25,7 @@ touch $OBJ/host_revoked_plain touch $OBJ/host_revoked_cert cp $OBJ/host_ca_key.pub $OBJ/host_revoked_ca @@ -2110,9 +2061,9 @@ diff -up openssh-6.8p1/regress/cert-hostkey.sh.gsskex openssh-6.8p1/regress/cert type_has_legacy() { case $1 in -diff -up openssh-6.8p1/regress/cert-userkey.sh.gsskex openssh-6.8p1/regress/cert-userkey.sh ---- openssh-6.8p1/regress/cert-userkey.sh.gsskex 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/regress/cert-userkey.sh 2015-03-18 11:24:48.879900758 +0100 +diff -up openssh/regress/cert-userkey.sh.gsskex openssh/regress/cert-userkey.sh +--- openssh/regress/cert-userkey.sh.gsskex 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/regress/cert-userkey.sh 2015-06-24 11:07:36.232389794 +0200 @@ -6,7 +6,7 @@ tid="certified user keys" rm -f $OBJ/authorized_keys_$USER $OBJ/user_ca_key* $OBJ/cert_user_key* cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak @@ -2122,9 +2073,9 @@ diff -up openssh-6.8p1/regress/cert-userkey.sh.gsskex openssh-6.8p1/regress/cert type_has_legacy() { case $1 in -diff -up openssh-6.8p1/regress/kextype.sh.gsskex openssh-6.8p1/regress/kextype.sh ---- openssh-6.8p1/regress/kextype.sh.gsskex 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/regress/kextype.sh 2015-03-18 11:24:48.879900758 +0100 +diff -up openssh/regress/kextype.sh.gsskex openssh/regress/kextype.sh +--- openssh/regress/kextype.sh.gsskex 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/regress/kextype.sh 2015-06-24 11:07:36.233389792 +0200 @@ -14,6 +14,9 @@ echo "KexAlgorithms=$KEXOPT" >> $OBJ/ssh tries="1 2 3 4" @@ -2135,9 +2086,9 @@ diff -up openssh-6.8p1/regress/kextype.sh.gsskex openssh-6.8p1/regress/kextype.s verbose "kex $k" for i in $tries; do ${SSH} -F $OBJ/ssh_proxy -o KexAlgorithms=$k x true -diff -up openssh-6.8p1/regress/rekey.sh.gsskex openssh-6.8p1/regress/rekey.sh ---- openssh-6.8p1/regress/rekey.sh.gsskex 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/regress/rekey.sh 2015-03-18 11:24:48.879900758 +0100 +diff -up openssh/regress/rekey.sh.gsskex openssh/regress/rekey.sh +--- openssh/regress/rekey.sh.gsskex 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/regress/rekey.sh 2015-06-24 11:07:36.233389792 +0200 @@ -38,6 +38,9 @@ increase_datafile_size 300 opts="" @@ -2158,21 +2109,21 @@ diff -up openssh-6.8p1/regress/rekey.sh.gsskex openssh-6.8p1/regress/rekey.sh verbose "client rekey $c $kex" ssh_data_rekeying "KexAlgorithms=$kex" -oRekeyLimit=256k -oCiphers=$c done -diff -up openssh-6.8p1/servconf.c.gsskex openssh-6.8p1/servconf.c ---- openssh-6.8p1/servconf.c.gsskex 2015-03-18 11:24:48.866900788 +0100 -+++ openssh-6.8p1/servconf.c 2015-03-18 12:14:37.967721387 +0100 -@@ -114,7 +114,10 @@ initialize_server_options(ServerOptions +diff -up openssh/servconf.c.gsskex openssh/servconf.c +--- openssh/servconf.c.gsskex 2015-06-24 11:07:36.214389839 +0200 ++++ openssh/servconf.c 2015-06-24 11:20:08.026487223 +0200 +@@ -115,8 +115,10 @@ initialize_server_options(ServerOptions options->kerberos_ticket_cleanup = -1; options->kerberos_get_afs_token = -1; options->gss_authentication=-1; + options->gss_keyex = -1; options->gss_cleanup_creds = -1; -+ options->gss_strict_acceptor = -1; + options->gss_strict_acceptor = -1; + options->gss_store_rekey = -1; options->password_authentication = -1; options->kbd_interactive_authentication = -1; options->challenge_response_authentication = -1; -@@ -270,8 +273,14 @@ fill_default_server_options(ServerOption +@@ -276,10 +278,14 @@ fill_default_server_options(ServerOption options->kerberos_get_afs_token = 0; if (options->gss_authentication == -1) options->gss_authentication = 0; @@ -2180,36 +2131,32 @@ diff -up openssh-6.8p1/servconf.c.gsskex openssh-6.8p1/servconf.c + options->gss_keyex = 0; if (options->gss_cleanup_creds == -1) options->gss_cleanup_creds = 1; -+ if (options->gss_strict_acceptor == -1) -+ options->gss_strict_acceptor = 1; + if (options->gss_strict_acceptor == -1) + options->gss_strict_acceptor = 0; + if (options->gss_store_rekey == -1) + options->gss_store_rekey = 0; if (options->password_authentication == -1) options->password_authentication = 1; if (options->kbd_interactive_authentication == -1) -@@ -394,7 +403,8 @@ typedef enum { - sBanner, sShowPatchLevel, sUseDNS, sHostbasedAuthentication, +@@ -404,7 +410,7 @@ typedef enum { sHostbasedUsesNameFromPacketOnly, sHostbasedAcceptedKeyTypes, sClientAliveInterval, sClientAliveCountMax, sAuthorizedKeysFile, -- sGssAuthentication, sGssCleanupCreds, sAcceptEnv, sPermitTunnel, -+ sGssAuthentication, sGssCleanupCreds, sGssStrictAcceptor, + sGssAuthentication, sGssCleanupCreds, sGssStrictAcceptor, +- sAcceptEnv, sPermitTunnel, + sGssKeyEx, sGssStoreRekey, sAcceptEnv, sPermitTunnel, sMatch, sPermitOpen, sForceCommand, sChrootDirectory, sUsePrivilegeSeparation, sAllowAgentForwarding, sHostCertificate, -@@ -465,10 +475,20 @@ static struct { - #ifdef GSSAPI +@@ -477,11 +483,17 @@ static struct { { "gssapiauthentication", sGssAuthentication, SSHCFG_ALL }, { "gssapicleanupcredentials", sGssCleanupCreds, SSHCFG_GLOBAL }, -+ { "gssapicleanupcreds", sGssCleanupCreds, SSHCFG_GLOBAL }, -+ { "gssapistrictacceptorcheck", sGssStrictAcceptor, SSHCFG_GLOBAL }, + { "gssapistrictacceptorcheck", sGssStrictAcceptor, SSHCFG_GLOBAL }, + { "gssapikeyexchange", sGssKeyEx, SSHCFG_GLOBAL }, + { "gssapistorecredentialsonrekey", sGssStoreRekey, SSHCFG_GLOBAL }, #else { "gssapiauthentication", sUnsupported, SSHCFG_ALL }, { "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL }, -+ { "gssapicleanupcreds", sUnsupported, SSHCFG_GLOBAL }, -+ { "gssapistrictacceptorcheck", sUnsupported, SSHCFG_GLOBAL }, + { "gssapistrictacceptorcheck", sUnsupported, SSHCFG_GLOBAL }, + { "gssapikeyexchange", sUnsupported, SSHCFG_GLOBAL }, + { "gssapistorecredentialsonrekey", sUnsupported, SSHCFG_GLOBAL }, #endif @@ -2218,7 +2165,7 @@ diff -up openssh-6.8p1/servconf.c.gsskex openssh-6.8p1/servconf.c { "passwordauthentication", sPasswordAuthentication, SSHCFG_ALL }, { "kbdinteractiveauthentication", sKbdInteractiveAuthentication, SSHCFG_ALL }, { "challengeresponseauthentication", sChallengeResponseAuthentication, SSHCFG_GLOBAL }, -@@ -1170,10 +1190,22 @@ process_server_config_line(ServerOptions +@@ -1218,6 +1230,10 @@ process_server_config_line(ServerOptions intptr = &options->gss_authentication; goto parse_flag; @@ -2229,11 +2176,10 @@ diff -up openssh-6.8p1/servconf.c.gsskex openssh-6.8p1/servconf.c case sGssCleanupCreds: intptr = &options->gss_cleanup_creds; goto parse_flag; +@@ -1226,6 +1242,10 @@ process_server_config_line(ServerOptions + intptr = &options->gss_strict_acceptor; + goto parse_flag; -+ case sGssStrictAcceptor: -+ intptr = &options->gss_strict_acceptor; -+ goto parse_flag; -+ + case sGssStoreRekey: + intptr = &options->gss_store_rekey; + goto parse_flag; @@ -2241,7 +2187,7 @@ diff -up openssh-6.8p1/servconf.c.gsskex openssh-6.8p1/servconf.c case sPasswordAuthentication: intptr = &options->password_authentication; goto parse_flag; -@@ -2134,6 +2166,9 @@ dump_config(ServerOptions *o) +@@ -2238,6 +2258,9 @@ dump_config(ServerOptions *o) #ifdef GSSAPI dump_cfg_fmtint(sGssAuthentication, o->gss_authentication); dump_cfg_fmtint(sGssCleanupCreds, o->gss_cleanup_creds); @@ -2251,138 +2197,24 @@ diff -up openssh-6.8p1/servconf.c.gsskex openssh-6.8p1/servconf.c #endif dump_cfg_fmtint(sPasswordAuthentication, o->password_authentication); dump_cfg_fmtint(sKbdInteractiveAuthentication, -diff -up openssh-6.8p1/servconf.h.gsskex openssh-6.8p1/servconf.h ---- openssh-6.8p1/servconf.h.gsskex 2015-03-18 11:24:48.866900788 +0100 -+++ openssh-6.8p1/servconf.h 2015-03-18 11:24:48.880900755 +0100 -@@ -115,7 +115,10 @@ typedef struct { +diff -up openssh/servconf.h.gsskex openssh/servconf.h +--- openssh/servconf.h.gsskex 2015-06-24 11:07:36.233389792 +0200 ++++ openssh/servconf.h 2015-06-24 11:21:20.888302354 +0200 +@@ -117,8 +117,10 @@ typedef struct { int kerberos_get_afs_token; /* If true, try to get AFS token if * authenticated with Kerberos. */ int gss_authentication; /* If true, permit GSSAPI authentication */ + int gss_keyex; /* If true, permit GSSAPI key exchange */ int gss_cleanup_creds; /* If true, destroy cred cache on logout */ -+ int gss_strict_acceptor; /* If true, restrict the GSSAPI acceptor name */ + int gss_strict_acceptor; /* If true, restrict the GSSAPI acceptor name */ + int gss_store_rekey; int password_authentication; /* If true, permit password * authentication. */ int kbd_interactive_authentication; /* If true, permit */ -diff -up openssh-6.8p1/ssh-gss.h.gsskex openssh-6.8p1/ssh-gss.h ---- openssh-6.8p1/ssh-gss.h.gsskex 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/ssh-gss.h 2015-03-18 11:24:48.880900755 +0100 -@@ -1,6 +1,6 @@ - /* $OpenBSD: ssh-gss.h,v 1.11 2014/02/26 20:28:44 djm Exp $ */ - /* -- * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. -+ * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions -@@ -61,10 +61,22 @@ - - #define SSH_GSS_OIDTYPE 0x06 - -+#define SSH2_MSG_KEXGSS_INIT 30 -+#define SSH2_MSG_KEXGSS_CONTINUE 31 -+#define SSH2_MSG_KEXGSS_COMPLETE 32 -+#define SSH2_MSG_KEXGSS_HOSTKEY 33 -+#define SSH2_MSG_KEXGSS_ERROR 34 -+#define SSH2_MSG_KEXGSS_GROUPREQ 40 -+#define SSH2_MSG_KEXGSS_GROUP 41 -+#define KEX_GSS_GRP1_SHA1_ID "gss-group1-sha1-" -+#define KEX_GSS_GRP14_SHA1_ID "gss-group14-sha1-" -+#define KEX_GSS_GEX_SHA1_ID "gss-gex-sha1-" -+ - typedef struct { - char *filename; - char *envvar; - char *envval; -+ struct passwd *owner; - void *data; - } ssh_gssapi_ccache; - -@@ -72,8 +84,11 @@ typedef struct { - gss_buffer_desc displayname; - gss_buffer_desc exportedname; - gss_cred_id_t creds; -+ gss_name_t name; - struct ssh_gssapi_mech_struct *mech; - ssh_gssapi_ccache store; -+ int used; -+ int updated; - } ssh_gssapi_client; - - typedef struct ssh_gssapi_mech_struct { -@@ -84,6 +99,7 @@ typedef struct ssh_gssapi_mech_struct { - int (*userok) (ssh_gssapi_client *, char *); - int (*localname) (ssh_gssapi_client *, char **); - void (*storecreds) (ssh_gssapi_client *); -+ int (*updatecreds) (ssh_gssapi_ccache *, ssh_gssapi_client *); - } ssh_gssapi_mech; - - typedef struct { -@@ -94,10 +110,11 @@ typedef struct { - gss_OID oid; /* client */ - gss_cred_id_t creds; /* server */ - gss_name_t client; /* server */ -- gss_cred_id_t client_creds; /* server */ -+ gss_cred_id_t client_creds; /* both */ - } Gssctxt; - - extern ssh_gssapi_mech *supported_mechs[]; -+extern Gssctxt *gss_kex_context; - - int ssh_gssapi_check_oid(Gssctxt *, void *, size_t); - void ssh_gssapi_set_oid_data(Gssctxt *, void *, size_t); -@@ -119,16 +136,32 @@ void ssh_gssapi_build_ctx(Gssctxt **); - void ssh_gssapi_delete_ctx(Gssctxt **); - OM_uint32 ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t); - void ssh_gssapi_buildmic(Buffer *, const char *, const char *, const char *); --int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *); -+int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *, const char *); -+OM_uint32 ssh_gssapi_client_identity(Gssctxt *, const char *); -+int ssh_gssapi_credentials_updated(Gssctxt *); - - /* In the server */ -+typedef int ssh_gssapi_check_fn(Gssctxt **, gss_OID, const char *, -+ const char *); -+char *ssh_gssapi_client_mechanisms(const char *, const char *); -+char *ssh_gssapi_kex_mechs(gss_OID_set, ssh_gssapi_check_fn *, const char *, -+ const char *); -+gss_OID ssh_gssapi_id_kex(Gssctxt *, char *, int); -+int ssh_gssapi_server_check_mech(Gssctxt **,gss_OID, const char *, -+ const char *); - OM_uint32 ssh_gssapi_server_ctx(Gssctxt **, gss_OID); --int ssh_gssapi_userok(char *name); -+int ssh_gssapi_userok(char *name, struct passwd *); - OM_uint32 ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t); - void ssh_gssapi_do_child(char ***, u_int *); - void ssh_gssapi_cleanup_creds(void); - void ssh_gssapi_storecreds(void); - -+char *ssh_gssapi_server_mechanisms(void); -+int ssh_gssapi_oid_table_ok(); -+ -+int ssh_gssapi_update_creds(ssh_gssapi_ccache *store); -+ -+void ssh_gssapi_rekey_creds(void); - #endif /* GSSAPI */ - - #endif /* _SSH_GSS_H */ -diff -up openssh-6.8p1/ssh_config.gsskex openssh-6.8p1/ssh_config ---- openssh-6.8p1/ssh_config.gsskex 2015-03-18 11:24:48.861900800 +0100 -+++ openssh-6.8p1/ssh_config 2015-03-18 11:24:48.880900755 +0100 -@@ -26,6 +26,8 @@ - # HostbasedAuthentication no - # GSSAPIAuthentication no - # GSSAPIDelegateCredentials no -+# GSSAPIKeyExchange no -+# GSSAPITrustDNS no - # BatchMode no - # CheckHostIP yes - # AddressFamily any -diff -up openssh-6.8p1/ssh_config.5.gsskex openssh-6.8p1/ssh_config.5 ---- openssh-6.8p1/ssh_config.5.gsskex 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/ssh_config.5 2015-03-18 11:24:48.881900753 +0100 -@@ -743,11 +743,43 @@ Specifies whether user authentication ba +diff -up openssh/ssh_config.5.gsskex openssh/ssh_config.5 +--- openssh/ssh_config.5.gsskex 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/ssh_config.5 2015-06-24 11:07:36.234389789 +0200 +@@ -744,11 +744,43 @@ Specifies whether user authentication ba The default is .Dq no . Note that this option applies to protocol version 2 only. @@ -2427,9 +2259,21 @@ diff -up openssh-6.8p1/ssh_config.5.gsskex openssh-6.8p1/ssh_config.5 .It Cm HashKnownHosts Indicates that .Xr ssh 1 -diff -up openssh-6.8p1/sshconnect2.c.gsskex openssh-6.8p1/sshconnect2.c ---- openssh-6.8p1/sshconnect2.c.gsskex 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/sshconnect2.c 2015-03-18 11:32:36.879784546 +0100 +diff -up openssh/ssh_config.gsskex openssh/ssh_config +--- openssh/ssh_config.gsskex 2015-06-24 11:07:36.209389852 +0200 ++++ openssh/ssh_config 2015-06-24 11:07:36.234389789 +0200 +@@ -26,6 +26,8 @@ + # HostbasedAuthentication no + # GSSAPIAuthentication no + # GSSAPIDelegateCredentials no ++# GSSAPIKeyExchange no ++# GSSAPITrustDNS no + # BatchMode no + # CheckHostIP yes + # AddressFamily any +diff -up openssh/sshconnect2.c.gsskex openssh/sshconnect2.c +--- openssh/sshconnect2.c.gsskex 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/sshconnect2.c 2015-06-24 11:07:36.234389789 +0200 @@ -160,9 +160,34 @@ ssh_kex2(char *host, struct sockaddr *ho struct kex *kex; int r; @@ -2629,10 +2473,10 @@ diff -up openssh-6.8p1/sshconnect2.c.gsskex openssh-6.8p1/sshconnect2.c #endif /* GSSAPI */ int -diff -up openssh-6.8p1/sshd.c.gsskex openssh-6.8p1/sshd.c ---- openssh-6.8p1/sshd.c.gsskex 2015-03-18 11:24:48.869900781 +0100 -+++ openssh-6.8p1/sshd.c 2015-03-18 11:35:53.260315986 +0100 -@@ -1831,10 +1831,13 @@ main(int ac, char **av) +diff -up openssh/sshd.c.gsskex openssh/sshd.c +--- openssh/sshd.c.gsskex 2015-06-24 11:07:36.217389832 +0200 ++++ openssh/sshd.c 2015-06-24 11:07:36.235389787 +0200 +@@ -1839,10 +1839,13 @@ main(int ac, char **av) logit("Disabling protocol version 1. Could not load host key"); options.protocol &= ~SSH_PROTO_1; } @@ -2646,7 +2490,7 @@ diff -up openssh-6.8p1/sshd.c.gsskex openssh-6.8p1/sshd.c if (!(options.protocol & (SSH_PROTO_1|SSH_PROTO_2))) { logit("sshd: no hostkeys available -- exiting."); exit(1); -@@ -2580,6 +2583,48 @@ do_ssh2_kex(void) +@@ -2589,6 +2592,48 @@ do_ssh2_kex(void) myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = compat_pkalg_proposal( list_hostkey_types()); @@ -2695,7 +2539,7 @@ diff -up openssh-6.8p1/sshd.c.gsskex openssh-6.8p1/sshd.c /* start key exchange */ if ((r = kex_setup(active_state, myproposal)) != 0) fatal("kex_setup: %s", ssh_err(r)); -@@ -2594,6 +2639,13 @@ do_ssh2_kex(void) +@@ -2603,6 +2648,13 @@ do_ssh2_kex(void) # endif #endif kex->kex[KEX_C25519_SHA256] = kexc25519_server; @@ -2709,22 +2553,10 @@ diff -up openssh-6.8p1/sshd.c.gsskex openssh-6.8p1/sshd.c kex->server = 1; kex->client_version_string=client_version_string; kex->server_version_string=server_version_string; -diff -up openssh-6.8p1/sshd_config.gsskex openssh-6.8p1/sshd_config ---- openssh-6.8p1/sshd_config.gsskex 2015-03-18 11:24:48.869900781 +0100 -+++ openssh-6.8p1/sshd_config 2015-03-18 11:24:48.882900750 +0100 -@@ -91,6 +91,8 @@ ChallengeResponseAuthentication no - # GSSAPI options - GSSAPIAuthentication yes - GSSAPICleanupCredentials no -+#GSSAPIStrictAcceptorCheck yes -+#GSSAPIKeyExchange no - - # Set this to 'yes' to enable PAM authentication, account processing, - # and session processing. If this is enabled, PAM authentication will -diff -up openssh-6.8p1/sshd_config.5.gsskex openssh-6.8p1/sshd_config.5 ---- openssh-6.8p1/sshd_config.5.gsskex 2015-03-18 11:24:48.882900750 +0100 -+++ openssh-6.8p1/sshd_config.5 2015-03-18 12:12:57.914965842 +0100 -@@ -564,12 +564,40 @@ Specifies whether user authentication ba +diff -up openssh/sshd_config.5.gsskex openssh/sshd_config.5 +--- openssh/sshd_config.5.gsskex 2015-06-24 11:07:36.235389787 +0200 ++++ openssh/sshd_config.5 2015-06-24 11:23:13.490016656 +0200 +@@ -616,6 +616,12 @@ Specifies whether user authentication ba The default is .Dq no . Note that this option applies to protocol version 2 only. @@ -2737,26 +2569,10 @@ diff -up openssh-6.8p1/sshd_config.5.gsskex openssh-6.8p1/sshd_config.5 .It Cm GSSAPICleanupCredentials Specifies whether to automatically destroy the user's credentials cache on logout. +@@ -637,6 +643,11 @@ machine's default store. + This facility is provided to assist with operation on multi homed machines. The default is .Dq yes . - Note that this option applies to protocol version 2 only. -+.It Cm GSSAPIStrictAcceptorCheck -+Determines whether to be strict about the identity of the GSSAPI acceptor -+a client authenticates against. If -+.Dq yes -+then the client must authenticate against the -+.Pa host -+service on the current hostname. If -+.Dq no -+then the client may authenticate against any service key stored in the -+machine's default store. This facility is provided to assist with operation -+on multi homed machines. -+The default is -+.Dq yes . -+Note that this option applies only to protocol version 2 GSSAPI connections, -+and setting it to -+.Dq no -+may only work with recent Kerberos GSSAPI libraries. +.It Cm GSSAPIStoreCredentialsOnRekey +Controls whether the user's GSSAPI credentials should be updated following a +successful connection rekeying. This option can be used to accepted renewed @@ -2765,3 +2581,117 @@ diff -up openssh-6.8p1/sshd_config.5.gsskex openssh-6.8p1/sshd_config.5 .It Cm HostbasedAcceptedKeyTypes Specifies the key types that will be accepted for hostbased authentication as a comma-separated pattern list. +diff -up openssh/sshd_config.gsskex openssh/sshd_config +--- openssh/sshd_config.gsskex 2015-06-24 11:07:36.217389832 +0200 ++++ openssh/sshd_config 2015-06-24 11:07:36.235389787 +0200 +@@ -91,6 +91,8 @@ ChallengeResponseAuthentication no + # GSSAPI options + GSSAPIAuthentication yes + GSSAPICleanupCredentials no ++#GSSAPIStrictAcceptorCheck yes ++#GSSAPIKeyExchange no + + # Set this to 'yes' to enable PAM authentication, account processing, + # and session processing. If this is enabled, PAM authentication will +diff -up openssh/ssh-gss.h.gsskex openssh/ssh-gss.h +--- openssh/ssh-gss.h.gsskex 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/ssh-gss.h 2015-06-24 11:07:36.234389789 +0200 +@@ -1,6 +1,6 @@ + /* $OpenBSD: ssh-gss.h,v 1.11 2014/02/26 20:28:44 djm Exp $ */ + /* +- * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. ++ * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions +@@ -61,10 +61,22 @@ + + #define SSH_GSS_OIDTYPE 0x06 + ++#define SSH2_MSG_KEXGSS_INIT 30 ++#define SSH2_MSG_KEXGSS_CONTINUE 31 ++#define SSH2_MSG_KEXGSS_COMPLETE 32 ++#define SSH2_MSG_KEXGSS_HOSTKEY 33 ++#define SSH2_MSG_KEXGSS_ERROR 34 ++#define SSH2_MSG_KEXGSS_GROUPREQ 40 ++#define SSH2_MSG_KEXGSS_GROUP 41 ++#define KEX_GSS_GRP1_SHA1_ID "gss-group1-sha1-" ++#define KEX_GSS_GRP14_SHA1_ID "gss-group14-sha1-" ++#define KEX_GSS_GEX_SHA1_ID "gss-gex-sha1-" ++ + typedef struct { + char *filename; + char *envvar; + char *envval; ++ struct passwd *owner; + void *data; + } ssh_gssapi_ccache; + +@@ -72,8 +84,11 @@ typedef struct { + gss_buffer_desc displayname; + gss_buffer_desc exportedname; + gss_cred_id_t creds; ++ gss_name_t name; + struct ssh_gssapi_mech_struct *mech; + ssh_gssapi_ccache store; ++ int used; ++ int updated; + } ssh_gssapi_client; + + typedef struct ssh_gssapi_mech_struct { +@@ -84,6 +99,7 @@ typedef struct ssh_gssapi_mech_struct { + int (*userok) (ssh_gssapi_client *, char *); + int (*localname) (ssh_gssapi_client *, char **); + void (*storecreds) (ssh_gssapi_client *); ++ int (*updatecreds) (ssh_gssapi_ccache *, ssh_gssapi_client *); + } ssh_gssapi_mech; + + typedef struct { +@@ -94,10 +110,11 @@ typedef struct { + gss_OID oid; /* client */ + gss_cred_id_t creds; /* server */ + gss_name_t client; /* server */ +- gss_cred_id_t client_creds; /* server */ ++ gss_cred_id_t client_creds; /* both */ + } Gssctxt; + + extern ssh_gssapi_mech *supported_mechs[]; ++extern Gssctxt *gss_kex_context; + + int ssh_gssapi_check_oid(Gssctxt *, void *, size_t); + void ssh_gssapi_set_oid_data(Gssctxt *, void *, size_t); +@@ -119,16 +136,32 @@ void ssh_gssapi_build_ctx(Gssctxt **); + void ssh_gssapi_delete_ctx(Gssctxt **); + OM_uint32 ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t); + void ssh_gssapi_buildmic(Buffer *, const char *, const char *, const char *); +-int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *); ++int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *, const char *); ++OM_uint32 ssh_gssapi_client_identity(Gssctxt *, const char *); ++int ssh_gssapi_credentials_updated(Gssctxt *); + + /* In the server */ ++typedef int ssh_gssapi_check_fn(Gssctxt **, gss_OID, const char *, ++ const char *); ++char *ssh_gssapi_client_mechanisms(const char *, const char *); ++char *ssh_gssapi_kex_mechs(gss_OID_set, ssh_gssapi_check_fn *, const char *, ++ const char *); ++gss_OID ssh_gssapi_id_kex(Gssctxt *, char *, int); ++int ssh_gssapi_server_check_mech(Gssctxt **,gss_OID, const char *, ++ const char *); + OM_uint32 ssh_gssapi_server_ctx(Gssctxt **, gss_OID); +-int ssh_gssapi_userok(char *name); ++int ssh_gssapi_userok(char *name, struct passwd *); + OM_uint32 ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t); + void ssh_gssapi_do_child(char ***, u_int *); + void ssh_gssapi_cleanup_creds(void); + void ssh_gssapi_storecreds(void); + ++char *ssh_gssapi_server_mechanisms(void); ++int ssh_gssapi_oid_table_ok(); ++ ++int ssh_gssapi_update_creds(ssh_gssapi_ccache *store); ++ ++void ssh_gssapi_rekey_creds(void); + #endif /* GSSAPI */ + + #endif /* _SSH_GSS_H */ diff --git a/openssh-6.6p1-keycat.patch b/openssh-6.6p1-keycat.patch index be79371..6018554 100644 --- a/openssh-6.6p1-keycat.patch +++ b/openssh-6.6p1-keycat.patch @@ -1,6 +1,24 @@ -diff -up openssh-6.8p1/HOWTO.ssh-keycat.keycat openssh-6.8p1/HOWTO.ssh-keycat ---- openssh-6.8p1/HOWTO.ssh-keycat.keycat 2015-03-18 11:13:43.063482958 +0100 -+++ openssh-6.8p1/HOWTO.ssh-keycat 2015-03-18 11:13:43.063482958 +0100 +diff -up openssh/auth2-pubkey.c.keycat openssh/auth2-pubkey.c +--- openssh/auth2-pubkey.c.keycat 2015-06-24 10:57:50.158849606 +0200 ++++ openssh/auth2-pubkey.c 2015-06-24 11:04:23.989868638 +0200 +@@ -490,6 +490,14 @@ subprocess(const char *tag, struct passw + _exit(1); + } + ++#ifdef WITH_SELINUX ++ if (sshd_selinux_setup_env_variables() < 0) { ++ error ("failed to copy environment: %s", ++ strerror(errno)); ++ _exit(127); ++ } ++#endif ++ + execve(av[0], av, child_env); + error("%s exec \"%s\": %s", tag, command, strerror(errno)); + _exit(127); +diff -up openssh/HOWTO.ssh-keycat.keycat openssh/HOWTO.ssh-keycat +--- openssh/HOWTO.ssh-keycat.keycat 2015-06-24 10:57:50.157849608 +0200 ++++ openssh/HOWTO.ssh-keycat 2015-06-24 10:57:50.157849608 +0200 @@ -0,0 +1,12 @@ +The ssh-keycat retrieves the content of the ~/.ssh/authorized_keys +of an user in any environment. This includes environments with @@ -14,9 +32,9 @@ diff -up openssh-6.8p1/HOWTO.ssh-keycat.keycat openssh-6.8p1/HOWTO.ssh-keycat + PubkeyAuthentication yes + + -diff -up openssh-6.8p1/Makefile.in.keycat openssh-6.8p1/Makefile.in ---- openssh-6.8p1/Makefile.in.keycat 2015-03-18 11:13:43.061482963 +0100 -+++ openssh-6.8p1/Makefile.in 2015-03-18 11:14:22.480389291 +0100 +diff -up openssh/Makefile.in.keycat openssh/Makefile.in +--- openssh/Makefile.in.keycat 2015-06-24 10:57:50.152849621 +0200 ++++ openssh/Makefile.in 2015-06-24 10:57:50.157849608 +0200 @@ -27,6 +27,7 @@ SFTP_SERVER=$(libexecdir)/sftp-server SSH_KEYSIGN=$(libexecdir)/ssh-keysign SSH_LDAP_HELPER=$(libexecdir)/ssh-ldap-helper @@ -52,27 +70,23 @@ diff -up openssh-6.8p1/Makefile.in.keycat openssh-6.8p1/Makefile.in $(INSTALL) -m 0755 $(STRIP_OPT) sftp$(EXEEXT) $(DESTDIR)$(bindir)/sftp$(EXEEXT) $(INSTALL) -m 0755 $(STRIP_OPT) sftp-server$(EXEEXT) $(DESTDIR)$(SFTP_SERVER)$(EXEEXT) $(INSTALL) -m 644 ssh.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh.1 -diff -up openssh-6.8p1/auth2-pubkey.c.keycat openssh-6.8p1/auth2-pubkey.c ---- openssh-6.8p1/auth2-pubkey.c.keycat 2015-03-18 11:13:43.053482982 +0100 -+++ openssh-6.8p1/auth2-pubkey.c 2015-03-18 11:13:43.063482958 +0100 -@@ -623,6 +623,14 @@ user_key_command_allowed2(struct passwd - _exit(1); - } +diff -up openssh/openbsd-compat/port-linux.h.keycat openssh/openbsd-compat/port-linux.h +--- openssh/openbsd-compat/port-linux.h.keycat 2015-06-24 10:57:50.150849626 +0200 ++++ openssh/openbsd-compat/port-linux.h 2015-06-24 10:57:50.160849601 +0200 +@@ -25,8 +25,10 @@ void ssh_selinux_setup_pty(char *, const + void ssh_selinux_change_context(const char *); + void ssh_selinux_setfscreatecon(const char *); -+#ifdef WITH_SELINUX -+ if (sshd_selinux_setup_env_variables() < 0) { -+ error ("failed to copy environment: %s", -+ strerror(errno)); -+ _exit(127); -+ } -+#endif -+ - execl(options.authorized_keys_command, - options.authorized_keys_command, user_pw->pw_name, NULL); ++int sshd_selinux_enabled(void); + void sshd_selinux_copy_context(void); + void sshd_selinux_setup_exec_context(char *); ++int sshd_selinux_setup_env_variables(void); + #endif -diff -up openssh-6.8p1/openbsd-compat/port-linux-sshd.c.keycat openssh-6.8p1/openbsd-compat/port-linux-sshd.c ---- openssh-6.8p1/openbsd-compat/port-linux-sshd.c.keycat 2015-03-18 11:13:43.057482972 +0100 -+++ openssh-6.8p1/openbsd-compat/port-linux-sshd.c 2015-03-18 11:13:43.063482958 +0100 + #ifdef LINUX_OOM_ADJUST +diff -up openssh/openbsd-compat/port-linux-sshd.c.keycat openssh/openbsd-compat/port-linux-sshd.c +--- openssh/openbsd-compat/port-linux-sshd.c.keycat 2015-06-24 10:57:50.150849626 +0200 ++++ openssh/openbsd-compat/port-linux-sshd.c 2015-06-24 10:57:50.159849603 +0200 @@ -54,6 +54,20 @@ extern Authctxt *the_authctxt; extern int inetd_flag; extern int rexeced_flag; @@ -166,23 +180,9 @@ diff -up openssh-6.8p1/openbsd-compat/port-linux-sshd.c.keycat openssh-6.8p1/ope return; if (getexeccon((security_context_t *)&ctx) != 0) { -diff -up openssh-6.8p1/openbsd-compat/port-linux.h.keycat openssh-6.8p1/openbsd-compat/port-linux.h ---- openssh-6.8p1/openbsd-compat/port-linux.h.keycat 2015-03-18 11:13:43.057482972 +0100 -+++ openssh-6.8p1/openbsd-compat/port-linux.h 2015-03-18 11:13:43.063482958 +0100 -@@ -25,8 +25,10 @@ void ssh_selinux_setup_pty(char *, const - void ssh_selinux_change_context(const char *); - void ssh_selinux_setfscreatecon(const char *); - -+int sshd_selinux_enabled(void); - void sshd_selinux_copy_context(void); - void sshd_selinux_setup_exec_context(char *); -+int sshd_selinux_setup_env_variables(void); - #endif - - #ifdef LINUX_OOM_ADJUST -diff -up openssh-6.8p1/platform.c.keycat openssh-6.8p1/platform.c ---- openssh-6.8p1/platform.c.keycat 2015-03-18 11:13:43.055482977 +0100 -+++ openssh-6.8p1/platform.c 2015-03-18 11:13:43.063482958 +0100 +diff -up openssh/platform.c.keycat openssh/platform.c +--- openssh/platform.c.keycat 2015-06-24 10:57:50.147849633 +0200 ++++ openssh/platform.c 2015-06-24 10:57:50.160849601 +0200 @@ -103,7 +103,7 @@ platform_setusercontext(struct passwd *p { #ifdef WITH_SELINUX @@ -192,9 +192,9 @@ diff -up openssh-6.8p1/platform.c.keycat openssh-6.8p1/platform.c #endif #ifdef USE_SOLARIS_PROJECTS -diff -up openssh-6.8p1/ssh-keycat.c.keycat openssh-6.8p1/ssh-keycat.c ---- openssh-6.8p1/ssh-keycat.c.keycat 2015-03-18 11:13:43.064482956 +0100 -+++ openssh-6.8p1/ssh-keycat.c 2015-03-18 11:13:43.064482956 +0100 +diff -up openssh/ssh-keycat.c.keycat openssh/ssh-keycat.c +--- openssh/ssh-keycat.c.keycat 2015-06-24 10:57:50.161849599 +0200 ++++ openssh/ssh-keycat.c 2015-06-24 10:57:50.161849599 +0200 @@ -0,0 +1,238 @@ +/* + * Redistribution and use in source and binary forms, with or without diff --git a/openssh-6.7p1-audit.patch b/openssh-6.7p1-audit.patch index 614604e..b216062 100644 --- a/openssh-6.7p1-audit.patch +++ b/openssh-6.7p1-audit.patch @@ -1,18 +1,6 @@ -diff -up openssh-6.8p1/Makefile.in.audit openssh-6.8p1/Makefile.in ---- openssh-6.8p1/Makefile.in.audit 2015-03-20 13:41:15.065883826 +0100 -+++ openssh-6.8p1/Makefile.in 2015-03-20 13:41:15.100883769 +0100 -@@ -98,7 +98,7 @@ LIBSSH_OBJS=${LIBOPENSSH_OBJS} \ - sc25519.o ge25519.o fe25519.o ed25519.o verify.o hash.o blocks.o \ - kex.o kexdh.o kexgex.o kexecdh.o kexc25519.o \ - kexdhc.o kexgexc.o kexecdhc.o kexc25519c.o \ -- kexdhs.o kexgexs.o kexecdhs.o kexc25519s.o -+ kexdhs.o kexgexs.o kexecdhs.o kexc25519s.o auditstub.o - - SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \ - sshconnect.o sshconnect1.o sshconnect2.o mux.o \ -diff -up openssh-6.8p1/audit-bsm.c.audit openssh-6.8p1/audit-bsm.c ---- openssh-6.8p1/audit-bsm.c.audit 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/audit-bsm.c 2015-03-20 13:41:15.092883782 +0100 +diff -up openssh/audit-bsm.c.audit openssh/audit-bsm.c +--- openssh/audit-bsm.c.audit 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/audit-bsm.c 2015-06-24 11:53:29.780390469 +0200 @@ -375,10 +375,23 @@ audit_connection_from(const char *host, #endif } @@ -38,7 +26,7 @@ diff -up openssh-6.8p1/audit-bsm.c.audit openssh-6.8p1/audit-bsm.c } void -@@ -393,6 +406,12 @@ audit_session_close(struct logininfo *li) +@@ -393,6 +406,12 @@ audit_session_close(struct logininfo *li /* not implemented */ } @@ -92,9 +80,247 @@ diff -up openssh-6.8p1/audit-bsm.c.audit openssh-6.8p1/audit-bsm.c + /* not implemented */ +} #endif /* BSM */ -diff -up openssh-6.8p1/audit-linux.c.audit openssh-6.8p1/audit-linux.c ---- openssh-6.8p1/audit-linux.c.audit 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/audit-linux.c 2015-03-20 13:41:15.093883780 +0100 +diff -up openssh/audit.c.audit openssh/audit.c +--- openssh/audit.c.audit 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/audit.c 2015-06-24 11:53:29.781390467 +0200 +@@ -28,6 +28,7 @@ + + #include + #include ++#include + + #ifdef SSH_AUDIT_EVENTS + +@@ -36,6 +37,11 @@ + #include "key.h" + #include "hostfile.h" + #include "auth.h" ++#include "ssh-gss.h" ++#include "monitor_wrap.h" ++#include "xmalloc.h" ++#include "misc.h" ++#include "servconf.h" + + /* + * Care must be taken when using this since it WILL NOT be initialized when +@@ -43,6 +49,7 @@ + * audit_event(CONNECTION_ABANDON) is called. Test for NULL before using. + */ + extern Authctxt *the_authctxt; ++extern ServerOptions options; + + /* Maybe add the audit class to struct Authmethod? */ + ssh_audit_event_t +@@ -71,13 +78,10 @@ audit_classify_auth(const char *method) + const char * + audit_username(void) + { +- static const char unknownuser[] = "(unknown user)"; +- static const char invaliduser[] = "(invalid user)"; ++ static const char unknownuser[] = "(unknown)"; + +- if (the_authctxt == NULL || the_authctxt->user == NULL) ++ if (the_authctxt == NULL || the_authctxt->user == NULL || !the_authctxt->valid) + return (unknownuser); +- if (!the_authctxt->valid) +- return (invaliduser); + return (the_authctxt->user); + } + +@@ -111,6 +115,40 @@ audit_event_lookup(ssh_audit_event_t ev) + return(event_lookup[i].name); + } + ++void ++audit_key(int host_user, int *rv, const Key *key) ++{ ++ char *fp; ++ const char *crypto_name; ++ ++ fp = sshkey_fingerprint(key, options.fingerprint_hash, SSH_FP_HEX); ++ if (key->type == KEY_RSA1) ++ crypto_name = "ssh-rsa1"; ++ else ++ crypto_name = key_ssh_name(key); ++ if (audit_keyusage(host_user, crypto_name, key_size(key), fp, *rv) == 0) ++ *rv = 0; ++ free(fp); ++} ++ ++void ++audit_unsupported(int what) ++{ ++ PRIVSEP(audit_unsupported_body(what)); ++} ++ ++void ++audit_kex(int ctos, char *enc, char *mac, char *comp, char *pfs) ++{ ++ PRIVSEP(audit_kex_body(ctos, enc, mac, comp, pfs, getpid(), getuid())); ++} ++ ++void ++audit_session_key_free(int ctos) ++{ ++ PRIVSEP(audit_session_key_free_body(ctos, getpid(), getuid())); ++} ++ + # ifndef CUSTOM_SSH_AUDIT_EVENTS + /* + * Null implementations of audit functions. +@@ -140,6 +178,17 @@ audit_event(ssh_audit_event_t event) + } + + /* ++ * Called when a child process has called, or will soon call, ++ * audit_session_open. ++ */ ++void ++audit_count_session_open(void) ++{ ++ debug("audit count session open euid %d user %s", geteuid(), ++ audit_username()); ++} ++ ++/* + * Called when a user session is started. Argument is the tty allocated to + * the session, or NULL if no tty was allocated. + * +@@ -174,13 +223,91 @@ audit_session_close(struct logininfo *li + /* + * This will be called when a user runs a non-interactive command. Note that + * it may be called multiple times for a single connection since SSH2 allows +- * multiple sessions within a single connection. ++ * multiple sessions within a single connection. Returns a "handle" for ++ * audit_end_command. + */ +-void ++int + audit_run_command(const char *command) + { + debug("audit run command euid %d user %s command '%.200s'", geteuid(), + audit_username(), command); ++ return 0; ++} ++ ++/* ++ * This will be called when the non-interactive command finishes. Note that ++ * it may be called multiple times for a single connection since SSH2 allows ++ * multiple sessions within a single connection. "handle" should come from ++ * the corresponding audit_run_command. ++ */ ++void ++audit_end_command(int handle, const char *command) ++{ ++ debug("audit end nopty exec euid %d user %s command '%.200s'", geteuid(), ++ audit_username(), command); ++} ++ ++/* ++ * This will be called when user is successfully autherized by the RSA1/RSA/DSA key. ++ * ++ * Type is the key type, len is the key length(byte) and fp is the fingerprint of the key. ++ */ ++int ++audit_keyusage(int host_user, const char *type, unsigned bits, char *fp, int rv) ++{ ++ debug("audit %s key usage euid %d user %s key type %s key length %d fingerprint %s%s, result %d", ++ host_user ? "pubkey" : "hostbased", geteuid(), audit_username(), type, bits, ++ sshkey_fingerprint_prefix(), fp, rv); ++} ++ ++/* ++ * This will be called when the protocol negotiation fails. ++ */ ++void ++audit_unsupported_body(int what) ++{ ++ debug("audit unsupported protocol euid %d type %d", geteuid(), what); ++} ++ ++/* ++ * This will be called on succesfull protocol negotiation. ++ */ ++void ++audit_kex_body(int ctos, char *enc, char *mac, char *compress, char *pfs, pid_t pid, ++ uid_t uid) ++{ ++ debug("audit protocol negotiation euid %d direction %d cipher %s mac %s compresion %s pfs %s from pid %ld uid %u", ++ (unsigned)geteuid(), ctos, enc, mac, compress, pfs, (long)pid, ++ (unsigned)uid); ++} ++ ++/* ++ * This will be called on succesfull session key discard ++ */ ++void ++audit_session_key_free_body(int ctos, pid_t pid, uid_t uid) ++{ ++ debug("audit session key discard euid %u direction %d from pid %ld uid %u", ++ (unsigned)geteuid(), ctos, (long)pid, (unsigned)uid); ++} ++ ++/* ++ * This will be called on destroy private part of the server key ++ */ ++void ++audit_destroy_sensitive_data(const char *fp, pid_t pid, uid_t uid) ++{ ++ debug("audit destroy sensitive data euid %d fingerprint %s from pid %ld uid %u", ++ geteuid(), fp, (long)pid, (unsigned)uid); ++} ++ ++/* ++ * This will be called on generation of the ephemeral server key ++ */ ++void ++audit_generate_ephemeral_server_key(const char *) ++{ ++ debug("audit create ephemeral server key euid %d fingerprint %s", geteuid(), fp); + } + # endif /* !defined CUSTOM_SSH_AUDIT_EVENTS */ + #endif /* SSH_AUDIT_EVENTS */ +diff -up openssh/audit.h.audit openssh/audit.h +--- openssh/audit.h.audit 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/audit.h 2015-06-24 11:53:29.781390467 +0200 +@@ -28,6 +28,7 @@ + # define _SSH_AUDIT_H + + #include "loginrec.h" ++#include "key.h" + + enum ssh_audit_event_type { + SSH_LOGIN_EXCEED_MAXTRIES, +@@ -47,11 +48,25 @@ enum ssh_audit_event_type { + }; + typedef enum ssh_audit_event_type ssh_audit_event_t; + ++int listening_for_clients(void); ++ + void audit_connection_from(const char *, int); + void audit_event(ssh_audit_event_t); ++void audit_count_session_open(void); + void audit_session_open(struct logininfo *); + void audit_session_close(struct logininfo *); +-void audit_run_command(const char *); ++int audit_run_command(const char *); ++void audit_end_command(int, const char *); + ssh_audit_event_t audit_classify_auth(const char *); ++int audit_keyusage(int, const char *, unsigned, char *, int); ++void audit_key(int, int *, const Key *); ++void audit_unsupported(int); ++void audit_kex(int, char *, char *, char *, char *); ++void audit_unsupported_body(int); ++void audit_kex_body(int, char *, char *, char *, char *, pid_t, uid_t); ++void audit_session_key_free(int ctos); ++void audit_session_key_free_body(int ctos, pid_t, uid_t); ++void audit_destroy_sensitive_data(const char *, pid_t, uid_t); ++void audit_generate_ephemeral_server_key(const char *); + + #endif /* _SSH_AUDIT_H */ +diff -up openssh/audit-linux.c.audit openssh/audit-linux.c +--- openssh/audit-linux.c.audit 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/audit-linux.c 2015-06-24 11:53:29.781390467 +0200 @@ -35,13 +35,25 @@ #include "log.h" @@ -124,7 +350,7 @@ diff -up openssh-6.8p1/audit-linux.c.audit openssh-6.8p1/audit-linux.c { int audit_fd, rc, saved_errno; -@@ -49,11 +61,11 @@ linux_audit_record_event(int uid, const char *username, +@@ -49,11 +61,11 @@ linux_audit_record_event(int uid, const if (audit_fd < 0) { if (errno == EINVAL || errno == EPROTONOSUPPORT || errno == EAFNOSUPPORT) @@ -139,7 +365,7 @@ diff -up openssh-6.8p1/audit-linux.c.audit openssh-6.8p1/audit-linux.c NULL, "login", username ? username : "(unknown)", username == NULL ? uid : -1, hostname, ip, ttyn, success); saved_errno = errno; -@@ -65,35 +77,154 @@ linux_audit_record_event(int uid, const char *username, +@@ -65,35 +77,154 @@ linux_audit_record_event(int uid, const if ((rc == -EPERM) && (geteuid() != 0)) rc = 0; errno = saved_errno; @@ -486,247 +712,9 @@ diff -up openssh-6.8p1/audit-linux.c.audit openssh-6.8p1/audit-linux.c + error("cannot write into audit"); +} #endif /* USE_LINUX_AUDIT */ -diff -up openssh-6.8p1/audit.c.audit openssh-6.8p1/audit.c ---- openssh-6.8p1/audit.c.audit 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/audit.c 2015-03-20 13:41:15.093883780 +0100 -@@ -28,6 +28,7 @@ - - #include - #include -+#include - - #ifdef SSH_AUDIT_EVENTS - -@@ -36,6 +37,11 @@ - #include "key.h" - #include "hostfile.h" - #include "auth.h" -+#include "ssh-gss.h" -+#include "monitor_wrap.h" -+#include "xmalloc.h" -+#include "misc.h" -+#include "servconf.h" - - /* - * Care must be taken when using this since it WILL NOT be initialized when -@@ -43,6 +49,7 @@ - * audit_event(CONNECTION_ABANDON) is called. Test for NULL before using. - */ - extern Authctxt *the_authctxt; -+extern ServerOptions options; - - /* Maybe add the audit class to struct Authmethod? */ - ssh_audit_event_t -@@ -71,13 +78,10 @@ audit_classify_auth(const char *method) - const char * - audit_username(void) - { -- static const char unknownuser[] = "(unknown user)"; -- static const char invaliduser[] = "(invalid user)"; -+ static const char unknownuser[] = "(unknown)"; - -- if (the_authctxt == NULL || the_authctxt->user == NULL) -+ if (the_authctxt == NULL || the_authctxt->user == NULL || !the_authctxt->valid) - return (unknownuser); -- if (!the_authctxt->valid) -- return (invaliduser); - return (the_authctxt->user); - } - -@@ -111,6 +115,40 @@ audit_event_lookup(ssh_audit_event_t ev) - return(event_lookup[i].name); - } - -+void -+audit_key(int host_user, int *rv, const Key *key) -+{ -+ char *fp; -+ const char *crypto_name; -+ -+ fp = sshkey_fingerprint(key, options.fingerprint_hash, SSH_FP_HEX); -+ if (key->type == KEY_RSA1) -+ crypto_name = "ssh-rsa1"; -+ else -+ crypto_name = key_ssh_name(key); -+ if (audit_keyusage(host_user, crypto_name, key_size(key), fp, *rv) == 0) -+ *rv = 0; -+ free(fp); -+} -+ -+void -+audit_unsupported(int what) -+{ -+ PRIVSEP(audit_unsupported_body(what)); -+} -+ -+void -+audit_kex(int ctos, char *enc, char *mac, char *comp, char *pfs) -+{ -+ PRIVSEP(audit_kex_body(ctos, enc, mac, comp, pfs, getpid(), getuid())); -+} -+ -+void -+audit_session_key_free(int ctos) -+{ -+ PRIVSEP(audit_session_key_free_body(ctos, getpid(), getuid())); -+} -+ - # ifndef CUSTOM_SSH_AUDIT_EVENTS - /* - * Null implementations of audit functions. -@@ -140,6 +178,17 @@ audit_event(ssh_audit_event_t event) - } - - /* -+ * Called when a child process has called, or will soon call, -+ * audit_session_open. -+ */ -+void -+audit_count_session_open(void) -+{ -+ debug("audit count session open euid %d user %s", geteuid(), -+ audit_username()); -+} -+ -+/* - * Called when a user session is started. Argument is the tty allocated to - * the session, or NULL if no tty was allocated. - * -@@ -174,13 +223,91 @@ audit_session_close(struct logininfo *li) - /* - * This will be called when a user runs a non-interactive command. Note that - * it may be called multiple times for a single connection since SSH2 allows -- * multiple sessions within a single connection. -+ * multiple sessions within a single connection. Returns a "handle" for -+ * audit_end_command. - */ --void -+int - audit_run_command(const char *command) - { - debug("audit run command euid %d user %s command '%.200s'", geteuid(), - audit_username(), command); -+ return 0; -+} -+ -+/* -+ * This will be called when the non-interactive command finishes. Note that -+ * it may be called multiple times for a single connection since SSH2 allows -+ * multiple sessions within a single connection. "handle" should come from -+ * the corresponding audit_run_command. -+ */ -+void -+audit_end_command(int handle, const char *command) -+{ -+ debug("audit end nopty exec euid %d user %s command '%.200s'", geteuid(), -+ audit_username(), command); -+} -+ -+/* -+ * This will be called when user is successfully autherized by the RSA1/RSA/DSA key. -+ * -+ * Type is the key type, len is the key length(byte) and fp is the fingerprint of the key. -+ */ -+int -+audit_keyusage(int host_user, const char *type, unsigned bits, char *fp, int rv) -+{ -+ debug("audit %s key usage euid %d user %s key type %s key length %d fingerprint %s%s, result %d", -+ host_user ? "pubkey" : "hostbased", geteuid(), audit_username(), type, bits, -+ sshkey_fingerprint_prefix(), fp, rv); -+} -+ -+/* -+ * This will be called when the protocol negotiation fails. -+ */ -+void -+audit_unsupported_body(int what) -+{ -+ debug("audit unsupported protocol euid %d type %d", geteuid(), what); -+} -+ -+/* -+ * This will be called on succesfull protocol negotiation. -+ */ -+void -+audit_kex_body(int ctos, char *enc, char *mac, char *compress, char *pfs, pid_t pid, -+ uid_t uid) -+{ -+ debug("audit protocol negotiation euid %d direction %d cipher %s mac %s compresion %s pfs %s from pid %ld uid %u", -+ (unsigned)geteuid(), ctos, enc, mac, compress, pfs, (long)pid, -+ (unsigned)uid); -+} -+ -+/* -+ * This will be called on succesfull session key discard -+ */ -+void -+audit_session_key_free_body(int ctos, pid_t pid, uid_t uid) -+{ -+ debug("audit session key discard euid %u direction %d from pid %ld uid %u", -+ (unsigned)geteuid(), ctos, (long)pid, (unsigned)uid); -+} -+ -+/* -+ * This will be called on destroy private part of the server key -+ */ -+void -+audit_destroy_sensitive_data(const char *fp, pid_t pid, uid_t uid) -+{ -+ debug("audit destroy sensitive data euid %d fingerprint %s from pid %ld uid %u", -+ geteuid(), fp, (long)pid, (unsigned)uid); -+} -+ -+/* -+ * This will be called on generation of the ephemeral server key -+ */ -+void -+audit_generate_ephemeral_server_key(const char *) -+{ -+ debug("audit create ephemeral server key euid %d fingerprint %s", geteuid(), fp); - } - # endif /* !defined CUSTOM_SSH_AUDIT_EVENTS */ - #endif /* SSH_AUDIT_EVENTS */ -diff -up openssh-6.8p1/audit.h.audit openssh-6.8p1/audit.h ---- openssh-6.8p1/audit.h.audit 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/audit.h 2015-03-20 13:41:15.093883780 +0100 -@@ -28,6 +28,7 @@ - # define _SSH_AUDIT_H - - #include "loginrec.h" -+#include "key.h" - - enum ssh_audit_event_type { - SSH_LOGIN_EXCEED_MAXTRIES, -@@ -47,11 +48,25 @@ enum ssh_audit_event_type { - }; - typedef enum ssh_audit_event_type ssh_audit_event_t; - -+int listening_for_clients(void); -+ - void audit_connection_from(const char *, int); - void audit_event(ssh_audit_event_t); -+void audit_count_session_open(void); - void audit_session_open(struct logininfo *); - void audit_session_close(struct logininfo *); --void audit_run_command(const char *); -+int audit_run_command(const char *); -+void audit_end_command(int, const char *); - ssh_audit_event_t audit_classify_auth(const char *); -+int audit_keyusage(int, const char *, unsigned, char *, int); -+void audit_key(int, int *, const Key *); -+void audit_unsupported(int); -+void audit_kex(int, char *, char *, char *, char *); -+void audit_unsupported_body(int); -+void audit_kex_body(int, char *, char *, char *, char *, pid_t, uid_t); -+void audit_session_key_free(int ctos); -+void audit_session_key_free_body(int ctos, pid_t, uid_t); -+void audit_destroy_sensitive_data(const char *, pid_t, uid_t); -+void audit_generate_ephemeral_server_key(const char *); - - #endif /* _SSH_AUDIT_H */ -diff -up openssh-6.8p1/auditstub.c.audit openssh-6.8p1/auditstub.c ---- openssh-6.8p1/auditstub.c.audit 2015-03-20 13:41:15.093883780 +0100 -+++ openssh-6.8p1/auditstub.c 2015-03-20 13:41:15.093883780 +0100 +diff -up openssh/auditstub.c.audit openssh/auditstub.c +--- openssh/auditstub.c.audit 2015-06-24 11:53:29.782390464 +0200 ++++ openssh/auditstub.c 2015-06-24 11:53:29.782390464 +0200 @@ -0,0 +1,50 @@ +/* $Id: auditstub.c,v 1.1 jfch Exp $ */ + @@ -778,10 +766,117 @@ diff -up openssh-6.8p1/auditstub.c.audit openssh-6.8p1/auditstub.c +audit_session_key_free_body(int ctos, pid_t pid, uid_t uid) +{ +} -diff -up openssh-6.8p1/auth-rsa.c.audit openssh-6.8p1/auth-rsa.c ---- openssh-6.8p1/auth-rsa.c.audit 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/auth-rsa.c 2015-03-20 13:41:15.094883779 +0100 -@@ -95,7 +95,10 @@ auth_rsa_verify_response(Key *key, BIGNUM *challenge, u_char response[16]) +diff -up openssh/auth2.c.audit openssh/auth2.c +--- openssh/auth2.c.audit 2015-06-24 11:53:29.731390595 +0200 ++++ openssh/auth2.c 2015-06-24 11:53:29.783390462 +0200 +@@ -249,9 +249,6 @@ input_userauth_request(int type, u_int32 + } else { + logit("input_userauth_request: invalid user %s", user); + authctxt->pw = fakepw(); +-#ifdef SSH_AUDIT_EVENTS +- PRIVSEP(audit_event(SSH_INVALID_USER)); +-#endif + } + #ifdef USE_PAM + if (options.use_pam) +diff -up openssh/auth2-hostbased.c.audit openssh/auth2-hostbased.c +--- openssh/auth2-hostbased.c.audit 2015-06-24 11:53:29.682390720 +0200 ++++ openssh/auth2-hostbased.c 2015-06-24 11:53:29.782390464 +0200 +@@ -146,7 +146,7 @@ userauth_hostbased(Authctxt *authctxt) + /* test for allowed key and correct signature */ + authenticated = 0; + if (PRIVSEP(hostbased_key_allowed(authctxt->pw, cuser, chost, key)) && +- PRIVSEP(key_verify(key, sig, slen, buffer_ptr(&b), ++ PRIVSEP(hostbased_key_verify(key, sig, slen, buffer_ptr(&b), + buffer_len(&b))) == 1) + authenticated = 1; + +@@ -163,6 +163,18 @@ done: + return authenticated; + } + ++int ++hostbased_key_verify(const Key *key, const u_char *sig, u_int slen, const u_char *data, u_int datalen) ++{ ++ int rv; ++ ++ rv = key_verify(key, sig, slen, data, datalen); ++#ifdef SSH_AUDIT_EVENTS ++ audit_key(0, &rv, key); ++#endif ++ return rv; ++} ++ + /* return 1 if given hostkey is allowed */ + int + hostbased_key_allowed(struct passwd *pw, const char *cuser, char *chost, +diff -up openssh/auth2-pubkey.c.audit openssh/auth2-pubkey.c +--- openssh/auth2-pubkey.c.audit 2015-06-24 11:53:29.783390462 +0200 ++++ openssh/auth2-pubkey.c 2015-06-24 11:58:49.547572821 +0200 +@@ -175,7 +175,7 @@ userauth_pubkey(Authctxt *authctxt) + /* test for correct signature */ + authenticated = 0; + if (PRIVSEP(user_key_allowed(authctxt->pw, key, 1)) && +- PRIVSEP(key_verify(key, sig, slen, buffer_ptr(&b), ++ PRIVSEP(user_key_verify(key, sig, slen, buffer_ptr(&b), + buffer_len(&b))) == 1) { + authenticated = 1; + /* Record the successful key to prevent reuse */ +@@ -253,6 +253,18 @@ pubkey_auth_info(Authctxt *authctxt, con + free(extra); + } + ++int ++user_key_verify(const Key *key, const u_char *sig, u_int slen, const u_char *data, u_int datalen) ++{ ++ int rv; ++ ++ rv = key_verify(key, sig, slen, data, datalen); ++#ifdef SSH_AUDIT_EVENTS ++ audit_key(1, &rv, key); ++#endif ++ return rv; ++} ++ + /* + * Splits 's' into an argument vector. Handles quoted string and basic + * escape characters (\\, \", \'). Caller must free the argument vector +diff -up openssh/auth.c.audit openssh/auth.c +--- openssh/auth.c.audit 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/auth.c 2015-06-24 11:53:29.782390464 +0200 +@@ -643,9 +643,6 @@ getpwnamallow(const char *user) + record_failed_login(user, + get_canonical_hostname(options.use_dns), "ssh"); + #endif +-#ifdef SSH_AUDIT_EVENTS +- audit_event(SSH_INVALID_USER); +-#endif /* SSH_AUDIT_EVENTS */ + return (NULL); + } + if (!allowed_user(pw)) +diff -up openssh/auth.h.audit openssh/auth.h +--- openssh/auth.h.audit 2015-06-24 11:53:29.682390720 +0200 ++++ openssh/auth.h 2015-06-24 11:53:29.782390464 +0200 +@@ -195,6 +195,7 @@ void abandon_challenge_response(Authctxt + + char *expand_authorized_keys(const char *, struct passwd *pw); + char *authorized_principals_file(struct passwd *); ++int user_key_verify(const Key *, const u_char *, u_int, const u_char *, u_int); + + FILE *auth_openkeyfile(const char *, struct passwd *, int); + FILE *auth_openprincipals(const char *, struct passwd *, int); +@@ -213,6 +214,7 @@ int get_hostkey_index(Key *, int, struc + int ssh1_session_key(BIGNUM *); + int sshd_hostkey_sign(Key *, Key *, u_char **, size_t *, + const u_char *, size_t, u_int); ++int hostbased_key_verify(const Key *, const u_char *, u_int, const u_char *, u_int); + + /* debug messages during authentication */ + void auth_debug_add(const char *fmt,...) __attribute__((format(printf, 1, 2))); +diff -up openssh/auth-rsa.c.audit openssh/auth-rsa.c +--- openssh/auth-rsa.c.audit 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/auth-rsa.c 2015-06-24 11:53:29.782390464 +0200 +@@ -95,7 +95,10 @@ auth_rsa_verify_response(Key *key, BIGNU { u_char buf[32], mdbuf[16]; struct ssh_digest_ctx *md; @@ -793,7 +888,7 @@ diff -up openssh-6.8p1/auth-rsa.c.audit openssh-6.8p1/auth-rsa.c /* don't allow short keys */ if (BN_num_bits(key->rsa->n) < SSH_RSA_MINIMUM_MODULUS_SIZE) { -@@ -119,12 +122,18 @@ auth_rsa_verify_response(Key *key, BIGNUM *challenge, u_char response[16]) +@@ -119,12 +122,18 @@ auth_rsa_verify_response(Key *key, BIGNU ssh_digest_free(md); /* Verify that the response is the original challenge. */ @@ -817,117 +912,10 @@ diff -up openssh-6.8p1/auth-rsa.c.audit openssh-6.8p1/auth-rsa.c } /* -diff -up openssh-6.8p1/auth.c.audit openssh-6.8p1/auth.c ---- openssh-6.8p1/auth.c.audit 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/auth.c 2015-03-20 13:41:15.094883779 +0100 -@@ -644,9 +644,6 @@ getpwnamallow(const char *user) - record_failed_login(user, - get_canonical_hostname(options.use_dns), "ssh"); - #endif --#ifdef SSH_AUDIT_EVENTS -- audit_event(SSH_INVALID_USER); --#endif /* SSH_AUDIT_EVENTS */ - return (NULL); - } - if (!allowed_user(pw)) -diff -up openssh-6.8p1/auth.h.audit openssh-6.8p1/auth.h ---- openssh-6.8p1/auth.h.audit 2015-03-20 13:41:15.002883927 +0100 -+++ openssh-6.8p1/auth.h 2015-03-20 13:41:15.094883779 +0100 -@@ -195,6 +195,7 @@ void abandon_challenge_response(Authctxt - - char *expand_authorized_keys(const char *, struct passwd *pw); - char *authorized_principals_file(struct passwd *); -+int user_key_verify(const Key *, const u_char *, u_int, const u_char *, u_int); - - FILE *auth_openkeyfile(const char *, struct passwd *, int); - FILE *auth_openprincipals(const char *, struct passwd *, int); -@@ -213,6 +214,7 @@ int get_hostkey_index(Key *, int, struc - int ssh1_session_key(BIGNUM *); - int sshd_hostkey_sign(Key *, Key *, u_char **, size_t *, - const u_char *, size_t, u_int); -+int hostbased_key_verify(const Key *, const u_char *, u_int, const u_char *, u_int); - - /* debug messages during authentication */ - void auth_debug_add(const char *fmt,...) __attribute__((format(printf, 1, 2))); -diff -up openssh-6.8p1/auth2-hostbased.c.audit openssh-6.8p1/auth2-hostbased.c ---- openssh-6.8p1/auth2-hostbased.c.audit 2015-03-20 13:41:15.002883927 +0100 -+++ openssh-6.8p1/auth2-hostbased.c 2015-03-20 13:41:15.093883780 +0100 -@@ -147,7 +147,7 @@ userauth_hostbased(Authctxt *authctxt) - /* test for allowed key and correct signature */ - authenticated = 0; - if (PRIVSEP(hostbased_key_allowed(authctxt->pw, cuser, chost, key)) && -- PRIVSEP(key_verify(key, sig, slen, buffer_ptr(&b), -+ PRIVSEP(hostbased_key_verify(key, sig, slen, buffer_ptr(&b), - buffer_len(&b))) == 1) - authenticated = 1; - -@@ -164,6 +164,18 @@ done: - return authenticated; - } - -+int -+hostbased_key_verify(const Key *key, const u_char *sig, u_int slen, const u_char *data, u_int datalen) -+{ -+ int rv; -+ -+ rv = key_verify(key, sig, slen, data, datalen); -+#ifdef SSH_AUDIT_EVENTS -+ audit_key(0, &rv, key); -+#endif -+ return rv; -+} -+ - /* return 1 if given hostkey is allowed */ - int - hostbased_key_allowed(struct passwd *pw, const char *cuser, char *chost, -diff -up openssh-6.8p1/auth2-pubkey.c.audit openssh-6.8p1/auth2-pubkey.c ---- openssh-6.8p1/auth2-pubkey.c.audit 2015-03-20 13:41:15.013883910 +0100 -+++ openssh-6.8p1/auth2-pubkey.c 2015-03-20 13:41:15.094883779 +0100 -@@ -172,7 +172,7 @@ userauth_pubkey(Authctxt *authctxt) - /* test for correct signature */ - authenticated = 0; - if (PRIVSEP(user_key_allowed(authctxt->pw, key)) && -- PRIVSEP(key_verify(key, sig, slen, buffer_ptr(&b), -+ PRIVSEP(user_key_verify(key, sig, slen, buffer_ptr(&b), - buffer_len(&b))) == 1) { - authenticated = 1; - /* Record the successful key to prevent reuse */ -@@ -250,6 +250,18 @@ pubkey_auth_info(Authctxt *authctxt, con - free(extra); - } - -+int -+user_key_verify(const Key *key, const u_char *sig, u_int slen, const u_char *data, u_int datalen) -+{ -+ int rv; -+ -+ rv = key_verify(key, sig, slen, data, datalen); -+#ifdef SSH_AUDIT_EVENTS -+ audit_key(1, &rv, key); -+#endif -+ return rv; -+} -+ - static int - match_principals_option(const char *principal_list, struct sshkey_cert *cert) - { -diff -up openssh-6.8p1/auth2.c.audit openssh-6.8p1/auth2.c ---- openssh-6.8p1/auth2.c.audit 2015-03-20 13:41:15.044883860 +0100 -+++ openssh-6.8p1/auth2.c 2015-03-20 13:41:15.093883780 +0100 -@@ -249,9 +249,6 @@ input_userauth_request(int type, u_int32 - } else { - logit("input_userauth_request: invalid user %s", user); - authctxt->pw = fakepw(); --#ifdef SSH_AUDIT_EVENTS -- PRIVSEP(audit_event(SSH_INVALID_USER)); --#endif - } - #ifdef USE_PAM - if (options.use_pam) -diff -up openssh-6.8p1/cipher.c.audit openssh-6.8p1/cipher.c ---- openssh-6.8p1/cipher.c.audit 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/cipher.c 2015-03-20 13:41:15.101883767 +0100 -@@ -57,26 +59,6 @@ extern const EVP_CIPHER *evp_ssh1_3des(v +diff -up openssh/cipher.c.audit openssh/cipher.c +--- openssh/cipher.c.audit 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/cipher.c 2015-06-24 11:53:29.783390462 +0200 +@@ -57,26 +57,6 @@ extern const EVP_CIPHER *evp_ssh1_3des(v extern int ssh1_3des_iv(EVP_CIPHER_CTX *, int, u_char *, int); #endif @@ -954,9 +942,9 @@ diff -up openssh-6.8p1/cipher.c.audit openssh-6.8p1/cipher.c static const struct sshcipher ciphers[] = { #ifdef WITH_SSH1 { "des", SSH_CIPHER_DES, 8, 8, 0, 0, 0, 1, EVP_des_cbc }, -diff -up openssh-6.8p1/cipher.h.audit openssh-6.8p1/cipher.h ---- openssh-6.8p1/cipher.h.audit 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/cipher.h 2015-03-20 13:41:15.094883779 +0100 +diff -up openssh/cipher.h.audit openssh/cipher.h +--- openssh/cipher.h.audit 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/cipher.h 2015-06-24 11:53:29.783390462 +0200 @@ -62,7 +62,26 @@ #define CIPHER_ENCRYPT 1 #define CIPHER_DECRYPT 0 @@ -985,10 +973,10 @@ diff -up openssh-6.8p1/cipher.h.audit openssh-6.8p1/cipher.h struct sshcipher_ctx { int plaintext; int encrypt; -diff -up openssh-6.8p1/kex.c.audit openssh-6.8p1/kex.c ---- openssh-6.8p1/kex.c.audit 2015-03-20 13:41:15.046883856 +0100 -+++ openssh-6.8p1/kex.c 2015-03-20 13:41:15.101883767 +0100 -@@ -54,6 +55,7 @@ +diff -up openssh/kex.c.audit openssh/kex.c +--- openssh/kex.c.audit 2015-06-24 11:53:29.733390590 +0200 ++++ openssh/kex.c 2015-06-24 11:53:29.783390462 +0200 +@@ -54,6 +54,7 @@ #include "ssherr.h" #include "sshbuf.h" #include "digest.h" @@ -996,7 +984,7 @@ diff -up openssh-6.8p1/kex.c.audit openssh-6.8p1/kex.c #ifdef GSSAPI #include "ssh-gss.h" -@@ -484,8 +508,12 @@ choose_enc(struct sshenc *enc, char *cli +@@ -486,8 +487,12 @@ choose_enc(struct sshenc *enc, char *cli { char *name = match_list(client, server, NULL); @@ -1010,7 +998,7 @@ diff -up openssh-6.8p1/kex.c.audit openssh-6.8p1/kex.c if ((enc->cipher = cipher_by_name(name)) == NULL) return SSH_ERR_INTERNAL_ERROR; enc->name = name; -@@ -503,8 +531,12 @@ choose_mac(struct ssh *ssh, struct sshma +@@ -505,8 +510,12 @@ choose_mac(struct ssh *ssh, struct sshma { char *name = match_list(client, server, NULL); @@ -1024,7 +1012,7 @@ diff -up openssh-6.8p1/kex.c.audit openssh-6.8p1/kex.c if (mac_setup(mac, name) < 0) return SSH_ERR_INTERNAL_ERROR; /* truncate the key */ -@@ -521,8 +553,12 @@ choose_comp(struct sshcomp *comp, char * +@@ -523,8 +532,12 @@ choose_comp(struct sshcomp *comp, char * { char *name = match_list(client, server, NULL); @@ -1038,7 +1026,7 @@ diff -up openssh-6.8p1/kex.c.audit openssh-6.8p1/kex.c if (strcmp(name, "zlib@openssh.com") == 0) { comp->type = COMP_DELAYED; } else if (strcmp(name, "zlib") == 0) { -@@ -672,6 +708,10 @@ kex_choose_conf(struct ssh *ssh) +@@ -674,6 +687,10 @@ kex_choose_conf(struct ssh *ssh) dh_need = MAX(dh_need, newkeys->enc.block_size); dh_need = MAX(dh_need, newkeys->enc.iv_len); dh_need = MAX(dh_need, newkeys->mac.key_len); @@ -1049,7 +1037,7 @@ diff -up openssh-6.8p1/kex.c.audit openssh-6.8p1/kex.c } /* XXX need runden? */ kex->we_need = need; -@@ -847,3 +887,34 @@ dump_digest(char *msg, u_char *digest, i +@@ -849,3 +866,34 @@ dump_digest(char *msg, u_char *digest, i sshbuf_dump_data(digest, len, stderr); } #endif @@ -1084,9 +1072,9 @@ diff -up openssh-6.8p1/kex.c.audit openssh-6.8p1/kex.c + memset(&newkeys->comp, 0, sizeof(newkeys->comp)); +} + -diff -up openssh-6.8p1/kex.h.audit openssh-6.8p1/kex.h ---- openssh-6.8p1/kex.h.audit 2015-03-20 13:41:15.046883856 +0100 -+++ openssh-6.8p1/kex.h 2015-03-20 13:41:15.095883777 +0100 +diff -up openssh/kex.h.audit openssh/kex.h +--- openssh/kex.h.audit 2015-06-24 11:53:29.733390590 +0200 ++++ openssh/kex.h 2015-06-24 11:53:29.784390459 +0200 @@ -199,6 +199,8 @@ int kexgss_client(struct ssh *); int kexgss_server(struct ssh *); #endif @@ -1096,9 +1084,9 @@ diff -up openssh-6.8p1/kex.h.audit openssh-6.8p1/kex.h int kex_dh_hash(const char *, const char *, const u_char *, size_t, const u_char *, size_t, const u_char *, size_t, const BIGNUM *, const BIGNUM *, const BIGNUM *, u_char *, size_t *); -diff -up openssh-6.8p1/key.h.audit openssh-6.8p1/key.h ---- openssh-6.8p1/key.h.audit 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/key.h 2015-03-20 13:41:15.095883777 +0100 +diff -up openssh/key.h.audit openssh/key.h +--- openssh/key.h.audit 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/key.h 2015-06-24 11:53:29.784390459 +0200 @@ -50,6 +50,7 @@ typedef struct sshkey Key; #define key_ecdsa_bits_to_nid sshkey_ecdsa_bits_to_nid #define key_ecdsa_key_to_nid sshkey_ecdsa_key_to_nid @@ -1107,10 +1095,10 @@ diff -up openssh-6.8p1/key.h.audit openssh-6.8p1/key.h #define key_type_plain sshkey_type_plain #define key_cert_is_legacy sshkey_cert_is_legacy #define key_curve_name_to_nid sshkey_curve_name_to_nid -diff -up openssh-6.8p1/mac.c.audit openssh-6.8p1/mac.c ---- openssh-6.8p1/mac.c.audit 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/mac.c 2015-03-20 13:41:15.102883766 +0100 -@@ -226,6 +246,20 @@ mac_clear(struct sshmac *mac) +diff -up openssh/mac.c.audit openssh/mac.c +--- openssh/mac.c.audit 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/mac.c 2015-06-24 11:53:29.784390459 +0200 +@@ -226,6 +226,20 @@ mac_clear(struct sshmac *mac) mac->umac_ctx = NULL; } @@ -1131,9 +1119,9 @@ diff -up openssh-6.8p1/mac.c.audit openssh-6.8p1/mac.c /* XXX copied from ciphers_valid */ #define MAC_SEP "," int -diff -up openssh-6.8p1/mac.h.audit openssh-6.8p1/mac.h ---- openssh-6.8p1/mac.h.audit 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/mac.h 2015-03-20 13:41:15.095883777 +0100 +diff -up openssh/mac.h.audit openssh/mac.h +--- openssh/mac.h.audit 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/mac.h 2015-06-24 11:53:29.784390459 +0200 @@ -47,5 +47,6 @@ int mac_init(struct sshmac *); int mac_compute(struct sshmac *, u_int32_t, const u_char *, int, u_char *, size_t); @@ -1141,9 +1129,21 @@ diff -up openssh-6.8p1/mac.h.audit openssh-6.8p1/mac.h +void mac_destroy(struct sshmac *); #endif /* SSHMAC_H */ -diff -up openssh-6.8p1/monitor.c.audit openssh-6.8p1/monitor.c ---- openssh-6.8p1/monitor.c.audit 2015-03-20 13:41:15.072883814 +0100 -+++ openssh-6.8p1/monitor.c 2015-03-20 13:41:15.107883758 +0100 +diff -up openssh/Makefile.in.audit openssh/Makefile.in +--- openssh/Makefile.in.audit 2015-06-24 11:53:29.752390541 +0200 ++++ openssh/Makefile.in 2015-06-24 11:53:29.780390469 +0200 +@@ -98,7 +98,7 @@ LIBSSH_OBJS=${LIBOPENSSH_OBJS} \ + sc25519.o ge25519.o fe25519.o ed25519.o verify.o hash.o blocks.o \ + kex.o kexdh.o kexgex.o kexecdh.o kexc25519.o \ + kexdhc.o kexgexc.o kexecdhc.o kexc25519c.o \ +- kexdhs.o kexgexs.o kexecdhs.o kexc25519s.o ++ kexdhs.o kexgexs.o kexecdhs.o kexc25519s.o auditstub.o + + SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \ + sshconnect.o sshconnect1.o sshconnect2.o mux.o \ +diff -up openssh/monitor.c.audit openssh/monitor.c +--- openssh/monitor.c.audit 2015-06-24 11:53:29.759390523 +0200 ++++ openssh/monitor.c 2015-06-24 11:53:29.784390459 +0200 @@ -102,6 +102,7 @@ #include "ssh2.h" #include "roaming.h" @@ -1219,7 +1219,7 @@ diff -up openssh-6.8p1/monitor.c.audit openssh-6.8p1/monitor.c #endif #endif /* WITH_SSH1 */ {0, 0, NULL} -@@ -1466,9 +1493,11 @@ mm_answer_keyverify(int sock, Buffer *m) +@@ -1467,9 +1493,11 @@ mm_answer_keyverify(int sock, Buffer *m) Key *key; u_char *signature, *data, *blob; u_int signaturelen, datalen, bloblen; @@ -1231,7 +1231,7 @@ diff -up openssh-6.8p1/monitor.c.audit openssh-6.8p1/monitor.c blob = buffer_get_string(m, &bloblen); signature = buffer_get_string(m, &signaturelen); data = buffer_get_string(m, &datalen); -@@ -1476,6 +1505,8 @@ mm_answer_keyverify(int sock, Buffer *m) +@@ -1477,6 +1505,8 @@ mm_answer_keyverify(int sock, Buffer *m) if (hostbased_cuser == NULL || hostbased_chost == NULL || !monitor_allowed_key(blob, bloblen)) fatal("%s: bad key, not previously allowed", __func__); @@ -1240,7 +1240,7 @@ diff -up openssh-6.8p1/monitor.c.audit openssh-6.8p1/monitor.c key = key_from_blob(blob, bloblen); if (key == NULL) -@@ -1496,7 +1527,17 @@ mm_answer_keyverify(int sock, Buffer *m) +@@ -1497,7 +1527,17 @@ mm_answer_keyverify(int sock, Buffer *m) if (!valid_data) fatal("%s: bad signature data blob", __func__); @@ -1259,7 +1259,7 @@ diff -up openssh-6.8p1/monitor.c.audit openssh-6.8p1/monitor.c debug3("%s: key %p signature %s", __func__, key, (verified == 1) ? "verified" : "unverified"); -@@ -1554,6 +1595,12 @@ mm_session_close(Session *s) +@@ -1558,6 +1598,12 @@ mm_session_close(Session *s) debug3("%s: tty %s ptyfd %d", __func__, s->tty, s->ptyfd); session_pty_cleanup2(s); } @@ -1272,7 +1272,7 @@ diff -up openssh-6.8p1/monitor.c.audit openssh-6.8p1/monitor.c session_unused(s->self); } -@@ -1836,6 +1883,8 @@ mm_answer_term(int sock, Buffer *req) +@@ -1840,6 +1886,8 @@ mm_answer_term(int sock, Buffer *req) sshpam_cleanup(); #endif @@ -1281,7 +1281,7 @@ diff -up openssh-6.8p1/monitor.c.audit openssh-6.8p1/monitor.c while (waitpid(pmonitor->m_pid, &status, 0) == -1) if (errno != EINTR) exit(1); -@@ -1878,11 +1927,43 @@ mm_answer_audit_command(int socket, Buff +@@ -1882,11 +1930,43 @@ mm_answer_audit_command(int socket, Buff { u_int len; char *cmd; @@ -1326,7 +1326,7 @@ diff -up openssh-6.8p1/monitor.c.audit openssh-6.8p1/monitor.c free(cmd); return (0); } -@@ -1936,6 +2017,7 @@ +@@ -1943,6 +2023,7 @@ monitor_apply_keystate(struct monitor *p void mm_get_keystate(struct monitor *pmonitor) { @@ -1334,7 +1334,7 @@ diff -up openssh-6.8p1/monitor.c.audit openssh-6.8p1/monitor.c debug3("%s: Waiting for new keys", __func__); if ((child_state = sshbuf_new()) == NULL) -@@ -1946,6 +2027,21 @@ mm_get_keystate(struct monitor *pmonitor +@@ -1950,6 +2031,21 @@ mm_get_keystate(struct monitor *pmonitor mm_request_receive_expect(pmonitor->m_sendfd, MONITOR_REQ_KEYEXPORT, child_state); debug3("%s: GOT new keys", __func__); @@ -1356,7 +1356,7 @@ diff -up openssh-6.8p1/monitor.c.audit openssh-6.8p1/monitor.c } -@@ -2212,3 +2308,87 @@ mm_answer_gss_updatecreds(int socket, Bu +@@ -2216,3 +2312,87 @@ mm_answer_gss_updatecreds(int socket, Bu #endif /* GSSAPI */ @@ -1444,9 +1444,9 @@ diff -up openssh-6.8p1/monitor.c.audit openssh-6.8p1/monitor.c + return 0; +} +#endif /* SSH_AUDIT_EVENTS */ -diff -up openssh-6.8p1/monitor.h.audit openssh-6.8p1/monitor.h ---- openssh-6.8p1/monitor.h.audit 2015-03-20 13:41:15.072883814 +0100 -+++ openssh-6.8p1/monitor.h 2015-03-20 13:41:15.096883775 +0100 +diff -up openssh/monitor.h.audit openssh/monitor.h +--- openssh/monitor.h.audit 2015-06-24 11:53:29.759390523 +0200 ++++ openssh/monitor.h 2015-06-24 11:53:29.785390457 +0200 @@ -69,7 +69,13 @@ enum monitor_reqtype { MONITOR_REQ_PAM_QUERY = 106, MONITOR_ANS_PAM_QUERY = 107, MONITOR_REQ_PAM_RESPOND = 108, MONITOR_ANS_PAM_RESPOND = 109, @@ -1462,10 +1462,10 @@ diff -up openssh-6.8p1/monitor.h.audit openssh-6.8p1/monitor.h }; -diff -up openssh-6.8p1/monitor_wrap.c.audit openssh-6.8p1/monitor_wrap.c ---- openssh-6.8p1/monitor_wrap.c.audit 2015-03-20 13:41:15.047883855 +0100 -+++ openssh-6.8p1/monitor_wrap.c 2015-03-20 13:41:15.108883756 +0100 -@@ -461,7 +461,7 @@ mm_key_allowed(enum mm_keytype type, cha +diff -up openssh/monitor_wrap.c.audit openssh/monitor_wrap.c +--- openssh/monitor_wrap.c.audit 2015-06-24 11:53:29.734390587 +0200 ++++ openssh/monitor_wrap.c 2015-06-24 11:53:29.785390457 +0200 +@@ -462,7 +462,7 @@ mm_key_allowed(enum mm_keytype type, cha */ int @@ -1474,7 +1474,7 @@ diff -up openssh-6.8p1/monitor_wrap.c.audit openssh-6.8p1/monitor_wrap.c { Buffer m; u_char *blob; -@@ -475,6 +475,7 @@ mm_key_verify(Key *key, u_char *sig, u_i +@@ -476,6 +476,7 @@ mm_key_verify(Key *key, u_char *sig, u_i return (0); buffer_init(&m); @@ -1482,7 +1482,7 @@ diff -up openssh-6.8p1/monitor_wrap.c.audit openssh-6.8p1/monitor_wrap.c buffer_put_string(&m, blob, len); buffer_put_string(&m, sig, siglen); buffer_put_string(&m, data, datalen); -@@ -492,6 +493,18 @@ mm_key_verify(Key *key, u_char *sig, u_i +@@ -493,6 +494,18 @@ mm_key_verify(Key *key, u_char *sig, u_i return (verified); } @@ -1501,7 +1501,7 @@ diff -up openssh-6.8p1/monitor_wrap.c.audit openssh-6.8p1/monitor_wrap.c void mm_send_keystate(struct monitor *monitor) { -@@ -1005,10 +1018,11 @@ mm_audit_event(ssh_audit_event_t event) +@@ -1006,10 +1019,11 @@ mm_audit_event(ssh_audit_event_t event) buffer_free(&m); } @@ -1514,7 +1514,7 @@ diff -up openssh-6.8p1/monitor_wrap.c.audit openssh-6.8p1/monitor_wrap.c debug3("%s entering command %s", __func__, command); -@@ -1016,6 +1030,26 @@ mm_audit_run_command(const char *command +@@ -1017,6 +1031,26 @@ mm_audit_run_command(const char *command buffer_put_cstring(&m, command); mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUDIT_COMMAND, &m); @@ -1541,7 +1541,7 @@ diff -up openssh-6.8p1/monitor_wrap.c.audit openssh-6.8p1/monitor_wrap.c buffer_free(&m); } #endif /* SSH_AUDIT_EVENTS */ -@@ -1151,3 +1185,72 @@ mm_ssh_gssapi_update_creds(ssh_gssapi_cc +@@ -1152,3 +1186,72 @@ mm_ssh_gssapi_update_creds(ssh_gssapi_cc #endif /* GSSAPI */ @@ -1614,11 +1614,11 @@ diff -up openssh-6.8p1/monitor_wrap.c.audit openssh-6.8p1/monitor_wrap.c + buffer_free(&m); +} +#endif /* SSH_AUDIT_EVENTS */ -diff -up openssh-6.8p1/monitor_wrap.h.audit openssh-6.8p1/monitor_wrap.h ---- openssh-6.8p1/monitor_wrap.h.audit 2015-03-20 13:41:15.048883853 +0100 -+++ openssh-6.8p1/monitor_wrap.h 2015-03-20 13:41:15.096883775 +0100 +diff -up openssh/monitor_wrap.h.audit openssh/monitor_wrap.h +--- openssh/monitor_wrap.h.audit 2015-06-24 11:53:29.734390587 +0200 ++++ openssh/monitor_wrap.h 2015-06-24 11:59:45.086430808 +0200 @@ -52,7 +52,8 @@ int mm_key_allowed(enum mm_keytype, char - int mm_user_key_allowed(struct passwd *, Key *); + int mm_user_key_allowed(struct passwd *, Key *, int); int mm_hostbased_key_allowed(struct passwd *, char *, char *, Key *); int mm_auth_rhosts_rsa_key_allowed(struct passwd *, char *, char *, Key *); -int mm_key_verify(Key *, u_char *, u_int, u_char *, u_int); @@ -1641,9 +1641,9 @@ diff -up openssh-6.8p1/monitor_wrap.h.audit openssh-6.8p1/monitor_wrap.h #endif struct Session; -diff -up openssh-6.8p1/packet.c.audit openssh-6.8p1/packet.c ---- openssh-6.8p1/packet.c.audit 2015-03-20 13:41:14.990883947 +0100 -+++ openssh-6.8p1/packet.c 2015-03-20 13:41:15.097883774 +0100 +diff -up openssh/packet.c.audit openssh/packet.c +--- openssh/packet.c.audit 2015-06-24 11:53:29.665390763 +0200 ++++ openssh/packet.c 2015-06-24 11:53:29.786390454 +0200 @@ -67,6 +67,7 @@ #include "key.h" /* typedefs XXX */ @@ -1652,7 +1652,7 @@ diff -up openssh-6.8p1/packet.c.audit openssh-6.8p1/packet.c #include "crc32.h" #include "deattack.h" #include "compat.h" -@@ -448,6 +449,13 @@ ssh_packet_get_connection_out(struct ssh +@@ -449,6 +450,13 @@ ssh_packet_get_connection_out(struct ssh return ssh->state->connection_out; } @@ -1666,7 +1666,7 @@ diff -up openssh-6.8p1/packet.c.audit openssh-6.8p1/packet.c /* * Returns the IP-address of the remote host as a string. The returned * string must not be freed. -@@ -478,13 +486,6 @@ ssh_packet_close(struct ssh *ssh) +@@ -479,13 +487,6 @@ ssh_packet_close(struct ssh *ssh) if (!state->initialized) return; state->initialized = 0; @@ -1680,7 +1680,7 @@ diff -up openssh-6.8p1/packet.c.audit openssh-6.8p1/packet.c sshbuf_free(state->input); sshbuf_free(state->output); sshbuf_free(state->outgoing_packet); -@@ -516,14 +517,24 @@ ssh_packet_close(struct ssh *ssh) +@@ -517,14 +518,24 @@ ssh_packet_close(struct ssh *ssh) inflateEnd(stream); } } @@ -1709,7 +1709,7 @@ diff -up openssh-6.8p1/packet.c.audit openssh-6.8p1/packet.c free(ssh->state); ssh->state = NULL; } -@@ -941,6 +952,7 @@ ssh_set_newkeys(struct ssh *ssh, int mod +@@ -944,6 +955,7 @@ ssh_set_newkeys(struct ssh *ssh, int mod } if (state->newkeys[mode] != NULL) { debug("set_newkeys: rekeying"); @@ -1717,7 +1717,7 @@ diff -up openssh-6.8p1/packet.c.audit openssh-6.8p1/packet.c if ((r = cipher_cleanup(cc)) != 0) return r; enc = &state->newkeys[mode]->enc; -@@ -2263,6 +2275,75 @@ ssh_packet_get_output(struct ssh *ssh) +@@ -2281,6 +2293,75 @@ ssh_packet_get_output(struct ssh *ssh) return (void *)ssh->state->output; } @@ -1793,7 +1793,7 @@ diff -up openssh-6.8p1/packet.c.audit openssh-6.8p1/packet.c /* XXX TODO update roaming to new API (does not work anyway) */ /* * Save the state for the real connection, and use a separate state when -@@ -2272,18 +2373,12 @@ void +@@ -2290,18 +2371,12 @@ void ssh_packet_backup_state(struct ssh *ssh, struct ssh *backup_state) { @@ -1813,7 +1813,7 @@ diff -up openssh-6.8p1/packet.c.audit openssh-6.8p1/packet.c } /* XXX FIXME FIXME FIXME */ -@@ -2302,9 +2397,7 @@ ssh_packet_restore_state(struct ssh *ssh +@@ -2320,9 +2395,7 @@ ssh_packet_restore_state(struct ssh *ssh backup_state = ssh; ssh = tmp; ssh->state->connection_in = backup_state->state->connection_in; @@ -1823,7 +1823,7 @@ diff -up openssh-6.8p1/packet.c.audit openssh-6.8p1/packet.c len = sshbuf_len(backup_state->state->input); if (len > 0) { if ((r = sshbuf_putb(ssh->state->input, -@@ -2313,6 +2406,11 @@ ssh_packet_restore_state(struct ssh *ssh +@@ -2331,6 +2404,11 @@ ssh_packet_restore_state(struct ssh *ssh sshbuf_reset(backup_state->state->input); add_recv_bytes(len); } @@ -1835,9 +1835,9 @@ diff -up openssh-6.8p1/packet.c.audit openssh-6.8p1/packet.c } /* Reset after_authentication and reset compression in post-auth privsep */ -diff -up openssh-6.8p1/packet.h.audit openssh-6.8p1/packet.h ---- openssh-6.8p1/packet.h.audit 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/packet.h 2015-03-20 13:41:15.097883774 +0100 +diff -up openssh/packet.h.audit openssh/packet.h +--- openssh/packet.h.audit 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/packet.h 2015-06-24 11:53:29.786390454 +0200 @@ -189,7 +189,7 @@ int sshpkt_get_end(struct ssh *ssh); const u_char *sshpkt_ptr(struct ssh *, size_t *lenp); @@ -1853,9 +1853,25 @@ diff -up openssh-6.8p1/packet.h.audit openssh-6.8p1/packet.h +void packet_destroy_all(int, int); #endif /* PACKET_H */ -diff -up openssh-6.8p1/session.c.audit openssh-6.8p1/session.c ---- openssh-6.8p1/session.c.audit 2015-03-20 13:41:15.073883813 +0100 -+++ openssh-6.8p1/session.c 2015-03-20 13:41:15.097883774 +0100 +diff -up openssh/sandbox-seccomp-filter.c.audit openssh/sandbox-seccomp-filter.c +--- openssh/sandbox-seccomp-filter.c.audit 2015-06-24 11:53:29.788390449 +0200 ++++ openssh/sandbox-seccomp-filter.c 2015-06-24 12:00:37.459296890 +0200 +@@ -147,6 +147,12 @@ static const struct sock_filter preauth_ + #ifdef __NR_gettimeofday + SC_ALLOW(gettimeofday), + #endif ++#ifdef SSH_AUDIT_EVENTS ++ SC_ALLOW(getuid), ++#ifdef __NR_getuid32 /* not defined on x86_64 */ ++ SC_ALLOW(getuid32), ++#endif ++#endif + #ifdef __NR_madvise + SC_ALLOW(madvise), + #endif +diff -up openssh/session.c.audit openssh/session.c +--- openssh/session.c.audit 2015-06-24 11:53:29.760390520 +0200 ++++ openssh/session.c 2015-06-24 11:53:29.786390454 +0200 @@ -139,7 +139,7 @@ extern int log_stderr; extern int debug_flag; extern u_int utmp_len; @@ -1975,7 +1991,7 @@ diff -up openssh-6.8p1/session.c.audit openssh-6.8p1/session.c void session_close(Session *s) { -@@ -2540,6 +2593,10 @@ session_close(Session *s) +@@ -2540,6 +2595,10 @@ session_close(Session *s) debug("session_close: session %d pid %ld", s->self, (long)s->pid); if (s->ttyfd != -1) session_pty_cleanup(s); @@ -1986,7 +2002,7 @@ diff -up openssh-6.8p1/session.c.audit openssh-6.8p1/session.c free(s->term); free(s->display); free(s->x11_chanids); -@@ -2754,6 +2811,15 @@ do_authenticated2(Authctxt *authctxt) +@@ -2754,6 +2813,15 @@ do_authenticated2(Authctxt *authctxt) server_loop2(authctxt); } @@ -2002,16 +2018,16 @@ diff -up openssh-6.8p1/session.c.audit openssh-6.8p1/session.c void do_cleanup(Authctxt *authctxt) { -@@ -2802,5 +2868,5 @@ do_cleanup(Authctxt *authctxt) +@@ -2802,5 +2870,5 @@ do_cleanup(Authctxt *authctxt) * or if running in monitor. */ if (!use_privsep || mm_is_monitor()) - session_destroy_all(session_pty_cleanup2); + session_destroy_all(do_cleanup_one_session); } -diff -up openssh-6.8p1/session.h.audit openssh-6.8p1/session.h ---- openssh-6.8p1/session.h.audit 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/session.h 2015-03-20 13:41:15.097883774 +0100 +diff -up openssh/session.h.audit openssh/session.h +--- openssh/session.h.audit 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/session.h 2015-06-24 11:53:29.786390454 +0200 @@ -61,6 +61,12 @@ struct Session { char *name; char *val; @@ -2036,10 +2052,10 @@ diff -up openssh-6.8p1/session.h.audit openssh-6.8p1/session.h Session *session_by_tty(char *); void session_close(Session *); void do_setusercontext(struct passwd *); -diff -up openssh-6.8p1/sshd.c.audit openssh-6.8p1/sshd.c ---- openssh-6.8p1/sshd.c.audit 2015-03-20 13:41:15.083883796 +0100 -+++ openssh-6.8p1/sshd.c 2015-03-20 13:41:15.110883753 +0100 -@@ -121,6 +124,7 @@ +diff -up openssh/sshd.c.audit openssh/sshd.c +--- openssh/sshd.c.audit 2015-06-24 11:53:29.770390495 +0200 ++++ openssh/sshd.c 2015-06-24 11:53:29.787390451 +0200 +@@ -121,6 +121,7 @@ #endif #include "monitor_wrap.h" #include "roaming.h" @@ -2047,7 +2063,7 @@ diff -up openssh-6.8p1/sshd.c.audit openssh-6.8p1/sshd.c #include "ssh-sandbox.h" #include "version.h" #include "ssherr.h" -@@ -260,7 +264,7 @@ Buffer loginmsg; +@@ -260,7 +261,7 @@ Buffer loginmsg; struct passwd *privsep_pw = NULL; /* Prototypes for various functions defined later in this file. */ @@ -2056,7 +2072,7 @@ diff -up openssh-6.8p1/sshd.c.audit openssh-6.8p1/sshd.c void demote_sensitive_data(void); #ifdef WITH_SSH1 -@@ -281,6 +285,15 @@ close_listen_socks(void) +@@ -281,6 +282,15 @@ close_listen_socks(void) num_listen_socks = -1; } @@ -2072,7 +2088,7 @@ diff -up openssh-6.8p1/sshd.c.audit openssh-6.8p1/sshd.c static void close_startup_pipes(void) { -@@ -560,22 +573,45 @@ sshd_exchange_identification(int sock_in +@@ -560,22 +570,45 @@ sshd_exchange_identification(int sock_in } } @@ -2121,7 +2137,7 @@ diff -up openssh-6.8p1/sshd.c.audit openssh-6.8p1/sshd.c key_free(sensitive_data.host_certificates[i]); sensitive_data.host_certificates[i] = NULL; } -@@ -589,6 +625,8 @@ void +@@ -589,6 +622,8 @@ void demote_sensitive_data(void) { Key *tmp; @@ -2130,7 +2146,7 @@ diff -up openssh-6.8p1/sshd.c.audit openssh-6.8p1/sshd.c int i; if (sensitive_data.server_key) { -@@ -597,13 +635,25 @@ demote_sensitive_data(void) +@@ -597,13 +632,25 @@ demote_sensitive_data(void) sensitive_data.server_key = tmp; } @@ -2156,7 +2172,7 @@ diff -up openssh-6.8p1/sshd.c.audit openssh-6.8p1/sshd.c } /* Certs do not need demotion */ } -@@ -675,7 +725,7 @@ privsep_preauth(Authctxt *authctxt) +@@ -675,7 +722,7 @@ privsep_preauth(Authctxt *authctxt) if (use_privsep == PRIVSEP_ON) box = ssh_sandbox_init(pmonitor); @@ -2165,7 +2181,7 @@ diff -up openssh-6.8p1/sshd.c.audit openssh-6.8p1/sshd.c if (pid == -1) { fatal("fork of unprivileged child failed"); } else if (pid != 0) { -@@ -759,6 +811,12 @@ privsep_postauth(Authctxt *authctxt) +@@ -759,6 +806,12 @@ privsep_postauth(Authctxt *authctxt) else if (pmonitor->m_pid != 0) { verbose("User child is on pid %ld", (long)pmonitor->m_pid); buffer_clear(&loginmsg); @@ -2178,7 +2194,7 @@ diff -up openssh-6.8p1/sshd.c.audit openssh-6.8p1/sshd.c monitor_child_postauth(pmonitor); /* NEVERREACHED */ -@@ -1286,6 +1341,7 @@ server_accept_loop(int *sock_in, int *so +@@ -1288,6 +1341,7 @@ server_accept_loop(int *sock_in, int *so if (received_sigterm) { logit("Received signal %d; terminating.", (int) received_sigterm); @@ -2186,7 +2202,7 @@ diff -up openssh-6.8p1/sshd.c.audit openssh-6.8p1/sshd.c close_listen_socks(); if (options.pid_file != NULL) unlink(options.pid_file); -@@ -2242,6 +2321,7 @@ main(int ac, char **av) +@@ -2251,6 +2305,7 @@ main(int ac, char **av) */ if (use_privsep) { mm_send_keystate(pmonitor); @@ -2194,7 +2210,7 @@ diff -up openssh-6.8p1/sshd.c.audit openssh-6.8p1/sshd.c exit(0); } -@@ -2287,7 +2367,7 @@ main(int ac, char **av) +@@ -2296,7 +2351,7 @@ main(int ac, char **av) privsep_postauth(authctxt); /* the monitor process [priv] will not return */ if (!compat20) @@ -2203,7 +2219,7 @@ diff -up openssh-6.8p1/sshd.c.audit openssh-6.8p1/sshd.c } packet_set_timeout(options.client_alive_interval, -@@ -2301,6 +2381,9 @@ main(int ac, char **av) +@@ -2310,6 +2365,9 @@ main(int ac, char **av) do_authenticated(authctxt); /* The connection has been terminated. */ @@ -2213,7 +2229,7 @@ diff -up openssh-6.8p1/sshd.c.audit openssh-6.8p1/sshd.c packet_get_bytes(&ibytes, &obytes); verbose("Transferred: sent %llu, received %llu bytes", (unsigned long long)obytes, (unsigned long long)ibytes); -@@ -2461,6 +2544,10 @@ do_ssh1_kex(void) +@@ -2470,6 +2528,10 @@ do_ssh1_kex(void) if (cookie[i] != packet_get_char()) packet_disconnect("IP Spoofing check bytes do not match."); @@ -2224,7 +2240,7 @@ diff -up openssh-6.8p1/sshd.c.audit openssh-6.8p1/sshd.c debug("Encryption type: %.200s", cipher_name(cipher_type)); /* Get the encrypted integer. */ -@@ -2520,7 +2607,7 @@ do_ssh1_kex(void) +@@ -2529,7 +2591,7 @@ do_ssh1_kex(void) } /* Destroy the private and public keys. No longer. */ @@ -2233,7 +2249,7 @@ diff -up openssh-6.8p1/sshd.c.audit openssh-6.8p1/sshd.c if (use_privsep) mm_ssh1_session_id(session_id); -@@ -2703,6 +2802,16 @@ do_ssh2_kex(void) +@@ -2712,6 +2774,16 @@ do_ssh2_kex(void) void cleanup_exit(int i) { @@ -2250,7 +2266,7 @@ diff -up openssh-6.8p1/sshd.c.audit openssh-6.8p1/sshd.c if (the_authctxt) { do_cleanup(the_authctxt); if (use_privsep && privsep_is_preauth && -@@ -2714,9 +2823,14 @@ cleanup_exit(int i) +@@ -2723,9 +2795,14 @@ cleanup_exit(int i) pmonitor->m_pid, strerror(errno)); } } @@ -2266,10 +2282,10 @@ diff -up openssh-6.8p1/sshd.c.audit openssh-6.8p1/sshd.c audit_event(SSH_CONNECTION_ABANDON); #endif _exit(i); -diff -up openssh-6.8p1/sshkey.c.audit openssh-6.8p1/sshkey.c ---- openssh-6.8p1/sshkey.c.audit 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/sshkey.c 2015-03-20 13:41:15.111883751 +0100 -@@ -317,6 +319,33 @@ sshkey_type_is_valid_ca(int type) +diff -up openssh/sshkey.c.audit openssh/sshkey.c +--- openssh/sshkey.c.audit 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/sshkey.c 2015-06-24 11:53:29.787390451 +0200 +@@ -317,6 +317,33 @@ sshkey_type_is_valid_ca(int type) } int @@ -2303,9 +2319,9 @@ diff -up openssh-6.8p1/sshkey.c.audit openssh-6.8p1/sshkey.c sshkey_is_cert(const struct sshkey *k) { if (k == NULL) -diff -up openssh-6.8p1/sshkey.h.audit openssh-6.8p1/sshkey.h ---- openssh-6.8p1/sshkey.h.audit 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/sshkey.h 2015-03-20 13:41:15.098883772 +0100 +diff -up openssh/sshkey.h.audit openssh/sshkey.h +--- openssh/sshkey.h.audit 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/sshkey.h 2015-06-24 11:53:29.787390451 +0200 @@ -134,6 +134,7 @@ u_int sshkey_size(const struct sshkey int sshkey_generate(int type, u_int bits, struct sshkey **keyp); int sshkey_from_private(const struct sshkey *, struct sshkey **); @@ -2314,19 +2330,3 @@ diff -up openssh-6.8p1/sshkey.h.audit openssh-6.8p1/sshkey.h int sshkey_is_cert(const struct sshkey *); int sshkey_type_is_cert(int); int sshkey_type_plain(int); -diff -up openssh-6.8p1/sandbox-seccomp-filter.c.audit openssh-6.8p1/sandbox-seccomp-filter.c ---- openssh-6.8p1/sandbox-seccomp-filter.c.audit 2015-03-20 13:41:15.088883788 +0100 -+++ openssh-6.8p1/sandbox-seccomp-filter.c 2015-03-20 13:41:15.097883774 +0100 -@@ -110,6 +110,12 @@ static const struct sock_filter preauth_ - #ifdef __NR_time /* not defined on EABI ARM */ - SC_ALLOW(time), - #endif -+#ifdef SSH_AUDIT_EVENTS -+ SC_ALLOW(getuid), -+#ifdef __NR_getuid32 /* not defined on x86_64 */ -+ SC_ALLOW(getuid32), -+#endif -+#endif - SC_ALLOW(read), - SC_ALLOW(write), - SC_ALLOW(close), diff --git a/openssh-6.7p1-coverity.patch b/openssh-6.7p1-coverity.patch index 35d6eb9..661292e 100644 --- a/openssh-6.7p1-coverity.patch +++ b/openssh-6.7p1-coverity.patch @@ -467,25 +467,3 @@ diff -up openssh-6.8p1/sshkey.c.coverity openssh-6.8p1/sshkey.c #include "match.h" /* openssh private key file format */ -diff --git a/sshd.c b/sshd.c -index 6ff8f6f..2f2fcf8 100644 ---- a/sshd.c -+++ b/sshd.c -@@ -1548,6 +1548,7 @@ main(int ac, char **av) - int keytype; - Authctxt *authctxt; - struct connection_info *connection_info = get_connection_info(0, 0); -+ char *addr = NULL; - - #ifdef HAVE_SECUREWARE - (void)set_auth_parameters(ac, av); -@@ -2261,7 +2262,8 @@ main(int ac, char **av) - /* Log the connection. */ - verbose("Connection from %s port %d on %s port %d", - remote_ip, remote_port, -- get_local_ipaddr(sock_in), get_local_port()); -+ (addr = get_local_ipaddr(sock_in)), get_local_port()); -+ free(addr); - - /* - * We don't want to listen forever unless the other side diff --git a/openssh-6.7p1-debian-restore-tcp-wrappers.patch b/openssh-6.7p1-debian-restore-tcp-wrappers.patch index 63d62a0..a41cf34 100644 --- a/openssh-6.7p1-debian-restore-tcp-wrappers.patch +++ b/openssh-6.7p1-debian-restore-tcp-wrappers.patch @@ -1,7 +1,7 @@ -diff -up openssh-6.8p1/configure.ac.tcp_wrappers openssh-6.8p1/configure.ac ---- openssh-6.8p1/configure.ac.tcp_wrappers 2015-03-18 13:05:57.365071779 +0100 -+++ openssh-6.8p1/configure.ac 2015-03-18 13:05:57.408071673 +0100 -@@ -1440,6 +1440,62 @@ AC_ARG_WITH([skey], +diff -up openssh/configure.ac.tcp_wrappers openssh/configure.ac +--- openssh/configure.ac.tcp_wrappers 2015-06-24 11:41:04.519293694 +0200 ++++ openssh/configure.ac 2015-06-24 11:41:04.556293600 +0200 +@@ -1448,6 +1448,62 @@ AC_ARG_WITH([skey], ] ) @@ -64,7 +64,7 @@ diff -up openssh-6.8p1/configure.ac.tcp_wrappers openssh-6.8p1/configure.ac # Check whether user wants to use ldns LDNS_MSG="no" AC_ARG_WITH(ldns, -@@ -5026,6 +5082,7 @@ echo " KerberosV support +@@ -5034,6 +5090,7 @@ echo " KerberosV support echo " SELinux support: $SELINUX_MSG" echo " Smartcard support: $SCARD_MSG" echo " S/KEY support: $SKEY_MSG" @@ -72,10 +72,10 @@ diff -up openssh-6.8p1/configure.ac.tcp_wrappers openssh-6.8p1/configure.ac echo " MD5 password support: $MD5_MSG" echo " libedit support: $LIBEDIT_MSG" echo " Solaris process contract support: $SPC_MSG" -diff -up openssh-6.8p1/sshd.8.tcp_wrappers openssh-6.8p1/sshd.8 ---- openssh-6.8p1/sshd.8.tcp_wrappers 2015-03-18 13:05:57.377071749 +0100 -+++ openssh-6.8p1/sshd.8 2015-03-18 13:05:57.408071673 +0100 -@@ -858,6 +858,12 @@ the user's home directory becomes access +diff -up openssh/sshd.8.tcp_wrappers openssh/sshd.8 +--- openssh/sshd.8.tcp_wrappers 2015-06-24 11:41:04.527293674 +0200 ++++ openssh/sshd.8 2015-06-24 11:41:04.556293600 +0200 +@@ -860,6 +860,12 @@ the user's home directory becomes access This file should be writable only by the user, and need not be readable by anyone else. .Pp @@ -88,7 +88,7 @@ diff -up openssh-6.8p1/sshd.8.tcp_wrappers openssh-6.8p1/sshd.8 .It Pa /etc/hosts.equiv This file is for host-based authentication (see .Xr ssh 1 ) . -@@ -981,6 +987,7 @@ IPv6 address can be used everywhere wher +@@ -983,6 +989,7 @@ IPv6 address can be used everywhere wher .Xr ssh-keygen 1 , .Xr ssh-keyscan 1 , .Xr chroot 2 , @@ -96,9 +96,9 @@ diff -up openssh-6.8p1/sshd.8.tcp_wrappers openssh-6.8p1/sshd.8 .Xr login.conf 5 , .Xr moduli 5 , .Xr sshd_config 5 , -diff -up openssh-6.8p1/sshd.c.tcp_wrappers openssh-6.8p1/sshd.c ---- openssh-6.8p1/sshd.c.tcp_wrappers 2015-03-18 13:05:57.402071688 +0100 -+++ openssh-6.8p1/sshd.c 2015-03-18 13:06:48.199947136 +0100 +diff -up openssh/sshd.c.tcp_wrappers openssh/sshd.c +--- openssh/sshd.c.tcp_wrappers 2015-06-24 11:41:04.549293618 +0200 ++++ openssh/sshd.c 2015-06-24 11:41:53.331169536 +0200 @@ -125,6 +125,13 @@ #include "version.h" #include "ssherr.h" @@ -113,7 +113,7 @@ diff -up openssh-6.8p1/sshd.c.tcp_wrappers openssh-6.8p1/sshd.c #ifndef O_NOCTTY #define O_NOCTTY 0 #endif -@@ -2150,6 +2157,24 @@ main(int ac, char **av) +@@ -2158,6 +2165,24 @@ main(int ac, char **av) #ifdef SSH_AUDIT_EVENTS audit_connection_from(remote_ip, remote_port); #endif @@ -137,4 +137,4 @@ diff -up openssh-6.8p1/sshd.c.tcp_wrappers openssh-6.8p1/sshd.c +#endif /* LIBWRAP */ /* Log the connection. */ - verbose("Connection from %s port %d on %s port %d", + laddr = get_local_ipaddr(sock_in); diff --git a/openssh-6.7p1-fips.patch b/openssh-6.7p1-fips.patch index e2931f2..9f8b490 100644 --- a/openssh-6.7p1-fips.patch +++ b/openssh-6.7p1-fips.patch @@ -1,63 +1,6 @@ -diff -up openssh-6.8p1/Makefile.in.fips openssh-6.8p1/Makefile.in ---- openssh-6.8p1/Makefile.in.fips 2015-03-19 13:14:22.221212174 +0100 -+++ openssh-6.8p1/Makefile.in 2015-03-19 13:14:22.230212157 +0100 -@@ -168,25 +168,25 @@ libssh.a: $(LIBSSH_OBJS) - $(RANLIB) $@ - - ssh$(EXEEXT): $(LIBCOMPAT) libssh.a $(SSHOBJS) -- $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHLIBS) $(LIBS) $(GSSLIBS) -+ $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(SSHLIBS) $(LIBS) $(GSSLIBS) - - sshd$(EXEEXT): libssh.a $(LIBCOMPAT) $(SSHDOBJS) -- $(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHDLIBS) $(LIBS) $(GSSLIBS) $(K5LIBS) -+ $(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(SSHDLIBS) $(LIBS) $(GSSLIBS) $(K5LIBS) - - scp$(EXEEXT): $(LIBCOMPAT) libssh.a scp.o progressmeter.o - $(LD) -o $@ scp.o progressmeter.o bufaux.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) - - ssh-add$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-add.o -- $(LD) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) -+ $(LD) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS) - - ssh-agent$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-agent.o ssh-pkcs11-client.o -- $(LD) -o $@ ssh-agent.o ssh-pkcs11-client.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) -+ $(LD) -o $@ ssh-agent.o ssh-pkcs11-client.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS) - - ssh-keygen$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keygen.o -- $(LD) -o $@ ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) -+ $(LD) -o $@ ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS) - - ssh-keysign$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keysign.o roaming_dummy.o readconf.o -- $(LD) -o $@ ssh-keysign.o readconf.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) -+ $(LD) -o $@ ssh-keysign.o readconf.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS) - - ssh-pkcs11-helper$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-pkcs11-helper.o ssh-pkcs11.o - $(LD) -o $@ ssh-pkcs11-helper.o ssh-pkcs11.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS) -@@ -204,7 +204,7 @@ ssh-cavs$(EXEEXT): $(LIBCOMPAT) libssh.a - $(LD) -o $@ ssh-cavs.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) - - ssh-keyscan$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keyscan.o roaming_dummy.o -- $(LD) -o $@ ssh-keyscan.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS) -+ $(LD) -o $@ ssh-keyscan.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lfipscheck $(LIBS) - - sftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o sftp-server-main.o - $(LD) -o $@ sftp-server.o sftp-common.o sftp-server-main.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) -diff -up openssh-6.8p1/cipher-ctr.c.fips openssh-6.8p1/cipher-ctr.c ---- openssh-6.8p1/cipher-ctr.c.fips 2015-03-19 13:14:22.155212302 +0100 -+++ openssh-6.8p1/cipher-ctr.c 2015-03-19 13:14:22.230212157 +0100 -@@ -179,7 +179,8 @@ evp_aes_128_ctr(void) - aes_ctr.do_cipher = ssh_aes_ctr; - #ifndef SSH_OLD_EVP - aes_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | -- EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV; -+ EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV | -+ EVP_CIPH_FLAG_FIPS; - #endif - return (&aes_ctr); - } -diff -up openssh-6.8p1/cipher.c.fips openssh-6.8p1/cipher.c ---- openssh-6.8p1/cipher.c.fips 2015-03-19 13:14:22.224212169 +0100 -+++ openssh-6.8p1/cipher.c 2015-03-19 13:14:22.230212157 +0100 +diff -up openssh/cipher.c.fips openssh/cipher.c +--- openssh/cipher.c.fips 2015-06-24 12:00:58.730242500 +0200 ++++ openssh/cipher.c 2015-06-24 12:00:58.737242482 +0200 @@ -39,6 +39,8 @@ #include @@ -130,10 +73,23 @@ diff -up openssh-6.8p1/cipher.c.fips openssh-6.8p1/cipher.c if (strcasecmp(c->name, name) == 0) return c->number; return -1; -diff -up openssh-6.8p1/dh.h.fips openssh-6.8p1/dh.h ---- openssh-6.8p1/dh.h.fips 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/dh.h 2015-03-19 13:14:22.230212157 +0100 -@@ -45,6 +45,7 @@ u_int dh_estimate(int); +diff -up openssh/cipher-ctr.c.fips openssh/cipher-ctr.c +--- openssh/cipher-ctr.c.fips 2015-06-24 12:00:58.669242656 +0200 ++++ openssh/cipher-ctr.c 2015-06-24 12:00:58.736242484 +0200 +@@ -179,7 +179,8 @@ evp_aes_128_ctr(void) + aes_ctr.do_cipher = ssh_aes_ctr; + #ifndef SSH_OLD_EVP + aes_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | +- EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV; ++ EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV | ++ EVP_CIPH_FLAG_FIPS; + #endif + return (&aes_ctr); + } +diff -up openssh/dh.h.fips openssh/dh.h +--- openssh/dh.h.fips 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/dh.h 2015-06-24 12:00:58.737242482 +0200 +@@ -46,6 +46,7 @@ u_int dh_estimate(int); /* Min and max values from RFC4419. */ #define DH_GRP_MIN 1024 @@ -141,9 +97,9 @@ diff -up openssh-6.8p1/dh.h.fips openssh-6.8p1/dh.h #define DH_GRP_MAX 8192 /* -diff -up openssh-6.8p1/entropy.c.fips openssh-6.8p1/entropy.c ---- openssh-6.8p1/entropy.c.fips 2015-03-19 13:14:22.147212317 +0100 -+++ openssh-6.8p1/entropy.c 2015-03-19 13:14:22.230212157 +0100 +diff -up openssh/entropy.c.fips openssh/entropy.c +--- openssh/entropy.c.fips 2015-06-24 12:00:58.662242674 +0200 ++++ openssh/entropy.c 2015-06-24 12:00:58.737242482 +0200 @@ -217,6 +217,9 @@ seed_rng(void) fatal("OpenSSL version mismatch. Built against %lx, you " "have %lx", (u_long)OPENSSL_VERSION_NUMBER, SSLeay()); @@ -154,9 +110,9 @@ diff -up openssh-6.8p1/entropy.c.fips openssh-6.8p1/entropy.c #ifndef OPENSSL_PRNG_ONLY if (RAND_status() == 1) { debug3("RNG is ready, skipping seeding"); -diff -up openssh-6.8p1/kex.c.fips openssh-6.8p1/kex.c ---- openssh-6.8p1/kex.c.fips 2015-03-19 13:14:22.165212282 +0100 -+++ openssh-6.8p1/kex.c 2015-03-19 13:14:22.230212157 +0100 +diff -up openssh/kex.c.fips openssh/kex.c +--- openssh/kex.c.fips 2015-06-24 12:00:58.730242500 +0200 ++++ openssh/kex.c 2015-06-24 12:00:58.737242482 +0200 @@ -35,6 +35,7 @@ #ifdef WITH_OPENSSL @@ -165,7 +121,7 @@ diff -up openssh-6.8p1/kex.c.fips openssh-6.8p1/kex.c #endif #include "ssh2.h" -@@ -107,6 +108,25 @@ static const struct kexalg kexalgs[] = { +@@ -108,6 +109,25 @@ static const struct kexalg kexalgs[] = { { NULL, -1, -1, -1}, }; @@ -191,7 +147,7 @@ diff -up openssh-6.8p1/kex.c.fips openssh-6.8p1/kex.c char * kex_alg_list(char sep) { -@@ -134,7 +154,7 @@ kex_alg_by_name(const char *name) +@@ -135,7 +155,7 @@ kex_alg_by_name(const char *name) { const struct kexalg *k; @@ -200,7 +156,7 @@ diff -up openssh-6.8p1/kex.c.fips openssh-6.8p1/kex.c if (strcmp(k->name, name) == 0) return k; #ifdef GSSAPI -@@ -160,7 +180,10 @@ kex_names_valid(const char *names) +@@ -161,7 +181,10 @@ kex_names_valid(const char *names) for ((p = strsep(&cp, ",")); p && *p != '\0'; (p = strsep(&cp, ","))) { if (kex_alg_by_name(p) == NULL) { @@ -212,54 +168,47 @@ diff -up openssh-6.8p1/kex.c.fips openssh-6.8p1/kex.c free(s); return 0; } -diff -up openssh-6.8p1/kexgexc.c.fips openssh-6.8p1/kexgexc.c ---- openssh-6.8p1/kexgexc.c.fips 2015-03-19 13:14:22.196212223 +0100 -+++ openssh-6.8p1/kexgexc.c 2015-03-19 13:15:11.462117016 +0100 -@@ -28,6 +28,8 @@ +diff -up openssh/kexgexc.c.fips openssh/kexgexc.c +--- openssh/kexgexc.c.fips 2015-06-24 12:00:58.737242482 +0200 ++++ openssh/kexgexc.c 2015-06-24 12:02:26.996015709 +0200 +@@ -28,6 +28,7 @@ #ifdef WITH_OPENSSL +#include -+ + #include #include - #include -@@ -62,7 +64,7 @@ kexgex_client(struct ssh *ssh) +@@ -63,7 +64,7 @@ kexgex_client(struct ssh *ssh) nbits = dh_estimate(kex->dh_need * 8); - kex->min = DH_GRP_MIN; + kex->min = FIPS_mode() ? DH_GRP_MIN_FIPS : DH_GRP_MIN; kex->max = DH_GRP_MAX; + kex->nbits = nbits; + if (datafellows & SSH_BUG_DHGEX_LARGE) +diff -up openssh/kexgexs.c.fips openssh/kexgexs.c +--- openssh/kexgexs.c.fips 2015-06-24 12:00:58.738242479 +0200 ++++ openssh/kexgexs.c 2015-06-24 13:48:23.735320199 +0200 +@@ -81,11 +81,11 @@ input_kex_dh_gex_request(int type, u_int + (r = sshpkt_get_end(ssh)) != 0) + goto out; + kex->nbits = nbits; +- kex->min = min; ++ kex->min = min = FIPS_mode() ? DH_GRP_MIN_FIPS : DH_GRP_MIN; + kex->max = max; +- min = MAX(DH_GRP_MIN, min); ++ min = MAX(FIPS_mode() ? DH_GRP_MIN_FIPS : DH_GRP_MIN, min); + max = MIN(DH_GRP_MAX, max); +- nbits = MAX(DH_GRP_MIN, nbits); ++ nbits = MAX(FIPS_mode() ? DH_GRP_MIN_FIPS : DH_GRP_MIN, nbits); + nbits = MIN(DH_GRP_MAX, nbits); - /* Servers with MAX4096DH need a preferred size (nbits) <= 4096. -diff -up openssh-6.8p1/kexgexs.c.fips openssh-6.8p1/kexgexs.c ---- openssh-6.8p1/kexgexs.c.fips 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/kexgexs.c 2015-03-19 13:14:22.231212155 +0100 -@@ -87,9 +87,9 @@ input_kex_dh_gex_request(int type, u_int - kex->nbits = nbits; - kex->min = min; - kex->max = max; -- min = MAX(DH_GRP_MIN, min); -+ min = MAX(FIPS_mode() ? DH_GRP_MIN_FIPS : DH_GRP_MIN, min); - max = MIN(DH_GRP_MAX, max); -- nbits = MAX(DH_GRP_MIN, nbits); -+ nbits = MAX(FIPS_mode() ? DH_GRP_MIN_FIPS : DH_GRP_MIN, nbits); - nbits = MIN(DH_GRP_MAX, nbits); - break; - case SSH2_MSG_KEX_DH_GEX_REQUEST_OLD: -@@ -99,7 +99,7 @@ input_kex_dh_gex_request(int type, u_int - goto out; - kex->nbits = nbits; - /* unused for old GEX */ -- kex->min = min = DH_GRP_MIN; -+ kex->min = min = FIPS_mode() ? DH_GRP_MIN_FIPS : DH_GRP_MIN; - kex->max = max = DH_GRP_MAX; - break; - default: -diff -up openssh-6.8p1/mac.c.fips openssh-6.8p1/mac.c ---- openssh-6.8p1/mac.c.fips 2015-03-19 13:14:22.224212169 +0100 -+++ openssh-6.8p1/mac.c 2015-03-19 13:14:22.231212155 +0100 + if (kex->max < kex->min || kex->nbits < kex->min || +diff -up openssh/mac.c.fips openssh/mac.c +--- openssh/mac.c.fips 2015-06-24 12:00:58.731242497 +0200 ++++ openssh/mac.c 2015-06-24 12:00:58.738242479 +0200 @@ -27,6 +27,8 @@ #include @@ -321,10 +270,54 @@ diff -up openssh-6.8p1/mac.c.fips openssh-6.8p1/mac.c if (strcmp(name, m->name) != 0) continue; if (mac != NULL) -diff -up openssh-6.8p1/myproposal.h.fips openssh-6.8p1/myproposal.h ---- openssh-6.8p1/myproposal.h.fips 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/myproposal.h 2015-03-19 13:14:22.231212155 +0100 -@@ -140,6 +140,28 @@ +diff -up openssh/Makefile.in.fips openssh/Makefile.in +--- openssh/Makefile.in.fips 2015-06-24 12:00:58.731242497 +0200 ++++ openssh/Makefile.in 2015-06-24 12:00:58.736242484 +0200 +@@ -168,25 +168,25 @@ libssh.a: $(LIBSSH_OBJS) + $(RANLIB) $@ + + ssh$(EXEEXT): $(LIBCOMPAT) libssh.a $(SSHOBJS) +- $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHLIBS) $(LIBS) $(GSSLIBS) ++ $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(SSHLIBS) $(LIBS) $(GSSLIBS) + + sshd$(EXEEXT): libssh.a $(LIBCOMPAT) $(SSHDOBJS) +- $(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHDLIBS) $(LIBS) $(GSSLIBS) $(K5LIBS) ++ $(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(SSHDLIBS) $(LIBS) $(GSSLIBS) $(K5LIBS) + + scp$(EXEEXT): $(LIBCOMPAT) libssh.a scp.o progressmeter.o + $(LD) -o $@ scp.o progressmeter.o bufaux.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) + + ssh-add$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-add.o +- $(LD) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) ++ $(LD) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS) + + ssh-agent$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-agent.o ssh-pkcs11-client.o +- $(LD) -o $@ ssh-agent.o ssh-pkcs11-client.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) ++ $(LD) -o $@ ssh-agent.o ssh-pkcs11-client.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS) + + ssh-keygen$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keygen.o +- $(LD) -o $@ ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) ++ $(LD) -o $@ ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS) + + ssh-keysign$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keysign.o roaming_dummy.o readconf.o +- $(LD) -o $@ ssh-keysign.o readconf.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) ++ $(LD) -o $@ ssh-keysign.o readconf.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS) + + ssh-pkcs11-helper$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-pkcs11-helper.o ssh-pkcs11.o + $(LD) -o $@ ssh-pkcs11-helper.o ssh-pkcs11.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS) +@@ -204,7 +204,7 @@ ssh-cavs$(EXEEXT): $(LIBCOMPAT) libssh.a + $(LD) -o $@ ssh-cavs.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) + + ssh-keyscan$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keyscan.o roaming_dummy.o +- $(LD) -o $@ ssh-keyscan.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS) ++ $(LD) -o $@ ssh-keyscan.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lfipscheck $(LIBS) + + sftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o sftp-server-main.o + $(LD) -o $@ sftp-server.o sftp-common.o sftp-server-main.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) +diff -up openssh/myproposal.h.fips openssh/myproposal.h +--- openssh/myproposal.h.fips 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/myproposal.h 2015-06-24 12:00:58.738242479 +0200 +@@ -143,6 +143,28 @@ "hmac-sha1-96," \ "hmac-md5-96" @@ -353,9 +346,36 @@ diff -up openssh-6.8p1/myproposal.h.fips openssh-6.8p1/myproposal.h #else #define KEX_SERVER_KEX \ -diff -up openssh-6.8p1/ssh.c.fips openssh-6.8p1/ssh.c ---- openssh-6.8p1/ssh.c.fips 2015-03-17 06:49:20.000000000 +0100 -+++ openssh-6.8p1/ssh.c 2015-03-19 13:14:22.232212153 +0100 +diff -up openssh/servconf.c.fips openssh/servconf.c +--- openssh/servconf.c.fips 2015-06-24 12:00:58.726242510 +0200 ++++ openssh/servconf.c 2015-06-24 13:49:40.164085648 +0200 +@@ -2319,8 +2319,10 @@ dump_config(ServerOptions *o) + /* string arguments */ + dump_cfg_string(sPidFile, o->pid_file); + dump_cfg_string(sXAuthLocation, o->xauth_location); +- dump_cfg_string(sCiphers, o->ciphers ? o->ciphers : KEX_SERVER_ENCRYPT); +- dump_cfg_string(sMacs, o->macs ? o->macs : KEX_SERVER_MAC); ++ dump_cfg_string(sCiphers, o->ciphers ? o->ciphers : FIPS_mode() ++ ? KEX_FIPS_ENCRYPT : KEX_SERVER_ENCRYPT); ++ dump_cfg_string(sMacs, o->macs ? o->macs : FIPS_mode() ++ ? KEX_FIPS_MAC : KEX_SERVER_MAC); + dump_cfg_string(sBanner, o->banner != NULL ? o->banner : "none"); + dump_cfg_string(sForceCommand, o->adm_forced_command); + dump_cfg_string(sChrootDirectory, o->chroot_directory); +@@ -2335,8 +2337,8 @@ dump_config(ServerOptions *o) + dump_cfg_string(sAuthorizedPrincipalsCommand, o->authorized_principals_command); + dump_cfg_string(sAuthorizedPrincipalsCommandUser, o->authorized_principals_command_user); + dump_cfg_string(sHostKeyAgent, o->host_key_agent); +- dump_cfg_string(sKexAlgorithms, +- o->kex_algorithms ? o->kex_algorithms : KEX_SERVER_KEX); ++ dump_cfg_string(sKexAlgorithms, o->kex_algorithms ? o->kex_algorithms : ++ FIPS_mode() ? KEX_DEFAULT_KEX_FIPS : KEX_SERVER_KEX); + dump_cfg_string(sHostbasedAcceptedKeyTypes, o->hostbased_key_types ? + o->hostbased_key_types : KEX_DEFAULT_PK_ALG); + dump_cfg_string(sPubkeyAcceptedKeyTypes, o->pubkey_key_types ? +diff -up openssh/ssh.c.fips openssh/ssh.c +--- openssh/ssh.c.fips 2015-06-23 02:34:47.000000000 +0200 ++++ openssh/ssh.c 2015-06-24 12:00:58.738242479 +0200 @@ -75,6 +75,8 @@ #include #include @@ -365,7 +385,7 @@ diff -up openssh-6.8p1/ssh.c.fips openssh-6.8p1/ssh.c #include "openbsd-compat/openssl-compat.h" #include "openbsd-compat/sys-queue.h" -@@ -523,6 +525,14 @@ main(int ac, char **av) +@@ -521,6 +523,14 @@ main(int ac, char **av) sanitise_stdfd(); __progname = ssh_get_progname(av[0]); @@ -380,7 +400,7 @@ diff -up openssh-6.8p1/ssh.c.fips openssh-6.8p1/ssh.c #ifndef HAVE_SETPROCTITLE /* Prepare for later setproctitle emulation */ -@@ -600,6 +610,9 @@ main(int ac, char **av) +@@ -598,6 +608,9 @@ main(int ac, char **av) "ACD:E:F:GI:KL:MNO:PQ:R:S:TVw:W:XYy")) != -1) { switch (opt) { case '1': @@ -390,7 +410,7 @@ diff -up openssh-6.8p1/ssh.c.fips openssh-6.8p1/ssh.c options.protocol = SSH_PROTO_1; break; case '2': -@@ -941,7 +954,6 @@ main(int ac, char **av) +@@ -939,7 +952,6 @@ main(int ac, char **av) host_arg = xstrdup(host); #ifdef WITH_OPENSSL @@ -398,7 +418,7 @@ diff -up openssh-6.8p1/ssh.c.fips openssh-6.8p1/ssh.c ERR_load_crypto_strings(); #endif -@@ -1115,6 +1127,10 @@ main(int ac, char **av) +@@ -1113,6 +1125,10 @@ main(int ac, char **av) seed_rng(); @@ -409,7 +429,7 @@ diff -up openssh-6.8p1/ssh.c.fips openssh-6.8p1/ssh.c if (options.user == NULL) options.user = xstrdup(pw->pw_name); -@@ -1192,6 +1208,12 @@ main(int ac, char **av) +@@ -1190,6 +1206,12 @@ main(int ac, char **av) timeout_ms = options.connection_timeout * 1000; @@ -422,9 +442,9 @@ diff -up openssh-6.8p1/ssh.c.fips openssh-6.8p1/ssh.c /* Open a connection to the remote host. */ if (ssh_connect(host, addrs, &hostaddr, options.port, options.address_family, options.connection_attempts, -diff -up openssh-6.8p1/sshconnect2.c.fips openssh-6.8p1/sshconnect2.c ---- openssh-6.8p1/sshconnect2.c.fips 2015-03-19 13:14:22.188212238 +0100 -+++ openssh-6.8p1/sshconnect2.c 2015-03-19 13:14:22.232212153 +0100 +diff -up openssh/sshconnect2.c.fips openssh/sshconnect2.c +--- openssh/sshconnect2.c.fips 2015-06-24 12:00:58.698242582 +0200 ++++ openssh/sshconnect2.c 2015-06-24 12:00:58.739242477 +0200 @@ -46,6 +46,8 @@ #include #endif @@ -510,9 +530,9 @@ diff -up openssh-6.8p1/sshconnect2.c.fips openssh-6.8p1/sshconnect2.c #ifdef GSSAPI /* If we've got GSSAPI algorithms, then we also support the * 'null' hostkey, as a last resort */ -diff -up openssh-6.8p1/sshd.c.fips openssh-6.8p1/sshd.c ---- openssh-6.8p1/sshd.c.fips 2015-03-19 13:14:22.226212165 +0100 -+++ openssh-6.8p1/sshd.c 2015-03-19 13:14:22.232212153 +0100 +diff -up openssh/sshd.c.fips openssh/sshd.c +--- openssh/sshd.c.fips 2015-06-24 12:00:58.734242489 +0200 ++++ openssh/sshd.c 2015-06-24 12:00:58.739242477 +0200 @@ -66,6 +66,7 @@ #include #include @@ -530,7 +550,7 @@ diff -up openssh-6.8p1/sshd.c.fips openssh-6.8p1/sshd.c #include "openbsd-compat/openssl-compat.h" #endif -@@ -1543,6 +1546,18 @@ main(int ac, char **av) +@@ -1548,6 +1551,18 @@ main(int ac, char **av) #endif __progname = ssh_get_progname(av[0]); @@ -549,7 +569,7 @@ diff -up openssh-6.8p1/sshd.c.fips openssh-6.8p1/sshd.c /* Save argv. Duplicate so setproctitle emulation doesn't clobber it */ saved_argc = ac; rexec_argc = ac; -@@ -1694,7 +1709,7 @@ main(int ac, char **av) +@@ -1700,7 +1715,7 @@ main(int ac, char **av) else closefrom(REEXEC_DEVCRYPTO_RESERVED_FD); @@ -558,7 +578,7 @@ diff -up openssh-6.8p1/sshd.c.fips openssh-6.8p1/sshd.c OpenSSL_add_all_algorithms(); #endif -@@ -1890,6 +1905,10 @@ main(int ac, char **av) +@@ -1901,6 +1916,10 @@ main(int ac, char **av) sshkey_type(pubkey) : sshkey_ssh_name(pubkey), fp); free(fp); } @@ -569,7 +589,7 @@ diff -up openssh-6.8p1/sshd.c.fips openssh-6.8p1/sshd.c if ((options.protocol & SSH_PROTO_1) && !sensitive_data.have_ssh1_key) { logit("Disabling protocol version 1. Could not load host key"); options.protocol &= ~SSH_PROTO_1; -@@ -2058,6 +2077,10 @@ main(int ac, char **av) +@@ -2069,6 +2088,10 @@ main(int ac, char **av) /* Reinitialize the log (because of the fork above). */ log_init(__progname, options.log_level, options.log_facility, log_stderr); @@ -580,7 +600,7 @@ diff -up openssh-6.8p1/sshd.c.fips openssh-6.8p1/sshd.c /* Chdir to the root directory so that the current disk can be unmounted if desired. */ if (chdir("/") == -1) -@@ -2642,6 +2665,9 @@ do_ssh2_kex(void) +@@ -2654,6 +2677,9 @@ do_ssh2_kex(void) if (options.ciphers != NULL) { myproposal[PROPOSAL_ENC_ALGS_CTOS] = myproposal[PROPOSAL_ENC_ALGS_STOC] = options.ciphers; @@ -590,7 +610,7 @@ diff -up openssh-6.8p1/sshd.c.fips openssh-6.8p1/sshd.c } myproposal[PROPOSAL_ENC_ALGS_CTOS] = compat_cipher_proposal(myproposal[PROPOSAL_ENC_ALGS_CTOS]); -@@ -2651,6 +2677,9 @@ do_ssh2_kex(void) +@@ -2663,6 +2689,9 @@ do_ssh2_kex(void) if (options.macs != NULL) { myproposal[PROPOSAL_MAC_ALGS_CTOS] = myproposal[PROPOSAL_MAC_ALGS_STOC] = options.macs; @@ -600,7 +620,7 @@ diff -up openssh-6.8p1/sshd.c.fips openssh-6.8p1/sshd.c } if (options.compression == COMP_NONE) { myproposal[PROPOSAL_COMP_ALGS_CTOS] = -@@ -2661,6 +2690,8 @@ do_ssh2_kex(void) +@@ -2673,6 +2702,8 @@ do_ssh2_kex(void) } if (options.kex_algorithms != NULL) myproposal[PROPOSAL_KEX_ALGS] = options.kex_algorithms; @@ -609,7 +629,7 @@ diff -up openssh-6.8p1/sshd.c.fips openssh-6.8p1/sshd.c myproposal[PROPOSAL_KEX_ALGS] = compat_kex_proposal( myproposal[PROPOSAL_KEX_ALGS]); -@@ -2687,10 +2718,14 @@ do_ssh2_kex(void) +@@ -2699,10 +2730,14 @@ do_ssh2_kex(void) if (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]) == 0) orig = NULL; @@ -628,9 +648,9 @@ diff -up openssh-6.8p1/sshd.c.fips openssh-6.8p1/sshd.c if (gss && orig) xasprintf(&newstr, "%s,%s", gss, orig); -diff -up openssh-6.8p1/sshkey.c.fips openssh-6.8p1/sshkey.c ---- openssh-6.8p1/sshkey.c.fips 2015-03-19 13:14:22.227212163 +0100 -+++ openssh-6.8p1/sshkey.c 2015-03-19 13:14:22.233212151 +0100 +diff -up openssh/sshkey.c.fips openssh/sshkey.c +--- openssh/sshkey.c.fips 2015-06-24 12:00:58.735242487 +0200 ++++ openssh/sshkey.c 2015-06-24 12:00:58.740242474 +0200 @@ -35,6 +35,7 @@ #include #include @@ -639,7 +659,7 @@ diff -up openssh-6.8p1/sshkey.c.fips openssh-6.8p1/sshkey.c #endif #include "crypto_api.h" -@@ -1562,6 +1563,8 @@ rsa_generate_private_key(u_int bits, RSA +@@ -1586,6 +1587,8 @@ rsa_generate_private_key(u_int bits, RSA } if (!BN_set_word(f4, RSA_F4) || !RSA_generate_key_ex(private, bits, f4, NULL)) { @@ -648,30 +668,3 @@ diff -up openssh-6.8p1/sshkey.c.fips openssh-6.8p1/sshkey.c ret = SSH_ERR_LIBCRYPTO_ERROR; goto out; } -diff -up openssh-6.8p1/servconf.c.fips openssh-6.8p1/servconf.c ---- openssh-6.8p1/servconf.c.fips 2015-03-19 13:14:22.210212196 +0100 -+++ openssh-6.8p1/servconf.c 2015-03-19 13:14:22.233212151 +0100 -@@ -2226,8 +2226,10 @@ dump_config(ServerOptions *o) - /* string arguments */ - dump_cfg_string(sPidFile, o->pid_file); - dump_cfg_string(sXAuthLocation, o->xauth_location); -- dump_cfg_string(sCiphers, o->ciphers ? o->ciphers : KEX_SERVER_ENCRYPT); -- dump_cfg_string(sMacs, o->macs ? o->macs : KEX_SERVER_MAC); -+ dump_cfg_string(sCiphers, o->ciphers ? o->ciphers : FIPS_mode() -+ ? KEX_FIPS_ENCRYPT : KEX_SERVER_ENCRYPT); -+ dump_cfg_string(sMacs, o->macs ? o->macs : FIPS_mode() -+ ? KEX_FIPS_MAC : KEX_SERVER_MAC); - dump_cfg_string(sBanner, o->banner != NULL ? o->banner : "none"); - dump_cfg_string(sForceCommand, o->adm_forced_command); - dump_cfg_string(sChrootDirectory, o->chroot_directory); -@@ -2240,8 +2242,8 @@ dump_config(ServerOptions *o) - dump_cfg_string(sAuthorizedKeysCommand, o->authorized_keys_command); - dump_cfg_string(sAuthorizedKeysCommandUser, o->authorized_keys_command_user); - dump_cfg_string(sHostKeyAgent, o->host_key_agent); -- dump_cfg_string(sKexAlgorithms, -- o->kex_algorithms ? o->kex_algorithms : KEX_SERVER_KEX); -+ dump_cfg_string(sKexAlgorithms, o->kex_algorithms ? o->kex_algorithms : -+ FIPS_mode() ? KEX_DEFAULT_KEX_FIPS : KEX_SERVER_KEX); - dump_cfg_string(sHostbasedAcceptedKeyTypes, o->hostbased_key_types ? - o->hostbased_key_types : KEX_DEFAULT_PK_ALG); - dump_cfg_string(sPubkeyAcceptedKeyTypes, o->pubkey_key_types ? diff --git a/openssh-6.7p1-ldap.patch b/openssh-6.7p1-ldap.patch index 2bf49c4..a555579 100644 --- a/openssh-6.7p1-ldap.patch +++ b/openssh-6.7p1-ldap.patch @@ -1742,7 +1742,7 @@ diff -up openssh-6.8p1/ldapconf.c.ldap openssh-6.8p1/ldapconf.c + len = snprintf (options.uri, MAXURILEN, "ldap%s://%s:%d", + (options.ssl == 0) ? "" : "s", options.host, options.port); + options.uri[MAXURILEN - 1] = 0; -+ options.uri = xrealloc (options.uri, len + 1, 1); ++ options.uri = xreallocarray(options.uri, len + 1, 1); + } + if (options.binddn == NULL) + options.binddn = ""; diff --git a/openssh-6.7p1-seccomp-aarch64.patch b/openssh-6.7p1-seccomp-aarch64.patch index 60d88c8..6e8c3b8 100644 --- a/openssh-6.7p1-seccomp-aarch64.patch +++ b/openssh-6.7p1-seccomp-aarch64.patch @@ -1,104 +1,14 @@ -diff --git a/configure.ac b/configure.ac -index 4065d0e..d59ad44 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -764,9 +764,12 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16)) - i*86-*) - seccomp_audit_arch=AUDIT_ARCH_I386 - ;; -- arm*-*) -+ aarch64*-*) -+ seccomp_audit_arch=AUDIT_ARCH_AARCH64 -+ ;; -+ arm*-*) - seccomp_audit_arch=AUDIT_ARCH_ARM -- ;; -+ ;; - esac - if test "x$seccomp_audit_arch" != "x" ; then - AC_MSG_RESULT(["$seccomp_audit_arch"]) -diff --git a/sandbox-seccomp-filter.c b/sandbox-seccomp-filter.c -index 095b04a..52f6810 100644 ---- a/sandbox-seccomp-filter.c -+++ b/sandbox-seccomp-filter.c -@@ -43,6 +43,7 @@ - #include - #include - -+#include - #include - #include - #include -@@ -80,6 +81,17 @@ - BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_ ## _nr, 0, 1), \ - BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW) - -+#define SC_ALLOW_ARG(_nr, _arg_nr, _arg_val) \ -+ BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_ ## _nr, 0, 3), \ -+ /* load first syscall argument */ \ -+ BPF_STMT(BPF_LD+BPF_W+BPF_ABS, \ -+ offsetof(struct seccomp_data, args[(_arg_nr)])), \ -+ BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, (_arg_val), 0, 1), \ -+ BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW), \ -+ /* reload syscall number; all rules expect it in accumulator */ \ -+ BPF_STMT(BPF_LD+BPF_W+BPF_ABS, \ -+ offsetof(struct seccomp_data, nr)) -+ - /* Syscall filtering set for preauth. */ - static const struct sock_filter preauth_insns[] = { - /* Ensure the syscall arch convention is as expected. */ -@@ -90,8 +90,23 @@ static const struct sock_filter preauth_insns[] = { - /* Load the syscall number for checking. */ - BPF_STMT(BPF_LD+BPF_W+BPF_ABS, - offsetof(struct seccomp_data, nr)), -- SC_DENY(open, EACCES), -+#ifdef __NR_stat - SC_DENY(stat, EACCES), -+#endif -+ SC_DENY(openat, EACCES), -+#ifdef __NR_open -+ SC_DENY(open, EACCES), /* not on AArch64 */ -+#endif -+#ifdef __NR_fstat -+ SC_DENY(fstat, EACCES), /* x86_64, Aarch64 */ -+#endif -+#if defined(__NR_stat64) && defined(__NR_fstat64) -+ SC_DENY(stat64, EACCES), /* ix86, arm */ -+ SC_DENY(fstat64, EACCES), -+#endif -+#ifdef __NR_newfstatat -+ SC_DENY(newfstatat, EACCES), /* Aarch64 */ -+#endif - SC_ALLOW(getpid), - SC_ALLOW(gettimeofday), - SC_ALLOW(clock_gettime), -@@ -111,12 +123,19 @@ static const struct sock_filter preauth_insns[] = { - SC_ALLOW(shutdown), - #endif - SC_ALLOW(brk), -+#ifdef __NR_poll /* not on AArch64 */ - SC_ALLOW(poll), -+#endif +diff -up openssh/configure.ac.seccomp openssh/configure.ac +diff -up openssh/sandbox-seccomp-filter.c.seccomp openssh/sandbox-seccomp-filter.c +--- openssh/sandbox-seccomp-filter.c.seccomp 2015-06-24 11:45:44.001581471 +0200 ++++ openssh/sandbox-seccomp-filter.c 2015-06-24 11:51:54.032635297 +0200 +@@ -165,6 +165,9 @@ static const struct sock_filter preauth_ #ifdef __NR__newselect SC_ALLOW(_newselect), - #else -+#ifdef __NR_select /* not on AArch64 */ - SC_ALLOW(select), #endif +#ifdef __NR_pselect6 /* AArch64 */ + SC_ALLOW(pselect6), +#endif -+#endif - SC_ALLOW(madvise), - #ifdef __NR_mmap2 /* EABI ARM only has mmap2() */ - SC_ALLOW(mmap2), -@@ -154,6 +157,9 @@ static const struct sock_filter preauth_insns[] = { - #else - SC_ALLOW(sigprocmask), + #ifdef __NR_poll + SC_ALLOW(poll), #endif -+#ifdef __NR_socketcall -+ SC_ALLOW_ARG(socketcall, 0, SYS_SHUTDOWN), -+#endif - BPF_STMT(BPF_RET+BPF_K, SECCOMP_FILTER_FAIL), - }; - diff --git a/openssh-6.8p1-880575.patch b/openssh-6.8p1-880575.patch deleted file mode 100644 index 9936282..0000000 --- a/openssh-6.8p1-880575.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- openssh-6.8p1/authfile.c.orig 2015-03-26 09:59:06.646924879 +0100 -+++ openssh-6.8p1/authfile.c 2015-03-26 09:59:19.310905998 +0100 -@@ -194,7 +194,7 @@ - error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); - error("Permissions 0%3.3o for '%s' are too open.", - (u_int)st.st_mode & 0777, filename); -- error("It is recommended that your private key files are NOT accessible by others."); -+ error("It is required that your private key files are NOT accessible by others."); - error("This private key will be ignored."); - return SSH_ERR_KEY_BAD_PERMISSIONS; - } diff --git a/openssh-6.8p1-sshdT-output.patch b/openssh-6.8p1-sshdT-output.patch index 0b8408d..7a843e7 100644 --- a/openssh-6.8p1-sshdT-output.patch +++ b/openssh-6.8p1-sshdT-output.patch @@ -1,41 +1,7 @@ -diff -up openssh-6.8p1/servconf.c.sshdt openssh-6.8p1/servconf.c ---- openssh-6.8p1/servconf.c.sshdt 2015-05-28 13:32:55.728821389 +0200 -+++ openssh-6.8p1/servconf.c 2015-05-28 13:34:01.937750270 +0200 -@@ -2118,6 +2118,8 @@ dump_cfg_strarray_oneline(ServerOpCodes - { - u_int i; - -+ if (count <= 0) -+ return; - printf("%s", lookup_opcode_name(code)); - for (i = 0; i < count; i++) - printf(" %s", vals[i]); -@@ -2156,7 +2158,7 @@ dump_config(ServerOptions *o) - - /* integer arguments */ - #ifdef USE_PAM -- dump_cfg_int(sUsePAM, o->use_pam); -+ dump_cfg_fmtint(sUsePAM, o->use_pam); - #endif - dump_cfg_int(sServerKeyBits, o->server_key_bits); - dump_cfg_int(sLoginGraceTime, o->login_grace_time); -@@ -2166,6 +2168,7 @@ dump_config(ServerOptions *o) - dump_cfg_int(sMaxSessions, o->max_sessions); - dump_cfg_int(sClientAliveInterval, o->client_alive_interval); - dump_cfg_int(sClientAliveCountMax, o->client_alive_count_max); -+ dump_cfg_int(sStreamLocalBindMask, o->fwd_opts.streamlocal_bind_mask); - - /* formatted integer arguments */ - dump_cfg_fmtint(sPermitRootLogin, o->permit_root_login); -@@ -2213,6 +2216,7 @@ dump_config(ServerOptions *o) - dump_cfg_fmtint(sShowPatchLevel, o->show_patchlevel); - dump_cfg_fmtint(sUseDNS, o->use_dns); - dump_cfg_fmtint(sAllowTcpForwarding, o->allow_tcp_forwarding); -+ dump_cfg_fmtint(sAllowAgentForwarding, o->allow_agent_forwarding); - dump_cfg_fmtint(sAllowStreamLocalForwarding, o->allow_streamlocal_forwarding); - dump_cfg_fmtint(sUsePrivilegeSeparation, use_privsep); - dump_cfg_fmtint(sFingerprintHash, o->fingerprint_hash); -@@ -2224,14 +2228,15 @@ dump_config(ServerOptions *o) +diff -up openssh/servconf.c.sshdt openssh/servconf.c +--- openssh/servconf.c.sshdt 2015-06-24 11:42:29.041078704 +0200 ++++ openssh/servconf.c 2015-06-24 11:44:39.734745802 +0200 +@@ -2317,7 +2317,7 @@ dump_config(ServerOptions *o) dump_cfg_string(sXAuthLocation, o->xauth_location); dump_cfg_string(sCiphers, o->ciphers ? o->ciphers : KEX_SERVER_ENCRYPT); dump_cfg_string(sMacs, o->macs ? o->macs : KEX_SERVER_MAC); @@ -44,29 +10,10 @@ diff -up openssh-6.8p1/servconf.c.sshdt openssh-6.8p1/servconf.c dump_cfg_string(sForceCommand, o->adm_forced_command); dump_cfg_string(sChrootDirectory, o->chroot_directory); dump_cfg_string(sTrustedUserCAKeys, o->trusted_user_ca_keys); - dump_cfg_string(sRevokedKeys, o->revoked_keys_file); - dump_cfg_string(sAuthorizedPrincipalsFile, - o->authorized_principals_file); -- dump_cfg_string(sVersionAddendum, o->version_addendum); -+ dump_cfg_string(sVersionAddendum, *o->version_addendum == '\0' -+ ? "none" : o->version_addendum); - dump_cfg_string(sAuthorizedKeysCommand, o->authorized_keys_command); - dump_cfg_string(sAuthorizedKeysCommandUser, o->authorized_keys_command_user); - dump_cfg_string(sHostKeyAgent, o->host_key_agent); -@@ -2251,7 +2256,7 @@ dump_config(ServerOptions *o) - o->authorized_keys_files); - dump_cfg_strarray(sHostKeyFile, o->num_host_key_files, - o->host_key_files); -- dump_cfg_strarray(sHostKeyFile, o->num_host_cert_files, -+ dump_cfg_strarray(sHostCertificate, o->num_host_cert_files, - o->host_cert_files); - dump_cfg_strarray(sAllowUsers, o->num_allow_users, o->allow_users); - dump_cfg_strarray(sDenyUsers, o->num_deny_users, o->deny_users); -diff --git a/ssh.1 b/ssh.1 -index cf02526..7fddf46 100644 ---- a/ssh.1 -+++ b/ssh.1 -@@ -441,7 +441,11 @@ For full details of the options listed below, and their possible values, see +diff -up openssh/ssh.1.sshdt openssh/ssh.1 +--- openssh/ssh.1.sshdt 2015-06-24 11:42:19.565102807 +0200 ++++ openssh/ssh.1 2015-06-24 11:42:29.042078701 +0200 +@@ -441,7 +441,11 @@ For full details of the options listed b .It GatewayPorts .It GlobalKnownHostsFile .It GSSAPIAuthentication diff --git a/openssh.spec b/openssh.spec index bf7ab55..47ff189 100644 --- a/openssh.spec +++ b/openssh.spec @@ -65,10 +65,10 @@ %endif # Do not forget to bump pam_ssh_agent_auth release if you rewind the main package release to 1 -%define openssh_ver 6.8p1 -%define openssh_rel 9 +%define openssh_ver 6.9p1 +%define openssh_rel 1 %define pam_ssh_agent_ver 0.9.3 -%define pam_ssh_agent_rel 5 +%define pam_ssh_agent_rel 6 Summary: An open source implementation of SSH protocol versions 1 and 2 Name: openssh @@ -218,8 +218,6 @@ Patch924: openssh-6.7p1-seccomp-aarch64.patch Patch925: openssh-6.7p1-ssh-copy-id-truncated-keys.patch # Add sftp option to force mode of created files (#1191055) Patch926: openssh-6.7p1-sftp-force-permission.patch -# Upstream bug #1878 reintroduced in openssh6.7p1 -Patch927: openssh-6.8p1-880575.patch # Memory problems # https://bugzilla.mindrot.org/show_bug.cgi?id=2401 Patch928: openssh-6.8p1-memory-problems.patch @@ -316,7 +314,7 @@ Requires: openssh = %{version}-%{release} Summary: PAM module for authentication with ssh-agent Group: System Environment/Base Version: %{pam_ssh_agent_ver} -Release: %{pam_ssh_agent_rel}.%{openssh_rel}%{?dist}%{?rescue_rel}.2 +Release: %{pam_ssh_agent_rel}.%{openssh_rel}%{?dist}%{?rescue_rel} License: BSD %description @@ -433,7 +431,7 @@ popd %patch912 -p1 -b .utf8-banner %patch914 -p1 -b .servconf %patch916 -p1 -b .contexts -%patch917 -p1 -b .cisco-dh +#%patch917 -p1 -b .cisco-dh # investigate %patch918 -p1 -b .log-in-chroot %patch919 -p1 -b .scp %patch920 -p1 -b .config @@ -444,7 +442,6 @@ popd %patch924 -p1 -b .seccomp %patch925 -p1 -b .newline %patch926 -p1 -b .sftp-force-mode -%patch927 -p1 -b .bz880575 %patch928 -p1 -b .memory %patch200 -p1 -b .audit