Merge "Optional autogen.sh flag --enable-kdbus-transport added allowing to compile...
[platform/upstream/dbus.git] / dbus / dbus-auth.c
index 35efa3a..86e3223 100644 (file)
@@ -2,6 +2,7 @@
 /* dbus-auth.c Authentication
  *
  * Copyright (C) 2002, 2003, 2004 Red Hat Inc.
+ * Copyright (C) 2013  Samsung Electronics
  *
  * Licensed under the Academic Free License version 2.1
  * 
@@ -30,7 +31,6 @@
 #include "dbus-sha.h"
 #include "dbus-protocol.h"
 #include "dbus-credentials.h"
-#include "dbus-authorization.h"
 
 /**
  * @defgroup DBusAuth Authentication
@@ -214,8 +214,6 @@ typedef struct
 {
   DBusAuth base;    /**< Parent class */
 
-  DBusAuthorization *authorization;             /* DBus Authorization callbacks */
-
   int failures;     /**< Number of times client has been rejected */
   int max_failures; /**< Number of times we reject before disconnect */
 
@@ -1118,26 +1116,12 @@ handle_server_data_external_mech (DBusAuth         *auth,
                                              DBUS_CREDENTIAL_ADT_AUDIT_DATA_ID,
                                              auth->credentials))
         return FALSE;
+      
+      if (!send_ok (auth))
+        return FALSE;
 
-      /* 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));
+      _dbus_verbose ("%s: authenticated client based on socket credentials\n",
+                     DBUS_AUTH_NAME (auth));
 
       return TRUE;
     }
@@ -2261,8 +2245,7 @@ process_command (DBusAuth *auth)
  * @returns the new object or #NULL if no memory
  */
 DBusAuth*
-_dbus_auth_server_new (const DBusString *guid,
-    DBusAuthorization *authorization)
+_dbus_auth_server_new (const DBusString *guid)
 {
   DBusAuth *auth;
   DBusAuthServer *server_auth;
@@ -2290,8 +2273,7 @@ _dbus_auth_server_new (const DBusString *guid,
   server_auth = DBUS_AUTH_SERVER (auth);
 
   server_auth->guid = guid_copy;
-  server_auth->authorization = _dbus_authorization_ref (authorization);
-
+  
   /* perhaps this should be per-mechanism with a lower
    * max
    */
@@ -2340,6 +2322,49 @@ _dbus_auth_client_new (void)
   return auth;
 }
 
+#ifdef ENABLE_KDBUS_TRANSPORT
+/**
+ * Creates a new auth conversation object for the client side of kdbus.
+ * In fact it only initialize structures and sets authenticated state
+ * because of different authentication-like mechanism in kdbus - policies
+ * TODO Probably to be checked and modified when kdbus will be documented
+ *
+ * @returns the new object or #NULL if no memory
+ */
+DBusAuth*
+_dbus_auth_client_new_kdbus (void)
+{
+  DBusAuth *auth;
+  DBusString guid_str;
+
+  if (!_dbus_string_init (&guid_str))
+    return NULL;
+
+  auth = _dbus_auth_new (sizeof (DBusAuthClient));
+  if (auth == NULL)
+    {
+      _dbus_string_free (&guid_str);
+      return NULL;
+    }
+
+  DBUS_AUTH_CLIENT (auth)->guid_from_server = guid_str;
+
+  auth->side = auth_side_client;
+  auth->state = &common_state_authenticated;
+  auth->unix_fd_negotiated = TRUE;
+
+  /* Start the auth conversation by sending AUTH for our default
+   * mechanism */
+/*  if (!send_auth (auth, &all_mechanisms[0]))
+    {
+      _dbus_auth_unref (auth);
+      return NULL;
+    }*/
+
+  return auth;
+}
+#endif
+
 /**
  * Increments the refcount of an auth object.
  *
@@ -2382,7 +2407,6 @@ _dbus_auth_unref (DBusAuth *auth)
           _dbus_assert (DBUS_AUTH_IS_SERVER (auth));
 
           _dbus_string_free (& DBUS_AUTH_SERVER (auth)->guid);
-          _dbus_authorization_unref (DBUS_AUTH_SERVER (auth)->authorization);
         }
 
       if (auth->keyring)