diff options
-rw-r--r-- | auth.h | 1 | ||||
-rw-r--r-- | auth2.c | 10 | ||||
-rw-r--r-- | monitor.c | 37 | ||||
-rw-r--r-- | monitor.h | 2 | ||||
-rw-r--r-- | monitor_wrap.c | 27 | ||||
-rw-r--r-- | monitor_wrap.h | 3 | ||||
-rw-r--r-- | openbsd-compat/port-linux.c | 21 | ||||
-rw-r--r-- | openbsd-compat/port-linux.h | 4 | ||||
-rw-r--r-- | platform.c | 4 | ||||
-rw-r--r-- | platform.h | 2 | ||||
-rw-r--r-- | session.c | 10 | ||||
-rw-r--r-- | session.h | 2 | ||||
-rw-r--r-- | sshd.c | 2 | ||||
-rw-r--r-- | sshpty.c | 4 | ||||
-rw-r--r-- | sshpty.h | 2 |
15 files changed, 99 insertions, 32 deletions
@@ -65,6 +65,7 @@ struct Authctxt { | |||
65 | char *service; | 65 | char *service; |
66 | struct passwd *pw; /* set if 'valid' */ | 66 | struct passwd *pw; /* set if 'valid' */ |
67 | char *style; | 67 | char *style; |
68 | char *role; | ||
68 | 69 | ||
69 | /* Method lists for multiple authentication */ | 70 | /* Method lists for multiple authentication */ |
70 | char **auth_methods; /* modified from server config */ | 71 | char **auth_methods; /* modified from server config */ |
@@ -267,7 +267,7 @@ input_userauth_request(int type, u_int32_t seq, struct ssh *ssh) | |||
267 | { | 267 | { |
268 | Authctxt *authctxt = ssh->authctxt; | 268 | Authctxt *authctxt = ssh->authctxt; |
269 | Authmethod *m = NULL; | 269 | Authmethod *m = NULL; |
270 | char *user = NULL, *service = NULL, *method = NULL, *style = NULL; | 270 | char *user = NULL, *service = NULL, *method = NULL, *style = NULL, *role = NULL; |
271 | int r, authenticated = 0; | 271 | int r, authenticated = 0; |
272 | double tstart = monotime_double(); | 272 | double tstart = monotime_double(); |
273 | 273 | ||
@@ -281,8 +281,13 @@ input_userauth_request(int type, u_int32_t seq, struct ssh *ssh) | |||
281 | debug("userauth-request for user %s service %s method %s", user, service, method); | 281 | debug("userauth-request for user %s service %s method %s", user, service, method); |
282 | debug("attempt %d failures %d", authctxt->attempt, authctxt->failures); | 282 | debug("attempt %d failures %d", authctxt->attempt, authctxt->failures); |
283 | 283 | ||
284 | if ((role = strchr(user, '/')) != NULL) | ||
285 | *role++ = 0; | ||
286 | |||
284 | if ((style = strchr(user, ':')) != NULL) | 287 | if ((style = strchr(user, ':')) != NULL) |
285 | *style++ = 0; | 288 | *style++ = 0; |
289 | else if (role && (style = strchr(role, ':')) != NULL) | ||
290 | *style++ = '\0'; | ||
286 | 291 | ||
287 | if (authctxt->attempt++ == 0) { | 292 | if (authctxt->attempt++ == 0) { |
288 | /* setup auth context */ | 293 | /* setup auth context */ |
@@ -309,8 +314,9 @@ input_userauth_request(int type, u_int32_t seq, struct ssh *ssh) | |||
309 | use_privsep ? " [net]" : ""); | 314 | use_privsep ? " [net]" : ""); |
310 | authctxt->service = xstrdup(service); | 315 | authctxt->service = xstrdup(service); |
311 | authctxt->style = style ? xstrdup(style) : NULL; | 316 | authctxt->style = style ? xstrdup(style) : NULL; |
317 | authctxt->role = role ? xstrdup(role) : NULL; | ||
312 | if (use_privsep) | 318 | if (use_privsep) |
313 | mm_inform_authserv(service, style); | 319 | mm_inform_authserv(service, style, role); |
314 | userauth_banner(ssh); | 320 | userauth_banner(ssh); |
315 | if (auth2_setup_methods_lists(authctxt) != 0) | 321 | if (auth2_setup_methods_lists(authctxt) != 0) |
316 | ssh_packet_disconnect(ssh, | 322 | ssh_packet_disconnect(ssh, |
@@ -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) |
@@ -65,6 +65,8 @@ enum monitor_reqtype { | |||
65 | 65 | ||
66 | MONITOR_REQ_GSSSIGN = 150, MONITOR_ANS_GSSSIGN = 151, | 66 | MONITOR_REQ_GSSSIGN = 150, MONITOR_ANS_GSSSIGN = 151, |
67 | MONITOR_REQ_GSSUPCREDS = 152, MONITOR_ANS_GSSUPCREDS = 153, | 67 | MONITOR_REQ_GSSUPCREDS = 152, MONITOR_ANS_GSSUPCREDS = 153, |
68 | |||
69 | MONITOR_REQ_AUTHROLE = 154, | ||
68 | }; | 70 | }; |
69 | 71 | ||
70 | struct ssh; | 72 | struct ssh; |
diff --git a/monitor_wrap.c b/monitor_wrap.c index 8e4c1c1f8..6b3a6251c 100644 --- a/monitor_wrap.c +++ b/monitor_wrap.c | |||
@@ -364,10 +364,10 @@ mm_auth2_read_banner(void) | |||
364 | return (banner); | 364 | return (banner); |
365 | } | 365 | } |
366 | 366 | ||
367 | /* Inform the privileged process about service and style */ | 367 | /* Inform the privileged process about service, style, and role */ |
368 | 368 | ||
369 | void | 369 | void |
370 | mm_inform_authserv(char *service, char *style) | 370 | mm_inform_authserv(char *service, char *style, char *role) |
371 | { | 371 | { |
372 | struct sshbuf *m; | 372 | struct sshbuf *m; |
373 | int r; | 373 | int r; |
@@ -377,7 +377,8 @@ mm_inform_authserv(char *service, char *style) | |||
377 | if ((m = sshbuf_new()) == NULL) | 377 | if ((m = sshbuf_new()) == NULL) |
378 | fatal("%s: sshbuf_new failed", __func__); | 378 | fatal("%s: sshbuf_new failed", __func__); |
379 | if ((r = sshbuf_put_cstring(m, service)) != 0 || | 379 | if ((r = sshbuf_put_cstring(m, service)) != 0 || |
380 | (r = sshbuf_put_cstring(m, style ? style : "")) != 0) | 380 | (r = sshbuf_put_cstring(m, style ? style : "")) != 0 || |
381 | (r = sshbuf_put_cstring(m, role ? role : "")) != 0) | ||
381 | fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 382 | fatal("%s: buffer error: %s", __func__, ssh_err(r)); |
382 | 383 | ||
383 | mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTHSERV, m); | 384 | mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTHSERV, m); |
@@ -385,6 +386,26 @@ mm_inform_authserv(char *service, char *style) | |||
385 | sshbuf_free(m); | 386 | sshbuf_free(m); |
386 | } | 387 | } |
387 | 388 | ||
389 | /* Inform the privileged process about role */ | ||
390 | |||
391 | void | ||
392 | mm_inform_authrole(char *role) | ||
393 | { | ||
394 | struct sshbuf *m; | ||
395 | int r; | ||
396 | |||
397 | debug3("%s entering", __func__); | ||
398 | |||
399 | if ((m = sshbuf_new()) == NULL) | ||
400 | fatal("%s: sshbuf_new failed", __func__); | ||
401 | if ((r = sshbuf_put_cstring(m, role ? role : "")) != 0) | ||
402 | fatal("%s: buffer error: %s", __func__, ssh_err(r)); | ||
403 | |||
404 | mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTHROLE, m); | ||
405 | |||
406 | sshbuf_free(m); | ||
407 | } | ||
408 | |||
388 | /* Do the password authentication */ | 409 | /* Do the password authentication */ |
389 | int | 410 | int |
390 | mm_auth_password(struct ssh *ssh, char *password) | 411 | mm_auth_password(struct ssh *ssh, char *password) |
diff --git a/monitor_wrap.h b/monitor_wrap.h index 69164a8c0..3d0e32d48 100644 --- a/monitor_wrap.h +++ b/monitor_wrap.h | |||
@@ -44,7 +44,8 @@ int mm_is_monitor(void); | |||
44 | DH *mm_choose_dh(int, int, int); | 44 | DH *mm_choose_dh(int, int, int); |
45 | int mm_sshkey_sign(struct ssh *, struct sshkey *, u_char **, size_t *, | 45 | int mm_sshkey_sign(struct ssh *, struct sshkey *, u_char **, size_t *, |
46 | const u_char *, size_t, const char *, u_int compat); | 46 | const u_char *, size_t, const char *, u_int compat); |
47 | void mm_inform_authserv(char *, char *); | 47 | void mm_inform_authserv(char *, char *, char *); |
48 | void mm_inform_authrole(char *); | ||
48 | struct passwd *mm_getpwnamallow(struct ssh *, const char *); | 49 | struct passwd *mm_getpwnamallow(struct ssh *, const char *); |
49 | char *mm_auth2_read_banner(void); | 50 | char *mm_auth2_read_banner(void); |
50 | int mm_auth_password(struct ssh *, char *); | 51 | int mm_auth_password(struct ssh *, char *); |
diff --git a/openbsd-compat/port-linux.c b/openbsd-compat/port-linux.c index 622988822..3e6e07670 100644 --- a/openbsd-compat/port-linux.c +++ b/openbsd-compat/port-linux.c | |||
@@ -56,7 +56,7 @@ ssh_selinux_enabled(void) | |||
56 | 56 | ||
57 | /* Return the default security context for the given username */ | 57 | /* Return the default security context for the given username */ |
58 | static security_context_t | 58 | static security_context_t |
59 | ssh_selinux_getctxbyname(char *pwname) | 59 | ssh_selinux_getctxbyname(char *pwname, const char *role) |
60 | { | 60 | { |
61 | security_context_t sc = NULL; | 61 | security_context_t sc = NULL; |
62 | char *sename = NULL, *lvl = NULL; | 62 | char *sename = NULL, *lvl = NULL; |
@@ -71,9 +71,16 @@ ssh_selinux_getctxbyname(char *pwname) | |||
71 | #endif | 71 | #endif |
72 | 72 | ||
73 | #ifdef HAVE_GET_DEFAULT_CONTEXT_WITH_LEVEL | 73 | #ifdef HAVE_GET_DEFAULT_CONTEXT_WITH_LEVEL |
74 | r = get_default_context_with_level(sename, lvl, NULL, &sc); | 74 | if (role != NULL && role[0]) |
75 | r = get_default_context_with_rolelevel(sename, role, lvl, NULL, | ||
76 | &sc); | ||
77 | else | ||
78 | r = get_default_context_with_level(sename, lvl, NULL, &sc); | ||
75 | #else | 79 | #else |
76 | r = get_default_context(sename, NULL, &sc); | 80 | if (role != NULL && role[0]) |
81 | r = get_default_context_with_role(sename, role, NULL, &sc); | ||
82 | else | ||
83 | r = get_default_context(sename, NULL, &sc); | ||
77 | #endif | 84 | #endif |
78 | 85 | ||
79 | if (r != 0) { | 86 | if (r != 0) { |
@@ -103,7 +110,7 @@ ssh_selinux_getctxbyname(char *pwname) | |||
103 | 110 | ||
104 | /* Set the execution context to the default for the specified user */ | 111 | /* Set the execution context to the default for the specified user */ |
105 | void | 112 | void |
106 | ssh_selinux_setup_exec_context(char *pwname) | 113 | ssh_selinux_setup_exec_context(char *pwname, const char *role) |
107 | { | 114 | { |
108 | security_context_t user_ctx = NULL; | 115 | security_context_t user_ctx = NULL; |
109 | 116 | ||
@@ -112,7 +119,7 @@ ssh_selinux_setup_exec_context(char *pwname) | |||
112 | 119 | ||
113 | debug3("%s: setting execution context", __func__); | 120 | debug3("%s: setting execution context", __func__); |
114 | 121 | ||
115 | user_ctx = ssh_selinux_getctxbyname(pwname); | 122 | user_ctx = ssh_selinux_getctxbyname(pwname, role); |
116 | if (setexeccon(user_ctx) != 0) { | 123 | if (setexeccon(user_ctx) != 0) { |
117 | switch (security_getenforce()) { | 124 | switch (security_getenforce()) { |
118 | case -1: | 125 | case -1: |
@@ -134,7 +141,7 @@ ssh_selinux_setup_exec_context(char *pwname) | |||
134 | 141 | ||
135 | /* Set the TTY context for the specified user */ | 142 | /* Set the TTY context for the specified user */ |
136 | void | 143 | void |
137 | ssh_selinux_setup_pty(char *pwname, const char *tty) | 144 | ssh_selinux_setup_pty(char *pwname, const char *tty, const char *role) |
138 | { | 145 | { |
139 | security_context_t new_tty_ctx = NULL; | 146 | security_context_t new_tty_ctx = NULL; |
140 | security_context_t user_ctx = NULL; | 147 | security_context_t user_ctx = NULL; |
@@ -146,7 +153,7 @@ ssh_selinux_setup_pty(char *pwname, const char *tty) | |||
146 | 153 | ||
147 | debug3("%s: setting TTY context on %s", __func__, tty); | 154 | debug3("%s: setting TTY context on %s", __func__, tty); |
148 | 155 | ||
149 | user_ctx = ssh_selinux_getctxbyname(pwname); | 156 | user_ctx = ssh_selinux_getctxbyname(pwname, role); |
150 | 157 | ||
151 | /* XXX: should these calls fatal() upon failure in enforcing mode? */ | 158 | /* XXX: should these calls fatal() upon failure in enforcing mode? */ |
152 | 159 | ||
diff --git a/openbsd-compat/port-linux.h b/openbsd-compat/port-linux.h index 3c22a854d..c88129428 100644 --- a/openbsd-compat/port-linux.h +++ b/openbsd-compat/port-linux.h | |||
@@ -19,8 +19,8 @@ | |||
19 | 19 | ||
20 | #ifdef WITH_SELINUX | 20 | #ifdef WITH_SELINUX |
21 | int ssh_selinux_enabled(void); | 21 | int ssh_selinux_enabled(void); |
22 | void ssh_selinux_setup_pty(char *, const char *); | 22 | void ssh_selinux_setup_pty(char *, const char *, const char *); |
23 | void ssh_selinux_setup_exec_context(char *); | 23 | void ssh_selinux_setup_exec_context(char *, const char *); |
24 | void ssh_selinux_change_context(const char *); | 24 | void ssh_selinux_change_context(const char *); |
25 | void ssh_selinux_setfscreatecon(const char *); | 25 | void ssh_selinux_setfscreatecon(const char *); |
26 | #endif | 26 | #endif |
diff --git a/platform.c b/platform.c index 41acc9370..35654ea51 100644 --- a/platform.c +++ b/platform.c | |||
@@ -142,7 +142,7 @@ platform_setusercontext(struct passwd *pw) | |||
142 | * called if sshd is running as root. | 142 | * called if sshd is running as root. |
143 | */ | 143 | */ |
144 | void | 144 | void |
145 | platform_setusercontext_post_groups(struct passwd *pw) | 145 | platform_setusercontext_post_groups(struct passwd *pw, const char *role) |
146 | { | 146 | { |
147 | #if !defined(HAVE_LOGIN_CAP) && defined(USE_PAM) | 147 | #if !defined(HAVE_LOGIN_CAP) && defined(USE_PAM) |
148 | /* | 148 | /* |
@@ -183,7 +183,7 @@ platform_setusercontext_post_groups(struct passwd *pw) | |||
183 | } | 183 | } |
184 | #endif /* HAVE_SETPCRED */ | 184 | #endif /* HAVE_SETPCRED */ |
185 | #ifdef WITH_SELINUX | 185 | #ifdef WITH_SELINUX |
186 | ssh_selinux_setup_exec_context(pw->pw_name); | 186 | ssh_selinux_setup_exec_context(pw->pw_name, role); |
187 | #endif | 187 | #endif |
188 | } | 188 | } |
189 | 189 | ||
diff --git a/platform.h b/platform.h index ea4f9c584..60d72ffe7 100644 --- a/platform.h +++ b/platform.h | |||
@@ -25,7 +25,7 @@ void platform_post_fork_parent(pid_t child_pid); | |||
25 | void platform_post_fork_child(void); | 25 | void platform_post_fork_child(void); |
26 | int platform_privileged_uidswap(void); | 26 | int platform_privileged_uidswap(void); |
27 | void platform_setusercontext(struct passwd *); | 27 | void platform_setusercontext(struct passwd *); |
28 | void platform_setusercontext_post_groups(struct passwd *); | 28 | void platform_setusercontext_post_groups(struct passwd *, const char *); |
29 | char *platform_get_krb5_client(const char *); | 29 | char *platform_get_krb5_client(const char *); |
30 | char *platform_krb5_get_principal_name(const char *); | 30 | char *platform_krb5_get_principal_name(const char *); |
31 | int platform_sys_dir_uid(uid_t); | 31 | int platform_sys_dir_uid(uid_t); |
@@ -1356,7 +1356,7 @@ safely_chroot(const char *path, uid_t uid) | |||
1356 | 1356 | ||
1357 | /* Set login name, uid, gid, and groups. */ | 1357 | /* Set login name, uid, gid, and groups. */ |
1358 | void | 1358 | void |
1359 | do_setusercontext(struct passwd *pw) | 1359 | do_setusercontext(struct passwd *pw, const char *role) |
1360 | { | 1360 | { |
1361 | char uidstr[32], *chroot_path, *tmp; | 1361 | char uidstr[32], *chroot_path, *tmp; |
1362 | 1362 | ||
@@ -1384,7 +1384,7 @@ do_setusercontext(struct passwd *pw) | |||
1384 | endgrent(); | 1384 | endgrent(); |
1385 | #endif | 1385 | #endif |
1386 | 1386 | ||
1387 | platform_setusercontext_post_groups(pw); | 1387 | platform_setusercontext_post_groups(pw, role); |
1388 | 1388 | ||
1389 | if (!in_chroot && options.chroot_directory != NULL && | 1389 | if (!in_chroot && options.chroot_directory != NULL && |
1390 | strcasecmp(options.chroot_directory, "none") != 0) { | 1390 | strcasecmp(options.chroot_directory, "none") != 0) { |
@@ -1525,7 +1525,7 @@ do_child(struct ssh *ssh, Session *s, const char *command) | |||
1525 | 1525 | ||
1526 | /* Force a password change */ | 1526 | /* Force a password change */ |
1527 | if (s->authctxt->force_pwchange) { | 1527 | if (s->authctxt->force_pwchange) { |
1528 | do_setusercontext(pw); | 1528 | do_setusercontext(pw, s->authctxt->role); |
1529 | child_close_fds(ssh); | 1529 | child_close_fds(ssh); |
1530 | do_pwchange(s); | 1530 | do_pwchange(s); |
1531 | exit(1); | 1531 | exit(1); |
@@ -1543,7 +1543,7 @@ do_child(struct ssh *ssh, Session *s, const char *command) | |||
1543 | /* When PAM is enabled we rely on it to do the nologin check */ | 1543 | /* When PAM is enabled we rely on it to do the nologin check */ |
1544 | if (!options.use_pam) | 1544 | if (!options.use_pam) |
1545 | do_nologin(pw); | 1545 | do_nologin(pw); |
1546 | do_setusercontext(pw); | 1546 | do_setusercontext(pw, s->authctxt->role); |
1547 | /* | 1547 | /* |
1548 | * PAM session modules in do_setusercontext may have | 1548 | * PAM session modules in do_setusercontext may have |
1549 | * generated messages, so if this in an interactive | 1549 | * generated messages, so if this in an interactive |
@@ -1942,7 +1942,7 @@ session_pty_req(struct ssh *ssh, Session *s) | |||
1942 | sshpkt_fatal(ssh, r, "%s: parse packet", __func__); | 1942 | sshpkt_fatal(ssh, r, "%s: parse packet", __func__); |
1943 | 1943 | ||
1944 | if (!use_privsep) | 1944 | if (!use_privsep) |
1945 | pty_setowner(s->pw, s->tty); | 1945 | pty_setowner(s->pw, s->tty, s->authctxt->role); |
1946 | 1946 | ||
1947 | /* Set window size from the packet. */ | 1947 | /* Set window size from the packet. */ |
1948 | pty_change_window_size(s->ptyfd, s->row, s->col, s->xpixel, s->ypixel); | 1948 | pty_change_window_size(s->ptyfd, s->row, s->col, s->xpixel, s->ypixel); |
@@ -77,7 +77,7 @@ void session_pty_cleanup2(Session *); | |||
77 | Session *session_new(void); | 77 | Session *session_new(void); |
78 | Session *session_by_tty(char *); | 78 | Session *session_by_tty(char *); |
79 | void session_close(struct ssh *, Session *); | 79 | void session_close(struct ssh *, Session *); |
80 | void do_setusercontext(struct passwd *); | 80 | void do_setusercontext(struct passwd *, const char *); |
81 | 81 | ||
82 | const char *session_get_remote_name_or_ip(struct ssh *, u_int, int); | 82 | const char *session_get_remote_name_or_ip(struct ssh *, u_int, int); |
83 | 83 | ||
@@ -594,7 +594,7 @@ privsep_postauth(struct ssh *ssh, Authctxt *authctxt) | |||
594 | reseed_prngs(); | 594 | reseed_prngs(); |
595 | 595 | ||
596 | /* Drop privileges */ | 596 | /* Drop privileges */ |
597 | do_setusercontext(authctxt->pw); | 597 | do_setusercontext(authctxt->pw, authctxt->role); |
598 | 598 | ||
599 | skip: | 599 | skip: |
600 | /* It is safe now to apply the key state */ | 600 | /* It is safe now to apply the key state */ |
@@ -162,7 +162,7 @@ pty_change_window_size(int ptyfd, u_int row, u_int col, | |||
162 | } | 162 | } |
163 | 163 | ||
164 | void | 164 | void |
165 | pty_setowner(struct passwd *pw, const char *tty) | 165 | pty_setowner(struct passwd *pw, const char *tty, const char *role) |
166 | { | 166 | { |
167 | struct group *grp; | 167 | struct group *grp; |
168 | gid_t gid; | 168 | gid_t gid; |
@@ -184,7 +184,7 @@ pty_setowner(struct passwd *pw, const char *tty) | |||
184 | strerror(errno)); | 184 | strerror(errno)); |
185 | 185 | ||
186 | #ifdef WITH_SELINUX | 186 | #ifdef WITH_SELINUX |
187 | ssh_selinux_setup_pty(pw->pw_name, tty); | 187 | ssh_selinux_setup_pty(pw->pw_name, tty, role); |
188 | #endif | 188 | #endif |
189 | 189 | ||
190 | if (st.st_uid != pw->pw_uid || st.st_gid != gid) { | 190 | if (st.st_uid != pw->pw_uid || st.st_gid != gid) { |
@@ -24,5 +24,5 @@ int pty_allocate(int *, int *, char *, size_t); | |||
24 | void pty_release(const char *); | 24 | void pty_release(const char *); |
25 | void pty_make_controlling_tty(int *, const char *); | 25 | void pty_make_controlling_tty(int *, const char *); |
26 | void pty_change_window_size(int, u_int, u_int, u_int, u_int); | 26 | void pty_change_window_size(int, u_int, u_int, u_int, u_int); |
27 | void pty_setowner(struct passwd *, const char *); | 27 | void pty_setowner(struct passwd *, const char *, const char *); |
28 | void disconnect_controlling_tty(void); | 28 | void disconnect_controlling_tty(void); |