dbus/dbus dbus-userdb-util.c, 1.5, 1.6 dbus-userdb.c, 1.16,
1.17 dbus-userdb.h, 1.9, 1.10
John Palmieri
johnp at freedesktop.org
Tue Mar 22 09:57:29 PST 2005
Update of /cvs/dbus/dbus/dbus
In directory gabe:/tmp/cvs-serv28555/dbus
Modified Files:
dbus-userdb-util.c dbus-userdb.c dbus-userdb.h
Log Message:
* tools/Makefile.am: Patch by Colin Walters that fixes distcheck
* dbus/dbus-userdb.c, dbus/dbus-userdb-util.c: Add patch we have
had in Red Hat packages for a while but for some reason never
got merged upstream
(_dbus_is_a_number): New checks if a string
can be converted to a number and does the conversion if it can
(_dbus_user_database_lookup): Add check to see if the given username
is a udi. This allows udi's to be used instead of usernames in the
config file.
(_dbus_user_database_lookup_group): Add check to see if the given groupname
is a gdi. This allows gdi's to be used instead of groupnames in the
config file.
Index: dbus-userdb-util.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-userdb-util.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- dbus-userdb-util.c 17 Mar 2005 23:13:38 -0000 1.5
+++ dbus-userdb-util.c 22 Mar 2005 17:57:27 -0000 1.6
@@ -195,6 +195,16 @@
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
+ /* See if the group is really a number */
+ if (gid == DBUS_UID_UNSET)
+ {
+ unsigned long n;
+
+ if (_dbus_is_a_number (groupname, &n))
+ gid = n;
+ }
+
+
if (gid != DBUS_GID_UNSET)
info = _dbus_hash_table_lookup_ulong (db->groups, gid);
else
Index: dbus-userdb.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-userdb.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- dbus-userdb.c 17 Mar 2005 23:13:38 -0000 1.16
+++ dbus-userdb.c 22 Mar 2005 17:57:27 -0000 1.17
@@ -66,6 +66,27 @@
}
/**
+ * Checks if a given string is actually a number
+ * and converts it if it is
+ *
+ * @param str the string to check
+ * @param num the memory location of the unsigned long to fill in
+ * @returns TRUE if str is a number and num is filled in
+ */
+dbus_bool_t
+_dbus_is_a_number (const DBusString *str,
+ unsigned long *num)
+{
+ int end;
+
+ if (_dbus_string_parse_int (str, 0, num, &end) &&
+ end == _dbus_string_get_length (str))
+ return TRUE;
+ else
+ return FALSE;
+}
+
+/**
* Looks up a uid or username in the user database. Only one of name
* or UID can be provided. There are wrapper functions for this that
* are better to use, this one does no locking or anything on the
@@ -87,7 +108,16 @@
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
_dbus_assert (uid != DBUS_UID_UNSET || username != NULL);
-
+
+ /* See if the username is really a number */
+ if (uid == DBUS_UID_UNSET)
+ {
+ unsigned long n;
+
+ if (_dbus_is_a_number (username, &n))
+ uid = n;
+ }
+
if (uid != DBUS_UID_UNSET)
info = _dbus_hash_table_lookup_ulong (db->users, uid);
else
Index: dbus-userdb.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-userdb.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- dbus-userdb.h 17 Jan 2005 01:20:02 -0000 1.9
+++ dbus-userdb.h 22 Mar 2005 17:57:27 -0000 1.10
@@ -106,6 +106,9 @@
dbus_bool_t _dbus_is_console_user (dbus_uid_t uid,
DBusError *error);
+dbus_bool_t _dbus_is_a_number (const DBusString *str,
+ unsigned long *num);
+
DBUS_END_DECLS
More information about the dbus-commit
mailing list