[gdm] smartcard: Use g_unix_open_pipe()



commit d061248c8d5987aed4ca5b287219f316fa9ab351
Author: Colin Walters <walters verbum org>
Date:   Tue Jan 22 16:12:34 2013 -0500

    smartcard: Use g_unix_open_pipe()
    
    Just code cleanup while thinking about:
    See https://bugzilla.gnome.org/show_bug.cgi?id=672102

 .../extensions/smartcard/gdm-smartcard-manager.c   |   43 ++-----------------
 1 files changed, 5 insertions(+), 38 deletions(-)
---
diff --git a/gui/simple-greeter/extensions/smartcard/gdm-smartcard-manager.c b/gui/simple-greeter/extensions/smartcard/gdm-smartcard-manager.c
index c7b707f..0412f2c 100644
--- a/gui/simple-greeter/extensions/smartcard/gdm-smartcard-manager.c
+++ b/gui/simple-greeter/extensions/smartcard/gdm-smartcard-manager.c
@@ -40,6 +40,7 @@
 #include <unistd.h>
 
 #include <glib.h>
+#include <glib-unix.h>
 #include <glib/gi18n.h>
 
 #include <prerror.h>
@@ -132,7 +133,6 @@ static GdmSmartcardManagerWorker * gdm_smartcard_manager_worker_new (GdmSmartcar
                                                                      int                  manager_fd,
                                                                      SECMODModule        *module);
 static void gdm_smartcard_manager_worker_free (GdmSmartcardManagerWorker *worker);
-static gboolean gdm_open_pipe (gint *write_fd, gint *read_fd);
 static gboolean sc_read_bytes (gint fd, gpointer bytes, gsize num_bytes);
 static gboolean sc_write_bytes (gint fd, gconstpointer bytes, gsize num_bytes);
 static GdmSmartcard *sc_read_smartcard (gint fd, SECMODModule *module);
@@ -575,37 +575,6 @@ gdm_smartcard_manager_event_processing_stopped_handler (GdmSmartcardManagerWorke
         stop_worker (worker);
 }
 
-static gboolean
-gdm_open_pipe (gint *write_fd,
-                  gint *read_fd)
-{
-        gint pipe_fds[2] = { -1, -1 };
-
-        g_assert (write_fd != NULL);
-        g_assert (read_fd != NULL);
-
-        if (pipe (pipe_fds) < 0) {
-                return FALSE;
-        }
-
-        if (fcntl (pipe_fds[0], F_SETFD, FD_CLOEXEC) < 0) {
-                close (pipe_fds[0]);
-                close (pipe_fds[1]);
-                return FALSE;
-        }
-
-        if (fcntl (pipe_fds[1], F_SETFD, FD_CLOEXEC) < 0) {
-                close (pipe_fds[0]);
-                close (pipe_fds[1]);
-                return FALSE;
-        }
-
-        *read_fd = pipe_fds[0];
-        *write_fd = pipe_fds[1];
-
-        return TRUE;
-}
-
 static void
 gdm_smartcard_manager_stop_watching_for_events (GdmSmartcardManager  *manager)
 {
@@ -1360,17 +1329,15 @@ gdm_smartcard_manager_create_worker (GdmSmartcardManager  *manager,
                                      SECMODModule         *module)
 {
         GdmSmartcardManagerWorker *worker;
-        gint write_fd, read_fd;
+	gint pipefds[2];
 
-        write_fd = -1;
-        read_fd = -1;
-        if (!gdm_open_pipe (&write_fd, &read_fd)) {
+        if (!g_unix_open_pipe (pipefds, FD_CLOEXEC)) {
                 return FALSE;
         }
 
         worker = gdm_smartcard_manager_worker_new (manager,
-                                                   write_fd,
-                                                   read_fd,
+                                                   pipefds[1],
+                                                   pipefds[0],
                                                    module);
 
         worker->thread = g_thread_new ("smartcard",



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]