added documentation for utility functions/classes
authorImran Zaman <imran.zaman@intel.com>
Thu, 14 Nov 2013 13:51:14 +0000 (15:51 +0200)
committerImran Zaman <imran.zaman@intel.com>
Thu, 14 Nov 2013 13:51:14 +0000 (15:51 +0200)
13 files changed:
include/gum/common/gum-crypt.h
include/gum/common/gum-disposable.h
include/gum/common/gum-string-utils.h
src/common/gum-crypt.c
src/common/gum-disposable.c
src/common/gum-error.c
src/common/gum-file.c
src/common/gum-lock.c
src/common/gum-string-utils.c
src/common/gum-utils.c
src/common/gum-validate.c
src/daemon/dbus/gumd-dbus-group-adapter.c
src/daemon/dbus/gumd-dbus-user-adapter.c

index 38d6c0d..4762660 100644 (file)
@@ -46,8 +46,8 @@ gum_crypt_encrypt_secret (
 
 gint
 gum_crypt_cmp_secret (
-        const gchar *plain_secret,
-        const gchar *enc_secret);
+        const gchar *plain_str1,
+        const gchar *enc_str2);
 
 G_END_DECLS
 
index 3ca5f28..ed32783 100644 (file)
@@ -6,6 +6,7 @@
  * Copyright (C) 2013 Intel Corporation.
  *
  * Contact: Amarnath Valluri <amarnath.valluri@linux.intel.com>
+ *          Imran Zaman <imran.zaman@intel.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -63,18 +64,22 @@ struct _GumDisposableClass
 GType gum_disposable_get_type (void) G_GNUC_CONST;
 
 void
-gum_disposable_set_auto_dispose (GumDisposable *disposable,
-                                      gboolean dispose);
+gum_disposable_set_auto_dispose (
+        GumDisposable *self,
+        gboolean dispose);
 
 gboolean
-gum_disposable_get_auto_dispose (GumDisposable *disposable);
+gum_disposable_get_auto_dispose (
+        GumDisposable *self);
 
 void
-gum_disposable_set_timeout (GumDisposable *self,
-                                 guint timeout);
+gum_disposable_set_timeout (
+        GumDisposable *self,
+        guint timeout);
 
 void
-gum_disposable_delete_later (GumDisposable *self);
+gum_disposable_delete_later (
+        GumDisposable *self);
 
 G_END_DECLS
 
index c6890ae..67b938a 100644 (file)
@@ -28,6 +28,8 @@
 
 #include <glib.h>
 
+G_BEGIN_DECLS
+
 #define GUM_STR_FREE(s) { \
     if (s) { \
         g_free (s); \
@@ -52,8 +54,6 @@
     d = g_strdupv (s); \
     }
 
-G_BEGIN_DECLS
-
 gboolean
 gum_string_utils_search_string (
         const gchar *strings,
@@ -69,14 +69,14 @@ gchar *
 gum_string_utils_get_string (
         const gchar *strings,
         const gchar *separator,
-        guint str_ind /*starts from 0*/);
+        guint str_ind);
 
 gchar *
 gum_string_utils_insert_string (
         const gchar *strings,
         const gchar *separator,
         const gchar *str_to_insert,
-        guint str_ind, /*starts from 0*/
+        guint str_ind,
         guint total_strings);
 
 gchar **
index 072bbe4..229d9b3 100644 (file)
 #include "common/gum-crypt.h"
 #include "common/gum-log.h"
 
