diff options
author | Manoj Srivastava <srivasta@debian.org> | 2014-02-09 16:09:49 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2019-06-05 13:11:52 +0100 |
commit | 21e3ff3ab4791d3c94bd775da66cde29797fcb36 (patch) | |
tree | c218b12d60175ae0572c0236f2390d9e26de5bc9 /monitor.c | |
parent | 0f9f44654708e4fde2f52c52f717d061b5e458fa (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: 2019-06-05
Patch-Name: selinux-role.patch
Diffstat (limited to 'monitor.c')
-rw-r--r-- | monitor.c | 37 |
1 files changed, 33 insertions, 4 deletions
@@ -117,6 +117,7 @@ int mm_answer_sign(struct ssh *, int, struct sshbuf *); | |||
117 | int mm_answer_pwnamallow(struct ssh *, int, struct sshbuf *); | 117 | int mm_answer_pwnamallow(struct ssh *, int, struct sshbuf *); |
118 | int mm_answer_auth2_read_banner(struct ssh *, int, struct sshbuf *); | 118 | int mm_answer_auth2_read_banner(struct ssh *, int, struct sshbuf *); |
119 | int mm_answer_authserv(struct ssh *, int, struct sshbuf *); | 119 | int mm_answer_authserv(struct ssh *, int, struct sshbuf *); |
120 | int mm_answer_authrole(struct ssh *, int, struct sshbuf *); | ||
120 | int mm_answer_authpassword(struct ssh *, int, struct sshbuf *); | 121 | int mm_answer_authpassword(struct ssh *, int, struct sshbuf *); |
121 | int mm_answer_bsdauthquery(struct ssh *, int, struct sshbuf *); | 122 | int mm_answer_bsdauthquery(struct ssh *, int, struct sshbuf *); |
122 | int mm_answer_bsdauthrespond(struct ssh *, int, struct sshbuf *); | 123 | int mm_answer_bsdauthrespond(struct ssh *, int, struct sshbuf *); |
@@ -197,6 +198,7 @@ struct mon_table mon_dispatch_proto20[] = { | |||
197 | {MONITOR_REQ_SIGN, MON_ONCE, mm_answer_sign}, | 198 | {MONITOR_REQ_SIGN, MON_ONCE, mm_answer_sign}, |
198 | {MONITOR_REQ_PWNAM, MON_ONCE, mm_answer_pwnamallow}, | 199 | {MONITOR_REQ_PWNAM, MON_ONCE, mm_answer_pwnamallow}, |
199 | {MONITOR_REQ_AUTHSERV, MON_ONCE, mm_answer_authserv}, | 200 | {MONITOR_REQ_AUTHSERV, MON_ONCE, mm_answer_authserv}, |
201 | {MONITOR_REQ_AUTHROLE, MON_ONCE, mm_answer_authrole}, | ||
200 | {MONITOR_REQ_AUTH2_READ_BANNER, MON_ONCE, mm_answer_auth2_read_banner}, | 202 | {MONITOR_REQ_AUTH2_READ_BANNER, MON_ONCE, mm_answer_auth2_read_banner}, |
201 | {MONITOR_REQ_AUTHPASSWORD, MON_AUTH, mm_answer_authpassword}, | 203 | {MONITOR_REQ_AUTHPASSWORD, MON_AUTH, mm_answer_authpassword}, |
202 | #ifdef USE_PAM | 204 | #ifdef USE_PAM |
@@ -819,6 +821,7 @@ mm_answer_pwnamallow(struct ssh *ssh, int sock, struct sshbuf *m) | |||
819 | 821 | ||
820 | /* Allow service/style information on the auth context */ | 822 | /* Allow service/style information on the auth context */ |
821 | monitor_permit(mon_dispatch, MONITOR_REQ_AUTHSERV, 1); | 823 | monitor_permit(mon_dispatch, MONITOR_REQ_AUTHSERV, 1); |
824 | monitor_permit(mon_dispatch, MONITOR_REQ_AUTHROLE, 1); | ||
822 | monitor_permit(mon_dispatch, MONITOR_REQ_AUTH2_READ_BANNER, 1); | 825 | monitor_permit(mon_dispatch, MONITOR_REQ_AUTH2_READ_BANNER, 1); |
823 | 826 | ||
824 | #ifdef USE_PAM | 827 | #ifdef USE_PAM |
@@ -852,16 +855,42 @@ mm_answer_authserv(struct ssh *ssh, int sock, struct sshbuf *m) | |||
852 | monitor_permit_authentications(1); | 855 | monitor_permit_authentications(1); |
853 | 856 | ||
854 | if ((r = sshbuf_get_cstring(m, &authctxt->service, NULL)) != 0 || | 857 | if ((r = sshbuf_get_cstring(m, &authctxt->service, NULL)) != 0 || |
855 | (r = sshbuf_get_cstring(m, &authctxt->style, NULL)) != 0) | 858 | (r = sshbuf_get_cstring(m, &authctxt->style, NULL)) != 0 || |
859 | (r = sshbuf_get_cstring(m, &authctxt->role, NULL)) != 0) | ||
856 | fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 860 | fatal("%s: buffer error: %s", __func__, ssh_err(r)); |
857 | debug3("%s: service=%s, style=%s", | 861 | debug3("%s: service=%s, style=%s, role=%s", |
858 | __func__, authctxt->service, authctxt->style); | 862 | __func__, authctxt->service, authctxt->style, authctxt->role); |
859 | 863 | ||
860 | if (strlen(authctxt->style) == 0) { | 864 | if (strlen(authctxt->style) == 0) { |
861 | free(authctxt->style); | 865 | free(authctxt->style); |
862 | authctxt->style = NULL; | 866 | authctxt->style = NULL; |
863 | } | 867 | } |
864 | 868 | ||
869 | if (strlen(authctxt->role) == 0) { | ||
870 | free(authctxt->role); | ||
871 | authctxt->role = NULL; | ||
872 | } | ||
873 | |||
874 | return (0); | ||
875 | } | ||
876 | |||
877 | int | ||
878 | mm_answer_authrole(struct ssh *ssh, int sock, struct sshbuf *m) | ||
879 | { | ||
880 | int r; | ||
881 | |||
882 | monitor_permit_authentications(1); | ||
883 | |||
884 | if ((r = sshbuf_get_cstring(m, &authctxt->role, NULL)) != 0) | ||
885 | fatal("%s: buffer error: %s", __func__, ssh_err(r)); | ||
886 | debug3("%s: role=%s", | ||
887 | __func__, authctxt->role); | ||
888 | |||
889 | if (strlen(authctxt->role) == 0) { | ||
890 | free(authctxt->role); | ||
891 | authctxt->role = NULL; | ||
892 | } | ||
893 | |||
865 | return (0); | 894 | return (0); |
866 | } | 895 | } |
867 | 896 | ||
@@ -1528,7 +1557,7 @@ mm_answer_pty(struct ssh *ssh, int sock, struct sshbuf *m) | |||
1528 | res = pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty)); | 1557 | res = pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty)); |
1529 | if (res == 0) | 1558 | if (res == 0) |
1530 | goto error; | 1559 | goto error; |
1531 | pty_setowner(authctxt->pw, s->tty); | 1560 | pty_setowner(authctxt->pw, s->tty, authctxt->role); |
1532 | 1561 | ||
1533 | if ((r = sshbuf_put_u32(m, 1)) != 0 || | 1562 | if ((r = sshbuf_put_u32(m, 1)) != 0 || |
1534 | (r = sshbuf_put_cstring(m, s->tty)) != 0) | 1563 | (r = sshbuf_put_cstring(m, s->tty)) != 0) |