summaryrefslogtreecommitdiffstats
path: root/proxy/src/gp_socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'proxy/src/gp_socket.c')
-rw-r--r--proxy/src/gp_socket.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/proxy/src/gp_socket.c b/proxy/src/gp_socket.c
index 3e8afc5..f7712cf 100644
--- a/proxy/src/gp_socket.c
+++ b/proxy/src/gp_socket.c
@@ -62,33 +62,31 @@ struct gp_buffer {
size_t pos;
};
-bool gp_conn_check_selinux(struct gp_conn *conn, SELINUX_CTX ctx)
+bool gp_selinux_ctx_equal(SELINUX_CTX ctx1, SELINUX_CTX ctx2)
{
const char *ra, *rb;
- if (ctx == NULL) {
+ if (ctx1 == ctx2) {
return true;
}
-
- if (!(conn->creds.type & CRED_TYPE_SELINUX) ||
- (conn->selinux_ctx == NULL)) {
+ if (ctx1 == NULL || ctx2 == NULL) {
return false;
}
- if (strcmp(SELINUX_context_user_get(ctx),
- SELINUX_context_user_get(conn->selinux_ctx)) != 0) {
+ if (strcmp(SELINUX_context_user_get(ctx1),
+ SELINUX_context_user_get(ctx2)) != 0) {
return false;
}
- if (strcmp(SELINUX_context_role_get(ctx),
- SELINUX_context_role_get(conn->selinux_ctx)) != 0) {
+ if (strcmp(SELINUX_context_role_get(ctx1),
+ SELINUX_context_role_get(ctx2)) != 0) {
return false;
}
- if (strcmp(SELINUX_context_type_get(ctx),
- SELINUX_context_type_get(conn->selinux_ctx)) != 0) {
+ if (strcmp(SELINUX_context_type_get(ctx1),
+ SELINUX_context_type_get(ctx2)) != 0) {
return false;
}
- ra = SELINUX_context_range_get(ctx);
- rb = SELINUX_context_range_get(conn->selinux_ctx);
+ ra = SELINUX_context_range_get(ctx1);
+ rb = SELINUX_context_range_get(ctx2);
if (ra && rb && (strcmp(ra, rb) != 0)) {
return false;
}
@@ -96,6 +94,20 @@ bool gp_conn_check_selinux(struct gp_conn *conn, SELINUX_CTX ctx)
return true;
}
+bool gp_conn_check_selinux(struct gp_conn *conn, SELINUX_CTX ctx)
+{
+ if (ctx == NULL) {
+ return true;
+ }
+
+ if (!(conn->creds.type & CRED_TYPE_SELINUX) ||
+ (conn->selinux_ctx == NULL)) {
+ return false;
+ }
+
+ return gp_selinux_ctx_equal(ctx, conn->selinux_ctx);
+}
+
struct gp_creds *gp_conn_get_creds(struct gp_conn *conn)
{
return &conn->creds;