|
Petr Lautrbach |
d9e618 |
diff -up openssh-5.9p1/auth.h.role openssh-5.9p1/auth.h
|
|
Petr Lautrbach |
d9e618 |
--- openssh-5.9p1/auth.h.role 2012-02-06 17:21:26.038970656 +0100
|
|
Petr Lautrbach |
d9e618 |
+++ openssh-5.9p1/auth.h 2012-02-06 17:21:59.477033401 +0100
|
|
Petr Lautrbach |
d9e618 |
@@ -59,6 +59,9 @@ struct Authctxt {
|
|
Petr Lautrbach |
d9e618 |
char *service;
|
|
Petr Lautrbach |
d9e618 |
struct passwd *pw; /* set if 'valid' */
|
|
Petr Lautrbach |
d9e618 |
char *style;
|
|
Petr Lautrbach |
d9e618 |
+#ifdef WITH_SELINUX
|
|
Petr Lautrbach |
d9e618 |
+ char *role;
|
|
Petr Lautrbach |
d9e618 |
+#endif
|
|
Petr Lautrbach |
d9e618 |
void *kbdintctxt;
|
|
Petr Lautrbach |
d9e618 |
void *jpake_ctx;
|
|
Petr Lautrbach |
d9e618 |
#ifdef BSD_AUTH
|
|
Petr Lautrbach |
d9e618 |
diff -up openssh-5.9p1/auth-pam.c.role openssh-5.9p1/auth-pam.c
|
|
Petr Lautrbach |
d9e618 |
--- openssh-5.9p1/auth-pam.c.role 2012-02-06 17:21:25.983793983 +0100
|
|
Petr Lautrbach |
d9e618 |
+++ openssh-5.9p1/auth-pam.c 2012-02-06 17:21:59.476038868 +0100
|
|
Petr Lautrbach |
d9e618 |
@@ -1074,7 +1074,7 @@ is_pam_session_open(void)
|
|
Jan F. Chadima |
69dd72 |
* during the ssh authentication process.
|
|
Jan F. Chadima |
69dd72 |
*/
|
|
Jan F. Chadima |
69dd72 |
int
|
|
Jan F. Chadima |
69dd72 |
-do_pam_putenv(char *name, char *value)
|
|
Jan F. Chadima |
69dd72 |
+do_pam_putenv(char *name, const char *value)
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Jan F. Chadima |
69dd72 |
int ret = 1;
|
|
Jan F. Chadima |
69dd72 |
#ifdef HAVE_PAM_PUTENV
|
|
Petr Lautrbach |
d9e618 |
diff -up openssh-5.9p1/auth-pam.h.role openssh-5.9p1/auth-pam.h
|
|
Petr Lautrbach |
d9e618 |
--- openssh-5.9p1/auth-pam.h.role 2004-09-11 14:17:26.000000000 +0200
|
|
Petr Lautrbach |
d9e618 |
+++ openssh-5.9p1/auth-pam.h 2012-02-06 17:21:59.477033401 +0100
|
|
Jan F. Chadima |
69dd72 |
@@ -38,7 +38,7 @@ void do_pam_session(void);
|
|
Jan F. Chadima |
69dd72 |
void do_pam_set_tty(const char *);
|
|
Jan F. Chadima |
69dd72 |
void do_pam_setcred(int );
|
|
Jan F. Chadima |
69dd72 |
void do_pam_chauthtok(void);
|
|
Jan F. Chadima |
69dd72 |
-int do_pam_putenv(char *, char *);
|
|
Jan F. Chadima |
69dd72 |
+int do_pam_putenv(char *, const char *);
|
|
Jan F. Chadima |
69dd72 |
char ** fetch_pam_environment(void);
|
|
Jan F. Chadima |
69dd72 |
char ** fetch_pam_child_environment(void);
|
|
Jan F. Chadima |
69dd72 |
void free_pam_environment(char **);
|
|
Petr Lautrbach |
d9e618 |
diff -up openssh-5.9p1/auth1.c.role openssh-5.9p1/auth1.c
|
|
Petr Lautrbach |
d9e618 |
--- openssh-5.9p1/auth1.c.role 2012-02-06 17:21:26.016845827 +0100
|
|
Petr Lautrbach |
d9e618 |
+++ openssh-5.9p1/auth1.c 2012-02-06 17:21:59.478033396 +0100
|
|
Petr Lautrbach |
d9e618 |
@@ -468,6 +468,9 @@ do_authentication(Authctxt *authctxt)
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Jan F. Chadima |
69dd72 |
u_int ulen;
|
|
Jan F. Chadima |
69dd72 |
char *user, *style = NULL;
|
|
Jan F. Chadima |
69dd72 |
+#ifdef WITH_SELINUX
|
|
Jan F. Chadima |
69dd72 |
+ char *role=NULL;
|
|
Jan F. Chadima |
69dd72 |
+#endif
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
/* Get the name of the user that we wish to log in as. */
|
|
Jan F. Chadima |
69dd72 |
packet_read_expect(SSH_CMSG_USER);
|
|
Petr Lautrbach |
d9e618 |
@@ -476,11 +479,24 @@ do_authentication(Authctxt *authctxt)
|
|
Jan F. Chadima |
69dd72 |
user = packet_get_cstring(&ulen);
|
|
Jan F. Chadima |
69dd72 |
packet_check_eom();
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+#ifdef WITH_SELINUX
|
|
Jan F. Chadima |
69dd72 |
+ if ((role = strchr(user, '/')) != NULL)
|
|
Jan F. Chadima |
69dd72 |
+ *role++ = '\0';
|
|
Jan F. Chadima |
69dd72 |
+#endif
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
if ((style = strchr(user, ':')) != NULL)
|
|
Jan F. Chadima |
69dd72 |
*style++ = '\0';
|
|
Jan F. Chadima |
69dd72 |
+#ifdef WITH_SELINUX
|
|
Jan F. Chadima |
69dd72 |
+ else
|
|
Jan F. Chadima |
69dd72 |
+ if (role && (style = strchr(role, ':')) != NULL)
|
|
Jan F. Chadima |
69dd72 |
+ *style++ = '\0';
|
|
Jan F. Chadima |
69dd72 |
+#endif
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
authctxt->user = user;
|
|
Jan F. Chadima |
69dd72 |
authctxt->style = style;
|
|
Jan F. Chadima |
69dd72 |
+#ifdef WITH_SELINUX
|
|
Jan F. Chadima |
69dd72 |
+ authctxt->role = role;
|
|
Jan F. Chadima |
69dd72 |
+#endif
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
/* Verify that the user is a valid user. */
|
|
Jan F. Chadima |
69dd72 |
if ((authctxt->pw = PRIVSEP(getpwnamallow(user))) != NULL)
|
|
Petr Lautrbach |
d9e618 |
diff -up openssh-5.9p1/auth2.c.role openssh-5.9p1/auth2.c
|
|
Petr Lautrbach |
d9e618 |
--- openssh-5.9p1/auth2.c.role 2012-02-06 17:21:26.024976386 +0100
|
|
Petr Lautrbach |
d9e618 |
+++ openssh-5.9p1/auth2.c 2012-02-06 17:23:14.127811737 +0100
|
|
Petr Lautrbach |
d9e618 |
@@ -216,6 +216,9 @@ input_userauth_request(int type, u_int32
|
|
Petr Lautrbach |
d9e618 |
Authctxt *authctxt = ctxt;
|
|
Petr Lautrbach |
d9e618 |
Authmethod *m = NULL;
|
|
Petr Lautrbach |
d9e618 |
char *user, *service, *method, *active_methods, *style = NULL;
|
|
Petr Lautrbach |
d9e618 |
+#ifdef WITH_SELINUX
|
|
Petr Lautrbach |
d9e618 |
+ char *role = NULL;
|
|
Petr Lautrbach |
d9e618 |
+#endif
|
|
Petr Lautrbach |
d9e618 |
int authenticated = 0;
|
|
Petr Lautrbach |
d9e618 |
|
|
Petr Lautrbach |
d9e618 |
if (authctxt == NULL)
|
|
Petr Lautrbach |
d9e618 |
@@ -227,6 +230,11 @@ input_userauth_request(int type, u_int32
|
|
Petr Lautrbach |
d9e618 |
debug("userauth-request for user %s service %s method %s", user, service, method);
|
|
Petr Lautrbach |
d9e618 |
debug("attempt %d failures %d", authctxt->attempt, authctxt->failures);
|
|
Petr Lautrbach |
d9e618 |
|
|
Petr Lautrbach |
d9e618 |
+#ifdef WITH_SELINUX
|
|
Petr Lautrbach |
d9e618 |
+ if ((role = strchr(user, '/')) != NULL)
|
|
Petr Lautrbach |
d9e618 |
+ *role++ = 0;
|
|
Petr Lautrbach |
d9e618 |
+#endif
|
|
Petr Lautrbach |
d9e618 |
+
|
|
Petr Lautrbach |
d9e618 |
if ((style = strchr(user, ':')) != NULL)
|
|
Petr Lautrbach |
d9e618 |
*style++ = 0;
|
|
Petr Lautrbach |
d9e618 |
|
|
Petr Lautrbach |
d9e618 |
@@ -249,8 +257,15 @@ input_userauth_request(int type, u_int32
|
|
Petr Lautrbach |
d9e618 |
use_privsep ? " [net]" : "");
|
|
Petr Lautrbach |
d9e618 |
authctxt->service = xstrdup(service);
|
|
Petr Lautrbach |
d9e618 |
authctxt->style = style ? xstrdup(style) : NULL;
|
|
Petr Lautrbach |
d9e618 |
- if (use_privsep)
|
|
Petr Lautrbach |
d9e618 |
+#ifdef WITH_SELINUX
|
|
Petr Lautrbach |
d9e618 |
+ authctxt->role = role ? xstrdup(role) : NULL;
|
|
Petr Lautrbach |
d9e618 |
+#endif
|
|
Petr Lautrbach |
d9e618 |
+ if (use_privsep) {
|
|
Petr Lautrbach |
d9e618 |
mm_inform_authserv(service, style);
|
|
Petr Lautrbach |
d9e618 |
+#ifdef WITH_SELINUX
|
|
Petr Lautrbach |
d9e618 |
+ mm_inform_authrole(role);
|
|
Petr Lautrbach |
d9e618 |
+#endif
|
|
Petr Lautrbach |
d9e618 |
+ }
|
|
Petr Lautrbach |
d9e618 |
userauth_banner();
|
|
Petr Lautrbach |
d9e618 |
} else if (strcmp(user, authctxt->user) != 0 ||
|
|
Petr Lautrbach |
d9e618 |
strcmp(service, authctxt->service) != 0) {
|
|
Petr Lautrbach |
d9e618 |
diff -up openssh-5.9p1/auth2-gss.c.role openssh-5.9p1/auth2-gss.c
|
|
Petr Lautrbach |
d9e618 |
--- openssh-5.9p1/auth2-gss.c.role 2012-02-06 17:21:26.017853239 +0100
|
|
Petr Lautrbach |
d9e618 |
+++ openssh-5.9p1/auth2-gss.c 2012-02-06 17:21:59.479096211 +0100
|
|
Jan F. Chadima |
69dd72 |
@@ -260,6 +260,7 @@ input_gssapi_mic(int type, u_int32_t ple
|
|
Jan F. Chadima |
69dd72 |
Authctxt *authctxt = ctxt;
|
|
Jan F. Chadima |
69dd72 |
Gssctxt *gssctxt;
|
|
Jan F. Chadima |
69dd72 |
int authenticated = 0;
|
|
Jan F. Chadima |
69dd72 |
+ char *micuser;
|
|
Jan F. Chadima |
69dd72 |
Buffer b;
|
|
Jan F. Chadima |
69dd72 |
gss_buffer_desc mic, gssbuf;
|
|
Jan F. Chadima |
69dd72 |
u_int len;
|
|
Jan F. Chadima |
69dd72 |
@@ -272,7 +273,13 @@ input_gssapi_mic(int type, u_int32_t ple
|
|
Jan F. Chadima |
69dd72 |
mic.value = packet_get_string(&len;;
|
|
Jan F. Chadima |
69dd72 |
mic.length = len;
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
- ssh_gssapi_buildmic(&b, authctxt->user, authctxt->service,
|
|
Jan F. Chadima |
69dd72 |
+#ifdef WITH_SELINUX
|
|
Jan F. Chadima |
69dd72 |
+ if (authctxt->role && (strlen(authctxt->role) > 0))
|
|
Jan F. Chadima |
69dd72 |
+ xasprintf(&micuser, "%s/%s", authctxt->user, authctxt->role);
|
|
Jan F. Chadima |
69dd72 |
+ else
|
|
Jan F. Chadima |
69dd72 |
+#endif
|
|
Jan F. Chadima |
69dd72 |
+ micuser = authctxt->user;
|
|
Jan F. Chadima |
69dd72 |
+ ssh_gssapi_buildmic(&b, micuser, authctxt->service,
|
|
Jan F. Chadima |
69dd72 |
"gssapi-with-mic");
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
gssbuf.value = buffer_ptr(&b);
|
|
Jan F. Chadima |
69dd72 |
@@ -284,6 +291,8 @@ input_gssapi_mic(int type, u_int32_t ple
|
|
Jan F. Chadima |
69dd72 |
logit("GSSAPI MIC check failed");
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
buffer_free(&b);
|
|
Jan F. Chadima |
69dd72 |
+ if (micuser != authctxt->user)
|
|
Jan F. Chadima |
69dd72 |
+ xfree(micuser);
|
|
Jan F. Chadima |
69dd72 |
xfree(mic.value);
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
authctxt->postponed = 0;
|
|
Petr Lautrbach |
d9e618 |
diff -up openssh-5.9p1/auth2-hostbased.c.role openssh-5.9p1/auth2-hostbased.c
|
|
Petr Lautrbach |
d9e618 |
--- openssh-5.9p1/auth2-hostbased.c.role 2012-02-06 17:21:26.038970656 +0100
|
|
Petr Lautrbach |
d9e618 |
+++ openssh-5.9p1/auth2-hostbased.c 2012-02-06 17:21:59.479096211 +0100
|
|
Jan F. Chadima |
69dd72 |
@@ -106,7 +106,15 @@ userauth_hostbased(Authctxt *authctxt)
|
|
Jan F. Chadima |
69dd72 |
buffer_put_string(&b, session_id2, session_id2_len);
|
|
Jan F. Chadima |
69dd72 |
/* reconstruct packet */
|
|
Jan F. Chadima |
69dd72 |
buffer_put_char(&b, SSH2_MSG_USERAUTH_REQUEST);
|
|
Jan F. Chadima |
69dd72 |
- buffer_put_cstring(&b, authctxt->user);
|
|
Jan F. Chadima |
69dd72 |
+#ifdef WITH_SELINUX
|
|
Jan F. Chadima |
69dd72 |
+ if (authctxt->role) {
|
|
Jan F. Chadima |
69dd72 |
+ buffer_put_int(&b, strlen(authctxt->user)+strlen(authctxt->role)+1);
|
|
Jan F. Chadima |
69dd72 |
+ buffer_append(&b, authctxt->user, strlen(authctxt->user));
|
|
Jan F. Chadima |
69dd72 |
+ buffer_put_char(&b, '/');
|
|
Jan F. Chadima |
69dd72 |
+ buffer_append(&b, authctxt->role, strlen(authctxt->role));
|
|
Jan F. Chadima |
69dd72 |
+ } else
|
|
Jan F. Chadima |
69dd72 |
+#endif
|
|
Jan F. Chadima |
69dd72 |
+ buffer_put_cstring(&b, authctxt->user);
|
|
Jan F. Chadima |
69dd72 |
buffer_put_cstring(&b, service);
|
|
Jan F. Chadima |
69dd72 |
buffer_put_cstring(&b, "hostbased");
|
|
Jan F. Chadima |
69dd72 |
buffer_put_string(&b, pkalg, alen);
|
|
Petr Lautrbach |
d9e618 |
diff -up openssh-5.9p1/auth2-pubkey.c.role openssh-5.9p1/auth2-pubkey.c
|
|
Petr Lautrbach |
d9e618 |
--- openssh-5.9p1/auth2-pubkey.c.role 2012-02-06 17:21:26.039787441 +0100
|
|
Petr Lautrbach |
d9e618 |
+++ openssh-5.9p1/auth2-pubkey.c 2012-02-06 17:21:59.480096032 +0100
|
|
Jan F. Chadima |
69dd72 |
@@ -121,7 +121,15 @@ userauth_pubkey(Authctxt *authctxt)
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
/* reconstruct packet */
|
|
Jan F. Chadima |
69dd72 |
buffer_put_char(&b, SSH2_MSG_USERAUTH_REQUEST);
|
|
Jan F. Chadima |
69dd72 |
- buffer_put_cstring(&b, authctxt->user);
|
|
Jan F. Chadima |
69dd72 |
+#ifdef WITH_SELINUX
|
|
Jan F. Chadima |
69dd72 |
+ if (authctxt->role) {
|
|
Jan F. Chadima |
69dd72 |
+ buffer_put_int(&b, strlen(authctxt->user)+strlen(authctxt->role)+1);
|
|
Jan F. Chadima |
69dd72 |
+ buffer_append(&b, authctxt->user, strlen(authctxt->user));
|
|
Jan F. Chadima |
69dd72 |
+ buffer_put_char(&b, '/');
|
|
Jan F. Chadima |
69dd72 |
+ buffer_append(&b, authctxt->role, strlen(authctxt->role));
|
|
Jan F. Chadima |
69dd72 |
+ } else
|
|
Jan F. Chadima |
69dd72 |
+#endif
|
|
Jan F. Chadima |
69dd72 |
+ buffer_put_cstring(&b, authctxt->user);
|
|
Jan F. Chadima |
69dd72 |
buffer_put_cstring(&b,
|
|
Jan F. Chadima |
69dd72 |
datafellows & SSH_BUG_PKSERVICE ?
|
|
Jan F. Chadima |
69dd72 |
"ssh-userauth" :
|
|
Petr Lautrbach |
d9e618 |
diff -up openssh-5.9p1/monitor.c.role openssh-5.9p1/monitor.c
|
|
Petr Lautrbach |
d9e618 |
--- openssh-5.9p1/monitor.c.role 2012-02-06 17:21:26.071220592 +0100
|
|
Petr Lautrbach |
d9e618 |
+++ openssh-5.9p1/monitor.c 2012-02-06 17:21:59.481783500 +0100
|
|
Jan F. Chadima |
69dd72 |
@@ -148,6 +148,9 @@ int mm_answer_sign(int, Buffer *);
|
|
Jan F. Chadima |
69dd72 |
int mm_answer_pwnamallow(int, Buffer *);
|
|
Jan F. Chadima |
69dd72 |
int mm_answer_auth2_read_banner(int, Buffer *);
|
|
Jan F. Chadima |
69dd72 |
int mm_answer_authserv(int, Buffer *);
|
|
Jan F. Chadima |
69dd72 |
+#ifdef WITH_SELINUX
|
|
Jan F. Chadima |
69dd72 |
+int mm_answer_authrole(int, Buffer *);
|
|
Jan F. Chadima |
69dd72 |
+#endif
|
|
Jan F. Chadima |
69dd72 |
int mm_answer_authpassword(int, Buffer *);
|
|
Jan F. Chadima |
69dd72 |
int mm_answer_bsdauthquery(int, Buffer *);
|
|
Jan F. Chadima |
69dd72 |
int mm_answer_bsdauthrespond(int, Buffer *);
|
|
Petr Lautrbach |
d9e618 |
@@ -232,6 +235,9 @@ struct mon_table mon_dispatch_proto20[]
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_SIGN, MON_ONCE, mm_answer_sign},
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_PWNAM, MON_ONCE, mm_answer_pwnamallow},
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUTHSERV, MON_ONCE, mm_answer_authserv},
|
|
Jan F. Chadima |
69dd72 |
+#ifdef WITH_SELINUX
|
|
Jan F. Chadima |
69dd72 |
+ {MONITOR_REQ_AUTHROLE, MON_ONCE, mm_answer_authrole},
|
|
Jan F. Chadima |
69dd72 |
+#endif
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUTH2_READ_BANNER, MON_ONCE, mm_answer_auth2_read_banner},
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUTHPASSWORD, MON_AUTH, mm_answer_authpassword},
|
|
Jan F. Chadima |
69dd72 |
#ifdef USE_PAM
|
|
Petr Lautrbach |
d9e618 |
@@ -833,6 +839,9 @@ mm_answer_pwnamallow(int sock, Buffer *m
|
|
Jan F. Chadima |
69dd72 |
else {
|
|
Jan F. Chadima |
69dd72 |
/* Allow service/style information on the auth context */
|
|
Jan F. Chadima |
69dd72 |
monitor_permit(mon_dispatch, MONITOR_REQ_AUTHSERV, 1);
|
|
Jan F. Chadima |
69dd72 |
+#ifdef WITH_SELINUX
|
|
Jan F. Chadima |
69dd72 |
+ monitor_permit(mon_dispatch, MONITOR_REQ_AUTHROLE, 1);
|
|
Jan F. Chadima |
69dd72 |
+#endif
|
|
Jan F. Chadima |
69dd72 |
monitor_permit(mon_dispatch, MONITOR_REQ_AUTH2_READ_BANNER, 1);
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
#ifdef USE_PAM
|
|
Petr Lautrbach |
d9e618 |
@@ -876,6 +885,25 @@ mm_answer_authserv(int sock, Buffer *m)
|
|
Jan F. Chadima |
69dd72 |
return (0);
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+#ifdef WITH_SELINUX
|
|
Jan F. Chadima |
69dd72 |
+int
|
|
Jan F. Chadima |
69dd72 |
+mm_answer_authrole(int sock, Buffer *m)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ monitor_permit_authentications(1);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ authctxt->role = buffer_get_string(m, NULL);
|
|
Jan F. Chadima |
69dd72 |
+ debug3("%s: role=%s",
|
|
Jan F. Chadima |
69dd72 |
+ __func__, authctxt->role);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ if (strlen(authctxt->role) == 0) {
|
|
Jan F. Chadima |
69dd72 |
+ xfree(authctxt->role);
|
|
Jan F. Chadima |
69dd72 |
+ authctxt->role = NULL;
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ return (0);
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
+#endif
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
int
|
|
Jan F. Chadima |
69dd72 |
mm_answer_authpassword(int sock, Buffer *m)
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Petr Lautrbach |
d9e618 |
@@ -1252,7 +1280,7 @@ static int
|
|
Jan F. Chadima |
69dd72 |
monitor_valid_userblob(u_char *data, u_int datalen)
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Jan F. Chadima |
69dd72 |
Buffer b;
|
|
Jan F. Chadima |
69dd72 |
- char *p;
|
|
Jan F. Chadima |
69dd72 |
+ char *p, *r;
|
|
Jan F. Chadima |
69dd72 |
u_int len;
|
|
Jan F. Chadima |
69dd72 |
int fail = 0;
|
|
Jan F. Chadima |
69dd72 |
|
|
Petr Lautrbach |
d9e618 |
@@ -1278,6 +1306,8 @@ monitor_valid_userblob(u_char *data, u_i
|
|
Jan F. Chadima |
69dd72 |
if (buffer_get_char(&b) != SSH2_MSG_USERAUTH_REQUEST)
|
|
Jan F. Chadima |
69dd72 |
fail++;
|
|
Jan F. Chadima |
69dd72 |
p = buffer_get_string(&b, NULL);
|
|
Jan F. Chadima |
69dd72 |
+ if ((r = strchr(p, '/')) != NULL)
|
|
Jan F. Chadima |
69dd72 |
+ *r = '\0';
|
|
Jan F. Chadima |
69dd72 |
if (strcmp(authctxt->user, p) != 0) {
|
|
Jan F. Chadima |
69dd72 |
logit("wrong user name passed to monitor: expected %s != %.100s",
|
|
Jan F. Chadima |
69dd72 |
authctxt->user, p);
|
|
Petr Lautrbach |
d9e618 |
@@ -1309,7 +1339,7 @@ monitor_valid_hostbasedblob(u_char *data
|
|
Jan F. Chadima |
69dd72 |
char *chost)
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Jan F. Chadima |
69dd72 |
Buffer b;
|
|
Jan F. Chadima |
69dd72 |
- char *p;
|
|
Jan F. Chadima |
69dd72 |
+ char *p, *r;
|
|
Jan F. Chadima |
69dd72 |
u_int len;
|
|
Jan F. Chadima |
69dd72 |
int fail = 0;
|
|
Jan F. Chadima |
69dd72 |
|
|
Petr Lautrbach |
d9e618 |
@@ -1326,6 +1356,8 @@ monitor_valid_hostbasedblob(u_char *data
|
|
Jan F. Chadima |
69dd72 |
if (buffer_get_char(&b) != SSH2_MSG_USERAUTH_REQUEST)
|
|
Jan F. Chadima |
69dd72 |
fail++;
|
|
Jan F. Chadima |
69dd72 |
p = buffer_get_string(&b, NULL);
|
|
Jan F. Chadima |
69dd72 |
+ if ((r = strchr(p, '/')) != NULL)
|
|
Jan F. Chadima |
69dd72 |
+ *r = '\0';
|
|
Jan F. Chadima |
69dd72 |
if (strcmp(authctxt->user, p) != 0) {
|
|
Jan F. Chadima |
69dd72 |
logit("wrong user name passed to monitor: expected %s != %.100s",
|
|
Jan F. Chadima |
69dd72 |
authctxt->user, p);
|
|
Petr Lautrbach |
d9e618 |
diff -up openssh-5.9p1/monitor.h.role openssh-5.9p1/monitor.h
|
|
Petr Lautrbach |
d9e618 |
--- openssh-5.9p1/monitor.h.role 2012-02-06 17:21:26.071852220 +0100
|
|
Petr Lautrbach |
d9e618 |
+++ openssh-5.9p1/monitor.h 2012-02-06 17:21:59.482846081 +0100
|
|
Jan F. Chadima |
69dd72 |
@@ -31,6 +31,9 @@
|
|
Jan F. Chadima |
69dd72 |
enum monitor_reqtype {
|
|
Jan F. Chadima |
69dd72 |
MONITOR_REQ_MODULI, MONITOR_ANS_MODULI,
|
|
Jan F. Chadima |
69dd72 |
MONITOR_REQ_FREE, MONITOR_REQ_AUTHSERV,
|
|
Jan F. Chadima |
69dd72 |
+#ifdef WITH_SELINUX
|
|
Jan F. Chadima |
69dd72 |
+ MONITOR_REQ_AUTHROLE,
|
|
Jan F. Chadima |
69dd72 |
+#endif
|
|
Jan F. Chadima |
69dd72 |
MONITOR_REQ_SIGN, MONITOR_ANS_SIGN,
|
|
Jan F. Chadima |
69dd72 |
MONITOR_REQ_PWNAM, MONITOR_ANS_PWNAM,
|
|
Jan F. Chadima |
69dd72 |
MONITOR_REQ_AUTH2_READ_BANNER, MONITOR_ANS_AUTH2_READ_BANNER,
|
|
Petr Lautrbach |
d9e618 |
diff -up openssh-5.9p1/monitor_wrap.c.role openssh-5.9p1/monitor_wrap.c
|
|
Petr Lautrbach |
d9e618 |
--- openssh-5.9p1/monitor_wrap.c.role 2012-02-06 17:21:26.071852220 +0100
|
|
Petr Lautrbach |
d9e618 |
+++ openssh-5.9p1/monitor_wrap.c 2012-02-06 17:21:59.483845610 +0100
|
|
Jan F. Chadima |
69dd72 |
@@ -336,6 +336,25 @@ mm_inform_authserv(char *service, char *
|
|
Jan F. Chadima |
69dd72 |
buffer_free(&m);
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+/* Inform the privileged process about role */
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+#ifdef WITH_SELINUX
|
|
Jan F. Chadima |
69dd72 |
+void
|
|
Jan F. Chadima |
69dd72 |
+mm_inform_authrole(char *role)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ Buffer m;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ debug3("%s entering", __func__);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ buffer_init(&m);
|
|
Jan F. Chadima |
69dd72 |
+ buffer_put_cstring(&m, role ? role : "");
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTHROLE, &m);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ buffer_free(&m);
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
+#endif
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
/* Do the password authentication */
|
|
Jan F. Chadima |
69dd72 |
int
|
|
Jan F. Chadima |
69dd72 |
mm_auth_password(Authctxt *authctxt, char *password)
|
|
Petr Lautrbach |
d9e618 |
diff -up openssh-5.9p1/monitor_wrap.h.role openssh-5.9p1/monitor_wrap.h
|
|
Petr Lautrbach |
d9e618 |
--- openssh-5.9p1/monitor_wrap.h.role 2012-02-06 17:21:26.073192915 +0100
|
|
Petr Lautrbach |
d9e618 |
+++ openssh-5.9p1/monitor_wrap.h 2012-02-06 17:21:59.483845610 +0100
|
|
Jan F. Chadima |
69dd72 |
@@ -42,6 +42,9 @@ int mm_is_monitor(void);
|
|
Jan F. Chadima |
69dd72 |
DH *mm_choose_dh(int, int, int);
|
|
Jan F. Chadima |
69dd72 |
int mm_key_sign(Key *, u_char **, u_int *, u_char *, u_int);
|
|
Jan F. Chadima |
69dd72 |
void mm_inform_authserv(char *, char *);
|
|
Jan F. Chadima |
69dd72 |
+#ifdef WITH_SELINUX
|
|
Jan F. Chadima |
69dd72 |
+void mm_inform_authrole(char *);
|
|
Jan F. Chadima |
69dd72 |
+#endif
|
|
Jan F. Chadima |
69dd72 |
struct passwd *mm_getpwnamallow(const char *);
|
|
Jan F. Chadima |
69dd72 |
char *mm_auth2_read_banner(void);
|
|
Jan F. Chadima |
69dd72 |
int mm_auth_password(struct Authctxt *, char *);
|
|
Petr Lautrbach |
d9e618 |
diff -up openssh-5.9p1/openbsd-compat/Makefile.in.role openssh-5.9p1/openbsd-compat/Makefile.in
|
|
Petr Lautrbach |
d9e618 |
--- openssh-5.9p1/openbsd-compat/Makefile.in.role 2010-10-07 13:19:24.000000000 +0200
|
|
Petr Lautrbach |
d9e618 |
+++ openssh-5.9p1/openbsd-compat/Makefile.in 2012-02-06 17:21:59.484846191 +0100
|
|
Jan F. Chadima |
69dd72 |
@@ -20,7 +20,7 @@ OPENBSD=base64.o basename.o bindresvport
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
COMPAT=bsd-arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-poll.o bsd-snprintf.o bsd-statvfs.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xmmap.o xcrypt.o
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
-PORTS=port-aix.o port-irix.o port-linux.o port-solaris.o port-tun.o port-uw.o
|
|
Jan F. Chadima |
69dd72 |
+PORTS=port-aix.o port-irix.o port-linux.o port-linux_part_2.o port-solaris.o port-tun.o port-uw.o
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
.c.o:
|
|
Jan F. Chadima |
69dd72 |
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
|
|
Petr Lautrbach |
d9e618 |
diff -up openssh-5.9p1/openbsd-compat/port-linux.c.role openssh-5.9p1/openbsd-compat/port-linux.c
|
|
Petr Lautrbach |
d9e618 |
--- openssh-5.9p1/openbsd-compat/port-linux.c.role 2011-08-29 08:09:57.000000000 +0200
|
|
Petr Lautrbach |
d9e618 |
+++ openssh-5.9p1/openbsd-compat/port-linux.c 2012-02-06 17:21:59.484846191 +0100
|
|
Jan F. Chadima |
69dd72 |
@@ -31,7 +31,11 @@
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
#include "log.h"
|
|
Jan F. Chadima |
69dd72 |
#include "xmalloc.h"
|
|
Jan F. Chadima |
69dd72 |
+#include "servconf.h"
|
|
Jan F. Chadima |
69dd72 |
#include "port-linux.h"
|
|
Jan F. Chadima |
69dd72 |
+#include "key.h"
|
|
Jan F. Chadima |
69dd72 |
+#include "hostfile.h"
|
|
Jan F. Chadima |
69dd72 |
+#include "auth.h"
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
#ifdef WITH_SELINUX
|
|
Jan F. Chadima |
69dd72 |
#include <selinux/selinux.h>
|
|
Jan F. Chadima |
69dd72 |
@@ -42,41 +46,63 @@
|
|
Jan F. Chadima |
69dd72 |
# define SSH_SELINUX_UNCONFINED_TYPE ":unconfined_t:"
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
-/* Wrapper around is_selinux_enabled() to log its return value once only */
|
|
Jan F. Chadima |
69dd72 |
-int
|
|
Jan F. Chadima |
69dd72 |
-ssh_selinux_enabled(void)
|
|
Jan F. Chadima |
69dd72 |
-{
|
|
Jan F. Chadima |
69dd72 |
- static int enabled = -1;
|
|
Jan F. Chadima |
69dd72 |
+extern ServerOptions options;
|
|
Jan F. Chadima |
69dd72 |
+extern Authctxt *the_authctxt;
|
|
Jan F. Chadima |
69dd72 |
+extern int inetd_flag;
|
|
Jan F. Chadima |
69dd72 |
+extern int rexeced_flag;
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
- if (enabled == -1) {
|
|
Jan F. Chadima |
69dd72 |
- enabled = (is_selinux_enabled() == 1);
|
|
Jan F. Chadima |
69dd72 |
- debug("SELinux support %s", enabled ? "enabled" : "disabled");
|
|
Jan F. Chadima |
69dd72 |
+static void
|
|
Jan F. Chadima |
69dd72 |
+ssh_selinux_get_role_level(char **role, const char **level)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ *role = NULL;
|
|
Jan F. Chadima |
69dd72 |
+ *level = NULL;
|
|
Jan F. Chadima |
69dd72 |
+ if (the_authctxt) {
|
|
Jan F. Chadima |
69dd72 |
+ if (the_authctxt->role != NULL) {
|
|
Jan F. Chadima |
69dd72 |
+ char *slash;
|
|
Jan F. Chadima |
69dd72 |
+ *role = xstrdup(the_authctxt->role);
|
|
Jan F. Chadima |
69dd72 |
+ if ((slash = strchr(*role, '/')) != NULL) {
|
|
Jan F. Chadima |
69dd72 |
+ *slash = '\0';
|
|
Jan F. Chadima |
69dd72 |
+ *level = slash + 1;
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
-
|
|
Jan F. Chadima |
69dd72 |
- return (enabled);
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
/* Return the default security context for the given username */
|
|
Jan F. Chadima |
69dd72 |
static security_context_t
|
|
Jan F. Chadima |
69dd72 |
ssh_selinux_getctxbyname(char *pwname)
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Jan F. Chadima |
69dd72 |
- security_context_t sc;
|
|
Jan F. Chadima |
69dd72 |
- char *sename = NULL, *lvl = NULL;
|
|
Jan F. Chadima |
69dd72 |
- int r;
|
|
Jan F. Chadima |
69dd72 |
+ security_context_t sc = NULL;
|
|
Jan F. Chadima |
69dd72 |
+ char *sename, *lvl;
|
|
Jan F. Chadima |
69dd72 |
+ char *role;
|
|
Jan F. Chadima |
69dd72 |
+ const char *reqlvl;
|
|
Jan F. Chadima |
69dd72 |
+ int r = 0;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ ssh_selinux_get_role_level(&role, &reqlvl);
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
#ifdef HAVE_GETSEUSERBYNAME
|
|
Jan F. Chadima |
69dd72 |
- if (getseuserbyname(pwname, &sename, &lvl) != 0)
|
|
Jan F. Chadima |
69dd72 |
- return NULL;
|
|
Jan F. Chadima |
69dd72 |
+ if ((r=getseuserbyname(pwname, &sename, &lvl)) != 0) {
|
|
Jan F. Chadima |
69dd72 |
+ sename = NULL;
|
|
Jan F. Chadima |
69dd72 |
+ lvl = NULL;
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
#else
|
|
Jan F. Chadima |
69dd72 |
sename = pwname;
|
|
Jan F. Chadima |
69dd72 |
lvl = NULL;
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+ if (r == 0) {
|
|
Jan F. Chadima |
69dd72 |
#ifdef HAVE_GET_DEFAULT_CONTEXT_WITH_LEVEL
|
|
Jan F. Chadima |
69dd72 |
- r = get_default_context_with_level(sename, lvl, NULL, &sc);
|
|
Jan F. Chadima |
69dd72 |
+ if (role != NULL && role[0])
|
|
Jan F. Chadima |
69dd72 |
+ r = get_default_context_with_rolelevel(sename, role, lvl, NULL, &sc);
|
|
Jan F. Chadima |
69dd72 |
+ else
|
|
Jan F. Chadima |
69dd72 |
+ r = get_default_context_with_level(sename, lvl, NULL, &sc);
|
|
Jan F. Chadima |
69dd72 |
#else
|
|
Jan F. Chadima |
69dd72 |
- r = get_default_context(sename, NULL, &sc);
|
|
Jan F. Chadima |
69dd72 |
+ if (role != NULL && role[0])
|
|
Jan F. Chadima |
69dd72 |
+ r = get_default_context_with_role(sename, role, NULL, &sc);
|
|
Jan F. Chadima |
69dd72 |
+ else
|
|
Jan F. Chadima |
69dd72 |
+ r = get_default_context(sename, NULL, &sc);
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
if (r != 0) {
|
|
Jan F. Chadima |
69dd72 |
switch (security_getenforce()) {
|
|
Jan F. Chadima |
69dd72 |
@@ -104,6 +130,36 @@ ssh_selinux_getctxbyname(char *pwname)
|
|
Jan F. Chadima |
69dd72 |
return (sc);
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+/* Setup environment variables for pam_selinux */
|
|
Jan F. Chadima |
69dd72 |
+static int
|
|
Jan F. Chadima |
69dd72 |
+ssh_selinux_setup_pam_variables(void)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ const char *reqlvl;
|
|
Jan F. Chadima |
69dd72 |
+ char *role;
|
|
Jan F. Chadima |
69dd72 |
+ char *use_current;
|
|
Jan F. Chadima |
69dd72 |
+ int rv;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ debug3("%s: setting execution context", __func__);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ ssh_selinux_get_role_level(&role, &reqlvl);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ rv = do_pam_putenv("SELINUX_ROLE_REQUESTED", role ? role : "");
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ if (inetd_flag && !rexeced_flag) {
|
|
Jan F. Chadima |
69dd72 |
+ use_current = "1";
|
|
Jan F. Chadima |
69dd72 |
+ } else {
|
|
Jan F. Chadima |
69dd72 |
+ use_current = "";
|
|
Jan F. Chadima |
69dd72 |
+ rv = rv || do_pam_putenv("SELINUX_LEVEL_REQUESTED", reqlvl ? reqlvl: "");
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ rv = rv || do_pam_putenv("SELINUX_USE_CURRENT_RANGE", use_current);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ if (role != NULL)
|
|
Jan F. Chadima |
69dd72 |
+ xfree(role);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ return rv;
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
/* Set the execution context to the default for the specified user */
|
|
Jan F. Chadima |
69dd72 |
void
|
|
Jan F. Chadima |
69dd72 |
ssh_selinux_setup_exec_context(char *pwname)
|
|
Jan F. Chadima |
69dd72 |
@@ -113,6 +169,24 @@ ssh_selinux_setup_exec_context(char *pwn
|
|
Jan F. Chadima |
69dd72 |
if (!ssh_selinux_enabled())
|
|
Jan F. Chadima |
69dd72 |
return;
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+ if (options.use_pam) {
|
|
Jan F. Chadima |
69dd72 |
+ /* do not compute context, just setup environment for pam_selinux */
|
|
Jan F. Chadima |
69dd72 |
+ if (ssh_selinux_setup_pam_variables()) {
|
|
Jan F. Chadima |
69dd72 |
+ switch (security_getenforce()) {
|
|
Jan F. Chadima |
69dd72 |
+ case -1:
|
|
Jan F. Chadima |
69dd72 |
+ fatal("%s: security_getenforce() failed", __func__);
|
|
Jan F. Chadima |
69dd72 |
+ case 0:
|
|
Jan F. Chadima |
69dd72 |
+ error("%s: SELinux PAM variable setup failure. Continuing in permissive mode.",
|
|
Jan F. Chadima |
69dd72 |
+ __func__);
|
|
Jan F. Chadima |
69dd72 |
+ break;
|
|
Jan F. Chadima |
69dd72 |
+ default:
|
|
Jan F. Chadima |
69dd72 |
+ fatal("%s: SELinux PAM variable setup failure. Aborting connection.",
|
|
Jan F. Chadima |
69dd72 |
+ __func__);
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+ return;
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
debug3("%s: setting execution context", __func__);
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
user_ctx = ssh_selinux_getctxbyname(pwname);
|
|
Jan F. Chadima |
69dd72 |
@@ -220,21 +294,6 @@ ssh_selinux_change_context(const char *n
|
|
Jan F. Chadima |
69dd72 |
xfree(newctx);
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
-void
|
|
Jan F. Chadima |
69dd72 |
-ssh_selinux_setfscreatecon(const char *path)
|
|
Jan F. Chadima |
69dd72 |
-{
|
|
Jan F. Chadima |
69dd72 |
- security_context_t context;
|
|
Jan F. Chadima |
69dd72 |
-
|
|
Jan F. Chadima |
69dd72 |
- if (!ssh_selinux_enabled())
|
|
Jan F. Chadima |
69dd72 |
- return;
|
|
Jan F. Chadima |
69dd72 |
- if (path == NULL) {
|
|
Jan F. Chadima |
69dd72 |
- setfscreatecon(NULL);
|
|
Jan F. Chadima |
69dd72 |
- return;
|
|
Jan F. Chadima |
69dd72 |
- }
|
|
Jan F. Chadima |
69dd72 |
- if (matchpathcon(path, 0700, &context) == 0)
|
|
Jan F. Chadima |
69dd72 |
- setfscreatecon(context);
|
|
Jan F. Chadima |
69dd72 |
-}
|
|
Jan F. Chadima |
69dd72 |
-
|
|
Jan F. Chadima |
69dd72 |
#endif /* WITH_SELINUX */
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
#ifdef LINUX_OOM_ADJUST
|
|
Petr Lautrbach |
d9e618 |
diff -up openssh-5.9p1/openbsd-compat/port-linux_part_2.c.role openssh-5.9p1/openbsd-compat/port-linux_part_2.c
|
|
Petr Lautrbach |
d9e618 |
--- openssh-5.9p1/openbsd-compat/port-linux_part_2.c.role 2012-02-06 17:21:59.485846294 +0100
|
|
Petr Lautrbach |
d9e618 |
+++ openssh-5.9p1/openbsd-compat/port-linux_part_2.c 2012-02-06 17:21:59.485846294 +0100
|
|
Jan F. Chadima |
69dd72 |
@@ -0,0 +1,75 @@
|
|
Jan F. Chadima |
69dd72 |
+/* $Id: port-linux.c,v 1.11.4.2 2011/02/04 00:43:08 djm Exp $ */
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+/*
|
|
Jan F. Chadima |
69dd72 |
+ * Copyright (c) 2005 Daniel Walsh <dwalsh@redhat.com>
|
|
Jan F. Chadima |
69dd72 |
+ * Copyright (c) 2006 Damien Miller <djm@openbsd.org>
|
|
Jan F. Chadima |
69dd72 |
+ *
|
|
Jan F. Chadima |
69dd72 |
+ * Permission to use, copy, modify, and distribute this software for any
|
|
Jan F. Chadima |
69dd72 |
+ * purpose with or without fee is hereby granted, provided that the above
|
|
Jan F. Chadima |
69dd72 |
+ * copyright notice and this permission notice appear in all copies.
|
|
Jan F. Chadima |
69dd72 |
+ *
|
|
Jan F. Chadima |
69dd72 |
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
Jan F. Chadima |
69dd72 |
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
Jan F. Chadima |
69dd72 |
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
Jan F. Chadima |
69dd72 |
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
Jan F. Chadima |
69dd72 |
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
Jan F. Chadima |
69dd72 |
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
Jan F. Chadima |
69dd72 |
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
Jan F. Chadima |
69dd72 |
+ */
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+/*
|
|
Jan F. Chadima |
69dd72 |
+ * Linux-specific portability code - just SELinux support at present
|
|
Jan F. Chadima |
69dd72 |
+ */
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+#include "includes.h"
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+#if defined(WITH_SELINUX) || defined(LINUX_OOM_ADJUST)
|
|
Jan F. Chadima |
69dd72 |
+#include <errno.h>
|
|
Jan F. Chadima |
69dd72 |
+#include <stdarg.h>
|
|
Jan F. Chadima |
69dd72 |
+#include <string.h>
|
|
Jan F. Chadima |
69dd72 |
+#include <stdio.h>
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+#include "log.h"
|
|
Jan F. Chadima |
69dd72 |
+#include "xmalloc.h"
|
|
Jan F. Chadima |
69dd72 |
+#include "port-linux.h"
|
|
Jan F. Chadima |
69dd72 |
+#include "key.h"
|
|
Jan F. Chadima |
69dd72 |
+#include "hostfile.h"
|
|
Jan F. Chadima |
69dd72 |
+#include "auth.h"
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+#ifdef WITH_SELINUX
|
|
Jan F. Chadima |
69dd72 |
+#include <selinux/selinux.h>
|
|
Jan F. Chadima |
69dd72 |
+#include <selinux/flask.h>
|
|
Jan F. Chadima |
69dd72 |
+#include <selinux/get_context_list.h>
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+/* Wrapper around is_selinux_enabled() to log its return value once only */
|
|
Jan F. Chadima |
69dd72 |
+int
|
|
Jan F. Chadima |
69dd72 |
+ssh_selinux_enabled(void)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ static int enabled = -1;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ if (enabled == -1) {
|
|
Jan F. Chadima |
69dd72 |
+ enabled = (is_selinux_enabled() == 1);
|
|
Jan F. Chadima |
69dd72 |
+ debug("SELinux support %s", enabled ? "enabled" : "disabled");
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ return (enabled);
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+void
|
|
Jan F. Chadima |
69dd72 |
+ssh_selinux_setfscreatecon(const char *path)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ security_context_t context;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ if (!ssh_selinux_enabled())
|
|
Jan F. Chadima |
69dd72 |
+ return;
|
|
Jan F. Chadima |
69dd72 |
+ if (path == NULL) {
|
|
Jan F. Chadima |
69dd72 |
+ setfscreatecon(NULL);
|
|
Jan F. Chadima |
69dd72 |
+ return;
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+ if (matchpathcon(path, 0700, &context) == 0)
|
|
Jan F. Chadima |
69dd72 |
+ setfscreatecon(context);
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+#endif /* WITH_SELINUX */
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+#endif /* WITH_SELINUX || LINUX_OOM_ADJUST */
|