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 ed598ce35..0f4055e54 100644
--- a/monitor.c
+++ b/monitor.c
@@ -145,6 +145,7 @@ int mm_answer_sign(int, Buffer *);
145int mm_answer_pwnamallow(int, Buffer *); 145int mm_answer_pwnamallow(int, Buffer *);
146int mm_answer_auth2_read_banner(int, Buffer *); 146int mm_answer_auth2_read_banner(int, Buffer *);
147int mm_answer_authserv(int, Buffer *); 147int mm_answer_authserv(int, Buffer *);
148int mm_answer_authrole(int, Buffer *);
148int mm_answer_authpassword(int, Buffer *); 149int mm_answer_authpassword(int, Buffer *);
149int mm_answer_bsdauthquery(int, Buffer *); 150int mm_answer_bsdauthquery(int, Buffer *);
150int mm_answer_bsdauthrespond(int, Buffer *); 151int mm_answer_bsdauthrespond(int, Buffer *);
@@ -225,6 +226,7 @@ struct mon_table mon_dispatch_proto20[] = {
225 {MONITOR_REQ_SIGN, MON_ONCE, mm_answer_sign}, 226 {MONITOR_REQ_SIGN, MON_ONCE, mm_answer_sign},
226 {MONITOR_REQ_PWNAM, MON_ONCE, mm_answer_pwnamallow}, 227 {MONITOR_REQ_PWNAM, MON_ONCE, mm_answer_pwnamallow},
227 {MONITOR_REQ_AUTHSERV, MON_ONCE, mm_answer_authserv}, 228 {MONITOR_REQ_AUTHSERV, MON_ONCE, mm_answer_authserv},
229 {MONITOR_REQ_AUTHROLE, MON_ONCE, mm_answer_authrole},
228 {MONITOR_REQ_AUTH2_READ_BANNER, MON_ONCE, mm_answer_auth2_read_banner}, 230 {MONITOR_REQ_AUTH2_READ_BANNER, MON_ONCE, mm_answer_auth2_read_banner},
229 {MONITOR_REQ_AUTHPASSWORD, MON_AUTH, mm_answer_authpassword}, 231 {MONITOR_REQ_AUTHPASSWORD, MON_AUTH, mm_answer_authpassword},
230#ifdef USE_PAM 232#ifdef USE_PAM
@@ -808,6 +810,7 @@ mm_answer_pwnamallow(int sock, Buffer *m)
808 else { 810 else {
809 /* Allow service/style information on the auth context */ 811 /* Allow service/style information on the auth context */
810 monitor_permit(mon_dispatch, MONITOR_REQ_AUTHSERV, 1); 812 monitor_permit(mon_dispatch, MONITOR_REQ_AUTHSERV, 1);
813 monitor_permit(mon_dispatch, MONITOR_REQ_AUTHROLE, 1);
811 monitor_permit(mon_dispatch, MONITOR_REQ_AUTH2_READ_BANNER, 1); 814 monitor_permit(mon_dispatch, MONITOR_REQ_AUTH2_READ_BANNER, 1);
812 } 815 }
813#ifdef USE_PAM 816#ifdef USE_PAM
@@ -840,14 +843,37 @@ mm_answer_authserv(int sock, Buffer *m)
840 843
841 authctxt->service = buffer_get_string(m, NULL); 844 authctxt->service = buffer_get_string(m, NULL);
842 authctxt->style = buffer_get_string(m, NULL); 845 authctxt->style = buffer_get_string(m, NULL);
843 debug3("%s: service=%s, style=%s", 846 authctxt->role = buffer_get_string(m, NULL);
844 __func__, authctxt->service, authctxt->style); 847 debug3("%s: service=%s, style=%s, role=%s",
848 __func__, authctxt->service, authctxt->style, authctxt->role);
845 849
846 if (strlen(authctxt->style) == 0) { 850 if (strlen(authctxt->style) == 0) {
847 xfree(authctxt->style); 851 xfree(authctxt->style);
848 authctxt->style = NULL; 852 authctxt->style = NULL;
849 } 853 }
850 854
855 if (strlen(authctxt->role) == 0) {
856 xfree(authctxt->role);
857 authctxt->role = NULL;
858 }
859
860 return (0);
861}
862
863int
864mm_answer_authrole(int sock, Buffer *m)
865{
866 monitor_permit_authentications(1);
867
868 authctxt->role = buffer_get_string(m, NULL);
869 debug3("%s: role=%s",
870 __func__, authctxt->role);
871
872 if (strlen(authctxt->role) == 0) {
873 xfree(authctxt->role);
874 authctxt->role = NULL;
875 }
876
851 return (0); 877 return (0);
852} 878}
853 879
@@ -1435,7 +1461,7 @@ mm_answer_pty(int sock, Buffer *m)
1435 res = pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty)); 1461 res = pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty));
1436 if (res == 0) 1462 if (res == 0)
1437 goto error; 1463 goto error;
1438 pty_setowner(authctxt->pw, s->tty); 1464 pty_setowner(authctxt->pw, s->tty, authctxt->role);
1439 1465
1440 buffer_put_int(m, 1); 1466 buffer_put_int(m, 1);
1441 buffer_put_cstring(m, s->tty); 1467 buffer_put_cstring(m, s->tty);