Skip to content

Commit 8de877b

Browse files
committed
Add more debug printfs.
1 parent d662ec1 commit 8de877b

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

cups/tls-gnutls.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ cupsGetCredentialsInfo(
790790
gnutls_x509_crt_t certs[16]; // Certificates
791791

792792

793-
DEBUG_printf("httpCredentialsString(credentials=%p, buffer=%p, bufsize=" CUPS_LLFMT ")", credentials, buffer, CUPS_LLCAST bufsize);
793+
DEBUG_printf("cupsGetCredentialsInfo(credentials=%p, buffer=%p, bufsize=" CUPS_LLFMT ")", credentials, buffer, CUPS_LLCAST bufsize);
794794

795795
if (buffer)
796796
*buffer = '\0';
@@ -884,6 +884,8 @@ cupsGetCredentialsTrust(
884884
// Per-thread globals
885885

886886

887+
DEBUG_printf("cupsGetCredentialsTrust(path=\"%s\", common_name=\"%s\", credentials=\"%lu bytes...\", require_ca=%s)", path, common_name, (unsigned long)(credentials ? strlen(credentials) : 0), require_ca ? "true" : "false");
888+
887889
// Range check input...
888890
if (!path)
889891
path = http_default_path(defpath, sizeof(defpath));
@@ -898,6 +900,7 @@ cupsGetCredentialsTrust(
898900
if (!gnutls_import_certs(credentials, &num_certs, certs))
899901
{
900902
_cupsSetError(IPP_STATUS_ERROR_CUPS_PKI, _("Unable to import credentials."), true);
903+
DEBUG_printf("1cupsGetCredentialsTrust: Returning %d.", HTTP_TRUST_UNKNOWN);
901904
return (HTTP_TRUST_UNKNOWN);
902905
}
903906

@@ -1014,6 +1017,8 @@ cupsGetCredentialsTrust(
10141017

10151018
gnutls_free_certs(num_certs, certs);
10161019

1020+
DEBUG_printf("1cupsGetCredentialsTrust: Returning %d.", trust);
1021+
10171022
return (trust);
10181023
}
10191024

cups/tls.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,17 +508,27 @@ http_copy_file(const char *path, // I - Directory
508508
struct stat fileinfo; // File information
509509

510510

511+
DEBUG_printf("3http_copy_file(path=\"%s\", common_name=\"%s\", ext=\"%s\")", path, common_name, ext);
512+
511513
if (!common_name)
512514
return (NULL);
513515

514516
if (!path)
515517
path = http_default_path(defpath, sizeof(defpath));
516518

517519
if ((fd = open(http_make_path(filename, sizeof(filename), path, common_name, ext), O_RDONLY)) < 0)
520+
{
521+
DEBUG_printf("4http_copy_file: open() failed: %s", strerror(errno));
518522
return (NULL);
523+
}
519524

520525
if (fstat(fd, &fileinfo))
526+
{
527+
DEBUG_printf("4http_copy_file: fstat() failed: %s", strerror(errno));
521528
goto done;
529+
}
530+
531+
DEBUG_printf("4http_copy_file: st_size=%lu", (unsigned long)fileinfo.st_size);
522532

523533
if (fileinfo.st_size > 65536)
524534
{
@@ -528,12 +538,14 @@ http_copy_file(const char *path, // I - Directory
528538

529539
if ((s = calloc(1, (size_t)fileinfo.st_size + 1)) == NULL)
530540
{
541+
DEBUG_printf("4http_copy_file: calloc() failed: %s", strerror(errno));
531542
close(fd);
532543
return (NULL);
533544
}
534545

535546
if (read(fd, s, (size_t)fileinfo.st_size) < 0)
536547
{
548+
DEBUG_printf("4http_copy_file: read() failed: %s", strerror(errno));
537549
free(s);
538550
s = NULL;
539551
}
@@ -542,6 +554,8 @@ http_copy_file(const char *path, // I - Directory
542554

543555
close(fd);
544556

557+
DEBUG_printf("4http_copy_file: Returning \"%s\"", s);
558+
545559
return (s);
546560
}
547561

@@ -565,7 +579,7 @@ http_default_path(
565579

566580
if (!_cupsDirCreate(buffer, 0700))
567581
{
568-
DEBUG_printf("1http_default_path: Failed to make directory '%s': %s", buffer, strerror(errno));
582+
DEBUG_printf("4http_default_path: Failed to make directory '%s': %s", buffer, strerror(errno));
569583
return (NULL);
570584
}
571585
}
@@ -575,12 +589,12 @@ http_default_path(
575589

576590
if (!_cupsDirCreate(buffer, 0700))
577591
{
578-
DEBUG_printf("1http_default_path: Failed to make directory '%s': %s", buffer, strerror(errno));
592+
DEBUG_printf("4http_default_path: Failed to make directory '%s': %s", buffer, strerror(errno));
579593
return (NULL);
580594
}
581595
}
582596

583-
DEBUG_printf("1http_default_path: Using default path \"%s\".", buffer);
597+
DEBUG_printf("4http_default_path: Using default path \"%s\".", buffer);
584598

585599
return (buffer);
586600
}
@@ -701,6 +715,8 @@ http_make_path(
701715
*bufend = buffer + bufsize - 1; // End of buffer
702716

703717

718+
DEBUG_printf("3http_make_path(buffer=%p, bufsize=%u, dirname=\"%s\", filename=\"%s\", ext=\"%s\")", (void *)buffer, (unsigned)bufsize, dirname, filename, ext);
719+
704720
snprintf(buffer, bufsize, "%s/", dirname);
705721
bufptr = buffer + strlen(buffer);
706722

@@ -719,6 +735,8 @@ http_make_path(
719735

720736
cupsCopyString(bufptr, ext, (size_t)(bufend - bufptr + 1));
721737

738+
DEBUG_printf("4http_make_path: Returning \"%s\".", buffer);
739+
722740
return (buffer);
723741
}
724742

0 commit comments

Comments
 (0)