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