summaryrefslogtreecommitdiff
path: root/auth2.c
diff options
context:
space:
mode:
Diffstat (limited to 'auth2.c')
-rw-r--r--auth2.c43
1 files changed, 31 insertions, 12 deletions
diff --git a/auth2.c b/auth2.c
index 61fd0a738..20584caa9 100644
--- a/auth2.c
+++ b/auth2.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: auth2.c,v 1.89 2002/03/19 14:27:39 markus Exp $"); 26RCSID("$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
286static void 286char *
287userauth_banner(void) 287auth2_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
314static void
315userauth_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)
310done: 330done:
311 if (banner) 331 if (banner)
312 xfree(banner); 332 xfree(banner);
313 close(fd);
314 return; 333 return;
315} 334}
316 335