summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2013-01-22 16:12:34 -0500
committerColin Walters <walters@verbum.org>2013-01-22 18:31:33 -0500
commitd061248c8d5987aed4ca5b287219f316fa9ab351 (patch)
tree6e0a41ebf54f8a06097d7c6ad07dd2ead071df46
parenta505c58cee7c1d4f397fb8c0903cc78221c308b4 (diff)
downloadgdm-d061248c8d5987aed4ca5b287219f316fa9ab351.tar.gz
smartcard: Use g_unix_open_pipe()
Just code cleanup while thinking about: See https://bugzilla.gnome.org/show_bug.cgi?id=672102
-rw-r--r--gui/simple-greeter/extensions/smartcard/gdm-smartcard-manager.c43
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 c7b707f6..0412f2c7 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",