Smack: Provide information for UDS getsockopt(SO_PEERCRED)
[linux-2.6.git] / security / smack / smack_lsm.c
index 6a82265..dab8af1 100644 (file)
@@ -2773,6 +2773,7 @@ static int smack_unix_stream_connect(struct sock *sock,
 {
        struct socket_smack *ssp = sock->sk_security;
        struct socket_smack *osp = other->sk_security;
+       struct socket_smack *nsp = newsk->sk_security;
        struct smk_audit_info ad;
        int rc = 0;
 
@@ -2782,6 +2783,14 @@ static int smack_unix_stream_connect(struct sock *sock,
        if (!capable(CAP_MAC_OVERRIDE))
                rc = smk_access(ssp->smk_out, osp->smk_in, MAY_WRITE, &ad);
 
+       /*
+        * Cross reference the peer labels for SO_PEERSEC.
+        */
+       if (rc == 0) {
+               nsp->smk_packet = ssp->smk_out;
+               ssp->smk_packet = osp->smk_out;
+       }
+
        return rc;
 }