summaryrefslogtreecommitdiff
path: root/auth-passwd.c
diff options
context:
space:
mode:
authormarkus@openbsd.org <markus@openbsd.org>2018-07-09 21:26:02 +0000
committerDamien Miller <djm@mindrot.org>2018-07-10 15:21:58 +1000
commit2808d18ca47ad3d251836c555f0e22aaca03d15c (patch)
tree06bc9605dd843d77ee25187637e348369e59cb1d /auth-passwd.c
parent89dd615b8b531979be63f05f9d5624367c9b28e6 (diff)
upstream: sshd: switch loginmsg to sshbuf API; ok djm@
OpenBSD-Commit-ID: f3cb4e54bff15c593602d95cc43e32ee1a4bac42
Diffstat (limited to 'auth-passwd.c')
-rw-r--r--auth-passwd.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/auth-passwd.c b/auth-passwd.c
index 6097fdd24..65f525184 100644
--- a/auth-passwd.c
+++ b/auth-passwd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth-passwd.c,v 1.46 2018/03/03 03:15:51 djm Exp $ */ 1/* $OpenBSD: auth-passwd.c,v 1.47 2018/07/09 21:26:02 markus Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -46,16 +46,17 @@
46#include <stdarg.h> 46#include <stdarg.h>
47 47
48#include "packet.h" 48#include "packet.h"
49#include "buffer.h" 49#include "sshbuf.h"
50#include "ssherr.h"
50#include "log.h" 51#include "log.h"
51#include "misc.h" 52#include "misc.h"
52#include "servconf.h" 53#include "servconf.h"
53#include "key.h" 54#include "sshkey.h"
54#include "hostfile.h" 55#include "hostfile.h"
55#include "auth.h" 56#include "auth.h"
56#include "auth-options.h" 57#include "auth-options.h"
57 58
58extern Buffer loginmsg; 59extern struct sshbuf *loginmsg;
59extern ServerOptions options; 60extern ServerOptions options;
60 61
61#ifdef HAVE_LOGIN_CAP 62#ifdef HAVE_LOGIN_CAP
@@ -131,7 +132,7 @@ auth_password(struct ssh *ssh, const char *password)
131static void 132static void
132warn_expiry(Authctxt *authctxt, auth_session_t *as) 133warn_expiry(Authctxt *authctxt, auth_session_t *as)
133{ 134{
134 char buf[256]; 135 int r;
135 quad_t pwtimeleft, actimeleft, daysleft, pwwarntime, acwarntime; 136 quad_t pwtimeleft, actimeleft, daysleft, pwwarntime, acwarntime;
136 137
137 pwwarntime = acwarntime = TWO_WEEKS; 138 pwwarntime = acwarntime = TWO_WEEKS;
@@ -148,17 +149,17 @@ warn_expiry(Authctxt *authctxt, auth_session_t *as)
148#endif 149#endif
149 if (pwtimeleft != 0 && pwtimeleft < pwwarntime) { 150 if (pwtimeleft != 0 && pwtimeleft < pwwarntime) {
150 daysleft = pwtimeleft / DAY + 1; 151 daysleft = pwtimeleft / DAY + 1;
151 snprintf(buf, sizeof(buf), 152 if ((r = sshbuf_putf(loginmsg,
152 "Your password will expire in %lld day%s.\n", 153 "Your password will expire in %lld day%s.\n",
153 daysleft, daysleft == 1 ? "" : "s"); 154 daysleft, daysleft == 1 ? "" : "s")) != 0)
154 buffer_append(&loginmsg, buf, strlen(buf)); 155 fatal("%s: buffer error: %s", __func__, ssh_err(r));
155 } 156 }
156 if (actimeleft != 0 && actimeleft < acwarntime) { 157 if (actimeleft != 0 && actimeleft < acwarntime) {
157 daysleft = actimeleft / DAY + 1; 158 daysleft = actimeleft / DAY + 1;
158 snprintf(buf, sizeof(buf), 159 if ((r = sshbuf_putf(loginmsg,
159 "Your account will expire in %lld day%s.\n", 160 "Your account will expire in %lld day%s.\n",
160 daysleft, daysleft == 1 ? "" : "s"); 161 daysleft, daysleft == 1 ? "" : "s")) != 0)
161 buffer_append(&loginmsg, buf, strlen(buf)); 162 fatal("%s: buffer error: %s", __func__, ssh_err(r));
162 } 163 }
163} 164}
164 165