pesign/0003-Rename-dprintf-to-dbgp...

665 lines
24 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 11 Mar 2022 12:46:16 -0500
Subject: [PATCH] Rename "dprintf' to "dbgprintf"
stdio defines a dprintf() macro now, so using dprintf() for our debug
printer gets obnoxious warnings. This renames it to dbgprintf().
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/cms_common.c | 73 +++++++++++++++++++++++++++++------------------------
src/cms_pe_common.c | 20 +++++++--------
src/efikeygen.c | 16 ++++++------
src/file_pe.c | 6 +++--
src/password.c | 68 ++++++++++++++++++++++++-------------------------
src/pesign.c | 10 ++++----
src/util.h | 26 +++++++++----------
7 files changed, 114 insertions(+), 105 deletions(-)
diff --git a/src/cms_common.c b/src/cms_common.c
index ca37e6a..86341ca 100644
--- a/src/cms_common.c
+++ b/src/cms_common.c
@@ -333,13 +333,13 @@ void cms_set_pw_data(cms_context *cms, secuPWData *pwdata)
if (!pwdata) {
cms->pwdata.source = PW_SOURCE_INVALID;
- dprintf("pwdata:NULL");
+ dbgprintf("pwdata:NULL");
} else {
memmove(&cms->pwdata, pwdata, sizeof(*pwdata));
- dprintf("pwdata:%p", pwdata);
- dprintf("pwdata->source:%d", pwdata->source);
- dprintf("pwdata->data:%p (\"%s\")", pwdata->data,
- pwdata->data ? pwdata->data : "(null)");
+ dbgprintf("pwdata:%p", pwdata);
+ dbgprintf("pwdata->source:%d", pwdata->source);
+ dbgprintf("pwdata->data:%p (\"%s\")", pwdata->data,
+ pwdata->data ? pwdata->data : "(null)");
}
egress();
@@ -382,7 +382,7 @@ is_valid_cert(CERTCertificate *cert, void *data)
errnum = PORT_GetError();
if (errnum == SEC_ERROR_EXTENSION_NOT_FOUND) {
- dprintf("Got SEC_ERROR_EXTENSION_NOT_FOUND; clearing");
+ dbgprintf("Got SEC_ERROR_EXTENSION_NOT_FOUND; clearing");
PORT_SetError(0);
errnum = 0;
}
@@ -415,7 +415,7 @@ is_valid_cert_without_private_key(CERTCertificate *cert, void *data)
errnum = PORT_GetError();
if (errnum == SEC_ERROR_EXTENSION_NOT_FOUND) {
- dprintf("Got SEC_ERROR_EXTENSION_NOT_FOUND; clearing");
+ dbgprintf("Got SEC_ERROR_EXTENSION_NOT_FOUND; clearing");
PORT_SetError(0);
errnum = 0;
}
@@ -467,23 +467,23 @@ unescape_html_in_place(char *s)
size_t pos = 0;
char *s1;
- dprintf("unescaping pos:%zd sz:%zd \"%s\"", pos, sz, s);
+ dbgprintf("unescaping pos:%zd sz:%zd \"%s\"", pos, sz, s);
do {
s1 = strchrnul(&s[pos], '%');
if (s1[0] == '\0')
break;
- dprintf("s1 is \"%s\"", s1);
+ dbgprintf("s1 is \"%s\"", s1);
if ((size_t)(s1 - s) < (size_t)(sz - 3)) {
int c;
c = (hexchar_to_bin(s1[1]) << 4)
| (hexchar_to_bin(s1[2]) & 0xf);
- dprintf("replacing %%%c%c with 0x%02hhx", s1[1], s1[2], (char)c);
+ dbgprintf("replacing %%%c%c with 0x%02hhx", s1[1], s1[2], (char)c);
s1[0] = c;
memmove(&s1[1], &s1[3], sz - (&s1[3] - s));
sz -= 2;
pos = &s1[1] - s;
- dprintf("new pos:%zd sz:%zd s:\"%s\"", pos, sz, s);
+ dbgprintf("new pos:%zd sz:%zd s:\"%s\"", pos, sz, s);
}
} while (pos < sz);
}
@@ -499,7 +499,7 @@ resolve_pkcs11_token_in_place(char *tokenname)
char c = *cp;
*cp = '\0';
- dprintf("ntn:\"%s\"", ntn);
+ dbgprintf("ntn:\"%s\"", ntn);
if (!strncmp(&ntn[pos], "token=", 6)) {
ntn += 6;
memmove(tokenname, ntn, cp - ntn + 1);
@@ -510,13 +510,13 @@ resolve_pkcs11_token_in_place(char *tokenname)
ntn = cp + (c ? 1 : 0);
}
unescape_html_in_place(tokenname);
- dprintf("token name is \"%s\"", tokenname);
+ dbgprintf("token name is \"%s\"", tokenname);
}
#define resolve_token_name(tn) ({ \
char *s_ = tn; \
if (!strncmp(tn, "pkcs11:", 7)) { \
- dprintf("provided token name is pkcs11 uri; parsing"); \
+ dbgprintf("provided token name is pkcs11 uri; parsing");\
s_ = strdupa(tn+7); \
resolve_pkcs11_token_in_place(s_); \
} \
@@ -528,7 +528,8 @@ unlock_nss_token(cms_context *cms)
{
char *tokenname = resolve_token_name(cms->tokenname);
- dprintf("setting password function to %s", cms->func ? "cms->func" : "SECU_GetModulePassword");
+ dbgprintf("setting password function to %s",
+ cms->func ? "cms->func" : "SECU_GetModulePassword");
PK11_SetPasswordFunc(cms->func ? cms->func : SECU_GetModulePassword);
PK11SlotList *slots = NULL;
@@ -592,7 +593,8 @@ find_certificate(cms_context *cms, int needs_private_key)
return -1;
}
- dprintf("setting password function to %s", cms->func ? "cms->func" : "SECU_GetModulePassword");
+ dbgprintf("setting password function to %s",
+ cms->func ? "cms->func" : "SECU_GetModulePassword");
PK11_SetPasswordFunc(cms->func ? cms->func : SECU_GetModulePassword);
PK11SlotList *slots = NULL;
@@ -610,10 +612,10 @@ find_certificate(cms_context *cms, int needs_private_key)
}
while (psle) {
- dprintf("looking for token \"%s\", got \"%s\"",
- tokenname, PK11_GetTokenName(psle->slot));
+ dbgprintf("looking for token \"%s\", got \"%s\"",
+ tokenname, PK11_GetTokenName(psle->slot));
if (!strcmp(tokenname, PK11_GetTokenName(psle->slot))) {
- dprintf("found token \"%s\"", tokenname);
+ dbgprintf("found token \"%s\"", tokenname);
break;
}
@@ -673,8 +675,9 @@ find_certificate(cms_context *cms, int needs_private_key)
psle->slot, is_valid_cert, &cbd);
errnum = PORT_GetError();
if (errnum)
- dprintf("PK11_TraverseCertsForNicknameInSlot():%s:%s",
- PORT_ErrorToName(errnum), PORT_ErrorToString(errnum));
+ dbgprintf("PK11_TraverseCertsForNicknameInSlot():%s:%s",
+ PORT_ErrorToName(errnum),
+ PORT_ErrorToString(errnum));
} else {
status = PK11_TraverseCertsForNicknameInSlot(&nickname,
psle->slot,
@@ -682,28 +685,30 @@ find_certificate(cms_context *cms, int needs_private_key)
&cbd);
errnum = PORT_GetError();
if (errnum)
- dprintf("PK11_TraverseCertsForNicknameInSlot():%s:%s",
- PORT_ErrorToName(errnum), PORT_ErrorToString(errnum));
+ dbgprintf("PK11_TraverseCertsForNicknameInSlot():%s:%s",
+ PORT_ErrorToName(errnum),
+ PORT_ErrorToString(errnum));
}
- dprintf("status:%d cbd.cert:%p", status, cbd.cert);
+ dbgprintf("status:%d cbd.cert:%p", status, cbd.cert);
if (status == SECSuccess && cbd.cert != NULL) {
if (cms->cert)
CERT_DestroyCertificate(cms->cert);
cms->cert = CERT_DupCertificate(cbd.cert);
} else {
errnum = PORT_GetError();
- dprintf("token traversal %s; cert %sfound:%s:%s",
- status == SECSuccess ? "succeeded" : "failed",
- cbd.cert == NULL ? "not" : "",
- PORT_ErrorToName(errnum), PORT_ErrorToString(errnum));
+ dbgprintf("token traversal %s; cert %sfound:%s:%s",
+ status == SECSuccess ? "succeeded" : "failed",
+ cbd.cert == NULL ? "not" : "",
+ PORT_ErrorToName(errnum),
+ PORT_ErrorToString(errnum));
}
save_port_err() {
- dprintf("Destroying cert list");
+ dbgprintf("Destroying cert list");
CERT_DestroyCertList(certlist);
- dprintf("Destroying slot list element");
+ dbgprintf("Destroying slot list element");
PK11_DestroySlotListElement(slots, &psle);
- dprintf("Destroying slot list");
+ dbgprintf("Destroying slot list");
PK11_FreeSlotList(slots);
cms->psle = NULL;
}
@@ -723,7 +728,8 @@ find_slot_for_token(cms_context *cms, PK11SlotInfo **slot)
char *tokenname = resolve_token_name(cms->tokenname);
- dprintf("setting password function to %s", cms->func ? "cms->func" : "SECU_GetModulePassword");
+ dbgprintf("setting password function to %s",
+ cms->func ? "cms->func" : "SECU_GetModulePassword");
PK11_SetPasswordFunc(cms->func ? cms->func : SECU_GetModulePassword);
PK11SlotList *slots = NULL;
@@ -792,7 +798,8 @@ find_certificate_by_callback(cms_context *cms,
return -1;
}
- dprintf("setting password function to %s", cms->func ? "cms->func" : "SECU_GetModulePassword");
+ dbgprintf("setting password function to %s",
+ cms->func ? "cms->func" : "SECU_GetModulePassword");
PK11_SetPasswordFunc(cms->func ? cms->func : SECU_GetModulePassword);
PK11SlotList *slots = NULL;
diff --git a/src/cms_pe_common.c b/src/cms_pe_common.c
index 3a3921b..fb90ecb 100644
--- a/src/cms_pe_common.c
+++ b/src/cms_pe_common.c
@@ -188,8 +188,8 @@ generate_digest(cms_context *cms, Pe *pe, int padded)
}
if (!check_pointer_and_size(cms, pe, hash_base, hash_size))
cmsgotoerr(error, cms, "PE header is invalid");
- dprintf("beginning of hash");
- dprintf("digesting %tx + %zx", hash_base - map, hash_size);
+ dbgprintf("beginning of hash");
+ dbgprintf("digesting %tx + %zx", hash_base - map, hash_size);
generate_digest_step(cms, hash_base, hash_size);
/* 5. Skip over the image checksum
@@ -209,7 +209,7 @@ generate_digest(cms_context *cms, Pe *pe, int padded)
cmsgotoerr(error, cms, "PE data directory is invalid");
generate_digest_step(cms, hash_base, hash_size);
- dprintf("digesting %tx + %zx", hash_base - map, hash_size);
+ dbgprintf("digesting %tx + %zx", hash_base - map, hash_size);
/* 8. Skip over the crt dir
* 9. Hash everything up to the end of the image header. */
@@ -222,7 +222,7 @@ generate_digest(cms_context *cms, Pe *pe, int padded)
cmsgotoerr(error, cms, "PE relocations table is invalid");
generate_digest_step(cms, hash_base, hash_size);
- dprintf("digesting %tx + %zx", hash_base - map, hash_size);
+ dbgprintf("digesting %tx + %zx", hash_base - map, hash_size);
/* 10. Set SUM_OF_BYTES_HASHED to the size of the header. */
hashed_bytes = pe32opthdr ? pe32opthdr->header_size
@@ -256,16 +256,16 @@ generate_digest(cms_context *cms, Pe *pe, int padded)
char *name = shdrs[i].name;
if (name && name[0] == '/')
name = get_str(cms, pe, name + 1);
- dprintf("section:\"%s\"", name ? name : "(null)");
+ dbgprintf("section:\"%s\"", name ? name : "(null)");
if (name && !strcmp(name, ".vendor_cert")) {
- dprintf("skipping .vendor_cert section");
+ dbgprintf("skipping .vendor_cert section");
hashed_bytes += hash_size;
continue;
}
}
generate_digest_step(cms, hash_base, hash_size);
- dprintf("digesting %tx + %zx", hash_base - map, hash_size);
+ dbgprintf("digesting %tx + %zx", hash_base - map, hash_size);
hashed_bytes += hash_size;
}
@@ -285,15 +285,15 @@ generate_digest(cms_context *cms, Pe *pe, int padded)
memset(tmp_array, '\0', tmp_size);
memcpy(tmp_array, hash_base, hash_size);
generate_digest_step(cms, tmp_array, tmp_size);
- dprintf("digesting %tx + %zx", (ptrdiff_t)tmp_array,
+ dbgprintf("digesting %tx + %zx", (ptrdiff_t)tmp_array,
tmp_size);
} else {
generate_digest_step(cms, hash_base, hash_size);
- dprintf("digesting %tx + %zx", hash_base - map,
+ dbgprintf("digesting %tx + %zx", hash_base - map,
hash_size);
}
}
- dprintf("end of hash");
+ dbgprintf("end of hash");
rc = generate_digest_finish(cms);
if (rc < 0)
diff --git a/src/efikeygen.c b/src/efikeygen.c
index 940fdf5..dd40502 100644
--- a/src/efikeygen.c
+++ b/src/efikeygen.c
@@ -1067,9 +1067,9 @@ int main(int argc, char *argv[])
errno = 0;
timeul = strtoul(not_valid_before, &endptr, 0);
- dprintf("not_valid_before:%lu", timeul);
+ dbgprintf("not_valid_before:%lu", timeul);
if (errno == 0 && endptr && *endptr == 0) {
- dprintf("not_valid_before:%lu", timeul);
+ dbgprintf("not_valid_before:%lu", timeul);
not_before = (PRTime)timeul * PR_USEC_PER_SEC;
} else {
prstatus = PR_ParseTimeString(not_valid_before,
@@ -1078,7 +1078,7 @@ int main(int argc, char *argv[])
"could not parse date \"%s\"",
not_valid_before);
}
- dprintf("not_before:%"PRId64, not_before);
+ dbgprintf("not_before:%"PRId64, not_before);
}
if (not_valid_after) {
@@ -1086,11 +1086,11 @@ int main(int argc, char *argv[])
char *endptr;
errno = 0;
- dprintf("not_valid_after:%s", not_valid_after);
+ dbgprintf("not_valid_after:%s", not_valid_after);
timeul = strtoul(not_valid_after, &endptr, 0);
- dprintf("not_valid_after:%lu", timeul);
+ dbgprintf("not_valid_after:%lu", timeul);
if (errno == 0 && endptr && *endptr == 0) {
- dprintf("not_valid_after:%lu", timeul);
+ dbgprintf("not_valid_after:%lu", timeul);
not_after = (PRTime)timeul * PR_USEC_PER_SEC;
} else {
prstatus = PR_ParseTimeString(not_valid_after, PR_TRUE,
@@ -1102,10 +1102,10 @@ int main(int argc, char *argv[])
} else {
// Mon Jan 19 03:14:07 GMT 2037, aka 0x7fffffff minus 1 year.
time_t time = 0x7ffffffful - 60ul * 60 * 24 * 365;
- dprintf("not_valid_after:%lu", time);
+ dbgprintf("not_valid_after:%lu", time);
not_after = (PRTime)time * PR_USEC_PER_SEC;
}
- dprintf("not_after:%"PRId64, not_after);
+ dbgprintf("not_after:%"PRId64, not_after);
CERTValidity *validity = NULL;
validity = CERT_CreateValidity(not_before, not_after);
diff --git a/src/file_pe.c b/src/file_pe.c
index fa97b89..fed6edb 100644
--- a/src/file_pe.c
+++ b/src/file_pe.c
@@ -264,7 +264,8 @@ pe_handle_action(pesign_context *ctxp, int action, int padding)
/* generate a signature and save it in a separate file */
case EXPORT_SIGNATURE|GENERATE_SIGNATURE:
perr = PORT_GetError();
- dprintf("PORT_GetError():%s:%s", PORT_ErrorToName(perr), PORT_ErrorToString(perr));
+ dbgprintf("PORT_GetError():%s:%s",
+ PORT_ErrorToName(perr), PORT_ErrorToString(perr));
PORT_SetError(0);
rc = find_certificate(ctxp->cms_ctx, 1);
conderrx(rc < 0, 1, "Could not find certificate %s",
@@ -281,7 +282,8 @@ pe_handle_action(pesign_context *ctxp, int action, int padding)
case IMPORT_SIGNATURE|GENERATE_SIGNATURE:
check_inputs(ctxp);
perr = PORT_GetError();
- dprintf("PORT_GetError():%s:%s", PORT_ErrorToName(perr), PORT_ErrorToString(perr));
+ dbgprintf("PORT_GetError():%s:%s",
+ PORT_ErrorToName(perr), PORT_ErrorToString(perr));
rc = find_certificate(ctxp->cms_ctx, 1);
conderrx(rc < 0, 1, "Could not find certificate %s",
ctxp->cms_ctx->certname);
diff --git a/src/password.c b/src/password.c
index 05add9a..18c32ed 100644
--- a/src/password.c
+++ b/src/password.c
@@ -167,7 +167,7 @@ SECU_GetPasswordString(void *arg UNUSED, char *prompt)
char *ret;
ingress();
ret = get_password(stdin, stdout, prompt, NULL);
- dprintf("password:\"%s\"", ret ? ret : "(null)");
+ dbgprintf("password:\"%s\"", ret ? ret : "(null)");
egress();
return ret;
}
@@ -194,7 +194,7 @@ parse_pwfile_line(char *start, struct token_pass *tp)
size_t offset = 0;
span = strspn(line, whitespace_and_eol_chars);
- dprintf("whitespace span is %zd", span);
+ dbgprintf("whitespace span is %zd", span);
if (span == 0 && line[span] == '\0')
return -1;
line += span;
@@ -210,17 +210,17 @@ parse_pwfile_line(char *start, struct token_pass *tp)
offset += escspan + 2;
} while(escspan < span);
span += offset;
- dprintf("non-whitespace span is %zd", span);
+ dbgprintf("non-whitespace span is %zd", span);
if (line[span] == '\0') {
- dprintf("returning %td", (line + span) - start);
+ dbgprintf("returning %td", (line + span) - start);
return (line + span) - start;
}
line[span] = '\0';
line += span + 1;
span = strspn(line, whitespace_and_eol_chars);
- dprintf("whitespace span is %zd", span);
+ dbgprintf("whitespace span is %zd", span);
line += span;
tp->token = tp->pass;
tp->pass = line;
@@ -233,15 +233,15 @@ parse_pwfile_line(char *start, struct token_pass *tp)
offset += escspan + 2;
} while(escspan < span);
span += offset;
- dprintf("non-whitespace span is %zd", span);
+ dbgprintf("non-whitespace span is %zd", span);
if (line[span] != '\0')
line[span++] = '\0';
resolve_escapes(tp->token);
- dprintf("Setting token pass %p to { %p, %p }", tp, tp->token, tp->pass);
- dprintf("token:\"%s\"", tp->token);
- dprintf("pass:\"%s\"", tp->pass);
- dprintf("returning %td", (line + span) - start);
+ dbgprintf("Setting token pass %p to { %p, %p }", tp, tp->token, tp->pass);
+ dbgprintf("token:\"%s\"", tp->token);
+ dbgprintf("pass:\"%s\"", tp->pass);
+ dbgprintf("returning %td", (line + span) - start);
return (line + span) - start;
}
@@ -260,7 +260,7 @@ SECU_FilePasswd(PK11SlotInfo *slot, PRBool retry, void *arg)
char *path;
ingress();
- dprintf("token_name: %s", token_name);
+ dbgprintf("token_name: %s", token_name);
if (cms->pwdata.source != PW_FROMFILEDB) {
cms->log(cms, LOG_ERR,
"Got to %s() but no file is specified.\n",
@@ -289,8 +289,8 @@ SECU_FilePasswd(PK11SlotInfo *slot, PRBool retry, void *arg)
if (rc < 0 || file_len < 1)
goto err_file;
file[file_len-1] = '\0';
- dprintf("file_len:%zd", file_len);
- dprintf("file:\"%s\"", file);
+ dbgprintf("file_len:%zd", file_len);
+ dbgprintf("file:\"%s\"", file);
unbreak_line_continuations(file, file_len);
}
@@ -314,23 +314,23 @@ SECU_FilePasswd(PK11SlotInfo *slot, PRBool retry, void *arg)
#pragma GCC diagnostic pop
span = strspn(start, whitespace_and_eol_chars);
- dprintf("whitespace span is %zd", span);
+ dbgprintf("whitespace span is %zd", span);
start += span;
span = strcspn(start, eol_chars);
- dprintf("non-whitespace span is %zd", span);
+ dbgprintf("non-whitespace span is %zd", span);
c = start[span];
start[span] = '\0';
- dprintf("file:\"%s\"", file);
+ dbgprintf("file:\"%s\"", file);
rc = parse_pwfile_line(start, &phrases[nphrases++]);
- dprintf("parse_pwfile_line returned %d", rc);
+ dbgprintf("parse_pwfile_line returned %d", rc);
if (rc < 0)
goto err_phrases;
if (c != '\0')
span++;
start += span;
- dprintf("start is file[%td] == '\\x%02hhx'", start - file,
+ dbgprintf("start is file[%td] == '\\x%02hhx'", start - file,
start[0]);
}
@@ -359,7 +359,7 @@ err_file:
err_phrases:
xfree(phrases);
err:
- dprintf("ret:\"%s\"", ret ? ret : "(null)");
+ dbgprintf("ret:\"%s\"", ret ? ret : "(null)");
egress();
return ret;
}
@@ -412,10 +412,10 @@ SECU_GetModulePassword(PK11SlotInfo *slot, PRBool retry, void *arg)
ingress();
if (PK11_ProtectedAuthenticationPath(slot)) {
- dprintf("prompting for PW_DEVICE data");
+ dbgprintf("prompting for PW_DEVICE data");
pwdata = &pwxtrn;
} else {
- dprintf("using pwdata from cms");
+ dbgprintf("using pwdata from cms");
pwdata = &cms->pwdata;
}
@@ -423,17 +423,17 @@ SECU_GetModulePassword(PK11SlotInfo *slot, PRBool retry, void *arg)
pwdata->source >= PW_SOURCE_MAX ||
pwdata->orig_source <= PW_SOURCE_INVALID ||
pwdata->orig_source >= PW_SOURCE_MAX) {
- dprintf("pwdata is invalid");
+ dbgprintf("pwdata is invalid");
return NULL;
}
- dprintf("pwdata:%p retry:%d", pwdata, retry);
- dprintf("pwdata->source:%s (%d) orig:%s (%d)",
- pw_source_names[pwdata->source], pwdata->source,
- pw_source_names[pwdata->orig_source], pwdata->orig_source);
- dprintf("pwdata->data:%p (\"%s\")", pwdata->data,
- pwdata->data ? pwdata->data : "(null)");
- dprintf("pwdata->intdata:%ld", pwdata->intdata);
+ dbgprintf("pwdata:%p retry:%d", pwdata, retry);
+ dbgprintf("pwdata->source:%s (%d) orig:%s (%d)",
+ pw_source_names[pwdata->source], pwdata->source,
+ pw_source_names[pwdata->orig_source], pwdata->orig_source);
+ dbgprintf("pwdata->data:%p (\"%s\")", pwdata->data,
+ pwdata->data ? pwdata->data : "(null)");
+ dbgprintf("pwdata->intdata:%ld", pwdata->intdata);
if (retry) {
warnx("Incorrect password/PIN entered.");
@@ -470,7 +470,7 @@ SECU_GetModulePassword(PK11SlotInfo *slot, PRBool retry, void *arg)
case PW_FROMFILEDB:
case PW_DATABASE:
- dprintf("pwdata->source:%s", pw_source_names[pwdata->source]);
+ dbgprintf("pwdata->source:%s", pw_source_names[pwdata->source]);
/* Instead of opening and closing the file every time, get the pw
* once, then keep it in memory (duh).
*/
@@ -480,17 +480,17 @@ SECU_GetModulePassword(PK11SlotInfo *slot, PRBool retry, void *arg)
return pw;
case PW_FROMENV:
- dprintf("pwdata->source:PW_FROMENV");
+ dbgprintf("pwdata->source:PW_FROMENV");
if (!pwdata || !pwdata->data)
break;
pw = get_env(pwdata->data);
- dprintf("env:%s pw:%s", pwdata->data, pw ? pw : "(null)");
+ dbgprintf("env:%s pw:%s", pwdata->data, pw ? pw : "(null)");
pwdata->data = pw;
pwdata->source = PW_PLAINTEXT;
goto PW_PLAINTEXT;
case PW_FROMFILE:
- dprintf("pwdata->source:PW_FROMFILE");
+ dbgprintf("pwdata->source:PW_FROMFILE");
in = fopen(pwdata->data, "r");
if (!in)
return NULL;
@@ -501,7 +501,7 @@ SECU_GetModulePassword(PK11SlotInfo *slot, PRBool retry, void *arg)
goto PW_PLAINTEXT;
case PW_FROMFD:
- dprintf("pwdata->source:PW_FROMFD");
+ dbgprintf("pwdata->source:PW_FROMFD");
rc = pwdata->intdata;
in = fdopen(pwdata->intdata, "r");
if (!in)
diff --git a/src/pesign.c b/src/pesign.c
index c2ff35f..f548d81 100644
--- a/src/pesign.c
+++ b/src/pesign.c
@@ -333,7 +333,7 @@ main(int argc, char *argv[])
while ((rc = poptGetNextOpt(optCon)) > 0) {
switch (rc) {
case POPT_RET_PWDB:
- dprintf("POPT_RET_PWDB:\"%s\"", pwdata.data ? pwdata.data : "(null)");
+ dbgprintf("POPT_RET_PWDB:\"%s\"", pwdata.data ? pwdata.data : "(null)");
if (pwdata.source != PW_SOURCE_INVALID)
errx(1, "only one password/pin method can be used at a time");
if (pwdata.data == NULL)
@@ -346,7 +346,7 @@ main(int argc, char *argv[])
continue;
case POPT_RET_ENV:
- dprintf("POPT_RET_ENV:\"%s\"", pwdata.data ? pwdata.data : "(null)");
+ dbgprintf("POPT_RET_ENV:\"%s\"", pwdata.data ? pwdata.data : "(null)");
if (pwdata.source != PW_SOURCE_INVALID)
errx(1, "only one password/pin method can be used at a time");
if (pwdata.data == NULL)
@@ -359,7 +359,7 @@ main(int argc, char *argv[])
continue;
case POPT_RET_PINFD:
- dprintf("POPT_RET_PINFD:\"%s\"", pwdata.data ? pwdata.data : "(null)");
+ dbgprintf("POPT_RET_PINFD:\"%s\"", pwdata.data ? pwdata.data : "(null)");
if (pwdata.source != PW_SOURCE_INVALID)
errx(1, "only one password/pin method can be used at a time");
if (pwdata.data == NULL)
@@ -373,7 +373,7 @@ main(int argc, char *argv[])
continue;
case POPT_RET_PINFILE:
- dprintf("POPT_RET_PINFILE:\"%s\"", pwdata.data ? pwdata.data : "(null)");
+ dbgprintf("POPT_RET_PINFILE:\"%s\"", pwdata.data ? pwdata.data : "(null)");
if (pwdata.source != PW_SOURCE_INVALID)
errx(1, "only one password/pin method can be used at a time");
if (pwdata.data == NULL)
@@ -387,7 +387,7 @@ main(int argc, char *argv[])
}
}
- dprintf("pwdata.source:%d %schecking for PESIGN_TOKEN_PIN",
+ dbgprintf("pwdata.source:%d %schecking for PESIGN_TOKEN_PIN",
pwdata.source,
pwdata.source == PW_SOURCE_INVALID ? "" : "not ");
if (pwdata.source == PW_SOURCE_INVALID && secure_getenv("PESIGN_TOKEN_PIN")) {
diff --git a/src/util.h b/src/util.h
index ba8c621..6616011 100644
--- a/src/util.h
+++ b/src/util.h
@@ -269,28 +269,28 @@ proxy_fd_mode(int fd, char *infile, mode_t *outmode, size_t *inlength)
extern long verbosity(void);
-#define dprintf_(tv, file, func, line, fmt, args...) ({ \
- struct timeval tv; \
- gettimeofday(&tv, NULL); \
- warnx("%ld.%lu %s:%s():%d: " fmt, \
- tv.tv_sec, tv.tv_usec, \
- file, func, line, ##args); \
+#define dbgprintf_(tv, file, func, line, fmt, args...) ({ \
+ struct timeval tv; \
+ gettimeofday(&tv, NULL); \
+ warnx("%ld.%lu %s:%s():%d: " fmt, \
+ tv.tv_sec, tv.tv_usec, \
+ file, func, line, ##args); \
})
#if defined(PESIGN_DEBUG)
-#define dprintf(fmt, args...) \
- dprintf_(CAT(CAT(CAT(tv_,__COUNTER__),__LINE__),_), \
- __FILE__, __func__, __LINE__ - 2, fmt, ##args)
+#define dbgprintf(fmt, args...) \
+ dbgprintf_(CAT(CAT(CAT(tv_,__COUNTER__),__LINE__),_), \
+ __FILE__, __func__, __LINE__ - 2, fmt, ##args)
#else
-#define dprintf(fmt, args...) ({ \
+#define dbgprintf(fmt, args...) ({ \
if (verbosity() > 1) \
- dprintf_(CAT(CAT(CAT(tv_,__COUNTER__),__LINE__),_), \
+ dbgprintf_(CAT(CAT(CAT(tv_,__COUNTER__),__LINE__),_), \
__FILE__, __func__, __LINE__ - 3, \
fmt, ##args); \
0; \
})
#endif
-#define ingress() dprintf("ingress");
-#define egress() dprintf("egress");
+#define ingress() dbgprintf("ingress");
+#define egress() dbgprintf("egress");
#endif /* PESIGN_UTIL_H */
// vim:fenc=utf-8:tw=75:noet