summaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/monitor.c b/monitor.c
index 506645c7c..7452e20e2 100644
--- a/monitor.c
+++ b/monitor.c
@@ -127,6 +127,7 @@ int mm_answer_sign(int, Buffer *);
127int mm_answer_pwnamallow(int, Buffer *); 127int mm_answer_pwnamallow(int, Buffer *);
128int mm_answer_auth2_read_banner(int, Buffer *); 128int mm_answer_auth2_read_banner(int, Buffer *);
129int mm_answer_authserv(int, Buffer *); 129int mm_answer_authserv(int, Buffer *);
130int mm_answer_authrole(int, Buffer *);
130int mm_answer_authpassword(int, Buffer *); 131int mm_answer_authpassword(int, Buffer *);
131int mm_answer_bsdauthquery(int, Buffer *); 132int mm_answer_bsdauthquery(int, Buffer *);
132int mm_answer_bsdauthrespond(int, Buffer *); 133int mm_answer_bsdauthrespond(int, Buffer *);
@@ -204,6 +205,7 @@ struct mon_table mon_dispatch_proto20[] = {
204 {MONITOR_REQ_SIGN, MON_ONCE, mm_answer_sign}, 205 {MONITOR_REQ_SIGN, MON_ONCE, mm_answer_sign},
205 {MONITOR_REQ_PWNAM, MON_ONCE, mm_answer_pwnamallow}, 206 {MONITOR_REQ_PWNAM, MON_ONCE, mm_answer_pwnamallow},
206 {MONITOR_REQ_AUTHSERV, MON_ONCE, mm_answer_authserv}, 207 {MONITOR_REQ_AUTHSERV, MON_ONCE, mm_answer_authserv},
208 {MONITOR_REQ_AUTHROLE, MON_ONCE, mm_answer_authrole},
207 {MONITOR_REQ_AUTH2_READ_BANNER, MON_ONCE, mm_answer_auth2_read_banner}, 209 {MONITOR_REQ_AUTH2_READ_BANNER, MON_ONCE, mm_answer_auth2_read_banner},
208 {MONITOR_REQ_AUTHPASSWORD, MON_AUTH, mm_answer_authpassword}, 210 {MONITOR_REQ_AUTHPASSWORD, MON_AUTH, mm_answer_authpassword},
209#ifdef USE_PAM 211#ifdef USE_PAM
@@ -791,6 +793,7 @@ mm_answer_pwnamallow(int sock, Buffer *m)
791 793
792 /* Allow service/style information on the auth context */ 794 /* Allow service/style information on the auth context */
793 monitor_permit(mon_dispatch, MONITOR_REQ_AUTHSERV, 1); 795 monitor_permit(mon_dispatch, MONITOR_REQ_AUTHSERV, 1);
796 monitor_permit(mon_dispatch, MONITOR_REQ_AUTHROLE, 1);
794 monitor_permit(mon_dispatch, MONITOR_REQ_AUTH2_READ_BANNER, 1); 797 monitor_permit(mon_dispatch, MONITOR_REQ_AUTH2_READ_BANNER, 1);
795 798
796#ifdef USE_PAM 799#ifdef USE_PAM
@@ -821,14 +824,37 @@ mm_answer_authserv(int sock, Buffer *m)
821 824
822 authctxt->service = buffer_get_string(m, NULL); 825 authctxt->service = buffer_get_string(m, NULL);
823 authctxt->style = buffer_get_string(m, NULL); 826 authctxt->style = buffer_get_string(m, NULL);
824 debug3("%s: service=%s, style=%s", 827 authctxt->role = buffer_get_string(m, NULL);
825 __func__, authctxt->service, authctxt->style); 828 debug3("%s: service=%s, style=%s, role=%s",
829 __func__, authctxt->service, authctxt->style, authctxt->role);
826 830
827 if (strlen(authctxt->style) == 0) { 831 if (strlen(authctxt->style) == 0) {
828 free(authctxt->style); 832 free(authctxt->style);
829 authctxt->style = NULL; 833 authctxt->style = NULL;
830 } 834 }
831 835
836 if (strlen(authctxt->role) == 0) {
837 free(authctxt->role);
838 authctxt->role = NULL;
839 }
840
841 return (0);
842}
843
844int
845mm_answer_authrole(int sock, Buffer *m)
846{
847 monitor_permit_authentications(1);
848
849 authctxt->role = buffer_get_string(m, NULL);
850 debug3("%s: role=%s",
851 __func__, authctxt->role);
852
853 if (strlen(authctxt->role) == 0) {
854 free(authctxt->role);
855 authctxt->role = NULL;
856 }
857
832 return (0); 858 return (0);
833} 859}
834 860
@@ -1463,7 +1489,7 @@ mm_answer_pty(int sock, Buffer *m)
1463 res = pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty)); 1489 res = pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty));
1464 if (res == 0) 1490 if (res == 0)
1465 goto error; 1491 goto error;
1466 pty_setowner(authctxt->pw, s->tty); 1492 pty_setowner(authctxt->pw, s->tty, authctxt->role);
1467 1493
1468 buffer_put_int(m, 1); 1494 buffer_put_int(m, 1);
1469 buffer_put_cstring(m, s->tty); 1495 buffer_put_cstring(m, s->tty);