Win32 port

Peter Kümmel syntheticpp at gmx.net
Thu Jun 22 07:11:23 PDT 2006


Because of an car accident Ralf currently can't do anything for dbus.
So I've taken a look at his win32 port:
http://webdev.cegit.de/snapshots/kde-windows/dbus-win/
and will send some patches to the list.

Several changes are related to a different type of dbus_uid_t/gid_t:

#ifndef _WIN32
typedef unsigned long dbus_pid_t;
typedef unsigned long dbus_uid_t;
#else
typedef const char *dbus_uid_t;
typedef const char *dbus_gid_t;
#endif


I've prepared a patch which only changes the 'unsigned long' to
the correct uid/guid type. This patch has in principle nothing to
do with win32 and is just a renaming of types and function names,
but it makes it more easy to apply the win32 patches step by step.

Best regards,

Peter


John (J5) Palmieri wrote:
> Ralf Habacker had asked for CVS access in fd.o bugzilla so he could do a
> Win32 branch.  I asked him to go through the patch process instead.  Not
> sure if you saw the reply Ralf.  We don't really want to branch for
> this.  It should all happen in HEAD with each patch being looked at to
> make sure it doesn't change the API or ABI unless it really needs to.
> I'm afraid of a whole bunch of work being done, only to find out we
> can't apply it.
> 
> Steps here are to get a initial patch in that enables dbus to at least
> build on Win32 and get all the Win32 hackers working on the same
> codebase and sending patches to the list.  
> 
> On Tue, 2006-06-20 at 11:49 +0100, Rob Taylor wrote:
>> I'm just writing to find out the status on win32 ports of dbus. As I
>> recall, there was some work being done to tidy up Tor's patches and
>> bring them up to date, and it'd be interesting to hear any status on
>> this plan. I'd also be interested to hear if anyone's planning on
>> working on a more secure solution, perhaps using win32 pipes.
>>
>> Thanks,
>> Rob Taylor
>> _______________________________________________
>> dbus mailing list
>> dbus at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dbus
> 

