version 1.44.2.2, 2003/09/16 21:20:24 |
version 1.45, 2002/11/21 23:03:51 |
|
|
case SSH_CMSG_AUTH_TIS: |
case SSH_CMSG_AUTH_TIS: |
case SSH_CMSG_AUTH_TIS_RESPONSE: |
case SSH_CMSG_AUTH_TIS_RESPONSE: |
return "challenge-response"; |
return "challenge-response"; |
|
#if defined(KRB4) || defined(KRB5) |
|
case SSH_CMSG_AUTH_KERBEROS: |
|
return "kerberos"; |
|
#endif |
} |
} |
snprintf(buf, sizeof buf, "bad-auth-msg-%d", type); |
snprintf(buf, sizeof buf, "bad-auth-msg-%d", type); |
return buf; |
return buf; |
|
|
|
|
/* If the user has no password, accept authentication immediately. */ |
/* If the user has no password, accept authentication immediately. */ |
if (options.password_authentication && |
if (options.password_authentication && |
#ifdef KRB5 |
#if defined(KRB4) || defined(KRB5) |
(!options.kerberos_authentication || options.kerberos_or_local_passwd) && |
(!options.kerberos_authentication || options.kerberos_or_local_passwd) && |
#endif |
#endif |
PRIVSEP(auth_password(authctxt, ""))) { |
PRIVSEP(auth_password(authctxt, ""))) { |
|
|
|
|
/* Process the packet. */ |
/* Process the packet. */ |
switch (type) { |
switch (type) { |
|
|
|
#if defined(KRB4) || defined(KRB5) |
|
case SSH_CMSG_AUTH_KERBEROS: |
|
if (!options.kerberos_authentication) { |
|
verbose("Kerberos authentication disabled."); |
|
} else { |
|
char *kdata = packet_get_string(&dlen); |
|
packet_check_eom(); |
|
|
|
if (kdata[0] == 4) { /* KRB_PROT_VERSION */ |
|
#ifdef KRB4 |
|
KTEXT_ST tkt, reply; |
|
tkt.length = dlen; |
|
if (tkt.length < MAX_KTXT_LEN) |
|
memcpy(tkt.dat, kdata, tkt.length); |
|
|
|
if (PRIVSEP(auth_krb4(authctxt, &tkt, |
|
&client_user, &reply))) { |
|
authenticated = 1; |
|
snprintf(info, sizeof(info), |
|
" tktuser %.100s", |
|
client_user); |
|
|
|
packet_start( |
|
SSH_SMSG_AUTH_KERBEROS_RESPONSE); |
|
packet_put_string((char *) |
|
reply.dat, reply.length); |
|
packet_send(); |
|
packet_write_wait(); |
|
|
|
xfree(client_user); |
|
} |
|
#endif /* KRB4 */ |
|
} else { |
|
#ifdef KRB5 |
|
krb5_data tkt, reply; |
|
tkt.length = dlen; |
|
tkt.data = kdata; |
|
|
|
if (PRIVSEP(auth_krb5(authctxt, &tkt, |
|
&client_user, &reply))) { |
|
authenticated = 1; |
|
snprintf(info, sizeof(info), |
|
" tktuser %.100s", |
|
client_user); |
|
|
|
/* Send response to client */ |
|
packet_start( |
|
SSH_SMSG_AUTH_KERBEROS_RESPONSE); |
|
packet_put_string((char *) |
|
reply.data, reply.length); |
|
packet_send(); |
|
packet_write_wait(); |
|
|
|
if (reply.length) |
|
xfree(reply.data); |
|
xfree(client_user); |
|
} |
|
#endif /* KRB5 */ |
|
} |
|
xfree(kdata); |
|
} |
|
break; |
|
#endif /* KRB4 || KRB5 */ |
|
|
|
#if defined(AFS) || defined(KRB5) |
|
/* XXX - punt on backward compatibility here. */ |
|
case SSH_CMSG_HAVE_KERBEROS_TGT: |
|
packet_send_debug("Kerberos TGT passing disabled before authentication."); |
|
break; |
|
#ifdef AFS |
|
case SSH_CMSG_HAVE_AFS_TOKEN: |
|
packet_send_debug("AFS token passing disabled before authentication."); |
|
break; |
|
#endif /* AFS */ |
|
#endif /* AFS || KRB5 */ |
|
|
|
case SSH_CMSG_AUTH_RHOSTS: |
|
if (!options.rhosts_authentication) { |
|
verbose("Rhosts authentication disabled."); |
|
break; |
|
} |
|
/* |
|
* Get client user name. Note that we just have to |
|
* trust the client; this is one reason why rhosts |
|
* authentication is insecure. (Another is |
|
* IP-spoofing on a local network.) |
|
*/ |
|
client_user = packet_get_string(&ulen); |
|
packet_check_eom(); |
|
|
|
/* Try to authenticate using /etc/hosts.equiv and .rhosts. */ |
|
authenticated = auth_rhosts(pw, client_user); |
|
|
|
snprintf(info, sizeof info, " ruser %.100s", client_user); |
|
xfree(client_user); |
|
break; |
|
|
case SSH_CMSG_AUTH_RHOSTS_RSA: |
case SSH_CMSG_AUTH_RHOSTS_RSA: |
if (!options.rhosts_rsa_authentication) { |
if (!options.rhosts_rsa_authentication) { |
verbose("Rhosts with RSA authentication disabled."); |
verbose("Rhosts with RSA authentication disabled."); |
|
|
debug("rcvd SSH_CMSG_AUTH_TIS_RESPONSE"); |
debug("rcvd SSH_CMSG_AUTH_TIS_RESPONSE"); |
if (options.challenge_response_authentication == 1) { |
if (options.challenge_response_authentication == 1) { |
char *response = packet_get_string(&dlen); |
char *response = packet_get_string(&dlen); |
|
debug("got response '%s'", response); |
packet_check_eom(); |
packet_check_eom(); |
authenticated = verify_response(authctxt, response); |
authenticated = verify_response(authctxt, response); |
memset(response, 'r', dlen); |
memset(response, 'r', dlen); |
|
|
* Any unknown messages will be ignored (and failure |
* Any unknown messages will be ignored (and failure |
* returned) during authentication. |
* returned) during authentication. |
*/ |
*/ |
logit("Unknown message during authentication: type %d", type); |
log("Unknown message during authentication: type %d", type); |
break; |
break; |
} |
} |
#ifdef BSD_AUTH |
#ifdef BSD_AUTH |
|
|
authctxt->user); |
authctxt->user); |
|
|
/* Special handling for root */ |
/* Special handling for root */ |
if (authenticated && authctxt->pw->pw_uid == 0 && |
if (!use_privsep && |
|
authenticated && authctxt->pw->pw_uid == 0 && |
!auth_root_allowed(get_authname(type))) |
!auth_root_allowed(get_authname(type))) |
authenticated = 0; |
authenticated = 0; |
|
|
|
|
if ((style = strchr(user, ':')) != NULL) |
if ((style = strchr(user, ':')) != NULL) |
*style++ = '\0'; |
*style++ = '\0'; |
|
|
|
#ifdef KRB5 |
|
/* XXX - SSH.com Kerberos v5 braindeath. */ |
|
if ((datafellows & SSH_BUG_K5USER) && |
|
options.kerberos_authentication) { |
|
char *p; |
|
if ((p = strchr(user, '@')) != NULL) |
|
*p = '\0'; |
|
} |
|
#endif |
|
|
authctxt = authctxt_new(); |
authctxt = authctxt_new(); |
authctxt->user = user; |
authctxt->user = user; |
authctxt->style = style; |
authctxt->style = style; |
|
|
/* Verify that the user is a valid user. */ |
/* Verify that the user is a valid user. */ |
if ((authctxt->pw = PRIVSEP(getpwnamallow(user))) != NULL) |
if ((authctxt->pw = PRIVSEP(getpwnamallow(user))) != NULL) |
authctxt->valid = 1; |
authctxt->valid = 1; |
else { |
else |
debug("do_authentication: illegal user %s", user); |
debug("do_authentication: illegal user %s", user); |
authctxt->pw = fakepw(); |
|
} |
|
|
|
setproctitle("%s%s", authctxt->pw ? user : "unknown", |
setproctitle("%s%s", authctxt->pw ? user : "unknown", |
use_privsep ? " [net]" : ""); |
use_privsep ? " [net]" : ""); |