*/
#include "includes.h"
-RCSID("$OpenBSD: monitor.c,v 1.59 2004/06/21 17:36:31 avsm Exp $");
+RCSID("$OpenBSD: monitor.c,v 1.61 2004/07/17 05:31:41 dtucker Exp $");
#include <openssl/dh.h>
extern Buffer input, output;
extern Buffer auth_debug;
extern int auth_debug_init;
+extern Buffer loginmsg;
/* State exported from the child */
int
mm_answer_pwnamallow(int sock, Buffer *m)
{
- char *login;
+ char *username;
struct passwd *pwent;
int allowed = 0;
if (authctxt->attempt++ != 0)
fatal("%s: multiple attempts for getpwnam", __func__);
- login = buffer_get_string(m, NULL);
+ username = buffer_get_string(m, NULL);
- pwent = getpwnamallow(login);
+ pwent = getpwnamallow(username);
- authctxt->user = xstrdup(login);
- setproctitle("%s [priv]", pwent ? login : "unknown");
- xfree(login);
+ authctxt->user = xstrdup(username);
+ setproctitle("%s [priv]", pwent ? username : "unknown");
+ xfree(username);
buffer_clear(m);
buffer_put_int(m, 1);
buffer_put_cstring(m, s->tty);
- mm_request_send(sock, MONITOR_ANS_PTY, m);
-
- mm_send_fd(sock, s->ptyfd);
- mm_send_fd(sock, s->ttyfd);
/* We need to trick ttyslot */
if (dup2(s->ttyfd, 0) == -1)
/* Now we can close the file descriptor again */
close(0);
+ /* send messages generated by record_login */
+ buffer_put_string(m, buffer_ptr(&loginmsg), buffer_len(&loginmsg));
+ buffer_clear(&loginmsg);
+
+ mm_request_send(sock, MONITOR_ANS_PTY, m);
+
+ mm_send_fd(sock, s->ptyfd);
+ mm_send_fd(sock, s->ttyfd);
+
/* make sure nothing uses fd 0 */
if ((fd0 = open(_PATH_DEVNULL, O_RDONLY)) < 0)
fatal("%s: open(/dev/null): %s", __func__, strerror(errno));