summaryrefslogtreecommitdiff
path: root/auth-shadow.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2018-07-10 19:39:52 +1000
committerDamien Miller <djm@mindrot.org>2018-07-10 19:39:52 +1000
commit120a1ec74e8d9d29f4eb9a27972ddd22351ddef9 (patch)
tree52308557de781f1d8ffb083369e0c209bc305c02 /auth-shadow.c
parent0f3958c1e6ffb8ea4ba27e2a97a00326fce23246 (diff)
Adapt portable to legacy buffer API removal
Diffstat (limited to 'auth-shadow.c')
-rw-r--r--auth-shadow.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/auth-shadow.c b/auth-shadow.c
index 219091677..3d11e5ded 100644
--- a/auth-shadow.c
+++ b/auth-shadow.c
@@ -33,7 +33,8 @@
33#include "key.h" 33#include "key.h"
34#include "hostfile.h" 34#include "hostfile.h"
35#include "auth.h" 35#include "auth.h"
36#include "buffer.h" 36#include "sshbuf.h"
37#include "ssherr.h"
37#include "log.h" 38#include "log.h"
38 39
39#ifdef DAY 40#ifdef DAY
@@ -41,7 +42,7 @@
41#endif 42#endif
42#define DAY (24L * 60 * 60) /* 1 day in seconds */ 43#define DAY (24L * 60 * 60) /* 1 day in seconds */
43 44
44extern Buffer loginmsg; 45extern struct sshbuf *loginmsg;
45 46
46/* 47/*
47 * For the account and password expiration functions, we assume the expiry 48 * For the account and password expiration functions, we assume the expiry
@@ -57,7 +58,7 @@ auth_shadow_acctexpired(struct spwd *spw)
57{ 58{
58 time_t today; 59 time_t today;
59 int daysleft; 60 int daysleft;
60 char buf[256]; 61 int r;
61 62
62 today = time(NULL) / DAY; 63 today = time(NULL) / DAY;
63 daysleft = spw->sp_expire - today; 64 daysleft = spw->sp_expire - today;
@@ -71,10 +72,10 @@ auth_shadow_acctexpired(struct spwd *spw)
71 return 1; 72 return 1;
72 } else if (daysleft <= spw->sp_warn) { 73 } else if (daysleft <= spw->sp_warn) {
73 debug3("account will expire in %d days", daysleft); 74 debug3("account will expire in %d days", daysleft);
74 snprintf(buf, sizeof(buf), 75 if ((r = sshbuf_putf(loginmsg,
75 "Your account will expire in %d day%s.\n", daysleft, 76 "Your account will expire in %d day%s.\n", daysleft,
76 daysleft == 1 ? "" : "s"); 77 daysleft == 1 ? "" : "s")) != 0)
77 buffer_append(&loginmsg, buf, strlen(buf)); 78 fatal("%s: buffer error: %s", __func__, ssh_err(r));
78 } 79 }
79 80
80 return 0; 81 return 0;
@@ -89,9 +90,8 @@ auth_shadow_pwexpired(Authctxt *ctxt)
89{ 90{
90 struct spwd *spw = NULL; 91 struct spwd *spw = NULL;
91 const char *user = ctxt->pw->pw_name; 92 const char *user = ctxt->pw->pw_name;
92 char buf[256];
93 time_t today; 93 time_t today;
94 int daysleft, disabled = 0; 94 int r, daysleft, disabled = 0;
95 95
96 if ((spw = getspnam((char *)user)) == NULL) { 96 if ((spw = getspnam((char *)user)) == NULL) {
97 error("Could not get shadow information for %.100s", user); 97 error("Could not get shadow information for %.100s", user);
@@ -131,10 +131,10 @@ auth_shadow_pwexpired(Authctxt *ctxt)
131 return 1; 131 return 1;
132 } else if (daysleft <= spw->sp_warn) { 132 } else if (daysleft <= spw->sp_warn) {
133 debug3("password will expire in %d days", daysleft); 133 debug3("password will expire in %d days", daysleft);
134 snprintf(buf, sizeof(buf), 134 if ((r = sshbuf_putf(loginmsg,
135 "Your password will expire in %d day%s.\n", daysleft, 135 "Your password will expire in %d day%s.\n", daysleft,
136 daysleft == 1 ? "" : "s"); 136 daysleft == 1 ? "" : "s")) != 0)
137 buffer_append(&loginmsg, buf, strlen(buf)); 137 fatal("%s: buffer error: %s", __func__, ssh_err(r));
138 } 138 }
139 139
140 return 0; 140 return 0;