+/**
+ * SECTION:gum-crypt
+ * @short_description: Utility functions for encryption
+ * @title: Gum Crypt
+ * @include: gum/common/gum-crypt.h
+ *
+ * Following code snippets shows how a string can be encrypted with any of the
+ * encrytpion method listed in #GumCryptMethodID. Moreover, plain and encrypted
+ * secrets can be compared if needed.
+ *
+ * |[
+ *   gchar *pass = gum_crypt_encrypt_secret("pas.-s123", GUM_CRYPT_SHA512);
+ *   g_free (pass);
+ *
+ *   pass = gum_crypt_encrypt_secret("pass ?()#123", GUM_CRYPT_SHA512);
+ *   gum_crypt_cmp_secret("pass ?()#123", pass); //should return true.
+ *   g_free (pass);
+ *
+ * ]|
+ */
+
+/**
+ * GumCryptMethodID:
+ * @GUM_CRYPT_MD5: MD5 encryption algorithm
+ * @GUM_CRYPT_SHA256: SHA-256 encryption algorithm
+ * @GUM_CRYPT_SHA512: SHA-512 encryption algorithm
+ * @GUM_CRYPT_DES: DES encryption algorithm
+ *
+ * This enumeration lists the supported encryption methods.
+ */
+
 guchar _salt_chars[64 + 1] =
     "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
 
@@ -83,6 +114,15 @@ _generate_salt (
     return g_strdup (salt);
 }
 
