MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cups_gss_getname

Function cups_gss_getname

cups/auth.c:822–907  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

820 */
821
822static gss_name_t /* O - Server name */
823cups_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 }

Callers 1

auth.cFile · 0.85

Calls 2

httpGetHostnameFunction · 0.85
cups_gss_printfFunction · 0.85

Tested by

no test coverage detected