diff options
Diffstat (limited to 'auth.c')
-rw-r--r-- | auth.c | 96 |
1 files changed, 2 insertions, 94 deletions
@@ -396,7 +396,8 @@ auth_root_allowed(struct ssh *ssh, const char *method) | |||
396 | case PERMIT_NO_PASSWD: | 396 | case PERMIT_NO_PASSWD: |
397 | if (strcmp(method, "publickey") == 0 || | 397 | if (strcmp(method, "publickey") == 0 || |
398 | strcmp(method, "hostbased") == 0 || | 398 | strcmp(method, "hostbased") == 0 || |
399 | strcmp(method, "gssapi-with-mic") == 0) | 399 | strcmp(method, "gssapi-with-mic") == 0 || |
400 | strcmp(method, "gssapi-keyex") == 0) | ||
400 | return 1; | 401 | return 1; |
401 | break; | 402 | break; |
402 | case PERMIT_FORCED_ONLY: | 403 | case PERMIT_FORCED_ONLY: |
@@ -729,99 +730,6 @@ fakepw(void) | |||
729 | } | 730 | } |
730 | 731 | ||
731 | /* | 732 | /* |
732 | * Returns the remote DNS hostname as a string. The returned string must not | ||
733 | * be freed. NB. this will usually trigger a DNS query the first time it is | ||
734 | * called. | ||
735 | * This function does additional checks on the hostname to mitigate some | ||
736 | * attacks on legacy rhosts-style authentication. | ||
737 | * XXX is RhostsRSAAuthentication vulnerable to these? | ||
738 | * XXX Can we remove these checks? (or if not, remove RhostsRSAAuthentication?) | ||
739 | */ | ||
740 | |||
741 | static char * | ||
742 | remote_hostname(struct ssh *ssh) | ||
743 | { | ||
744 | struct sockaddr_storage from; | ||
745 | socklen_t fromlen; | ||
746 | struct addrinfo hints, *ai, *aitop; | ||
747 | char name[NI_MAXHOST], ntop2[NI_MAXHOST]; | ||
748 | const char *ntop = ssh_remote_ipaddr(ssh); | ||
749 | |||
750 | /* Get IP address of client. */ | ||
751 | fromlen = sizeof(from); | ||
752 | memset(&from, 0, sizeof(from)); | ||
753 | if (getpeername(ssh_packet_get_connection_in(ssh), | ||
754 | (struct sockaddr *)&from, &fromlen) < 0) { | ||
755 | debug("getpeername failed: %.100s", strerror(errno)); | ||
756 | return strdup(ntop); | ||
757 | } | ||
758 | |||
759 | ipv64_normalise_mapped(&from, &fromlen); | ||
760 | if (from.ss_family == AF_INET6) | ||
761 | fromlen = sizeof(struct sockaddr_in6); | ||
762 | |||
763 | debug3("Trying to reverse map address %.100s.", ntop); | ||
764 | /* Map the IP address to a host name. */ | ||
765 | if (getnameinfo((struct sockaddr *)&from, fromlen, name, sizeof(name), | ||
766 | NULL, 0, NI_NAMEREQD) != 0) { | ||
767 | /* Host name not found. Use ip address. */ | ||
768 | return strdup(ntop); | ||
769 | } | ||
770 | |||
771 | /* | ||
772 | * if reverse lookup result looks like a numeric hostname, | ||
773 | * someone is trying to trick us by PTR record like following: | ||
774 | * 1.1.1.10.in-addr.arpa. IN PTR 2.3.4.5 | ||
775 | */ | ||
776 | memset(&hints, 0, sizeof(hints)); | ||
777 | hints.ai_socktype = SOCK_DGRAM; /*dummy*/ | ||
778 | hints.ai_flags = AI_NUMERICHOST; | ||
779 | if (getaddrinfo(name, NULL, &hints, &ai) == 0) { | ||
780 | logit("Nasty PTR record \"%s\" is set up for %s, ignoring", | ||
781 | name, ntop); | ||
782 | freeaddrinfo(ai); | ||
783 | return strdup(ntop); | ||
784 | } | ||
785 | |||
786 | /* Names are stored in lowercase. */ | ||
787 | lowercase(name); | ||
788 | |||
789 | /* | ||
790 | * Map it back to an IP address and check that the given | ||
791 | * address actually is an address of this host. This is | ||
792 | * necessary because anyone with access to a name server can | ||
793 | * define arbitrary names for an IP address. Mapping from | ||
794 | * name to IP address can be trusted better (but can still be | ||
795 | * fooled if the intruder has access to the name server of | ||
796 | * the domain). | ||
797 | */ | ||
798 | memset(&hints, 0, sizeof(hints)); | ||
799 | hints.ai_family = from.ss_family; | ||
800 | hints.ai_socktype = SOCK_STREAM; | ||
801 | if (getaddrinfo(name, NULL, &hints, &aitop) != 0) { | ||
802 | logit("reverse mapping checking getaddrinfo for %.700s " | ||
803 | "[%s] failed.", name, ntop); | ||
804 | return strdup(ntop); | ||
805 | } | ||
806 | /* Look for the address from the list of addresses. */ | ||
807 | for (ai = aitop; ai; ai = ai->ai_next) { | ||
808 | if (getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop2, | ||
809 | sizeof(ntop2), NULL, 0, NI_NUMERICHOST) == 0 && | ||
810 | (strcmp(ntop, ntop2) == 0)) | ||
811 | break; | ||
812 | } | ||
813 | freeaddrinfo(aitop); | ||
814 | /* If we reached the end of the list, the address was not there. */ | ||
815 | if (ai == NULL) { | ||
816 | /* Address not found for the host name. */ | ||
817 | logit("Address %.100s maps to %.600s, but this does not " | ||
818 | "map back to the address.", ntop, name); | ||
819 | return strdup(ntop); | ||
820 | } | ||
821 | return strdup(name); | ||
822 | } | ||
823 | |||
824 | /* | ||
825 | * Return the canonical name of the host in the other side of the current | 733 | * Return the canonical name of the host in the other side of the current |
826 | * connection. The host name is cached, so it is efficient to call this | 734 | * connection. The host name is cached, so it is efficient to call this |
827 | * several times. | 735 | * several times. |