+/**
+ * gum_crypt_encrypt_secret:
+ * @secret: (transfer none): string to encrypt
+ * @methodid: #GumCryptMethodID method id
+ *
+ * Encrypts the secret with the specified method.
+ *
+ * Returns: (transfer full): encrypted secret if successful, NULL otherwise.
+ */
 gchar *
 gum_crypt_encrypt_secret (
         const gchar *secret,
@@ -125,23 +165,34 @@ _extract_salt (
     return salt;
 }
 
+/**
+ * gum_crypt_cmp_secret:
+ * @plain_str1: (transfer none): plain string
+ * @enc_str2: (transfer none): encrypted string
+ *
+ * Encrypts plain string with the same parameters as that of encrypted string
+ * and then compares both encrypted strings.
+ *
+ * Returns: 0 if enc_str1 == enc_str2, less than 0 if the enc_str1 < enc_str2,
+ * greater than 0 if enc_str1 > enc_str2.
+ */
 gint
 gum_crypt_cmp_secret (
-        const gchar *plain_secret,
-        const gchar *enc_secret)
+        const gchar *plain_str1,
+        const gchar *enc_str2)
 {
     gint cmp = -1;
     gchar *plain_enc = NULL;
 
-    if (!enc_secret || !plain_secret) return cmp;
+    if (!enc_str2 || !plain_str1) return cmp;
 
-    gchar *salt = _extract_salt (enc_secret);
+    gchar *salt = _extract_salt (enc_str2);
     if (!salt) return cmp;
 
-    plain_enc = g_strdup (crypt (plain_secret, salt));
+    plain_enc = g_strdup (crypt (plain_str1, salt));
     g_free (salt);
 
-    cmp = g_strcmp0 (plain_enc, enc_secret);
+    cmp = g_strcmp0 (plain_enc, enc_str2);
     g_free (plain_enc);
 
     return cmp;
index 423a2a3..237fdc9 100644 (file)
@@ -6,6 +6,7 @@
  * Copyright (C) 2013 Intel Corporation.
  *
  * Contact: Amarnath Valluri <amarnath.valluri@linux.intel.com>
+ *          Imran Zaman <imran.zaman@intel.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
 #include "common/gum-disposable.h"
 #include "common/gum-log.h"
 
+/**
+ * SECTION:gum-disposable
+ * @short_description: timer-based auto disposable object
+ * @include: gum/common/gum-disposable.h
+ *
+ * #GumDisposable is used to dispose the object when the timer expires with the
+ * specified timeout value provided auto-dispose is enabled. A #GObject which
+ * needs to be auto-disposable should derive itself from #GumDisposable and
+ * can set the timeout value (at the time of object construction e.g.). One such
+ * example, which can make use of #GumDisposable, is a DBus object as it may
+ * be required to destory after some period of inactivity.
+ *
+ * <refsect1><title>Usage</title></refsect1>
+ * Following code snippet demonstrates how to derive and use #GumDisposable:
+ * |[
+ *
+ * //gum-test-object.h
+ * struct _GumTestObject
+ * {
+ *     GumDisposable parent;
+ * };
+ *
+ * struct _GumTestObjectClass
+ * {
+ *     GumDisposableClass parent_class;
+ * };
+ *
+ * //gum-test-object.c
+ * GumTestObject *
+ * gum_test_object_new ()
+ * {
+ *    GumTestObject *obj = g_object_new (GUM_TYPE_TEST_OBJECT, NULL);
+ *
+ *    // ... other code
+ *
+ *    // GumTestobject will be disposed after 5 seconds unless auto-dispose
+ *    // is disabled by calling gum_disposable_set_auto_dispose (obj, FALSE)
+ *    gint timeout = 5;
+ *    gum_disposable_set_timeout (GUM_DISPOSABLE (obj), timeout);
+ *
+ *    // ... other code
+ * }
+ *
+ * ]|
+ *
+ */
+
+/**
+ * GumDisposable:
+ *
+ * Opaque structure for the object.
+ */
+
+/**
+ * GumDisposableClass:
+ * @parent_class: parent class object
+ *
+ * Opaque structure for the class.
+ */
+
 struct _GumDisposablePrivate
 {
     guint timeout;       /* timeout in seconds */
@@ -146,6 +207,12 @@ gum_disposable_class_init (
     object_class->dispose = _dispose;
     object_class->finalize = _finalize;
 
+    /**
+     * GumDisposable:timeout:
+     *
+     * This property holds the value of timeout in seconds. Default value is 0.
+     * If timeout value is 0, the object never auto-dispose.
+     */
     properties[PROP_TIMEOUT] = 
             g_param_spec_uint ("timeout",
                     "Object timeout",
@@ -155,6 +222,13 @@ gum_disposable_class_init (
                     0,
                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
+    /**
+     * GumDisposable:auto-dispose:
+     *
+     * This property holds the value of auto-dispose to be TRUE or FALSE.
+     * Default value is FALSE. If auto-dispose is TRUE, then object is
+     * auto-disposed otherwise not.
+     */
     properties[PROP_AUTO_DISPOSE] =
             g_param_spec_boolean ("auto-dispose",
                     "Auto dispose",
@@ -162,6 +236,13 @@ gum_disposable_class_init (
                     TRUE,
                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
+    /**
+     * GumDisposable:delete-later:
+     *
+     * This property is used when the object is asked to be deleted later.
+     * The object should not be used once #gum_disposable_delete_later is
+     * requested for the object.
+     */
     properties[PROP_DELETE_LATER] =
             g_param_spec_boolean ("delete-later",
                     "Delete Later",
@@ -171,6 +252,11 @@ gum_disposable_class_init (
 
     g_object_class_install_properties (object_class, PROP_MAX, properties);
 
+    /**
+     * GumDisposable:disposing:
+     *
+     * This signal is emitted when the object is about to be disposed.
+     */
     signals[SIG_DISPOSING] = g_signal_new ("disposing",
             GUM_TYPE_DISPOSABLE,
             G_SIGNAL_RUN_FIRST| G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
@@ -205,7 +291,8 @@ _auto_dispose (
     GumDisposable *self = GUM_DISPOSABLE (user_data);
     g_signal_emit (self, signals[SIG_DISPOSING], 0);
     /* destroy object */
-    DBG ("%s AUTO DISPOSE %d", G_OBJECT_TYPE_NAME (self), G_OBJECT (self)->ref_count);
+    DBG ("%s AUTO DISPOSE %d", G_OBJECT_TYPE_NAME (self),
+            G_OBJECT (self)->ref_count);
     g_object_unref (G_OBJECT (self));
     return FALSE;
 }
@@ -250,6 +337,14 @@ _update_timer (
     }
 }
 
+/**
+ * gum_disposable_set_auto_dispose:
+ * @self: (transfer none): an instance of #GumDisposable
+ * @dispose: dispose flag
+ *
+ * Sets the auto-dispose flag, and sets up the timer if needed.
+ *
+ */
 void
 gum_disposable_set_auto_dispose (
         GumDisposable *self,
@@ -264,6 +359,14 @@ gum_disposable_set_auto_dispose (
     _update_timer (self);
 }
 
+/**
+ * gum_disposable_set_timeout:
+ * @self: (transfer none): an instance of #GumDisposable
+ * @timeout: timeout value in seconds
+ *
+ * Sets the timeout value and sets up the timer if needed. If timeout
+ * value is set to 0, the object is never disposed.
+ */
 void
 gum_disposable_set_timeout (
         GumDisposable *self,
@@ -278,6 +381,13 @@ gum_disposable_set_timeout (
     _update_timer (self);
 }
 
+/**
+ * gum_disposable_delete_later:
+ * @self: (transfer none): an instance of #GumDisposable
+ *
+ * Sets the object to be deleted later. Once delete later is requested, the
+ * object should not be used.
+ */
 void
 gum_disposable_delete_later (
         GumDisposable *self)
@@ -291,6 +401,14 @@ gum_disposable_delete_later (
     self->priv->delete_later = TRUE;
 }
 
+/**
+ * gum_disposable_get_auto_dispose:
+ * @self: (transfer none): an instance of #GumDisposable
+ *
+ * Gets the auto-dispose value.
+ *
+ * Returns: the auto-dispose value of the object.
+ */
 gboolean
 gum_disposable_get_auto_dispose (
         GumDisposable *self)
index 31669f5..59b5d5c 100644 (file)
  * @GUM_ERROR_USER_ERR: Placeholder to rearrange enumeration - User space
  * specific
  *
- * This enum provides a list of errors
+ * This enumeration provides a list of errors
  */
 
 /**
index 3912709..2346aab 100644 (file)
 #include "common/gum-log.h"
 #include "common/gum-error.h"
 
+/**
+ * SECTION:gum-file
+ * @short_description: Utility functions for file handling
+ * @title: Gum File
+ * @include: gum/common/gum-file.h
+ *
+ *
+ * |[
+ *
+ * ]|
+ */
+
 #define GUM_PERM 0777
 
 static FILE *
@@ -506,6 +518,7 @@ _copy_dir_recursively (
                 goto _free_data;
             }
         }
+        /* when run in test mode, user may not exist */
 #ifndef ENABLE_TESTS
         if (!stop) stop = (chown (dest_filepath, uid, gid) < 0);
 #endif
index ec1f3fe..c5634d7 100644 (file)
 #include "common/gum-lock.h"
 #include "common/gum-log.h"
 
+/**
+ * SECTION:gum-lock
+ * @short_description: Utility functions for (un)locking user/group database
+ * @title: Gum Lock
+ * @include: gum/common/gum-lock.h
+ *
+ * Locking the user/group database is required when modifications are needed to
+ * the database e.g. adding and deleting users. Lock can be called multiple
+ * times as it merely increases the lock counter after acquiring the lock for
+ * the first time. Similarly unlock can be called multiple times as it decreases
+ * lock counter until it the count reaches to 0 when the lock is released.
+ * Locking and unlocking the database is disabled for when testing is enabled
+ * as tests are run on dummy databases.
+ *
+ * |[
+ *   //return value must be checked if the lock succeed or not.
+ *   gboolean ret = gum_lock_pwdf_lock ();
+ *
+ *   //return value must be checked if the unlock succeed or not.
+ *   ret = gum_lock_pwdf_unlock ();
+ * ]|
+ */
+
 static gint lock_count = 0;
 
+/**
+ * gum_lock_pwdf_lock:
+ *
+ * Gets the lock to the user/group database file(s). Lock can be called multiple
+ * times as it merely increases the lock counter after acquiring the lock for
+ * the first time. In order to release the lock, unlock needs to be called
+ * the same number of times as that of lock. Locking and unlocking the database
+ * is disabled for when testing is enabled as tests are run on dummy databases.
+ *
+ * Returns: TRUE if successful, FALSE otherwise.
+ */
 gboolean
 gum_lock_pwdf_lock ()
 {
@@ -60,6 +94,18 @@ gum_lock_pwdf_lock ()
     return TRUE;
 }
 
+/**
+ * gum_lock_pwdf_unlock:
+ *
+ * Releases the lock to the user/group database file(s). Unlock can be called
+ * multiple times as it decreases lock counter until it the count reaches to 0
+ * when the lock is released. In order to release the lock, unlock needs to be
+ * called the same number of times as that of lock. Locking and unlocking the
+ * database is disabled for when testing is enabled as tests are run on dummy
+ * databases.
+ *
+ * Returns: TRUE if successful, FALSE otherwise.
+ */
 gboolean
 gum_lock_pwdf_unlock ()
 {
index 7924a9d..7e12e20 100644 (file)
 #include "common/gum-log.h"
 #include "common/gum-error.h"
 
+/**
+ * SECTION:gum-string-utils
+ * @short_description: Utility functions for strings handling
+ * @title: Gum String Utils
+ * @include: gum/common/gum-string-utils.h
+ *
+ */
+
+/**
+ * GUM_STR_FREE:
+ * @s: the string to free
+ *
+ * A helper macro that frees the string after checking if it is not NULL.
+ */
+
+/**
+ * GUM_STR_DUP:
+ * @s: the source string
+ * @d: the destination string
+ *
+ * A helper macro that duplicates source string to destination string after
+ * freeing the destination string first if it is not NULL.
+ */
+
+/**
+ * GUM_STR_FREEV:
+ * @s: the string vector to free
+ *
+ * A helper macro that frees string vector after checking if it is not NULL.
+ */
+
+/**
+ * GUM_STR_DUPV:
+ * @s: the source string vector
+ * @d: the destination string vector
+ *
+ * A helper macro that duplicates source string vector to destination string
+ * vector after freeing the destination string vector first if it is not NULL.
+ */
+
+/**
+ * gum_string_utils_search_string:
+ * @strings: (transfer none): concatenated strings in a string placeholder
+ * separated by a separator
+ * @separator: (transfer none): separator between strings
+ * @search_str: (transfer none): string to search
+ *
+ * Finds the 'search string' in the strings.
+ *
+ * Returns: TRUE if found, FALSE otherwise.
+ */
 gboolean
 gum_string_utils_search_string (
         const gchar *strings,
@@ -51,6 +102,15 @@ gum_string_utils_search_string (
     return FALSE;
 }
 
+/**
+ * gum_string_utils_search_stringv:
+ * @stringv: (transfer none): vector of strings
+ * @search_str: (transfer none): string to search
+ *
+ * Finds the 'search string' in the string vector.
+ *
+ * Returns: TRUE if found, FALSE otherwise.
+ */
 gboolean
 gum_string_utils_search_stringv (
         gchar **stringv,
@@ -72,11 +132,21 @@ gum_string_utils_search_stringv (
     return FALSE;
 }
 
+/**
+ * gum_string_utils_get_string:
+ * @strings: (transfer none): vector of strings
+ * @separator: (transfer none): separator between strings
+ * @str_ind: starting from 0, position for the string to fetch
+ *
+ * Gets the str_ind'th string from the strings.
+ *
+ * Returns: (transfer full): string if successful, NULL otherwise.
+ */
 gchar *
 gum_string_utils_get_string (
         const gchar *strings,
         const gchar *separator,
-        guint str_ind /*starts from 0*/)
+        guint str_ind)
 {
     gchar **strv = NULL;
     gchar *str = NULL;
@@ -94,12 +164,26 @@ gum_string_utils_get_string (
     return str;
 }
 
+/**
+ * gum_string_utils_insert_string:
+ * @strings: (transfer none): vector of strings
+ * @separator: (transfer none): separator between strings
+ * @str_to_insert: (transfer none): string to insert
+ * @str_ind: starting from 0, position for the string to insert
+ * @total_strings: total number of strings in the strings vector
+ *
+ * Inserts the string at the desired position and returns the concatenated
+ * string
+ *
+ * Returns: (transfer full): concatenated string vector if successful, NULL
+ * otherwise.
+ */
 gchar *
 gum_string_utils_insert_string (
         const gchar *strings,
         const gchar *separator,
         const gchar *str_to_insert,
-        guint str_ind, /*starts from 0*/
+        guint str_ind,
         guint total_strings)
 {
     gchar **src_strv = NULL, **dest_strv = NULL;
@@ -136,6 +220,16 @@ gum_string_utils_insert_string (
     return result_str;
 }
 
+/**
+ * gum_string_utils_delete_string:
+ * @src_strv: (transfer none): vector of strings
+ * @string: (transfer none): string to delete
+ *
+ * Deletes the string from the strings' vector.
+ *
+ * Returns: (transfer full): modified string vector if string found, NULL
+ * otherwise.
+ */
 gchar **
 gum_string_utils_delete_string (
         gchar **src_strv,
@@ -162,6 +256,16 @@ gum_string_utils_delete_string (
     return dest_strv;
 }
 
+/**
+ * gum_string_utils_append_string:
+ * @src_strv: (transfer none): vector of strings
+ * @string: (transfer none): string to append
+ *
+ * Appends the string to the end of the strings' vector.
+ *
+ * Returns: (transfer full): concatenated string vector if successful, NULL
+ * otherwise.
+ */
 gchar **
 gum_string_utils_append_string (
         gchar **src_strv,
index 482a159..a0809e0 100644 (file)
 #include "common/gum-utils.h"
 #include "common/gum-log.h"
 
+/**
+ * SECTION:gum-utils
+ * @short_description: Utility functions
+ * @title: Gum Utils
+ * @include: gum/common/gum-utils.h
+ *
+ */
 
 typedef struct __nonce_ctx_t
 {
@@ -75,8 +82,17 @@ init_exit:
     return _nonce_ctx.initialized;
 }
 
+/**
+ * gum_generate_nonce:
+ * @algorithm: the #GChecksumType algorithm
+ *
+ * Generates nonce based on hashing algorithm as specified in @algorithm
+ *
+ * Returns: (transfer full): generate nonce if successful, NULL otherwise.
+ */
 gchar *
-gum_generate_nonce ()
+gum_generate_nonce (
+        GChecksumType algorithm)
 {
     GHmac *hmac;
     gchar *nonce = NULL;
@@ -87,15 +103,17 @@ gum_generate_nonce ()
     if (G_UNLIKELY (!_init_nonce_gen()))
         goto nonce_exit;
 
-    hmac = g_hmac_new (G_CHECKSUM_SHA1,
-                       _nonce_ctx.key, sizeof (_nonce_ctx.key));
+    hmac = g_hmac_new (algorithm, _nonce_ctx.key, sizeof (_nonce_ctx.key));
+
     g_hmac_update (hmac, _nonce_ctx.entropy, sizeof (_nonce_ctx.entropy));
+
     _nonce_ctx.serial++;
-    g_hmac_update (hmac,
-                   (const guchar *) &_nonce_ctx.serial,
-                   sizeof (_nonce_ctx.serial));
+    g_hmac_update (hmac, (const guchar *) &_nonce_ctx.serial,
+            sizeof (_nonce_ctx.serial));
+
     if (clock_gettime (CLOCK_MONOTONIC, &ts) == 0)
         g_hmac_update (hmac, (const guchar *) &ts, sizeof (ts));
+
     memset (&ts, 0x00, sizeof(ts));
     nonce = g_strdup (g_hmac_get_string (hmac));
     g_hmac_unref (hmac);
index 9893ced..055c374 100644 (file)
 #include "common/gum-log.h"
 #include "common/gum-error.h"
 
+/**
+ * SECTION:gum-validate
+ * @short_description: Utility functions for validating strings
+ * @title: Gum Validate
+ * @include: gum/common/gum-validate.h
+ *
+ */
+
+/**
+ * GUM_NAME_PATTERN:
+ *
+ * A macro that defines the string pattern to be acceptable for names.
+ */
+
+/**
+ * GUM_DB_ENTRY_PATTERN:
+ *
+ * A macro that defines the string pattern to be acceptable for entries in the
+ * user/group database.
+ */
+
+/**
+ * gum_validate_name:
+ * @name: (transfer none): the name string to be validated
+ * @error: (transfer none): the #GError to be set in case of error
+ *
+ * Validates the name against the #GUM_NAME_PATTERN pattern.
+ *
+ * Returns: TRUE if validation succeeds, FALSE otherwise.
+ */
 gboolean
 gum_validate_name (
         const gchar *name,
@@ -68,6 +98,16 @@ gum_validate_name (
     return TRUE;
 }
 
+/**
+ * gum_validate_generate_username:
+ * @str: (transfer none): the string to be validated
+ * @error: (transfer none): the #GError to be set in case of error
+ *
+ * Generate username based on the string @str and then validate the generated
+ * user name against #GUM_NAME_PATTERN pattern.
+ *
+ * Returns: (transfer full): string if successful, NULL otherwise.
+ */
 gchar *
 gum_validate_generate_username (
         const gchar *str,
@@ -98,6 +138,16 @@ gum_validate_generate_username (
     return gen_name;
 }
 
+/**
+ * gum_validate_db_string_entry_regx:
+ * @str: (transfer none): the string to be validated
+ * @error: (transfer none): the #GError to be set in case of error
+ *
+ * Validates the string @str against the #GUM_DB_ENTRY_PATTERN pattern using
+ * regular expressions.
+ *
+ * Returns: TRUE if validation succeeds, FALSE otherwise.
+ */
 gboolean
 gum_validate_db_string_entry_regx (
         const gchar *str,
@@ -126,6 +176,16 @@ gum_validate_db_string_entry_regx (
     return TRUE;
 }
 
+/**
+ * gum_validate_db_string_entry:
+ * @str: (transfer none): the string to be validated
+ * @error: (transfer none): the #GError to be set in case of error
+ *
+ * Validates the string @str to be used in the user/group database. No control
+ * chars (0x00-0x1F,0x7F), comma (',' 0x2c) or colon (':' 0x3A) is allowed.
+ *
+ * Returns: TRUE if validation succeeds, FALSE otherwise.
+ */
 gboolean
 gum_validate_db_string_entry (
         const gchar *str,
@@ -153,6 +213,16 @@ gum_validate_db_string_entry (
     return TRUE;
 }
 
+/**
+ * gum_validate_db_secret_entry:
+ * @str: (transfer none): the string to be validated
+ * @error: (transfer none): the #GError to be set in case of error
+ *
+ * Validates the string @str to be used as secret in the user/group database.
+ * No control chars (0x00-0x1F,0x7F) or colon (':' 0x3A) is allowed.
+ *
+ * Returns: TRUE if validation succeeds, FALSE otherwise.
+ */
 gboolean
 gum_validate_db_secret_entry (
         const gchar *str,
index f2fadc2..0105c12 100644 (file)
@@ -458,7 +458,7 @@ gumd_dbus_group_adapter_new_with_connection (
     _sync_group_properties (G_OBJECT (adapter->priv->group),
             G_OBJECT (adapter->priv->dbus_group));
 
-    nonce = gum_generate_nonce ();
+    nonce = gum_generate_nonce (G_CHECKSUM_SHA1);
     object_path = g_strdup_printf ("%s/Group_%s_%d",
             GUM_GROUP_SERVICE_OBJECTPATH, nonce, object_counter++);
     g_free (nonce);
index 681899c..119a14d 100644 (file)
@@ -388,7 +388,7 @@ gumd_dbus_user_adapter_new_with_connection (
     _sync_user_properties (G_OBJECT (adapter->priv->user),
             G_OBJECT (adapter->priv->dbus_user));
 
-    nonce = gum_generate_nonce ();
+    nonce = gum_generate_nonce (G_CHECKSUM_SHA1);
     object_path = g_strdup_printf ("%s/User_%s_%d",
             GUM_USER_SERVICE_OBJECTPATH, nonce, object_counter++);
     g_free (nonce);