summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'session.c')
-rw-r--r--session.c42
1 files changed, 14 insertions, 28 deletions
diff --git a/session.c b/session.c
index 7c8fe5faf..99b84394e 100644
--- a/session.c
+++ b/session.c
@@ -33,7 +33,7 @@
33 */ 33 */
34 34
35#include "includes.h" 35#include "includes.h"
36RCSID("$OpenBSD: session.c,v 1.178 2004/07/11 17:48:47 deraadt Exp $"); 36RCSID("$OpenBSD: session.c,v 1.179 2004/07/17 05:31:41 dtucker Exp $");
37 37
38#include "ssh.h" 38#include "ssh.h"
39#include "ssh1.h" 39#include "ssh1.h"
@@ -196,12 +196,11 @@ auth_input_request_forwarding(struct passwd * pw)
196static void 196static void
197display_loginmsg(void) 197display_loginmsg(void)
198{ 198{
199 if (buffer_len(&loginmsg) > 0) { 199 if (buffer_len(&loginmsg) > 0) {
200 buffer_append(&loginmsg, "\0", 1); 200 buffer_append(&loginmsg, "\0", 1);
201 printf("%s\n", (char *)buffer_ptr(&loginmsg)); 201 printf("%s", (char *)buffer_ptr(&loginmsg));
202 buffer_clear(&loginmsg); 202 buffer_clear(&loginmsg);
203 } 203 }
204 fflush(stdout);
205} 204}
206 205
207void 206void
@@ -676,14 +675,19 @@ do_exec(Session *s, const char *command)
676 do_exec_no_pty(s, command); 675 do_exec_no_pty(s, command);
677 676
678 original_command = NULL; 677 original_command = NULL;
679}
680 678
679 /*
680 * Clear loginmsg: it's the child's responsibility to display
681 * it to the user, otherwise multiple sessions may accumulate
682 * multiple copies of the login messages.
683 */
684 buffer_clear(&loginmsg);
685}
681 686
682/* administrative, login(1)-like work */ 687/* administrative, login(1)-like work */
683void 688void
684do_login(Session *s, const char *command) 689do_login(Session *s, const char *command)
685{ 690{
686 char *time_string;
687 socklen_t fromlen; 691 socklen_t fromlen;
688 struct sockaddr_storage from; 692 struct sockaddr_storage from;
689 struct passwd * pw = s->pw; 693 struct passwd * pw = s->pw;
@@ -728,19 +732,6 @@ do_login(Session *s, const char *command)
728 732
729 display_loginmsg(); 733 display_loginmsg();
730 734
731#ifndef NO_SSH_LASTLOG
732 if (options.print_lastlog && s->last_login_time != 0) {
733 time_string = ctime(&s->last_login_time);
734 if (strchr(time_string, '\n'))
735 *strchr(time_string, '\n') = 0;
736 if (strcmp(s->hostname, "") == 0)
737 printf("Last login: %s\r\n", time_string);
738 else
739 printf("Last login: %s from %s\r\n", time_string,
740 s->hostname);
741 }
742#endif /* NO_SSH_LASTLOG */
743
744 do_motd(); 735 do_motd();
745} 736}
746 737
@@ -1318,6 +1309,7 @@ do_setusercontext(struct passwd *pw)
1318static void 1309static void
1319do_pwchange(Session *s) 1310do_pwchange(Session *s)
1320{ 1311{
1312 fflush(NULL);
1321 fprintf(stderr, "WARNING: Your password has expired.\n"); 1313 fprintf(stderr, "WARNING: Your password has expired.\n");
1322 if (s->ttyfd != -1) { 1314 if (s->ttyfd != -1) {
1323 fprintf(stderr, 1315 fprintf(stderr,
@@ -1703,12 +1695,6 @@ session_pty_req(Session *s)
1703 packet_disconnect("Protocol error: you already have a pty."); 1695 packet_disconnect("Protocol error: you already have a pty.");
1704 return 0; 1696 return 0;
1705 } 1697 }
1706 /* Get the time and hostname when the user last logged in. */
1707 if (options.print_lastlog) {
1708 s->hostname[0] = '\0';
1709 s->last_login_time = get_last_login_time(s->pw->pw_uid,
1710 s->pw->pw_name, s->hostname, sizeof(s->hostname));
1711 }
1712 1698
1713 s->term = packet_get_string(&len); 1699 s->term = packet_get_string(&len);
1714 1700