- _dbus_verbose ("%s: authenticated client based on socket credentials\n",
- DBUS_AUTH_NAME (auth));
+ /* Do a first authorization of the transport, in order to REJECT
+ * immediately connection if needed (FDO#39720), transport will
+ * re-authorize later, but it will close the connection on fail,
+ * we want to REJECT now if possible */
+ if (_dbus_authorization_do_authorization (DBUS_AUTH_SERVER (auth)->authorization,
+ auth->authorized_identity))
+ {
+ if (!send_ok (auth))
+ return FALSE;
+ }
+ else
+ {
+ _dbus_verbose ("%s: desired identity does not match server identity: "
+ "not authorized\n", DBUS_AUTH_NAME (auth));
+ return send_rejected (auth);
+ }
+
+ _dbus_verbose ("%s: authenticated and authorized client based on "
+ "socket credentials\n", DBUS_AUTH_NAME (auth));