View | Details | Raw Unified | Return to bug 87 | Differences between
and this patch

Collapse All | Expand All

(-)session.c~ (-16 / +13 lines)
Lines 128-134 Link Here
128
void	do_exec_pty(Session *, const char *);
128
void	do_exec_pty(Session *, const char *);
129
void	do_exec_no_pty(Session *, const char *);
129
void	do_exec_no_pty(Session *, const char *);
130
void	do_exec(Session *, const char *);
130
void	do_exec(Session *, const char *);
131
void	do_login(Session *, const char *);
131
void	do_login(Session *, const char *, const time_t, const char *);
132
#ifdef LOGIN_NEEDS_UTMPX
132
#ifdef LOGIN_NEEDS_UTMPX
133
static void	do_pre_login(Session *s);
133
static void	do_pre_login(Session *s);
134
#endif
134
#endif
Lines 548-558 Link Here
548
{
548
{
549
	int fdout, ptyfd, ttyfd, ptymaster;
549
	int fdout, ptyfd, ttyfd, ptymaster;
550
	pid_t pid;
550
	pid_t pid;
551
	char hostname[MAXHOSTNAMELEN];
552
	time_t last_login_time;
551
553
552
	if (s == NULL)
554
	if (s == NULL)
553
		fatal("do_exec_pty: no session");
555
		fatal("do_exec_pty: no session");
554
	ptyfd = s->ptyfd;
556
	ptyfd = s->ptyfd;
555
	ttyfd = s->ttyfd;
557
	ttyfd = s->ttyfd;
558
	/* Get the time and hostname when the user last logged in. */
559
	hostname[0] = '\0';
560
	last_login_time = get_last_login_time(s->pw->pw_uid, s->pw->pw_name,
561
	    hostname, sizeof(hostname));
556
562
557
#if defined(USE_PAM)
563
#if defined(USE_PAM)
558
	do_pam_session(s->pw->pw_name, s->tty);
564
	do_pam_session(s->pw->pw_name, s->tty);
Lines 584-590 Link Here
584
		/* record login, etc. similar to login(1) */
590
		/* record login, etc. similar to login(1) */
585
#ifndef HAVE_OSF_SIA
591
#ifndef HAVE_OSF_SIA
586
		if (!(options.use_login && command == NULL))
592
		if (!(options.use_login && command == NULL))
587
			do_login(s, command);
593
			do_login(s, command, last_login_time, hostname);
588
# ifdef LOGIN_NEEDS_UTMPX
594
# ifdef LOGIN_NEEDS_UTMPX
589
		else
595
		else
590
			do_pre_login(s);
596
			do_pre_login(s);
Lines 682-694 Link Here
682
688
683
/* administrative, login(1)-like work */
689
/* administrative, login(1)-like work */
684
void
690
void
685
do_login(Session *s, const char *command)
691
do_login(Session *s, const char *command, const time_t found_last_login_time, const char *last_host)
686
{
692
{
687
	char *time_string;
693
	char *time_string;
688
	char hostname[MAXHOSTNAMELEN];
689
	socklen_t fromlen;
694
	socklen_t fromlen;
690
	struct sockaddr_storage from;
695
	struct sockaddr_storage from;
691
	time_t last_login_time;
692
	struct passwd * pw = s->pw;
696
	struct passwd * pw = s->pw;
693
	pid_t pid = getpid();
697
	pid_t pid = getpid();
694
698
Lines 706-718 Link Here
706
		}
710
		}
707
	}
711
	}
708
712
709
	/* Get the time and hostname when the user last logged in. */
710
	if (options.print_lastlog) {
711
		hostname[0] = '\0';
712
		last_login_time = get_last_login_time(pw->pw_uid, pw->pw_name,
713
		    hostname, sizeof(hostname));
714
	}
715
716
	/* Record that there was a login on that tty from the remote host. */
713
	/* Record that there was a login on that tty from the remote host. */
717
	record_login(pid, s->tty, pw->pw_name, pw->pw_uid,
714
	record_login(pid, s->tty, pw->pw_name, pw->pw_uid,
718
	    get_remote_name_or_ip(utmp_len, options.reverse_mapping_check),
715
	    get_remote_name_or_ip(utmp_len, options.reverse_mapping_check),
Lines 741-754 Link Here
741
		printf("%s\n", aixloginmsg);
738
		printf("%s\n", aixloginmsg);
742
#endif /* WITH_AIXAUTHENTICATE */
739
#endif /* WITH_AIXAUTHENTICATE */
743
740
744
	if (options.print_lastlog && last_login_time != 0) {
741
	if (options.print_lastlog && found_last_login_time != 0) {
745
		time_string = ctime(&last_login_time);
742
		time_string = ctime(&found_last_login_time);
746
		if (strchr(time_string, '\n'))
743
		if (strchr(time_string, '\n'))
747
			*strchr(time_string, '\n') = 0;
744
			*strchr(time_string, '\n') = 0;
748
		if (strcmp(hostname, "") == 0)
745
		if (strcmp(last_host, "") == 0)
749
			printf("Last login: %s\r\n", time_string);
746
			printf("Last login: %s\r\n", time_string);
750
		else
747
		else
751
			printf("Last login: %s from %s\r\n", time_string, hostname);
748
			printf("Last login: %s from %s\r\n", time_string, last_host);
752
	}
749
	}
753
750
754
	do_motd();
751
	do_motd();

Return to bug 87