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 868fb0d2d..ed37458fb 100644
--- a/monitor.c
+++ b/monitor.c
@@ -128,6 +128,7 @@ int mm_answer_sign(int, Buffer *);
128int mm_answer_pwnamallow(int, Buffer *); 128int mm_answer_pwnamallow(int, Buffer *);
129int mm_answer_auth2_read_banner(int, Buffer *); 129int mm_answer_auth2_read_banner(int, Buffer *);
130int mm_answer_authserv(int, Buffer *); 130int mm_answer_authserv(int, Buffer *);
131int mm_answer_authrole(int, Buffer *);
131int mm_answer_authpassword(int, Buffer *); 132int mm_answer_authpassword(int, Buffer *);
132int mm_answer_bsdauthquery(int, Buffer *); 133int mm_answer_bsdauthquery(int, Buffer *);
133int mm_answer_bsdauthrespond(int, Buffer *); 134int mm_answer_bsdauthrespond(int, Buffer *);
@@ -206,6 +207,7 @@ struct mon_table mon_dispatch_proto20[] = {
206 {MONITOR_REQ_SIGN, MON_ONCE, mm_answer_sign}, 207 {MONITOR_REQ_SIGN, MON_ONCE, mm_answer_sign},
207 {MONITOR_REQ_PWNAM, MON_ONCE, mm_answer_pwnamallow}, 208 {MONITOR_REQ_PWNAM, MON_ONCE, mm_answer_pwnamallow},
208 {MONITOR_REQ_AUTHSERV, MON_ONCE, mm_answer_authserv}, 209 {MONITOR_REQ_AUTHSERV, MON_ONCE, mm_answer_authserv},
210 {MONITOR_REQ_AUTHROLE, MON_ONCE, mm_answer_authrole},
209 {MONITOR_REQ_AUTH2_READ_BANNER, MON_ONCE, mm_answer_auth2_read_banner}, 211 {MONITOR_REQ_AUTH2_READ_BANNER, MON_ONCE, mm_answer_auth2_read_banner},
210 {MONITOR_REQ_AUTHPASSWORD, MON_AUTH, mm_answer_authpassword}, 212 {MONITOR_REQ_AUTHPASSWORD, MON_AUTH, mm_answer_authpassword},
211#ifdef USE_PAM 213#ifdef USE_PAM
@@ -806,6 +808,7 @@ mm_answer_pwnamallow(int sock, Buffer *m)
806 808
807 /* Allow service/style information on the auth context */ 809 /* Allow service/style information on the auth context */
808 monitor_permit(mon_dispatch, MONITOR_REQ_AUTHSERV, 1); 810 monitor_permit(mon_dispatch, MONITOR_REQ_AUTHSERV, 1);
811 monitor_permit(mon_dispatch, MONITOR_REQ_AUTHROLE, 1);
809 monitor_permit(mon_dispatch, MONITOR_REQ_AUTH2_READ_BANNER, 1); 812 monitor_permit(mon_dispatch, MONITOR_REQ_AUTH2_READ_BANNER, 1);
810 813
811#ifdef USE_PAM 814#ifdef USE_PAM
@@ -836,14 +839,37 @@ mm_answer_authserv(int sock, Buffer *m)
836 839
837 authctxt->service = buffer_get_string(m, NULL); 840 authctxt->service = buffer_get_string(m, NULL);
838 authctxt->style = buffer_get_string(m, NULL); 841 authctxt->style = buffer_get_string(m, NULL);
839 debug3("%s: service=%s, style=%s", 842 authctxt->role = buffer_get_string(m, NULL);
840 __func__, authctxt->service, authctxt->style); 843 debug3("%s: service=%s, style=%s, role=%s",
844 __func__, authctxt->service, authctxt->style, authctxt->role);
841 845
842 if (strlen(authctxt->style) == 0) { 846 if (strlen(authctxt->style) == 0) {
843 free(authctxt->style); 847 free(authctxt->style);
844 authctxt->style = NULL; 848 authctxt->style = NULL;
845 } 849 }
846 850
851 if (strlen(authctxt->role) == 0) {
852 free(authctxt->role);
853 authctxt->role = NULL;
854 }
855
856 return (0);
857}
858
859int
860mm_answer_authrole(int sock, Buffer *m)
861{
862 monitor_permit_authentications(1);
863
864 authctxt->role = buffer_get_string(m, NULL);
865 debug3("%s: role=%s",
866 __func__, authctxt->role);
867
868 if (strlen(authctxt->role) == 0) {
869 free(authctxt->role);
870 authctxt->role = NULL;
871 }
872
847 return (0); 873 return (0);
848} 874}
849 875
@@ -1497,7 +1523,7 @@ mm_answer_pty(int sock, Buffer *m)
1497 res = pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty)); 1523 res = pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty));
1498 if (res == 0) 1524 if (res == 0)
1499 goto error; 1525 goto error;
1500 pty_setowner(authctxt->pw, s->tty); 1526 pty_setowner(authctxt->pw, s->tty, authctxt->role);
1501 1527
1502 buffer_put_int(m, 1); 1528 buffer_put_int(m, 1);
1503 buffer_put_cstring(m, s->tty); 1529 buffer_put_cstring(m, s->tty);