_dbus_file_path_extract_elements_from_tail: don't misuse static variable
[platform/upstream/dbus.git] / dbus / dbus-auth-script.c
index d195dde..c1f0c88 100644 (file)
@@ -30,7 +30,6 @@
 #include "dbus-hash.h"
 #include "dbus-credentials.h"
 #include "dbus-internals.h"
-#include "dbus-authorization.h"
 
 /**
  * @defgroup DBusAuthScript code for running unit test scripts for DBusAuth
@@ -250,7 +249,6 @@ _dbus_auth_script_run (const DBusString *filename)
   dbus_bool_t retval;
   int line_no;
   DBusAuth *auth;
-  DBusAuthorization *authorization;
   DBusString from_auth;
   DBusAuthState state;
   DBusString context;
@@ -258,7 +256,6 @@ _dbus_auth_script_run (const DBusString *filename)
   
   retval = FALSE;
   auth = NULL;
-  authorization = NULL;
 
   _dbus_string_init_const (&guid, "5fa01f4202cd837709a3274ca0df9d00");
   _dbus_string_init_const (&context, "org_freedesktop_test");
@@ -376,24 +373,32 @@ _dbus_auth_script_run (const DBusString *filename)
               goto out;
             }
 
+          /* test ref/unref */
+          _dbus_auth_ref (auth);
+          _dbus_auth_unref (auth);
+
           creds = _dbus_credentials_new_from_current_process ();
           if (creds == NULL)
             {
               _dbus_warn ("no memory for credentials\n");
+              _dbus_auth_unref (auth);
+              auth = NULL;
               goto out;
             }
               
           if (!_dbus_auth_set_credentials (auth, creds))
             {
               _dbus_warn ("no memory for setting credentials\n");
+              _dbus_auth_unref (auth);
+              auth = NULL;
               _dbus_credentials_unref (creds);
               goto out;
             }
           
           _dbus_credentials_unref (creds);
         }
-      else if (_dbus_string_starts_with_c_str (&line, "SERVER") ||
-               _dbus_string_starts_with_c_str (&line, "SERVER_ANONYMOUS"))
+      else if (_dbus_string_starts_with_c_str (&line,
+                                               "SERVER"))
         {
           DBusCredentials *creds;
           
@@ -403,35 +408,31 @@ _dbus_auth_script_run (const DBusString *filename)
               goto out;
             }
 
-          /* empty authorization, it will use default rules */
-          authorization = _dbus_authorization_new ();
-          if (authorization == NULL)
-            {
-              _dbus_warn ("no memory to create DBusAuthorization\n");
-              goto out;
-            }
-          /* if we are testing an anonymous server, we need to enable
-           * anonymous authorization, or the mech will REJECT */
-          if (_dbus_string_starts_with_c_str (&line, "SERVER_ANONYMOUS"))
-            _dbus_authorization_set_allow_anonymous (authorization, TRUE);
-
-          auth = _dbus_auth_server_new (&guid, authorization);
+          auth = _dbus_auth_server_new (&guid);
           if (auth == NULL)
             {
               _dbus_warn ("no memory to create DBusAuth\n");
               goto out;
             }
 
+          /* test ref/unref */
+          _dbus_auth_ref (auth);
+          _dbus_auth_unref (auth);
+
           creds = _dbus_credentials_new_from_current_process ();
           if (creds == NULL)
             {
               _dbus_warn ("no memory for credentials\n");
+              _dbus_auth_unref (auth);
+              auth = NULL;
               goto out;
             }
               
           if (!_dbus_auth_set_credentials (auth, creds))
             {
               _dbus_warn ("no memory for setting credentials\n");
+              _dbus_auth_unref (auth);
+              auth = NULL;
               _dbus_credentials_unref (creds);
               goto out;
             }
@@ -789,9 +790,7 @@ _dbus_auth_script_run (const DBusString *filename)
   
  out:
   if (auth)
-    _dbus_auth_free (auth);
-  if (authorization)
-    _dbus_authorization_free (authorization);
+    _dbus_auth_unref (auth);
 
   _dbus_string_free (&file);
   _dbus_string_free (&line);