summaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorManoj Srivastava <srivasta@debian.org>2014-02-09 16:09:49 +0000
committerColin Watson <cjwatson@debian.org>2018-04-03 08:20:56 +0100
commit7da968d97beba5fb80a5488516563ea1376db907 (patch)
tree0e9107c92138281814181acbdd1428a6862ef63b /monitor.c
parent398af3d66bfe8dc7d436570026571e522a0a13a0 (diff)
Handle SELinux authorisation roles
Rejected upstream due to discomfort with magic usernames; a better approach will need an SSH protocol change. In the meantime, this came from Debian's SELinux maintainer, so we'll keep it until we have something better. Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1641 Bug-Debian: http://bugs.debian.org/394795 Last-Update: 2017-10-04 Patch-Name: selinux-role.patch
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);