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

Function cupsdDefaultAuthType

scheduler/conf.c:401–501  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

399 */
400
401int /* O - Default AuthType value */
402cupsdDefaultAuthType(void)
403{
404#ifdef HAVE_GSSAPI
405 OM_uint32 major_status, /* Major status code */
406 minor_status; /* Minor status code */
407 gss_name_t server_name; /* Server name */
408 gss_buffer_desc token = GSS_C_EMPTY_BUFFER;
409 /* Service name token */
410 char buf[1024]; /* Service name buffer */
411#endif /* HAVE_GSSAPI */
412
413
414 /*
415 * If we have already determined the correct default AuthType, use it...
416 */
417
418 if (default_auth_type != CUPSD_AUTH_AUTO)
419 return (default_auth_type);
420
421#ifdef HAVE_GSSAPI
422# ifdef __APPLE__
423 /*
424 * If the weak-linked GSSAPI/Kerberos library is not present, don't try
425 * to use it...
426 */
427
428 if (&gss_init_sec_context == NULL)
429 return (default_auth_type = CUPSD_AUTH_BASIC);
430# endif /* __APPLE__ */
431
432 /*
433 * Try to obtain the server's GSS credentials (GSSServiceName@servername). If
434 * that fails we must use Basic...
435 */
436
437 snprintf(buf, sizeof(buf), "%s@%s", GSSServiceName, ServerName);
438
439 token.value = buf;
440 token.length = strlen(buf);
441 server_name = GSS_C_NO_NAME;
442 major_status = gss_import_name(&minor_status, &token,
443 GSS_C_NT_HOSTBASED_SERVICE,
444 &server_name);
445
446 memset(&token, 0, sizeof(token));
447
448 if (GSS_ERROR(major_status))
449 {
450 cupsdLogGSSMessage(CUPSD_LOG_DEBUG, major_status, minor_status,
451 "cupsdDefaultAuthType: gss_import_name(%s) failed", buf);
452 return (default_auth_type = CUPSD_AUTH_BASIC);
453 }
454
455 major_status = gss_display_name(&minor_status, server_name, &token, NULL);
456
457 if (GSS_ERROR(major_status))
458 {

Callers 8

auth.cFile · 0.85
cupsdIsAuthorizedFunction · 0.85
cupsdSendHeaderFunction · 0.85
send_http_errorFunction · 0.85
mainFunction · 0.85
cupsdSetPrinterAttrsFunction · 0.85
get_auth_info_requiredFunction · 0.85
cupsdInitCertsFunction · 0.85

Calls 2

cupsdLogGSSMessageFunction · 0.85
cupsdLogMessageFunction · 0.85

Tested by

no test coverage detected