48 |
|
|
49 |
extern char *server_hostname; |
extern char *server_hostname; |
50 |
|
|
|
# include <netdb.h> |
|
|
|
|
51 |
# ifdef HAVE_WINSOCK_H |
# ifdef HAVE_WINSOCK_H |
52 |
# include <winsock.h> |
# include <winsock.h> |
53 |
# endif |
# endif |
585 |
|
|
586 |
|
|
587 |
|
|
588 |
|
/* From GNULIB lib/canon-host.c. */ |
589 |
|
extern char *canon_host (char const *host); |
590 |
|
|
591 |
/* Return true if OTHERHOST resolves to this host in the DNS. |
/* Return true if OTHERHOST resolves to this host in the DNS. |
592 |
* |
* |
593 |
* GLOBALS |
* GLOBALS |
601 |
static inline bool |
static inline bool |
602 |
isThisHost (const char *otherhost) |
isThisHost (const char *otherhost) |
603 |
{ |
{ |
604 |
struct hostent *hinfo; |
char *fqdno; |
605 |
|
char *fqdns; |
606 |
|
bool retval; |
607 |
|
|
608 |
/* As an optimization, check the literal strings before looking up |
/* As an optimization, check the literal strings before looking up |
609 |
* OTHERHOST in the DNS. |
* OTHERHOST in the DNS. |
611 |
if (!strcasecmp (server_hostname, otherhost)) |
if (!strcasecmp (server_hostname, otherhost)) |
612 |
return true; |
return true; |
613 |
|
|
614 |
if (!(hinfo = gethostbyname (otherhost))) |
fqdno = canon_host (otherhost); |
615 |
#ifdef HAVE_HSTRERROR |
if (!fqdno) |
616 |
error (1, 0, "Name lookup failed for `%s': %s", |
error (1, 0, "Name lookup failed for `%s'", otherhost); |
617 |
otherhost, hstrerror (h_errno)); |
fqdns = canon_host (server_hostname); |
618 |
#else |
if (!fqdno) |
619 |
error (1, 0, "Name lookup failed for `%s': h_error=%d", |
error (1, 0, "Name lookup failed for `%s'", server_hostname); |
620 |
otherhost, h_errno); |
|
621 |
#endif |
retval = !strcasecmp (fqdns, fqdno); |
622 |
|
|
623 |
return !strcasecmp (server_hostname, hinfo->h_name); |
free (fqdno); |
624 |
|
free (fqdns); |
625 |
|
return retval; |
626 |
} |
} |
627 |
|
|
628 |
|
|
7442 |
static void |
static void |
7443 |
gserver_authenticate_connection (void) |
gserver_authenticate_connection (void) |
7444 |
{ |
{ |
7445 |
struct hostent *hp; |
char *hn; |
7446 |
gss_buffer_desc tok_in, tok_out; |
gss_buffer_desc tok_in, tok_out; |
7447 |
char buf[1024]; |
char buf[1024]; |
7448 |
char *credbuf; |
char *credbuf; |
7453 |
int nbytes; |
int nbytes; |
7454 |
gss_OID mechid; |
gss_OID mechid; |
7455 |
|
|
7456 |
hp = gethostbyname (server_hostname); |
hn = canon_host (server_hostname); |
7457 |
if (hp == NULL) |
if (hn == NULL) |
7458 |
error (1, 0, "can't get canonical hostname"); |
error (1, 0, "can't get canonical hostname"); |
7459 |
|
|
7460 |
sprintf (buf, "cvs@%s", hp->h_name); |
sprintf (buf, "cvs@%s", hn); |
7461 |
|
free (hn); |
7462 |
tok_in.value = buf; |
tok_in.value = buf; |
7463 |
tok_in.length = strlen (buf); |
tok_in.length = strlen (buf); |
7464 |
|
|