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 ff5547e0e..d522a0753 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
@@ -811,6 +813,7 @@ mm_answer_pwnamallow(int sock, Buffer *m)
811 else { 813 else {
812 /* Allow service/style information on the auth context */ 814 /* Allow service/style information on the auth context */
813 monitor_permit(mon_dispatch, MONITOR_REQ_AUTHSERV, 1); 815 monitor_permit(mon_dispatch, MONITOR_REQ_AUTHSERV, 1);
816 monitor_permit(mon_dispatch, MONITOR_REQ_AUTHROLE, 1);
814 monitor_permit(mon_dispatch, MONITOR_REQ_AUTH2_READ_BANNER, 1); 817 monitor_permit(mon_dispatch, MONITOR_REQ_AUTH2_READ_BANNER, 1);
815 } 818 }
816#ifdef USE_PAM 819#ifdef USE_PAM
@@ -843,14 +846,37 @@ mm_answer_authserv(int sock, Buffer *m)
843 846
844 authctxt->service = buffer_get_string(m, NULL); 847 authctxt->service = buffer_get_string(m, NULL);
845 authctxt->style = buffer_get_string(m, NULL); 848 authctxt->style = buffer_get_string(m, NULL);
846 debug3("%s: service=%s, style=%s", 849 authctxt->role = buffer_get_string(m, NULL);
847 __func__, authctxt->service, authctxt->style); 850 debug3("%s: service=%s, style=%s, role=%s",
851 __func__, authctxt->service, authctxt->style, authctxt->role);
848 852
849 if (strlen(authctxt->style) == 0) { 853 if (strlen(authctxt->style) == 0) {
850 xfree(authctxt->style); 854 xfree(authctxt->style);
851 authctxt->style = NULL; 855 authctxt->style = NULL;
852 } 856 }
853 857
858 if (strlen(authctxt->role) == 0) {
859 xfree(authctxt->role);
860 authctxt->role = NULL;
861 }
862
863 return (0);
864}
865
866int
867mm_answer_authrole(int sock, Buffer *m)
868{
869 monitor_permit_authentications(1);
870
871 authctxt->role = buffer_get_string(m, NULL);
872 debug3("%s: role=%s",
873 __func__, authctxt->role);
874
875 if (strlen(authctxt->role) == 0) {
876 xfree(authctxt->role);
877 authctxt->role = NULL;
878 }
879
854 return (0); 880 return (0);
855} 881}
856 882
@@ -1438,7 +1464,7 @@ mm_answer_pty(int sock, Buffer *m)
1438 res = pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty)); 1464 res = pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty));
1439 if (res == 0) 1465 if (res == 0)
1440 goto error; 1466 goto error;
1441 pty_setowner(authctxt->pw, s->tty); 1467 pty_setowner(authctxt->pw, s->tty, authctxt->role);
1442 1468
1443 buffer_put_int(m, 1); 1469 buffer_put_int(m, 1);
1444 buffer_put_cstring(m, s->tty); 1470 buffer_put_cstring(m, s->tty);