summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2013-10-11 09:47:31 +0200
committerKay Sievers <kay@vrfy.org>2013-10-11 10:16:41 +0200
commit9a4e038c1519d836d217fac5df3722e6a02ea78d (patch)
tree62cdab0fa3da479f39317a049908ca9265d0040f /src/core
parentadcdb3747609962881301ed19636002dd34c05a0 (diff)
smack: minimize ifdef use, and move all labeling to smack-util.c
Diffstat (limited to 'src/core')
-rw-r--r--src/core/socket.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/core/socket.c b/src/core/socket.c
index 9a20b5c326..ae92408560 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -775,17 +775,13 @@ static void socket_apply_socket_options(Socket *s, int fd) {
log_warning_unit(UNIT(s)->id, "SO_REUSEPORT failed: %m");
}
-#ifdef HAVE_SMACK
- if (s->smack_ip_in && use_smack())
- if (fsetxattr(fd, "security.SMACK64IPIN", s->smack_ip_in, strlen(s->smack_ip_in), 0) < 0)
- log_error_unit(UNIT(s)->id,
- "fsetxattr(\"security.SMACK64IPIN\"): %m");
-
- if (s->smack_ip_out && use_smack())
- if (fsetxattr(fd, "security.SMACK64IPOUT", s->smack_ip_out, strlen(s->smack_ip_out), 0) < 0)
- log_error_unit(UNIT(s)->id,
- "fsetxattr(\"security.SMACK64IPOUT\"): %m");
-#endif
+ if (s->smack_ip_in)
+ if (smack_label_ip_in_fd(fd, s->smack_ip_in) < 0)
+ log_error_unit(UNIT(s)->id, "smack_label_ip_in_fd: %m");
+
+ if (s->smack_ip_out)
+ if (smack_label_ip_out_fd(fd, s->smack_ip_out) < 0)
+ log_error_unit(UNIT(s)->id, "smack_label_ip_out_fd: %m");
}
static void socket_apply_fifo_options(Socket *s, int fd) {
@@ -797,12 +793,9 @@ static void socket_apply_fifo_options(Socket *s, int fd) {
log_warning_unit(UNIT(s)->id,
"F_SETPIPE_SZ: %m");
-#ifdef HAVE_SMACK
- if (s->smack && use_smack())
- if (fsetxattr(fd, "security.SMACK64", s->smack, strlen(s->smack), 0) < 0)
- log_error_unit(UNIT(s)->id,
- "fsetxattr(\"security.SMACK64\"): %m");
-#endif
+ if (s->smack)
+ if (smack_label_fd(fd, s->smack) < 0)
+ log_error_unit(UNIT(s)->id, "smack_label_fd: %m");
}
static int fifo_address_create(