-------------- next part --------------
Index: bus/bus.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/bus.c,v
retrieving revision 1.67
diff -u -b -B -r1.67 bus.c
--- bus/bus.c	7 Jun 2006 20:07:34 -0000	1.67
+++ bus/bus.c	22 Jun 2006 13:45:57 -0000
@@ -1003,7 +1003,7 @@
 
 dbus_bool_t
 bus_context_allow_user (BusContext   *context,
-                        unsigned long uid)
+                        dbus_uid_t uid)
 {
   return bus_policy_allow_user (context->policy,
                                 context->user_database,
Index: bus/bus.h
===================================================================
RCS file: /cvs/dbus/dbus/bus/bus.h,v
retrieving revision 1.27
diff -u -b -B -r1.27 bus.h
--- bus/bus.h	22 Nov 2005 20:37:00 -0000	1.27
+++ bus/bus.h	22 Jun 2006 13:45:57 -0000
@@ -89,7 +89,7 @@
 DBusUserDatabase* bus_context_get_user_database                  (BusContext       *context);
 
 dbus_bool_t       bus_context_allow_user                         (BusContext       *context,
-                                                                  unsigned long     uid);
+                                                                  dbus_uid_t        uid);
 BusPolicy*        bus_context_get_policy                         (BusContext       *context);
 
 BusClientPolicy*  bus_context_create_client_policy               (BusContext       *context,
Index: bus/config-parser.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/config-parser.c,v
retrieving revision 1.42
diff -u -b -B -r1.42 config-parser.c
--- bus/config-parser.c	15 Jun 2005 02:31:38 -0000	1.42
+++ bus/config-parser.c	22 Jun 2006 13:45:57 -0000
@@ -81,7 +81,12 @@
     struct
     {
       PolicyType type;
-      unsigned long gid_uid_or_at_console;      
+      union
+      {
+	dbus_uid_t uid;
+	dbus_gid_t gid;
+	dbus_bool_t at_console;
+      } u;
     } policy;
 
     struct
@@ -889,7 +894,7 @@
           _dbus_string_init_const (&username, user);
 
           if (_dbus_get_user_id (&username,
-                                 &e->d.policy.gid_uid_or_at_console))
+                                 &e->d.policy.u.uid))
             e->d.policy.type = POLICY_USER;
           else
             _dbus_warn ("Unknown username \"%s\" in message bus configuration file\n",
@@ -901,7 +906,7 @@
           _dbus_string_init_const (&group_name, group);
 
           if (_dbus_get_group_id (&group_name,
-                                  &e->d.policy.gid_uid_or_at_console))
+                                  &e->d.policy.u.gid))
             e->d.policy.type = POLICY_GROUP;
           else
             _dbus_warn ("Unknown group \"%s\" in message bus configuration file\n",
@@ -913,7 +918,7 @@
            t = (strcmp (at_console, "true") == 0);
            if (t || strcmp (at_console, "false") == 0)
              {
-               e->d.policy.gid_uid_or_at_console = t; 
+               e->d.policy.u.at_console = t; 
                e->d.policy.type = POLICY_CONSOLE;
              }  
            else
@@ -1400,7 +1405,7 @@
           
           _dbus_string_init_const (&groupname, group);
           
-          if (_dbus_get_user_id (&groupname, &gid))
+          if (_dbus_get_group_id (&groupname, &gid))
             {
               rule = bus_policy_rule_new (BUS_POLICY_RULE_GROUP, allow); 
               if (rule == NULL)
@@ -1449,7 +1454,7 @@
               goto failed;
             }
           
-          if (!bus_policy_append_user_rule (parser->policy, pe->d.policy.gid_uid_or_at_console,
+          if (!bus_policy_append_user_rule (parser->policy, pe->d.policy.u.uid,
                                             rule))
             goto nomem;
           break;
@@ -1462,14 +1467,14 @@
               goto failed;
             }
           
-          if (!bus_policy_append_group_rule (parser->policy, pe->d.policy.gid_uid_or_at_console,
+          if (!bus_policy_append_group_rule (parser->policy, pe->d.policy.u.gid,
                                              rule))
             goto nomem;
           break;
         
 
         case POLICY_CONSOLE:
-          if (!bus_policy_append_console_rule (parser->policy, pe->d.policy.gid_uid_or_at_console,
+          if (!bus_policy_append_console_rule (parser->policy, pe->d.policy.u.at_console,
                                              rule))
             goto nomem;
           break;
@@ -2666,10 +2671,27 @@
     case ELEMENT_POLICY:
       if (a->d.policy.type != b->d.policy.type)
 	return FALSE;
-      if (a->d.policy.gid_uid_or_at_console != b->d.policy.gid_uid_or_at_console)
+      switch (a->d.policy.type)
+	{
+	case POLICY_USER:
+	  if (!DBUS_UID_EQUAL (a->d.policy.u.uid, b->d.policy.u.uid))
+	    return FALSE;
+	  break;
+
+	case POLICY_GROUP:
+	  if (!DBUS_GID_EQUAL (a->d.policy.u.gid, b->d.policy.u.gid))
+	return FALSE;
+      break;
+
+        case POLICY_CONSOLE:
+	  if (a->d.policy.u.at_console != b->d.policy.u.at_console)
 	return FALSE;
       break;
 
+	default:
+	  break;		/* TRUE or FALSE? */
+	}
+      break;
     case ELEMENT_LIMIT:
       if (strcmp (a->d.limit.name, b->d.limit.name))
 	return FALSE;
Index: bus/connection.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/connection.c,v
retrieving revision 1.62
diff -u -b -B -r1.62 connection.c
--- bus/connection.c	10 Feb 2006 21:44:15 -0000	1.62
+++ bus/connection.c	22 Jun 2006 13:45:58 -0000
@@ -114,7 +114,7 @@
 
   /* val is NULL is 0 when it isn't in the hash yet */
   
-  val = _dbus_hash_table_lookup_ulong (connections->completed_by_user,
+  val = _dbus_hash_table_lookup_uid_t (connections->completed_by_user,
                                        uid);
 
   current_count = _DBUS_POINTER_TO_INT (val);
@@ -143,14 +143,14 @@
 
   if (current_count == 0)
     {
-      _dbus_hash_table_remove_ulong (connections->completed_by_user, uid);
+      _dbus_hash_table_remove_uid_t (connections->completed_by_user, uid);
       return TRUE;
     }
   else
     {
       dbus_bool_t retval;
       
-      retval = _dbus_hash_table_insert_ulong (connections->completed_by_user,
+      retval = _dbus_hash_table_insert_uid_t (connections->completed_by_user,
                                               uid, _DBUS_INT_TO_POINTER (current_count));
 
       /* only positive adjustment can fail as otherwise
@@ -252,7 +252,7 @@
     {
       if (d->name != NULL)
         {
-          unsigned long uid;
+          dbus_uid_t uid;
           
           _dbus_list_remove_link (&d->connections->completed, d->link_in_connection_list);
           d->link_in_connection_list = NULL;
@@ -369,7 +369,7 @@
 
 static dbus_bool_t
 allow_user_function (DBusConnection *connection,
-                     unsigned long   uid,
+                     dbus_uid_t      uid,
                      void           *data)
 {
   BusConnectionData *d;
@@ -429,7 +429,7 @@
   if (connections == NULL)
     goto failed_1;
 
-  connections->completed_by_user = _dbus_hash_table_new (DBUS_HASH_ULONG,
+  connections->completed_by_user = _dbus_hash_table_new (DBUS_HASH_UID_T,
                                                          NULL, NULL);
   if (connections->completed_by_user == NULL)
     goto failed_2;
@@ -770,12 +770,12 @@
 
 dbus_bool_t
 bus_connection_get_groups  (DBusConnection   *connection,
-                            unsigned long   **groups,
+                            dbus_gid_t      **groups,
                             int              *n_groups,
                             DBusError        *error)
 {
   BusConnectionData *d;
-  unsigned long uid;
+  dbus_uid_t uid;
   DBusUserDatabase *user_database;
   
   d = BUS_CONNECTION_DATA (connection);
@@ -811,10 +811,10 @@
 
 dbus_bool_t
 bus_connection_is_in_group (DBusConnection *connection,
-                            unsigned long   gid)
+                            dbus_gid_t      gid)
 {
   int i;
-  unsigned long *group_ids;
+  dbus_gid_t *group_ids;
   int n_group_ids;
 
   if (!bus_connection_get_groups (connection, &group_ids, &n_group_ids,
@@ -1254,7 +1254,7 @@
                          DBusError        *error)
 {
   BusConnectionData *d;
-  unsigned long uid;
+  dbus_uid_t uid;
   
   d = BUS_CONNECTION_DATA (connection);
   _dbus_assert (d != NULL);
@@ -1344,7 +1344,7 @@
                               DBusError       *error)
 {
   BusConnectionData *d;
-  unsigned long uid;
+  dbus_uid_t uid;
   
   d = BUS_CONNECTION_DATA (requesting_completion);
   _dbus_assert (d != NULL);
Index: bus/connection.h
===================================================================
RCS file: /cvs/dbus/dbus/bus/connection.h,v
retrieving revision 1.21
diff -u -b -B -r1.21 connection.h
--- bus/connection.h	10 Aug 2004 03:06:59 -0000	1.21
+++ bus/connection.h	22 Jun 2006 13:45:58 -0000
@@ -106,9 +106,9 @@
 void        bus_connection_disconnected (DBusConnection *connection);
 
 dbus_bool_t      bus_connection_is_in_group (DBusConnection       *connection,
-                                             unsigned long         gid);
+                                             dbus_gid_t            gid);
 dbus_bool_t      bus_connection_get_groups  (DBusConnection       *connection,
-                                             unsigned long       **groups,
+                                             dbus_gid_t          **groups,
                                              int                  *n_groups,
                                              DBusError            *error);
 BusClientPolicy* bus_connection_get_policy  (DBusConnection       *connection);
Index: bus/driver.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/driver.c,v
retrieving revision 1.76
diff -u -b -B -r1.76 driver.c
--- bus/driver.c	22 Nov 2005 20:37:00 -0000	1.76
+++ bus/driver.c	22 Jun 2006 13:45:58 -0000
@@ -1040,7 +1040,7 @@
   BusService *serv;
   DBusConnection *conn;
   DBusMessage *reply;
-  unsigned long uid;
+  dbus_uid_t uid;
   dbus_uint32_t uid32;
 
   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
@@ -1116,7 +1116,7 @@
   BusService *serv;
   DBusConnection *conn;
   DBusMessage *reply;
-  unsigned long pid;
+  dbus_uid_t pid;
   dbus_uint32_t pid32;
 
   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
Index: bus/policy.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/policy.c,v
retrieving revision 1.23
diff -u -b -B -r1.23 policy.c
--- bus/policy.c	29 Aug 2005 20:19:19 -0000	1.23
+++ bus/policy.c	22 Jun 2006 13:45:59 -0000
@@ -168,13 +168,13 @@
 
   policy->refcount = 1;
   
-  policy->rules_by_uid = _dbus_hash_table_new (DBUS_HASH_ULONG,
+  policy->rules_by_uid = _dbus_hash_table_new (DBUS_HASH_UID_T,
                                                NULL,
                                                free_rule_list_func);
   if (policy->rules_by_uid == NULL)
     goto failed;
 
-  policy->rules_by_gid = _dbus_hash_table_new (DBUS_HASH_ULONG,
+  policy->rules_by_gid = _dbus_hash_table_new (DBUS_HASH_UID_T,
                                                NULL,
                                                free_rule_list_func);
   if (policy->rules_by_gid == NULL)
@@ -291,7 +291,7 @@
    */
   if (_dbus_hash_table_get_n_entries (policy->rules_by_gid) > 0)
     {
-      unsigned long *groups;
+      dbus_gid_t *groups;
       int n_groups;
       int i;
       
@@ -303,7 +303,7 @@
         {
           DBusList **list;
           
-          list = _dbus_hash_table_lookup_ulong (policy->rules_by_gid,
+          list = _dbus_hash_table_lookup_uid_t (policy->rules_by_gid,
                                                 groups[i]);
           
           if (list != NULL)
@@ -332,7 +332,7 @@
     {
       DBusList **list;
       
-      list = _dbus_hash_table_lookup_ulong (policy->rules_by_uid,
+      list = _dbus_hash_table_lookup_uid_t (policy->rules_by_uid,
                                             uid);
 
       if (list != NULL)
@@ -379,8 +379,8 @@
 static dbus_bool_t
 list_allows_user (dbus_bool_t           def,
                   DBusList            **list,
-                  unsigned long         uid,
-                  const unsigned long  *group_ids,
+                  dbus_uid_t            uid,
+                  const dbus_gid_t     *group_ids,
                   int                   n_group_ids)
 {
   DBusList *link;
@@ -439,10 +439,10 @@
 dbus_bool_t
 bus_policy_allow_user (BusPolicy        *policy,
                        DBusUserDatabase *user_database,
-                       unsigned long     uid)
+                       dbus_uid_t        uid)
 {
   dbus_bool_t allowed;
-  unsigned long *group_ids;
+  dbus_gid_t *group_ids;
   int n_group_ids;
 
   /* On OOM or error we always reject the user */
@@ -502,11 +502,11 @@
 
 static DBusList**
 get_list (DBusHashTable *hash,
-          unsigned long  key)
+          dbus_uid_t     key)
 {
   DBusList **list;
 
-  list = _dbus_hash_table_lookup_ulong (hash, key);
+  list = _dbus_hash_table_lookup_uid_t (hash, key);
 
   if (list == NULL)
     {
@@ -514,7 +514,7 @@
       if (list == NULL)
         return NULL;
 
-      if (!_dbus_hash_table_insert_ulong (hash, key, list))
+      if (!_dbus_hash_table_insert_uid_t (hash, key, list))
         {
           dbus_free (list);
           return NULL;
@@ -627,7 +627,7 @@
   _dbus_hash_iter_init (to_absorb, &iter);
   while (_dbus_hash_iter_next (&iter))
     {
-      unsigned long id = _dbus_hash_iter_get_ulong_key (&iter);
+      dbus_uid_t id = _dbus_hash_iter_get_uid_t_key (&iter);
       DBusList **list = _dbus_hash_iter_get_value (&iter);
       DBusList **target = get_list (dest, id);
 
Index: bus/policy.h
===================================================================
RCS file: /cvs/dbus/dbus/bus/policy.h,v
retrieving revision 1.16
diff -u -b -B -r1.16 policy.h
--- bus/policy.h	25 Aug 2004 22:11:49 -0000	1.16
+++ bus/policy.h	22 Jun 2006 13:45:59 -0000
@@ -114,7 +114,7 @@
                                                    DBusError        *error);
 dbus_bool_t      bus_policy_allow_user            (BusPolicy        *policy,
                                                    DBusUserDatabase *user_database,
-                                                   unsigned long     uid);
+                                                   dbus_uid_t     uid);
 dbus_bool_t      bus_policy_append_default_rule   (BusPolicy        *policy,
                                                    BusPolicyRule    *rule);
 dbus_bool_t      bus_policy_append_mandatory_rule (BusPolicy        *policy,
Index: dbus/dbus-bus.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-bus.c,v
retrieving revision 1.50
diff -u -b -B -r1.50 dbus-bus.c
--- dbus/dbus-bus.c	3 May 2006 22:56:35 -0000	1.50
+++ dbus/dbus-bus.c	22 Jun 2006 13:45:59 -0000
@@ -644,7 +644,7 @@
 
   dbus_message_unref (reply);
   
-  return (unsigned long) uid;
+  return (dbus_uid_t) uid;
 }
 
 
Index: dbus/dbus-connection.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-connection.c,v
retrieving revision 1.118
diff -u -b -B -r1.118 dbus-connection.c
--- dbus/dbus-connection.c	23 Apr 2006 18:54:47 -0000	1.118
+++ dbus/dbus-connection.c	22 Jun 2006 13:46:00 -0000
@@ -4122,7 +4122,7 @@
  */
 dbus_bool_t
 dbus_connection_get_unix_user (DBusConnection *connection,
-                               unsigned long  *uid)
+                               dbus_uid_t     *uid)
 {
   dbus_bool_t result;
 
@@ -4153,7 +4153,7 @@
  */
 dbus_bool_t
 dbus_connection_get_unix_process_id (DBusConnection *connection,
-				     unsigned long  *pid)
+				     dbus_uid_t     *pid)
 {
   dbus_bool_t result;
 
Index: dbus/dbus-connection.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-connection.h,v
retrieving revision 1.40
diff -u -b -B -r1.40 dbus-connection.h
--- dbus/dbus-connection.h	30 Nov 2005 20:30:02 -0000	1.40
+++ dbus/dbus-connection.h	22 Jun 2006 13:46:00 -0000
@@ -31,6 +31,7 @@
 #include <dbus/dbus-memory.h>
 #include <dbus/dbus-message.h>
 #include <dbus/dbus-shared.h>
+#include <dbus/dbus-sysdeps.h>
 
 DBUS_BEGIN_DECLS
 
@@ -76,7 +77,7 @@
                                                     void           *data);
 typedef void        (* DBusWakeupMainFunction)     (void           *data);
 typedef dbus_bool_t (* DBusAllowUnixUserFunction)  (DBusConnection *connection,
-                                                    unsigned long   uid,
+                                                    dbus_uid_t      uid,
                                                     void           *data);
 
 typedef void (* DBusPendingCallNotifyFunction) (DBusPendingCall *pending,
@@ -145,7 +146,7 @@
                                                                  void                       *data,
                                                                  DBusFreeFunction            free_data_function);
 dbus_bool_t        dbus_connection_get_unix_user                (DBusConnection             *connection,
-                                                                 unsigned long              *uid);
+                                                                 dbus_uid_t                 *uid);
 dbus_bool_t        dbus_connection_get_unix_process_id          (DBusConnection             *connection,
                                                                  unsigned long              *pid);
 void               dbus_connection_set_unix_user_function       (DBusConnection             *connection,
Index: dbus/dbus-hash.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-hash.c,v
retrieving revision 1.20
diff -u -b -B -r1.20 dbus-hash.c
--- dbus/dbus-hash.c	6 Mar 2006 19:06:45 -0000	1.20
+++ dbus/dbus-hash.c	22 Jun 2006 13:46:01 -0000
@@ -327,7 +327,7 @@
     {
     case DBUS_HASH_INT:
     case DBUS_HASH_POINTER:
-    case DBUS_HASH_ULONG:
+    case DBUS_HASH_UID_T:
       table->find_function = find_direct_function;
       break;
     case DBUS_HASH_STRING:
@@ -683,12 +683,12 @@
 
 /**
  * Gets the key for the current entry.
- * Only works for hash tables of type #DBUS_HASH_ULONG.
+ * Only works for hash tables of type #DBUS_HASH_UID_T.
  *
  * @param iter the hash table iterator.
  */
-unsigned long
-_dbus_hash_iter_get_ulong_key (DBusHashIter *iter)
+dbus_uid_t
+_dbus_hash_iter_get_uid_t_key (DBusHashIter *iter)
 {
   DBusRealHashIter *real;
 
@@ -697,7 +697,7 @@
   _dbus_assert (real->table != NULL);
   _dbus_assert (real->entry != NULL);
 
-  return (unsigned long) real->entry->key;
+  return (dbus_uid_t) real->entry->key;
 }
 
 /**
@@ -1115,7 +1115,7 @@
 #endif
               break;
             case DBUS_HASH_INT:
-            case DBUS_HASH_ULONG:
+            case DBUS_HASH_UID_T:
             case DBUS_HASH_POINTER:
               idx = RANDOM_INDEX (table, entry->key);
               break;
@@ -1244,7 +1244,7 @@
 
 /**
  * Looks up the value for a given integer in a hash table
- * of type #DBUS_HASH_ULONG. Returns %NULL if the value
+ * of type #DBUS_HASH_UID_T. Returns %NULL if the value
  * is not present. (A not-present entry is indistinguishable
  * from an entry with a value of %NULL.)
  * @param table the hash table.
@@ -1252,12 +1252,12 @@
  * @returns the value of the hash entry.
  */
 void*
-_dbus_hash_table_lookup_ulong (DBusHashTable *table,
-                               unsigned long  key)
+_dbus_hash_table_lookup_uid_t (DBusHashTable *table,
+                               dbus_uid_t     key)
 {
   DBusHashEntry *entry;
 
-  _dbus_assert (table->key_type == DBUS_HASH_ULONG);
+  _dbus_assert (table->key_type == DBUS_HASH_UID_T);
   
   entry = (* table->find_function) (table, (void*) key, FALSE, NULL, NULL);
 
@@ -1393,13 +1393,13 @@
  * @returns #TRUE if the entry existed
  */
 dbus_bool_t
-_dbus_hash_table_remove_ulong (DBusHashTable *table,
-                               unsigned long  key)
+_dbus_hash_table_remove_uid_t (DBusHashTable *table,
+                               dbus_uid_t     key)
 {
   DBusHashEntry *entry;
   DBusHashEntry **bucket;
   
-  _dbus_assert (table->key_type == DBUS_HASH_ULONG);
+  _dbus_assert (table->key_type == DBUS_HASH_UID_T);
   
   entry = (* table->find_function) (table, (void*) key, FALSE, &bucket, NULL);
   
@@ -1590,13 +1590,13 @@
  * @param value the hash entry value.
  */
 dbus_bool_t
-_dbus_hash_table_insert_ulong (DBusHashTable *table,
-                               unsigned long  key,
+_dbus_hash_table_insert_uid_t (DBusHashTable *table,
+                               dbus_uid_t     key,
                                void          *value)
 {
   DBusHashEntry *entry;
 
-  _dbus_assert (table->key_type == DBUS_HASH_ULONG);
+  _dbus_assert (table->key_type == DBUS_HASH_UID_T);
   
   entry = (* table->find_function) (table, (void*) key, TRUE, NULL, NULL);
 
@@ -1809,7 +1809,7 @@
   if (table2 == NULL)
     goto out;
 
-  table3 = _dbus_hash_table_new (DBUS_HASH_ULONG,
+  table3 = _dbus_hash_table_new (DBUS_HASH_UID_T,
                                  NULL, dbus_free);
   if (table3 == NULL)
     goto out;
@@ -1852,7 +1852,7 @@
       if (value == NULL)
         goto out;
       
-      if (!_dbus_hash_table_insert_ulong (table3,
+      if (!_dbus_hash_table_insert_uid_t (table3,
                                           i, value))
         goto out;
 
@@ -1880,7 +1880,7 @@
       _dbus_assert (value != NULL);
       _dbus_assert (strcmp (value, keys[i]) == 0);
 
-      value = _dbus_hash_table_lookup_ulong (table3, i);
+      value = _dbus_hash_table_lookup_uid_t (table3, i);
       _dbus_assert (value != NULL);
       _dbus_assert (strcmp (value, keys[i]) == 0);
 
@@ -1899,7 +1899,7 @@
 
       _dbus_hash_table_remove_int (table2, i);
 
-      _dbus_hash_table_remove_ulong (table3, i); 
+      _dbus_hash_table_remove_uid_t (table3, i); 
 
       _dbus_hash_table_remove_two_strings (table4,
                                            keys[i]);
Index: dbus/dbus-hash.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-hash.h,v
retrieving revision 1.15
diff -u -b -B -r1.15 dbus-hash.h
--- dbus/dbus-hash.h	6 Mar 2006 19:06:45 -0000	1.15
+++ dbus/dbus-hash.h	22 Jun 2006 13:46:01 -0000
@@ -26,6 +26,7 @@
 
 #include <dbus/dbus-memory.h>
 #include <dbus/dbus-types.h>
+#include <dbus/dbus-sysdeps.h>
 
 DBUS_BEGIN_DECLS
 
@@ -56,7 +57,7 @@
   DBUS_HASH_TWO_STRINGS,   /**< Hash key is two strings in one memory block, i.e. foo\\0bar\\0 */
   DBUS_HASH_INT,           /**< Hash keys are integers. */
   DBUS_HASH_POINTER,       /**< Hash keys are pointers. */
-  DBUS_HASH_ULONG          /**< Hash keys are unsigned long. */
+  DBUS_HASH_UID_T          /**< Hash keys are dbus_uid_t. */
 } DBusHashType;
 DBusHashTable* _dbus_hash_table_new                (DBusHashType      type,
                                                     DBusFreeFunction  key_free_function,
@@ -74,7 +75,7 @@
 int            _dbus_hash_iter_get_int_key         (DBusHashIter     *iter);
 const char*    _dbus_hash_iter_get_string_key      (DBusHashIter     *iter);
 const char*    _dbus_hash_iter_get_two_strings_key (DBusHashIter     *iter);
-unsigned long  _dbus_hash_iter_get_ulong_key       (DBusHashIter     *iter);
+dbus_uid_t     _dbus_hash_iter_get_uid_t_key       (DBusHashIter     *iter);
 dbus_bool_t    _dbus_hash_iter_lookup              (DBusHashTable    *table,
                                                     void             *key,
                                                     dbus_bool_t       create_if_not_found,
@@ -87,8 +88,8 @@
                                                     int               key);
 void*          _dbus_hash_table_lookup_pointer     (DBusHashTable    *table,
                                                     void             *key);
-void*          _dbus_hash_table_lookup_ulong       (DBusHashTable    *table,
-                                                    unsigned long     key);
+void*          _dbus_hash_table_lookup_uid_t       (DBusHashTable    *table,
+                                                    dbus_uid_t        key);
 dbus_bool_t    _dbus_hash_table_remove_string      (DBusHashTable    *table,
                                                     const char       *key);
 dbus_bool_t    _dbus_hash_table_remove_two_strings (DBusHashTable    *table,
@@ -97,8 +98,8 @@
                                                     int               key);
 dbus_bool_t    _dbus_hash_table_remove_pointer     (DBusHashTable    *table,
                                                     void             *key);
-dbus_bool_t    _dbus_hash_table_remove_ulong       (DBusHashTable    *table,
-                                                    unsigned long     key);
+dbus_bool_t    _dbus_hash_table_remove_uid_t       (DBusHashTable    *table,
+                                                    dbus_uid_t        key);
 dbus_bool_t    _dbus_hash_table_insert_string      (DBusHashTable    *table,
                                                     char             *key,
                                                     void             *value);
@@ -111,8 +112,8 @@
 dbus_bool_t    _dbus_hash_table_insert_pointer     (DBusHashTable    *table,
                                                     void             *key,
                                                     void             *value);
-dbus_bool_t    _dbus_hash_table_insert_ulong       (DBusHashTable    *table,
-                                                    unsigned long     key,
+dbus_bool_t    _dbus_hash_table_insert_uid_t       (DBusHashTable    *table,
+                                                    dbus_uid_t        key,
                                                     void             *value);
 int            _dbus_hash_table_get_n_entries      (DBusHashTable    *table);
 
Index: dbus/dbus-sysdeps.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps.h,v
retrieving revision 1.49
diff -u -b -B -r1.49 dbus-sysdeps.h
--- dbus/dbus-sysdeps.h	8 Jul 2005 14:36:22 -0000	1.49
+++ dbus/dbus-sysdeps.h	22 Jun 2006 13:46:01 -0000
@@ -91,6 +91,11 @@
 typedef unsigned long dbus_uid_t;
 typedef unsigned long dbus_gid_t;
 
+#define DBUS_HASH_UID_T DBUS_HASH_ULONG           
+     
+#define DBUS_UID_EQUAL(a,b) (a == b)                  
+#define DBUS_GID_EQUAL(a,b) DBUS_UID_EQUAL (a, b)     
+
 #define DBUS_PID_UNSET ((dbus_pid_t) -1)
 #define DBUS_UID_UNSET ((dbus_uid_t) -1)
 #define DBUS_GID_UNSET ((dbus_gid_t) -1)
Index: dbus/dbus-transport.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-transport.c,v
retrieving revision 1.46
diff -u -b -B -r1.46 dbus-transport.c
--- dbus/dbus-transport.c	5 May 2005 22:02:11 -0000	1.46
+++ dbus/dbus-transport.c	22 Jun 2006 13:46:01 -0000
@@ -963,7 +963,7 @@
  */
 dbus_bool_t
 _dbus_transport_get_unix_user (DBusTransport *transport,
-                               unsigned long *uid)
+                               dbus_uid_t *uid)
 {
   DBusCredentials auth_identity;
 
Index: dbus/dbus-userdb-util.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-userdb-util.c,v
retrieving revision 1.7
diff -u -b -B -r1.7 dbus-userdb-util.c
--- dbus/dbus-userdb-util.c	7 Jun 2006 19:59:11 -0000	1.7
+++ dbus/dbus-userdb-util.c	22 Jun 2006 13:46:01 -0000
@@ -226,7 +226,7 @@
    /* See if the group is really a number */
    if (gid == DBUS_UID_UNSET)
     {
-      unsigned long n;
+      dbus_gid_t n;
 
       if (_dbus_is_a_number (groupname, &n))
         gid = n;
@@ -234,7 +234,7 @@
 
 
   if (gid != DBUS_GID_UNSET)
-    info = _dbus_hash_table_lookup_ulong (db->groups, gid);
+    info = _dbus_hash_table_lookup_uid_t (db->groups, gid);
   else
     info = _dbus_hash_table_lookup_string (db->groups_by_name,
                                            _dbus_string_get_const_data (groupname));
@@ -283,7 +283,7 @@
       gid = DBUS_GID_UNSET;
       groupname = NULL;
 
-      if (!_dbus_hash_table_insert_ulong (db->groups, info->gid, info))
+      if (!_dbus_hash_table_insert_uid_t (db->groups, info->gid, info))
         {
           dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
           _dbus_group_info_free_allocated (info);
@@ -295,7 +295,7 @@
                                            info->groupname,
                                            info))
         {
-          _dbus_hash_table_remove_ulong (db->groups, info->gid);
+          _dbus_hash_table_remove_uid_t (db->groups, info->gid);
           dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
           return NULL;
         }
Index: dbus/dbus-userdb.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-userdb.c,v
retrieving revision 1.19
diff -u -b -B -r1.19 dbus-userdb.c
--- dbus/dbus-userdb.c	6 Mar 2006 19:06:45 -0000	1.19
+++ dbus/dbus-userdb.c	22 Jun 2006 13:46:01 -0000
@@ -112,14 +112,14 @@
   /* See if the username is really a number */
   if (uid == DBUS_UID_UNSET)
     {
-      unsigned long n;
+      dbus_uid_t n;
 
       if (_dbus_is_a_number (username, &n))
         uid = n;
     }
 
   if (uid != DBUS_UID_UNSET)
-    info = _dbus_hash_table_lookup_ulong (db->users, uid);
+    info = _dbus_hash_table_lookup_uid_t (db->users, uid);
   else
     info = _dbus_hash_table_lookup_string (db->users_by_name, _dbus_string_get_const_data (username));
   
@@ -169,7 +169,7 @@
       username = NULL;
 
       /* insert into hash */
-      if (!_dbus_hash_table_insert_ulong (db->users, info->uid, info))
+      if (!_dbus_hash_table_insert_uid_t (db->users, info->uid, info))
         {
           dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
           _dbus_user_info_free_allocated (info);
@@ -180,7 +180,7 @@
                                            info->username,
                                            info))
         {
-          _dbus_hash_table_remove_ulong (db->users, info->uid);
+          _dbus_hash_table_remove_uid_t (db->users, info->uid);
           dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
           return NULL;
         }
@@ -447,13 +447,13 @@
 
   db->refcount = 1;
 
-  db->users = _dbus_hash_table_new (DBUS_HASH_ULONG,
+  db->users = _dbus_hash_table_new (DBUS_HASH_UID_T,
                                     NULL, (DBusFreeFunction) _dbus_user_info_free_allocated);
   
   if (db->users == NULL)
     goto failed;
 
-  db->groups = _dbus_hash_table_new (DBUS_HASH_ULONG,
+  db->groups = _dbus_hash_table_new (DBUS_HASH_UID_T,
                                      NULL, (DBusFreeFunction) _dbus_group_info_free_allocated);
   
   if (db->groups == NULL)


More information about the dbus mailing list