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)
downloadopenssh-git-120a1ec74e8d9d29f4eb9a27972ddd22351ddef9.tar.gz
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 21909167..3d11e5de 100644
--- a/auth-shadow.c
+++ b/auth-shadow.c
@@ -33,7 +33,8 @@
#include "key.h"
#include "hostfile.h"
#include "auth.h"
-#include "buffer.h"
+#include "sshbuf.h"
+#include "ssherr.h"
#include "log.h"
#ifdef DAY
@@ -41,7 +42,7 @@
#endif
#define DAY (24L * 60 * 60) /* 1 day in seconds */
-extern Buffer loginmsg;
+extern struct sshbuf *loginmsg;
/*
* For the account and password expiration functions, we assume the expiry
@@ -57,7 +58,7 @@ auth_shadow_acctexpired(struct spwd *spw)
{
time_t today;
int daysleft;
- char buf[256];
+ int r;
today = time(NULL) / DAY;
daysleft = spw->sp_expire - today;
@@ -71,10 +72,10 @@ auth_shadow_acctexpired(struct spwd *spw)
return 1;
} else if (daysleft <= spw->sp_warn) {
debug3("account will expire in %d days", daysleft);
- snprintf(buf, sizeof(buf),
+ if ((r = sshbuf_putf(loginmsg,
"Your account will expire in %d day%s.\n", daysleft,
- daysleft == 1 ? "" : "s");
- buffer_append(&loginmsg, buf, strlen(buf));
+ daysleft == 1 ? "" : "s")) != 0)
+ fatal("%s: buffer error: %s", __func__, ssh_err(r));
}
return 0;
@@ -89,9 +90,8 @@ auth_shadow_pwexpired(Authctxt *ctxt)
{
struct spwd *spw = NULL;
const char *user = ctxt->pw->pw_name;
- char buf[256];
time_t today;
- int daysleft, disabled = 0;
+ int r, daysleft, disabled = 0;
if ((spw = getspnam((char *)user)) == NULL) {
error("Could not get shadow information for %.100s", user);
@@ -131,10 +131,10 @@ auth_shadow_pwexpired(Authctxt *ctxt)
return 1;
} else if (daysleft <= spw->sp_warn) {
debug3("password will expire in %d days", daysleft);
- snprintf(buf, sizeof(buf),
+ if ((r = sshbuf_putf(loginmsg,
"Your password will expire in %d day%s.\n", daysleft,
- daysleft == 1 ? "" : "s");
- buffer_append(&loginmsg, buf, strlen(buf));
+ daysleft == 1 ? "" : "s")) != 0)
+ fatal("%s: buffer error: %s", __func__, ssh_err(r));
}
return 0;