diff options
Diffstat (limited to 'auth2.c')
-rw-r--r-- | auth2.c | 43 |
1 files changed, 31 insertions, 12 deletions
@@ -23,7 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | RCSID("$OpenBSD: auth2.c,v 1.89 2002/03/19 14:27:39 markus Exp $"); | 26 | RCSID("$OpenBSD: auth2.c,v 1.90 2002/05/12 23:53:45 djm Exp $"); |
27 | 27 | ||
28 | #include <openssl/evp.h> | 28 | #include <openssl/evp.h> |
29 | 29 | ||
@@ -283,25 +283,45 @@ userauth_finish(Authctxt *authctxt, int authenticated, char *method) | |||
283 | } | 283 | } |
284 | } | 284 | } |
285 | 285 | ||
286 | static void | 286 | char * |
287 | userauth_banner(void) | 287 | auth2_read_banner(void) |
288 | { | 288 | { |
289 | struct stat st; | 289 | struct stat st; |
290 | char *banner = NULL; | 290 | char *banner = NULL; |
291 | off_t len, n; | 291 | off_t len, n; |
292 | int fd; | 292 | int fd; |
293 | 293 | ||
294 | if (options.banner == NULL || (datafellows & SSH_BUG_BANNER)) | 294 | if ((fd = open(options.banner, O_RDONLY)) == -1) |
295 | return; | 295 | return (NULL); |
296 | if ((fd = open(options.banner, O_RDONLY)) < 0) | 296 | if (fstat(fd, &st) == -1) { |
297 | return; | 297 | close(fd); |
298 | if (fstat(fd, &st) < 0) | 298 | return (NULL); |
299 | goto done; | 299 | } |
300 | len = st.st_size; | 300 | len = st.st_size; |
301 | banner = xmalloc(len + 1); | 301 | banner = xmalloc(len + 1); |
302 | if ((n = read(fd, banner, len)) < 0) | 302 | n = atomicio(read, fd, banner, len); |
303 | goto done; | 303 | close(fd); |
304 | |||
305 | if (n != len) { | ||
306 | free(banner); | ||
307 | return (NULL); | ||
308 | } | ||
304 | banner[n] = '\0'; | 309 | banner[n] = '\0'; |
310 | |||
311 | return (banner); | ||
312 | } | ||
313 | |||
314 | static void | ||
315 | userauth_banner(void) | ||
316 | { | ||
317 | char *banner = NULL; | ||
318 | |||
319 | if (options.banner == NULL || (datafellows & SSH_BUG_BANNER)) | ||
320 | return; | ||
321 | |||
322 | if ((banner = PRIVSEP(auth2_read_banner())) == NULL) | ||
323 | goto done; | ||
324 | |||
305 | packet_start(SSH2_MSG_USERAUTH_BANNER); | 325 | packet_start(SSH2_MSG_USERAUTH_BANNER); |
306 | packet_put_cstring(banner); | 326 | packet_put_cstring(banner); |
307 | packet_put_cstring(""); /* language, unused */ | 327 | packet_put_cstring(""); /* language, unused */ |
@@ -310,7 +330,6 @@ userauth_banner(void) | |||
310 | done: | 330 | done: |
311 | if (banner) | 331 | if (banner) |
312 | xfree(banner); | 332 | xfree(banner); |
313 | close(fd); | ||
314 | return; | 333 | return; |
315 | } | 334 | } |
316 | 335 | ||