daemon: Clocwork issues fixed.
authorAmarnath Valluri <amarnath.valluri@linux.intel.com>
Tue, 11 Jun 2013 12:40:08 +0000 (15:40 +0300)
committerAmarnath Valluri <amarnath.valluri@linux.intel.com>
Tue, 11 Jun 2013 12:40:54 +0000 (15:40 +0300)
src/common/gsignond-disposable.c
src/daemon/db/gsignond-db-metadata-database.c
src/daemon/dbus/gsignond-dbus-identity-adapter.c
src/daemon/plugins/gsignond-plugin-remote-private.h
src/daemon/plugins/gsignond-plugin-remote.c
src/daemon/plugins/plugind/main.c
src/plugins/digest/gsignond-digest-plugin.c

index 879a1bb..f5bb9fe 100644 (file)
@@ -139,7 +139,7 @@ gsignond_disposable_class_init (GSignondDisposableClass *klass)
                            "Object timeout",
                            "object timeout",
                            0,
-                           G_MAXINT,
+                           G_MAXUINT,
                            0,
                            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
index f0c5025..e191b4a 100644 (file)
@@ -234,7 +234,7 @@ _gsignond_db_metadata_database_update_credentials (
     gchar *query = NULL;
     gint flags = 0;
     guint32 type;
-    gint id;
+    gint64 id;
     const gchar *caption= NULL, *username = NULL;
     gboolean ret = FALSE;
 
index 9ddbdfc..9e236aa 100644 (file)
@@ -79,10 +79,10 @@ struct _GSignondDbusIdentityAdapterPrivate
     GSignondSecurityContext *sec_context;
     GList *sessions;
     /* signal handler ids */
-    guint info_updated_handler_id;
-    guint verify_user_handler_id;
-    guint verify_secret_handler_id;
-    guint credentials_update_handler_id;
+    gulong info_updated_handler_id;
+    gulong verify_user_handler_id;
+    gulong verify_secret_handler_id;
+    gulong credentials_update_handler_id;
 };
 
 G_DEFINE_TYPE (GSignondDbusIdentityAdapter, gsignond_dbus_identity_adapter, GSIGNOND_TYPE_DISPOSABLE)
