summaryrefslogtreecommitdiff
path: root/auth-shadow.c
diff options
context:
space:
mode:
authorAlistair Delva <adelva@google.com>2020-08-20 16:14:23 -0700
committerAlistair Delva <adelva@google.com>2020-08-20 16:53:18 -0700
commitd9da10d147d633fdb6ec65e17ff4b8447419d83e (patch)
tree8f93e8fdc2907f141e0924910bfec26669819f0b /auth-shadow.c
parent22246b08952d746a7cc5a292570636cf4277598f (diff)
parentecb2c02d994b3e21994f31a70ff911667c262f1f (diff)
Merge upstream-master into master
Commit ecb2c02d994b3e21994f31a70ff911667c262f1f upstream This nearly (but not quite) corresponds to V_8_3_P1; subsequent cherry-picks will correct this. Bug: 162492243 Change-Id: I3c079d86435b7c25aefff4538dc89a3002b1e25b
Diffstat (limited to 'auth-shadow.c')
-rw-r--r--auth-shadow.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/auth-shadow.c b/auth-shadow.c
index 21909167..c77ee8da 100644
--- a/auth-shadow.c
+++ b/auth-shadow.c
@@ -30,10 +30,10 @@
#include <string.h>
#include <time.h>
-#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 +41,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 +57,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 +71,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 +89,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 +130,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;