chiark / gitweb /
sd-bus: store selinux context at connection time
[elogind.git] / src / libelogind / sd-bus / bus-socket.c
index 8b15a743c44fccbeb60f090a55283bbd7f8a104c..e182cfacfcc394a3c8854b5fd8298f0c4e63dd68 100644 (file)
@@ -588,10 +588,17 @@ void bus_socket_setup(sd_bus *b) {
 }
 
 static void bus_get_peercred(sd_bus *b) {
+        int r;
+
         assert(b);
 
         /* Get the peer for socketpair() sockets */
         b->ucred_valid = getpeercred(b->input_fd, &b->ucred) >= 0;
+
+        /* Get the SELinux context of the peer */
+        r = getpeersec(b->input_fd, &b->label);
+        if (r < 0 && r != -EOPNOTSUPP)
+                log_debug_errno(r, "Failed to determine peer security context: %m");
 }
 
 static int bus_socket_start_auth_client(sd_bus *b) {