@@ -695,7 +695,7 @@ _handle_add_reference (GSignondDbusIdentityAdapter *self,
                        const gchar *reference,
                        gpointer user_data)
 {
-    gint32 id = 0;
+    guint32 id = 0;
     GError *error = NULL;
 
     g_return_val_if_fail (self && GSIGNOND_IS_DBUS_IDENTITY_ADAPTER (self), FALSE);
@@ -725,7 +725,7 @@ _handle_remove_reference (GSignondDbusIdentityAdapter *self,
                           const gchar *reference,
                           gpointer user_data)
 {
-    gint32 id = 0;
+    guint32 id = 0;
     GError *error = NULL;
 
     g_return_val_if_fail (self && GSIGNOND_IS_DBUS_IDENTITY_ADAPTER (self), FALSE);
index 7a3850a..98c0da0 100644 (file)
@@ -48,13 +48,13 @@ struct _GSignondPluginRemotePrivate
     gboolean is_plugind_up;
 
     /* Signals */
-    guint signal_response;
-    guint signal_response_final;
-    guint signal_store;
-    guint signal_error;
-    guint signal_user_action_required;
-    guint signal_refreshed;
-    guint signal_status_changed;
+    gulong signal_response;
+    gulong signal_response_final;
+    gulong signal_store;
+    gulong signal_error;
+    gulong signal_user_action_required;
+    gulong signal_refreshed;
+    gulong signal_status_changed;
 };
 
 G_END_DECLS
index 3adbbbc..f0ab0cb 100644 (file)
@@ -717,7 +717,8 @@ gsignond_plugin_remote_new (
             NULL, &cpid, &cin_fd, &cout_fd, &cerr_fd, &error);
     g_strfreev (argv);
     if (ret == FALSE || (kill(cpid, 0) != 0)) {
-        DBG ("failed to start plugind: error %s(%d)", error->message, ret);
+        DBG ("failed to start plugind: error %s(%d)", 
+            error ? error->message : "(null)", ret);
         if (error) g_error_free (error);
         return NULL;
     }
index f09ac60..727a3f1 100644 (file)
@@ -98,6 +98,7 @@ int main (int argc, char **argv)
     GOptionContext *opt_context = NULL;
     gchar **plugin_args = NULL;
     gint up_signal = -1;
+    gint in_fd = 0, out_fd = 1, err_fd = 2;
     GOptionEntry opt_entries[] = {
         {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &plugin_args,
                 "Plugin Args", NULL},
@@ -108,17 +109,29 @@ int main (int argc, char **argv)
      * to /dev/null to avoid anyone writing to descriptors before initial
      * "plugind-is-ready" notification is sent to gsignond
      * */
-    gint in_fd = dup(0);
+    in_fd = dup(0);
+    if (in_fd == -1) {
+        WARN ("Failed to dup stdin : %s(%d)", strerror(errno), errno);
+        in_fd = 0;
+    }
     if (!freopen("/dev/null", "r+", stdin)) {
         WARN ("Unable to redirect stdin to /dev/null");
     }
 
-    gint out_fd = dup(1);
+    out_fd = dup(1);
+    if (out_fd == -1) {
+        WARN ("Failed to dup stdout : %s(%d)", strerror(errno), errno);
+        out_fd = 1;
+    }
     if(!freopen("/dev/null", "r+", stdout)) {
         WARN ("Unable to redirect stdout to /dev/null");
     }
 
-    gint err_fd = dup(2);
+    err_fd = dup(2);
+    if (err_fd == -1) {
+        WARN ("Failed to dup stderr : %s(%d)", strerror(errno), errno);
+        err_fd = 2;
+    }
     if (!freopen("/dev/null", "r+", stderr)) {
         WARN ("Unable to redirect stderr to /dev/null");
     }
@@ -130,13 +143,18 @@ int main (int argc, char **argv)
     opt_context = g_option_context_new ("<plugin_path> <plugin_name>");
     g_option_context_set_summary (opt_context, "gSSO helper plugin daemon");
     g_option_context_add_main_entries (opt_context, opt_entries, NULL);
+    g_option_context_set_ignore_unknown_options (opt_context, TRUE);
     g_option_context_parse (opt_context, &argc, &argv, &error);
     g_option_context_free (opt_context);
-    if (error || !plugin_args || !plugin_args[0] || !plugin_args[1]) {
-        close (in_fd);
-        close (out_fd);
-        close (err_fd);
-        if (error) g_error_free (error);
+    if (error) {
+        WARN ("Error in arguments parsing: %s", error->message);
+        g_error_free (error);
+    }
+    if (!plugin_args || !plugin_args[0] || !plugin_args[1]) {
+        WARN ("plugin path or plugin type missing");
+        if (in_fd != 0) close (in_fd);
+        if (out_fd != 1) close (out_fd);
+        if (err_fd != 2) close (err_fd);
         if (plugin_args) g_strfreev(plugin_args);
         return -1;
     }
@@ -145,9 +163,9 @@ int main (int argc, char **argv)
             out_fd);
     g_strfreev(plugin_args);
     if (_daemon == NULL) {
-        close (in_fd);
-        close (out_fd);
-        close (err_fd);
+        if (in_fd != 0) close (in_fd);
+        if (out_fd != 1) close (out_fd);
+        if (err_fd != 2) close (err_fd);
         return -1;
     }
 
@@ -176,7 +194,7 @@ int main (int argc, char **argv)
     if(_daemon) {
         g_object_unref (_daemon);
     }
+
     if (main_loop) {
         g_main_loop_unref (main_loop);
     }
index b446a98..cd091ea 100644 (file)
@@ -101,7 +101,7 @@ _gsignond_digest_plugin_compute_md5_digest (
     g_checksum_update (a2, TO_GUCHAR(method), strlen(method));
     g_checksum_update (a2, TO_GUCHAR(":"), 1);
     g_checksum_update (a2, TO_GUCHAR(digest_uri), strlen(digest_uri));
-    if (qop && g_strcmp0 (qop, "auth-int") == 0) {
+    if (qop && g_strcmp0 (qop, "auth-int") == 0 && hentity) {
         g_checksum_update (a2, TO_GUCHAR(":"), 1);
         g_checksum_update (a2, TO_GUCHAR(hentity), strlen(hentity));
     }
@@ -300,6 +300,16 @@ gsignond_digest_plugin_user_action_finished (
         const gchar* hentity = gsignond_dictionary_get_string (session_data,
                 "HEntity");
         gchar *cnonce = _gsignond_digest_plugin_generate_nonce (priv);
+
+        if ((!realm || !algo  || !nonce  || !method  || !digest_uri)
+            || (qop && g_strcmp0 (qop, "auth-int") == 0 && !hentity)
+            || (qop && !nonce_count)) {
+            GError* error = g_error_new (GSIGNOND_ERROR,
+                       GSIGNOND_ERROR_MISSING_DATA, "Missing Session Data");
+            gsignond_plugin_error (plugin, error);
+            g_error_free (error);
+            return;
+        }
         gchar *digest = _gsignond_digest_plugin_compute_md5_digest(algo,
                 username,realm, secret, nonce, nonce_count, cnonce, qop, method,
                 digest_uri, hentity);