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>2017-10-04 13:54:48 +0100
commit4b276122c04aed0726803a92c8ca955e614a4d3a (patch)
tree5c5638fad9f6edf9ada6a4661f6c5cbb1bec2696 /monitor.c
parentcdd9076a145a95c21538eedb3f728a897480c5de (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 cabfeb8a4..510e3496e 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
@@ -799,6 +801,7 @@ mm_answer_pwnamallow(int sock, Buffer *m)
799 801
800 /* Allow service/style information on the auth context */ 802 /* Allow service/style information on the auth context */
801 monitor_permit(mon_dispatch, MONITOR_REQ_AUTHSERV, 1); 803 monitor_permit(mon_dispatch, MONITOR_REQ_AUTHSERV, 1);
804 monitor_permit(mon_dispatch, MONITOR_REQ_AUTHROLE, 1);
802 monitor_permit(mon_dispatch, MONITOR_REQ_AUTH2_READ_BANNER, 1); 805 monitor_permit(mon_dispatch, MONITOR_REQ_AUTH2_READ_BANNER, 1);
803 806
804#ifdef USE_PAM 807#ifdef USE_PAM
@@ -829,14 +832,37 @@ mm_answer_authserv(int sock, Buffer *m)
829 832
830 authctxt->service = buffer_get_string(m, NULL); 833 authctxt->service = buffer_get_string(m, NULL);
831 authctxt->style = buffer_get_string(m, NULL); 834 authctxt->style = buffer_get_string(m, NULL);
832 debug3("%s: service=%s, style=%s", 835 authctxt->role = buffer_get_string(m, NULL);
833 __func__, authctxt->service, authctxt->style); 836 debug3("%s: service=%s, style=%s, role=%s",
837 __func__, authctxt->service, authctxt->style, authctxt->role);
834 838
835 if (strlen(authctxt->style) == 0) { 839 if (strlen(authctxt->style) == 0) {
836 free(authctxt->style); 840 free(authctxt->style);
837 authctxt->style = NULL; 841 authctxt->style = NULL;
838 } 842 }
839 843
844 if (strlen(authctxt->role) == 0) {
845 free(authctxt->role);
846 authctxt->role = NULL;
847 }
848
849 return (0);
850}
851
852int
853mm_answer_authrole(int sock, Buffer *m)
854{
855 monitor_permit_authentications(1);
856
857 authctxt->role = buffer_get_string(m, NULL);
858 debug3("%s: role=%s",
859 __func__, authctxt->role);
860
861 if (strlen(authctxt->role) == 0) {
862 free(authctxt->role);
863 authctxt->role = NULL;
864 }
865
840 return (0); 866 return (0);
841} 867}
842 868
@@ -1471,7 +1497,7 @@ mm_answer_pty(int sock, Buffer *m)
1471 res = pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty)); 1497 res = pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty));
1472 if (res == 0) 1498 if (res == 0)
1473 goto error; 1499 goto error;
1474 pty_setowner(authctxt->pw, s->tty); 1500 pty_setowner(authctxt->pw, s->tty, authctxt->role);
1475 1501
1476 buffer_put_int(m, 1); 1502 buffer_put_int(m, 1);
1477 buffer_put_cstring(m, s->tty); 1503 buffer_put_cstring(m, s->tty);