=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/auth2.c,v retrieving revision 1.158 retrieving revision 1.159 diff -u -r1.158 -r1.159 --- src/usr.bin/ssh/auth2.c 2020/03/06 18:16:21 1.158 +++ src/usr.bin/ssh/auth2.c 2020/10/18 11:32:01 1.159 @@ -1,4 +1,4 @@ -/* $OpenBSD: auth2.c,v 1.158 2020/03/06 18:16:21 markus Exp $ */ +/* $OpenBSD: auth2.c,v 1.159 2020/10/18 11:32:01 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -149,7 +149,7 @@ (r = sshpkt_put_cstring(ssh, banner)) != 0 || (r = sshpkt_put_cstring(ssh, "")) != 0 || /* language, unused */ (r = sshpkt_send(ssh)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); + fatal_fr(r, "send packet"); debug("userauth_banner: sent"); done: free(banner); @@ -222,11 +222,11 @@ (void)snprintf(b, sizeof b, "%llu%s", (unsigned long long)options.timing_secret, user); if (ssh_digest_memory(SSH_DIGEST_SHA512, b, strlen(b), hash, len) != 0) - fatal("%s: ssh_digest_memory", __func__); + fatal_f("ssh_digest_memory"); /* 0-4.2 ms of delay */ delay = (double)PEEK_U32(hash) / 1000 / 1000 / 1000 / 1000; freezero(hash, len); - debug3("%s: user specific delay %0.3lfms", __func__, delay/1000); + debug3_f("user specific delay %0.3lfms", delay/1000); return MIN_FAIL_DELAY_SECONDS + delay; } @@ -242,8 +242,8 @@ ts.tv_sec = remain; ts.tv_nsec = (remain - ts.tv_sec) * 1000000000; - debug3("%s: elapsed %0.3lfms, delaying %0.3lfms (requested %0.3lfms)", - __func__, elapsed*1000, remain*1000, req*1000); + debug3_f("elapsed %0.3lfms, delaying %0.3lfms (requested %0.3lfms)", + elapsed*1000, remain*1000, req*1000); nanosleep(&ts, NULL); } @@ -275,8 +275,7 @@ authctxt->pw = PRIVSEP(getpwnamallow(ssh, user)); if (authctxt->pw && strcmp(service, "ssh-connection")==0) { authctxt->valid = 1; - debug2("%s: setting up authctxt for %s", - __func__, user); + debug2_f("setting up authctxt for %s", user); } else { /* Invalid user, fake password information */ authctxt->pw = fakepw(); @@ -374,7 +373,7 @@ if ((r = sshpkt_start(ssh, SSH2_MSG_USERAUTH_SUCCESS)) != 0 || (r = sshpkt_send(ssh)) != 0 || (r = ssh_packet_write_wait(ssh)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); + fatal_fr(r, "send success packet"); /* now we can break out */ authctxt->success = 1; ssh_packet_set_log_preamble(ssh, "user %s", authctxt->user); @@ -386,14 +385,14 @@ if (authctxt->failures >= options.max_authtries) auth_maxtries_exceeded(ssh); methods = authmethods_get(authctxt); - debug3("%s: failure partial=%d next methods=\"%s\"", __func__, + debug3_f("failure partial=%d next methods=\"%s\"", partial, methods); if ((r = sshpkt_start(ssh, SSH2_MSG_USERAUTH_FAILURE)) != 0 || (r = sshpkt_put_cstring(ssh, methods)) != 0 || (r = sshpkt_put_u8(ssh, partial)) != 0 || (r = sshpkt_send(ssh)) != 0 || (r = ssh_packet_write_wait(ssh)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); + fatal_fr(r, "send failure packet"); free(methods); } } @@ -431,7 +430,7 @@ int i, r; if ((b = sshbuf_new()) == NULL) - fatal("%s: sshbuf_new failed", __func__); + fatal_f("sshbuf_new failed"); for (i = 0; authmethods[i] != NULL; i++) { if (strcmp(authmethods[i]->name, "none") == 0) continue; @@ -443,10 +442,10 @@ continue; if ((r = sshbuf_putf(b, "%s%s", sshbuf_len(b) ? "," : "", authmethods[i]->name)) != 0) - fatal("%s: buffer error: %s", __func__, ssh_err(r)); + fatal_fr(r, "buffer error"); } if ((list = sshbuf_dup_string(b)) == NULL) - fatal("%s: sshbuf_dup_string failed", __func__); + fatal_f("sshbuf_dup_string failed"); sshbuf_free(b); return list; } @@ -538,7 +537,7 @@ if (options.num_auth_methods == 0) return 0; - debug3("%s: checking methods", __func__); + debug3_f("checking methods"); authctxt->auth_methods = xcalloc(options.num_auth_methods, sizeof(*authctxt->auth_methods)); authctxt->num_auth_methods = 0; @@ -626,7 +625,7 @@ { u_int i, found = 0; - debug3("%s: updating methods list after \"%s\"", __func__, method); + debug3_f("updating methods list after \"%s\"", method); for (i = 0; i < authctxt->num_auth_methods; i++) { if (!remove_method(&(authctxt->auth_methods[i]), method, submethod)) @@ -641,7 +640,7 @@ } /* This should not happen, but would be bad if it did */ if (!found) - fatal("%s: method not in AuthenticationMethods", __func__); + fatal_f("method not in AuthenticationMethods"); return 0; } @@ -669,7 +668,7 @@ va_end(ap); if (i == -1) - fatal("%s: vasprintf failed", __func__); + fatal_f("vasprintf failed"); } /* @@ -685,7 +684,7 @@ int r; if ((r = sshkey_from_private(key, &dup)) != 0) - fatal("%s: copy key: %s", __func__, ssh_err(r)); + fatal_fr(r, "copy key"); sshkey_free(authctxt->auth_method_key); authctxt->auth_method_key = dup; @@ -694,11 +693,11 @@ /* If authenticated, make sure we don't accept this key again */ if ((r = sshkey_from_private(key, &dup)) != 0) - fatal("%s: copy key: %s", __func__, ssh_err(r)); + fatal_fr(r, "copy key"); if (authctxt->nprev_keys >= INT_MAX || (tmp = recallocarray(authctxt->prev_keys, authctxt->nprev_keys, authctxt->nprev_keys + 1, sizeof(*authctxt->prev_keys))) == NULL) - fatal("%s: reallocarray failed", __func__); + fatal_f("reallocarray failed"); authctxt->prev_keys = tmp; authctxt->prev_keys[authctxt->nprev_keys] = dup; authctxt->nprev_keys++; @@ -716,7 +715,7 @@ if (sshkey_equal_public(key, authctxt->prev_keys[i])) { fp = sshkey_fingerprint(authctxt->prev_keys[i], options.fingerprint_hash, SSH_FP_DEFAULT); - debug3("%s: key already used: %s %s", __func__, + debug3_f("key already used: %s %s", sshkey_type(authctxt->prev_keys[i]), fp == NULL ? "UNKNOWN" : fp); free(fp); @@ -738,35 +737,34 @@ if (authctxt->session_info == NULL) { if ((authctxt->session_info = sshbuf_new()) == NULL) - fatal("%s: sshbuf_new", __func__); + fatal_f("sshbuf_new"); } /* Append method[/submethod] */ if ((r = sshbuf_putf(authctxt->session_info, "%s%s%s", method, submethod == NULL ? "" : "/", submethod == NULL ? "" : submethod)) != 0) - fatal("%s: append method: %s", __func__, ssh_err(r)); + fatal_fr(r, "append method"); /* Append key if present */ if (authctxt->auth_method_key != NULL) { if ((r = sshbuf_put_u8(authctxt->session_info, ' ')) != 0 || (r = sshkey_format_text(authctxt->auth_method_key, authctxt->session_info)) != 0) - fatal("%s: append key: %s", __func__, ssh_err(r)); + fatal_fr(r, "append key"); } if (authctxt->auth_method_info != NULL) { /* Ensure no ambiguity here */ if (strchr(authctxt->auth_method_info, '\n') != NULL) - fatal("%s: auth_method_info contains \\n", __func__); + fatal_f("auth_method_info contains \\n"); if ((r = sshbuf_put_u8(authctxt->session_info, ' ')) != 0 || (r = sshbuf_putf(authctxt->session_info, "%s", authctxt->auth_method_info)) != 0) { - fatal("%s: append method info: %s", - __func__, ssh_err(r)); + fatal_fr(r, "append method info"); } } if ((r = sshbuf_put_u8(authctxt->session_info, '\n')) != 0) - fatal("%s: append: %s", __func__, ssh_err(r)); + fatal_fr(r, "append"); }