| 820 | */ |
| 821 | |
| 822 | static gss_name_t /* O - Server name */ |
| 823 | cups_gss_getname( |
| 824 | http_t *http, /* I - Connection to server */ |
| 825 | const char *service_name) /* I - Service name */ |
| 826 | { |
| 827 | gss_buffer_desc token = GSS_C_EMPTY_BUFFER; |
| 828 | /* Service token */ |
| 829 | OM_uint32 major_status, /* Major status code */ |
| 830 | minor_status; /* Minor status code */ |
| 831 | gss_name_t server_name; /* Server name */ |
| 832 | char buf[1024]; /* Name buffer */ |
| 833 | |
| 834 | |
| 835 | DEBUG_printf(("7cups_gss_getname(http=%p, service_name=\"%s\")", http, |
| 836 | service_name)); |
| 837 | |
| 838 | |
| 839 | /* |
| 840 | * Get the hostname... |
| 841 | */ |
| 842 | |
| 843 | if (!http->gsshost[0]) |
| 844 | { |
| 845 | httpGetHostname(http, http->gsshost, sizeof(http->gsshost)); |
| 846 | |
| 847 | if (!strcmp(http->gsshost, "localhost")) |
| 848 | { |
| 849 | if (gethostname(http->gsshost, sizeof(http->gsshost)) < 0) |
| 850 | { |
| 851 | DEBUG_printf(("1cups_gss_getname: gethostname() failed: %s", |
| 852 | strerror(errno))); |
| 853 | http->gsshost[0] = '\0'; |
| 854 | return (NULL); |
| 855 | } |
| 856 | |
| 857 | if (!strchr(http->gsshost, '.')) |
| 858 | { |
| 859 | /* |
| 860 | * The hostname is not a FQDN, so look it up... |
| 861 | */ |
| 862 | |
| 863 | struct hostent *host; /* Host entry to get FQDN */ |
| 864 | |
| 865 | if ((host = gethostbyname(http->gsshost)) != NULL && host->h_name) |
| 866 | { |
| 867 | /* |
| 868 | * Use the resolved hostname... |
| 869 | */ |
| 870 | |
| 871 | strlcpy(http->gsshost, host->h_name, sizeof(http->gsshost)); |
| 872 | } |
| 873 | else |
| 874 | { |
| 875 | DEBUG_printf(("1cups_gss_getname: gethostbyname(\"%s\") failed.", |
| 876 | http->gsshost)); |
| 877 | http->gsshost[0] = '\0'; |
| 878 | return (NULL); |
| 879 | } |
no test coverage detected