=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/hostfile.c,v retrieving revision 1.85 retrieving revision 1.86 diff -u -r1.85 -r1.86 --- src/usr.bin/ssh/hostfile.c 2020/10/11 22:13:37 1.85 +++ src/usr.bin/ssh/hostfile.c 2020/10/18 11:32:01 1.86 @@ -1,4 +1,4 @@ -/* $OpenBSD: hostfile.c,v 1.85 2020/10/11 22:13:37 djm Exp $ */ +/* $OpenBSD: hostfile.c,v 1.86 2020/10/18 11:32:01 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -139,12 +139,12 @@ ssh_hmac_init(ctx, salt, len) < 0 || ssh_hmac_update(ctx, host, strlen(host)) < 0 || ssh_hmac_final(ctx, result, sizeof(result))) - fatal("%s: ssh_hmac failed", __func__); + fatal_f("ssh_hmac failed"); ssh_hmac_free(ctx); if (__b64_ntop(salt, len, uu_salt, sizeof(uu_salt)) == -1 || __b64_ntop(result, len, uu_result, sizeof(uu_result)) == -1) - fatal("%s: __b64_ntop failed", __func__); + fatal_f("__b64_ntop failed"); snprintf(encoded, sizeof(encoded), "%s%s%c%s", HASH_MAGIC, uu_salt, HASH_DELIM, uu_result); @@ -244,7 +244,7 @@ return 0; } - debug3("%s: found %skey type %s in file %s:%lu", __func__, + debug3_f("found %skey type %s in file %s:%lu", l->marker == MRK_NONE ? "" : (l->marker == MRK_CA ? "ca " : "revoked "), sshkey_type(l->key), l->path, l->linenum); @@ -277,12 +277,10 @@ if ((r = hostkeys_foreach(path, record_hostkey, &ctx, host, NULL, HKF_WANT_MATCH|HKF_WANT_PARSE_KEY)) != 0) { if (r != SSH_ERR_SYSTEM_ERROR && errno != ENOENT) - debug("%s: hostkeys_foreach failed for %s: %s", - __func__, path, ssh_err(r)); + debug_fr(r, "hostkeys_foreach failed for %s", path); } if (ctx.num_loaded != 0) - debug3("%s: loaded %lu keys from %s", __func__, - ctx.num_loaded, host); + debug3_f("loaded %lu keys from %s", ctx.num_loaded, host); } void @@ -433,7 +431,7 @@ if (store_hash) { if ((hashed_host = host_hash(lhost, NULL, 0)) == NULL) { - error("%s: host_hash failed", __func__); + error_f("host_hash failed"); free(lhost); return 0; } @@ -447,7 +445,7 @@ if ((r = sshkey_write(key, f)) == 0) success = 1; else - error("%s: sshkey_write failed: %s", __func__, ssh_err(r)); + error_fr(r, "sshkey_write"); fputc('\n', f); /* If hashing is enabled, the IP address needs to go on its own line */ if (success && store_hash && ip != NULL) @@ -539,7 +537,7 @@ continue; ctx->match_keys[i] |= l->match; fprintf(ctx->out, "%s\n", l->line); - debug3("%s: %s key already at %s:%ld", __func__, + debug3_f("%s key already at %s:%ld", sshkey_type(l->key), l->path, l->linenum); return 0; } @@ -601,14 +599,14 @@ if ((fd = mkstemp(temp)) == -1) { oerrno = errno; - error("%s: mkstemp: %s", __func__, strerror(oerrno)); + error_f("mkstemp: %s", strerror(oerrno)); r = SSH_ERR_SYSTEM_ERROR; goto fail; } if ((ctx.out = fdopen(fd, "w")) == NULL) { oerrno = errno; close(fd); - error("%s: fdopen: %s", __func__, strerror(oerrno)); + error_f("fdopen: %s", strerror(oerrno)); r = SSH_ERR_SYSTEM_ERROR; goto fail; } @@ -617,7 +615,7 @@ if ((r = hostkeys_foreach(filename, host_delete, &ctx, host, ip, HKF_WANT_PARSE_KEY)) != 0) { oerrno = errno; - error("%s: hostkeys_foreach failed: %s", __func__, ssh_err(r)); + error_fr(r, "hostkeys_foreach"); goto fail; } @@ -669,30 +667,28 @@ /* Backup the original file and replace it with the temporary */ if (unlink(back) == -1 && errno != ENOENT) { oerrno = errno; - error("%s: unlink %.100s: %s", __func__, - back, strerror(errno)); + error_f("unlink %.100s: %s", back, strerror(errno)); r = SSH_ERR_SYSTEM_ERROR; goto fail; } if (link(filename, back) == -1) { oerrno = errno; - error("%s: link %.100s to %.100s: %s", __func__, - filename, back, strerror(errno)); + error_f("link %.100s to %.100s: %s", filename, + back, strerror(errno)); r = SSH_ERR_SYSTEM_ERROR; goto fail; } if (rename(temp, filename) == -1) { oerrno = errno; - error("%s: rename \"%s\" to \"%s\": %s", __func__, - temp, filename, strerror(errno)); + error_f("rename \"%s\" to \"%s\": %s", temp, + filename, strerror(errno)); r = SSH_ERR_SYSTEM_ERROR; goto fail; } } else { /* No changes made; just delete the temporary file */ if (unlink(temp) != 0) - error("%s: unlink \"%s\": %s", __func__, - temp, strerror(errno)); + error_f("unlink \"%s\": %s", temp, strerror(errno)); } /* success */ @@ -749,7 +745,7 @@ if ((f = fopen(path, "r")) == NULL) return SSH_ERR_SYSTEM_ERROR; - debug3("%s: reading file \"%s\"", __func__, path); + debug3_f("reading file \"%s\"", path); while (getline(&line, &linesize, f) != -1) { linenum++; line[strcspn(line, "\n")] = '\0'; @@ -777,8 +773,7 @@ } if ((lineinfo.marker = check_markers(&cp)) == MRK_ERROR) { - verbose("%s: invalid marker at %s:%lu", - __func__, path, linenum); + verbose_f("invalid marker at %s:%lu", path, linenum); if ((options & HKF_WANT_MATCH) == 0) goto bad; continue; @@ -794,8 +789,8 @@ if (host != NULL) { if ((s = match_maybe_hashed(host, lineinfo.hosts, &hashed)) == -1) { - debug2("%s: %s:%ld: bad host hash \"%.32s\"", - __func__, path, linenum, lineinfo.hosts); + debug2_f("%s:%ld: bad host hash \"%.32s\"", + path, linenum, lineinfo.hosts); goto bad; } if (s == 1) { @@ -807,9 +802,9 @@ if (ip != NULL) { if ((s = match_maybe_hashed(ip, lineinfo.hosts, &hashed)) == -1) { - debug2("%s: %s:%ld: bad ip hash " - "\"%.32s\"", __func__, path, - linenum, lineinfo.hosts); + debug2_f("%s:%ld: bad ip hash " + "\"%.32s\"", path, linenum, + lineinfo.hosts); goto bad; } if (s == 1) { @@ -844,7 +839,7 @@ * lines. */ if ((lineinfo.key = sshkey_new(KEY_UNSPEC)) == NULL) { - error("%s: sshkey_new failed", __func__); + error_f("sshkey_new failed"); r = SSH_ERR_ALLOC_FAIL; break; }