summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Jon McCann <mccann@jhu.edu>2007-08-28 20:06:58 +0000
committerWilliam Jon McCann <mccann@src.gnome.org>2007-08-28 20:06:58 +0000
commit77b6d6f45367ebf5e0a045a0a7ec7efadd3eb5fa (patch)
treeadeadb2ab532f60cf2952584935f4088b7569dd5
parentaf364b9934700cc5641717dfa97ecd40e0657944 (diff)
downloadgdm-77b6d6f45367ebf5e0a045a0a7ec7efadd3eb5fa.tar.gz
Mass change tabs to spaces. Tabs suck.
2007-08-28 William Jon McCann <mccann@jhu.edu> * common/gdm-address.c: * common/gdm-address.h: * common/gdm-common.c: * common/gdm-common.h: * common/gdm-log.c: * common/gdm-log.h: * common/gdm-md5.c: * common/gdm-md5.h: * common/gdm-settings-backend.c: * common/gdm-settings-backend.h: * common/gdm-settings-client.c: * common/gdm-settings-client.h: * common/gdm-settings-desktop-backend.c: * common/gdm-settings-desktop-backend.h: * common/gdm-settings-direct.c: * common/gdm-settings-direct.h: * common/gdm-settings-keys.h: * common/gdm-settings-utils.c: * common/gdm-settings-utils.h: * common/gdm-settings.c: * common/gdm-settings.h: * common/gdm-signal-handler.c: * common/gdm-signal-handler.h: * common/ve-signal.c: * common/ve-signal.h: * daemon/auth.c: * daemon/choose.c: * daemon/choose.h: * daemon/factory-slave-main.c: * daemon/filecheck.c: * daemon/gdm-display-factory.c: * daemon/gdm-display-factory.h: * daemon/gdm-display-store.c: * daemon/gdm-display-store.h: * daemon/gdm-display.c: * daemon/gdm-display.h: * daemon/gdm-factory-slave.c: * daemon/gdm-factory-slave.h: * daemon/gdm-greeter-proxy.c: * daemon/gdm-greeter-proxy.h: * daemon/gdm-greeter-server.c: * daemon/gdm-greeter-server.h: * daemon/gdm-local-display-factory.c: * daemon/gdm-local-display-factory.h: * daemon/gdm-manager.c: * daemon/gdm-manager.h: * daemon/gdm-product-display.c: * daemon/gdm-product-display.h: * daemon/gdm-product-slave.c: * daemon/gdm-product-slave.h: * daemon/gdm-server.c: * daemon/gdm-server.h: * daemon/gdm-session-relay.c: * daemon/gdm-session-relay.h: * daemon/gdm-session-worker-job.c: * daemon/gdm-session-worker-job.h: * daemon/gdm-session-worker.c: * daemon/gdm-session-worker.h: * daemon/gdm-session.c: * daemon/gdm-session.h: * daemon/gdm-simple-slave.c: * daemon/gdm-simple-slave.h: * daemon/gdm-slave-proxy.c: * daemon/gdm-slave-proxy.h: * daemon/gdm-slave.c: * daemon/gdm-slave.h: * daemon/gdm-static-display.c: * daemon/gdm-static-display.h: * daemon/gdm-static-factory-display.c: * daemon/gdm-static-factory-display.h: * daemon/gdm-xdmcp-display-factory.c: * daemon/gdm-xdmcp-display-factory.h: * daemon/gdm-xdmcp-display.c: * daemon/gdm-xdmcp-display.h: * daemon/main.c: * daemon/product-slave-main.c: * daemon/session-worker-main.c: * daemon/simple-slave-main.c: * daemon/test-hal-seats.c: * daemon/test-session.c: * gui/simple-greeter/gdm-simple-greeter.c: * gui/simple-greeter/gdm-simple-greeter.h: * gui/simple-greeter/greeter-main.c: * libgreeter/gdm-greeter.c: * libgreeter/gdm-greeter.h: * libgreeter/gdmlanguages.c: * libgreeter/gdmsession.c: Mass change tabs to spaces. Tabs suck. svn path=/branches/mccann-gobject/; revision=5196
-rw-r--r--ChangeLog91
-rw-r--r--common/gdm-address.c438
-rw-r--r--common/gdm-address.h12
-rw-r--r--common/gdm-common.c1078
-rw-r--r--common/gdm-common.h84
-rw-r--r--common/gdm-log.c252
-rw-r--r--common/gdm-log.h4
-rw-r--r--common/gdm-md5.c446
-rw-r--r--common/gdm-md5.h12
-rw-r--r--common/gdm-settings-backend.c148
-rw-r--r--common/gdm-settings-backend.h66
-rw-r--r--common/gdm-settings-client.c602
-rw-r--r--common/gdm-settings-client.h34
-rw-r--r--common/gdm-settings-desktop-backend.c464
-rw-r--r--common/gdm-settings-desktop-backend.h10
-rw-r--r--common/gdm-settings-direct.c208
-rw-r--r--common/gdm-settings-direct.h20
-rw-r--r--common/gdm-settings-keys.h4
-rw-r--r--common/gdm-settings-utils.c302
-rw-r--r--common/gdm-settings-utils.h16
-rw-r--r--common/gdm-settings.c210
-rw-r--r--common/gdm-settings.h38
-rw-r--r--common/gdm-signal-handler.c384
-rw-r--r--common/gdm-signal-handler.h22
-rw-r--r--common/test-settings-client.c2
-rw-r--r--common/test-settings-server.c180
-rw-r--r--common/ve-signal.c122
-rw-r--r--common/ve-signal.h22
-rw-r--r--daemon/auth.c322
-rw-r--r--daemon/choose.c460
-rw-r--r--daemon/choose.h20
-rw-r--r--daemon/ck-connector.c2
-rw-r--r--daemon/factory-slave-main.c282
-rw-r--r--daemon/filecheck.c258
-rw-r--r--daemon/filecheck.h6
-rw-r--r--daemon/gdm-display-factory.c162
-rw-r--r--daemon/gdm-display-factory.h18
-rw-r--r--daemon/gdm-display-store.c182
-rw-r--r--daemon/gdm-display-store.h44
-rw-r--r--daemon/gdm-display.c784
-rw-r--r--daemon/gdm-display.h84
-rw-r--r--daemon/gdm-factory-slave.c1304
-rw-r--r--daemon/gdm-factory-slave.h10
-rw-r--r--daemon/gdm-greeter-proxy.c1120
-rw-r--r--daemon/gdm-greeter-proxy.h24
-rw-r--r--daemon/gdm-greeter-server.c1006
-rw-r--r--daemon/gdm-greeter-server.h42
-rw-r--r--daemon/gdm-local-display-factory.c320
-rw-r--r--daemon/gdm-local-display-factory.h16
-rw-r--r--daemon/gdm-manager.c368
-rw-r--r--daemon/gdm-manager.h32
-rw-r--r--daemon/gdm-product-display.c230
-rw-r--r--daemon/gdm-product-display.h20
-rw-r--r--daemon/gdm-product-slave.c1924
-rw-r--r--daemon/gdm-product-slave.h10
-rw-r--r--daemon/gdm-server.c1252
-rw-r--r--daemon/gdm-server.h14
-rw-r--r--daemon/gdm-session-relay.c1038
-rw-r--r--daemon/gdm-session-relay.h64
-rw-r--r--daemon/gdm-session-worker-job.c522
-rw-r--r--daemon/gdm-session-worker-job.h26
-rw-r--r--daemon/gdm-session-worker.c2564
-rw-r--r--daemon/gdm-session-worker.h32
-rw-r--r--daemon/gdm-session.c2094
-rw-r--r--daemon/gdm-session.h94
-rw-r--r--daemon/gdm-simple-slave.c1802
-rw-r--r--daemon/gdm-simple-slave.h10
-rw-r--r--daemon/gdm-slave-proxy.c364
-rw-r--r--daemon/gdm-slave-proxy.h22
-rw-r--r--daemon/gdm-slave.c870
-rw-r--r--daemon/gdm-slave.h24
-rw-r--r--daemon/gdm-static-display.c154
-rw-r--r--daemon/gdm-static-display.h12
-rw-r--r--daemon/gdm-static-factory-display.c288
-rw-r--r--daemon/gdm-static-factory-display.h20
-rw-r--r--daemon/gdm-xdmcp-display-factory.c4406
-rw-r--r--daemon/gdm-xdmcp-display-factory.h18
-rw-r--r--daemon/gdm-xdmcp-display.c414
-rw-r--r--daemon/gdm-xdmcp-display.h18
-rw-r--r--daemon/main.c912
-rw-r--r--daemon/product-slave-main.c282
-rw-r--r--daemon/session-worker-main.c182
-rw-r--r--daemon/simple-slave-main.c278
-rw-r--r--daemon/test-hal-seats.c168
-rw-r--r--daemon/test-session.c246
-rw-r--r--gui/simple-greeter/gdm-simple-greeter.c454
-rw-r--r--gui/simple-greeter/gdm-simple-greeter.h12
-rw-r--r--gui/simple-greeter/greeter-main.c508
-rw-r--r--libgreeter/gdm-greeter.c420
-rw-r--r--libgreeter/gdm-greeter.h80
-rw-r--r--libgreeter/gdmlanguages.c1286
-rw-r--r--libgreeter/gdmlanguages.h42
-rw-r--r--libgreeter/gdmsession.c730
-rw-r--r--libgreeter/gdmsession.h38
-rw-r--r--libgreeter/gdmwm.c2520
-rw-r--r--libgreeter/gdmwm.h32
96 files changed, 19362 insertions, 19271 deletions
diff --git a/ChangeLog b/ChangeLog
index b2c32d61..6e7c52b5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,96 @@
2007-08-28 William Jon McCann <mccann@jhu.edu>
+ * common/gdm-address.c:
+ * common/gdm-address.h:
+ * common/gdm-common.c:
+ * common/gdm-common.h:
+ * common/gdm-log.c:
+ * common/gdm-log.h:
+ * common/gdm-md5.c:
+ * common/gdm-md5.h:
+ * common/gdm-settings-backend.c:
+ * common/gdm-settings-backend.h:
+ * common/gdm-settings-client.c:
+ * common/gdm-settings-client.h:
+ * common/gdm-settings-desktop-backend.c:
+ * common/gdm-settings-desktop-backend.h:
+ * common/gdm-settings-direct.c:
+ * common/gdm-settings-direct.h:
+ * common/gdm-settings-keys.h:
+ * common/gdm-settings-utils.c:
+ * common/gdm-settings-utils.h:
+ * common/gdm-settings.c:
+ * common/gdm-settings.h:
+ * common/gdm-signal-handler.c:
+ * common/gdm-signal-handler.h:
+ * common/ve-signal.c:
+ * common/ve-signal.h:
+ * daemon/auth.c:
+ * daemon/choose.c:
+ * daemon/choose.h:
+ * daemon/factory-slave-main.c:
+ * daemon/filecheck.c:
+ * daemon/gdm-display-factory.c:
+ * daemon/gdm-display-factory.h:
+ * daemon/gdm-display-store.c:
+ * daemon/gdm-display-store.h:
+ * daemon/gdm-display.c:
+ * daemon/gdm-display.h:
+ * daemon/gdm-factory-slave.c:
+ * daemon/gdm-factory-slave.h:
+ * daemon/gdm-greeter-proxy.c:
+ * daemon/gdm-greeter-proxy.h:
+ * daemon/gdm-greeter-server.c:
+ * daemon/gdm-greeter-server.h:
+ * daemon/gdm-local-display-factory.c:
+ * daemon/gdm-local-display-factory.h:
+ * daemon/gdm-manager.c:
+ * daemon/gdm-manager.h:
+ * daemon/gdm-product-display.c:
+ * daemon/gdm-product-display.h:
+ * daemon/gdm-product-slave.c:
+ * daemon/gdm-product-slave.h:
+ * daemon/gdm-server.c:
+ * daemon/gdm-server.h:
+ * daemon/gdm-session-relay.c:
+ * daemon/gdm-session-relay.h:
+ * daemon/gdm-session-worker-job.c:
+ * daemon/gdm-session-worker-job.h:
+ * daemon/gdm-session-worker.c:
+ * daemon/gdm-session-worker.h:
+ * daemon/gdm-session.c:
+ * daemon/gdm-session.h:
+ * daemon/gdm-simple-slave.c:
+ * daemon/gdm-simple-slave.h:
+ * daemon/gdm-slave-proxy.c:
+ * daemon/gdm-slave-proxy.h:
+ * daemon/gdm-slave.c:
+ * daemon/gdm-slave.h:
+ * daemon/gdm-static-display.c:
+ * daemon/gdm-static-display.h:
+ * daemon/gdm-static-factory-display.c:
+ * daemon/gdm-static-factory-display.h:
+ * daemon/gdm-xdmcp-display-factory.c:
+ * daemon/gdm-xdmcp-display-factory.h:
+ * daemon/gdm-xdmcp-display.c:
+ * daemon/gdm-xdmcp-display.h:
+ * daemon/main.c:
+ * daemon/product-slave-main.c:
+ * daemon/session-worker-main.c:
+ * daemon/simple-slave-main.c:
+ * daemon/test-hal-seats.c:
+ * daemon/test-session.c:
+ * gui/simple-greeter/gdm-simple-greeter.c:
+ * gui/simple-greeter/gdm-simple-greeter.h:
+ * gui/simple-greeter/greeter-main.c:
+ * libgreeter/gdm-greeter.c:
+ * libgreeter/gdm-greeter.h:
+ * libgreeter/gdmlanguages.c:
+ * libgreeter/gdmsession.c:
+ Mass change tabs to spaces. Tabs suck.
+
+2007-08-28 William Jon McCann <mccann@jhu.edu>
+
* daemon/gdm-factory-slave.c: (on_greeter_answer):
* daemon/gdm-greeter-server.c: (handle_answer_query):
* daemon/gdm-product-slave.c: (on_relay_answer):
diff --git a/common/gdm-address.c b/common/gdm-address.c
index d376610a..356e9159 100644
--- a/common/gdm-address.c
+++ b/common/gdm-address.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -47,22 +47,22 @@
struct _GdmAddress
{
- struct sockaddr_storage *ss;
+ struct sockaddr_storage *ss;
};
/* Register GdmAddress in the glib type system */
GType
gdm_address_get_type (void)
{
- static GType addr_type = 0;
+ static GType addr_type = 0;
- if (addr_type == 0) {
- addr_type = g_boxed_type_register_static ("GdmAddress",
- (GBoxedCopyFunc) gdm_address_copy,
- (GBoxedFreeFunc) gdm_address_free);
- }
+ if (addr_type == 0) {
+ addr_type = g_boxed_type_register_static ("GdmAddress",
+ (GBoxedCopyFunc) gdm_address_copy,
+ (GBoxedFreeFunc) gdm_address_free);
+ }
- return addr_type;
+ return addr_type;
}
/**
@@ -94,14 +94,14 @@ gdm_address_get_family_type (GdmAddress *address)
GdmAddress *
gdm_address_new_from_sockaddr_storage (struct sockaddr_storage *ss)
{
- GdmAddress *addr;
+ GdmAddress *addr;
- g_return_val_if_fail (ss != NULL, NULL);
+ g_return_val_if_fail (ss != NULL, NULL);
- addr = g_new0 (GdmAddress, 1);
- addr->ss = g_memdup (ss, sizeof (struct sockaddr_storage));
+ addr = g_new0 (GdmAddress, 1);
+ addr->ss = g_memdup (ss, sizeof (struct sockaddr_storage));
- return addr;
+ return addr;
}
/**
@@ -117,237 +117,237 @@ gdm_address_new_from_sockaddr_storage (struct sockaddr_storage *ss)
struct sockaddr_storage *
gdm_address_get_sockaddr_storage (GdmAddress *address)
{
- struct sockaddr_storage *ss;
+ struct sockaddr_storage *ss;
- g_return_val_if_fail (address != NULL, NULL);
+ g_return_val_if_fail (address != NULL, NULL);
- ss = g_memdup (address->ss, sizeof (struct sockaddr_storage));
+ ss = g_memdup (address->ss, sizeof (struct sockaddr_storage));
- return ss;
+ return ss;
}
struct sockaddr_storage *
gdm_address_peek_sockaddr_storage (GdmAddress *address)
{
- g_return_val_if_fail (address != NULL, NULL);
+ g_return_val_if_fail (address != NULL, NULL);
- return address->ss;
+ return address->ss;
}
static gboolean
v4_v4_equal (const struct sockaddr_in *a,
- const struct sockaddr_in *b)
+ const struct sockaddr_in *b)
{
- return a->sin_addr.s_addr == b->sin_addr.s_addr;
+ return a->sin_addr.s_addr == b->sin_addr.s_addr;
}
#ifdef ENABLE_IPV6
static gboolean
v6_v6_equal (struct sockaddr_in6 *a,
- struct sockaddr_in6 *b)
+ struct sockaddr_in6 *b)
{
- return IN6_ARE_ADDR_EQUAL (&a->sin6_addr, &b->sin6_addr);
+ return IN6_ARE_ADDR_EQUAL (&a->sin6_addr, &b->sin6_addr);
}
#endif
-#define SA(__s) ((struct sockaddr *) __s)
+#define SA(__s) ((struct sockaddr *) __s)
#define SIN(__s) ((struct sockaddr_in *) __s)
#define SIN6(__s) ((struct sockaddr_in6 *) __s)
gboolean
gdm_address_equal (GdmAddress *a,
- GdmAddress *b)
+ GdmAddress *b)
{
- guint8 fam_a;
- guint8 fam_b;
+ guint8 fam_a;
+ guint8 fam_b;
- g_return_val_if_fail (a != NULL || a->ss != NULL, FALSE);
- g_return_val_if_fail (b != NULL || b->ss != NULL, FALSE);
+ g_return_val_if_fail (a != NULL || a->ss != NULL, FALSE);
+ g_return_val_if_fail (b != NULL || b->ss != NULL, FALSE);
- fam_a = a->ss->ss_family;
- fam_b = b->ss->ss_family;
+ fam_a = a->ss->ss_family;
+ fam_b = b->ss->ss_family;
- if (fam_a == AF_INET && fam_b == AF_INET) {
- return v4_v4_equal (SIN (a->ss), SIN (b->ss));
- }
+ if (fam_a == AF_INET && fam_b == AF_INET) {
+ return v4_v4_equal (SIN (a->ss), SIN (b->ss));
+ }
#ifdef ENABLE_IPV6
- else if (fam_a == AF_INET6 && fam_b == AF_INET6) {
- return v6_v6_equal (SIN6 (a->ss), SIN6 (b->ss));
- }
+ else if (fam_a == AF_INET6 && fam_b == AF_INET6) {
+ return v6_v6_equal (SIN6 (a->ss), SIN6 (b->ss));
+ }
#endif
- return FALSE;
+ return FALSE;
}
gboolean
gdm_address_get_hostname (GdmAddress *address,
- char **hostnamep)
+ char **hostnamep)
{
- char host [NI_MAXHOST];
- int res;
- gboolean ret;
-
- g_return_val_if_fail (address != NULL || address->ss != NULL, FALSE);
-
- ret = FALSE;
-
- host [0] = '\0';
- res = getnameinfo ((const struct sockaddr *)address->ss,
- sizeof (struct sockaddr_storage),
- host, sizeof (host),
- NULL, 0,
- 0);
- if (res == 0) {
- ret = TRUE;
- goto done;
- } else {
- g_warning ("Unable lookup hostname: %s", gai_strerror (res));
- gdm_address_debug (address);
- }
-
- /* try numeric? */
+ char host [NI_MAXHOST];
+ int res;
+ gboolean ret;
+
+ g_return_val_if_fail (address != NULL || address->ss != NULL, FALSE);
+
+ ret = FALSE;
+
+ host [0] = '\0';
+ res = getnameinfo ((const struct sockaddr *)address->ss,
+ sizeof (struct sockaddr_storage),
+ host, sizeof (host),
+ NULL, 0,
+ 0);
+ if (res == 0) {
+ ret = TRUE;
+ goto done;
+ } else {
+ g_warning ("Unable lookup hostname: %s", gai_strerror (res));
+ gdm_address_debug (address);
+ }
+
+ /* try numeric? */
done:
- if (hostnamep != NULL) {
- *hostnamep = g_strdup (host);
- }
+ if (hostnamep != NULL) {
+ *hostnamep = g_strdup (host);
+ }
- return ret;
+ return ret;
}
gboolean
gdm_address_get_numeric_info (GdmAddress *address,
- char **hostp,
- char **servp)
+ char **hostp,
+ char **servp)
{
- char host [NI_MAXHOST];
- char serv [NI_MAXSERV];
- int res;
- gboolean ret;
-
- g_return_val_if_fail (address != NULL || address->ss != NULL, FALSE);
-
- ret = FALSE;
-
- host [0] = '\0';
- serv [0] = '\0';
- res = getnameinfo ((const struct sockaddr *)address->ss,
- sizeof (struct sockaddr_storage),
- host, sizeof (host),
- serv, sizeof (serv),
- NI_NUMERICHOST | NI_NUMERICSERV);
- if (res != 0) {
- g_warning ("Unable lookup numeric info: %s", gai_strerror (res));
- } else {
- ret = TRUE;
- }
-
- if (servp != NULL) {
- *servp = g_strdup (serv);
- }
- if (hostp != NULL) {
- *hostp = g_strdup (host);
- }
-
- return ret;
+ char host [NI_MAXHOST];
+ char serv [NI_MAXSERV];
+ int res;
+ gboolean ret;
+
+ g_return_val_if_fail (address != NULL || address->ss != NULL, FALSE);
+
+ ret = FALSE;
+
+ host [0] = '\0';
+ serv [0] = '\0';
+ res = getnameinfo ((const struct sockaddr *)address->ss,
+ sizeof (struct sockaddr_storage),
+ host, sizeof (host),
+ serv, sizeof (serv),
+ NI_NUMERICHOST | NI_NUMERICSERV);
+ if (res != 0) {
+ g_warning ("Unable lookup numeric info: %s", gai_strerror (res));
+ } else {
+ ret = TRUE;
+ }
+
+ if (servp != NULL) {
+ *servp = g_strdup (serv);
+ }
+ if (hostp != NULL) {
+ *hostp = g_strdup (host);
+ }
+
+ return ret;
}
gboolean
gdm_address_is_loopback (GdmAddress *address)
{
- g_return_val_if_fail (address != NULL || address->ss != NULL, FALSE);
+ g_return_val_if_fail (address != NULL || address->ss != NULL, FALSE);
- switch (address->ss->ss_family){
-#ifdef AF_INET6
- case AF_INET6:
- return IN6_IS_ADDR_LOOPBACK (&((struct sockaddr_in6 *)address->ss)->sin6_addr);
- break;
+ switch (address->ss->ss_family){
+#ifdef AF_INET6
+ case AF_INET6:
+ return IN6_IS_ADDR_LOOPBACK (&((struct sockaddr_in6 *)address->ss)->sin6_addr);
+ break;
#endif
- case AF_INET:
- return (INADDR_LOOPBACK == (((struct sockaddr_in *)address->ss)->sin_addr.s_addr));
- break;
- default:
- break;
- }
-
- return FALSE;
+ case AF_INET:
+ return (INADDR_LOOPBACK == (((struct sockaddr_in *)address->ss)->sin_addr.s_addr));
+ break;
+ default:
+ break;
+ }
+
+ return FALSE;
}
const GList *
gdm_address_peek_local_list (void)
{
- static GList *the_list = NULL;
- static time_t last_time = 0;
- char hostbuf[BUFSIZ];
- struct addrinfo hints;
- struct addrinfo *result;
- struct addrinfo *res;
-
- /* Don't check more then every 5 seconds */
- if (last_time + 5 > time (NULL)) {
- return the_list;
- }
-
- g_list_foreach (the_list, (GFunc)gdm_address_free, NULL);
- g_list_free (the_list);
- the_list = NULL;
-
- last_time = time (NULL);
-
- hostbuf[BUFSIZ-1] = '\0';
- if (gethostname (hostbuf, BUFSIZ-1) != 0) {
- g_debug ("%s: Could not get server hostname, using localhost", "gdm_peek_local_address_list");
- snprintf (hostbuf, BUFSIZ-1, "localhost");
- }
-
- memset (&hints, 0, sizeof (hints));
- hints.ai_family = AF_INET;
+ static GList *the_list = NULL;
+ static time_t last_time = 0;
+ char hostbuf[BUFSIZ];
+ struct addrinfo hints;
+ struct addrinfo *result;
+ struct addrinfo *res;
+
+ /* Don't check more then every 5 seconds */
+ if (last_time + 5 > time (NULL)) {
+ return the_list;
+ }
+
+ g_list_foreach (the_list, (GFunc)gdm_address_free, NULL);
+ g_list_free (the_list);
+ the_list = NULL;
+
+ last_time = time (NULL);
+
+ hostbuf[BUFSIZ-1] = '\0';
+ if (gethostname (hostbuf, BUFSIZ-1) != 0) {
+ g_debug ("%s: Could not get server hostname, using localhost", "gdm_peek_local_address_list");
+ snprintf (hostbuf, BUFSIZ-1, "localhost");
+ }
+
+ memset (&hints, 0, sizeof (hints));
+ hints.ai_family = AF_INET;
#ifdef ENABLE_IPV6
- hints.ai_family |= AF_INET6;
+ hints.ai_family |= AF_INET6;
#endif
- if (getaddrinfo (hostbuf, NULL, &hints, &result) != 0) {
- g_debug ("%s: Could not get address from hostname!", "gdm_peek_local_address_list");
+ if (getaddrinfo (hostbuf, NULL, &hints, &result) != 0) {
+ g_debug ("%s: Could not get address from hostname!", "gdm_peek_local_address_list");
- return NULL;
- }
+ return NULL;
+ }
- for (res = result; res != NULL; res = res->ai_next) {
- GdmAddress *address;
+ for (res = result; res != NULL; res = res->ai_next) {
+ GdmAddress *address;
- address = gdm_address_new_from_sockaddr_storage ((struct sockaddr_storage *)res->ai_addr);
- the_list = g_list_append (the_list, address);
- }
+ address = gdm_address_new_from_sockaddr_storage ((struct sockaddr_storage *)res->ai_addr);
+ the_list = g_list_append (the_list, address);
+ }
- if (result != NULL) {
- freeaddrinfo (result);
- result = NULL;
- }
+ if (result != NULL) {
+ freeaddrinfo (result);
+ result = NULL;
+ }
- return the_list;
+ return the_list;
}
gboolean
gdm_address_is_local (GdmAddress *address)
{
- const GList *list;
+ const GList *list;
- if (gdm_address_is_loopback (address)) {
- return TRUE;
- }
+ if (gdm_address_is_loopback (address)) {
+ return TRUE;
+ }
- list = gdm_address_peek_local_list ();
+ list = gdm_address_peek_local_list ();
- while (list != NULL) {
- GdmAddress *addr = list->data;
+ while (list != NULL) {
+ GdmAddress *addr = list->data;
- if (gdm_address_equal (address, addr)) {
- return TRUE;
- }
+ if (gdm_address_equal (address, addr)) {
+ return TRUE;
+ }
- list = list->next;
- }
+ list = list->next;
+ }
- return FALSE;
+ return FALSE;
}
/**
@@ -361,14 +361,14 @@ gdm_address_is_local (GdmAddress *address)
GdmAddress *
gdm_address_copy (GdmAddress *address)
{
- GdmAddress *addr;
+ GdmAddress *addr;
- g_return_val_if_fail (address != NULL, NULL);
+ g_return_val_if_fail (address != NULL, NULL);
- addr = g_new0 (GdmAddress, 1);
- addr->ss = g_memdup (address->ss, sizeof (struct sockaddr_storage));
+ addr = g_new0 (GdmAddress, 1);
+ addr->ss = g_memdup (address->ss, sizeof (struct sockaddr_storage));
- return addr;
+ return addr;
}
/**
@@ -380,63 +380,63 @@ gdm_address_copy (GdmAddress *address)
void
gdm_address_free (GdmAddress *address)
{
- g_return_if_fail (address != NULL);
+ g_return_if_fail (address != NULL);
- g_free (address->ss);
- g_free (address);
+ g_free (address->ss);
+ g_free (address);
}
/* for debugging */
static const char *
address_family_str (GdmAddress *address)
{
- const char *str;
- switch (address->ss->ss_family) {
- case AF_INET:
- str = "inet";
- break;
- case AF_INET6:
- str = "inet6";
- break;
- case AF_UNIX:
- str = "unix";
- break;
- case AF_UNSPEC:
- str = "unspecified";
- break;
- default:
- str = "unknown";
- break;
- }
- return str;
+ const char *str;
+ switch (address->ss->ss_family) {
+ case AF_INET:
+ str = "inet";
+ break;
+ case AF_INET6:
+ str = "inet6";
+ break;
+ case AF_UNIX:
+ str = "unix";
+ break;
+ case AF_UNSPEC:
+ str = "unspecified";
+ break;
+ default:
+ str = "unknown";
+ break;
+ }
+ return str;
}
void
gdm_address_debug (GdmAddress *address)
{
- char *hostname;
- char *host;
- char *port;
-
- g_return_if_fail (address != NULL);
-
- hostname = NULL;
- host = NULL;
- port = NULL;
-
- gdm_address_get_hostname (address, &hostname);
- gdm_address_get_numeric_info (address, &host, &port);
-
- g_debug ("Address family:%d (%s) hostname:%s host:%s port:%s local:%d loopback:%d",
- address->ss->ss_family,
- address_family_str (address),
- hostname,
- host,
- port,
- gdm_address_is_local (address),
- gdm_address_is_loopback (address));
-
- g_free (hostname);
- g_free (host);
- g_free (port);
+ char *hostname;
+ char *host;
+ char *port;
+
+ g_return_if_fail (address != NULL);
+
+ hostname = NULL;
+ host = NULL;
+ port = NULL;
+
+ gdm_address_get_hostname (address, &hostname);
+ gdm_address_get_numeric_info (address, &host, &port);
+
+ g_debug ("Address family:%d (%s) hostname:%s host:%s port:%s local:%d loopback:%d",
+ address->ss->ss_family,
+ address_family_str (address),
+ hostname,
+ host,
+ port,
+ gdm_address_is_local (address),
+ gdm_address_is_loopback (address));
+
+ g_free (hostname);
+ g_free (host);
+ g_free (port);
}
diff --git a/common/gdm-address.h b/common/gdm-address.h
index 1db36b19..2bebedbb 100644
--- a/common/gdm-address.h
+++ b/common/gdm-address.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -38,7 +38,7 @@ G_BEGIN_DECLS
typedef struct _GdmAddress GdmAddress;
-GType gdm_address_get_type (void);
+GType gdm_address_get_type (void);
GdmAddress * gdm_address_new_from_sockaddr_storage (struct sockaddr_storage *ss);
@@ -47,15 +47,15 @@ struct sockaddr_storage *gdm_address_get_sockaddr_storage (GdmAddress
struct sockaddr_storage *gdm_address_peek_sockaddr_storage (GdmAddress *address);
gboolean gdm_address_get_hostname (GdmAddress *address,
- char **hostname);
+ char **hostname);
gboolean gdm_address_get_numeric_info (GdmAddress *address,
- char **numeric_hostname,
- char **service);
+ char **numeric_hostname,
+ char **service);
gboolean gdm_address_is_local (GdmAddress *address);
gboolean gdm_address_is_loopback (GdmAddress *address);
gboolean gdm_address_equal (GdmAddress *a,
- GdmAddress *b);
+ GdmAddress *b);
GdmAddress * gdm_address_copy (GdmAddress *address);
void gdm_address_free (GdmAddress *address);
diff --git a/common/gdm-common.c b/common/gdm-common.c
index c66c026a..7ea3a488 100644
--- a/common/gdm-common.c
+++ b/common/gdm-common.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* (c) 2000 Eazel, Inc.
* (c) 2001,2002 George Lebl
@@ -10,7 +10,7 @@
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
@@ -45,182 +45,182 @@
int
gdm_fdgetc (int fd)
{
- char buf[1];
- int bytes;
+ char buf[1];
+ int bytes;
- VE_IGNORE_EINTR (bytes = read (fd, buf, 1));
- if (bytes != 1)
- return EOF;
- else
- return (int)buf[0];
+ VE_IGNORE_EINTR (bytes = read (fd, buf, 1));
+ if (bytes != 1)
+ return EOF;
+ else
+ return (int)buf[0];
}
char *
gdm_fdgets (int fd)
{
- int c;
- int bytes = 0;
- GString *gs = g_string_new (NULL);
- for (;;) {
- c = gdm_fdgetc (fd);
- if (c == '\n')
- return g_string_free (gs, FALSE);
- /* on EOF */
- if (c < 0) {
- if (bytes == 0) {
- g_string_free (gs, TRUE);
- return NULL;
- } else {
- return g_string_free (gs, FALSE);
- }
- } else {
- bytes++;
- g_string_append_c (gs, c);
- }
- }
+ int c;
+ int bytes = 0;
+ GString *gs = g_string_new (NULL);
+ for (;;) {
+ c = gdm_fdgetc (fd);
+ if (c == '\n')
+ return g_string_free (gs, FALSE);
+ /* on EOF */
+ if (c < 0) {
+ if (bytes == 0) {
+ g_string_free (gs, TRUE);
+ return NULL;
+ } else {
+ return g_string_free (gs, FALSE);
+ }
+ } else {
+ bytes++;
+ g_string_append_c (gs, c);
+ }
+ }
}
void
gdm_fdprintf (int fd, const gchar *format, ...)
{
- va_list args;
- gchar *s;
- int written, len;
+ va_list args;
+ gchar *s;
+ int written, len;
- va_start (args, format);
- s = g_strdup_vprintf (format, args);
- va_end (args);
+ va_start (args, format);
+ s = g_strdup_vprintf (format, args);
+ va_end (args);
- len = strlen (s);
+ len = strlen (s);
- if (len == 0) {
- g_free (s);
- return;
- }
+ if (len == 0) {
+ g_free (s);
+ return;
+ }
- written = 0;
- while (written < len) {
- int w;
- VE_IGNORE_EINTR (w = write (fd, &s[written], len - written));
- if (w < 0)
- /* evil! */
- break;
- written += w;
- }
+ written = 0;
+ while (written < len) {
+ int w;
+ VE_IGNORE_EINTR (w = write (fd, &s[written], len - written));
+ if (w < 0)
+ /* evil! */
+ break;
+ written += w;
+ }
- g_free (s);
+ g_free (s);
}
void
gdm_close_all_descriptors (int from, int except, int except2)
{
- DIR *dir;
- struct dirent *ent;
- GSList *openfds = NULL;
+ DIR *dir;
+ struct dirent *ent;
+ GSList *openfds = NULL;
- /*
+ /*
* Evil, but less evil then going to _SC_OPEN_MAX
- * which can be very VERY large
+ * which can be very VERY large
*/
- dir = opendir ("/proc/self/fd/"); /* This is the Linux dir */
- if (dir == NULL)
- dir = opendir ("/dev/fd/"); /* This is the FreeBSD dir */
- if G_LIKELY (dir != NULL) {
- GSList *li;
- while ((ent = readdir (dir)) != NULL) {
- int fd;
- if (ent->d_name[0] == '.')
- continue;
- fd = atoi (ent->d_name);
- if (fd >= from && fd != except && fd != except2)
- openfds = g_slist_prepend (openfds, GINT_TO_POINTER (fd));
- }
- closedir (dir);
- for (li = openfds; li != NULL; li = li->next) {
- int fd = GPOINTER_TO_INT (li->data);
- VE_IGNORE_EINTR (close (fd));
- }
- g_slist_free (openfds);
- } else {
- int i;
- int max = sysconf (_SC_OPEN_MAX);
- /*
+ dir = opendir ("/proc/self/fd/"); /* This is the Linux dir */
+ if (dir == NULL)
+ dir = opendir ("/dev/fd/"); /* This is the FreeBSD dir */
+ if G_LIKELY (dir != NULL) {
+ GSList *li;
+ while ((ent = readdir (dir)) != NULL) {
+ int fd;
+ if (ent->d_name[0] == '.')
+ continue;
+ fd = atoi (ent->d_name);
+ if (fd >= from && fd != except && fd != except2)
+ openfds = g_slist_prepend (openfds, GINT_TO_POINTER (fd));
+ }
+ closedir (dir);
+ for (li = openfds; li != NULL; li = li->next) {
+ int fd = GPOINTER_TO_INT (li->data);
+ VE_IGNORE_EINTR (close (fd));
+ }
+ g_slist_free (openfds);
+ } else {
+ int i;
+ int max = sysconf (_SC_OPEN_MAX);
+ /*
* Don't go higher then this. This is
- * a safety measure to not hang on crazy
- * systems
+ * a safety measure to not hang on crazy
+ * systems
*/
- if G_UNLIKELY (max > 4096) {
- /* FIXME: warn about this perhaps */
- /*
+ if G_UNLIKELY (max > 4096) {
+ /* FIXME: warn about this perhaps */
+ /*
* Try an open, in case we're really
- * leaking fds somewhere badly, this
- * should be very high
+ * leaking fds somewhere badly, this
+ * should be very high
*/
- i = gdm_open_dev_null (O_RDONLY);
- max = MAX (i+1, 4096);
- }
- for (i = from; i < max; i++) {
- if G_LIKELY (i != except && i != except2)
- VE_IGNORE_EINTR (close (i));
- }
- }
+ i = gdm_open_dev_null (O_RDONLY);
+ max = MAX (i+1, 4096);
+ }
+ for (i = from; i < max; i++) {
+ if G_LIKELY (i != except && i != except2)
+ VE_IGNORE_EINTR (close (i));
+ }
+ }
}
void
gdm_signal_ignore (int signal)
{
- struct sigaction ign_signal;
+ struct sigaction ign_signal;
- ign_signal.sa_handler = SIG_IGN;
- ign_signal.sa_flags = SA_RESTART;
- sigemptyset (&ign_signal.sa_mask);
+ ign_signal.sa_handler = SIG_IGN;
+ ign_signal.sa_flags = SA_RESTART;
+ sigemptyset (&ign_signal.sa_mask);
- if G_UNLIKELY (sigaction (signal, &ign_signal, NULL) < 0)
- g_warning (_("%s: Error setting signal %d to %s"),
- "gdm_signal_ignore", signal, "SIG_IGN");
+ if G_UNLIKELY (sigaction (signal, &ign_signal, NULL) < 0)
+ g_warning (_("%s: Error setting signal %d to %s"),
+ "gdm_signal_ignore", signal, "SIG_IGN");
}
void
gdm_signal_default (int signal)
{
- struct sigaction def_signal;
+ struct sigaction def_signal;
- def_signal.sa_handler = SIG_DFL;
- def_signal.sa_flags = SA_RESTART;
- sigemptyset (&def_signal.sa_mask);
+ def_signal.sa_handler = SIG_DFL;
+ def_signal.sa_flags = SA_RESTART;
+ sigemptyset (&def_signal.sa_mask);
- if G_UNLIKELY (sigaction (signal, &def_signal, NULL) < 0)
- g_warning (_("%s: Error setting signal %d to %s"),
- "gdm_signal_ignore", signal, "SIG_DFL");
+ if G_UNLIKELY (sigaction (signal, &def_signal, NULL) < 0)
+ g_warning (_("%s: Error setting signal %d to %s"),
+ "gdm_signal_ignore", signal, "SIG_DFL");
}
int
gdm_open_dev_null (mode_t mode)
{
- int ret;
- VE_IGNORE_EINTR (ret = open ("/dev/null", mode));
- if G_UNLIKELY (ret < 0) {
- /*
+ int ret;
+ VE_IGNORE_EINTR (ret = open ("/dev/null", mode));
+ if G_UNLIKELY (ret < 0) {
+ /*
* Never output anything, we're likely in some
- * strange state right now
+ * strange state right now
*/
- gdm_signal_ignore (SIGPIPE);
- VE_IGNORE_EINTR (close (2));
- g_error ("Cannot open /dev/null, system on crack!");
- }
+ gdm_signal_ignore (SIGPIPE);
+ VE_IGNORE_EINTR (close (2));
+ g_error ("Cannot open /dev/null, system on crack!");
+ }
- return ret;
+ return ret;
}
char *
gdm_make_filename (const char *dir,
- const char *name,
- const char *extension)
+ const char *name,
+ const char *extension)
{
- char *base = g_strconcat (name, extension, NULL);
- char *full = g_build_filename (dir, base, NULL);
- g_free (base);
- return full;
+ char *base = g_strconcat (name, extension, NULL);
+ char *full = g_build_filename (dir, base, NULL);
+ g_free (base);
+ return full;
}
@@ -236,161 +236,161 @@ static sigset_t sigusr2block_mask, sigusr2block_oldmask;
void
gdm_sigchld_block_push (void)
{
- sigchld_blocked++;
+ sigchld_blocked++;
- if (sigchld_blocked == 1) {
- /* Set signal mask */
- sigemptyset (&sigchldblock_mask);
- sigaddset (&sigchldblock_mask, SIGCHLD);
- sigprocmask (SIG_BLOCK, &sigchldblock_mask, &sigchldblock_oldmask);
- }
+ if (sigchld_blocked == 1) {
+ /* Set signal mask */
+ sigemptyset (&sigchldblock_mask);
+ sigaddset (&sigchldblock_mask, SIGCHLD);
+ sigprocmask (SIG_BLOCK, &sigchldblock_mask, &sigchldblock_oldmask);
+ }
}
void
gdm_sigchld_block_pop (void)
{
- sigchld_blocked --;
+ sigchld_blocked --;
- if (sigchld_blocked == 0) {
- /* Reset signal mask back */
- sigprocmask (SIG_SETMASK, &sigchldblock_oldmask, NULL);
- }
+ if (sigchld_blocked == 0) {
+ /* Reset signal mask back */
+ sigprocmask (SIG_SETMASK, &sigchldblock_oldmask, NULL);
+ }
}
void
gdm_sigterm_block_push (void)
{
- sigterm_blocked++;
+ sigterm_blocked++;
- if (sigterm_blocked == 1) {
- /* Set signal mask */
- sigemptyset (&sigtermblock_mask);
- sigaddset (&sigtermblock_mask, SIGTERM);
- sigaddset (&sigtermblock_mask, SIGINT);
- sigaddset (&sigtermblock_mask, SIGHUP);
- sigprocmask (SIG_BLOCK, &sigtermblock_mask, &sigtermblock_oldmask);
- }
+ if (sigterm_blocked == 1) {
+ /* Set signal mask */
+ sigemptyset (&sigtermblock_mask);
+ sigaddset (&sigtermblock_mask, SIGTERM);
+ sigaddset (&sigtermblock_mask, SIGINT);
+ sigaddset (&sigtermblock_mask, SIGHUP);
+ sigprocmask (SIG_BLOCK, &sigtermblock_mask, &sigtermblock_oldmask);
+ }
}
void
gdm_sigterm_block_pop (void)
{
- sigterm_blocked --;
+ sigterm_blocked --;
- if (sigterm_blocked == 0) {
- /* Reset signal mask back */
- sigprocmask (SIG_SETMASK, &sigtermblock_oldmask, NULL);
- }
+ if (sigterm_blocked == 0) {
+ /* Reset signal mask back */
+ sigprocmask (SIG_SETMASK, &sigtermblock_oldmask, NULL);
+ }
}
void
gdm_sigusr2_block_push (void)
{
- sigset_t oldmask;
+ sigset_t oldmask;
- if (sigusr2_blocked == 0) {
- /* Set signal mask */
- sigemptyset (&sigusr2block_mask);
- sigaddset (&sigusr2block_mask, SIGUSR2);
- sigprocmask (SIG_BLOCK, &sigusr2block_mask, &oldmask);
- }
+ if (sigusr2_blocked == 0) {
+ /* Set signal mask */
+ sigemptyset (&sigusr2block_mask);
+ sigaddset (&sigusr2block_mask, SIGUSR2);
+ sigprocmask (SIG_BLOCK, &sigusr2block_mask, &oldmask);
+ }
- sigusr2_blocked++;
+ sigusr2_blocked++;
- sigusr2block_oldmask = oldmask;
+ sigusr2block_oldmask = oldmask;
}
void
gdm_sigusr2_block_pop (void)
{
- sigset_t oldmask;
+ sigset_t oldmask;
- oldmask = sigusr2block_oldmask;
+ oldmask = sigusr2block_oldmask;
- sigusr2_blocked--;
+ sigusr2_blocked--;
- if (sigusr2_blocked == 0) {
- /* Reset signal mask back */
- sigprocmask (SIG_SETMASK, &sigusr2block_oldmask, NULL);
- }
+ if (sigusr2_blocked == 0) {
+ /* Reset signal mask back */
+ sigprocmask (SIG_SETMASK, &sigusr2block_oldmask, NULL);
+ }
}
/* Like fopen with "w" */
FILE *
gdm_safe_fopen_w (const char *file, mode_t perm)
{
- int fd;
- FILE *ret;
- VE_IGNORE_EINTR (g_unlink (file));
- do {
- errno = 0;
- fd = open (file, O_EXCL|O_CREAT|O_TRUNC|O_WRONLY
+ int fd;
+ FILE *ret;
+ VE_IGNORE_EINTR (g_unlink (file));
+ do {
+ errno = 0;
+ fd = open (file, O_EXCL|O_CREAT|O_TRUNC|O_WRONLY
#ifdef O_NOCTTY
- |O_NOCTTY
+ |O_NOCTTY
#endif
#ifdef O_NOFOLLOW
- |O_NOFOLLOW
+ |O_NOFOLLOW
#endif
- , perm);
- } while G_UNLIKELY (errno == EINTR);
- if (fd < 0)
- return NULL;
- VE_IGNORE_EINTR (ret = fdopen (fd, "w"));
- return ret;
+ , perm);
+ } while G_UNLIKELY (errno == EINTR);
+ if (fd < 0)
+ return NULL;
+ VE_IGNORE_EINTR (ret = fdopen (fd, "w"));
+ return ret;
}
/* Like fopen with "a+" */
FILE *
gdm_safe_fopen_ap (const char *file, mode_t perm)
{
- int fd;
- FILE *ret;
+ int fd;
+ FILE *ret;
- if (g_access (file, F_OK) == 0) {
- do {
- errno = 0;
- fd = open (file, O_APPEND|O_RDWR
+ if (g_access (file, F_OK) == 0) {
+ do {
+ errno = 0;
+ fd = open (file, O_APPEND|O_RDWR
#ifdef O_NOCTTY
- |O_NOCTTY
+ |O_NOCTTY
#endif
#ifdef O_NOFOLLOW
- |O_NOFOLLOW
+ |O_NOFOLLOW
#endif
- );
- } while G_UNLIKELY (errno == EINTR);
- } else {
- /* Doesn't exist, open with O_EXCL */
- do {
- errno = 0;
- fd = open (file, O_EXCL|O_CREAT|O_RDWR
+ );
+ } while G_UNLIKELY (errno == EINTR);
+ } else {
+ /* Doesn't exist, open with O_EXCL */
+ do {
+ errno = 0;
+ fd = open (file, O_EXCL|O_CREAT|O_RDWR
#ifdef O_NOCTTY
- |O_NOCTTY
+ |O_NOCTTY
#endif
#ifdef O_NOFOLLOW
- |O_NOFOLLOW
+ |O_NOFOLLOW
#endif
- , perm);
- } while G_UNLIKELY (errno == EINTR);
- }
- if (fd < 0)
- return NULL;
- VE_IGNORE_EINTR (ret = fdopen (fd, "a+"));
- return ret;
+ , perm);
+ } while G_UNLIKELY (errno == EINTR);
+ }
+ if (fd < 0)
+ return NULL;
+ VE_IGNORE_EINTR (ret = fdopen (fd, "a+"));
+ return ret;
}
void
gdm_fd_set_close_on_exec (int fd)
{
- int flags;
+ int flags;
- flags = fcntl (fd, F_GETFD, 0);
- if (flags < 0) {
- return;
- }
+ flags = fcntl (fd, F_GETFD, 0);
+ if (flags < 0) {
+ return;
+ }
- flags |= FD_CLOEXEC;
+ flags |= FD_CLOEXEC;
- fcntl (fd, F_SETFD, flags);
+ fcntl (fd, F_SETFD, flags);
}
/**
@@ -406,7 +406,7 @@ void
ve_clearenv (void)
{
#ifdef HAVE_CLEARENV
- clearenv ();
+ clearenv ();
#else
#ifdef HAVE__NSGETENVIRON
@@ -415,152 +415,152 @@ ve_clearenv (void)
extern char **environ;
#endif
- if (environ != NULL)
- environ[0] = NULL;
+ if (environ != NULL)
+ environ[0] = NULL;
#endif
}
char *
ve_first_word (const char *s)
{
- int argc;
- char **argv;
- char *ret;
+ int argc;
+ char **argv;
+ char *ret;
- if (s == NULL)
- return NULL;
+ if (s == NULL)
+ return NULL;
- if ( ! g_shell_parse_argv (s, &argc, &argv, NULL)) {
- char *p;
- ret = g_strdup (s);
- p = strchr (ret, ' ');
- if (p != NULL)
- *p = '\0';
- return ret;
- }
+ if ( ! g_shell_parse_argv (s, &argc, &argv, NULL)) {
+ char *p;
+ ret = g_strdup (s);
+ p = strchr (ret, ' ');
+ if (p != NULL)
+ *p = '\0';
+ return ret;
+ }
- ret = g_strdup (argv[0]);
+ ret = g_strdup (argv[0]);
- g_strfreev (argv);
+ g_strfreev (argv);
- return ret;
+ return ret;
}
static gboolean
ve_first_word_executable (const char *s,
- gboolean only_existance)
+ gboolean only_existance)
{
- char *bin = ve_first_word (s);
- if (bin == NULL)
- return FALSE;
- if (g_access (bin, only_existance ? F_OK : X_OK) == 0) {
- g_free (bin);
- return TRUE;
- } else {
- g_free (bin);
- return FALSE;
- }
+ char *bin = ve_first_word (s);
+ if (bin == NULL)
+ return FALSE;
+ if (g_access (bin, only_existance ? F_OK : X_OK) == 0) {
+ g_free (bin);
+ return TRUE;
+ } else {
+ g_free (bin);
+ return FALSE;
+ }
}
char *
ve_get_first_working_command (const char *list,
- gboolean only_existance)
+ gboolean only_existance)
{
- int i;
- char **vector;
- char *ret = NULL;
+ int i;
+ char **vector;
+ char *ret = NULL;
- if (list == NULL)
- return NULL;
+ if (list == NULL)
+ return NULL;
- vector = g_strsplit (list, ";", -1);
- for (i = 0; vector[i] != NULL; i++) {
- if (ve_first_word_executable (vector[i],
- only_existance)) {
- ret = g_strdup (vector[i]);
- break;
- }
- }
- g_strfreev (vector);
- return ret;
+ vector = g_strsplit (list, ";", -1);
+ for (i = 0; vector[i] != NULL; i++) {
+ if (ve_first_word_executable (vector[i],
+ only_existance)) {
+ ret = g_strdup (vector[i]);
+ break;
+ }
+ }
+ g_strfreev (vector);
+ return ret;
}
char *
ve_locale_to_utf8 (const char *str)
{
- char *ret = g_locale_to_utf8 (str, -1, NULL, NULL, NULL);
+ char *ret = g_locale_to_utf8 (str, -1, NULL, NULL, NULL);
- if (ret == NULL) {
- g_warning ("string not in proper locale encoding: \"%s\"", str);
- return g_strdup (str);
- } else {
- return ret;
- }
+ if (ret == NULL) {
+ g_warning ("string not in proper locale encoding: \"%s\"", str);
+ return g_strdup (str);
+ } else {
+ return ret;
+ }
}
char *
ve_locale_from_utf8 (const char *str)
{
- char *ret = g_locale_from_utf8 (str, -1, NULL, NULL, NULL);
+ char *ret = g_locale_from_utf8 (str, -1, NULL, NULL, NULL);
- if (ret == NULL) {
- g_warning ("string not in proper utf8 encoding: \"%s\"", str);
- return g_strdup (str);
- } else {
- return ret;
- }
+ if (ret == NULL) {
+ g_warning ("string not in proper utf8 encoding: \"%s\"", str);
+ return g_strdup (str);
+ } else {
+ return ret;
+ }
}
char *
ve_filename_to_utf8 (const char *str)
{
- char *ret = g_filename_to_utf8 (str, -1, NULL, NULL, NULL);
- if (ret == NULL) {
- g_warning ("string not in proper locale encoding: \"%s\"", str);
- return g_strdup (str);
- } else {
- return ret;
- }
+ char *ret = g_filename_to_utf8 (str, -1, NULL, NULL, NULL);
+ if (ret == NULL) {
+ g_warning ("string not in proper locale encoding: \"%s\"", str);
+ return g_strdup (str);
+ } else {
+ return ret;
+ }
}
char *
ve_filename_from_utf8 (const char *str)
{
- char *ret = g_filename_from_utf8 (str, -1, NULL, NULL, NULL);
- if (ret == NULL) {
- g_warning ("string not in proper utf8 encoding: \"%s\"", str);
- return g_strdup (str);
- } else {
- return ret;
- }
+ char *ret = g_filename_from_utf8 (str, -1, NULL, NULL, NULL);
+ if (ret == NULL) {
+ g_warning ("string not in proper utf8 encoding: \"%s\"", str);
+ return g_strdup (str);
+ } else {
+ return ret;
+ }
}
pid_t
ve_waitpid_no_signal (pid_t pid, int *status, int options)
{
- pid_t ret;
+ pid_t ret;
- for (;;) {
- ret = waitpid (pid, status, options);
- if (ret == 0)
- return 0;
- if (errno != EINTR)
- return ret;
- }
+ for (;;) {
+ ret = waitpid (pid, status, options);
+ if (ret == 0)
+ return 0;
+ if (errno != EINTR)
+ return ret;
+ }
}
gboolean
ve_locale_exists (const char *loc)
{
- gboolean ret;
- char *old = g_strdup (setlocale (LC_MESSAGES, NULL));
- if (setlocale (LC_MESSAGES, loc) != NULL)
- ret = TRUE;
- else
- ret = FALSE;
- setlocale (LC_MESSAGES, old);
- g_free (old);
- return ret;
+ gboolean ret;
+ char *old = g_strdup (setlocale (LC_MESSAGES, NULL));
+ if (setlocale (LC_MESSAGES, loc) != NULL)
+ ret = TRUE;
+ else
+ ret = FALSE;
+ setlocale (LC_MESSAGES, old);
+ g_free (old);
+ return ret;
}
/* hex conversion adapted from D-Bus */
@@ -574,16 +574,16 @@ ve_locale_exists (const char *loc)
*/
static void
_gdm_string_append_byte_as_hex (GString *str,
- int byte)
+ int byte)
{
- const char hexdigits[16] = {
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
- 'a', 'b', 'c', 'd', 'e', 'f'
- };
+ const char hexdigits[16] = {
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ 'a', 'b', 'c', 'd', 'e', 'f'
+ };
- str = g_string_append_c (str, hexdigits[(byte >> 4)]);
+ str = g_string_append_c (str, hexdigits[(byte >> 4)]);
- str = g_string_append_c (str, hexdigits[(byte & 0x0f)]);
+ str = g_string_append_c (str, hexdigits[(byte & 0x0f)]);
}
/**
@@ -598,37 +598,37 @@ _gdm_string_append_byte_as_hex (GString *str,
*/
gboolean
gdm_string_hex_encode (const GString *source,
- int start,
- GString *dest,
- int insert_at)
+ int start,
+ GString *dest,
+ int insert_at)
{
- GString *result;
- const unsigned char *p;
- const unsigned char *end;
- gboolean retval;
+ GString *result;
+ const unsigned char *p;
+ const unsigned char *end;
+ gboolean retval;
- g_assert (start <= source->len);
+ g_assert (start <= source->len);
- result = g_string_new (NULL);
+ result = g_string_new (NULL);
- retval = FALSE;
+ retval = FALSE;
- p = (const unsigned char*) source->str;
- end = p + source->len;
- p += start;
+ p = (const unsigned char*) source->str;
+ end = p + source->len;
+ p += start;
- while (p != end) {
- _gdm_string_append_byte_as_hex (result, *p);
- ++p;
- }
+ while (p != end) {
+ _gdm_string_append_byte_as_hex (result, *p);
+ ++p;
+ }
- dest = g_string_insert (dest, insert_at, result->str);
+ dest = g_string_insert (dest, insert_at, result->str);
- retval = TRUE;
+ retval = TRUE;
- g_string_free (result, TRUE);
+ g_string_free (result, TRUE);
- return retval;
+ return retval;
}
/**
@@ -643,199 +643,199 @@ gdm_string_hex_encode (const GString *source,
*/
gboolean
gdm_string_hex_decode (const GString *source,
- int start,
- int *end_return,
- GString *dest,
- int insert_at)
-{
- GString *result;
- const unsigned char *p;
- const unsigned char *end;
- gboolean retval;
- gboolean high_bits;
-
- g_assert (start <= source->len);
-
- result = g_string_new (NULL);
-
- retval = FALSE;
-
- high_bits = TRUE;
- p = (const unsigned char*) source->str;
- end = p + source->len;
- p += start;
-
- while (p != end) {
- unsigned int val;
-
- switch (*p) {
- case '0':
- val = 0;
- break;
- case '1':
- val = 1;
- break;
- case '2':
- val = 2;
- break;
- case '3':
- val = 3;
- break;
- case '4':
- val = 4;
- break;
- case '5':
- val = 5;
- break;
- case '6':
- val = 6;
- break;
- case '7':
- val = 7;
- break;
- case '8':
- val = 8;
- break;
- case '9':
- val = 9;
- break;
- case 'a':
- case 'A':
- val = 10;
- break;
- case 'b':
- case 'B':
- val = 11;
- break;
- case 'c':
- case 'C':
- val = 12;
- break;
- case 'd':
- case 'D':
- val = 13;
- break;
- case 'e':
- case 'E':
- val = 14;
- break;
- case 'f':
- case 'F':
- val = 15;
- break;
- default:
- goto done;
- }
-
- if (high_bits) {
- result = g_string_append_c (result, val << 4);
- } else {
- int len;
- unsigned char b;
-
- len = result->len;
-
- b = result->str[len - 1];
-
- b |= val;
-
- result->str[len - 1] = b;
- }
-
- high_bits = !high_bits;
-
- ++p;
- }
+ int start,
+ int *end_return,
+ GString *dest,
+ int insert_at)
+{
+ GString *result;
+ const unsigned char *p;
+ const unsigned char *end;
+ gboolean retval;
+ gboolean high_bits;
+
+ g_assert (start <= source->len);
+
+ result = g_string_new (NULL);
+
+ retval = FALSE;
+
+ high_bits = TRUE;
+ p = (const unsigned char*) source->str;
+ end = p + source->len;
+ p += start;
+
+ while (p != end) {
+ unsigned int val;
+
+ switch (*p) {
+ case '0':
+ val = 0;
+ break;
+ case '1':
+ val = 1;
+ break;
+ case '2':
+ val = 2;
+ break;
+ case '3':
+ val = 3;
+ break;
+ case '4':
+ val = 4;
+ break;
+ case '5':
+ val = 5;
+ break;
+ case '6':
+ val = 6;
+ break;
+ case '7':
+ val = 7;
+ break;
+ case '8':
+ val = 8;
+ break;
+ case '9':
+ val = 9;
+ break;
+ case 'a':
+ case 'A':
+ val = 10;
+ break;
+ case 'b':
+ case 'B':
+ val = 11;
+ break;
+ case 'c':
+ case 'C':
+ val = 12;
+ break;
+ case 'd':
+ case 'D':
+ val = 13;
+ break;
+ case 'e':
+ case 'E':
+ val = 14;
+ break;
+ case 'f':
+ case 'F':
+ val = 15;
+ break;
+ default:
+ goto done;
+ }
+
+ if (high_bits) {
+ result = g_string_append_c (result, val << 4);
+ } else {
+ int len;
+ unsigned char b;
+
+ len = result->len;
+
+ b = result->str[len - 1];
+
+ b |= val;
+
+ result->str[len - 1] = b;
+ }
+
+ high_bits = !high_bits;
+
+ ++p;
+ }
done:
- dest = g_string_insert (dest, insert_at, result->str);
+ dest = g_string_insert (dest, insert_at, result->str);
- if (end_return) {
- *end_return = p - (const unsigned char*) source->str;
- }
+ if (end_return) {
+ *end_return = p - (const unsigned char*) source->str;
+ }
- retval = TRUE;
+ retval = TRUE;
- g_string_free (result, TRUE);
+ g_string_free (result, TRUE);
- return retval;
+ return retval;
}
static void
_gdm_generate_pseudorandom_bytes_buffer (char *buffer,
- int n_bytes)
+ int n_bytes)
{
- int i;
+ int i;
- /* fall back to pseudorandom */
- g_debug ("Falling back to pseudorandom for %d bytes\n",
+ /* fall back to pseudorandom */
+ g_debug ("Falling back to pseudorandom for %d bytes\n",
n_bytes);
- i = 0;
- while (i < n_bytes) {
- int b;
+ i = 0;
+ while (i < n_bytes) {
+ int b;
- b = g_random_int_range (0, 255);
+ b = g_random_int_range (0, 255);
- buffer[i] = b;
+ buffer[i] = b;
- ++i;
- }
+ ++i;
+ }
}
static gboolean
_gdm_generate_pseudorandom_bytes (GString *str,
- int n_bytes)
+ int n_bytes)
{
- int old_len;
- char *p;
+ int old_len;
+ char *p;
- old_len = str->len;
+ old_len = str->len;
- str = g_string_set_size (str, old_len + n_bytes);
+ str = g_string_set_size (str, old_len + n_bytes);
- p = str->str + old_len;
+ p = str->str + old_len;
- _gdm_generate_pseudorandom_bytes_buffer (p, n_bytes);
+ _gdm_generate_pseudorandom_bytes_buffer (p, n_bytes);
- return TRUE;
+ return TRUE;
}
static int
_gdm_fdread (int fd,
- GString *buffer,
- int count)
+ GString *buffer,
+ int count)
{
- int bytes_read;
- int start;
- char *data;
+ int bytes_read;
+ int start;
+ char *data;
- g_assert (count >= 0);
+ g_assert (count >= 0);
- start = buffer->len;
+ start = buffer->len;
- buffer = g_string_set_size (buffer, start + count);
+ buffer = g_string_set_size (buffer, start + count);
- data = buffer->str + start;
+ data = buffer->str + start;
again:
- bytes_read = read (fd, data, count);
+ bytes_read = read (fd, data, count);
- if (bytes_read < 0) {
- if (errno == EINTR) {
- goto again;
- } else {
- /* put length back (note that this doesn't actually realloc anything) */
- buffer = g_string_set_size (buffer, start);
- return -1;
- }
- } else {
- /* put length back (doesn't actually realloc) */
- buffer = g_string_set_size (buffer, start + bytes_read);
+ if (bytes_read < 0) {
+ if (errno == EINTR) {
+ goto again;
+ } else {
+ /* put length back (note that this doesn't actually realloc anything) */
+ buffer = g_string_set_size (buffer, start);
+ return -1;
+ }
+ } else {
+ /* put length back (doesn't actually realloc) */
+ buffer = g_string_set_size (buffer, start + bytes_read);
- return bytes_read;
- }
+ return bytes_read;
+ }
}
/**
@@ -849,17 +849,17 @@ static gboolean
_gdm_fdclose (int fd)
{
again:
- if (close (fd) < 0) {
- if (errno == EINTR)
- goto again;
+ if (close (fd) < 0) {
+ if (errno == EINTR)
+ goto again;
- g_warning ("Could not close fd %d: %s",
- fd,
- g_strerror (errno));
- return FALSE;
- }
+ g_warning ("Could not close fd %d: %s",
+ fd,
+ g_strerror (errno));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
/**
@@ -871,37 +871,37 @@ _gdm_fdclose (int fd)
*/
gboolean
gdm_generate_random_bytes (GString *str,
- int n_bytes)
+ int n_bytes)
{
- int old_len;
- int fd;
+ int old_len;
+ int fd;
- /* FALSE return means "no memory", if it could
- * mean something else then we'd need to return
- * a DBusError. So we always fall back to pseudorandom
- * if the I/O fails.
- */
+ /* FALSE return means "no memory", if it could
+ * mean something else then we'd need to return
+ * a DBusError. So we always fall back to pseudorandom
+ * if the I/O fails.
+ */
- old_len = str->len;
- fd = -1;
+ old_len = str->len;
+ fd = -1;
- /* note, urandom on linux will fall back to pseudorandom */
- fd = g_open ("/dev/urandom", O_RDONLY, 0);
- if (fd < 0) {
- return _gdm_generate_pseudorandom_bytes (str, n_bytes);
- }
+ /* note, urandom on linux will fall back to pseudorandom */
+ fd = g_open ("/dev/urandom", O_RDONLY, 0);
+ if (fd < 0) {
+ return _gdm_generate_pseudorandom_bytes (str, n_bytes);
+ }
- if (_gdm_fdread (fd, str, n_bytes) != n_bytes) {
- _gdm_fdclose (fd);
- str = g_string_set_size (str, old_len);
- return _gdm_generate_pseudorandom_bytes (str, n_bytes);
- }
+ if (_gdm_fdread (fd, str, n_bytes) != n_bytes) {
+ _gdm_fdclose (fd);
+ str = g_string_set_size (str, old_len);
+ return _gdm_generate_pseudorandom_bytes (str, n_bytes);
+ }
- g_debug ("Read %d bytes from /dev/urandom\n", n_bytes);
+ g_debug ("Read %d bytes from /dev/urandom\n", n_bytes);
- _gdm_fdclose (fd);
+ _gdm_fdclose (fd);
- return TRUE;
+ return TRUE;
}
/**
@@ -914,49 +914,49 @@ gdm_generate_random_bytes (GString *str,
*/
static gboolean
gdm_md5_compute (const GString *data,
- GString *ascii_output)
+ GString *ascii_output)
{
- GdmMD5Context context;
- GString *digest;
+ GdmMD5Context context;
+ GString *digest;
- gdm_md5_init (&context);
+ gdm_md5_init (&context);
- gdm_md5_update (&context, data);
+ gdm_md5_update (&context, data);
- digest = g_string_new (NULL);
- if (digest == NULL)
- return FALSE;
+ digest = g_string_new (NULL);
+ if (digest == NULL)
+ return FALSE;
- if (! gdm_md5_final (&context, digest))
- goto error;
+ if (! gdm_md5_final (&context, digest))
+ goto error;
- if (! gdm_string_hex_encode (digest,
- 0,
- ascii_output,
- ascii_output->len))
- goto error;
+ if (! gdm_string_hex_encode (digest,
+ 0,
+ ascii_output,
+ ascii_output->len))
+ goto error;
- g_string_free (digest, TRUE);
+ g_string_free (digest, TRUE);
- return TRUE;
+ return TRUE;
error:
- g_string_free (digest, TRUE);
+ g_string_free (digest, TRUE);
- return FALSE;
+ return FALSE;
}
gboolean
gdm_generate_cookie (GString *result)
{
- gboolean ret;
- GString *data;
+ gboolean ret;
+ GString *data;
- data = g_string_new (NULL);
- gdm_generate_random_bytes (data, 16);
+ data = g_string_new (NULL);
+ gdm_generate_random_bytes (data, 16);
- ret = gdm_md5_compute (data, result);
- g_string_free (data, TRUE);
+ ret = gdm_md5_compute (data, result);
+ g_string_free (data, TRUE);
- return ret;
+ return ret;
}
diff --git a/common/gdm-common.h b/common/gdm-common.h
index 8b6b2fe8..83c26f7a 100644
--- a/common/gdm-common.h
+++ b/common/gdm-common.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* (c) 2000 Eazel, Inc.
* (c) 2001,2002 George Lebl
@@ -10,7 +10,7 @@
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
@@ -39,48 +39,48 @@ G_BEGIN_DECLS
#define ve_string_empty(x) ((x)==NULL||(x)[0]=='\0')
#define ve_sure_string(x) ((x)!=NULL?(x):"")
#define VE_IGNORE_EINTR(expr) \
- do { \
- errno = 0; \
- expr; \
- } while G_UNLIKELY (errno == EINTR);
+ do { \
+ errno = 0; \
+ expr; \
+ } while G_UNLIKELY (errno == EINTR);
#define NEVER_FAILS_seteuid(uid) \
- { int r = 0; \
- if (geteuid () != uid) \
- r = seteuid (uid); \
- if G_UNLIKELY (r != 0) \
+ { int r = 0; \
+ if (geteuid () != uid) \
+ r = seteuid (uid); \
+ if G_UNLIKELY (r != 0) \
g_error ("GDM file %s: line %d (%s): Cannot run seteuid to %d: %s", \
- __FILE__, \
- __LINE__, \
- G_GNUC_PRETTY_FUNCTION, \
- (int)uid, \
- strerror (errno)); }
+ __FILE__, \
+ __LINE__, \
+ G_GNUC_PRETTY_FUNCTION, \
+ (int)uid, \
+ strerror (errno)); }
#define NEVER_FAILS_setegid(gid) \
- { int r = 0; \
- if (getegid () != gid) \
- r = setegid (gid); \
- if G_UNLIKELY (r != 0) \
+ { int r = 0; \
+ if (getegid () != gid) \
+ r = setegid (gid); \
+ if G_UNLIKELY (r != 0) \
g_error ("GDM file %s: line %d (%s): Cannot run setegid to %d: %s", \
- __FILE__, \
- __LINE__, \
- G_GNUC_PRETTY_FUNCTION, \
- (int)gid, \
- strerror (errno)); }
+ __FILE__, \
+ __LINE__, \
+ G_GNUC_PRETTY_FUNCTION, \
+ (int)gid, \
+ strerror (errno)); }
/* first goes to euid-root and then sets the egid and euid, to make sure
* this succeeds */
#define NEVER_FAILS_root_set_euid_egid(uid,gid) \
- { NEVER_FAILS_seteuid (0); \
- NEVER_FAILS_setegid (gid); \
- if (uid != 0) { NEVER_FAILS_seteuid (uid); } }
+ { NEVER_FAILS_seteuid (0); \
+ NEVER_FAILS_setegid (gid); \
+ if (uid != 0) { NEVER_FAILS_seteuid (uid); } }
/* like fopen with "w" but unlinks and uses O_EXCL */
FILE * gdm_safe_fopen_w (const char *file,
- mode_t perm);
+ mode_t perm);
/* like fopen with "a+" and uses O_EXCL and O_NOFOLLOW */
FILE * gdm_safe_fopen_ap (const char *file,
- mode_t perm);
+ mode_t perm);
/* This is for race free forks */
void gdm_sigchld_block_push (void);
@@ -107,15 +107,15 @@ int gdm_open_dev_null (mode_t mode);
* <dir> "/" <name> <extension>
*/
char * gdm_make_filename (const char *dir,
- const char *name,
- const char *extension);
+ const char *name,
+ const char *extension);
void ve_clearenv (void);
-char * ve_first_word (const char *s);
+char * ve_first_word (const char *s);
/* Gets the first existing command out of a list separated by semicolons */
-char * ve_get_first_working_command (const char *list,
- gboolean only_existance);
+char * ve_get_first_working_command (const char *list,
+ gboolean only_existance);
/* These two functions will ALWAYS return a non-NULL string,
* if there is an error, they return the unconverted string */
@@ -134,17 +134,17 @@ pid_t ve_waitpid_no_signal (pid_t pid, int *status, int options);
gboolean ve_locale_exists (const char *loc);
gboolean gdm_generate_random_bytes (GString *str,
- int n_bytes);
+ int n_bytes);
gboolean gdm_string_hex_encode (const GString *source,
- int start,
- GString *dest,
- int insert_at);
+ int start,
+ GString *dest,
+ int insert_at);
gboolean gdm_string_hex_decode (const GString *source,
- int start,
- int *end_return,
- GString *dest,
- int insert_at);
+ int start,
+ int *end_return,
+ GString *dest,
+ int insert_at);
gboolean gdm_generate_cookie (GString *result);
G_END_DECLS
diff --git a/common/gdm-log.c b/common/gdm-log.c
index a4777802..29476b3f 100644
--- a/common/gdm-log.c
+++ b/common/gdm-log.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -41,163 +41,163 @@ static int syslog_levels = (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LO
static void
log_level_to_priority_and_prefix (GLogLevelFlags log_level,
- int *priorityp,
- const char **prefixp)
+ int *priorityp,
+ const char **prefixp)
{
- int priority;
- const char *prefix;
-
- /* Process the message prefix and priority */
- switch (log_level & G_LOG_LEVEL_MASK) {
- case G_LOG_FLAG_FATAL:
- priority = LOG_EMERG;
- prefix = "FATAL";
- break;
- case G_LOG_LEVEL_ERROR:
- priority = LOG_ERR;
- prefix = "ERROR";
- break;
- case G_LOG_LEVEL_CRITICAL:
- priority = LOG_CRIT;
- prefix = "CRITICAL";
- break;
- case G_LOG_LEVEL_WARNING:
- priority = LOG_WARNING;
- prefix = "WARNING";
- break;
- case G_LOG_LEVEL_MESSAGE:
- priority = LOG_NOTICE;
- prefix = "MESSAGE";
- break;
- case G_LOG_LEVEL_INFO:
- priority = LOG_INFO;
- prefix = "INFO";
- break;
- case G_LOG_LEVEL_DEBUG:
- /* if debug was requested then bump this up to ERROR
- * to ensure it is seen in a log */
- if (syslog_levels & G_LOG_LEVEL_DEBUG) {
- priority = LOG_WARNING;
- } else {
- priority = LOG_DEBUG;
- }
- prefix = "DEBUG";
- break;
- default:
- priority = LOG_DEBUG;
- prefix = "UNKNOWN";
- break;
- }
-
- if (priorityp != NULL) {
- *priorityp = priority;
- }
- if (prefixp != NULL) {
- *prefixp = prefix;
- }
+ int priority;
+ const char *prefix;
+
+ /* Process the message prefix and priority */
+ switch (log_level & G_LOG_LEVEL_MASK) {
+ case G_LOG_FLAG_FATAL:
+ priority = LOG_EMERG;
+ prefix = "FATAL";
+ break;
+ case G_LOG_LEVEL_ERROR:
+ priority = LOG_ERR;
+ prefix = "ERROR";
+ break;
+ case G_LOG_LEVEL_CRITICAL:
+ priority = LOG_CRIT;
+ prefix = "CRITICAL";
+ break;
+ case G_LOG_LEVEL_WARNING:
+ priority = LOG_WARNING;
+ prefix = "WARNING";
+ break;
+ case G_LOG_LEVEL_MESSAGE:
+ priority = LOG_NOTICE;
+ prefix = "MESSAGE";
+ break;
+ case G_LOG_LEVEL_INFO:
+ priority = LOG_INFO;
+ prefix = "INFO";
+ break;
+ case G_LOG_LEVEL_DEBUG:
+ /* if debug was requested then bump this up to ERROR
+ * to ensure it is seen in a log */
+ if (syslog_levels & G_LOG_LEVEL_DEBUG) {
+ priority = LOG_WARNING;
+ } else {
+ priority = LOG_DEBUG;
+ }
+ prefix = "DEBUG";
+ break;
+ default:
+ priority = LOG_DEBUG;
+ prefix = "UNKNOWN";
+ break;
+ }
+
+ if (priorityp != NULL) {
+ *priorityp = priority;
+ }
+ if (prefixp != NULL) {
+ *prefixp = prefix;
+ }
}
void
gdm_log_default_handler (const gchar *log_domain,
- GLogLevelFlags log_level,
- const gchar *message,
- gpointer unused_data)
+ GLogLevelFlags log_level,
+ const gchar *message,
+ gpointer unused_data)
{
- GString *gstring;
- int priority;
- const char *level_prefix;
- char *string;
- gboolean do_log;
- gboolean is_fatal;
-
- is_fatal = (log_level & G_LOG_FLAG_FATAL) != 0;
-
- do_log = (log_level & syslog_levels);
- if (! do_log) {
- return;
- }
-
- if (! initialized) {
- gdm_log_init ();
- }
-
- log_level_to_priority_and_prefix (log_level,
- &priority,
- &level_prefix);
-
- gstring = g_string_new (NULL);
-
- if (log_domain != NULL) {
- g_string_append (gstring, log_domain);
- g_string_append_c (gstring, '-');
- }
- g_string_append (gstring, level_prefix);
-
- g_string_append (gstring, ": ");
- if (message == NULL) {
- g_string_append (gstring, "(NULL) message");
- } else {
- g_string_append (gstring, message);
- }
- if (is_fatal) {
- g_string_append (gstring, "\naborting...\n");
- } else {
- g_string_append (gstring, "\n");
- }
-
- string = g_string_free (gstring, FALSE);
-
- syslog (priority, "%s", string);
-
- g_free (string);
+ GString *gstring;
+ int priority;
+ const char *level_prefix;
+ char *string;
+ gboolean do_log;
+ gboolean is_fatal;
+
+ is_fatal = (log_level & G_LOG_FLAG_FATAL) != 0;
+
+ do_log = (log_level & syslog_levels);
+ if (! do_log) {
+ return;
+ }
+
+ if (! initialized) {
+ gdm_log_init ();
+ }
+
+ log_level_to_priority_and_prefix (log_level,
+ &priority,
+ &level_prefix);
+
+ gstring = g_string_new (NULL);
+
+ if (log_domain != NULL) {
+ g_string_append (gstring, log_domain);
+ g_string_append_c (gstring, '-');
+ }
+ g_string_append (gstring, level_prefix);
+
+ g_string_append (gstring, ": ");
+ if (message == NULL) {
+ g_string_append (gstring, "(NULL) message");
+ } else {
+ g_string_append (gstring, message);
+ }
+ if (is_fatal) {
+ g_string_append (gstring, "\naborting...\n");
+ } else {
+ g_string_append (gstring, "\n");
+ }
+
+ string = g_string_free (gstring, FALSE);
+
+ syslog (priority, "%s", string);
+
+ g_free (string);
}
void
gdm_log_toggle_debug (void)
{
- if (syslog_levels & G_LOG_LEVEL_DEBUG) {
- g_debug ("Debugging disabled");
- syslog_levels &= ~G_LOG_LEVEL_DEBUG;
- } else {
- syslog_levels |= G_LOG_LEVEL_DEBUG;
- g_debug ("Debugging enabled");
- }
+ if (syslog_levels & G_LOG_LEVEL_DEBUG) {
+ g_debug ("Debugging disabled");
+ syslog_levels &= ~G_LOG_LEVEL_DEBUG;
+ } else {
+ syslog_levels |= G_LOG_LEVEL_DEBUG;
+ g_debug ("Debugging enabled");
+ }
}
void
gdm_log_set_debug (gboolean debug)
{
- if (debug) {
- syslog_levels |= G_LOG_LEVEL_DEBUG;
- } else {
- syslog_levels &= ~G_LOG_LEVEL_DEBUG;
- }
+ if (debug) {
+ syslog_levels |= G_LOG_LEVEL_DEBUG;
+ } else {
+ syslog_levels &= ~G_LOG_LEVEL_DEBUG;
+ }
}
void
gdm_log_init (void)
{
- const char *prg_name;
- int options;
+ const char *prg_name;
+ int options;
- g_log_set_default_handler (gdm_log_default_handler, NULL);
+ g_log_set_default_handler (gdm_log_default_handler, NULL);
- prg_name = g_get_prgname ();
+ prg_name = g_get_prgname ();
- options = LOG_PID;
+ options = LOG_PID;
#ifdef LOG_PERROR
- options |= LOG_PERROR;
+ options |= LOG_PERROR;
#endif
- openlog (prg_name, options, LOG_DAEMON);
+ openlog (prg_name, options, LOG_DAEMON);
- initialized = TRUE;
+ initialized = TRUE;
}
void
gdm_log_shutdown (void)
{
- closelog ();
- initialized = FALSE;
+ closelog ();
+ initialized = FALSE;
}
diff --git a/common/gdm-log.h b/common/gdm-log.h
index 77c2d6fb..2b52ccda 100644
--- a/common/gdm-log.h
+++ b/common/gdm-log.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -31,7 +31,7 @@ G_BEGIN_DECLS
void gdm_log_default_handler (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *message,
- gpointer unused_data);
+ gpointer unused_data);
void gdm_log_set_debug (gboolean debug);
void gdm_log_toggle_debug (void);
void gdm_log_init (void);
diff --git a/common/gdm-md5.c b/common/gdm-md5.c
index 6a676a59..f25e9d10 100644
--- a/common/gdm-md5.c
+++ b/common/gdm-md5.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* gdm-md5.c md5 implementation (based on L Peter Deutsch implementation)
*
@@ -64,24 +64,24 @@
int
main(int argc, char **argv)
{
- int i;
- for (i = 1; i <= 64; ++i)
- {
- unsigned long v = (unsigned long)(4294967296.0 * fabs(sin((double)i)));
-
- /*
- * The following nonsense is only to avoid compiler warnings about
- * "integer constant is unsigned in ANSI C, signed with -traditional".
- */
- if (v >> 31)
- {
- printf("#define T%d /* 0x%08lx */ (T_MASK ^ 0x%08lx)\n", i,
- v, (unsigned long)(unsigned int)(~v));
- } else {
- printf("#define T%d 0x%08lx\n", i, v);
- }
- }
- return 0;
+ int i;
+ for (i = 1; i <= 64; ++i)
+ {
+ unsigned long v = (unsigned long)(4294967296.0 * fabs(sin((double)i)));
+
+ /*
+ * The following nonsense is only to avoid compiler warnings about
+ * "integer constant is unsigned in ANSI C, signed with -traditional".
+ */
+ if (v >> 31)
+ {
+ printf("#define T%d /* 0x%08lx */ (T_MASK ^ 0x%08lx)\n", i,
+ v, (unsigned long)(unsigned int)(~v));
+ } else {
+ printf("#define T%d 0x%08lx\n", i, v);
+ }
+ }
+ return 0;
}
#endif /* COMPUTE_T_VALUES */
/*
@@ -157,234 +157,234 @@ main(int argc, char **argv)
static void
md5_process (GdmMD5Context *context,
- const unsigned char *data /*[64]*/)
+ const unsigned char *data /*[64]*/)
{
- guint32
- a = context->abcd[0], b = context->abcd[1],
- c = context->abcd[2], d = context->abcd[3];
- guint32 t;
+ guint32
+ a = context->abcd[0], b = context->abcd[1],
+ c = context->abcd[2], d = context->abcd[3];
+ guint32 t;
#ifdef WORDS_BIGENDIAN
- /*
- * On big-endian machines, we must arrange the bytes in the right
- * order. (This also works on machines of unknown byte order.)
- */
- guint32 X[16];
- const unsigned char *xp = data;
- int i;
+ /*
+ * On big-endian machines, we must arrange the bytes in the right
+ * order. (This also works on machines of unknown byte order.)
+ */
+ guint32 X[16];
+ const unsigned char *xp = data;
+ int i;
- for (i = 0; i < 16; ++i, xp += 4)
- X[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
+ for (i = 0; i < 16; ++i, xp += 4)
+ X[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
#else /* !WORDS_BIGENDIAN */
- /*
- * On little-endian machines, we can process properly aligned data
- * without copying it.
- */
- guint32 xbuf[16];
- const guint32 *X;
-
- if (!((data - (const unsigned char *)0) & 3))
- {
- /* data are properly aligned */
- X = (const guint32 *)data;
- }
- else
- {
- /* not aligned */
- memcpy(xbuf, data, 64);
- X = xbuf;
- }
+ /*
+ * On little-endian machines, we can process properly aligned data
+ * without copying it.
+ */
+ guint32 xbuf[16];
+ const guint32 *X;
+
+ if (!((data - (const unsigned char *)0) & 3))
+ {
+ /* data are properly aligned */
+ X = (const guint32 *)data;
+ }
+ else
+ {
+ /* not aligned */
+ memcpy(xbuf, data, 64);
+ X = xbuf;
+ }
#endif
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
- /* Round 1. */
- /* Let [abcd k s i] denote the operation
- a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */
+ /* Round 1. */
+ /* Let [abcd k s i] denote the operation
+ a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */
#define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
#define SET(a, b, c, d, k, s, Ti) \
- t = a + F(b,c,d) + X[k] + Ti; \
- a = ROTATE_LEFT(t, s) + b
- /* Do the following 16 operations. */
- SET(a, b, c, d, 0, 7, T1);
- SET(d, a, b, c, 1, 12, T2);
- SET(c, d, a, b, 2, 17, T3);
- SET(b, c, d, a, 3, 22, T4);
- SET(a, b, c, d, 4, 7, T5);
- SET(d, a, b, c, 5, 12, T6);
- SET(c, d, a, b, 6, 17, T7);
- SET(b, c, d, a, 7, 22, T8);
- SET(a, b, c, d, 8, 7, T9);
- SET(d, a, b, c, 9, 12, T10);
- SET(c, d, a, b, 10, 17, T11);
- SET(b, c, d, a, 11, 22, T12);
- SET(a, b, c, d, 12, 7, T13);
- SET(d, a, b, c, 13, 12, T14);
- SET(c, d, a, b, 14, 17, T15);
- SET(b, c, d, a, 15, 22, T16);
+ t = a + F(b,c,d) + X[k] + Ti; \
+ a = ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 0, 7, T1);
+ SET(d, a, b, c, 1, 12, T2);
+ SET(c, d, a, b, 2, 17, T3);
+ SET(b, c, d, a, 3, 22, T4);
+ SET(a, b, c, d, 4, 7, T5);
+ SET(d, a, b, c, 5, 12, T6);
+ SET(c, d, a, b, 6, 17, T7);
+ SET(b, c, d, a, 7, 22, T8);
+ SET(a, b, c, d, 8, 7, T9);
+ SET(d, a, b, c, 9, 12, T10);
+ SET(c, d, a, b, 10, 17, T11);
+ SET(b, c, d, a, 11, 22, T12);
+ SET(a, b, c, d, 12, 7, T13);
+ SET(d, a, b, c, 13, 12, T14);
+ SET(c, d, a, b, 14, 17, T15);
+ SET(b, c, d, a, 15, 22, T16);
#undef SET
- /* Round 2. */
- /* Let [abcd k s i] denote the operation
- a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */
+ /* Round 2. */
+ /* Let [abcd k s i] denote the operation
+ a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */
#define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
#define SET(a, b, c, d, k, s, Ti) \
- t = a + G(b,c,d) + X[k] + Ti; \
- a = ROTATE_LEFT(t, s) + b
- /* Do the following 16 operations. */
- SET(a, b, c, d, 1, 5, T17);
- SET(d, a, b, c, 6, 9, T18);
- SET(c, d, a, b, 11, 14, T19);
- SET(b, c, d, a, 0, 20, T20);
- SET(a, b, c, d, 5, 5, T21);
- SET(d, a, b, c, 10, 9, T22);
- SET(c, d, a, b, 15, 14, T23);
- SET(b, c, d, a, 4, 20, T24);
- SET(a, b, c, d, 9, 5, T25);
- SET(d, a, b, c, 14, 9, T26);
- SET(c, d, a, b, 3, 14, T27);
- SET(b, c, d, a, 8, 20, T28);
- SET(a, b, c, d, 13, 5, T29);
- SET(d, a, b, c, 2, 9, T30);
- SET(c, d, a, b, 7, 14, T31);
- SET(b, c, d, a, 12, 20, T32);
+ t = a + G(b,c,d) + X[k] + Ti; \
+ a = ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 1, 5, T17);
+ SET(d, a, b, c, 6, 9, T18);
+ SET(c, d, a, b, 11, 14, T19);
+ SET(b, c, d, a, 0, 20, T20);
+ SET(a, b, c, d, 5, 5, T21);
+ SET(d, a, b, c, 10, 9, T22);
+ SET(c, d, a, b, 15, 14, T23);
+ SET(b, c, d, a, 4, 20, T24);
+ SET(a, b, c, d, 9, 5, T25);
+ SET(d, a, b, c, 14, 9, T26);
+ SET(c, d, a, b, 3, 14, T27);
+ SET(b, c, d, a, 8, 20, T28);
+ SET(a, b, c, d, 13, 5, T29);
+ SET(d, a, b, c, 2, 9, T30);
+ SET(c, d, a, b, 7, 14, T31);
+ SET(b, c, d, a, 12, 20, T32);
#undef SET
- /* Round 3. */
- /* Let [abcd k s t] denote the operation
- a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */
+ /* Round 3. */
+ /* Let [abcd k s t] denote the operation
+ a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define SET(a, b, c, d, k, s, Ti) \
- t = a + H(b,c,d) + X[k] + Ti; \
- a = ROTATE_LEFT(t, s) + b
- /* Do the following 16 operations. */
- SET(a, b, c, d, 5, 4, T33);
- SET(d, a, b, c, 8, 11, T34);
- SET(c, d, a, b, 11, 16, T35);
- SET(b, c, d, a, 14, 23, T36);
- SET(a, b, c, d, 1, 4, T37);
- SET(d, a, b, c, 4, 11, T38);
- SET(c, d, a, b, 7, 16, T39);
- SET(b, c, d, a, 10, 23, T40);
- SET(a, b, c, d, 13, 4, T41);
- SET(d, a, b, c, 0, 11, T42);
- SET(c, d, a, b, 3, 16, T43);
- SET(b, c, d, a, 6, 23, T44);
- SET(a, b, c, d, 9, 4, T45);
- SET(d, a, b, c, 12, 11, T46);
- SET(c, d, a, b, 15, 16, T47);
- SET(b, c, d, a, 2, 23, T48);
+ t = a + H(b,c,d) + X[k] + Ti; \
+ a = ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 5, 4, T33);
+ SET(d, a, b, c, 8, 11, T34);
+ SET(c, d, a, b, 11, 16, T35);
+ SET(b, c, d, a, 14, 23, T36);
+ SET(a, b, c, d, 1, 4, T37);
+ SET(d, a, b, c, 4, 11, T38);
+ SET(c, d, a, b, 7, 16, T39);
+ SET(b, c, d, a, 10, 23, T40);
+ SET(a, b, c, d, 13, 4, T41);
+ SET(d, a, b, c, 0, 11, T42);
+ SET(c, d, a, b, 3, 16, T43);
+ SET(b, c, d, a, 6, 23, T44);
+ SET(a, b, c, d, 9, 4, T45);
+ SET(d, a, b, c, 12, 11, T46);
+ SET(c, d, a, b, 15, 16, T47);
+ SET(b, c, d, a, 2, 23, T48);
#undef SET
- /* Round 4. */
- /* Let [abcd k s t] denote the operation
- a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */
+ /* Round 4. */
+ /* Let [abcd k s t] denote the operation
+ a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */
#define I(x, y, z) ((y) ^ ((x) | ~(z)))
#define SET(a, b, c, d, k, s, Ti) \
- t = a + I(b,c,d) + X[k] + Ti; \
- a = ROTATE_LEFT(t, s) + b
- /* Do the following 16 operations. */
- SET(a, b, c, d, 0, 6, T49);
- SET(d, a, b, c, 7, 10, T50);
- SET(c, d, a, b, 14, 15, T51);
- SET(b, c, d, a, 5, 21, T52);
- SET(a, b, c, d, 12, 6, T53);
- SET(d, a, b, c, 3, 10, T54);
- SET(c, d, a, b, 10, 15, T55);
- SET(b, c, d, a, 1, 21, T56);
- SET(a, b, c, d, 8, 6, T57);
- SET(d, a, b, c, 15, 10, T58);
- SET(c, d, a, b, 6, 15, T59);
- SET(b, c, d, a, 13, 21, T60);
- SET(a, b, c, d, 4, 6, T61);
- SET(d, a, b, c, 11, 10, T62);
- SET(c, d, a, b, 2, 15, T63);
- SET(b, c, d, a, 9, 21, T64);
+ t = a + I(b,c,d) + X[k] + Ti; \
+ a = ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 0, 6, T49);
+ SET(d, a, b, c, 7, 10, T50);
+ SET(c, d, a, b, 14, 15, T51);
+ SET(b, c, d, a, 5, 21, T52);
+ SET(a, b, c, d, 12, 6, T53);
+ SET(d, a, b, c, 3, 10, T54);
+ SET(c, d, a, b, 10, 15, T55);
+ SET(b, c, d, a, 1, 21, T56);
+ SET(a, b, c, d, 8, 6, T57);
+ SET(d, a, b, c, 15, 10, T58);
+ SET(c, d, a, b, 6, 15, T59);
+ SET(b, c, d, a, 13, 21, T60);
+ SET(a, b, c, d, 4, 6, T61);
+ SET(d, a, b, c, 11, 10, T62);
+ SET(c, d, a, b, 2, 15, T63);
+ SET(b, c, d, a, 9, 21, T64);
#undef SET
- /* Then perform the following additions. (That is increment each
- of the four registers by the value it had before this block
- was started.) */
- context->abcd[0] += a;
- context->abcd[1] += b;
- context->abcd[2] += c;
- context->abcd[3] += d;
+ /* Then perform the following additions. (That is increment each
+ of the four registers by the value it had before this block
+ was started.) */
+ context->abcd[0] += a;
+ context->abcd[1] += b;
+ context->abcd[2] += c;
+ context->abcd[3] += d;
}
static void
md5_init (GdmMD5Context *context)
{
- context->count[0] = context->count[1] = 0;
- context->abcd[0] = 0x67452301;
- context->abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476;
- context->abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301;
- context->abcd[3] = 0x10325476;
+ context->count[0] = context->count[1] = 0;
+ context->abcd[0] = 0x67452301;
+ context->abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476;
+ context->abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301;
+ context->abcd[3] = 0x10325476;
}
static void
md5_append (GdmMD5Context *context,
- const unsigned char *data,
- int nbytes)
+ const unsigned char *data,
+ int nbytes)
{
- const unsigned char *p = data;
- int left = nbytes;
- int offset = (context->count[0] >> 3) & 63;
- guint32 nbits = (guint32)(nbytes << 3);
-
- if (nbytes <= 0)
- return;
-
- /* Update the message length. */
- context->count[1] += nbytes >> 29;
- context->count[0] += nbits;
- if (context->count[0] < nbits)
- context->count[1]++;
-
- /* Process an initial partial block. */
- if (offset)
- {
- int copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
-
- memcpy(context->buf + offset, p, copy);
- if (offset + copy < 64)
- return;
- p += copy;
- left -= copy;
- md5_process(context, context->buf);
- }
-
- /* Process full blocks. */
- for (; left >= 64; p += 64, left -= 64)
- md5_process(context, p);
-
- /* Process a final partial block. */
- if (left)
- memcpy(context->buf, p, left);
+ const unsigned char *p = data;
+ int left = nbytes;
+ int offset = (context->count[0] >> 3) & 63;
+ guint32 nbits = (guint32)(nbytes << 3);
+
+ if (nbytes <= 0)
+ return;
+
+ /* Update the message length. */
+ context->count[1] += nbytes >> 29;
+ context->count[0] += nbits;
+ if (context->count[0] < nbits)
+ context->count[1]++;
+
+ /* Process an initial partial block. */
+ if (offset)
+ {
+ int copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
+
+ memcpy(context->buf + offset, p, copy);
+ if (offset + copy < 64)
+ return;
+ p += copy;
+ left -= copy;
+ md5_process(context, context->buf);
+ }
+
+ /* Process full blocks. */
+ for (; left >= 64; p += 64, left -= 64)
+ md5_process(context, p);
+
+ /* Process a final partial block. */
+ if (left)
+ memcpy(context->buf, p, left);
}
static void
md5_finish (GdmMD5Context *context,
- unsigned char digest[16])
+ unsigned char digest[16])
{
- static const unsigned char pad[64] = {
- 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
- unsigned char data[8];
- int i;
-
- /* Save the length before padding. */
- for (i = 0; i < 8; ++i)
- data[i] = (unsigned char)(context->count[i >> 2] >> ((i & 3) << 3));
- /* Pad to 56 bytes mod 64. */
- md5_append(context, pad, ((55 - (context->count[0] >> 3)) & 63) + 1);
- /* Append the length. */
- md5_append(context, data, 8);
- for (i = 0; i < 16; ++i)
- digest[i] = (unsigned char)(context->abcd[i >> 2] >> ((i & 3) << 3));
+ static const unsigned char pad[64] = {
+ 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
+ unsigned char data[8];
+ int i;
+
+ /* Save the length before padding. */
+ for (i = 0; i < 8; ++i)
+ data[i] = (unsigned char)(context->count[i >> 2] >> ((i & 3) << 3));
+ /* Pad to 56 bytes mod 64. */
+ md5_append(context, pad, ((55 - (context->count[0] >> 3)) & 63) + 1);
+ /* Append the length. */
+ md5_append(context, data, 8);
+ for (i = 0; i < 16; ++i)
+ digest[i] = (unsigned char)(context->abcd[i >> 2] >> ((i & 3) << 3));
}
/** @} */ /* End of internals */
@@ -403,7 +403,7 @@ md5_finish (GdmMD5Context *context,
void
gdm_md5_init (GdmMD5Context *context)
{
- md5_init (context);
+ md5_init (context);
}
@@ -415,15 +415,15 @@ gdm_md5_init (GdmMD5Context *context)
*/
void
gdm_md5_update (GdmMD5Context *context,
- const GString *data)
+ const GString *data)
{
- unsigned int inputLen;
- unsigned char *input;
+ unsigned int inputLen;
+ unsigned char *input;
- input = (unsigned char *)data->str;
- inputLen = data->len;
+ input = (unsigned char *)data->str;
+ inputLen = data->len;
- md5_append (context, input, inputLen);
+ md5_append (context, input, inputLen);
}
/**
@@ -439,19 +439,19 @@ gdm_md5_update (GdmMD5Context *context,
*/
gboolean
gdm_md5_final (GdmMD5Context *context,
- GString *results)
+ GString *results)
{
- unsigned char digest[16];
+ unsigned char digest[16];
- md5_finish (context, digest);
+ md5_finish (context, digest);
- if (!g_string_append_len (results, digest, 16))
- return FALSE;
+ if (!g_string_append_len (results, digest, 16))
+ return FALSE;
- /* some kind of security paranoia, though it seems pointless
- * to me given the nonzeroed stuff flying around
- */
- memset ((void*)context, '\0', sizeof (GdmMD5Context));
+ /* some kind of security paranoia, though it seems pointless
+ * to me given the nonzeroed stuff flying around
+ */
+ memset ((void*)context, '\0', sizeof (GdmMD5Context));
- return TRUE;
+ return TRUE;
}
diff --git a/common/gdm-md5.h b/common/gdm-md5.h
index 80051f49..dbc45c14 100644
--- a/common/gdm-md5.h
+++ b/common/gdm-md5.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* gdm-md5.h md5 implementation (based on L Peter Deutsch implementation)
*
@@ -34,16 +34,16 @@ typedef struct GdmMD5Context GdmMD5Context;
*/
struct GdmMD5Context
{
- guint32 count[2]; /**< message length in bits, lsw first */
- guint32 abcd[4]; /**< digest buffer */
- unsigned char buf[64]; /**< accumulate block */
+ guint32 count[2]; /**< message length in bits, lsw first */
+ guint32 abcd[4]; /**< digest buffer */
+ unsigned char buf[64]; /**< accumulate block */
};
void gdm_md5_init (GdmMD5Context *context);
void gdm_md5_update (GdmMD5Context *context,
- const GString *data);
+ const GString *data);
gboolean gdm_md5_final (GdmMD5Context *context,
- GString *results);
+ GString *results);
G_END_DECLS
diff --git a/common/gdm-settings-backend.c b/common/gdm-settings-backend.c
index 760592b7..f2e4da61 100644
--- a/common/gdm-settings-backend.c
+++ b/common/gdm-settings-backend.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -41,19 +41,19 @@
struct GdmSettingsBackendPrivate
{
- gpointer dummy;
+ gpointer dummy;
};
enum {
- VALUE_CHANGED,
- LAST_SIGNAL
+ VALUE_CHANGED,
+ LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0, };
-static void gdm_settings_backend_class_init (GdmSettingsBackendClass *klass);
-static void gdm_settings_backend_init (GdmSettingsBackend *settings_backend);
-static void gdm_settings_backend_finalize (GObject *object);
+static void gdm_settings_backend_class_init (GdmSettingsBackendClass *klass);
+static void gdm_settings_backend_init (GdmSettingsBackend *settings_backend);
+static void gdm_settings_backend_finalize (GObject *object);
static gpointer settings_backend_object = NULL;
@@ -62,125 +62,125 @@ G_DEFINE_ABSTRACT_TYPE (GdmSettingsBackend, gdm_settings_backend, G_TYPE_OBJECT)
GQuark
gdm_settings_backend_error_quark (void)
{
- static GQuark ret = 0;
- if (ret == 0) {
- ret = g_quark_from_static_string ("gdm_settings_backend_error");
- }
+ static GQuark ret = 0;
+ if (ret == 0) {
+ ret = g_quark_from_static_string ("gdm_settings_backend_error");
+ }
- return ret;
+ return ret;
}
static gboolean
gdm_settings_backend_real_get_value (GdmSettingsBackend *settings_backend,
- const char *key,
- char **value,
- GError **error)
+ const char *key,
+ char **value,
+ GError **error)
{
- g_return_val_if_fail (GDM_IS_SETTINGS_BACKEND (settings_backend), FALSE);
+ g_return_val_if_fail (GDM_IS_SETTINGS_BACKEND (settings_backend), FALSE);
- return FALSE;
+ return FALSE;
}
static gboolean
gdm_settings_backend_real_set_value (GdmSettingsBackend *settings_backend,
- const char *key,
- const char *value,
- GError **error)
+ const char *key,
+ const char *value,
+ GError **error)
{
- g_return_val_if_fail (GDM_IS_SETTINGS_BACKEND (settings_backend), FALSE);
+ g_return_val_if_fail (GDM_IS_SETTINGS_BACKEND (settings_backend), FALSE);
- return FALSE;
+ return FALSE;
}
gboolean
gdm_settings_backend_get_value (GdmSettingsBackend *settings_backend,
- const char *key,
- char **value,
- GError **error)
+ const char *key,
+ char **value,
+ GError **error)
{
- gboolean ret;
+ gboolean ret;
- g_return_val_if_fail (GDM_IS_SETTINGS_BACKEND (settings_backend), FALSE);
+ g_return_val_if_fail (GDM_IS_SETTINGS_BACKEND (settings_backend), FALSE);
- g_object_ref (settings_backend);
- ret = GDM_SETTINGS_BACKEND_GET_CLASS (settings_backend)->get_value (settings_backend, key, value, error);
- g_object_unref (settings_backend);
+ g_object_ref (settings_backend);
+ ret = GDM_SETTINGS_BACKEND_GET_CLASS (settings_backend)->get_value (settings_backend, key, value, error);
+ g_object_unref (settings_backend);
- return ret;
+ return ret;
}
gboolean
gdm_settings_backend_set_value (GdmSettingsBackend *settings_backend,
- const char *key,
- const char *value,
- GError **error)
+ const char *key,
+ const char *value,
+ GError **error)
{
- gboolean ret;
+ gboolean ret;
- g_return_val_if_fail (GDM_IS_SETTINGS_BACKEND (settings_backend), FALSE);
+ g_return_val_if_fail (GDM_IS_SETTINGS_BACKEND (settings_backend), FALSE);
- g_object_ref (settings_backend);
- ret = GDM_SETTINGS_BACKEND_GET_CLASS (settings_backend)->set_value (settings_backend, key, value, error);
- g_object_unref (settings_backend);
+ g_object_ref (settings_backend);
+ ret = GDM_SETTINGS_BACKEND_GET_CLASS (settings_backend)->set_value (settings_backend, key, value, error);
+ g_object_unref (settings_backend);
- return ret;
+ return ret;
}
void
gdm_settings_backend_value_changed (GdmSettingsBackend *settings_backend,
- const char *key,
- const char *old_value,
- const char *new_value)
+ const char *key,
+ const char *old_value,
+ const char *new_value)
{
- g_return_if_fail (GDM_IS_SETTINGS_BACKEND (settings_backend));
+ g_return_if_fail (GDM_IS_SETTINGS_BACKEND (settings_backend));
- g_signal_emit (settings_backend, signals[VALUE_CHANGED], 0, key, old_value, new_value);
+ g_signal_emit (settings_backend, signals[VALUE_CHANGED], 0, key, old_value, new_value);
}
static void
gdm_settings_backend_class_init (GdmSettingsBackendClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = gdm_settings_backend_finalize;
-
- klass->get_value = gdm_settings_backend_real_get_value;
- klass->set_value = gdm_settings_backend_real_set_value;
-
- signals [VALUE_CHANGED] =
- g_signal_new ("value-changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdmSettingsBackendClass, value_changed),
- NULL,
- NULL,
- gdm_marshal_VOID__STRING_STRING_STRING,
- G_TYPE_NONE,
- 3,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING);
-
- g_type_class_add_private (klass, sizeof (GdmSettingsBackendPrivate));
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gdm_settings_backend_finalize;
+
+ klass->get_value = gdm_settings_backend_real_get_value;
+ klass->set_value = gdm_settings_backend_real_set_value;
+
+ signals [VALUE_CHANGED] =
+ g_signal_new ("value-changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdmSettingsBackendClass, value_changed),
+ NULL,
+ NULL,
+ gdm_marshal_VOID__STRING_STRING_STRING,
+ G_TYPE_NONE,
+ 3,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
+
+ g_type_class_add_private (klass, sizeof (GdmSettingsBackendPrivate));
}
static void
gdm_settings_backend_init (GdmSettingsBackend *settings_backend)
{
- settings_backend->priv = GDM_SETTINGS_BACKEND_GET_PRIVATE (settings_backend);
+ settings_backend->priv = GDM_SETTINGS_BACKEND_GET_PRIVATE (settings_backend);
}
static void
gdm_settings_backend_finalize (GObject *object)
{
- GdmSettingsBackend *settings_backend;
+ GdmSettingsBackend *settings_backend;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_SETTINGS_BACKEND (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_SETTINGS_BACKEND (object));
- settings_backend = GDM_SETTINGS_BACKEND (object);
+ settings_backend = GDM_SETTINGS_BACKEND (object);
- g_return_if_fail (settings_backend->priv != NULL);
+ g_return_if_fail (settings_backend->priv != NULL);
- G_OBJECT_CLASS (gdm_settings_backend_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_settings_backend_parent_class)->finalize (object);
}
diff --git a/common/gdm-settings-backend.h b/common/gdm-settings-backend.h
index 18198638..118699a2 100644
--- a/common/gdm-settings-backend.h
+++ b/common/gdm-settings-backend.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -37,55 +37,55 @@ typedef struct GdmSettingsBackendPrivate GdmSettingsBackendPrivate;
typedef struct
{
- GObject parent;
- GdmSettingsBackendPrivate *priv;
+ GObject parent;
+ GdmSettingsBackendPrivate *priv;
} GdmSettingsBackend;
typedef struct
{
- GObjectClass parent_class;
-
- /* methods */
- gboolean (*get_value) (GdmSettingsBackend *settings_backend,
- const char *key,
- char **value,
- GError **error);
- gboolean (*set_value) (GdmSettingsBackend *settings_backend,
- const char *key,
- const char *value,
- GError **error);
-
- /* signals */
- void (* value_changed) (GdmSettingsBackend *settings_backend,
- const char *key,
- const char *old_value,
- const char **new_value);
+ GObjectClass parent_class;
+
+ /* methods */
+ gboolean (*get_value) (GdmSettingsBackend *settings_backend,
+ const char *key,
+ char **value,
+ GError **error);
+ gboolean (*set_value) (GdmSettingsBackend *settings_backend,
+ const char *key,
+ const char *value,
+ GError **error);
+
+ /* signals */
+ void (* value_changed) (GdmSettingsBackend *settings_backend,
+ const char *key,
+ const char *old_value,
+ const char **new_value);
} GdmSettingsBackendClass;
typedef enum
{
- GDM_SETTINGS_BACKEND_ERROR_GENERAL,
- GDM_SETTINGS_BACKEND_ERROR_KEY_NOT_FOUND
+ GDM_SETTINGS_BACKEND_ERROR_GENERAL,
+ GDM_SETTINGS_BACKEND_ERROR_KEY_NOT_FOUND
} GdmSettingsBackendError;
#define GDM_SETTINGS_BACKEND_ERROR gdm_settings_backend_error_quark ()
-GQuark gdm_settings_backend_error_quark (void);
-GType gdm_settings_backend_get_type (void);
+GQuark gdm_settings_backend_error_quark (void);
+GType gdm_settings_backend_get_type (void);
gboolean gdm_settings_backend_get_value (GdmSettingsBackend *settings_backend,
- const char *key,
- char **value,
- GError **error);
+ const char *key,
+ char **value,
+ GError **error);
gboolean gdm_settings_backend_set_value (GdmSettingsBackend *settings_backend,
- const char *key,
- const char *value,
- GError **error);
+ const char *key,
+ const char *value,
+ GError **error);
void gdm_settings_backend_value_changed (GdmSettingsBackend *settings_backend,
- const char *key,
- const char *old_value,
- const char *new_value);
+ const char *key,
+ const char *old_value,
+ const char *new_value);
G_END_DECLS
diff --git a/common/gdm-settings-client.c b/common/gdm-settings-client.c
index 701209c9..099304d1 100644
--- a/common/gdm-settings-client.c
+++ b/common/gdm-settings-client.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -54,116 +54,116 @@ static DBusGConnection *connection = NULL;
static guint32 id_serial = 0;
typedef struct {
- guint id;
- char *root;
- GdmSettingsClientNotifyFunc func;
- gpointer user_data;
- GFreeFunc destroy_notify;
+ guint id;
+ char *root;
+ GdmSettingsClientNotifyFunc func;
+ gpointer user_data;
+ GFreeFunc destroy_notify;
} GdmSettingsClientNotify;
static void
gdm_settings_client_notify_free (GdmSettingsClientNotify *notify)
{
- g_free (notify->root);
+ g_free (notify->root);
- if (notify->destroy_notify != NULL) {
- notify->destroy_notify (notify->user_data);
- }
+ if (notify->destroy_notify != NULL) {
+ notify->destroy_notify (notify->user_data);
+ }
- g_free (notify);
+ g_free (notify);
}
static GdmSettingsEntry *
get_entry_for_key (const char *key)
{
- GdmSettingsEntry *entry;
+ GdmSettingsEntry *entry;
- entry = g_hash_table_lookup (schemas, key);
+ entry = g_hash_table_lookup (schemas, key);
- return entry;
+ return entry;
}
static gboolean
set_value (const char *key,
- const char *value)
+ const char *value)
{
- GError *error;
- gboolean res;
-
- /* FIXME: check cache */
-
- g_debug ("Setting %s=%s", key, value);
- error = NULL;
- res = dbus_g_proxy_call (settings_proxy,
- "SetValue",
- &error,
- G_TYPE_STRING, key,
- G_TYPE_STRING, value,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (! res) {
- if (error != NULL) {
- /*g_debug ("Failed to get value for %s: %s", key, error->message);*/
- g_error_free (error);
- } else {
- /*g_debug ("Failed to get value for %s", key);*/
- }
-
- return FALSE;
- }
-
- return TRUE;
+ GError *error;
+ gboolean res;
+
+ /* FIXME: check cache */
+
+ g_debug ("Setting %s=%s", key, value);
+ error = NULL;
+ res = dbus_g_proxy_call (settings_proxy,
+ "SetValue",
+ &error,
+ G_TYPE_STRING, key,
+ G_TYPE_STRING, value,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! res) {
+ if (error != NULL) {
+ /*g_debug ("Failed to get value for %s: %s", key, error->message);*/
+ g_error_free (error);
+ } else {
+ /*g_debug ("Failed to get value for %s", key);*/
+ }
+
+ return FALSE;
+ }
+
+ return TRUE;
}
static gboolean
get_value (const char *key,
- char **value)
+ char **value)
{
- GError *error;
- char *str;
- gboolean res;
-
- /* FIXME: check cache */
-
- error = NULL;
- res = dbus_g_proxy_call (settings_proxy,
- "GetValue",
- &error,
- G_TYPE_STRING, key,
- G_TYPE_INVALID,
- G_TYPE_STRING, &str,
- G_TYPE_INVALID);
- if (! res) {
- if (error != NULL) {
- /*g_debug ("Failed to get value for %s: %s", key, error->message);*/
- g_error_free (error);
- } else {
- /*g_debug ("Failed to get value for %s", key);*/
- }
-
- return FALSE;
- }
-
- if (value != NULL) {
- *value = g_strdup (str);
- }
-
- g_free (str);
-
- return TRUE;
+ GError *error;
+ char *str;
+ gboolean res;
+
+ /* FIXME: check cache */
+
+ error = NULL;
+ res = dbus_g_proxy_call (settings_proxy,
+ "GetValue",
+ &error,
+ G_TYPE_STRING, key,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &str,
+ G_TYPE_INVALID);
+ if (! res) {
+ if (error != NULL) {
+ /*g_debug ("Failed to get value for %s: %s", key, error->message);*/
+ g_error_free (error);
+ } else {
+ /*g_debug ("Failed to get value for %s", key);*/
+ }
+
+ return FALSE;
+ }
+
+ if (value != NULL) {
+ *value = g_strdup (str);
+ }
+
+ g_free (str);
+
+ return TRUE;
}
static void
assert_signature (GdmSettingsEntry *entry,
- const char *signature)
+ const char *signature)
{
- const char *sig;
+ const char *sig;
- sig = gdm_settings_entry_get_signature (entry);
+ sig = gdm_settings_entry_get_signature (entry);
- g_assert (sig != NULL);
- g_assert (signature != NULL);
- g_assert (strcmp (signature, sig) == 0);
+ g_assert (sig != NULL);
+ g_assert (signature != NULL);
+ g_assert (strcmp (signature, sig) == 0);
}
static guint32
@@ -182,322 +182,322 @@ get_next_serial (void)
guint
gdm_settings_client_notify_add (const char *root,
- GdmSettingsClientNotifyFunc func,
- gpointer user_data,
- GFreeFunc destroy_notify)
+ GdmSettingsClientNotifyFunc func,
+ gpointer user_data,
+ GFreeFunc destroy_notify)
{
- guint32 id;
- GdmSettingsClientNotify *notify;
+ guint32 id;
+ GdmSettingsClientNotify *notify;
- id = get_next_serial ();
+ id = get_next_serial ();
- notify = g_new0 (GdmSettingsClientNotify, 1);
- notify->id = id;
- notify->root = g_strdup (root);
- notify->func = func;
- notify->user_data = user_data;
- notify->destroy_notify = destroy_notify;
+ notify = g_new0 (GdmSettingsClientNotify, 1);
+ notify->id = id;
+ notify->root = g_strdup (root);
+ notify->func = func;
+ notify->user_data = user_data;
+ notify->destroy_notify = destroy_notify;
- g_hash_table_insert (notifiers, GINT_TO_POINTER (id), notify);
+ g_hash_table_insert (notifiers, GINT_TO_POINTER (id), notify);
- return id;
+ return id;
}
void
gdm_settings_client_notify_remove (guint id)
{
- g_hash_table_remove (notifiers, GINT_TO_POINTER (id));
+ g_hash_table_remove (notifiers, GINT_TO_POINTER (id));
}
gboolean
gdm_settings_client_get_string (const char *key,
- char **value)
+ char **value)
{
- GdmSettingsEntry *entry;
- gboolean ret;
- gboolean res;
- char *str;
+ GdmSettingsEntry *entry;
+ gboolean ret;
+ gboolean res;
+ char *str;
- g_return_val_if_fail (key != NULL, FALSE);
+ g_return_val_if_fail (key != NULL, FALSE);
- entry = get_entry_for_key (key);
- g_assert (entry != NULL);
+ entry = get_entry_for_key (key);
+ g_assert (entry != NULL);
- assert_signature (entry, "s");
+ assert_signature (entry, "s");
- ret = FALSE;
+ ret = FALSE;
- res = get_value (key, &str);
+ res = get_value (key, &str);
- if (! res) {
- /* use the default */
- str = g_strdup (gdm_settings_entry_get_default_value (entry));
- }
+ if (! res) {
+ /* use the default */
+ str = g_strdup (gdm_settings_entry_get_default_value (entry));
+ }
- if (value != NULL) {
- *value = g_strdup (str);
- }
+ if (value != NULL) {
+ *value = g_strdup (str);
+ }
- g_free (str);
+ g_free (str);
- return ret;
+ return ret;
}
gboolean
gdm_settings_client_get_locale_string (const char *key,
- const char *locale,
- char **value)
+ const char *locale,
+ char **value)
{
- char *candidate_key;
- char *translated_value;
- GError *error;
- char **languages;
- gboolean free_languages = FALSE;
- int i;
- gboolean ret;
-
- g_return_val_if_fail (key != NULL, FALSE);
-
- candidate_key = NULL;
- translated_value = NULL;
- error = NULL;
-
- if (locale != NULL) {
- languages = g_new (char *, 2);
- languages[0] = (char *)locale;
- languages[1] = NULL;
-
- free_languages = TRUE;
- } else {
- languages = (char **) g_get_language_names ();
- free_languages = FALSE;
- }
-
- for (i = 0; languages[i]; i++) {
- gboolean res;
-
- candidate_key = g_strdup_printf ("%s[%s]", key, languages[i]);
-
- res = get_value (candidate_key, &translated_value);
- g_free (candidate_key);
-
- if (res) {
- break;
- }
-
- g_free (translated_value);
- translated_value = NULL;
- }
-
- /* Fallback to untranslated key
- */
- if (translated_value == NULL) {
- get_value (key, &translated_value);
- }
-
- if (free_languages) {
- g_strfreev (languages);
- }
-
- if (translated_value != NULL) {
- ret = TRUE;
- if (value != NULL) {
- *value = g_strdup (translated_value);
- }
- } else {
- ret = FALSE;
- }
-
- g_free (translated_value);
-
- return ret;
+ char *candidate_key;
+ char *translated_value;
+ GError *error;
+ char **languages;
+ gboolean free_languages = FALSE;
+ int i;
+ gboolean ret;
+
+ g_return_val_if_fail (key != NULL, FALSE);
+
+ candidate_key = NULL;
+ translated_value = NULL;
+ error = NULL;
+
+ if (locale != NULL) {
+ languages = g_new (char *, 2);
+ languages[0] = (char *)locale;
+ languages[1] = NULL;
+
+ free_languages = TRUE;
+ } else {
+ languages = (char **) g_get_language_names ();
+ free_languages = FALSE;
+ }
+
+ for (i = 0; languages[i]; i++) {
+ gboolean res;
+
+ candidate_key = g_strdup_printf ("%s[%s]", key, languages[i]);
+
+ res = get_value (candidate_key, &translated_value);
+ g_free (candidate_key);
+
+ if (res) {
+ break;
+ }
+
+ g_free (translated_value);
+ translated_value = NULL;
+ }
+
+ /* Fallback to untranslated key
+ */
+ if (translated_value == NULL) {
+ get_value (key, &translated_value);
+ }
+
+ if (free_languages) {
+ g_strfreev (languages);
+ }
+
+ if (translated_value != NULL) {
+ ret = TRUE;
+ if (value != NULL) {
+ *value = g_strdup (translated_value);
+ }
+ } else {
+ ret = FALSE;
+ }
+
+ g_free (translated_value);
+
+ return ret;
}
gboolean
gdm_settings_client_get_boolean (const char *key,
- gboolean *value)
+ gboolean *value)
{
- GdmSettingsEntry *entry;
- gboolean ret;
- gboolean res;
- char *str;
+ GdmSettingsEntry *entry;
+ gboolean ret;
+ gboolean res;
+ char *str;
- g_return_val_if_fail (key != NULL, FALSE);
+ g_return_val_if_fail (key != NULL, FALSE);
- entry = get_entry_for_key (key);
- g_assert (entry != NULL);
+ entry = get_entry_for_key (key);
+ g_assert (entry != NULL);
- assert_signature (entry, "b");
+ assert_signature (entry, "b");
- ret = FALSE;
+ ret = FALSE;
- res = get_value (key, &str);
+ res = get_value (key, &str);
- if (! res) {
- /* use the default */
- str = g_strdup (gdm_settings_entry_get_default_value (entry));
- }
+ if (! res) {
+ /* use the default */
+ str = g_strdup (gdm_settings_entry_get_default_value (entry));
+ }
- ret = gdm_settings_parse_value_as_boolean (str, value);
+ ret = gdm_settings_parse_value_as_boolean (str, value);
- g_free (str);
+ g_free (str);
- return ret;
+ return ret;
}
gboolean
gdm_settings_client_get_int (const char *key,
- int *value)
+ int *value)
{
- GdmSettingsEntry *entry;
- gboolean ret;
- gboolean res;
- char *str;
+ GdmSettingsEntry *entry;
+ gboolean ret;
+ gboolean res;
+ char *str;
- g_return_val_if_fail (key != NULL, FALSE);
+ g_return_val_if_fail (key != NULL, FALSE);
- entry = get_entry_for_key (key);
- g_assert (entry != NULL);
+ entry = get_entry_for_key (key);
+ g_assert (entry != NULL);
- assert_signature (entry, "i");
+ assert_signature (entry, "i");
- ret = FALSE;
+ ret = FALSE;
- res = get_value (key, &str);
+ res = get_value (key, &str);
- if (! res) {
- /* use the default */
- str = g_strdup (gdm_settings_entry_get_default_value (entry));
- }
+ if (! res) {
+ /* use the default */
+ str = g_strdup (gdm_settings_entry_get_default_value (entry));
+ }
- ret = gdm_settings_parse_value_as_integer (str, value);
+ ret = gdm_settings_parse_value_as_integer (str, value);
- g_free (str);
+ g_free (str);
- return ret;
+ return ret;
}
gboolean
gdm_settings_client_set_int (const char *key,
- int value)
+ int value)
{
- GdmSettingsEntry *entry;
- gboolean res;
- char *str;
+ GdmSettingsEntry *entry;
+ gboolean res;
+ char *str;
- g_return_val_if_fail (key != NULL, FALSE);
+ g_return_val_if_fail (key != NULL, FALSE);
- entry = get_entry_for_key (key);
- g_assert (entry != NULL);
+ entry = get_entry_for_key (key);
+ g_assert (entry != NULL);
- assert_signature (entry, "i");
+ assert_signature (entry, "i");
- str = gdm_settings_parse_integer_as_value (value);
+ str = gdm_settings_parse_integer_as_value (value);
- res = set_value (key, str);
+ res = set_value (key, str);
- g_free (str);
+ g_free (str);
- return res;
+ return res;
}
gboolean
gdm_settings_client_set_string (const char *key,
- const char *value)
+ const char *value)
{
- GdmSettingsEntry *entry;
- gboolean res;
+ GdmSettingsEntry *entry;
+ gboolean res;
- g_return_val_if_fail (key != NULL, FALSE);
+ g_return_val_if_fail (key != NULL, FALSE);
- entry = get_entry_for_key (key);
- g_assert (entry != NULL);
+ entry = get_entry_for_key (key);
+ g_assert (entry != NULL);
- assert_signature (entry, "s");
+ assert_signature (entry, "s");
- res = set_value (key, value);
+ res = set_value (key, value);
- return res;
+ return res;
}
gboolean
gdm_settings_client_set_boolean (const char *key,
- gboolean value)
+ gboolean value)
{
- GdmSettingsEntry *entry;
- gboolean res;
- char *str;
+ GdmSettingsEntry *entry;
+ gboolean res;
+ char *str;
- g_return_val_if_fail (key != NULL, FALSE);
+ g_return_val_if_fail (key != NULL, FALSE);
- entry = get_entry_for_key (key);
- g_assert (entry != NULL);
+ entry = get_entry_for_key (key);
+ g_assert (entry != NULL);
- assert_signature (entry, "b");
+ assert_signature (entry, "b");
- str = gdm_settings_parse_boolean_as_value (value);
+ str = gdm_settings_parse_boolean_as_value (value);
- res = set_value (key, str);
+ res = set_value (key, str);
- g_free (str);
+ g_free (str);
- return res;
+ return res;
}
static void
hashify_list (GdmSettingsEntry *entry,
- gpointer data)
+ gpointer data)
{
- g_hash_table_insert (schemas, g_strdup (gdm_settings_entry_get_key (entry)), entry);
+ g_hash_table_insert (schemas, g_strdup (gdm_settings_entry_get_key (entry)), entry);
}
static void
send_notification (gpointer key,
- GdmSettingsClientNotify *notify,
- GdmSettingsEntry *entry)
+ GdmSettingsClientNotify *notify,
+ GdmSettingsEntry *entry)
{
- /* get out if the key is not in the region of interest */
- if (! g_str_has_prefix (gdm_settings_entry_get_key (entry), notify->root)) {
- return;
- }
+ /* get out if the key is not in the region of interest */
+ if (! g_str_has_prefix (gdm_settings_entry_get_key (entry), notify->root)) {
+ return;
+ }
- notify->func (notify->id, entry, notify->user_data);
+ notify->func (notify->id, entry, notify->user_data);
}
static void
on_value_changed (DBusGProxy *proxy,
- const char *key,
- const char *old_value,
- const char *new_value,
- gpointer data)
+ const char *key,
+ const char *old_value,
+ const char *new_value,
+ gpointer data)
{
- GdmSettingsEntry *entry;
+ GdmSettingsEntry *entry;
- g_debug ("Value Changed key=%s old=%s new=%s", key, old_value, new_value);
+ g_debug ("Value Changed key=%s old=%s new=%s", key, old_value, new_value);
- /* lookup entry */
- entry = get_entry_for_key (key);
+ /* lookup entry */
+ entry = get_entry_for_key (key);
- if (entry == NULL) {
- return;
- }
+ if (entry == NULL) {
+ return;
+ }
- gdm_settings_entry_set_value (entry, new_value);
+ gdm_settings_entry_set_value (entry, new_value);
- g_hash_table_foreach (notifiers, (GHFunc)send_notification, entry);
+ g_hash_table_foreach (notifiers, (GHFunc)send_notification, entry);
}
gboolean
gdm_settings_client_init (const char *file,
- const char *root)
+ const char *root)
{
GError *error;
- GSList *list;
+ GSList *list;
- g_return_val_if_fail (file != NULL, FALSE);
- g_return_val_if_fail (root != NULL, FALSE);
+ g_return_val_if_fail (file != NULL, FALSE);
+ g_return_val_if_fail (root != NULL, FALSE);
- g_assert (schemas == NULL);
+ g_assert (schemas == NULL);
error = NULL;
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
@@ -506,41 +506,41 @@ gdm_settings_client_init (const char *file,
g_warning ("error getting system bus: %s", error->message);
g_error_free (error);
}
- return FALSE;
+ return FALSE;
}
settings_proxy = dbus_g_proxy_new_for_name (connection,
- SETTINGS_DBUS_NAME,
- SETTINGS_DBUS_PATH,
- SETTINGS_DBUS_INTERFACE);
- if (settings_proxy == NULL) {
- g_warning ("Unable to connect to settings server");
- return FALSE;
- }
+ SETTINGS_DBUS_NAME,
+ SETTINGS_DBUS_PATH,
+ SETTINGS_DBUS_INTERFACE);
+ if (settings_proxy == NULL) {
+ g_warning ("Unable to connect to settings server");
+ return FALSE;
+ }
- list = NULL;
- if (! gdm_settings_parse_schemas (file, root, &list)) {
- g_warning ("Unable to parse schemas");
- return FALSE;
- }
+ list = NULL;
+ if (! gdm_settings_parse_schemas (file, root, &list)) {
+ g_warning ("Unable to parse schemas");
+ return FALSE;
+ }
- notifiers = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)gdm_settings_client_notify_free);
+ notifiers = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)gdm_settings_client_notify_free);
- schemas = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)gdm_settings_entry_free);
- g_slist_foreach (list, (GFunc)hashify_list, NULL);
+ schemas = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)gdm_settings_entry_free);
+ g_slist_foreach (list, (GFunc)hashify_list, NULL);
- schemas_file = g_strdup (file);
- schemas_root = g_strdup (root);
+ schemas_file = g_strdup (file);
+ schemas_root = g_strdup (root);
- dbus_g_proxy_add_signal (settings_proxy, "ValueChanged", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (settings_proxy,
- "ValueChanged",
- G_CALLBACK (on_value_changed),
- NULL,
- NULL);
+ dbus_g_proxy_add_signal (settings_proxy, "ValueChanged", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (settings_proxy,
+ "ValueChanged",
+ G_CALLBACK (on_value_changed),
+ NULL,
+ NULL);
- return TRUE;
+ return TRUE;
}
void
diff --git a/common/gdm-settings-client.h b/common/gdm-settings-client.h
index f8cbf16d..f2982950 100644
--- a/common/gdm-settings-client.h
+++ b/common/gdm-settings-client.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -28,34 +28,34 @@
G_BEGIN_DECLS
typedef void (*GdmSettingsClientNotifyFunc) (guint id,
- GdmSettingsEntry *entry,
- gpointer user_data);
+ GdmSettingsEntry *entry,
+ gpointer user_data);
-gboolean gdm_settings_client_init (const char *schemas_file,
- const char *root);
-void gdm_settings_client_shutdown (void);
+gboolean gdm_settings_client_init (const char *schemas_file,
+ const char *root);
+void gdm_settings_client_shutdown (void);
gboolean gdm_settings_client_get_int (const char *key,
- int *value);
+ int *value);
gboolean gdm_settings_client_get_boolean (const char *key,
- gboolean *value);
+ gboolean *value);
gboolean gdm_settings_client_get_string (const char *key,
- char **value);
+ char **value);
gboolean gdm_settings_client_get_locale_string (const char *key,
- const char *locale,
- char **value);
+ const char *locale,
+ char **value);
gboolean gdm_settings_client_set_int (const char *key,
- int value);
+ int value);
gboolean gdm_settings_client_set_boolean (const char *key,
- gboolean value);
+ gboolean value);
gboolean gdm_settings_client_set_string (const char *key,
- const char *value);
+ const char *value);
guint gdm_settings_client_notify_add (const char *namespace_section,
- GdmSettingsClientNotifyFunc func,
- gpointer user_data,
- GFreeFunc destroy_notify);
+ GdmSettingsClientNotifyFunc func,
+ gpointer user_data,
+ GFreeFunc destroy_notify);
void gdm_settings_client_notify_remove (guint id);
G_END_DECLS
diff --git a/common/gdm-settings-desktop-backend.c b/common/gdm-settings-desktop-backend.c
index adfcfe6e..b068c248 100644
--- a/common/gdm-settings-desktop-backend.c
+++ b/common/gdm-settings-desktop-backend.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -42,301 +42,301 @@
struct GdmSettingsDesktopBackendPrivate
{
- char *filename;
- GKeyFile *key_file;
- gboolean dirty;
- guint save_id;
+ char *filename;
+ GKeyFile *key_file;
+ gboolean dirty;
+ guint save_id;
};
-static void gdm_settings_desktop_backend_class_init (GdmSettingsDesktopBackendClass *klass);
-static void gdm_settings_desktop_backend_init (GdmSettingsDesktopBackend *settings_desktop_backend);
-static void gdm_settings_desktop_backend_finalize (GObject *object);
+static void gdm_settings_desktop_backend_class_init (GdmSettingsDesktopBackendClass *klass);
+static void gdm_settings_desktop_backend_init (GdmSettingsDesktopBackend *settings_desktop_backend);
+static void gdm_settings_desktop_backend_finalize (GObject *object);
G_DEFINE_TYPE (GdmSettingsDesktopBackend, gdm_settings_desktop_backend, GDM_TYPE_SETTINGS_BACKEND)
static gboolean
parse_key_string (const char *keystring,
- char **group,
- char **key,
- char **locale,
- char **value)
+ char **group,
+ char **key,
+ char **locale,
+ char **value)
{
- char **split1;
- char **split2;
- char *g;
- char *k;
- char *l;
- char *v;
- char *tmp1;
- char *tmp2;
- gboolean ret;
-
- g_return_val_if_fail (keystring != NULL, FALSE);
-
- ret = FALSE;
- g = k = v = l = NULL;
- split1 = split2 = NULL;
-
- /*g_debug ("Attempting to parse key string: %s", keystring);*/
-
- split1 = g_strsplit (keystring, "/", 2);
- if (split1 == NULL || split1 [0] == NULL || split1 [1] == NULL) {
- goto out;
- }
-
- g = split1 [0];
-
- split2 = g_strsplit (split1 [1], "=", 2);
- if (split2 == NULL) {
- k = split1 [1];
- } else {
- k = split2 [0];
- v = split2 [1];
- }
-
- /* trim off the locale */
- tmp1 = strchr (k, '[');
- tmp2 = strchr (k, ']');
- if (tmp1 != NULL && tmp2 != NULL && tmp2 > tmp1) {
- l = g_strndup (tmp1 + 1, tmp2 - tmp1 - 1);
- *tmp1 = '\0';
- }
-
- ret = TRUE;
+ char **split1;
+ char **split2;
+ char *g;
+ char *k;
+ char *l;
+ char *v;
+ char *tmp1;
+ char *tmp2;
+ gboolean ret;
+
+ g_return_val_if_fail (keystring != NULL, FALSE);
+
+ ret = FALSE;
+ g = k = v = l = NULL;
+ split1 = split2 = NULL;
+
+ /*g_debug ("Attempting to parse key string: %s", keystring);*/
+
+ split1 = g_strsplit (keystring, "/", 2);
+ if (split1 == NULL || split1 [0] == NULL || split1 [1] == NULL) {
+ goto out;
+ }
+
+ g = split1 [0];
+
+ split2 = g_strsplit (split1 [1], "=", 2);
+ if (split2 == NULL) {
+ k = split1 [1];
+ } else {
+ k = split2 [0];
+ v = split2 [1];
+ }
+
+ /* trim off the locale */
+ tmp1 = strchr (k, '[');
+ tmp2 = strchr (k, ']');
+ if (tmp1 != NULL && tmp2 != NULL && tmp2 > tmp1) {
+ l = g_strndup (tmp1 + 1, tmp2 - tmp1 - 1);
+ *tmp1 = '\0';
+ }
+
+ ret = TRUE;
out:
- if (group != NULL) {
- *group = g_strdup (g);
- }
- if (key != NULL) {
- *key = g_strdup (k);
- }
- if (locale != NULL) {
- *locale = g_strdup (l);
- }
- if (value != NULL) {
- *value = g_strdup (v);
- }
-
- g_strfreev (split1);
- g_strfreev (split2);
-
- return ret;
+ if (group != NULL) {
+ *group = g_strdup (g);
+ }
+ if (key != NULL) {
+ *key = g_strdup (k);
+ }
+ if (locale != NULL) {
+ *locale = g_strdup (l);
+ }
+ if (value != NULL) {
+ *value = g_strdup (v);
+ }
+
+ g_strfreev (split1);
+ g_strfreev (split2);
+
+ return ret;
}
static gboolean
gdm_settings_desktop_backend_get_value (GdmSettingsBackend *backend,
- const char *key,
- char **value,
- GError **error)
+ const char *key,
+ char **value,
+ GError **error)
{
- GError *local_error;
- char *val;
- char *g;
- char *k;
- char *l;
-
- g_return_val_if_fail (GDM_IS_SETTINGS_BACKEND (backend), FALSE);
- g_return_val_if_fail (key != NULL, FALSE);
-
- if (value != NULL) {
- *value = NULL;
- }
-
- /*GDM_SETTINGS_BACKEND_CLASS (gdm_settings_desktop_backend_parent_class)->get_value (display);*/
- if (! parse_key_string (key, &g, &k, &l, NULL)) {
- g_set_error (error, GDM_SETTINGS_BACKEND_ERROR, GDM_SETTINGS_BACKEND_ERROR_KEY_NOT_FOUND, "Key not found");
- return FALSE;
- }
-
- /*g_debug ("Getting key: %s %s %s", g, k, l);*/
- local_error = NULL;
- val = g_key_file_get_value (GDM_SETTINGS_DESKTOP_BACKEND (backend)->priv->key_file,
- g,
- k,
- &local_error);
- if (local_error != NULL) {
- g_error_free (local_error);
- g_set_error (error, GDM_SETTINGS_BACKEND_ERROR, GDM_SETTINGS_BACKEND_ERROR_KEY_NOT_FOUND, "Key not found");
- return FALSE;
- }
-
- if (value != NULL) {
- *value = g_strdup (val);
- }
-
- g_free (val);
-
- return TRUE;
+ GError *local_error;
+ char *val;
+ char *g;
+ char *k;
+ char *l;
+
+ g_return_val_if_fail (GDM_IS_SETTINGS_BACKEND (backend), FALSE);
+ g_return_val_if_fail (key != NULL, FALSE);
+
+ if (value != NULL) {
+ *value = NULL;
+ }
+
+ /*GDM_SETTINGS_BACKEND_CLASS (gdm_settings_desktop_backend_parent_class)->get_value (display);*/
+ if (! parse_key_string (key, &g, &k, &l, NULL)) {
+ g_set_error (error, GDM_SETTINGS_BACKEND_ERROR, GDM_SETTINGS_BACKEND_ERROR_KEY_NOT_FOUND, "Key not found");
+ return FALSE;
+ }
+
+ /*g_debug ("Getting key: %s %s %s", g, k, l);*/
+ local_error = NULL;
+ val = g_key_file_get_value (GDM_SETTINGS_DESKTOP_BACKEND (backend)->priv->key_file,
+ g,
+ k,
+ &local_error);
+ if (local_error != NULL) {
+ g_error_free (local_error);
+ g_set_error (error, GDM_SETTINGS_BACKEND_ERROR, GDM_SETTINGS_BACKEND_ERROR_KEY_NOT_FOUND, "Key not found");
+ return FALSE;
+ }
+
+ if (value != NULL) {
+ *value = g_strdup (val);
+ }
+
+ g_free (val);
+
+ return TRUE;
}
static void
save_settings (GdmSettingsDesktopBackend *backend)
{
- GError *local_error;
- gboolean res;
- char *contents;
- gsize length;
-
- if (! backend->priv->dirty) {
- return;
- }
-
- g_debug ("Saving settings to %s", backend->priv->filename);
-
- local_error = NULL;
- contents = g_key_file_to_data (backend->priv->key_file, &length, &local_error);
- if (local_error != NULL) {
- g_warning ("Unable to save settings: %s", local_error->message);
- g_error_free (local_error);
- return;
- }
-
- local_error = NULL;
- res = g_file_set_contents (backend->priv->filename,
- contents,
- length,
- &local_error);
- if (local_error != NULL) {
- g_warning ("Unable to save settings: %s", local_error->message);
- g_error_free (local_error);
- g_free (contents);
- return;
- }
-
- g_free (contents);
-
- backend->priv->dirty = FALSE;
+ GError *local_error;
+ gboolean res;
+ char *contents;
+ gsize length;
+
+ if (! backend->priv->dirty) {
+ return;
+ }
+
+ g_debug ("Saving settings to %s", backend->priv->filename);
+
+ local_error = NULL;
+ contents = g_key_file_to_data (backend->priv->key_file, &length, &local_error);
+ if (local_error != NULL) {
+ g_warning ("Unable to save settings: %s", local_error->message);
+ g_error_free (local_error);
+ return;
+ }
+
+ local_error = NULL;
+ res = g_file_set_contents (backend->priv->filename,
+ contents,
+ length,
+ &local_error);
+ if (local_error != NULL) {
+ g_warning ("Unable to save settings: %s", local_error->message);
+ g_error_free (local_error);
+ g_free (contents);
+ return;
+ }
+
+ g_free (contents);
+
+ backend->priv->dirty = FALSE;
}
static gboolean
save_settings_timer (GdmSettingsDesktopBackend *backend)
{
- save_settings (backend);
- backend->priv->save_id = 0;
- return FALSE;
+ save_settings (backend);
+ backend->priv->save_id = 0;
+ return FALSE;
}
static void
queue_save (GdmSettingsDesktopBackend *backend)
{
- if (! backend->priv->dirty) {
- return;
- }
+ if (! backend->priv->dirty) {
+ return;
+ }
- if (backend->priv->save_id != 0) {
- /* already pending */
- return;
- }
+ if (backend->priv->save_id != 0) {
+ /* already pending */
+ return;
+ }
- backend->priv->save_id = g_timeout_add_seconds (5, (GSourceFunc)save_settings_timer, backend);
+ backend->priv->save_id = g_timeout_add_seconds (5, (GSourceFunc)save_settings_timer, backend);
}
static gboolean
gdm_settings_desktop_backend_set_value (GdmSettingsBackend *backend,
- const char *key,
- const char *value,
- GError **error)
+ const char *key,
+ const char *value,
+ GError **error)
{
- GError *local_error;
- char *old_val;
- char *g;
- char *k;
- char *l;
-
- g_return_val_if_fail (GDM_IS_SETTINGS_BACKEND (backend), FALSE);
- g_return_val_if_fail (key != NULL, FALSE);
-
- /*GDM_SETTINGS_BACKEND_CLASS (gdm_settings_desktop_backend_parent_class)->get_value (display);*/
- if (! parse_key_string (key, &g, &k, &l, NULL)) {
- g_set_error (error, GDM_SETTINGS_BACKEND_ERROR, GDM_SETTINGS_BACKEND_ERROR_KEY_NOT_FOUND, "Key not found");
- return FALSE;
- }
-
- local_error = NULL;
- old_val = g_key_file_get_value (GDM_SETTINGS_DESKTOP_BACKEND (backend)->priv->key_file,
- g,
- k,
- &local_error);
- if (local_error != NULL) {
- g_error_free (local_error);
- }
-
- /*g_debug ("Setting key: %s %s %s", g, k, l);*/
- local_error = NULL;
- g_key_file_set_value (GDM_SETTINGS_DESKTOP_BACKEND (backend)->priv->key_file,
- g,
- k,
- value);
-
- GDM_SETTINGS_DESKTOP_BACKEND (backend)->priv->dirty = TRUE;
- queue_save (GDM_SETTINGS_DESKTOP_BACKEND (backend));
-
- gdm_settings_backend_value_changed (backend, key, old_val, value);
-
- g_free (old_val);
-
- return TRUE;
+ GError *local_error;
+ char *old_val;
+ char *g;
+ char *k;
+ char *l;
+
+ g_return_val_if_fail (GDM_IS_SETTINGS_BACKEND (backend), FALSE);
+ g_return_val_if_fail (key != NULL, FALSE);
+
+ /*GDM_SETTINGS_BACKEND_CLASS (gdm_settings_desktop_backend_parent_class)->get_value (display);*/
+ if (! parse_key_string (key, &g, &k, &l, NULL)) {
+ g_set_error (error, GDM_SETTINGS_BACKEND_ERROR, GDM_SETTINGS_BACKEND_ERROR_KEY_NOT_FOUND, "Key not found");
+ return FALSE;
+ }
+
+ local_error = NULL;
+ old_val = g_key_file_get_value (GDM_SETTINGS_DESKTOP_BACKEND (backend)->priv->key_file,
+ g,
+ k,
+ &local_error);
+ if (local_error != NULL) {
+ g_error_free (local_error);
+ }
+
+ /*g_debug ("Setting key: %s %s %s", g, k, l);*/
+ local_error = NULL;
+ g_key_file_set_value (GDM_SETTINGS_DESKTOP_BACKEND (backend)->priv->key_file,
+ g,
+ k,
+ value);
+
+ GDM_SETTINGS_DESKTOP_BACKEND (backend)->priv->dirty = TRUE;
+ queue_save (GDM_SETTINGS_DESKTOP_BACKEND (backend));
+
+ gdm_settings_backend_value_changed (backend, key, old_val, value);
+
+ g_free (old_val);
+
+ return TRUE;
}
static void
gdm_settings_desktop_backend_class_init (GdmSettingsDesktopBackendClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GdmSettingsBackendClass *backend_class = GDM_SETTINGS_BACKEND_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GdmSettingsBackendClass *backend_class = GDM_SETTINGS_BACKEND_CLASS (klass);
- object_class->finalize = gdm_settings_desktop_backend_finalize;
+ object_class->finalize = gdm_settings_desktop_backend_finalize;
- backend_class->get_value = gdm_settings_desktop_backend_get_value;
- backend_class->set_value = gdm_settings_desktop_backend_set_value;
+ backend_class->get_value = gdm_settings_desktop_backend_get_value;
+ backend_class->set_value = gdm_settings_desktop_backend_set_value;
- g_type_class_add_private (klass, sizeof (GdmSettingsDesktopBackendPrivate));
+ g_type_class_add_private (klass, sizeof (GdmSettingsDesktopBackendPrivate));
}
static void
gdm_settings_desktop_backend_init (GdmSettingsDesktopBackend *backend)
{
- gboolean res;
- GError *error;
-
- backend->priv = GDM_SETTINGS_DESKTOP_BACKEND_GET_PRIVATE (backend);
-
- backend->priv->key_file = g_key_file_new ();
- backend->priv->filename = g_strdup (GDMCONFDIR "/custom.conf");
-
- error = NULL;
- res = g_key_file_load_from_file (backend->priv->key_file,
- backend->priv->filename,
- G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS,
- &error);
- if (! res) {
- g_warning ("Unable to load file '%s': %s", backend->priv->filename, error->message);
- }
+ gboolean res;
+ GError *error;
+
+ backend->priv = GDM_SETTINGS_DESKTOP_BACKEND_GET_PRIVATE (backend);
+
+ backend->priv->key_file = g_key_file_new ();
+ backend->priv->filename = g_strdup (GDMCONFDIR "/custom.conf");
+
+ error = NULL;
+ res = g_key_file_load_from_file (backend->priv->key_file,
+ backend->priv->filename,
+ G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS,
+ &error);
+ if (! res) {
+ g_warning ("Unable to load file '%s': %s", backend->priv->filename, error->message);
+ }
}
static void
gdm_settings_desktop_backend_finalize (GObject *object)
{
- GdmSettingsDesktopBackend *backend;
+ GdmSettingsDesktopBackend *backend;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_SETTINGS_DESKTOP_BACKEND (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_SETTINGS_DESKTOP_BACKEND (object));
- backend = GDM_SETTINGS_DESKTOP_BACKEND (object);
+ backend = GDM_SETTINGS_DESKTOP_BACKEND (object);
- g_return_if_fail (backend->priv != NULL);
+ g_return_if_fail (backend->priv != NULL);
- save_settings (backend);
- g_key_file_free (backend->priv->key_file);
+ save_settings (backend);
+ g_key_file_free (backend->priv->key_file);
- G_OBJECT_CLASS (gdm_settings_desktop_backend_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_settings_desktop_backend_parent_class)->finalize (object);
}
GdmSettingsBackend *
gdm_settings_desktop_backend_new (void)
{
- GObject *object;
+ GObject *object;
- object = g_object_new (GDM_TYPE_SETTINGS_DESKTOP_BACKEND, NULL);
+ object = g_object_new (GDM_TYPE_SETTINGS_DESKTOP_BACKEND, NULL);
- return GDM_SETTINGS_BACKEND (object);
+ return GDM_SETTINGS_BACKEND (object);
}
diff --git a/common/gdm-settings-desktop-backend.h b/common/gdm-settings-desktop-backend.h
index fae0bd30..4d003b1b 100644
--- a/common/gdm-settings-desktop-backend.h
+++ b/common/gdm-settings-desktop-backend.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -38,16 +38,16 @@ typedef struct GdmSettingsDesktopBackendPrivate GdmSettingsDesktopBackendPrivate
typedef struct
{
- GdmSettingsBackend parent;
- GdmSettingsDesktopBackendPrivate *priv;
+ GdmSettingsBackend parent;
+ GdmSettingsDesktopBackendPrivate *priv;
} GdmSettingsDesktopBackend;
typedef struct
{
- GdmSettingsBackendClass parent_class;
+ GdmSettingsBackendClass parent_class;
} GdmSettingsDesktopBackendClass;
-GType gdm_settings_desktop_backend_get_type (void);
+GType gdm_settings_desktop_backend_get_type (void);
GdmSettingsBackend *gdm_settings_desktop_backend_new (void);
diff --git a/common/gdm-settings-direct.c b/common/gdm-settings-direct.c
index 0b9385ab..176049e4 100644
--- a/common/gdm-settings-direct.c
+++ b/common/gdm-settings-direct.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -46,192 +46,192 @@ static GdmSettings *settings_object;
static GdmSettingsEntry *
get_entry_for_key (const char *key)
{
- GdmSettingsEntry *entry;
+ GdmSettingsEntry *entry;
- entry = g_hash_table_lookup (schemas, key);
+ entry = g_hash_table_lookup (schemas, key);
- return entry;
+ return entry;
}
static void
assert_signature (GdmSettingsEntry *entry,
- const char *signature)
+ const char *signature)
{
- const char *sig;
+ const char *sig;
- sig = gdm_settings_entry_get_signature (entry);
+ sig = gdm_settings_entry_get_signature (entry);
- g_assert (sig != NULL);
- g_assert (signature != NULL);
- g_assert (strcmp (signature, sig) == 0);
+ g_assert (sig != NULL);
+ g_assert (signature != NULL);
+ g_assert (strcmp (signature, sig) == 0);
}
static gboolean
get_value (const char *key,
- char **value)
+ char **value)
{
- GError *error;
- char *str;
- gboolean res;
+ GError *error;
+ char *str;
+ gboolean res;
- error = NULL;
- res = gdm_settings_get_value (settings_object, key, &str, &error);
- if (! res) {
- if (error != NULL) {
- g_error_free (error);
- } else {
- }
+ error = NULL;
+ res = gdm_settings_get_value (settings_object, key, &str, &error);
+ if (! res) {
+ if (error != NULL) {
+ g_error_free (error);
+ } else {
+ }
- return FALSE;
- }
+ return FALSE;
+ }
- if (value != NULL) {
- *value = g_strdup (str);
- }
+ if (value != NULL) {
+ *value = g_strdup (str);
+ }
- g_free (str);
+ g_free (str);
- return TRUE;
+ return TRUE;
}
gboolean
gdm_settings_direct_get_int (const char *key,
- int *value)
+ int *value)
{
- GdmSettingsEntry *entry;
- gboolean ret;
- gboolean res;
- char *str;
+ GdmSettingsEntry *entry;
+ gboolean ret;
+ gboolean res;
+ char *str;
- g_return_val_if_fail (key != NULL, FALSE);
+ g_return_val_if_fail (key != NULL, FALSE);
- entry = get_entry_for_key (key);
- g_assert (entry != NULL);
+ entry = get_entry_for_key (key);
+ g_assert (entry != NULL);
- assert_signature (entry, "i");
+ assert_signature (entry, "i");
- ret = FALSE;
+ ret = FALSE;
- res = get_value (key, &str);
+ res = get_value (key, &str);
- if (! res) {
- /* use the default */
- str = g_strdup (gdm_settings_entry_get_default_value (entry));
- }
+ if (! res) {
+ /* use the default */
+ str = g_strdup (gdm_settings_entry_get_default_value (entry));
+ }
- ret = gdm_settings_parse_value_as_integer (str, value);
+ ret = gdm_settings_parse_value_as_integer (str, value);
- g_free (str);
+ g_free (str);
- return ret;
+ return ret;
}
gboolean
gdm_settings_direct_get_boolean (const char *key,
- gboolean *value)
+ gboolean *value)
{
- GdmSettingsEntry *entry;
- gboolean ret;
- gboolean res;
- char *str;
+ GdmSettingsEntry *entry;
+ gboolean ret;
+ gboolean res;
+ char *str;
- g_return_val_if_fail (key != NULL, FALSE);
+ g_return_val_if_fail (key != NULL, FALSE);
- entry = get_entry_for_key (key);
- g_assert (entry != NULL);
+ entry = get_entry_for_key (key);
+ g_assert (entry != NULL);
- assert_signature (entry, "b");
+ assert_signature (entry, "b");
- ret = FALSE;
+ ret = FALSE;
- res = get_value (key, &str);
+ res = get_value (key, &str);
- if (! res) {
- /* use the default */
- str = g_strdup (gdm_settings_entry_get_default_value (entry));
- }
+ if (! res) {
+ /* use the default */
+ str = g_strdup (gdm_settings_entry_get_default_value (entry));
+ }
- ret = gdm_settings_parse_value_as_boolean (str, value);
+ ret = gdm_settings_parse_value_as_boolean (str, value);
- g_free (str);
+ g_free (str);
- return ret;
+ return ret;
}
gboolean
gdm_settings_direct_get_string (const char *key,
- char **value)
+ char **value)
{
- GdmSettingsEntry *entry;
- gboolean ret;
- gboolean res;
- char *str;
+ GdmSettingsEntry *entry;
+ gboolean ret;
+ gboolean res;
+ char *str;
- g_return_val_if_fail (key != NULL, FALSE);
+ g_return_val_if_fail (key != NULL, FALSE);
- entry = get_entry_for_key (key);
- g_assert (entry != NULL);
+ entry = get_entry_for_key (key);
+ g_assert (entry != NULL);
- assert_signature (entry, "s");
+ assert_signature (entry, "s");
- ret = FALSE;
+ ret = FALSE;
- res = get_value (key, &str);
+ res = get_value (key, &str);
- if (! res) {
- /* use the default */
- str = g_strdup (gdm_settings_entry_get_default_value (entry));
- }
+ if (! res) {
+ /* use the default */
+ str = g_strdup (gdm_settings_entry_get_default_value (entry));
+ }
- if (value != NULL) {
- *value = g_strdup (str);
- }
+ if (value != NULL) {
+ *value = g_strdup (str);
+ }
- g_free (str);
+ g_free (str);
- return ret;
+ return ret;
}
gboolean
gdm_settings_direct_set (const char *key,
- GValue *value)
+ GValue *value)
{
- return TRUE;
+ return TRUE;
}
static void
hashify_list (GdmSettingsEntry *entry,
- gpointer data)
+ gpointer data)
{
- g_hash_table_insert (schemas, g_strdup (gdm_settings_entry_get_key (entry)), entry);
+ g_hash_table_insert (schemas, g_strdup (gdm_settings_entry_get_key (entry)), entry);
}
gboolean
gdm_settings_direct_init (GdmSettings *settings,
- const char *file,
- const char *root)
+ const char *file,
+ const char *root)
{
- GSList *list;
+ GSList *list;
- g_return_val_if_fail (file != NULL, FALSE);
- g_return_val_if_fail (root != NULL, FALSE);
+ g_return_val_if_fail (file != NULL, FALSE);
+ g_return_val_if_fail (root != NULL, FALSE);
- g_assert (schemas == NULL);
+ g_assert (schemas == NULL);
- if (! gdm_settings_parse_schemas (file, root, &list)) {
- g_warning ("Unable to parse schemas");
- return FALSE;
- }
+ if (! gdm_settings_parse_schemas (file, root, &list)) {
+ g_warning ("Unable to parse schemas");
+ return FALSE;
+ }
- schemas = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)gdm_settings_entry_free);
- g_slist_foreach (list, (GFunc)hashify_list, NULL);
+ schemas = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)gdm_settings_entry_free);
+ g_slist_foreach (list, (GFunc)hashify_list, NULL);
- schemas_file = g_strdup (file);
- schemas_root = g_strdup (root);
+ schemas_file = g_strdup (file);
+ schemas_root = g_strdup (root);
- settings_object = settings;
+ settings_object = settings;
- return TRUE;
+ return TRUE;
}
void
diff --git a/common/gdm-settings-direct.h b/common/gdm-settings-direct.h
index 38e9bb76..feb97d53 100644
--- a/common/gdm-settings-direct.h
+++ b/common/gdm-settings-direct.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -27,21 +27,21 @@
G_BEGIN_DECLS
-gboolean gdm_settings_direct_init (GdmSettings *settings,
- const char *schemas_file,
- const char *root);
-void gdm_settings_direct_shutdown (void);
+gboolean gdm_settings_direct_init (GdmSettings *settings,
+ const char *schemas_file,
+ const char *root);
+void gdm_settings_direct_shutdown (void);
gboolean gdm_settings_direct_get (const char *key,
- GValue *value);
+ GValue *value);
gboolean gdm_settings_direct_set (const char *key,
- GValue *value);
+ GValue *value);
gboolean gdm_settings_direct_get_int (const char *key,
- int *value);
+ int *value);
gboolean gdm_settings_direct_get_boolean (const char *key,
- gboolean *value);
+ gboolean *value);
gboolean gdm_settings_direct_get_string (const char *key,
- char **value);
+ char **value);
G_END_DECLS
diff --git a/common/gdm-settings-keys.h b/common/gdm-settings-keys.h
index 576c6b3d..ffd5b642 100644
--- a/common/gdm-settings-keys.h
+++ b/common/gdm-settings-keys.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -9,7 +9,7 @@
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
diff --git a/common/gdm-settings-utils.c b/common/gdm-settings-utils.c
index f1ea463d..af677f9b 100644
--- a/common/gdm-settings-utils.c
+++ b/common/gdm-settings-utils.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -39,289 +39,289 @@
struct _GdmSettingsEntry
{
- char *key;
- char *signature;
- char *default_value;
- char *value;
+ char *key;
+ char *signature;
+ char *default_value;
+ char *value;
};
GdmSettingsEntry *
gdm_settings_entry_new (void)
{
- GdmSettingsEntry *entry = NULL;
+ GdmSettingsEntry *entry = NULL;
- entry = g_new0 (GdmSettingsEntry, 1);
- entry->key = NULL;
- entry->signature = NULL;
- entry->value = NULL;
- entry->default_value = NULL;
+ entry = g_new0 (GdmSettingsEntry, 1);
+ entry->key = NULL;
+ entry->signature = NULL;
+ entry->value = NULL;
+ entry->default_value = NULL;
- return entry;
+ return entry;
}
const char *
gdm_settings_entry_get_key (GdmSettingsEntry *entry)
{
- return entry->key;
+ return entry->key;
}
const char *
gdm_settings_entry_get_signature (GdmSettingsEntry *entry)
{
- return entry->signature;
+ return entry->signature;
}
const char *
gdm_settings_entry_get_default_value (GdmSettingsEntry *entry)
{
- return entry->default_value;
+ return entry->default_value;
}
const char *
gdm_settings_entry_get_value (GdmSettingsEntry *entry)
{
- return entry->value;
+ return entry->value;
}
void
gdm_settings_entry_set_value (GdmSettingsEntry *entry,
- const char *value)
+ const char *value)
{
- g_free (entry->value);
- entry->value = g_strdup (value);
+ g_free (entry->value);
+ entry->value = g_strdup (value);
}
void
gdm_settings_entry_free (GdmSettingsEntry *entry)
{
- g_free (entry->key);
- g_free (entry->signature);
- g_free (entry->default_value);
- g_free (entry->value);
- g_free (entry);
+ g_free (entry->key);
+ g_free (entry->signature);
+ g_free (entry->default_value);
+ g_free (entry->value);
+ g_free (entry);
}
typedef struct {
- GSList *list;
- GdmSettingsEntry *entry;
- gboolean in_key;
- gboolean in_signature;
- gboolean in_default;
+ GSList *list;
+ GdmSettingsEntry *entry;
+ gboolean in_key;
+ gboolean in_signature;
+ gboolean in_default;
} ParserInfo;
static void
start_element_cb (GMarkupParseContext *ctx,
- const char *element_name,
- const char **attribute_names,
- const char **attribute_values,
- gpointer user_data,
- GError **error)
+ const char *element_name,
+ const char **attribute_names,
+ const char **attribute_values,
+ gpointer user_data,
+ GError **error)
{
- ParserInfo *info;
+ ParserInfo *info;
- info = (ParserInfo *) user_data;
+ info = (ParserInfo *) user_data;
- /*g_debug ("parsing start: '%s'", element_name);*/
+ /*g_debug ("parsing start: '%s'", element_name);*/
- if (strcmp (element_name, "schema") == 0) {
- info->entry = gdm_settings_entry_new ();
- } else if (strcmp (element_name, "key") == 0) {
- info->in_key = TRUE;
- } else if (strcmp (element_name, "signature") == 0) {
- info->in_signature = TRUE;
- } else if (strcmp (element_name, "default") == 0) {
- info->in_default = TRUE;
- }
+ if (strcmp (element_name, "schema") == 0) {
+ info->entry = gdm_settings_entry_new ();
+ } else if (strcmp (element_name, "key") == 0) {
+ info->in_key = TRUE;
+ } else if (strcmp (element_name, "signature") == 0) {
+ info->in_signature = TRUE;
+ } else if (strcmp (element_name, "default") == 0) {
+ info->in_default = TRUE;
+ }
}
static void
add_schema_entry (ParserInfo *info)
{
- /*g_debug ("Inserting entry %s", info->entry->key);*/
+ /*g_debug ("Inserting entry %s", info->entry->key);*/
- info->list = g_slist_prepend (info->list, info->entry);
+ info->list = g_slist_prepend (info->list, info->entry);
}
static void
end_element_cb (GMarkupParseContext *ctx,
- const char *element_name,
- gpointer user_data,
- GError **error)
+ const char *element_name,
+ gpointer user_data,
+ GError **error)
{
- ParserInfo *info;
+ ParserInfo *info;
- info = (ParserInfo *) user_data;
+ info = (ParserInfo *) user_data;
- /*g_debug ("parsing end: '%s'", element_name);*/
+ /*g_debug ("parsing end: '%s'", element_name);*/
- if (strcmp (element_name, "schema") == 0) {
- add_schema_entry (info);
- } else if (strcmp (element_name, "key") == 0) {
- info->in_key = FALSE;
- } else if (strcmp (element_name, "signature") == 0) {
- info->in_signature = FALSE;
- } else if (strcmp (element_name, "default") == 0) {
- info->in_default = FALSE;
- }
+ if (strcmp (element_name, "schema") == 0) {
+ add_schema_entry (info);
+ } else if (strcmp (element_name, "key") == 0) {
+ info->in_key = FALSE;
+ } else if (strcmp (element_name, "signature") == 0) {
+ info->in_signature = FALSE;
+ } else if (strcmp (element_name, "default") == 0) {
+ info->in_default = FALSE;
+ }
}
static void
text_cb (GMarkupParseContext *ctx,
- const char *text,
- gsize text_len,
- gpointer user_data,
- GError **error)
+ const char *text,
+ gsize text_len,
+ gpointer user_data,
+ GError **error)
{
- ParserInfo *info;
- char *t;
+ ParserInfo *info;
+ char *t;
- info = (ParserInfo *) user_data;
+ info = (ParserInfo *) user_data;
- t = g_strndup (text, text_len);
+ t = g_strndup (text, text_len);
- if (info->in_key) {
- info->entry->key = g_strdup (t);
- } else if (info->in_signature) {
- info->entry->signature = g_strdup (t);
- } else if (info->in_default) {
- info->entry->default_value = g_strdup (t);
- }
+ if (info->in_key) {
+ info->entry->key = g_strdup (t);
+ } else if (info->in_signature) {
+ info->entry->signature = g_strdup (t);
+ } else if (info->in_default) {
+ info->entry->default_value = g_strdup (t);
+ }
- g_free (t);
+ g_free (t);
}
static void
error_cb (GMarkupParseContext *ctx,
- GError *error,
- gpointer user_data)
+ GError *error,
+ gpointer user_data)
{
}
static GMarkupParser parser = {
- start_element_cb,
- end_element_cb,
- text_cb,
- NULL,
- error_cb
+ start_element_cb,
+ end_element_cb,
+ text_cb,
+ NULL,
+ error_cb
};
gboolean
gdm_settings_parse_schemas (const char *file,
- const char *root,
- GSList **schemas)
+ const char *root,
+ GSList **schemas)
{
- GMarkupParseContext *ctx;
- ParserInfo *info;
- char *contents;
- gsize len;
- GError *error;
+ GMarkupParseContext *ctx;
+ ParserInfo *info;
+ char *contents;
+ gsize len;
+ GError *error;
- g_return_val_if_fail (file != NULL, FALSE);
- g_return_val_if_fail (root != NULL, FALSE);
+ g_return_val_if_fail (file != NULL, FALSE);
+ g_return_val_if_fail (root != NULL, FALSE);
- g_assert (schemas != NULL);
+ g_assert (schemas != NULL);
- error = NULL;
- if (! g_file_get_contents (file, &contents, &len, &error)) {
- g_warning ("Unable to read schemas file: %s", error->message);
- g_error_free (error);
- return FALSE;
- }
+ error = NULL;
+ if (! g_file_get_contents (file, &contents, &len, &error)) {
+ g_warning ("Unable to read schemas file: %s", error->message);
+ g_error_free (error);
+ return FALSE;
+ }
- info = g_new0 (ParserInfo, 1);
- ctx = g_markup_parse_context_new (&parser, 0, info, NULL);
- g_markup_parse_context_parse (ctx, contents, len, NULL);
+ info = g_new0 (ParserInfo, 1);
+ ctx = g_markup_parse_context_new (&parser, 0, info, NULL);
+ g_markup_parse_context_parse (ctx, contents, len, NULL);
- *schemas = info->list;
+ *schemas = info->list;
- g_free (info);
+ g_free (info);
- return TRUE;
+ return TRUE;
}
char *
gdm_settings_parse_double_as_value (gdouble doubleval)
{
- char result[G_ASCII_DTOSTR_BUF_SIZE];
+ char result[G_ASCII_DTOSTR_BUF_SIZE];
- g_ascii_dtostr (result, sizeof (result), doubleval);
+ g_ascii_dtostr (result, sizeof (result), doubleval);
- return g_strdup (result);
+ return g_strdup (result);
}
char *
gdm_settings_parse_integer_as_value (int intval)
{
- return g_strdup_printf ("%d", intval);
+ return g_strdup_printf ("%d", intval);
}
char *
gdm_settings_parse_boolean_as_value (gboolean boolval)
{
- if (boolval) {
- return g_strdup ("true");
- } else {
- return g_strdup ("false");
- }
+ if (boolval) {
+ return g_strdup ("true");
+ } else {
+ return g_strdup ("false");
+ }
}
/* adapted from GKeyFile */
gboolean
gdm_settings_parse_value_as_boolean (const char *value,
- gboolean *bool)
+ gboolean *bool)
{
- if (strcmp (value, "true") == 0 || strcmp (value, "1") == 0) {
- *bool = TRUE;
- return TRUE;
- } else if (strcmp (value, "false") == 0 || strcmp (value, "0") == 0) {
- *bool = FALSE;
- return TRUE;
- } else {
- return FALSE;
- }
+ if (strcmp (value, "true") == 0 || strcmp (value, "1") == 0) {
+ *bool = TRUE;
+ return TRUE;
+ } else if (strcmp (value, "false") == 0 || strcmp (value, "0") == 0) {
+ *bool = FALSE;
+ return TRUE;
+ } else {
+ return FALSE;
+ }
}
gboolean
gdm_settings_parse_value_as_integer (const char *value,
- int *intval)
+ int *intval)
{
- char *end_of_valid_int;
- glong long_value;
- gint int_value;
+ char *end_of_valid_int;
+ glong long_value;
+ gint int_value;
- errno = 0;
- long_value = strtol (value, &end_of_valid_int, 10);
+ errno = 0;
+ long_value = strtol (value, &end_of_valid_int, 10);
- if (*value == '\0' || *end_of_valid_int != '\0') {
- return FALSE;
- }
+ if (*value == '\0' || *end_of_valid_int != '\0') {
+ return FALSE;
+ }
- int_value = long_value;
- if (int_value != long_value || errno == ERANGE) {
- return FALSE;
- }
+ int_value = long_value;
+ if (int_value != long_value || errno == ERANGE) {
+ return FALSE;
+ }
- *intval = int_value;
+ *intval = int_value;
- return TRUE;
+ return TRUE;
}
gboolean
gdm_settings_parse_value_as_double (const char *value,
- gdouble *doubleval)
+ gdouble *doubleval)
{
- char *end_of_valid_d;
- gdouble double_value = 0;
+ char *end_of_valid_d;
+ gdouble double_value = 0;
- double_value = g_ascii_strtod (value, &end_of_valid_d);
+ double_value = g_ascii_strtod (value, &end_of_valid_d);
- if (*end_of_valid_d != '\0' || end_of_valid_d == value) {
- return FALSE;
- }
+ if (*end_of_valid_d != '\0' || end_of_valid_d == value) {
+ return FALSE;
+ }
- *doubleval = double_value;
- return TRUE;
+ *doubleval = double_value;
+ return TRUE;
}
diff --git a/common/gdm-settings-utils.h b/common/gdm-settings-utils.h
index fe8f4fc4..b406969b 100644
--- a/common/gdm-settings-utils.h
+++ b/common/gdm-settings-utils.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -38,18 +38,18 @@ const char * gdm_settings_entry_get_default_value (GdmSettingsEntry
const char * gdm_settings_entry_get_value (GdmSettingsEntry *entry);
void gdm_settings_entry_set_value (GdmSettingsEntry *entry,
- const char *value);
+ const char *value);
-gboolean gdm_settings_parse_schemas (const char *file,
- const char *root,
- GSList **list);
+gboolean gdm_settings_parse_schemas (const char *file,
+ const char *root,
+ GSList **list);
gboolean gdm_settings_parse_value_as_boolean (const char *value,
- gboolean *bool);
+ gboolean *bool);
gboolean gdm_settings_parse_value_as_integer (const char *value,
- int *intval);
+ int *intval);
gboolean gdm_settings_parse_value_as_double (const char *value,
- gdouble *doubleval);
+ gdouble *doubleval);
char * gdm_settings_parse_boolean_as_value (gboolean boolval);
char * gdm_settings_parse_integer_as_value (int intval);
diff --git a/common/gdm-settings.c b/common/gdm-settings.c
index 7e7d80b3..13a8f6ed 100644
--- a/common/gdm-settings.c
+++ b/common/gdm-settings.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -53,19 +53,19 @@
struct GdmSettingsPrivate
{
DBusGConnection *connection;
- GdmSettingsBackend *backend;
+ GdmSettingsBackend *backend;
};
enum {
- VALUE_CHANGED,
- LAST_SIGNAL
+ VALUE_CHANGED,
+ LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0, };
-static void gdm_settings_class_init (GdmSettingsClass *klass);
-static void gdm_settings_init (GdmSettings *settings);
-static void gdm_settings_finalize (GObject *object);
+static void gdm_settings_class_init (GdmSettingsClass *klass);
+static void gdm_settings_init (GdmSettings *settings);
+static void gdm_settings_finalize (GObject *object);
static gpointer settings_object = NULL;
@@ -74,62 +74,62 @@ G_DEFINE_TYPE (GdmSettings, gdm_settings, G_TYPE_OBJECT)
GQuark
gdm_settings_error_quark (void)
{
- static GQuark ret = 0;
- if (ret == 0) {
- ret = g_quark_from_static_string ("gdm_settings_error");
- }
+ static GQuark ret = 0;
+ if (ret == 0) {
+ ret = g_quark_from_static_string ("gdm_settings_error");
+ }
- return ret;
+ return ret;
}
gboolean
gdm_settings_get_value (GdmSettings *settings,
- const char *key,
- char **value,
- GError **error)
+ const char *key,
+ char **value,
+ GError **error)
{
- GError *local_error;
- gboolean res;
-
- g_return_val_if_fail (GDM_IS_SETTINGS (settings), FALSE);
- g_return_val_if_fail (key != NULL, FALSE);
-
- local_error = NULL;
- res = gdm_settings_backend_get_value (settings->priv->backend,
- key,
- value,
- &local_error);
- if (! res) {
- g_propagate_error (error, local_error);
- }
-
- return res;
+ GError *local_error;
+ gboolean res;
+
+ g_return_val_if_fail (GDM_IS_SETTINGS (settings), FALSE);
+ g_return_val_if_fail (key != NULL, FALSE);
+
+ local_error = NULL;
+ res = gdm_settings_backend_get_value (settings->priv->backend,
+ key,
+ value,
+ &local_error);
+ if (! res) {
+ g_propagate_error (error, local_error);
+ }
+
+ return res;
}
gboolean
gdm_settings_set_value (GdmSettings *settings,
- const char *key,
- const char *value,
- GError **error)
+ const char *key,
+ const char *value,
+ GError **error)
{
- GError *local_error;
- gboolean res;
+ GError *local_error;
+ gboolean res;
- g_return_val_if_fail (GDM_IS_SETTINGS (settings), FALSE);
- g_return_val_if_fail (key != NULL, FALSE);
+ g_return_val_if_fail (GDM_IS_SETTINGS (settings), FALSE);
+ g_return_val_if_fail (key != NULL, FALSE);
- g_debug ("Setting value %s", key);
+ g_debug ("Setting value %s", key);
- local_error = NULL;
- res = gdm_settings_backend_set_value (settings->priv->backend,
- key,
- value,
- &local_error);
- if (! res) {
- g_propagate_error (error, local_error);
- }
+ local_error = NULL;
+ res = gdm_settings_backend_set_value (settings->priv->backend,
+ key,
+ value,
+ &local_error);
+ if (! res) {
+ g_propagate_error (error, local_error);
+ }
- return FALSE;
+ return FALSE;
}
static gboolean
@@ -159,95 +159,95 @@ dbus-send --system --print-reply --dest=org.gnome.DisplayManager /org/gnome/Disp
static void
gdm_settings_class_init (GdmSettingsClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = gdm_settings_finalize;
-
- signals [VALUE_CHANGED] =
- g_signal_new ("value-changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdmSettingsClass, value_changed),
- NULL,
- NULL,
- gdm_marshal_VOID__STRING_STRING_STRING,
- G_TYPE_NONE,
- 3,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING);
-
- g_type_class_add_private (klass, sizeof (GdmSettingsPrivate));
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gdm_settings_finalize;
+
+ signals [VALUE_CHANGED] =
+ g_signal_new ("value-changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdmSettingsClass, value_changed),
+ NULL,
+ NULL,
+ gdm_marshal_VOID__STRING_STRING_STRING,
+ G_TYPE_NONE,
+ 3,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
+
+ g_type_class_add_private (klass, sizeof (GdmSettingsPrivate));
dbus_g_object_type_install_info (GDM_TYPE_SETTINGS, &dbus_glib_gdm_settings_object_info);
}
static void
backend_value_changed (GdmSettingsBackend *backend,
- const char *key,
- const char *old_value,
- const char *new_value,
- GdmSettings *settings)
+ const char *key,
+ const char *old_value,
+ const char *new_value,
+ GdmSettings *settings)
{
- g_debug ("Emitting value-changed %s %s %s", key, old_value, new_value);
- /* just proxy it */
- g_signal_emit (settings,
- signals [VALUE_CHANGED],
- 0,
- key,
- old_value,
- new_value);
+ g_debug ("Emitting value-changed %s %s %s", key, old_value, new_value);
+ /* just proxy it */
+ g_signal_emit (settings,
+ signals [VALUE_CHANGED],
+ 0,
+ key,
+ old_value,
+ new_value);
}
static void
gdm_settings_init (GdmSettings *settings)
{
- settings->priv = GDM_SETTINGS_GET_PRIVATE (settings);
+ settings->priv = GDM_SETTINGS_GET_PRIVATE (settings);
- settings->priv->backend = gdm_settings_desktop_backend_new ();
- g_signal_connect (settings->priv->backend,
- "value-changed",
- G_CALLBACK (backend_value_changed),
- settings);
+ settings->priv->backend = gdm_settings_desktop_backend_new ();
+ g_signal_connect (settings->priv->backend,
+ "value-changed",
+ G_CALLBACK (backend_value_changed),
+ settings);
}
static void
gdm_settings_finalize (GObject *object)
{
- GdmSettings *settings;
+ GdmSettings *settings;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_SETTINGS (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_SETTINGS (object));
- settings = GDM_SETTINGS (object);
+ settings = GDM_SETTINGS (object);
- g_return_if_fail (settings->priv != NULL);
+ g_return_if_fail (settings->priv != NULL);
- if (settings->priv->backend != NULL) {
- g_object_unref (settings->priv->backend);
- }
+ if (settings->priv->backend != NULL) {
+ g_object_unref (settings->priv->backend);
+ }
- G_OBJECT_CLASS (gdm_settings_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_settings_parent_class)->finalize (object);
}
GdmSettings *
gdm_settings_new (void)
{
- if (settings_object != NULL) {
- g_object_ref (settings_object);
- } else {
- gboolean res;
-
- settings_object = g_object_new (GDM_TYPE_SETTINGS, NULL);
- g_object_add_weak_pointer (settings_object,
- (gpointer *) &settings_object);
+ if (settings_object != NULL) {
+ g_object_ref (settings_object);
+ } else {
+ gboolean res;
+
+ settings_object = g_object_new (GDM_TYPE_SETTINGS, NULL);
+ g_object_add_weak_pointer (settings_object,
+ (gpointer *) &settings_object);
res = register_settings (settings_object);
if (! res) {
- g_warning ("Unable to register settings");
+ g_warning ("Unable to register settings");
g_object_unref (settings_object);
return NULL;
}
- }
+ }
- return GDM_SETTINGS (settings_object);
+ return GDM_SETTINGS (settings_object);
}
diff --git a/common/gdm-settings.h b/common/gdm-settings.h
index efd9cb68..8284e84b 100644
--- a/common/gdm-settings.h
+++ b/common/gdm-settings.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -37,43 +37,43 @@ typedef struct GdmSettingsPrivate GdmSettingsPrivate;
typedef struct
{
- GObject parent;
- GdmSettingsPrivate *priv;
+ GObject parent;
+ GdmSettingsPrivate *priv;
} GdmSettings;
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
- void (* value_changed) (GdmSettings *settings,
- const char *key,
- const char *old_value,
- const char **new_value);
+ void (* value_changed) (GdmSettings *settings,
+ const char *key,
+ const char *old_value,
+ const char **new_value);
} GdmSettingsClass;
typedef enum
{
- GDM_SETTINGS_ERROR_GENERAL,
- GDM_SETTINGS_ERROR_KEY_NOT_FOUND
+ GDM_SETTINGS_ERROR_GENERAL,
+ GDM_SETTINGS_ERROR_KEY_NOT_FOUND
} GdmSettingsError;
#define GDM_SETTINGS_ERROR gdm_settings_error_quark ()
-GQuark gdm_settings_error_quark (void);
-GType gdm_settings_get_type (void);
+GQuark gdm_settings_error_quark (void);
+GType gdm_settings_get_type (void);
-GdmSettings * gdm_settings_new (void);
+GdmSettings * gdm_settings_new (void);
/* exported */
gboolean gdm_settings_get_value (GdmSettings *settings,
- const char *key,
- char **value,
- GError **error);
+ const char *key,
+ char **value,
+ GError **error);
gboolean gdm_settings_set_value (GdmSettings *settings,
- const char *key,
- const char *value,
- GError **error);
+ const char *key,
+ const char *value,
+ GError **error);
G_END_DECLS
diff --git a/common/gdm-signal-handler.c b/common/gdm-signal-handler.c
index 7db9db45..ec1aef55 100644
--- a/common/gdm-signal-handler.c
+++ b/common/gdm-signal-handler.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2006 Red Hat, Inc.
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
@@ -42,19 +42,19 @@
#define GDM_SIGNAL_HANDLER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_SIGNAL_HANDLER, GdmSignalHandlerPrivate))
typedef struct {
- GdmSignalHandlerFunc func;
- gpointer data;
+ GdmSignalHandlerFunc func;
+ gpointer data;
} CallbackData;
struct GdmSignalHandlerPrivate
{
- GMainLoop *main_loop;
- GHashTable *lookup;
+ GMainLoop *main_loop;
+ GHashTable *lookup;
};
-static void gdm_signal_handler_class_init (GdmSignalHandlerClass *klass);
-static void gdm_signal_handler_init (GdmSignalHandler *signal_handler);
-static void gdm_signal_handler_finalize (GObject *object);
+static void gdm_signal_handler_class_init (GdmSignalHandlerClass *klass);
+static void gdm_signal_handler_init (GdmSignalHandler *signal_handler);
+static void gdm_signal_handler_finalize (GObject *object);
static gpointer signal_handler_object = NULL;
static int signal_pipes[2];
@@ -67,78 +67,78 @@ G_DEFINE_TYPE (GdmSignalHandler, gdm_signal_handler, G_TYPE_OBJECT)
static void
block_signals_push (void)
{
- signals_blocked++;
-
- if (signals_blocked == 1) {
- /* Set signal mask */
- sigemptyset (&signals_block_mask);
- sigfillset (&signals_block_mask);
- sigprocmask (SIG_BLOCK, &signals_block_mask, &signals_oldmask);
- }
+ signals_blocked++;
+
+ if (signals_blocked == 1) {
+ /* Set signal mask */
+ sigemptyset (&signals_block_mask);
+ sigfillset (&signals_block_mask);
+ sigprocmask (SIG_BLOCK, &signals_block_mask, &signals_oldmask);
+ }
}
static void
block_signals_pop (void)
{
- signals_blocked--;
+ signals_blocked--;
- if (signals_blocked == 0) {
- /* Set signal mask */
- sigprocmask (SIG_SETMASK, &signals_oldmask, NULL);
- }
+ if (signals_blocked == 0) {
+ /* Set signal mask */
+ sigprocmask (SIG_SETMASK, &signals_oldmask, NULL);
+ }
}
static gboolean
signal_io_watch (GIOChannel *ioc,
- GIOCondition condition,
- GdmSignalHandler *handler)
+ GIOCondition condition,
+ GdmSignalHandler *handler)
{
- char buf[256];
- gboolean is_fatal;
- gsize bytes_read;
- int i;
+ char buf[256];
+ gboolean is_fatal;
+ gsize bytes_read;
+ int i;
- block_signals_push ();
+ block_signals_push ();
- g_io_channel_read_chars (ioc, buf, sizeof (buf), &bytes_read, NULL);
+ g_io_channel_read_chars (ioc, buf, sizeof (buf), &bytes_read, NULL);
- is_fatal = FALSE;
+ is_fatal = FALSE;
- g_debug ("Read %d chars", (int)bytes_read);
+ g_debug ("Read %d chars", (int)bytes_read);
- for (i = 0; i < bytes_read; i++) {
- int signum;
- GSList *handlers;
- GSList *l;
+ for (i = 0; i < bytes_read; i++) {
+ int signum;
+ GSList *handlers;
+ GSList *l;
- signum = (gint32)buf[i];
+ signum = (gint32)buf[i];
- g_debug ("handling signal %d", signum);
- handlers = g_hash_table_lookup (handler->priv->lookup, GINT_TO_POINTER (signum));
+ g_debug ("handling signal %d", signum);
+ handlers = g_hash_table_lookup (handler->priv->lookup, GINT_TO_POINTER (signum));
- g_debug ("Found %u callbacks", g_slist_length (handlers));
- for (l = handlers; l != NULL; l = l->next) {
- gboolean res;
- CallbackData *data;
+ g_debug ("Found %u callbacks", g_slist_length (handlers));
+ for (l = handlers; l != NULL; l = l->next) {
+ gboolean res;
+ CallbackData *data;
- data = l->data;
- g_debug ("running %d handler: %p", signum, data->func);
- res = data->func (signum, data->data);
- if (! res) {
- is_fatal = TRUE;
- }
- }
- }
+ data = l->data;
+ g_debug ("running %d handler: %p", signum, data->func);
+ res = data->func (signum, data->data);
+ if (! res) {
+ is_fatal = TRUE;
+ }
+ }
+ }
- block_signals_pop ();
+ block_signals_pop ();
- if (is_fatal) {
- g_debug ("Caught termination signal - exiting main loop");
- g_main_loop_quit (handler->priv->main_loop);
- return FALSE;
- }
+ if (is_fatal) {
+ g_debug ("Caught termination signal - exiting main loop");
+ g_main_loop_quit (handler->priv->main_loop);
+ return FALSE;
+ }
- g_debug ("Done handling signals");
+ g_debug ("Done handling signals");
return TRUE;
}
@@ -146,112 +146,112 @@ signal_io_watch (GIOChannel *ioc,
static void
fallback_get_backtrace (void)
{
- void * frames[64];
- size_t size;
- char ** strings;
- size_t i;
-
- size = backtrace (frames, G_N_ELEMENTS (frames));
- if ((strings = backtrace_symbols (frames, size))) {
- syslog (LOG_CRIT, "******************* START ********************************");
- for (i = 0; i < size; i++) {
- syslog (LOG_CRIT, "Frame %zd: %s", i, strings[i]);
- }
- free (strings);
- syslog (LOG_CRIT, "******************* END **********************************");
- } else {
- g_warning ("GDM crashed, but symbols couldn't be retrieved.");
- }
+ void * frames[64];
+ size_t size;
+ char ** strings;
+ size_t i;
+
+ size = backtrace (frames, G_N_ELEMENTS (frames));
+ if ((strings = backtrace_symbols (frames, size))) {
+ syslog (LOG_CRIT, "******************* START ********************************");
+ for (i = 0; i < size; i++) {
+ syslog (LOG_CRIT, "Frame %zd: %s", i, strings[i]);
+ }
+ free (strings);
+ syslog (LOG_CRIT, "******************* END **********************************");
+ } else {
+ g_warning ("GDM crashed, but symbols couldn't be retrieved.");
+ }
}
static gboolean
crashlogger_get_backtrace (void)
{
- gboolean success = FALSE;
- int pid;
-
- pid = fork();
- if (pid > 0) {
- /* Wait for the child to finish */
- int estatus;
- if (waitpid (pid, &estatus, 0) != -1) {
- /* Only succeed if the crashlogger succeeded */
- if (WIFEXITED (estatus) && (WEXITSTATUS (estatus) == 0)) {
- success = TRUE;
- }
- }
- } else if (pid == 0) {
- /* Child process */
- execl (LIBEXECDIR"/gdm-crash-logger",
- LIBEXECDIR"/gdm-crash-logger", NULL);
- }
-
- return success;
+ gboolean success = FALSE;
+ int pid;
+
+ pid = fork();
+ if (pid > 0) {
+ /* Wait for the child to finish */
+ int estatus;
+ if (waitpid (pid, &estatus, 0) != -1) {
+ /* Only succeed if the crashlogger succeeded */
+ if (WIFEXITED (estatus) && (WEXITSTATUS (estatus) == 0)) {
+ success = TRUE;
+ }
+ }
+ } else if (pid == 0) {
+ /* Child process */
+ execl (LIBEXECDIR"/gdm-crash-logger",
+ LIBEXECDIR"/gdm-crash-logger", NULL);
+ }
+
+ return success;
}
static void
gdm_signal_handler_backtrace (void)
{
- struct stat s;
- gboolean fallback = TRUE;
-
- /* Try to use gdb via gdm-crash-logger if it exists, since
- * we get much better information out of it. Otherwise
- * fall back to execinfo.
- */
- if (g_stat (LIBEXECDIR"/gdm-crash-logger", &s) == 0) {
- fallback = crashlogger_get_backtrace () ? FALSE : TRUE;
- }
-
- if (fallback) {
- fallback_get_backtrace ();
- }
+ struct stat s;
+ gboolean fallback = TRUE;
+
+ /* Try to use gdb via gdm-crash-logger if it exists, since
+ * we get much better information out of it. Otherwise
+ * fall back to execinfo.
+ */
+ if (g_stat (LIBEXECDIR"/gdm-crash-logger", &s) == 0) {
+ fallback = crashlogger_get_backtrace () ? FALSE : TRUE;
+ }
+
+ if (fallback) {
+ fallback_get_backtrace ();
+ }
}
static void
signal_handler (int signo)
{
- static int in_fatal = 0;
- int ignore;
-
- /* avoid loops */
- if (in_fatal > 0) {
- return;
- }
-
- ++in_fatal;
-
- switch (signo) {
- case SIGSEGV:
- case SIGBUS:
- case SIGILL:
- case SIGABRT:
- g_warning ("Caught signal %d. Generating backtrace...", signo);
- gdm_signal_handler_backtrace ();
- exit (1);
- break;
- case SIGFPE:
- case SIGPIPE:
- /* let the fatal signals interrupt us */
- --in_fatal;
-
- g_warning ("Caught signal %d, shutting down abnormally. Generating backtrace...", signo);
- gdm_signal_handler_backtrace ();
- ignore = write (signal_pipes [1], (guchar *)&signo, 1);
- break;
- default:
- --in_fatal;
- /* FIXME: should probably use int32 here */
- ignore = write (signal_pipes [1], (guchar *)&signo, 1);
- break;
- }
+ static int in_fatal = 0;
+ int ignore;
+
+ /* avoid loops */
+ if (in_fatal > 0) {
+ return;
+ }
+
+ ++in_fatal;
+
+ switch (signo) {
+ case SIGSEGV:
+ case SIGBUS:
+ case SIGILL:
+ case SIGABRT:
+ g_warning ("Caught signal %d. Generating backtrace...", signo);
+ gdm_signal_handler_backtrace ();
+ exit (1);
+ break;
+ case SIGFPE:
+ case SIGPIPE:
+ /* let the fatal signals interrupt us */
+ --in_fatal;
+
+ g_warning ("Caught signal %d, shutting down abnormally. Generating backtrace...", signo);
+ gdm_signal_handler_backtrace ();
+ ignore = write (signal_pipes [1], (guchar *)&signo, 1);
+ break;
+ default:
+ --in_fatal;
+ /* FIXME: should probably use int32 here */
+ ignore = write (signal_pipes [1], (guchar *)&signo, 1);
+ break;
+ }
}
static void
catch_signal (GdmSignalHandler *handler,
- int signal_number)
+ int signal_number)
{
struct sigaction action;
@@ -259,60 +259,60 @@ catch_signal (GdmSignalHandler *handler,
sigemptyset (&action.sa_mask);
action.sa_flags = 0;
- /* FIXME: save old action? */
- sigaction (signal_number, &action, NULL);
+ /* FIXME: save old action? */
+ sigaction (signal_number, &action, NULL);
}
void
gdm_signal_handler_add (GdmSignalHandler *handler,
- int signal_number,
- GdmSignalHandlerFunc callback,
- gpointer data)
+ int signal_number,
+ GdmSignalHandlerFunc callback,
+ gpointer data)
{
- CallbackData *cdata;
- GSList *list;
+ CallbackData *cdata;
+ GSList *list;
- g_return_if_fail (GDM_IS_SIGNAL_HANDLER (handler));
+ g_return_if_fail (GDM_IS_SIGNAL_HANDLER (handler));
- cdata = g_new0 (CallbackData, 1);
- cdata->func = callback;
- cdata->data = data;
+ cdata = g_new0 (CallbackData, 1);
+ cdata->func = callback;
+ cdata->data = data;
- list = g_hash_table_lookup (handler->priv->lookup, GINT_TO_POINTER (signal_number));
- if (list == NULL) {
- catch_signal (handler, signal_number);
- }
+ list = g_hash_table_lookup (handler->priv->lookup, GINT_TO_POINTER (signal_number));
+ if (list == NULL) {
+ catch_signal (handler, signal_number);
+ }
- list = g_slist_prepend (list, cdata);
- g_debug ("Inserting %d callback %p", signal_number, cdata->func);
- g_hash_table_insert (handler->priv->lookup, GINT_TO_POINTER (signal_number), list);
+ list = g_slist_prepend (list, cdata);
+ g_debug ("Inserting %d callback %p", signal_number, cdata->func);
+ g_hash_table_insert (handler->priv->lookup, GINT_TO_POINTER (signal_number), list);
}
static void
gdm_signal_handler_class_init (GdmSignalHandlerClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gdm_signal_handler_finalize;
+ object_class->finalize = gdm_signal_handler_finalize;
- g_type_class_add_private (klass, sizeof (GdmSignalHandlerPrivate));
+ g_type_class_add_private (klass, sizeof (GdmSignalHandlerPrivate));
}
static void
signal_list_free (GSList *list)
{
- g_slist_foreach (list, (GFunc)g_free, NULL);
- g_slist_free (list);
+ g_slist_foreach (list, (GFunc)g_free, NULL);
+ g_slist_free (list);
}
void
gdm_signal_handler_set_main_loop (GdmSignalHandler *handler,
- GMainLoop *main_loop)
+ GMainLoop *main_loop)
{
- g_return_if_fail (GDM_IS_SIGNAL_HANDLER (handler));
+ g_return_if_fail (GDM_IS_SIGNAL_HANDLER (handler));
- /* FIXME: take a ref */
- handler->priv->main_loop = main_loop;
+ /* FIXME: take a ref */
+ handler->priv->main_loop = main_loop;
}
static void
@@ -320,51 +320,51 @@ gdm_signal_handler_init (GdmSignalHandler *handler)
{
GIOChannel *ioc;
- handler->priv = GDM_SIGNAL_HANDLER_GET_PRIVATE (handler);
+ handler->priv = GDM_SIGNAL_HANDLER_GET_PRIVATE (handler);
- handler->priv->lookup = g_hash_table_new (NULL, NULL);
+ handler->priv->lookup = g_hash_table_new (NULL, NULL);
if (pipe (signal_pipes) == -1) {
g_error ("Could not create pipe() for signal handling");
}
ioc = g_io_channel_unix_new (signal_pipes[0]);
- g_io_channel_set_flags (ioc, G_IO_FLAG_NONBLOCK, NULL);
+ g_io_channel_set_flags (ioc, G_IO_FLAG_NONBLOCK, NULL);
g_io_add_watch (ioc, G_IO_IN, (GIOFunc)signal_io_watch, handler);
- g_io_channel_set_close_on_unref (ioc, TRUE);
- g_io_channel_unref (ioc);
+ g_io_channel_set_close_on_unref (ioc, TRUE);
+ g_io_channel_unref (ioc);
}
static void
gdm_signal_handler_finalize (GObject *object)
{
- GdmSignalHandler *handler;
+ GdmSignalHandler *handler;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_SIGNAL_HANDLER (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_SIGNAL_HANDLER (object));
- handler = GDM_SIGNAL_HANDLER (object);
+ handler = GDM_SIGNAL_HANDLER (object);
- g_debug ("Finalizing signal handler");
+ g_debug ("Finalizing signal handler");
- g_return_if_fail (handler->priv != NULL);
+ g_return_if_fail (handler->priv != NULL);
- /* FIXME: free hash lists */
- g_hash_table_destroy (handler->priv->lookup);
+ /* FIXME: free hash lists */
+ g_hash_table_destroy (handler->priv->lookup);
- G_OBJECT_CLASS (gdm_signal_handler_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_signal_handler_parent_class)->finalize (object);
}
GdmSignalHandler *
gdm_signal_handler_new (void)
{
- if (signal_handler_object != NULL) {
- g_object_ref (signal_handler_object);
- } else {
- signal_handler_object = g_object_new (GDM_TYPE_SIGNAL_HANDLER, NULL);
- g_object_add_weak_pointer (signal_handler_object,
- (gpointer *) &signal_handler_object);
- }
-
- return GDM_SIGNAL_HANDLER (signal_handler_object);
+ if (signal_handler_object != NULL) {
+ g_object_ref (signal_handler_object);
+ } else {
+ signal_handler_object = g_object_new (GDM_TYPE_SIGNAL_HANDLER, NULL);
+ g_object_add_weak_pointer (signal_handler_object,
+ (gpointer *) &signal_handler_object);
+ }
+
+ return GDM_SIGNAL_HANDLER (signal_handler_object);
}
diff --git a/common/gdm-signal-handler.h b/common/gdm-signal-handler.h
index 43e5808b..f29d5625 100644
--- a/common/gdm-signal-handler.h
+++ b/common/gdm-signal-handler.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -34,32 +34,32 @@ G_BEGIN_DECLS
#define GDM_SIGNAL_HANDLER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDM_TYPE_SIGNAL_HANDLER, GdmSignalHandlerClass))
-typedef gboolean (*GdmSignalHandlerFunc) (int signal,
- gpointer data);
+typedef gboolean (*GdmSignalHandlerFunc) (int signal,
+ gpointer data);
typedef struct GdmSignalHandlerPrivate GdmSignalHandlerPrivate;
typedef struct
{
- GObject parent;
- GdmSignalHandlerPrivate *priv;
+ GObject parent;
+ GdmSignalHandlerPrivate *priv;
} GdmSignalHandler;
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
} GdmSignalHandlerClass;
-GType gdm_signal_handler_get_type (void);
+GType gdm_signal_handler_get_type (void);
GdmSignalHandler * gdm_signal_handler_new (void);
void gdm_signal_handler_set_main_loop (GdmSignalHandler *handler,
- GMainLoop *main_loop);
+ GMainLoop *main_loop);
void gdm_signal_handler_add (GdmSignalHandler *handler,
- int signal_number,
- GdmSignalHandlerFunc callback,
- gpointer data);
+ int signal_number,
+ GdmSignalHandlerFunc callback,
+ gpointer data);
G_END_DECLS
diff --git a/common/test-settings-client.c b/common/test-settings-client.c
index b9927607..e2a82717 100644
--- a/common/test-settings-client.c
+++ b/common/test-settings-client.c
@@ -89,5 +89,5 @@ main (int argc, char **argv)
loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (loop);
- return 0;
+ return 0;
}
diff --git a/common/test-settings-server.c b/common/test-settings-server.c
index cc2f609e..a7fe7918 100644
--- a/common/test-settings-server.c
+++ b/common/test-settings-server.c
@@ -44,125 +44,125 @@ static GdmSettings *settings = NULL;
static gboolean
acquire_name_on_proxy (DBusGProxy *bus_proxy)
{
- GError *error;
- guint result;
- gboolean res;
- gboolean ret;
-
- ret = FALSE;
-
- if (bus_proxy == NULL) {
- goto out;
- }
-
- error = NULL;
- res = dbus_g_proxy_call (bus_proxy,
- "RequestName",
- &error,
- G_TYPE_STRING, GDM_DBUS_NAME,
- G_TYPE_UINT, 0,
- G_TYPE_INVALID,
- G_TYPE_UINT, &result,
- G_TYPE_INVALID);
- if (! res) {
- if (error != NULL) {
- g_warning ("Failed to acquire %s: %s", GDM_DBUS_NAME, error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to acquire %s", GDM_DBUS_NAME);
- }
- goto out;
- }
-
- if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
- if (error != NULL) {
- g_warning ("Failed to acquire %s: %s", GDM_DBUS_NAME, error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to acquire %s", GDM_DBUS_NAME);
- }
- goto out;
- }
-
- ret = TRUE;
+ GError *error;
+ guint result;
+ gboolean res;
+ gboolean ret;
+
+ ret = FALSE;
+
+ if (bus_proxy == NULL) {
+ goto out;
+ }
+
+ error = NULL;
+ res = dbus_g_proxy_call (bus_proxy,
+ "RequestName",
+ &error,
+ G_TYPE_STRING, GDM_DBUS_NAME,
+ G_TYPE_UINT, 0,
+ G_TYPE_INVALID,
+ G_TYPE_UINT, &result,
+ G_TYPE_INVALID);
+ if (! res) {
+ if (error != NULL) {
+ g_warning ("Failed to acquire %s: %s", GDM_DBUS_NAME, error->message);
+ g_error_free (error);
+ } else {
+ g_warning ("Failed to acquire %s", GDM_DBUS_NAME);
+ }
+ goto out;
+ }
+
+ if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+ if (error != NULL) {
+ g_warning ("Failed to acquire %s: %s", GDM_DBUS_NAME, error->message);
+ g_error_free (error);
+ } else {
+ g_warning ("Failed to acquire %s", GDM_DBUS_NAME);
+ }
+ goto out;
+ }
+
+ ret = TRUE;
out:
- return ret;
+ return ret;
}
static DBusGProxy *
get_bus_proxy (DBusGConnection *connection)
{
- DBusGProxy *bus_proxy;
+ DBusGProxy *bus_proxy;
- bus_proxy = dbus_g_proxy_new_for_name (connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
- return bus_proxy;
+ bus_proxy = dbus_g_proxy_new_for_name (connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);
+ return bus_proxy;
}
static DBusGConnection *
get_system_bus (void)
{
- GError *error;
- DBusGConnection *bus;
- DBusConnection *connection;
-
- error = NULL;
- bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (bus == NULL) {
- g_warning ("Couldn't connect to system bus: %s",
- error->message);
- g_error_free (error);
- goto out;
- }
-
- connection = dbus_g_connection_get_connection (bus);
- dbus_connection_set_exit_on_disconnect (connection, FALSE);
+ GError *error;
+ DBusGConnection *bus;
+ DBusConnection *connection;
+
+ error = NULL;
+ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (bus == NULL) {
+ g_warning ("Couldn't connect to system bus: %s",
+ error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ connection = dbus_g_connection_get_connection (bus);
+ dbus_connection_set_exit_on_disconnect (connection, FALSE);
out:
- return bus;
+ return bus;
}
int
main (int argc, char **argv)
{
- GMainLoop *main_loop;
+ GMainLoop *main_loop;
DBusGConnection *connection;
- DBusGProxy *bus_proxy;
+ DBusGProxy *bus_proxy;
g_type_init ();
- connection = get_system_bus ();
- if (connection == NULL) {
- goto out;
- }
-
- bus_proxy = get_bus_proxy (connection);
- if (bus_proxy == NULL) {
- g_warning ("Could not construct bus_proxy object; bailing out");
- goto out;
- }
-
- if (! acquire_name_on_proxy (bus_proxy) ) {
- g_warning ("Could not acquire name; bailing out");
- goto out;
- }
-
- settings = gdm_settings_new ();
- if (settings == NULL) {
- g_warning ("Unable to initialize settings");
- exit (1);
+ connection = get_system_bus ();
+ if (connection == NULL) {
+ goto out;
+ }
+
+ bus_proxy = get_bus_proxy (connection);
+ if (bus_proxy == NULL) {
+ g_warning ("Could not construct bus_proxy object; bailing out");
+ goto out;
+ }
+
+ if (! acquire_name_on_proxy (bus_proxy) ) {
+ g_warning ("Could not acquire name; bailing out");
+ goto out;
+ }
+
+ settings = gdm_settings_new ();
+ if (settings == NULL) {
+ g_warning ("Unable to initialize settings");
+ exit (1);
}
- main_loop = g_main_loop_new (NULL, FALSE);
- g_main_loop_run (main_loop);
+ main_loop = g_main_loop_new (NULL, FALSE);
+ g_main_loop_run (main_loop);
- g_main_loop_unref (main_loop);
+ g_main_loop_unref (main_loop);
g_object_unref (settings);
out:
- return 0;
+ return 0;
}
diff --git a/common/ve-signal.c b/common/ve-signal.c
index 76f7ed4e..2492b2ff 100644
--- a/common/ve-signal.c
+++ b/common/ve-signal.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Signal routines
*
@@ -11,7 +11,7 @@
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
@@ -34,127 +34,127 @@
typedef struct _SignalSource SignalSource;
struct _SignalSource {
- GSource source;
+ GSource source;
- int signal;
- guint8 index;
- guint8 shift;
+ int signal;
+ guint8 index;
+ guint8 shift;
};
-static guint32 signals_notified[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+static guint32 signals_notified[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
static gboolean
ve_signal_prepare (GSource *source,
- int *timeout)
+ int *timeout)
{
- SignalSource *ss = (SignalSource *)source;
+ SignalSource *ss = (SignalSource *)source;
- return signals_notified[ss->index] & (1 << ss->shift);
+ return signals_notified[ss->index] & (1 << ss->shift);
}
static gboolean
ve_signal_check (GSource *source)
{
- SignalSource *ss = (SignalSource *)source;
+ SignalSource *ss = (SignalSource *)source;
- return signals_notified[ss->index] & (1 << ss->shift);
+ return signals_notified[ss->index] & (1 << ss->shift);
}
static gboolean
ve_signal_dispatch (GSource *source,
- GSourceFunc callback,
- gpointer user_data)
+ GSourceFunc callback,
+ gpointer user_data)
{
- SignalSource *ss = (SignalSource *)source;
+ SignalSource *ss = (SignalSource *)source;
- signals_notified[ss->index] &= ~(1 << ss->shift);
+ signals_notified[ss->index] &= ~(1 << ss->shift);
- return ((VeSignalFunc)callback) (ss->signal, user_data);
+ return ((VeSignalFunc)callback) (ss->signal, user_data);
}
static GSourceFuncs signal_funcs = {
- ve_signal_prepare,
- ve_signal_check,
- ve_signal_dispatch
+ ve_signal_prepare,
+ ve_signal_check,
+ ve_signal_dispatch
};
guint
-ve_signal_add (int signal,
- VeSignalFunc function,
- gpointer data)
+ve_signal_add (int signal,
+ VeSignalFunc function,
+ gpointer data)
{
- return ve_signal_add_full (G_PRIORITY_DEFAULT, signal, function, data, NULL);
+ return ve_signal_add_full (G_PRIORITY_DEFAULT, signal, function, data, NULL);
}
guint
ve_signal_add_full (int priority,
- int signal,
- VeSignalFunc function,
- gpointer data,
- GDestroyNotify destroy)
+ int signal,
+ VeSignalFunc function,
+ gpointer data,
+ GDestroyNotify destroy)
{
- GSource *source;
- SignalSource *ss;
- guint s = 128 + signal;
+ GSource *source;
+ SignalSource *ss;
+ guint s = 128 + signal;
- g_return_val_if_fail (function != NULL, 0);
+ g_return_val_if_fail (function != NULL, 0);
- source = g_source_new (&signal_funcs, sizeof (SignalSource));
- ss = (SignalSource *)source;
+ source = g_source_new (&signal_funcs, sizeof (SignalSource));
+ ss = (SignalSource *)source;
- ss->signal = signal;
- ss->index = s / 32;
- ss->shift = s % 32;
+ ss->signal = signal;
+ ss->index = s / 32;
+ ss->shift = s % 32;
- g_assert (ss->index < 8);
+ g_assert (ss->index < 8);
- g_source_set_priority (source, priority);
- g_source_set_callback (source, (GSourceFunc)function, data, destroy);
- g_source_set_can_recurse (source, TRUE);
+ g_source_set_priority (source, priority);
+ g_source_set_callback (source, (GSourceFunc)function, data, destroy);
+ g_source_set_can_recurse (source, TRUE);
- return g_source_attach (source, NULL);
+ return g_source_attach (source, NULL);
}
void
ve_signal_notify (int signal)
{
- guint index, shift;
- guint s = 128 + signal;
+ guint index, shift;
+ guint s = 128 + signal;
- index = s / 32;
- shift = s % 32;
+ index = s / 32;
+ shift = s % 32;
- g_assert (index < 8);
+ g_assert (index < 8);
- signals_notified[index] |= 1 << shift;
+ signals_notified[index] |= 1 << shift;
- g_main_context_wakeup (NULL);
+ g_main_context_wakeup (NULL);
}
gboolean
ve_signal_was_notified (int signal)
{
- guint index, shift;
- guint s = 128 + signal;
+ guint index, shift;
+ guint s = 128 + signal;
- index = s / 32;
- shift = s % 32;
+ index = s / 32;
+ shift = s % 32;
- g_assert (index < 8);
+ g_assert (index < 8);
- return ((signals_notified[index]) & (1 << shift)) ? TRUE : FALSE;
+ return ((signals_notified[index]) & (1 << shift)) ? TRUE : FALSE;
}
void
ve_signal_unnotify (int signal)
{
- guint index, shift;
- guint s = 128 + signal;
+ guint index, shift;
+ guint s = 128 + signal;
- index = s / 32;
- shift = s % 32;
+ index = s / 32;
+ shift = s % 32;
- g_assert (index < 8);
+ g_assert (index < 8);
- signals_notified[index] &= ~(1 << shift);
+ signals_notified[index] &= ~(1 << shift);
}
diff --git a/common/ve-signal.h b/common/ve-signal.h
index f8f4c4c3..c98adcd7 100644
--- a/common/ve-signal.h
+++ b/common/ve-signal.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Signal routines
*
@@ -11,7 +11,7 @@
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
@@ -25,16 +25,16 @@
#include <glib.h>
-typedef gboolean (*VeSignalFunc) (int signal,
- gpointer data);
-guint ve_signal_add (int signal,
- VeSignalFunc function,
- gpointer data);
+typedef gboolean (*VeSignalFunc) (int signal,
+ gpointer data);
+guint ve_signal_add (int signal,
+ VeSignalFunc function,
+ gpointer data);
guint ve_signal_add_full (int priority,
- int signal,
- VeSignalFunc function,
- gpointer data,
- GDestroyNotify destroy);
+ int signal,
+ VeSignalFunc function,
+ gpointer data,
+ GDestroyNotify destroy);
/* You must handle the signal notify yourself, you add
* this function as the signal notification function
* however */
diff --git a/daemon/auth.c b/daemon/auth.c
index 3ac76235..33cbcd1c 100644
--- a/daemon/auth.c
+++ b/daemon/auth.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* GDM - The GNOME Display Manager
* Copyright (C) 1998, 1999, 2000 Martin K. Petersen <mkp@mkp.net>
@@ -48,194 +48,194 @@
gboolean
gdm_auth_add_entry (int display_num,
- GdmAddress *address,
- GString *binary_cookie,
- FILE *af,
- GSList **authlist)
+ GdmAddress *address,
+ GString *binary_cookie,
+ FILE *af,
+ GSList **authlist)
{
- Xauth *xa;
- char *dispnum;
-
- xa = malloc (sizeof (Xauth));
-
- if (xa == NULL) {
- return FALSE;
- }
-
- if (address == NULL) {
- xa->family = FamilyWild;
- xa->address = NULL;
- xa->address_length = 0;
- } else {
- gboolean res;
- char *hostname;
-
- xa->family = gdm_address_get_family_type (address);
-
- res = gdm_address_get_hostname (address, &hostname);
- if (! res) {
- free (xa);
- return FALSE;
- }
-
- g_debug ("Got hostname: %s", hostname);
-
- xa->address = hostname;
- xa->address_length = strlen (xa->address);
- }
-
- dispnum = g_strdup_printf ("%d", display_num);
- xa->number = strdup (dispnum);
- xa->number_length = strlen (dispnum);
- g_free (dispnum);
-
- xa->name = strdup ("MIT-MAGIC-COOKIE-1");
- xa->name_length = strlen ("MIT-MAGIC-COOKIE-1");
- xa->data = malloc (16);
- if (xa->data == NULL) {
- free (xa->number);
- free (xa->name);
- free (xa->address);
- free (xa);
- return FALSE;
- }
-
- memcpy (xa->data, binary_cookie->str, binary_cookie->len);
- xa->data_length = binary_cookie->len;
-
- g_debug ("Writing auth for address:%p %s:%d", address, xa->address, display_num);
-
- if (af != NULL) {
- errno = 0;
- if ( ! XauWriteAuth (af, xa)) {
- free (xa->data);
- free (xa->number);
- free (xa->name);
- free (xa->address);
- free (xa);
-
- if (errno != 0) {
- g_warning (_("%s: Could not write new authorization entry: %s"),
- "add_auth_entry", g_strerror (errno));
- } else {
- g_warning (_("%s: Could not write new authorization entry. "
- "Possibly out of diskspace"),
- "add_auth_entry");
- }
-
- return FALSE;
- }
- }
-
- if (authlist != NULL) {
- *authlist = g_slist_append (*authlist, xa);
- }
-
- return TRUE;
+ Xauth *xa;
+ char *dispnum;
+
+ xa = malloc (sizeof (Xauth));
+
+ if (xa == NULL) {
+ return FALSE;
+ }
+
+ if (address == NULL) {
+ xa->family = FamilyWild;
+ xa->address = NULL;
+ xa->address_length = 0;
+ } else {
+ gboolean res;
+ char *hostname;
+
+ xa->family = gdm_address_get_family_type (address);
+
+ res = gdm_address_get_hostname (address, &hostname);
+ if (! res) {
+ free (xa);
+ return FALSE;
+ }
+
+ g_debug ("Got hostname: %s", hostname);
+
+ xa->address = hostname;
+ xa->address_length = strlen (xa->address);
+ }
+
+ dispnum = g_strdup_printf ("%d", display_num);
+ xa->number = strdup (dispnum);
+ xa->number_length = strlen (dispnum);
+ g_free (dispnum);
+
+ xa->name = strdup ("MIT-MAGIC-COOKIE-1");
+ xa->name_length = strlen ("MIT-MAGIC-COOKIE-1");
+ xa->data = malloc (16);
+ if (xa->data == NULL) {
+ free (xa->number);
+ free (xa->name);
+ free (xa->address);
+ free (xa);
+ return FALSE;
+ }
+
+ memcpy (xa->data, binary_cookie->str, binary_cookie->len);
+ xa->data_length = binary_cookie->len;
+
+ g_debug ("Writing auth for address:%p %s:%d", address, xa->address, display_num);
+
+ if (af != NULL) {
+ errno = 0;
+ if ( ! XauWriteAuth (af, xa)) {
+ free (xa->data);
+ free (xa->number);
+ free (xa->name);
+ free (xa->address);
+ free (xa);
+
+ if (errno != 0) {
+ g_warning (_("%s: Could not write new authorization entry: %s"),
+ "add_auth_entry", g_strerror (errno));
+ } else {
+ g_warning (_("%s: Could not write new authorization entry. "
+ "Possibly out of diskspace"),
+ "add_auth_entry");
+ }
+
+ return FALSE;
+ }
+ }
+
+ if (authlist != NULL) {
+ *authlist = g_slist_append (*authlist, xa);
+ }
+
+ return TRUE;
}
gboolean
gdm_auth_add_entry_for_display (int display_num,
- GdmAddress *address,
- GString *cookie,
- FILE *af,
- GSList **authlist)
+ GdmAddress *address,
+ GString *cookie,
+ FILE *af,
+ GSList **authlist)
{
- GString *binary_cookie;
- gboolean ret;
-
- binary_cookie = g_string_new (NULL);
-
- if (! gdm_string_hex_decode (cookie,
- 0,
- NULL,
- binary_cookie,
- 0)) {
- ret = FALSE;
- goto out;
- }
-
- ret = gdm_auth_add_entry (display_num,
- address,
- binary_cookie,
- af,
- authlist);
+ GString *binary_cookie;
+ gboolean ret;
+
+ binary_cookie = g_string_new (NULL);
+
+ if (! gdm_string_hex_decode (cookie,
+ 0,
+ NULL,
+ binary_cookie,
+ 0)) {
+ ret = FALSE;
+ goto out;
+ }
+
+ ret = gdm_auth_add_entry (display_num,
+ address,
+ binary_cookie,
+ af,
+ authlist);
out:
- g_string_free (binary_cookie, TRUE);
- return ret;
+ g_string_free (binary_cookie, TRUE);
+ return ret;
}
gboolean
gdm_auth_user_add (int display_num,
- GdmAddress *address,
- const char *username,
- const char *cookie,
- char **filenamep)
+ GdmAddress *address,
+ const char *username,
+ const char *cookie,
+ char **filenamep)
{
- int fd;
- char *filename;
- GError *error;
- mode_t old_mask;
- FILE *af;
- gboolean ret;
- struct passwd *pwent;
- GString *cookie_str;
+ int fd;
+ char *filename;
+ GError *error;
+ mode_t old_mask;
+ FILE *af;
+ gboolean ret;
+ struct passwd *pwent;
+ GString *cookie_str;
- g_debug ("Add user auth for address:%p num:%d user:%s", address, display_num, username);
+ g_debug ("Add user auth for address:%p num:%d user:%s", address, display_num, username);
- ret = FALSE;
- filename = NULL;
- af = NULL;
- fd = -1;
+ ret = FALSE;
+ filename = NULL;
+ af = NULL;
+ fd = -1;
- old_mask = umask (077);
+ old_mask = umask (077);
- filename = NULL;
- error = NULL;
- fd = g_file_open_tmp (".gdmXXXXXX", &filename, &error);
+ filename = NULL;
+ error = NULL;
+ fd = g_file_open_tmp (".gdmXXXXXX", &filename, &error);
- umask (old_mask);
+ umask (old_mask);
- if (fd == -1) {
- g_warning ("Unable to create temporary file: %s", error->message);
- g_error_free (error);
- goto out;
- }
+ if (fd == -1) {
+ g_warning ("Unable to create temporary file: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
- if (filenamep != NULL) {
- *filenamep = g_strdup (filename);
- }
+ if (filenamep != NULL) {
+ *filenamep = g_strdup (filename);
+ }
- VE_IGNORE_EINTR (af = fdopen (fd, "w"));
- if (af == NULL) {
- g_warning ("Unable to open cookie file: %s", filename);
- goto out;
- }
+ VE_IGNORE_EINTR (af = fdopen (fd, "w"));
+ if (af == NULL) {
+ g_warning ("Unable to open cookie file: %s", filename);
+ goto out;
+ }
- /* FIXME: clean old files? */
+ /* FIXME: clean old files? */
- cookie_str = g_string_new (cookie);
+ cookie_str = g_string_new (cookie);
- /* FIXME: ?? */
- /*gdm_auth_add_entry_for_display (display_num, address, cookie_str, af, NULL);*/
- gdm_auth_add_entry_for_display (display_num, NULL, cookie_str, af, NULL);
- g_string_free (cookie_str, TRUE);
+ /* FIXME: ?? */
+ /*gdm_auth_add_entry_for_display (display_num, address, cookie_str, af, NULL);*/
+ gdm_auth_add_entry_for_display (display_num, NULL, cookie_str, af, NULL);
+ g_string_free (cookie_str, TRUE);
- pwent = getpwnam (username);
- if (pwent == NULL) {
- goto out;
- }
+ pwent = getpwnam (username);
+ if (pwent == NULL) {
+ goto out;
+ }
- fchown (fd, pwent->pw_uid, -1);
+ fchown (fd, pwent->pw_uid, -1);
- ret = TRUE;
+ ret = TRUE;
out:
- g_free (filename);
+ g_free (filename);
- if (af != NULL) {
- fclose (af);
- }
+ if (af != NULL) {
+ fclose (af);
+ }
- return ret;
+ return ret;
}
diff --git a/daemon/choose.c b/daemon/choose.c
index f9901563..b3cf8378 100644
--- a/daemon/choose.c
+++ b/daemon/choose.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* GDM - The GNOME Display Manager
* Copyright (C) 1998, 1999, 2000 Martin K. Petersen <mkp@mkp.net>
@@ -57,26 +57,26 @@ static guint indirect_id = 1;
static gboolean
remove_oldest_pending (void)
{
- GSList *li;
- GdmIndirectDisplay *oldest = NULL;
-
- for (li = indirect; li != NULL; li = li->next) {
- GdmIndirectDisplay *idisp = li->data;
- if (idisp->acctime == 0)
- continue;
-
- if (oldest == NULL ||
- idisp->acctime < oldest->acctime) {
- oldest = idisp;
- }
- }
-
- if (oldest != NULL) {
- gdm_choose_indirect_dispose (oldest);
- return TRUE;
- } else {
- return FALSE;
- }
+ GSList *li;
+ GdmIndirectDisplay *oldest = NULL;
+
+ for (li = indirect; li != NULL; li = li->next) {
+ GdmIndirectDisplay *idisp = li->data;
+ if (idisp->acctime == 0)
+ continue;
+
+ if (oldest == NULL ||
+ idisp->acctime < oldest->acctime) {
+ oldest = idisp;
+ }
+ }
+
+ if (oldest != NULL) {
+ gdm_choose_indirect_dispose (oldest);
+ return TRUE;
+ } else {
+ return FALSE;
+ }
}
#ifndef XDM_UDP_PORT
@@ -85,287 +85,287 @@ remove_oldest_pending (void)
static gboolean
get_first_address_for_node (const char *node,
- GdmAddress **address)
+ GdmAddress **address)
{
- struct addrinfo hints;
- struct addrinfo *ai_list;
- struct addrinfo *ai;
- int gaierr;
- gboolean found;
- char strport[NI_MAXSERV];
+ struct addrinfo hints;
+ struct addrinfo *ai_list;
+ struct addrinfo *ai;
+ int gaierr;
+ gboolean found;
+ char strport[NI_MAXSERV];
- found = FALSE;
+ found = FALSE;
- memset (&hints, 0, sizeof (hints));
- hints.ai_family = AF_UNSPEC;
+ memset (&hints, 0, sizeof (hints));
+ hints.ai_family = AF_UNSPEC;
- snprintf (strport, sizeof (strport), "%u", XDM_UDP_PORT);
+ snprintf (strport, sizeof (strport), "%u", XDM_UDP_PORT);
- if ((gaierr = getaddrinfo (node, strport, &hints, &ai_list)) != 0) {
- g_warning ("Unable get address: %s", gai_strerror (gaierr));
- return FALSE;
- }
+ if ((gaierr = getaddrinfo (node, strport, &hints, &ai_list)) != 0) {
+ g_warning ("Unable get address: %s", gai_strerror (gaierr));
+ return FALSE;
+ }
- for (ai = ai_list; ai != NULL; ai = ai->ai_next) {
- if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6) {
- continue;
- }
+ for (ai = ai_list; ai != NULL; ai = ai->ai_next) {
+ if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6) {
+ continue;
+ }
#ifndef ENABLE_IPV6
- if (ai->ai_family == AF_INET6) {
- continue;
- }
+ if (ai->ai_family == AF_INET6) {
+ continue;
+ }
#endif
- found = TRUE;
- break;
- }
+ found = TRUE;
+ break;
+ }
- if (ai != NULL) {
- if (address != NULL) {
- *address = gdm_address_new_from_sockaddr_storage ((struct sockaddr_storage *)ai->ai_addr);
- }
- }
+ if (ai != NULL) {
+ if (address != NULL) {
+ *address = gdm_address_new_from_sockaddr_storage ((struct sockaddr_storage *)ai->ai_addr);
+ }
+ }
- freeaddrinfo (ai_list);
+ freeaddrinfo (ai_list);
- return found;
+ return found;
}
static int
get_config_int (char *key)
{
- int val;
+ int val;
- gdm_settings_direct_get_int (key, &val);
+ gdm_settings_direct_get_int (key, &val);
- return val;
+ return val;
}
#if 0
gboolean
gdm_choose_data (const char *data)
{
- int id;
- GdmAddress *address;
- GSList *li;
- char *msg;
- char *p;
- char *host;
- gboolean ret;
-
- msg = g_strdup (data);
- address = NULL;
- ret = FALSE;
-
- p = strtok (msg, " ");
- if (p == NULL || strcmp (GDM_SOP_CHOSEN, p) != 0) {
- goto out;
- }
-
- p = strtok (NULL, " ");
- if (p == NULL || sscanf (p, "%d", &id) != 1) {
- goto out;
- }
-
- p = strtok (NULL, " ");
-
- if (p == NULL) {
- goto out;
- }
-
- if (! get_first_address_for_node (p, &address)) {
- goto out;
- }
-
- gdm_address_get_numeric_info (address, &host, NULL);
- g_debug ("gdm_choose_data: got indirect id: %d address: %s",
- id,
- host);
- g_free (host);
-
- for (li = indirect; li != NULL; li = li->next) {
- GdmIndirectDisplay *idisp = li->data;
- if (idisp->id == id) {
- /* whack the oldest if more then allowed */
- while (ipending >= get_config_int (GDM_KEY_MAX_INDIRECT) &&
- remove_oldest_pending ())
- ;
-
- idisp->acctime = time (NULL);
-
- g_free (idisp->chosen_host);
- idisp->chosen_host = gdm_address_copy (address);
-
- /* Now this display is pending */
- ipending++;
-
- ret = TRUE;
- break;
- }
- }
+ int id;
+ GdmAddress *address;
+ GSList *li;
+ char *msg;
+ char *p;
+ char *host;
+ gboolean ret;
+
+ msg = g_strdup (data);
+ address = NULL;
+ ret = FALSE;
+
+ p = strtok (msg, " ");
+ if (p == NULL || strcmp (GDM_SOP_CHOSEN, p) != 0) {
+ goto out;
+ }
+
+ p = strtok (NULL, " ");
+ if (p == NULL || sscanf (p, "%d", &id) != 1) {
+ goto out;
+ }
+
+ p = strtok (NULL, " ");
+
+ if (p == NULL) {
+ goto out;
+ }
+
+ if (! get_first_address_for_node (p, &address)) {
+ goto out;
+ }
+
+ gdm_address_get_numeric_info (address, &host, NULL);
+ g_debug ("gdm_choose_data: got indirect id: %d address: %s",
+ id,
+ host);
+ g_free (host);
+
+ for (li = indirect; li != NULL; li = li->next) {
+ GdmIndirectDisplay *idisp = li->data;
+ if (idisp->id == id) {
+ /* whack the oldest if more then allowed */
+ while (ipending >= get_config_int (GDM_KEY_MAX_INDIRECT) &&
+ remove_oldest_pending ())
+ ;
+
+ idisp->acctime = time (NULL);
+
+ g_free (idisp->chosen_host);
+ idisp->chosen_host = gdm_address_copy (address);
+
+ /* Now this display is pending */
+ ipending++;
+
+ ret = TRUE;
+ break;
+ }
+ }
out:
- gdm_address_free (address);
- g_free (msg);
+ gdm_address_free (address);
+ g_free (msg);
- return ret;
+ return ret;
}
#endif
GdmIndirectDisplay *
gdm_choose_indirect_alloc (GdmAddress *address)
{
- GdmIndirectDisplay *id;
- char *host;
+ GdmIndirectDisplay *id;
+ char *host;
- g_assert (address != NULL);
+ g_assert (address != NULL);
- id = g_new0 (GdmIndirectDisplay, 1);
- id->id = indirect_id++;
- /* deal with a rollover, that will NEVER EVER happen,
- * but I'm a paranoid bastard */
- if (id->id == 0)
- id->id = indirect_id++;
+ id = g_new0 (GdmIndirectDisplay, 1);
+ id->id = indirect_id++;
+ /* deal with a rollover, that will NEVER EVER happen,
+ * but I'm a paranoid bastard */
+ if (id->id == 0)
+ id->id = indirect_id++;
- id->dsp_address = gdm_address_copy (address);
- id->chosen_host = NULL;
+ id->dsp_address = gdm_address_copy (address);
+ id->chosen_host = NULL;
- id->acctime = 0;
+ id->acctime = 0;
- indirect = g_slist_prepend (indirect, id);
+ indirect = g_slist_prepend (indirect, id);
- gdm_address_get_numeric_info (id->dsp_address, &host, NULL);
+ gdm_address_get_numeric_info (id->dsp_address, &host, NULL);
- g_debug ("gdm_choose_display_alloc: display=%s, pending=%d ",
- host,
- ipending);
- g_free (host);
+ g_debug ("gdm_choose_display_alloc: display=%s, pending=%d ",
+ host,
+ ipending);
+ g_free (host);
- return (id);
+ return (id);
}
/* dispose of indirect display of id, if no host is set */
void
gdm_choose_indirect_dispose_empty_id (guint id)
{
- GSList *li;
+ GSList *li;
- if (id == 0)
- return;
+ if (id == 0)
+ return;
- for (li = indirect; li != NULL; li = li->next) {
- GdmIndirectDisplay *idisp = li->data;
+ for (li = indirect; li != NULL; li = li->next) {
+ GdmIndirectDisplay *idisp = li->data;
- if (idisp == NULL)
- continue;
+ if (idisp == NULL)
+ continue;
- if (idisp->id == id) {
- if (idisp->chosen_host == NULL)
- gdm_choose_indirect_dispose (idisp);
- return;
- }
- }
+ if (idisp->id == id) {
+ if (idisp->chosen_host == NULL)
+ gdm_choose_indirect_dispose (idisp);
+ return;
+ }
+ }
}
GdmIndirectDisplay *
gdm_choose_indirect_lookup_by_chosen (GdmAddress *chosen,
- GdmAddress *origin)
+ GdmAddress *origin)
{
- GSList *li;
- char *host;
-
- for (li = indirect; li != NULL; li = li->next) {
- GdmIndirectDisplay *id = li->data;
-
- if (id != NULL &&
- id->chosen_host != NULL &&
- gdm_address_equal (id->chosen_host, chosen)) {
- if (gdm_address_equal (id->dsp_address, origin)) {
- return id;
- } else if (gdm_address_is_loopback (id->dsp_address) &&
- gdm_address_is_local (origin)) {
- return id;
- }
- }
- }
-
- gdm_address_get_numeric_info (chosen, &host, NULL);
-
- g_debug ("gdm_choose_indirect_lookup_by_chosen: Chosen %s host not found",
- host);
- g_debug ("gdm_choose_indirect_lookup_by_chosen: Origin was: %s",
- host);
- g_free (host);
-
- return NULL;
+ GSList *li;
+ char *host;
+
+ for (li = indirect; li != NULL; li = li->next) {
+ GdmIndirectDisplay *id = li->data;
+
+ if (id != NULL &&
+ id->chosen_host != NULL &&
+ gdm_address_equal (id->chosen_host, chosen)) {
+ if (gdm_address_equal (id->dsp_address, origin)) {
+ return id;
+ } else if (gdm_address_is_loopback (id->dsp_address) &&
+ gdm_address_is_local (origin)) {
+ return id;
+ }
+ }
+ }
+
+ gdm_address_get_numeric_info (chosen, &host, NULL);
+
+ g_debug ("gdm_choose_indirect_lookup_by_chosen: Chosen %s host not found",
+ host);
+ g_debug ("gdm_choose_indirect_lookup_by_chosen: Origin was: %s",
+ host);
+ g_free (host);
+
+ return NULL;
}
GdmIndirectDisplay *
gdm_choose_indirect_lookup (GdmAddress *address)
{
- GSList *li, *ilist;
- GdmIndirectDisplay *id;
- time_t curtime = time (NULL);
- char *host;
-
- ilist = g_slist_copy (indirect);
-
- for (li = ilist; li != NULL; li = li->next) {
- id = (GdmIndirectDisplay *) li->data;
- if (id == NULL)
- continue;
-
- if (id->acctime > 0 &&
- curtime > id->acctime + get_config_int (GDM_KEY_MAX_WAIT_INDIRECT)) {
-
- gdm_address_get_numeric_info (address, &host, NULL);
- g_debug ("gdm_choose_indirect_check: Disposing stale INDIRECT query from %s",
- host);
- g_free (host);
-
- gdm_choose_indirect_dispose (id);
- continue;
- }
-
- if (gdm_address_equal (id->dsp_address, address)) {
- g_slist_free (ilist);
- return id;
- }
- }
- g_slist_free (ilist);
-
- gdm_address_get_numeric_info (address, &host, NULL);
- g_debug ("gdm_choose_indirect_lookup: Host %s not found",
- host);
- g_free (host);
-
- return NULL;
+ GSList *li, *ilist;
+ GdmIndirectDisplay *id;
+ time_t curtime = time (NULL);
+ char *host;
+
+ ilist = g_slist_copy (indirect);
+
+ for (li = ilist; li != NULL; li = li->next) {
+ id = (GdmIndirectDisplay *) li->data;
+ if (id == NULL)
+ continue;
+
+ if (id->acctime > 0 &&
+ curtime > id->acctime + get_config_int (GDM_KEY_MAX_WAIT_INDIRECT)) {
+
+ gdm_address_get_numeric_info (address, &host, NULL);
+ g_debug ("gdm_choose_indirect_check: Disposing stale INDIRECT query from %s",
+ host);
+ g_free (host);
+
+ gdm_choose_indirect_dispose (id);
+ continue;
+ }
+
+ if (gdm_address_equal (id->dsp_address, address)) {
+ g_slist_free (ilist);
+ return id;
+ }
+ }
+ g_slist_free (ilist);
+
+ gdm_address_get_numeric_info (address, &host, NULL);
+ g_debug ("gdm_choose_indirect_lookup: Host %s not found",
+ host);
+ g_free (host);
+
+ return NULL;
}
void
gdm_choose_indirect_dispose (GdmIndirectDisplay *id)
{
- char *host;
+ char *host;
- if (id == NULL)
- return;
+ if (id == NULL)
+ return;
- indirect = g_slist_remove (indirect, id);
+ indirect = g_slist_remove (indirect, id);
- if (id->acctime > 0)
- ipending--;
- id->acctime = 0;
+ if (id->acctime > 0)
+ ipending--;
+ id->acctime = 0;
- gdm_address_get_numeric_info (id->dsp_address, &host, NULL);
- g_debug ("gdm_choose_indirect_dispose: Disposing %s",
- host);
- g_free (host);
+ gdm_address_get_numeric_info (id->dsp_address, &host, NULL);
+ g_debug ("gdm_choose_indirect_dispose: Disposing %s",
+ host);
+ g_free (host);
- g_free (id->chosen_host);
- id->chosen_host = NULL;
+ g_free (id->chosen_host);
+ id->chosen_host = NULL;
- gdm_address_free (id->dsp_address);
- id->dsp_address = NULL;
+ gdm_address_free (id->dsp_address);
+ id->dsp_address = NULL;
- g_free (id);
+ g_free (id);
}
diff --git a/daemon/choose.h b/daemon/choose.h
index ea2fe87b..09c151a7 100644
--- a/daemon/choose.h
+++ b/daemon/choose.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* GDM - The GNOME Display Manager
* Copyright (C) 1998, 1999, 2000 Martin K. Petersen <mkp@mkp.net>
@@ -25,22 +25,22 @@
typedef struct _GdmIndirectDisplay GdmIndirectDisplay;
struct _GdmIndirectDisplay {
- int id;
- GdmAddress *dsp_address;
- GdmAddress *chosen_host;
- time_t acctime;
+ int id;
+ GdmAddress *dsp_address;
+ GdmAddress *chosen_host;
+ time_t acctime;
};
GdmIndirectDisplay * gdm_choose_indirect_alloc (GdmAddress *address);
GdmIndirectDisplay * gdm_choose_indirect_lookup (GdmAddress *address);
-GdmIndirectDisplay * gdm_choose_indirect_lookup_by_chosen (GdmAddress *chosen,
- GdmAddress *origin);
-void gdm_choose_indirect_dispose (GdmIndirectDisplay *id);
+GdmIndirectDisplay * gdm_choose_indirect_lookup_by_chosen (GdmAddress *chosen,
+ GdmAddress *origin);
+void gdm_choose_indirect_dispose (GdmIndirectDisplay *id);
/* dispose of indirect display of id, if no host is set */
-void gdm_choose_indirect_dispose_empty_id (guint id);
+void gdm_choose_indirect_dispose_empty_id (guint id);
-gboolean gdm_choose_data (const char *data);
+gboolean gdm_choose_data (const char *data);
#endif /* CHOOSE_H */
diff --git a/daemon/ck-connector.c b/daemon/ck-connector.c
index 7f6f87f0..0117eb99 100644
--- a/daemon/ck-connector.c
+++ b/daemon/ck-connector.c
@@ -70,7 +70,7 @@ struct _CkConnector
};
static struct {
- char *name;
+ char *name;
int type;
} parameter_lookup[] = {
{ "display-device", DBUS_TYPE_STRING },
diff --git a/daemon/factory-slave-main.c b/daemon/factory-slave-main.c
index 9f740d73..f798ed52 100644
--- a/daemon/factory-slave-main.c
+++ b/daemon/factory-slave-main.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -48,181 +48,181 @@ static int gdm_return_code = 0;
static DBusGConnection *
get_system_bus (void)
{
- GError *error;
- DBusGConnection *bus;
- DBusConnection *connection;
-
- error = NULL;
- bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (bus == NULL) {
- g_warning ("Couldn't connect to system bus: %s",
- error->message);
- g_error_free (error);
- goto out;
- }
-
- connection = dbus_g_connection_get_connection (bus);
- dbus_connection_set_exit_on_disconnect (connection, FALSE);
+ GError *error;
+ DBusGConnection *bus;
+ DBusConnection *connection;
+
+ error = NULL;
+ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (bus == NULL) {
+ g_warning ("Couldn't connect to system bus: %s",
+ error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ connection = dbus_g_connection_get_connection (bus);
+ dbus_connection_set_exit_on_disconnect (connection, FALSE);
out:
- return bus;
+ return bus;
}
static gboolean
signal_cb (int signo,
- gpointer data)
+ gpointer data)
{
- int ret;
+ int ret;
- g_debug ("Got callback for signal %d", signo);
+ g_debug ("Got callback for signal %d", signo);
- ret = TRUE;
+ ret = TRUE;
- switch (signo) {
- case SIGSEGV:
- case SIGBUS:
- case SIGILL:
- case SIGABRT:
- g_debug ("Caught signal %d.", signo);
+ switch (signo) {
+ case SIGSEGV:
+ case SIGBUS:
+ case SIGILL:
+ case SIGABRT:
+ g_debug ("Caught signal %d.", signo);
- ret = FALSE;
- break;
+ ret = FALSE;
+ break;
- case SIGFPE:
- case SIGPIPE:
- /* let the fatal signals interrupt us */
- g_debug ("Caught signal %d, shutting down abnormally.", signo);
- ret = FALSE;
+ case SIGFPE:
+ case SIGPIPE:
+ /* let the fatal signals interrupt us */
+ g_debug ("Caught signal %d, shutting down abnormally.", signo);
+ ret = FALSE;
- break;
+ break;
- case SIGINT:
- case SIGTERM:
- /* let the fatal signals interrupt us */
- g_debug ("Caught signal %d, shutting down normally.", signo);
- ret = FALSE;
+ case SIGINT:
+ case SIGTERM:
+ /* let the fatal signals interrupt us */
+ g_debug ("Caught signal %d, shutting down normally.", signo);
+ ret = FALSE;
- break;
+ break;
- case SIGHUP:
- g_debug ("Got HUP signal");
- /* FIXME:
- * Reread config stuff like system config files, VPN service files, etc
- */
- ret = TRUE;
+ case SIGHUP:
+ g_debug ("Got HUP signal");
+ /* FIXME:
+ * Reread config stuff like system config files, VPN service files, etc
+ */
+ ret = TRUE;
- break;
+ break;
- case SIGUSR1:
- g_debug ("Got USR1 signal");
- /* FIXME:
- * Play with log levels or something
- */
- ret = TRUE;
+ case SIGUSR1:
+ g_debug ("Got USR1 signal");
+ /* FIXME:
+ * Play with log levels or something
+ */
+ ret = TRUE;
- break;
+ break;
- default:
- g_debug ("Caught unhandled signal %d", signo);
- ret = TRUE;
+ default:
+ g_debug ("Caught unhandled signal %d", signo);
+ ret = TRUE;
- break;
- }
+ break;
+ }
- return ret;
+ return ret;
}
static void
on_slave_stopped (GdmSlave *slave,
- GMainLoop *main_loop)
+ GMainLoop *main_loop)
{
- g_debug ("slave finished");
- gdm_return_code = 0;
- g_main_loop_quit (main_loop);
+ g_debug ("slave finished");
+ gdm_return_code = 0;
+ g_main_loop_quit (main_loop);
}
int
main (int argc,
char **argv)
{
- GMainLoop *main_loop;
- GOptionContext *context;
- DBusGConnection *connection;
- GdmSlave *slave;
- static char *display_id = NULL;
- GdmSignalHandler *signal_handler;
- static GOptionEntry entries [] = {
- { "display-id", 0, 0, G_OPTION_ARG_STRING, &display_id, N_("Display ID"), N_("id") },
- { NULL }
- };
-
- bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
- textdomain (GETTEXT_PACKAGE);
- setlocale (LC_ALL, "");
-
- g_type_init ();
-
- context = g_option_context_new (_("GNOME Display Manager Slave"));
- g_option_context_add_main_entries (context, entries, NULL);
-
- g_option_context_parse (context, &argc, &argv, NULL);
- g_option_context_free (context);
-
- connection = get_system_bus ();
- if (connection == NULL) {
- goto out;
- }
-
- gdm_log_init ();
-
- gdm_log_set_debug (TRUE);
-
- if (display_id == NULL) {
- g_critical ("No display ID set");
- exit (1);
- }
-
- main_loop = g_main_loop_new (NULL, FALSE);
-
- signal_handler = gdm_signal_handler_new ();
- gdm_signal_handler_set_main_loop (signal_handler, main_loop);
- gdm_signal_handler_add (signal_handler, SIGTERM, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGINT, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGILL, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGBUS, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGFPE, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGHUP, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGSEGV, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGABRT, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGUSR1, signal_cb, NULL);
-
- slave = gdm_factory_slave_new (display_id);
- if (slave == NULL) {
- goto out;
- }
- g_signal_connect (slave,
- "stopped",
- G_CALLBACK (on_slave_stopped),
- main_loop);
- gdm_slave_start (slave);
-
- g_main_loop_run (main_loop);
-
- if (slave != NULL) {
- g_object_unref (slave);
- }
-
- if (signal_handler != NULL) {
- g_object_unref (signal_handler);
- }
-
- if (main_loop != NULL) {
- g_main_loop_unref (main_loop);
- }
+ GMainLoop *main_loop;
+ GOptionContext *context;
+ DBusGConnection *connection;
+ GdmSlave *slave;
+ static char *display_id = NULL;
+ GdmSignalHandler *signal_handler;
+ static GOptionEntry entries [] = {
+ { "display-id", 0, 0, G_OPTION_ARG_STRING, &display_id, N_("Display ID"), N_("id") },
+ { NULL }
+ };
+
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ textdomain (GETTEXT_PACKAGE);
+ setlocale (LC_ALL, "");
+
+ g_type_init ();
+
+ context = g_option_context_new (_("GNOME Display Manager Slave"));
+ g_option_context_add_main_entries (context, entries, NULL);
+
+ g_option_context_parse (context, &argc, &argv, NULL);
+ g_option_context_free (context);
+
+ connection = get_system_bus ();
+ if (connection == NULL) {
+ goto out;
+ }
+
+ gdm_log_init ();
+
+ gdm_log_set_debug (TRUE);
+
+ if (display_id == NULL) {
+ g_critical ("No display ID set");
+ exit (1);
+ }
+
+ main_loop = g_main_loop_new (NULL, FALSE);
+
+ signal_handler = gdm_signal_handler_new ();
+ gdm_signal_handler_set_main_loop (signal_handler, main_loop);
+ gdm_signal_handler_add (signal_handler, SIGTERM, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGINT, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGILL, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGBUS, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGFPE, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGHUP, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGSEGV, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGABRT, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGUSR1, signal_cb, NULL);
+
+ slave = gdm_factory_slave_new (display_id);
+ if (slave == NULL) {
+ goto out;
+ }
+ g_signal_connect (slave,
+ "stopped",
+ G_CALLBACK (on_slave_stopped),
+ main_loop);
+ gdm_slave_start (slave);
+
+ g_main_loop_run (main_loop);
+
+ if (slave != NULL) {
+ g_object_unref (slave);
+ }
+
+ if (signal_handler != NULL) {
+ g_object_unref (signal_handler);
+ }
+
+ if (main_loop != NULL) {
+ g_main_loop_unref (main_loop);
+ }
out:
- g_debug ("Slave finished");
+ g_debug ("Slave finished");
- return gdm_return_code;
+ return gdm_return_code;
}
diff --git a/daemon/filecheck.c b/daemon/filecheck.c
index 69b164d4..30bac2d3 100644
--- a/daemon/filecheck.c
+++ b/daemon/filecheck.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* GDM - The GNOME Display Manager
* Copyright (C) 1998, 1999, 2000 Martin K. Petersen <mkp@mkp.net>
@@ -46,100 +46,100 @@ gboolean
gdm_file_check (const gchar *caller,
uid_t user,
const gchar *dir,
- const gchar *file,
+ const gchar *file,
gboolean absentok,
- gboolean absentdirok,
+ gboolean absentdirok,
gint maxsize,
gint perms)
{
- struct stat statbuf;
- gchar *fullpath;
- gchar *dirautofs;
- int r;
-
- if (ve_string_empty (dir) ||
- ve_string_empty (file))
- return FALSE;
-
-
- VE_IGNORE_EINTR (r = stat (dir, &statbuf));
-
- if (r < 0) {
- if ( ! absentdirok)
- g_warning (_("%s: Directory %s does not exist."),
- caller, dir);
- return FALSE;
- }
-
- /* ... if group has write permission ... */
- if G_UNLIKELY (perms < 1 && (statbuf.st_mode & S_IWGRP) == S_IWGRP) {
- g_warning (_("%s: %s is writable by group."), caller, dir);
- return FALSE;
- }
-
- /* ... and if others have write permission. */
- if G_UNLIKELY (perms < 2 && (statbuf.st_mode & S_IWOTH) == S_IWOTH) {
- g_warning (_("%s: %s is writable by other."), caller, dir);
- return FALSE;
- }
-
- fullpath = g_build_filename (dir, file, NULL);
-
- /* Stat file */
- VE_IGNORE_EINTR (r = g_stat (fullpath, &statbuf));
- if (r < 0) {
- /* Return true if file does not exist and that is ok */
- if (absentok) {
- g_free (fullpath);
- return TRUE;
- }
- else {
- g_warning (_("%s: %s does not exist but must exist."), caller, fullpath);
- g_free (fullpath);
- return FALSE;
- }
- }
-
- /* Check that it is a regular file ... */
- if G_UNLIKELY (! S_ISREG (statbuf.st_mode)) {
- g_warning (_("%s: %s is not a regular file."), caller, fullpath);
- g_free (fullpath);
- return FALSE;
- }
-
- /* ... owned by the user ... */
- if G_UNLIKELY (statbuf.st_uid != user) {
- g_warning (_("%s: %s is not owned by uid %d."), caller, fullpath, user);
- g_free (fullpath);
- return FALSE;
- }
-
- /* ... unwritable by group ... */
- if G_UNLIKELY (perms < 1 && (statbuf.st_mode & S_IWGRP) == S_IWGRP) {
- g_warning (_("%s: %s is writable by group."), caller, fullpath);
- g_free (fullpath);
- return FALSE;
- }
-
- /* ... unwritable by others ... */
- if G_UNLIKELY (perms < 2 && (statbuf.st_mode & S_IWOTH) == S_IWOTH) {
- g_warning (_("%s: %s is writable by group/other."), caller, fullpath);
- g_free (fullpath);
- return FALSE;
- }
-
- /* ... and smaller than sysadmin specified limit. */
- if G_UNLIKELY (maxsize && statbuf.st_size > maxsize) {
- g_warning (_("%s: %s is bigger than sysadmin specified maximum file size."),
- caller, fullpath);
- g_free (fullpath);
- return FALSE;
- }
-
- g_free (fullpath);
-
- /* Yeap, this file is ok */
- return TRUE;
+ struct stat statbuf;
+ gchar *fullpath;
+ gchar *dirautofs;
+ int r;
+
+ if (ve_string_empty (dir) ||
+ ve_string_empty (file))
+ return FALSE;
+
+
+ VE_IGNORE_EINTR (r = stat (dir, &statbuf));
+
+ if (r < 0) {
+ if ( ! absentdirok)
+ g_warning (_("%s: Directory %s does not exist."),
+ caller, dir);
+ return FALSE;
+ }
+
+ /* ... if group has write permission ... */
+ if G_UNLIKELY (perms < 1 && (statbuf.st_mode & S_IWGRP) == S_IWGRP) {
+ g_warning (_("%s: %s is writable by group."), caller, dir);
+ return FALSE;
+ }
+
+ /* ... and if others have write permission. */
+ if G_UNLIKELY (perms < 2 && (statbuf.st_mode & S_IWOTH) == S_IWOTH) {
+ g_warning (_("%s: %s is writable by other."), caller, dir);
+ return FALSE;
+ }
+
+ fullpath = g_build_filename (dir, file, NULL);
+
+ /* Stat file */
+ VE_IGNORE_EINTR (r = g_stat (fullpath, &statbuf));
+ if (r < 0) {
+ /* Return true if file does not exist and that is ok */
+ if (absentok) {
+ g_free (fullpath);
+ return TRUE;
+ }
+ else {
+ g_warning (_("%s: %s does not exist but must exist."), caller, fullpath);
+ g_free (fullpath);
+ return FALSE;
+ }
+ }
+
+ /* Check that it is a regular file ... */
+ if G_UNLIKELY (! S_ISREG (statbuf.st_mode)) {
+ g_warning (_("%s: %s is not a regular file."), caller, fullpath);
+ g_free (fullpath);
+ return FALSE;
+ }
+
+ /* ... owned by the user ... */
+ if G_UNLIKELY (statbuf.st_uid != user) {
+ g_warning (_("%s: %s is not owned by uid %d."), caller, fullpath, user);
+ g_free (fullpath);
+ return FALSE;
+ }
+
+ /* ... unwritable by group ... */
+ if G_UNLIKELY (perms < 1 && (statbuf.st_mode & S_IWGRP) == S_IWGRP) {
+ g_warning (_("%s: %s is writable by group."), caller, fullpath);
+ g_free (fullpath);
+ return FALSE;
+ }
+
+ /* ... unwritable by others ... */
+ if G_UNLIKELY (perms < 2 && (statbuf.st_mode & S_IWOTH) == S_IWOTH) {
+ g_warning (_("%s: %s is writable by group/other."), caller, fullpath);
+ g_free (fullpath);
+ return FALSE;
+ }
+
+ /* ... and smaller than sysadmin specified limit. */
+ if G_UNLIKELY (maxsize && statbuf.st_size > maxsize) {
+ g_warning (_("%s: %s is bigger than sysadmin specified maximum file size."),
+ caller, fullpath);
+ g_free (fullpath);
+ return FALSE;
+ }
+
+ g_free (fullpath);
+
+ /* Yeap, this file is ok */
+ return TRUE;
}
/* we should be euid the user BTW */
@@ -150,42 +150,42 @@ gdm_auth_file_check (const gchar *caller,
gboolean absentok,
struct stat *s)
{
- struct stat statbuf;
- gint usermaxfile;
- int r;
-
- if (ve_string_empty (authfile))
- return FALSE;
-
- /* Stat file */
- VE_IGNORE_EINTR (r = g_lstat (authfile, &statbuf));
- if (s != NULL)
- *s = statbuf;
- if (r < 0) {
- if (absentok)
- return TRUE;
- g_warning (_("%s: %s does not exist but must exist."), caller, authfile);
- return FALSE;
- }
-
- /* Check that it is a regular file ... */
- if G_UNLIKELY (! S_ISREG (statbuf.st_mode)) {
- g_warning (_("%s: %s is not a regular file."), caller, authfile);
- return FALSE;
- }
-
- /* ... owned by the user ... */
- if G_UNLIKELY (statbuf.st_uid != user) {
- g_warning (_("%s: %s is not owned by uid %d."), caller, authfile, user);
- return FALSE;
- }
-
- /* ... has right permissions ... */
- if G_UNLIKELY (statbuf.st_mode & 0077) {
- g_warning ("%s: %s has wrong permissions (should be 0600)", caller, authfile);
- return FALSE;
- }
-
- /* Yeap, this file is ok */
- return TRUE;
+ struct stat statbuf;
+ gint usermaxfile;
+ int r;
+
+ if (ve_string_empty (authfile))
+ return FALSE;
+
+ /* Stat file */
+ VE_IGNORE_EINTR (r = g_lstat (authfile, &statbuf));
+ if (s != NULL)
+ *s = statbuf;
+ if (r < 0) {
+ if (absentok)
+ return TRUE;
+ g_warning (_("%s: %s does not exist but must exist."), caller, authfile);
+ return FALSE;
+ }
+
+ /* Check that it is a regular file ... */
+ if G_UNLIKELY (! S_ISREG (statbuf.st_mode)) {
+ g_warning (_("%s: %s is not a regular file."), caller, authfile);
+ return FALSE;
+ }
+
+ /* ... owned by the user ... */
+ if G_UNLIKELY (statbuf.st_uid != user) {
+ g_warning (_("%s: %s is not owned by uid %d."), caller, authfile, user);
+ return FALSE;
+ }
+
+ /* ... has right permissions ... */
+ if G_UNLIKELY (statbuf.st_mode & 0077) {
+ g_warning ("%s: %s has wrong permissions (should be 0600)", caller, authfile);
+ return FALSE;
+ }
+
+ /* Yeap, this file is ok */
+ return TRUE;
}
diff --git a/daemon/filecheck.h b/daemon/filecheck.h
index 7d71a691..48a0c1d3 100644
--- a/daemon/filecheck.h
+++ b/daemon/filecheck.h
@@ -20,9 +20,9 @@
#define GDM_FILECHECK_H
gboolean gdm_file_check (const gchar *caller, uid_t user, const gchar *dir,
- const gchar *file, gboolean absentok,
- gboolean absentdirok, gint maxsize,
- gint perms);
+ const gchar *file, gboolean absentok,
+ gboolean absentdirok, gint maxsize,
+ gint perms);
/* more paranoid on the file itself, doesn't check directory (for all we know
it could be /tmp) */
diff --git a/daemon/gdm-display-factory.c b/daemon/gdm-display-factory.c
index 3cad7dc9..4253f10e 100644
--- a/daemon/gdm-display-factory.c
+++ b/daemon/gdm-display-factory.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -34,158 +34,158 @@
struct GdmDisplayFactoryPrivate
{
- GdmDisplayStore *display_store;
+ GdmDisplayStore *display_store;
};
enum {
- PROP_0,
- PROP_DISPLAY_STORE,
+ PROP_0,
+ PROP_DISPLAY_STORE,
};
-static void gdm_display_factory_class_init (GdmDisplayFactoryClass *klass);
-static void gdm_display_factory_init (GdmDisplayFactory *factory);
-static void gdm_display_factory_finalize (GObject *object);
+static void gdm_display_factory_class_init (GdmDisplayFactoryClass *klass);
+static void gdm_display_factory_init (GdmDisplayFactory *factory);
+static void gdm_display_factory_finalize (GObject *object);
G_DEFINE_ABSTRACT_TYPE (GdmDisplayFactory, gdm_display_factory, G_TYPE_OBJECT)
GQuark
gdm_display_factory_error_quark (void)
{
- static GQuark ret = 0;
- if (ret == 0) {
- ret = g_quark_from_static_string ("gdm_display_factory_error");
- }
+ static GQuark ret = 0;
+ if (ret == 0) {
+ ret = g_quark_from_static_string ("gdm_display_factory_error");
+ }
- return ret;
+ return ret;
}
GdmDisplayStore *
gdm_display_factory_get_display_store (GdmDisplayFactory *factory)
{
- g_return_val_if_fail (GDM_IS_DISPLAY_FACTORY (factory), NULL);
+ g_return_val_if_fail (GDM_IS_DISPLAY_FACTORY (factory), NULL);
- return factory->priv->display_store;
+ return factory->priv->display_store;
}
gboolean
gdm_display_factory_start (GdmDisplayFactory *factory)
{
- gboolean ret;
+ gboolean ret;
- g_return_val_if_fail (GDM_IS_DISPLAY_FACTORY (factory), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY_FACTORY (factory), FALSE);
- g_object_ref (factory);
- ret = GDM_DISPLAY_FACTORY_GET_CLASS (factory)->start (factory);
- g_object_unref (factory);
+ g_object_ref (factory);
+ ret = GDM_DISPLAY_FACTORY_GET_CLASS (factory)->start (factory);
+ g_object_unref (factory);
- return ret;
+ return ret;
}
gboolean
gdm_display_factory_stop (GdmDisplayFactory *factory)
{
- gboolean ret;
+ gboolean ret;
- g_return_val_if_fail (GDM_IS_DISPLAY_FACTORY (factory), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY_FACTORY (factory), FALSE);
- g_object_ref (factory);
- ret = GDM_DISPLAY_FACTORY_GET_CLASS (factory)->stop (factory);
- g_object_unref (factory);
+ g_object_ref (factory);
+ ret = GDM_DISPLAY_FACTORY_GET_CLASS (factory)->stop (factory);
+ g_object_unref (factory);
- return ret;
+ return ret;
}
static void
gdm_display_factory_set_display_store (GdmDisplayFactory *factory,
- GdmDisplayStore *display_store)
+ GdmDisplayStore *display_store)
{
- if (factory->priv->display_store != NULL) {
- g_object_unref (factory->priv->display_store);
- factory->priv->display_store = NULL;
- }
-
- if (display_store != NULL) {
- factory->priv->display_store = g_object_ref (display_store);
- }
+ if (factory->priv->display_store != NULL) {
+ g_object_unref (factory->priv->display_store);
+ factory->priv->display_store = NULL;
+ }
+
+ if (display_store != NULL) {
+ factory->priv->display_store = g_object_ref (display_store);
+ }
}
static void
gdm_display_factory_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GdmDisplayFactory *self;
-
- self = GDM_DISPLAY_FACTORY (object);
-
- switch (prop_id) {
- case PROP_DISPLAY_STORE:
- gdm_display_factory_set_display_store (self, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GdmDisplayFactory *self;
+
+ self = GDM_DISPLAY_FACTORY (object);
+
+ switch (prop_id) {
+ case PROP_DISPLAY_STORE:
+ gdm_display_factory_set_display_store (self, g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_display_factory_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GdmDisplayFactory *self;
-
- self = GDM_DISPLAY_FACTORY (object);
-
- switch (prop_id) {
- case PROP_DISPLAY_STORE:
- g_value_set_object (value, self->priv->display_store);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GdmDisplayFactory *self;
+
+ self = GDM_DISPLAY_FACTORY (object);
+
+ switch (prop_id) {
+ case PROP_DISPLAY_STORE:
+ g_value_set_object (value, self->priv->display_store);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_display_factory_class_init (GdmDisplayFactoryClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->get_property = gdm_display_factory_get_property;
- object_class->set_property = gdm_display_factory_set_property;
- object_class->finalize = gdm_display_factory_finalize;
+ object_class->get_property = gdm_display_factory_get_property;
+ object_class->set_property = gdm_display_factory_set_property;
+ object_class->finalize = gdm_display_factory_finalize;
g_object_class_install_property (object_class,
PROP_DISPLAY_STORE,
g_param_spec_object ("display-store",
- "display store",
- "display store",
- GDM_TYPE_DISPLAY_STORE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ "display store",
+ "display store",
+ GDM_TYPE_DISPLAY_STORE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_type_class_add_private (klass, sizeof (GdmDisplayFactoryPrivate));
+ g_type_class_add_private (klass, sizeof (GdmDisplayFactoryPrivate));
}
static void
gdm_display_factory_init (GdmDisplayFactory *factory)
{
- factory->priv = GDM_DISPLAY_FACTORY_GET_PRIVATE (factory);
+ factory->priv = GDM_DISPLAY_FACTORY_GET_PRIVATE (factory);
}
static void
gdm_display_factory_finalize (GObject *object)
{
- GdmDisplayFactory *factory;
+ GdmDisplayFactory *factory;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_DISPLAY_FACTORY (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_DISPLAY_FACTORY (object));
- factory = GDM_DISPLAY_FACTORY (object);
+ factory = GDM_DISPLAY_FACTORY (object);
- g_return_if_fail (factory->priv != NULL);
+ g_return_if_fail (factory->priv != NULL);
- G_OBJECT_CLASS (gdm_display_factory_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_display_factory_parent_class)->finalize (object);
}
diff --git a/daemon/gdm-display-factory.h b/daemon/gdm-display-factory.h
index f743e75a..c7d39262 100644
--- a/daemon/gdm-display-factory.h
+++ b/daemon/gdm-display-factory.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -39,27 +39,27 @@ typedef struct GdmDisplayFactoryPrivate GdmDisplayFactoryPrivate;
typedef struct
{
- GObject parent;
- GdmDisplayFactoryPrivate *priv;
+ GObject parent;
+ GdmDisplayFactoryPrivate *priv;
} GdmDisplayFactory;
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
- gboolean (*start) (GdmDisplayFactory *factory);
- gboolean (*stop) (GdmDisplayFactory *factory);
+ gboolean (*start) (GdmDisplayFactory *factory);
+ gboolean (*stop) (GdmDisplayFactory *factory);
} GdmDisplayFactoryClass;
typedef enum
{
- GDM_DISPLAY_FACTORY_ERROR_GENERAL
+ GDM_DISPLAY_FACTORY_ERROR_GENERAL
} GdmDisplayFactoryError;
#define GDM_DISPLAY_FACTORY_ERROR gdm_display_factory_error_quark ()
-GQuark gdm_display_factory_error_quark (void);
-GType gdm_display_factory_get_type (void);
+GQuark gdm_display_factory_error_quark (void);
+GType gdm_display_factory_get_type (void);
gboolean gdm_display_factory_start (GdmDisplayFactory *manager);
gboolean gdm_display_factory_stop (GdmDisplayFactory *manager);
diff --git a/daemon/gdm-display-store.c b/daemon/gdm-display-store.c
index 44a0a113..4943d218 100644
--- a/daemon/gdm-display-store.c
+++ b/daemon/gdm-display-store.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -37,176 +37,176 @@
struct GdmDisplayStorePrivate
{
- GHashTable *displays;
+ GHashTable *displays;
};
enum {
- DISPLAY_ADDED,
- DISPLAY_REMOVED,
- LAST_SIGNAL
+ DISPLAY_ADDED,
+ DISPLAY_REMOVED,
+ LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0, };
-static void gdm_display_store_class_init (GdmDisplayStoreClass *klass);
-static void gdm_display_store_init (GdmDisplayStore *display_store);
-static void gdm_display_store_finalize (GObject *object);
+static void gdm_display_store_class_init (GdmDisplayStoreClass *klass);
+static void gdm_display_store_init (GdmDisplayStore *display_store);
+static void gdm_display_store_finalize (GObject *object);
G_DEFINE_TYPE (GdmDisplayStore, gdm_display_store, G_TYPE_OBJECT)
GQuark
gdm_display_store_error_quark (void)
{
- static GQuark ret = 0;
- if (ret == 0) {
- ret = g_quark_from_static_string ("gdm_display_store_error");
- }
+ static GQuark ret = 0;
+ if (ret == 0) {
+ ret = g_quark_from_static_string ("gdm_display_store_error");
+ }
- return ret;
+ return ret;
}
void
gdm_display_store_clear (GdmDisplayStore *store)
{
- g_debug ("Clearing display store");
- g_hash_table_remove_all (store->priv->displays);
+ g_debug ("Clearing display store");
+ g_hash_table_remove_all (store->priv->displays);
}
gboolean
gdm_display_store_remove (GdmDisplayStore *store,
- GdmDisplay *display)
+ GdmDisplay *display)
{
- g_warning ("Implement me");
- return FALSE;
+ g_warning ("Implement me");
+ return FALSE;
}
void
gdm_display_store_foreach (GdmDisplayStore *store,
- GdmDisplayStoreFunc func,
- gpointer user_data)
+ GdmDisplayStoreFunc func,
+ gpointer user_data)
{
- g_return_if_fail (store != NULL);
- g_return_if_fail (func != NULL);
+ g_return_if_fail (store != NULL);
+ g_return_if_fail (func != NULL);
- g_hash_table_find (store->priv->displays,
- (GHRFunc)func,
- user_data);
+ g_hash_table_find (store->priv->displays,
+ (GHRFunc)func,
+ user_data);
}
GdmDisplay *
gdm_display_store_find (GdmDisplayStore *store,
- GdmDisplayStoreFunc predicate,
- gpointer user_data)
+ GdmDisplayStoreFunc predicate,
+ gpointer user_data)
{
- GdmDisplay *display;
+ GdmDisplay *display;
- g_return_val_if_fail (store != NULL, NULL);
- g_return_val_if_fail (predicate != NULL, NULL);
+ g_return_val_if_fail (store != NULL, NULL);
+ g_return_val_if_fail (predicate != NULL, NULL);
- display = g_hash_table_find (store->priv->displays,
- (GHRFunc)predicate,
- user_data);
- return display;
+ display = g_hash_table_find (store->priv->displays,
+ (GHRFunc)predicate,
+ user_data);
+ return display;
}
guint
gdm_display_store_foreach_remove (GdmDisplayStore *store,
- GdmDisplayStoreFunc func,
- gpointer user_data)
+ GdmDisplayStoreFunc func,
+ gpointer user_data)
{
- guint ret;
+ guint ret;
- g_return_val_if_fail (store != NULL, 0);
- g_return_val_if_fail (func != NULL, 0);
+ g_return_val_if_fail (store != NULL, 0);
+ g_return_val_if_fail (func != NULL, 0);
- ret = g_hash_table_foreach_remove (store->priv->displays,
- (GHRFunc)func,
- user_data);
+ ret = g_hash_table_foreach_remove (store->priv->displays,
+ (GHRFunc)func,
+ user_data);
- return ret;
+ return ret;
}
void
gdm_display_store_add (GdmDisplayStore *store,
- GdmDisplay *display)
+ GdmDisplay *display)
{
- char *id;
+ char *id;
- g_return_if_fail (store != NULL);
- g_return_if_fail (display != NULL);
+ g_return_if_fail (store != NULL);
+ g_return_if_fail (display != NULL);
- gdm_display_get_id (display, &id, NULL);
+ gdm_display_get_id (display, &id, NULL);
- g_debug ("Adding display %s to store", id);
+ g_debug ("Adding display %s to store", id);
- g_hash_table_insert (store->priv->displays,
- id,
- g_object_ref (display));
+ g_hash_table_insert (store->priv->displays,
+ id,
+ g_object_ref (display));
}
static void
gdm_display_store_class_init (GdmDisplayStoreClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = gdm_display_store_finalize;
-
- signals [DISPLAY_ADDED] =
- g_signal_new ("display-added",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdmDisplayStoreClass, display_added),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1, G_TYPE_STRING);
- signals [DISPLAY_REMOVED] =
- g_signal_new ("display-removed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdmDisplayStoreClass, display_removed),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1, G_TYPE_STRING);
-
- g_type_class_add_private (klass, sizeof (GdmDisplayStorePrivate));
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gdm_display_store_finalize;
+
+ signals [DISPLAY_ADDED] =
+ g_signal_new ("display-added",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdmDisplayStoreClass, display_added),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1, G_TYPE_STRING);
+ signals [DISPLAY_REMOVED] =
+ g_signal_new ("display-removed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdmDisplayStoreClass, display_removed),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1, G_TYPE_STRING);
+
+ g_type_class_add_private (klass, sizeof (GdmDisplayStorePrivate));
}
static void
display_unref (GdmDisplay *display)
{
- g_debug ("Unreffing display: %p", display);
- g_object_unref (display);
+ g_debug ("Unreffing display: %p", display);
+ g_object_unref (display);
}
static void
gdm_display_store_init (GdmDisplayStore *store)
{
- store->priv = GDM_DISPLAY_STORE_GET_PRIVATE (store);
+ store->priv = GDM_DISPLAY_STORE_GET_PRIVATE (store);
- store->priv->displays = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- (GDestroyNotify) display_unref);
+ store->priv->displays = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ (GDestroyNotify) display_unref);
}
static void
gdm_display_store_finalize (GObject *object)
{
- GdmDisplayStore *display_store;
+ GdmDisplayStore *display_store;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_DISPLAY_STORE (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_DISPLAY_STORE (object));
- display_store = GDM_DISPLAY_STORE (object);
+ display_store = GDM_DISPLAY_STORE (object);
- g_return_if_fail (display_store->priv != NULL);
+ g_return_if_fail (display_store->priv != NULL);
- G_OBJECT_CLASS (gdm_display_store_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_display_store_parent_class)->finalize (object);
}
GdmDisplayStore *
diff --git a/daemon/gdm-display-store.h b/daemon/gdm-display-store.h
index 1d014466..dcd88149 100644
--- a/daemon/gdm-display-store.h
+++ b/daemon/gdm-display-store.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -38,50 +38,50 @@ typedef struct GdmDisplayStorePrivate GdmDisplayStorePrivate;
typedef struct
{
- GObject parent;
- GdmDisplayStorePrivate *priv;
+ GObject parent;
+ GdmDisplayStorePrivate *priv;
} GdmDisplayStore;
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
- void (* display_added) (GdmDisplayStore *display_store,
- const char *id);
- void (* display_removed) (GdmDisplayStore *display_store,
- const char *id);
+ void (* display_added) (GdmDisplayStore *display_store,
+ const char *id);
+ void (* display_removed) (GdmDisplayStore *display_store,
+ const char *id);
} GdmDisplayStoreClass;
typedef enum
{
- GDM_DISPLAY_STORE_ERROR_GENERAL
+ GDM_DISPLAY_STORE_ERROR_GENERAL
} GdmDisplayStoreError;
#define GDM_DISPLAY_STORE_ERROR gdm_display_store_error_quark ()
typedef gboolean (*GdmDisplayStoreFunc) (const char *id,
- GdmDisplay *display,
- gpointer user_data);
+ GdmDisplay *display,
+ gpointer user_data);
-GQuark gdm_display_store_error_quark (void);
-GType gdm_display_store_get_type (void);
+GQuark gdm_display_store_error_quark (void);
+GType gdm_display_store_get_type (void);
-GdmDisplayStore * gdm_display_store_new (void);
+GdmDisplayStore * gdm_display_store_new (void);
void gdm_display_store_add (GdmDisplayStore *store,
- GdmDisplay *display);
+ GdmDisplay *display);
void gdm_display_store_clear (GdmDisplayStore *store);
gboolean gdm_display_store_remove (GdmDisplayStore *store,
- GdmDisplay *display);
+ GdmDisplay *display);
void gdm_display_store_foreach (GdmDisplayStore *store,
- GdmDisplayStoreFunc func,
- gpointer user_data);
+ GdmDisplayStoreFunc func,
+ gpointer user_data);
guint gdm_display_store_foreach_remove (GdmDisplayStore *store,
- GdmDisplayStoreFunc func,
- gpointer user_data);
+ GdmDisplayStoreFunc func,
+ gpointer user_data);
GdmDisplay * gdm_display_store_find (GdmDisplayStore *store,
- GdmDisplayStoreFunc predicate,
- gpointer user_data);
+ GdmDisplayStoreFunc predicate,
+ gpointer user_data);
G_END_DECLS
diff --git a/daemon/gdm-display.c b/daemon/gdm-display.c
index 2d348084..0278230e 100644
--- a/daemon/gdm-display.c
+++ b/daemon/gdm-display.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -48,220 +48,220 @@ static guint32 display_serial = 1;
struct GdmDisplayPrivate
{
- char *id;
- char *seat_id;
+ char *id;
+ char *seat_id;
- char *remote_hostname;
- int x11_display_number;
- char *x11_display_name;
- int status;
- time_t creation_time;
- char *x11_cookie;
- char *x11_authority_file;
- char *slave_command;
+ char *remote_hostname;
+ int x11_display_number;
+ char *x11_display_name;
+ int status;
+ time_t creation_time;
+ char *x11_cookie;
+ char *x11_authority_file;
+ char *slave_command;
- gboolean is_local;
- guint finish_idle_id;
+ gboolean is_local;
+ guint finish_idle_id;
- GdmSlaveProxy *slave_proxy;
+ GdmSlaveProxy *slave_proxy;
DBusGConnection *connection;
};
enum {
- PROP_0,
- PROP_ID,
- PROP_SEAT_ID,
- PROP_REMOTE_HOSTNAME,
- PROP_X11_DISPLAY_NUMBER,
- PROP_X11_DISPLAY_NAME,
- PROP_X11_COOKIE,
- PROP_X11_AUTHORITY_FILE,
- PROP_IS_LOCAL,
- PROP_SLAVE_COMMAND,
+ PROP_0,
+ PROP_ID,
+ PROP_SEAT_ID,
+ PROP_REMOTE_HOSTNAME,
+ PROP_X11_DISPLAY_NUMBER,
+ PROP_X11_DISPLAY_NAME,
+ PROP_X11_COOKIE,
+ PROP_X11_AUTHORITY_FILE,
+ PROP_IS_LOCAL,
+ PROP_SLAVE_COMMAND,
};
-static void gdm_display_class_init (GdmDisplayClass *klass);
-static void gdm_display_init (GdmDisplay *display);
-static void gdm_display_finalize (GObject *object);
+static void gdm_display_class_init (GdmDisplayClass *klass);
+static void gdm_display_init (GdmDisplay *display);
+static void gdm_display_finalize (GObject *object);
G_DEFINE_ABSTRACT_TYPE (GdmDisplay, gdm_display, G_TYPE_OBJECT)
GQuark
gdm_display_error_quark (void)
{
- static GQuark ret = 0;
- if (ret == 0) {
- ret = g_quark_from_static_string ("gdm_display_error");
- }
+ static GQuark ret = 0;
+ if (ret == 0) {
+ ret = g_quark_from_static_string ("gdm_display_error");
+ }
- return ret;
+ return ret;
}
static guint32
get_next_display_serial (void)
{
- guint32 serial;
+ guint32 serial;
- serial = display_serial++;
+ serial = display_serial++;
- if ((gint32)display_serial < 0) {
- display_serial = 1;
- }
+ if ((gint32)display_serial < 0) {
+ display_serial = 1;
+ }
- return serial;
+ return serial;
}
time_t
gdm_display_get_creation_time (GdmDisplay *display)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), 0);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), 0);
- return display->priv->creation_time;
+ return display->priv->creation_time;
}
int
gdm_display_get_status (GdmDisplay *display)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), 0);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), 0);
- return display->priv->status;
+ return display->priv->status;
}
static gboolean
gdm_display_real_create_authority (GdmDisplay *display)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- return TRUE;
+ return TRUE;
}
gboolean
gdm_display_create_authority (GdmDisplay *display)
{
- gboolean ret;
+ gboolean ret;
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- g_object_ref (display);
- ret = GDM_DISPLAY_GET_CLASS (display)->create_authority (display);
- g_object_unref (display);
+ g_object_ref (display);
+ ret = GDM_DISPLAY_GET_CLASS (display)->create_authority (display);
+ g_object_unref (display);
- return ret;
+ return ret;
}
static gboolean
gdm_display_real_add_user_authorization (GdmDisplay *display,
- const char *username,
- char **filename,
- GError **error)
+ const char *username,
+ char **filename,
+ GError **error)
{
- gboolean ret;
+ gboolean ret;
- ret = FALSE;
+ ret = FALSE;
- return ret;
+ return ret;
}
gboolean
gdm_display_add_user_authorization (GdmDisplay *display,
- const char *username,
- char **filename,
- GError **error)
+ const char *username,
+ char **filename,
+ GError **error)
{
- gboolean ret;
+ gboolean ret;
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- g_debug ("Adding authorization for user:%s on display %s", username, display->priv->x11_display_name);
+ g_debug ("Adding authorization for user:%s on display %s", username, display->priv->x11_display_name);
- g_object_ref (display);
- ret = GDM_DISPLAY_GET_CLASS (display)->add_user_authorization (display, username, filename, error);
- g_object_unref (display);
+ g_object_ref (display);
+ ret = GDM_DISPLAY_GET_CLASS (display)->add_user_authorization (display, username, filename, error);
+ g_object_unref (display);
- return ret;
+ return ret;
}
static gboolean
gdm_display_real_remove_user_authorization (GdmDisplay *display,
- const char *username,
- GError **error)
+ const char *username,
+ GError **error)
{
- gboolean ret;
+ gboolean ret;
- ret = FALSE;
+ ret = FALSE;
- return ret;
+ return ret;
}
gboolean
gdm_display_remove_user_authorization (GdmDisplay *display,
- const char *username,
- GError **error)
+ const char *username,
+ GError **error)
{
- gboolean ret;
+ gboolean ret;
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- g_debug ("Removing authorization for user:%s on display %s", username, display->priv->x11_display_name);
+ g_debug ("Removing authorization for user:%s on display %s", username, display->priv->x11_display_name);
- g_object_ref (display);
- ret = GDM_DISPLAY_GET_CLASS (display)->remove_user_authorization (display, username, error);
- g_object_unref (display);
+ g_object_ref (display);
+ ret = GDM_DISPLAY_GET_CLASS (display)->remove_user_authorization (display, username, error);
+ g_object_unref (display);
- return ret;
+ return ret;
}
gboolean
gdm_display_get_x11_cookie (GdmDisplay *display,
- char **x11_cookie,
- GError **error)
+ char **x11_cookie,
+ GError **error)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- if (x11_cookie != NULL) {
- *x11_cookie = g_strdup (display->priv->x11_cookie);
- }
+ if (x11_cookie != NULL) {
+ *x11_cookie = g_strdup (display->priv->x11_cookie);
+ }
- return TRUE;
+ return TRUE;
}
gboolean
gdm_display_get_x11_authority_file (GdmDisplay *display,
- char **filename,
- GError **error)
+ char **filename,
+ GError **error)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- if (filename != NULL) {
- *filename = g_strdup (display->priv->x11_authority_file);
- }
+ if (filename != NULL) {
+ *filename = g_strdup (display->priv->x11_authority_file);
+ }
- return TRUE;
+ return TRUE;
}
gboolean
gdm_display_get_remote_hostname (GdmDisplay *display,
- char **hostname,
- GError **error)
+ char **hostname,
+ GError **error)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- if (hostname != NULL) {
- *hostname = g_strdup (display->priv->remote_hostname);
- }
+ if (hostname != NULL) {
+ *hostname = g_strdup (display->priv->remote_hostname);
+ }
- return TRUE;
+ return TRUE;
}
gboolean
gdm_display_get_x11_display_number (GdmDisplay *display,
- int *number,
- GError **error)
+ int *number,
+ GError **error)
{
g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
if (number != NULL) {
- *number = display->priv->x11_display_number;
+ *number = display->priv->x11_display_number;
}
return TRUE;
@@ -270,198 +270,198 @@ gdm_display_get_x11_display_number (GdmDisplay *display,
static gboolean
finish_idle (GdmDisplay *display)
{
- gdm_display_finish (display);
- display->priv->finish_idle_id = 0;
- return FALSE;
+ gdm_display_finish (display);
+ display->priv->finish_idle_id = 0;
+ return FALSE;
}
static void
queue_finish (GdmDisplay *display)
{
- if (display->priv->finish_idle_id == 0) {
- display->priv->finish_idle_id = g_idle_add ((GSourceFunc)finish_idle, display);
- }
+ if (display->priv->finish_idle_id == 0) {
+ display->priv->finish_idle_id = g_idle_add ((GSourceFunc)finish_idle, display);
+ }
}
static void
slave_exited (GdmSlaveProxy *proxy,
- int code,
- GdmDisplay *display)
+ int code,
+ GdmDisplay *display)
{
- g_debug ("Slave exited: %d", code);
+ g_debug ("Slave exited: %d", code);
- queue_finish (display);
+ queue_finish (display);
}
static void
slave_died (GdmSlaveProxy *proxy,
- int signum,
- GdmDisplay *display)
+ int signum,
+ GdmDisplay *display)
{
- g_debug ("Slave died: %d", signum);
+ g_debug ("Slave died: %d", signum);
- queue_finish (display);
+ queue_finish (display);
}
static gboolean
gdm_display_real_manage (GdmDisplay *display)
{
- char *command;
+ char *command;
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- g_debug ("GdmDisplay manage display");
+ g_debug ("GdmDisplay manage display");
- display->priv->status = GDM_DISPLAY_MANAGED;
+ display->priv->status = GDM_DISPLAY_MANAGED;
- g_assert (display->priv->slave_proxy == NULL);
+ g_assert (display->priv->slave_proxy == NULL);
- display->priv->slave_proxy = gdm_slave_proxy_new ();
- g_signal_connect (display->priv->slave_proxy,
- "exited",
- G_CALLBACK (slave_exited),
- display);
- g_signal_connect (display->priv->slave_proxy,
- "died",
- G_CALLBACK (slave_died),
- display);
+ display->priv->slave_proxy = gdm_slave_proxy_new ();
+ g_signal_connect (display->priv->slave_proxy,
+ "exited",
+ G_CALLBACK (slave_exited),
+ display);
+ g_signal_connect (display->priv->slave_proxy,
+ "died",
+ G_CALLBACK (slave_died),
+ display);
- command = g_strdup_printf ("%s --display-id %s",
- display->priv->slave_command,
- display->priv->id);
+ command = g_strdup_printf ("%s --display-id %s",
+ display->priv->slave_command,
+ display->priv->id);
- gdm_slave_proxy_set_command (display->priv->slave_proxy, command);
- g_free (command);
+ gdm_slave_proxy_set_command (display->priv->slave_proxy, command);
+ g_free (command);
- gdm_slave_proxy_start (display->priv->slave_proxy);
+ gdm_slave_proxy_start (display->priv->slave_proxy);
- return TRUE;
+ return TRUE;
}
gboolean
gdm_display_manage (GdmDisplay *display)
{
- gboolean ret;
+ gboolean ret;
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- g_debug ("Managing display: %s", display->priv->id);
+ g_debug ("Managing display: %s", display->priv->id);
- g_object_ref (display);
- ret = GDM_DISPLAY_GET_CLASS (display)->manage (display);
- g_object_unref (display);
+ g_object_ref (display);
+ ret = GDM_DISPLAY_GET_CLASS (display)->manage (display);
+ g_object_unref (display);
- return ret;
+ return ret;
}
static gboolean
gdm_display_real_finish (GdmDisplay *display)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- display->priv->status = GDM_DISPLAY_FINISHED;
+ display->priv->status = GDM_DISPLAY_FINISHED;
- g_debug ("GdmDisplay finish display");
+ g_debug ("GdmDisplay finish display");
- return TRUE;
+ return TRUE;
}
gboolean
gdm_display_finish (GdmDisplay *display)
{
- gboolean ret;
+ gboolean ret;
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- g_debug ("Finishing display: %s", display->priv->id);
+ g_debug ("Finishing display: %s", display->priv->id);
- g_object_ref (display);
- ret = GDM_DISPLAY_GET_CLASS (display)->finish (display);
- g_object_unref (display);
+ g_object_ref (display);
+ ret = GDM_DISPLAY_GET_CLASS (display)->finish (display);
+ g_object_unref (display);
- return ret;
+ return ret;
}
static gboolean
gdm_display_real_unmanage (GdmDisplay *display)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- display->priv->status = GDM_DISPLAY_UNMANAGED;
+ display->priv->status = GDM_DISPLAY_UNMANAGED;
- g_debug ("GdmDisplay unmanage display");
+ g_debug ("GdmDisplay unmanage display");
- if (display->priv->slave_proxy != NULL) {
- gdm_slave_proxy_stop (display->priv->slave_proxy);
+ if (display->priv->slave_proxy != NULL) {
+ gdm_slave_proxy_stop (display->priv->slave_proxy);
- g_object_unref (display->priv->slave_proxy);
- display->priv->slave_proxy = NULL;
- }
+ g_object_unref (display->priv->slave_proxy);
+ display->priv->slave_proxy = NULL;
+ }
- return TRUE;
+ return TRUE;
}
gboolean
gdm_display_unmanage (GdmDisplay *display)
{
- gboolean ret;
+ gboolean ret;
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- g_debug ("Unmanaging display");
+ g_debug ("Unmanaging display");
- g_object_ref (display);
- ret = GDM_DISPLAY_GET_CLASS (display)->unmanage (display);
- g_object_unref (display);
+ g_object_ref (display);
+ ret = GDM_DISPLAY_GET_CLASS (display)->unmanage (display);
+ g_object_unref (display);
- return ret;
+ return ret;
}
gboolean
-gdm_display_get_id (GdmDisplay *display,
- char **id,
- GError **error)
+gdm_display_get_id (GdmDisplay *display,
+ char **id,
+ GError **error)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- if (id != NULL) {
- *id = g_strdup (display->priv->id);
- }
+ if (id != NULL) {
+ *id = g_strdup (display->priv->id);
+ }
- return TRUE;
+ return TRUE;
}
gboolean
gdm_display_get_x11_display_name (GdmDisplay *display,
- char **x11_display,
- GError **error)
+ char **x11_display,
+ GError **error)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- if (x11_display != NULL) {
- *x11_display = g_strdup (display->priv->x11_display_name);
- }
+ if (x11_display != NULL) {
+ *x11_display = g_strdup (display->priv->x11_display_name);
+ }
- return TRUE;
+ return TRUE;
}
gboolean
gdm_display_is_local (GdmDisplay *display,
- gboolean *local,
- GError **error)
+ gboolean *local,
+ GError **error)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- if (local != NULL) {
- *local = display->priv->is_local;
- }
+ if (local != NULL) {
+ *local = display->priv->is_local;
+ }
- return TRUE;
+ return TRUE;
}
static void
_gdm_display_set_id (GdmDisplay *display,
- const char *id)
+ const char *id)
{
g_free (display->priv->id);
display->priv->id = g_strdup (id);
@@ -469,7 +469,7 @@ _gdm_display_set_id (GdmDisplay *display,
static void
_gdm_display_set_seat_id (GdmDisplay *display,
- const char *seat_id)
+ const char *seat_id)
{
g_free (display->priv->seat_id);
display->priv->seat_id = g_strdup (seat_id);
@@ -477,7 +477,7 @@ _gdm_display_set_seat_id (GdmDisplay *display,
static void
_gdm_display_set_remote_hostname (GdmDisplay *display,
- const char *hostname)
+ const char *hostname)
{
g_free (display->priv->remote_hostname);
display->priv->remote_hostname = g_strdup (hostname);
@@ -485,14 +485,14 @@ _gdm_display_set_remote_hostname (GdmDisplay *display,
static void
_gdm_display_set_x11_display_number (GdmDisplay *display,
- int num)
+ int num)
{
display->priv->x11_display_number = num;
}
static void
_gdm_display_set_x11_display_name (GdmDisplay *display,
- const char *x11_display)
+ const char *x11_display)
{
g_free (display->priv->x11_display_name);
display->priv->x11_display_name = g_strdup (x11_display);
@@ -500,7 +500,7 @@ _gdm_display_set_x11_display_name (GdmDisplay *display,
static void
_gdm_display_set_x11_cookie (GdmDisplay *display,
- const char *x11_cookie)
+ const char *x11_cookie)
{
g_free (display->priv->x11_cookie);
display->priv->x11_cookie = g_strdup (x11_cookie);
@@ -508,7 +508,7 @@ _gdm_display_set_x11_cookie (GdmDisplay *display,
static void
_gdm_display_set_x11_authority_file (GdmDisplay *display,
- const char *file)
+ const char *file)
{
g_free (display->priv->x11_authority_file);
display->priv->x11_authority_file = g_strdup (file);
@@ -516,105 +516,105 @@ _gdm_display_set_x11_authority_file (GdmDisplay *display,
static void
_gdm_display_set_is_local (GdmDisplay *display,
- gboolean is_local)
+ gboolean is_local)
{
display->priv->is_local = is_local;
}
static void
_gdm_display_set_slave_command (GdmDisplay *display,
- const char *command)
+ const char *command)
{
g_free (display->priv->slave_command);
display->priv->slave_command = g_strdup (command);
}
static void
-gdm_display_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GdmDisplay *self;
-
- self = GDM_DISPLAY (object);
-
- switch (prop_id) {
- case PROP_ID:
- _gdm_display_set_id (self, g_value_get_string (value));
- break;
- case PROP_SEAT_ID:
- _gdm_display_set_seat_id (self, g_value_get_string (value));
- break;
- case PROP_REMOTE_HOSTNAME:
- _gdm_display_set_remote_hostname (self, g_value_get_string (value));
- break;
- case PROP_X11_DISPLAY_NUMBER:
- _gdm_display_set_x11_display_number (self, g_value_get_int (value));
- break;
- case PROP_X11_DISPLAY_NAME:
- _gdm_display_set_x11_display_name (self, g_value_get_string (value));
- break;
- case PROP_X11_COOKIE:
- _gdm_display_set_x11_cookie (self, g_value_get_string (value));
- break;
- case PROP_X11_AUTHORITY_FILE:
- _gdm_display_set_x11_authority_file (self, g_value_get_string (value));
- break;
- case PROP_IS_LOCAL:
- _gdm_display_set_is_local (self, g_value_get_boolean (value));
- break;
- case PROP_SLAVE_COMMAND:
- _gdm_display_set_slave_command (self, g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+gdm_display_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GdmDisplay *self;
+
+ self = GDM_DISPLAY (object);
+
+ switch (prop_id) {
+ case PROP_ID:
+ _gdm_display_set_id (self, g_value_get_string (value));
+ break;
+ case PROP_SEAT_ID:
+ _gdm_display_set_seat_id (self, g_value_get_string (value));
+ break;
+ case PROP_REMOTE_HOSTNAME:
+ _gdm_display_set_remote_hostname (self, g_value_get_string (value));
+ break;
+ case PROP_X11_DISPLAY_NUMBER:
+ _gdm_display_set_x11_display_number (self, g_value_get_int (value));
+ break;
+ case PROP_X11_DISPLAY_NAME:
+ _gdm_display_set_x11_display_name (self, g_value_get_string (value));
+ break;
+ case PROP_X11_COOKIE:
+ _gdm_display_set_x11_cookie (self, g_value_get_string (value));
+ break;
+ case PROP_X11_AUTHORITY_FILE:
+ _gdm_display_set_x11_authority_file (self, g_value_get_string (value));
+ break;
+ case PROP_IS_LOCAL:
+ _gdm_display_set_is_local (self, g_value_get_boolean (value));
+ break;
+ case PROP_SLAVE_COMMAND:
+ _gdm_display_set_slave_command (self, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gdm_display_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GdmDisplay *self;
-
- self = GDM_DISPLAY (object);
-
- switch (prop_id) {
- case PROP_ID:
- g_value_set_string (value, self->priv->id);
- break;
- case PROP_SEAT_ID:
- g_value_set_string (value, self->priv->seat_id);
- break;
- case PROP_REMOTE_HOSTNAME:
- g_value_set_string (value, self->priv->remote_hostname);
- break;
- case PROP_X11_DISPLAY_NUMBER:
- g_value_set_int (value, self->priv->x11_display_number);
- break;
- case PROP_X11_DISPLAY_NAME:
- g_value_set_string (value, self->priv->x11_display_name);
- break;
- case PROP_X11_COOKIE:
- g_value_set_string (value, self->priv->x11_cookie);
- break;
- case PROP_X11_AUTHORITY_FILE:
- g_value_set_string (value, self->priv->x11_authority_file);
- break;
- case PROP_IS_LOCAL:
- g_value_set_boolean (value, self->priv->is_local);
- break;
- case PROP_SLAVE_COMMAND:
- g_value_set_string (value, self->priv->slave_command);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+gdm_display_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GdmDisplay *self;
+
+ self = GDM_DISPLAY (object);
+
+ switch (prop_id) {
+ case PROP_ID:
+ g_value_set_string (value, self->priv->id);
+ break;
+ case PROP_SEAT_ID:
+ g_value_set_string (value, self->priv->seat_id);
+ break;
+ case PROP_REMOTE_HOSTNAME:
+ g_value_set_string (value, self->priv->remote_hostname);
+ break;
+ case PROP_X11_DISPLAY_NUMBER:
+ g_value_set_int (value, self->priv->x11_display_number);
+ break;
+ case PROP_X11_DISPLAY_NAME:
+ g_value_set_string (value, self->priv->x11_display_name);
+ break;
+ case PROP_X11_COOKIE:
+ g_value_set_string (value, self->priv->x11_cookie);
+ break;
+ case PROP_X11_AUTHORITY_FILE:
+ g_value_set_string (value, self->priv->x11_authority_file);
+ break;
+ case PROP_IS_LOCAL:
+ g_value_set_boolean (value, self->priv->is_local);
+ break;
+ case PROP_SLAVE_COMMAND:
+ g_value_set_string (value, self->priv->slave_command);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static gboolean
@@ -643,24 +643,24 @@ register_display (GdmDisplay *display)
static GObject *
gdm_display_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
{
GdmDisplay *display;
GdmDisplayClass *klass;
- gboolean res;
+ gboolean res;
klass = GDM_DISPLAY_CLASS (g_type_class_peek (GDM_TYPE_DISPLAY));
display = GDM_DISPLAY (G_OBJECT_CLASS (gdm_display_parent_class)->constructor (type,
- n_construct_properties,
- construct_properties));
+ n_construct_properties,
+ construct_properties));
- display->priv->id = g_strdup_printf ("/org/gnome/DisplayManager/Display%u", get_next_display_serial ());
+ display->priv->id = g_strdup_printf ("/org/gnome/DisplayManager/Display%u", get_next_display_serial ());
res = register_display (display);
if (! res) {
- g_warning ("Unable to register display with system bus");
+ g_warning ("Unable to register display with system bus");
}
return G_OBJECT (display);
@@ -669,90 +669,90 @@ gdm_display_constructor (GType type,
static void
gdm_display_dispose (GObject *object)
{
- GdmDisplay *display;
+ GdmDisplay *display;
- display = GDM_DISPLAY (object);
+ display = GDM_DISPLAY (object);
- if (display->priv->finish_idle_id > 0) {
- g_source_remove (display->priv->finish_idle_id);
- display->priv->finish_idle_id = 0;
- }
+ if (display->priv->finish_idle_id > 0) {
+ g_source_remove (display->priv->finish_idle_id);
+ display->priv->finish_idle_id = 0;
+ }
- g_debug ("Disposing display");
- gdm_display_unmanage (display);
+ g_debug ("Disposing display");
+ gdm_display_unmanage (display);
- G_OBJECT_CLASS (gdm_display_parent_class)->dispose (object);
+ G_OBJECT_CLASS (gdm_display_parent_class)->dispose (object);
}
static void
gdm_display_class_init (GdmDisplayClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->get_property = gdm_display_get_property;
- object_class->set_property = gdm_display_set_property;
+ object_class->get_property = gdm_display_get_property;
+ object_class->set_property = gdm_display_set_property;
object_class->constructor = gdm_display_constructor;
- object_class->dispose = gdm_display_dispose;
- object_class->finalize = gdm_display_finalize;
-
- klass->create_authority = gdm_display_real_create_authority;
- klass->add_user_authorization = gdm_display_real_add_user_authorization;
- klass->remove_user_authorization = gdm_display_real_remove_user_authorization;
- klass->manage = gdm_display_real_manage;
- klass->finish = gdm_display_real_finish;
- klass->unmanage = gdm_display_real_unmanage;
-
- g_object_class_install_property (object_class,
- PROP_ID,
- g_param_spec_string ("id",
- "id",
- "id",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_SEAT_ID,
- g_param_spec_string ("seat-id",
- "seat id",
- "seat id",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_REMOTE_HOSTNAME,
- g_param_spec_string ("remote-hostname",
- "remote-hostname",
- "remote-hostname",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_X11_DISPLAY_NUMBER,
- g_param_spec_int ("x11-display-number",
- "x11 display number",
- "x11 display number",
- -1,
- G_MAXINT,
- -1,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_X11_DISPLAY_NAME,
- g_param_spec_string ("x11-display-name",
- "x11-display-name",
- "x11-display-name",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_X11_COOKIE,
- g_param_spec_string ("x11-cookie",
- "cookie",
- "cookie",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class,
- PROP_X11_AUTHORITY_FILE,
- g_param_spec_string ("x11-authority-file",
- "authority file",
- "authority file",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ object_class->dispose = gdm_display_dispose;
+ object_class->finalize = gdm_display_finalize;
+
+ klass->create_authority = gdm_display_real_create_authority;
+ klass->add_user_authorization = gdm_display_real_add_user_authorization;
+ klass->remove_user_authorization = gdm_display_real_remove_user_authorization;
+ klass->manage = gdm_display_real_manage;
+ klass->finish = gdm_display_real_finish;
+ klass->unmanage = gdm_display_real_unmanage;
+
+ g_object_class_install_property (object_class,
+ PROP_ID,
+ g_param_spec_string ("id",
+ "id",
+ "id",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_SEAT_ID,
+ g_param_spec_string ("seat-id",
+ "seat id",
+ "seat id",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_REMOTE_HOSTNAME,
+ g_param_spec_string ("remote-hostname",
+ "remote-hostname",
+ "remote-hostname",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_X11_DISPLAY_NUMBER,
+ g_param_spec_int ("x11-display-number",
+ "x11 display number",
+ "x11 display number",
+ -1,
+ G_MAXINT,
+ -1,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_X11_DISPLAY_NAME,
+ g_param_spec_string ("x11-display-name",
+ "x11-display-name",
+ "x11-display-name",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_X11_COOKIE,
+ g_param_spec_string ("x11-cookie",
+ "cookie",
+ "cookie",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
+ PROP_X11_AUTHORITY_FILE,
+ g_param_spec_string ("x11-authority-file",
+ "authority file",
+ "authority file",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_IS_LOCAL,
@@ -762,49 +762,49 @@ gdm_display_class_init (GdmDisplayClass *klass)
TRUE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class,
- PROP_SLAVE_COMMAND,
- g_param_spec_string ("slave-command",
- "slave command",
- "slave command",
- DEFAULT_SLAVE_COMMAND,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
+ PROP_SLAVE_COMMAND,
+ g_param_spec_string ("slave-command",
+ "slave command",
+ "slave command",
+ DEFAULT_SLAVE_COMMAND,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_type_class_add_private (klass, sizeof (GdmDisplayPrivate));
+ g_type_class_add_private (klass, sizeof (GdmDisplayPrivate));
- dbus_g_object_type_install_info (GDM_TYPE_DISPLAY, &dbus_glib_gdm_display_object_info);
+ dbus_g_object_type_install_info (GDM_TYPE_DISPLAY, &dbus_glib_gdm_display_object_info);
}
static void
gdm_display_init (GdmDisplay *display)
{
- display->priv = GDM_DISPLAY_GET_PRIVATE (display);
+ display->priv = GDM_DISPLAY_GET_PRIVATE (display);
- display->priv->status = GDM_DISPLAY_UNMANAGED;
- display->priv->creation_time = time (NULL);
+ display->priv->status = GDM_DISPLAY_UNMANAGED;
+ display->priv->creation_time = time (NULL);
}
static void
gdm_display_finalize (GObject *object)
{
- GdmDisplay *display;
+ GdmDisplay *display;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_DISPLAY (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_DISPLAY (object));
- display = GDM_DISPLAY (object);
+ display = GDM_DISPLAY (object);
- g_return_if_fail (display->priv != NULL);
+ g_return_if_fail (display->priv != NULL);
- g_debug ("Finalizing display: %s", display->priv->id);
- g_free (display->priv->id);
- g_free (display->priv->seat_id);
- g_free (display->priv->remote_hostname);
- g_free (display->priv->x11_display_name);
- g_free (display->priv->x11_cookie);
- g_free (display->priv->x11_authority_file);
- g_free (display->priv->slave_command);
+ g_debug ("Finalizing display: %s", display->priv->id);
+ g_free (display->priv->id);
+ g_free (display->priv->seat_id);
+ g_free (display->priv->remote_hostname);
+ g_free (display->priv->x11_display_name);
+ g_free (display->priv->x11_cookie);
+ g_free (display->priv->x11_authority_file);
+ g_free (display->priv->slave_command);
- G_OBJECT_CLASS (gdm_display_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_display_parent_class)->finalize (object);
}
diff --git a/daemon/gdm-display.h b/daemon/gdm-display.h
index 60bbb83e..41b03102 100644
--- a/daemon/gdm-display.h
+++ b/daemon/gdm-display.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -37,45 +37,45 @@ G_BEGIN_DECLS
typedef struct GdmDisplayPrivate GdmDisplayPrivate;
typedef enum {
- GDM_DISPLAY_UNMANAGED,
- GDM_DISPLAY_MANAGED,
- GDM_DISPLAY_FINISHED
+ GDM_DISPLAY_UNMANAGED,
+ GDM_DISPLAY_MANAGED,
+ GDM_DISPLAY_FINISHED
} GdmDisplayStatus;
typedef struct
{
- GObject parent;
- GdmDisplayPrivate *priv;
+ GObject parent;
+ GdmDisplayPrivate *priv;
} GdmDisplay;
typedef struct
{
- GObjectClass parent_class;
-
- /* methods */
- gboolean (*create_authority) (GdmDisplay *display);
- gboolean (*add_user_authorization) (GdmDisplay *display,
- const char *username,
- char **filename,
- GError **error);
- gboolean (*remove_user_authorization) (GdmDisplay *display,
- const char *username,
- GError **error);
- gboolean (*manage) (GdmDisplay *display);
- gboolean (*finish) (GdmDisplay *display);
- gboolean (*unmanage) (GdmDisplay *display);
+ GObjectClass parent_class;
+
+ /* methods */
+ gboolean (*create_authority) (GdmDisplay *display);
+ gboolean (*add_user_authorization) (GdmDisplay *display,
+ const char *username,
+ char **filename,
+ GError **error);
+ gboolean (*remove_user_authorization) (GdmDisplay *display,
+ const char *username,
+ GError **error);
+ gboolean (*manage) (GdmDisplay *display);
+ gboolean (*finish) (GdmDisplay *display);
+ gboolean (*unmanage) (GdmDisplay *display);
} GdmDisplayClass;
typedef enum
{
- GDM_DISPLAY_ERROR_GENERAL
+ GDM_DISPLAY_ERROR_GENERAL
} GdmDisplayError;
#define GDM_DISPLAY_ERROR gdm_display_error_quark ()
-GQuark gdm_display_error_quark (void);
-GType gdm_display_get_type (void);
+GQuark gdm_display_error_quark (void);
+GType gdm_display_get_type (void);
int gdm_display_get_status (GdmDisplay *display);
time_t gdm_display_get_creation_time (GdmDisplay *display);
@@ -89,35 +89,35 @@ gboolean gdm_display_unmanage (GdmDisplay *disp
/* exported to bus */
gboolean gdm_display_get_id (GdmDisplay *display,
- char **id,
- GError **error);
+ char **id,
+ GError **error);
gboolean gdm_display_get_remote_hostname (GdmDisplay *display,
- char **hostname,
- GError **error);
+ char **hostname,
+ GError **error);
gboolean gdm_display_get_x11_display_number (GdmDisplay *display,
- int *number,
- GError **error);
+ int *number,
+ GError **error);
gboolean gdm_display_get_x11_display_name (GdmDisplay *display,
- char **x11_display,
- GError **error);
+ char **x11_display,
+ GError **error);
gboolean gdm_display_is_local (GdmDisplay *display,
- gboolean *local,
- GError **error);
+ gboolean *local,
+ GError **error);
/* exported but protected */
gboolean gdm_display_get_x11_cookie (GdmDisplay *display,
- char **x11_cookie,
- GError **error);
+ char **x11_cookie,
+ GError **error);
gboolean gdm_display_get_x11_authority_file (GdmDisplay *display,
- char **filename,
- GError **error);
+ char **filename,
+ GError **error);
gboolean gdm_display_add_user_authorization (GdmDisplay *display,
- const char *username,
- char **filename,
- GError **error);
+ const char *username,
+ char **filename,
+ GError **error);
gboolean gdm_display_remove_user_authorization (GdmDisplay *display,
- const char *username,
- GError **error);
+ const char *username,
+ GError **error);
G_END_DECLS
diff --git a/daemon/gdm-factory-slave.c b/daemon/gdm-factory-slave.c
index 8877c443..3891e40a 100644
--- a/daemon/gdm-factory-slave.c
+++ b/daemon/gdm-factory-slave.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -57,71 +57,71 @@ extern char **environ;
#define GDM_FACTORY_SLAVE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_FACTORY_SLAVE, GdmFactorySlavePrivate))
-#define GDM_DBUS_NAME "org.gnome.DisplayManager"
+#define GDM_DBUS_NAME "org.gnome.DisplayManager"
#define GDM_DBUS_FACTORY_DISPLAY_INTERFACE "org.gnome.DisplayManager.StaticFactoryDisplay"
#define MAX_CONNECT_ATTEMPTS 10
struct GdmFactorySlavePrivate
{
- char *id;
- GPid pid;
+ char *id;
+ GPid pid;
guint output_watch_id;
guint error_watch_id;
- GPid server_pid;
- Display *server_display;
- guint connection_attempts;
+ GPid server_pid;
+ Display *server_display;
+ guint connection_attempts;
- GdmServer *server;
- GdmSessionRelay *session_relay;
- GdmGreeterServer *greeter_server;
- GdmGreeterProxy *greeter;
- DBusGProxy *factory_display_proxy;
+ GdmServer *server;
+ GdmSessionRelay *session_relay;
+ GdmGreeterServer *greeter_server;
+ GdmGreeterProxy *greeter;
+ DBusGProxy *factory_display_proxy;
DBusGConnection *connection;
};
enum {
- PROP_0,
+ PROP_0,
};
-static void gdm_factory_slave_class_init (GdmFactorySlaveClass *klass);
-static void gdm_factory_slave_init (GdmFactorySlave *factory_slave);
-static void gdm_factory_slave_finalize (GObject *object);
+static void gdm_factory_slave_class_init (GdmFactorySlaveClass *klass);
+static void gdm_factory_slave_init (GdmFactorySlave *factory_slave);
+static void gdm_factory_slave_finalize (GObject *object);
G_DEFINE_TYPE (GdmFactorySlave, gdm_factory_slave, GDM_TYPE_SLAVE)
static void
set_busy_cursor (GdmFactorySlave *factory_slave)
{
- if (factory_slave->priv->server_display != NULL) {
- Cursor xcursor;
-
- xcursor = XCreateFontCursor (factory_slave->priv->server_display, GDK_WATCH);
- XDefineCursor (factory_slave->priv->server_display,
- DefaultRootWindow (factory_slave->priv->server_display),
- xcursor);
- XFreeCursor (factory_slave->priv->server_display, xcursor);
- XSync (factory_slave->priv->server_display, False);
- }
+ if (factory_slave->priv->server_display != NULL) {
+ Cursor xcursor;
+
+ xcursor = XCreateFontCursor (factory_slave->priv->server_display, GDK_WATCH);
+ XDefineCursor (factory_slave->priv->server_display,
+ DefaultRootWindow (factory_slave->priv->server_display),
+ xcursor);
+ XFreeCursor (factory_slave->priv->server_display, xcursor);
+ XSync (factory_slave->priv->server_display, False);
+ }
}
static void
gdm_factory_slave_whack_temp_auth_file (GdmFactorySlave *factory_slave)
{
#if 0
- uid_t old;
-
- old = geteuid ();
- if (old != 0)
- seteuid (0);
- if (d->parent_temp_auth_file != NULL) {
- VE_IGNORE_EINTR (g_unlink (d->parent_temp_auth_file));
- }
- g_free (d->parent_temp_auth_file);
- d->parent_temp_auth_file = NULL;
- if (old != 0)
- seteuid (old);
+ uid_t old;
+
+ old = geteuid ();
+ if (old != 0)
+ seteuid (0);
+ if (d->parent_temp_auth_file != NULL) {
+ VE_IGNORE_EINTR (g_unlink (d->parent_temp_auth_file));
+ }
+ g_free (d->parent_temp_auth_file);
+ d->parent_temp_auth_file = NULL;
+ if (old != 0)
+ seteuid (old);
#endif
}
@@ -130,818 +130,818 @@ static void
create_temp_auth_file (GdmFactorySlave *factory_slave)
{
#if 0
- if (d->type == TYPE_FLEXI_XNEST &&
- d->parent_auth_file != NULL) {
- if (d->parent_temp_auth_file != NULL) {
- VE_IGNORE_EINTR (g_unlink (d->parent_temp_auth_file));
- }
- g_free (d->parent_temp_auth_file);
- d->parent_temp_auth_file =
- copy_auth_file (d->server_uid,
- gdm_daemon_config_get_gdmuid (),
- d->parent_auth_file);
- }
+ if (d->type == TYPE_FLEXI_XNEST &&
+ d->parent_auth_file != NULL) {
+ if (d->parent_temp_auth_file != NULL) {
+ VE_IGNORE_EINTR (g_unlink (d->parent_temp_auth_file));
+ }
+ g_free (d->parent_temp_auth_file);
+ d->parent_temp_auth_file =
+ copy_auth_file (d->server_uid,
+ gdm_daemon_config_get_gdmuid (),
+ d->parent_auth_file);
+ }
#endif
}
static void
listify_hash (const char *key,
- const char *value,
- GPtrArray *env)
+ const char *value,
+ GPtrArray *env)
{
- char *str;
- str = g_strdup_printf ("%s=%s", key, value);
- g_debug ("environment: %s", str);
- g_ptr_array_add (env, str);
+ char *str;
+ str = g_strdup_printf ("%s=%s", key, value);
+ g_debug ("environment: %s", str);
+ g_ptr_array_add (env, str);
}
static GPtrArray *
get_script_environment (GdmFactorySlave *slave,
- const char *username)
+ const char *username)
{
- GPtrArray *env;
- GHashTable *hash;
- struct passwd *pwent;
- char *x_servers_file;
- char *display_name;
- char *display_hostname;
- char *display_x11_authority_file;
- gboolean display_is_local;
-
- g_object_get (slave,
- "display-name", &display_name,
- "display-hostname", &display_hostname,
- "display-is-local", &display_is_local,
- "display-x11-authority-file", &display_x11_authority_file,
- NULL);
-
- env = g_ptr_array_new ();
-
- /* create a hash table of current environment, then update keys has necessary */
- hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-
- /* modify environment here */
- g_hash_table_insert (hash, g_strdup ("HOME"), g_strdup ("/"));
- g_hash_table_insert (hash, g_strdup ("PWD"), g_strdup ("/"));
- g_hash_table_insert (hash, g_strdup ("SHELL"), g_strdup ("/bin/sh"));
-
- g_hash_table_insert (hash, g_strdup ("LOGNAME"), g_strdup (username));
- g_hash_table_insert (hash, g_strdup ("USER"), g_strdup (username));
- g_hash_table_insert (hash, g_strdup ("USERNAME"), g_strdup (username));
-
- pwent = getpwnam (username);
- if (pwent != NULL) {
- if (pwent->pw_dir != NULL && pwent->pw_dir[0] != '\0') {
- g_hash_table_insert (hash, g_strdup ("HOME"), g_strdup (pwent->pw_dir));
- g_hash_table_insert (hash, g_strdup ("PWD"), g_strdup (pwent->pw_dir));
- }
-
- g_hash_table_insert (hash, g_strdup ("SHELL"), g_strdup (pwent->pw_shell));
- }
+ GPtrArray *env;
+ GHashTable *hash;
+ struct passwd *pwent;
+ char *x_servers_file;
+ char *display_name;
+ char *display_hostname;
+ char *display_x11_authority_file;
+ gboolean display_is_local;
+
+ g_object_get (slave,
+ "display-name", &display_name,
+ "display-hostname", &display_hostname,
+ "display-is-local", &display_is_local,
+ "display-x11-authority-file", &display_x11_authority_file,
+ NULL);
+
+ env = g_ptr_array_new ();
+
+ /* create a hash table of current environment, then update keys has necessary */
+ hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
+ /* modify environment here */
+ g_hash_table_insert (hash, g_strdup ("HOME"), g_strdup ("/"));
+ g_hash_table_insert (hash, g_strdup ("PWD"), g_strdup ("/"));
+ g_hash_table_insert (hash, g_strdup ("SHELL"), g_strdup ("/bin/sh"));
+
+ g_hash_table_insert (hash, g_strdup ("LOGNAME"), g_strdup (username));
+ g_hash_table_insert (hash, g_strdup ("USER"), g_strdup (username));
+ g_hash_table_insert (hash, g_strdup ("USERNAME"), g_strdup (username));
+
+ pwent = getpwnam (username);
+ if (pwent != NULL) {
+ if (pwent->pw_dir != NULL && pwent->pw_dir[0] != '\0') {
+ g_hash_table_insert (hash, g_strdup ("HOME"), g_strdup (pwent->pw_dir));
+ g_hash_table_insert (hash, g_strdup ("PWD"), g_strdup (pwent->pw_dir));
+ }
+
+ g_hash_table_insert (hash, g_strdup ("SHELL"), g_strdup (pwent->pw_shell));
+ }
#if 0
- if (display_is_parented) {
- g_hash_table_insert (hash, g_strdup ("GDM_PARENT_DISPLAY"), g_strdup (parent_display_name));
+ if (display_is_parented) {
+ g_hash_table_insert (hash, g_strdup ("GDM_PARENT_DISPLAY"), g_strdup (parent_display_name));
- /*g_hash_table_insert (hash, "GDM_PARENT_XAUTHORITY"), slave->priv->parent_temp_auth_file));*/
- }
+ /*g_hash_table_insert (hash, "GDM_PARENT_XAUTHORITY"), slave->priv->parent_temp_auth_file));*/
+ }
#endif
- /* some env for use with the Pre and Post scripts */
- x_servers_file = gdm_make_filename (AUTHDIR,
- display_name,
- ".Xservers");
- g_hash_table_insert (hash, g_strdup ("X_SERVERS"), x_servers_file);
+ /* some env for use with the Pre and Post scripts */
+ x_servers_file = gdm_make_filename (AUTHDIR,
+ display_name,
+ ".Xservers");
+ g_hash_table_insert (hash, g_strdup ("X_SERVERS"), x_servers_file);
- if (! display_is_local) {
- g_hash_table_insert (hash, g_strdup ("REMOTE_HOST"), g_strdup (display_hostname));
- }
+ if (! display_is_local) {
+ g_hash_table_insert (hash, g_strdup ("REMOTE_HOST"), g_strdup (display_hostname));
+ }
- /* Runs as root */
- g_hash_table_insert (hash, g_strdup ("XAUTHORITY"), g_strdup (display_x11_authority_file));
- g_hash_table_insert (hash, g_strdup ("DISPLAY"), g_strdup (display_name));
+ /* Runs as root */
+ g_hash_table_insert (hash, g_strdup ("XAUTHORITY"), g_strdup (display_x11_authority_file));
+ g_hash_table_insert (hash, g_strdup ("DISPLAY"), g_strdup (display_name));
- /*g_setenv ("PATH", gdm_daemon_config_get_value_string (GDM_KEY_ROOT_PATH), TRUE);*/
+ /*g_setenv ("PATH", gdm_daemon_config_get_value_string (GDM_KEY_ROOT_PATH), TRUE);*/
- g_hash_table_insert (hash, g_strdup ("RUNNING_UNDER_GDM"), g_strdup ("true"));
+ g_hash_table_insert (hash, g_strdup ("RUNNING_UNDER_GDM"), g_strdup ("true"));
#if 0
- if ( ! ve_string_empty (d->theme_name))
- g_setenv ("GDM_GTK_THEME", d->theme_name, TRUE);
+ if ( ! ve_string_empty (d->theme_name))
+ g_setenv ("GDM_GTK_THEME", d->theme_name, TRUE);
#endif
- g_hash_table_remove (hash, "MAIL");
+ g_hash_table_remove (hash, "MAIL");
- g_hash_table_foreach (hash, (GHFunc)listify_hash, env);
- g_hash_table_destroy (hash);
+ g_hash_table_foreach (hash, (GHFunc)listify_hash, env);
+ g_hash_table_destroy (hash);
- g_ptr_array_add (env, NULL);
+ g_ptr_array_add (env, NULL);
- g_free (display_name);
- g_free (display_hostname);
- g_free (display_x11_authority_file);
+ g_free (display_name);
+ g_free (display_hostname);
+ g_free (display_x11_authority_file);
- return env;
+ return env;
}
static gboolean
gdm_factory_slave_exec_script (GdmFactorySlave *slave,
- const char *dir,
- const char *login)
+ const char *dir,
+ const char *login)
{
- char *script;
- char **argv;
- gint status;
- GError *error;
- GPtrArray *env;
- gboolean res;
- gboolean ret;
- char *display_name;
- char *display_hostname;
-
- g_assert (dir != NULL);
- g_assert (login != NULL);
-
- g_object_get (slave,
- "display-name", &display_name,
- "display-hostname", &display_hostname,
- NULL);
-
- script = g_build_filename (dir, display_name, NULL);
- if (g_access (script, R_OK|X_OK) != 0) {
- g_free (script);
- script = NULL;
- }
-
- if (script == NULL &&
- display_hostname != NULL) {
- script = g_build_filename (dir, display_hostname, NULL);
- if (g_access (script, R_OK|X_OK) != 0) {
- g_free (script);
- script = NULL;
- }
- }
+ char *script;
+ char **argv;
+ gint status;
+ GError *error;
+ GPtrArray *env;
+ gboolean res;
+ gboolean ret;
+ char *display_name;
+ char *display_hostname;
+
+ g_assert (dir != NULL);
+ g_assert (login != NULL);
+
+ g_object_get (slave,
+ "display-name", &display_name,
+ "display-hostname", &display_hostname,
+ NULL);
+
+ script = g_build_filename (dir, display_name, NULL);
+ if (g_access (script, R_OK|X_OK) != 0) {
+ g_free (script);
+ script = NULL;
+ }
+
+ if (script == NULL &&
+ display_hostname != NULL) {
+ script = g_build_filename (dir, display_hostname, NULL);
+ if (g_access (script, R_OK|X_OK) != 0) {
+ g_free (script);
+ script = NULL;
+ }
+ }
#if 0
- if (script == NULL &&
- SERVER_IS_XDMCP (d)) {
- script = g_build_filename (dir, "XDMCP", NULL);
- if (g_access (script, R_OK|X_OK) != 0) {
- g_free (script);
- script = NULL;
- }
- }
- if (script == NULL &&
- SERVER_IS_FLEXI (d)) {
- script = g_build_filename (dir, "Flexi", NULL);
- if (g_access (script, R_OK|X_OK) != 0) {
- g_free (script);
- script = NULL;
- }
- }
+ if (script == NULL &&
+ SERVER_IS_XDMCP (d)) {
+ script = g_build_filename (dir, "XDMCP", NULL);
+ if (g_access (script, R_OK|X_OK) != 0) {
+ g_free (script);
+ script = NULL;
+ }
+ }
+ if (script == NULL &&
+ SERVER_IS_FLEXI (d)) {
+ script = g_build_filename (dir, "Flexi", NULL);
+ if (g_access (script, R_OK|X_OK) != 0) {
+ g_free (script);
+ script = NULL;
+ }
+ }
#endif
- if (script == NULL) {
- script = g_build_filename (dir, "Default", NULL);
- if (g_access (script, R_OK|X_OK) != 0) {
- g_free (script);
- script = NULL;
- }
- }
-
- if (script == NULL) {
- return TRUE;
- }
-
- create_temp_auth_file (slave);
-
- g_debug ("Running process: %s", script);
- error = NULL;
- if (! g_shell_parse_argv (script, NULL, &argv, &error)) {
- g_warning ("Could not parse command: %s", error->message);
- g_error_free (error);
- goto out;
- }
-
- env = get_script_environment (slave, login);
-
- res = g_spawn_sync (NULL,
- argv,
- (char **)env->pdata,
- G_SPAWN_SEARCH_PATH,
- NULL,
- NULL,
- NULL,
- NULL,
- &status,
- &error);
-
- g_ptr_array_foreach (env, (GFunc)g_free, NULL);
+ if (script == NULL) {
+ script = g_build_filename (dir, "Default", NULL);
+ if (g_access (script, R_OK|X_OK) != 0) {
+ g_free (script);
+ script = NULL;
+ }
+ }
+
+ if (script == NULL) {
+ return TRUE;
+ }
+
+ create_temp_auth_file (slave);
+
+ g_debug ("Running process: %s", script);
+ error = NULL;
+ if (! g_shell_parse_argv (script, NULL, &argv, &error)) {
+ g_warning ("Could not parse command: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ env = get_script_environment (slave, login);
+
+ res = g_spawn_sync (NULL,
+ argv,
+ (char **)env->pdata,
+ G_SPAWN_SEARCH_PATH,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ &status,
+ &error);
+
+ g_ptr_array_foreach (env, (GFunc)g_free, NULL);
g_ptr_array_free (env, TRUE);
- gdm_factory_slave_whack_temp_auth_file (slave);
+ gdm_factory_slave_whack_temp_auth_file (slave);
- if (WIFEXITED (status)) {
- g_debug ("Process exit status: %d", WEXITSTATUS (status));
- ret = WEXITSTATUS (status) != 0;
- } else {
- ret = TRUE;
- }
+ if (WIFEXITED (status)) {
+ g_debug ("Process exit status: %d", WEXITSTATUS (status));
+ ret = WEXITSTATUS (status) != 0;
+ } else {
+ ret = TRUE;
+ }
out:
- g_free (script);
- g_free (display_name);
- g_free (display_hostname);
+ g_free (script);
+ g_free (display_name);
+ g_free (display_hostname);
- return ret;
+ return ret;
}
static void
on_greeter_start (GdmGreeterProxy *greeter,
- GdmFactorySlave *slave)
+ GdmFactorySlave *slave)
{
- g_debug ("Greeter started");
+ g_debug ("Greeter started");
}
static void
on_greeter_stop (GdmGreeterProxy *greeter,
- GdmFactorySlave *slave)
+ GdmFactorySlave *slave)
{
- g_debug ("Greeter stopped");
+ g_debug ("Greeter stopped");
}
static void
on_relay_info (GdmSessionRelay *relay,
- const char *text,
- GdmFactorySlave *slave)
+ const char *text,
+ GdmFactorySlave *slave)
{
- g_debug ("Info: %s", text);
- gdm_greeter_server_info (slave->priv->greeter_server, text);
+ g_debug ("Info: %s", text);
+ gdm_greeter_server_info (slave->priv->greeter_server, text);
}
static void
on_relay_problem (GdmSessionRelay *relay,
- const char *text,
- GdmFactorySlave *slave)
+ const char *text,
+ GdmFactorySlave *slave)
{
- g_debug ("Problem: %s", text);
- gdm_greeter_server_problem (slave->priv->greeter_server, text);
+ g_debug ("Problem: %s", text);
+ gdm_greeter_server_problem (slave->priv->greeter_server, text);
}
static void
on_relay_info_query (GdmSessionRelay *relay,
- const char *text,
- GdmFactorySlave *slave)
+ const char *text,
+ GdmFactorySlave *slave)
{
- g_debug ("Info query: %s", text);
- gdm_greeter_server_info_query (slave->priv->greeter_server, text);
+ g_debug ("Info query: %s", text);
+ gdm_greeter_server_info_query (slave->priv->greeter_server, text);
}
static void
on_relay_secret_info_query (GdmSessionRelay *relay,
- const char *text,
- GdmFactorySlave *slave)
+ const char *text,
+ GdmFactorySlave *slave)
{
- g_debug ("Secret info query: %s", text);
- gdm_greeter_server_secret_info_query (slave->priv->greeter_server, text);
+ g_debug ("Secret info query: %s", text);
+ gdm_greeter_server_secret_info_query (slave->priv->greeter_server, text);
}
static void
on_relay_ready (GdmSessionRelay *relay,
- GdmFactorySlave *slave)
+ GdmFactorySlave *slave)
{
- g_debug ("Relay is ready");
+ g_debug ("Relay is ready");
- gdm_greeter_server_reset (slave->priv->greeter_server);
- gdm_session_relay_open (slave->priv->session_relay);
+ gdm_greeter_server_reset (slave->priv->greeter_server);
+ gdm_session_relay_open (slave->priv->session_relay);
}
static gboolean
create_product_display (GdmFactorySlave *slave)
{
- char *display_id;
- char *server_address;
- char *product_id;
- GError *error;
- gboolean res;
- gboolean ret;
-
- ret = FALSE;
-
- g_debug ("Create product display");
-
- g_object_get (slave,
- "display-id", &display_id,
- NULL);
-
- g_debug ("Connecting to display %s", display_id);
- slave->priv->factory_display_proxy = dbus_g_proxy_new_for_name (slave->priv->connection,
- GDM_DBUS_NAME,
- display_id,
- GDM_DBUS_FACTORY_DISPLAY_INTERFACE);
- g_free (display_id);
-
- if (slave->priv->factory_display_proxy == NULL) {
- g_warning ("Failed to create display proxy %s", display_id);
- goto out;
- }
-
- server_address = gdm_session_relay_get_address (slave->priv->session_relay);
-
- error = NULL;
- res = dbus_g_proxy_call (slave->priv->factory_display_proxy,
- "CreateProductDisplay",
- &error,
- G_TYPE_STRING, server_address,
- G_TYPE_INVALID,
- DBUS_TYPE_G_OBJECT_PATH, &product_id,
- G_TYPE_INVALID);
- g_free (server_address);
-
- if (! res) {
- if (error != NULL) {
- g_warning ("Failed to create product display: %s", error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to create product display");
- }
- goto out;
- }
-
- ret = TRUE;
+ char *display_id;
+ char *server_address;
+ char *product_id;
+ GError *error;
+ gboolean res;
+ gboolean ret;
+
+ ret = FALSE;
+
+ g_debug ("Create product display");
+
+ g_object_get (slave,
+ "display-id", &display_id,
+ NULL);
+
+ g_debug ("Connecting to display %s", display_id);
+ slave->priv->factory_display_proxy = dbus_g_proxy_new_for_name (slave->priv->connection,
+ GDM_DBUS_NAME,
+ display_id,
+ GDM_DBUS_FACTORY_DISPLAY_INTERFACE);
+ g_free (display_id);
+
+ if (slave->priv->factory_display_proxy == NULL) {
+ g_warning ("Failed to create display proxy %s", display_id);
+ goto out;
+ }
+
+ server_address = gdm_session_relay_get_address (slave->priv->session_relay);
+
+ error = NULL;
+ res = dbus_g_proxy_call (slave->priv->factory_display_proxy,
+ "CreateProductDisplay",
+ &error,
+ G_TYPE_STRING, server_address,
+ G_TYPE_INVALID,
+ DBUS_TYPE_G_OBJECT_PATH, &product_id,
+ G_TYPE_INVALID);
+ g_free (server_address);
+
+ if (! res) {
+ if (error != NULL) {
+ g_warning ("Failed to create product display: %s", error->message);
+ g_error_free (error);
+ } else {
+ g_warning ("Failed to create product display");
+ }
+ goto out;
+ }
+
+ ret = TRUE;
out:
- return ret;
+ return ret;
}
static void
on_relay_disconnected (GdmSessionRelay *relay,
- GdmFactorySlave *slave)
+ GdmFactorySlave *slave)
{
- g_debug ("Relay disconnected");
+ g_debug ("Relay disconnected");
- /* FIXME: do some kind of loop detection */
- gdm_greeter_server_reset (slave->priv->greeter_server);
- create_product_display (slave);
+ /* FIXME: do some kind of loop detection */
+ gdm_greeter_server_reset (slave->priv->greeter_server);
+ create_product_display (slave);
}
static void
on_relay_session_started (GdmSessionRelay *relay,
- GdmFactorySlave *slave)
+ GdmFactorySlave *slave)
{
- g_debug ("Relay session started");
- gdm_greeter_server_reset (slave->priv->greeter_server);
+ g_debug ("Relay session started");
+ gdm_greeter_server_reset (slave->priv->greeter_server);
}
static void
on_greeter_answer (GdmGreeterServer *greeter_server,
- const char *text,
- GdmFactorySlave *slave)
+ const char *text,
+ GdmFactorySlave *slave)
{
- g_debug ("Greeter answer");
- gdm_session_relay_answer_query (slave->priv->session_relay, text);
+ g_debug ("Greeter answer");
+ gdm_session_relay_answer_query (slave->priv->session_relay, text);
}
static void
on_greeter_session_selected (GdmGreeterServer *greeter_server,
- const char *text,
- GdmFactorySlave *slave)
+ const char *text,
+ GdmFactorySlave *slave)
{
- gdm_session_relay_select_session (slave->priv->session_relay, text);
+ gdm_session_relay_select_session (slave->priv->session_relay, text);
}
static void
on_greeter_language_selected (GdmGreeterServer *greeter_server,
- const char *text,
- GdmFactorySlave *slave)
+ const char *text,
+ GdmFactorySlave *slave)
{
- gdm_session_relay_select_language (slave->priv->session_relay, text);
+ gdm_session_relay_select_language (slave->priv->session_relay, text);
}
static void
on_greeter_user_selected (GdmGreeterServer *greeter_server,
- const char *text,
- GdmFactorySlave *slave)
+ const char *text,
+ GdmFactorySlave *slave)
{
- gdm_session_relay_select_user (slave->priv->session_relay, text);
+ gdm_session_relay_select_user (slave->priv->session_relay, text);
}
static void
on_greeter_cancel (GdmGreeterServer *greeter_server,
- GdmFactorySlave *slave)
+ GdmFactorySlave *slave)
{
- gdm_session_relay_cancel (slave->priv->session_relay);
+ gdm_session_relay_cancel (slave->priv->session_relay);
}
static void
on_greeter_connected (GdmGreeterServer *greeter_server,
- GdmFactorySlave *slave)
+ GdmFactorySlave *slave)
{
- g_debug ("Greeter started");
+ g_debug ("Greeter started");
- create_product_display (slave);
+ create_product_display (slave);
}
static void
run_greeter (GdmFactorySlave *slave)
{
- gboolean display_is_local;
- char *display_name;
- char *display_device;
- char *display_hostname;
- char *auth_file;
- char *address;
-
- g_debug ("Running greeter");
-
- display_is_local = FALSE;
- display_name = NULL;
- auth_file = NULL;
- display_device = NULL;
- display_hostname = NULL;
-
- g_object_get (slave,
- "display-is-local", &display_is_local,
- "display-name", &display_name,
- "display-hostname", &display_hostname,
- "display-x11-authority-file", &auth_file,
- NULL);
-
- if (slave->priv->server != NULL) {
- display_device = gdm_server_get_display_device (slave->priv->server);
- }
+ gboolean display_is_local;
+ char *display_name;
+ char *display_device;
+ char *display_hostname;
+ char *auth_file;
+ char *address;
+
+ g_debug ("Running greeter");
+
+ display_is_local = FALSE;
+ display_name = NULL;
+ auth_file = NULL;
+ display_device = NULL;
+ display_hostname = NULL;
+
+ g_object_get (slave,
+ "display-is-local", &display_is_local,
+ "display-name", &display_name,
+ "display-hostname", &display_hostname,
+ "display-x11-authority-file", &auth_file,
+ NULL);
+
+ if (slave->priv->server != NULL) {
+ display_device = gdm_server_get_display_device (slave->priv->server);
+ }
- /* Set the busy cursor */
- set_busy_cursor (slave);
+ /* Set the busy cursor */
+ set_busy_cursor (slave);
- /* FIXME: send a signal back to the master */
+ /* FIXME: send a signal back to the master */
#if 0
- /* OK from now on it's really the user whacking us most likely,
- * we have already started up well */
- do_xfailed_on_xio_error = FALSE;
+ /* OK from now on it's really the user whacking us most likely,
+ * we have already started up well */
+ do_xfailed_on_xio_error = FALSE;
#endif
#if 0
- /* checkout xinerama */
- gdm_screen_init (slave);
+ /* checkout xinerama */
+ gdm_screen_init (slave);
#endif
- /* Run the init script. gdmslave suspends until script has terminated */
- gdm_factory_slave_exec_script (slave,
- GDMCONFDIR"/Init",
- "gdm");
-
- slave->priv->greeter_server = gdm_greeter_server_new ();
- g_signal_connect (slave->priv->greeter_server,
- "query-answer",
- G_CALLBACK (on_greeter_answer),
- slave);
- g_signal_connect (slave->priv->greeter_server,
- "session-selected",
- G_CALLBACK (on_greeter_session_selected),
- slave);
- g_signal_connect (slave->priv->greeter_server,
- "language-selected",
- G_CALLBACK (on_greeter_language_selected),
- slave);
- g_signal_connect (slave->priv->greeter_server,
- "user-selected",
- G_CALLBACK (on_greeter_user_selected),
- slave);
- g_signal_connect (slave->priv->greeter_server,
- "connected",
- G_CALLBACK (on_greeter_connected),
- slave);
- g_signal_connect (slave->priv->greeter_server,
- "cancelled",
- G_CALLBACK (on_greeter_cancel),
- slave);
- gdm_greeter_server_start (slave->priv->greeter_server);
-
- address = gdm_greeter_server_get_address (slave->priv->greeter_server);
-
- g_debug ("Creating greeter on %s %s", display_name, display_device);
- slave->priv->greeter = gdm_greeter_proxy_new (display_name,
- display_device,
- display_hostname,
- display_is_local);
- g_signal_connect (slave->priv->greeter,
- "started",
- G_CALLBACK (on_greeter_start),
- slave);
- g_signal_connect (slave->priv->greeter,
- "stopped",
- G_CALLBACK (on_greeter_stop),
- slave);
- g_object_set (slave->priv->greeter,
- "x11-authority-file", auth_file,
- NULL);
- gdm_greeter_proxy_set_server_address (slave->priv->greeter, address);
- gdm_greeter_proxy_start (slave->priv->greeter);
-
- g_free (address);
-
- g_free (display_name);
- g_free (display_device);
- g_free (display_hostname);
- g_free (auth_file);
+ /* Run the init script. gdmslave suspends until script has terminated */
+ gdm_factory_slave_exec_script (slave,
+ GDMCONFDIR"/Init",
+ "gdm");
+
+ slave->priv->greeter_server = gdm_greeter_server_new ();
+ g_signal_connect (slave->priv->greeter_server,
+ "query-answer",
+ G_CALLBACK (on_greeter_answer),
+ slave);
+ g_signal_connect (slave->priv->greeter_server,
+ "session-selected",
+ G_CALLBACK (on_greeter_session_selected),
+ slave);
+ g_signal_connect (slave->priv->greeter_server,
+ "language-selected",
+ G_CALLBACK (on_greeter_language_selected),
+ slave);
+ g_signal_connect (slave->priv->greeter_server,
+ "user-selected",
+ G_CALLBACK (on_greeter_user_selected),
+ slave);
+ g_signal_connect (slave->priv->greeter_server,
+ "connected",
+ G_CALLBACK (on_greeter_connected),
+ slave);
+ g_signal_connect (slave->priv->greeter_server,
+ "cancelled",
+ G_CALLBACK (on_greeter_cancel),
+ slave);
+ gdm_greeter_server_start (slave->priv->greeter_server);
+
+ address = gdm_greeter_server_get_address (slave->priv->greeter_server);
+
+ g_debug ("Creating greeter on %s %s", display_name, display_device);
+ slave->priv->greeter = gdm_greeter_proxy_new (display_name,
+ display_device,
+ display_hostname,
+ display_is_local);
+ g_signal_connect (slave->priv->greeter,
+ "started",
+ G_CALLBACK (on_greeter_start),
+ slave);
+ g_signal_connect (slave->priv->greeter,
+ "stopped",
+ G_CALLBACK (on_greeter_stop),
+ slave);
+ g_object_set (slave->priv->greeter,
+ "x11-authority-file", auth_file,
+ NULL);
+ gdm_greeter_proxy_set_server_address (slave->priv->greeter, address);
+ gdm_greeter_proxy_start (slave->priv->greeter);
+
+ g_free (address);
+
+ g_free (display_name);
+ g_free (display_device);
+ g_free (display_hostname);
+ g_free (auth_file);
}
static void
set_local_auth (GdmFactorySlave *slave)
{
- GString *binary_cookie;
- GString *cookie;
- char *display_x11_cookie;
-
- g_object_get (slave,
- "display-x11-cookie", &display_x11_cookie,
- NULL);
-
- g_debug ("Setting authorization key for display %s", display_x11_cookie);
-
- cookie = g_string_new (display_x11_cookie);
- binary_cookie = g_string_new (NULL);
- if (! gdm_string_hex_decode (cookie,
- 0,
- NULL,
- binary_cookie,
- 0)) {
- g_warning ("Unable to decode hex cookie");
- goto out;
- }
-
- g_debug ("Decoded cookie len %d", binary_cookie->len);
-
- XSetAuthorization ("MIT-MAGIC-COOKIE-1",
- (int) strlen ("MIT-MAGIC-COOKIE-1"),
- (char *)binary_cookie->str,
- binary_cookie->len);
+ GString *binary_cookie;
+ GString *cookie;
+ char *display_x11_cookie;
+
+ g_object_get (slave,
+ "display-x11-cookie", &display_x11_cookie,
+ NULL);
+
+ g_debug ("Setting authorization key for display %s", display_x11_cookie);
+
+ cookie = g_string_new (display_x11_cookie);
+ binary_cookie = g_string_new (NULL);
+ if (! gdm_string_hex_decode (cookie,
+ 0,
+ NULL,
+ binary_cookie,
+ 0)) {
+ g_warning ("Unable to decode hex cookie");
+ goto out;
+ }
+
+ g_debug ("Decoded cookie len %d", binary_cookie->len);
+
+ XSetAuthorization ("MIT-MAGIC-COOKIE-1",
+ (int) strlen ("MIT-MAGIC-COOKIE-1"),
+ (char *)binary_cookie->str,
+ binary_cookie->len);
out:
- g_string_free (binary_cookie, TRUE);
- g_string_free (cookie, TRUE);
- g_free (display_x11_cookie);
+ g_string_free (binary_cookie, TRUE);
+ g_string_free (cookie, TRUE);
+ g_free (display_x11_cookie);
}
static gboolean
connect_to_display (GdmFactorySlave *slave)
{
- char *display_name;
- gboolean ret;
+ char *display_name;
+ gboolean ret;
- ret = FALSE;
+ ret = FALSE;
- g_object_get (slave,
- "display-name", &display_name,
- NULL);
+ g_object_get (slave,
+ "display-name", &display_name,
+ NULL);
- /* We keep our own (windowless) connection (dsp) open to avoid the
- * X server resetting due to lack of active connections. */
+ /* We keep our own (windowless) connection (dsp) open to avoid the
+ * X server resetting due to lack of active connections. */
- g_debug ("Server is ready - opening display %s", display_name);
+ g_debug ("Server is ready - opening display %s", display_name);
- g_setenv ("DISPLAY", display_name, TRUE);
- g_unsetenv ("XAUTHORITY"); /* just in case it's set */
+ g_setenv ("DISPLAY", display_name, TRUE);
+ g_unsetenv ("XAUTHORITY"); /* just in case it's set */
- set_local_auth (slave);
+ set_local_auth (slave);
#if 0
- /* X error handlers to avoid the default one (i.e. exit (1)) */
- do_xfailed_on_xio_error = TRUE;
- XSetErrorHandler (gdm_factory_slave_xerror_handler);
- XSetIOErrorHandler (gdm_factory_slave_xioerror_handler);
+ /* X error handlers to avoid the default one (i.e. exit (1)) */
+ do_xfailed_on_xio_error = TRUE;
+ XSetErrorHandler (gdm_factory_slave_xerror_handler);
+ XSetIOErrorHandler (gdm_factory_slave_xioerror_handler);
#endif
- gdm_sigchld_block_push ();
- slave->priv->server_display = XOpenDisplay (display_name);
- gdm_sigchld_block_pop ();
+ gdm_sigchld_block_push ();
+ slave->priv->server_display = XOpenDisplay (display_name);
+ gdm_sigchld_block_pop ();
- if (slave->priv->server_display == NULL) {
- g_warning ("Unable to connect to display %s", display_name);
- ret = FALSE;
- } else {
- g_debug ("Connected to display %s", display_name);
- ret = TRUE;
- }
+ if (slave->priv->server_display == NULL) {
+ g_warning ("Unable to connect to display %s", display_name);
+ ret = FALSE;
+ } else {
+ g_debug ("Connected to display %s", display_name);
+ ret = TRUE;
+ }
- g_free (display_name);
+ g_free (display_name);
- return ret;
+ return ret;
}
static gboolean
idle_connect_to_display (GdmFactorySlave *slave)
{
- gboolean res;
+ gboolean res;
- slave->priv->connection_attempts++;
+ slave->priv->connection_attempts++;
- g_debug ("Connect to display");
+ g_debug ("Connect to display");
- res = connect_to_display (slave);
- if (res) {
- /* FIXME: handle wait-for-go */
+ res = connect_to_display (slave);
+ if (res) {
+ /* FIXME: handle wait-for-go */
- run_greeter (slave);
- } else {
- if (slave->priv->connection_attempts >= MAX_CONNECT_ATTEMPTS) {
- g_warning ("Unable to connect to display after %d tries - bailing out", slave->priv->connection_attempts);
- exit (1);
- }
- }
+ run_greeter (slave);
+ } else {
+ if (slave->priv->connection_attempts >= MAX_CONNECT_ATTEMPTS) {
+ g_warning ("Unable to connect to display after %d tries - bailing out", slave->priv->connection_attempts);
+ exit (1);
+ }
+ }
- return FALSE;
+ return FALSE;
}
static void
server_ready_cb (GdmServer *server,
- GdmFactorySlave *slave)
+ GdmFactorySlave *slave)
{
- g_debug ("Server ready");
+ g_debug ("Server ready");
- g_timeout_add (500, (GSourceFunc)idle_connect_to_display, slave);
+ g_timeout_add (500, (GSourceFunc)idle_connect_to_display, slave);
}
static gboolean
gdm_factory_slave_run (GdmFactorySlave *slave)
{
- char *display_name;
- gboolean display_is_local;
-
- g_object_get (slave,
- "display-is-local", &display_is_local,
- "display-name", &display_name,
- NULL);
-
- /* if this is local display start a server if one doesn't
- * exist */
- if (display_is_local) {
- gboolean res;
-
- slave->priv->server = gdm_server_new (display_name);
-
- g_signal_connect (slave->priv->server,
- "ready",
- G_CALLBACK (server_ready_cb),
- slave);
-
- res = gdm_server_start (slave->priv->server);
- if (! res) {
- g_warning (_("Could not start the X "
- "server (your graphical environment) "
- "due to some internal error. "
- "Please contact your system administrator "
- "or check your syslog to diagnose. "
- "In the meantime this display will be "
- "disabled. Please restart GDM when "
- "the problem is corrected."));
- exit (1);
- }
-
- g_debug ("Started X server");
- } else {
- g_timeout_add (500, (GSourceFunc)idle_connect_to_display, slave);
- }
-
- g_free (display_name);
-
- return TRUE;
+ char *display_name;
+ gboolean display_is_local;
+
+ g_object_get (slave,
+ "display-is-local", &display_is_local,
+ "display-name", &display_name,
+ NULL);
+
+ /* if this is local display start a server if one doesn't
+ * exist */
+ if (display_is_local) {
+ gboolean res;
+
+ slave->priv->server = gdm_server_new (display_name);
+
+ g_signal_connect (slave->priv->server,
+ "ready",
+ G_CALLBACK (server_ready_cb),
+ slave);
+
+ res = gdm_server_start (slave->priv->server);
+ if (! res) {
+ g_warning (_("Could not start the X "
+ "server (your graphical environment) "
+ "due to some internal error. "
+ "Please contact your system administrator "
+ "or check your syslog to diagnose. "
+ "In the meantime this display will be "
+ "disabled. Please restart GDM when "
+ "the problem is corrected."));
+ exit (1);
+ }
+
+ g_debug ("Started X server");
+ } else {
+ g_timeout_add (500, (GSourceFunc)idle_connect_to_display, slave);
+ }
+
+ g_free (display_name);
+
+ return TRUE;
}
static gboolean
gdm_factory_slave_start (GdmSlave *slave)
{
- gboolean res;
- gboolean ret;
-
- ret = FALSE;
-
- g_debug ("Starting factory slave");
-
- res = GDM_SLAVE_CLASS (gdm_factory_slave_parent_class)->start (slave);
-
-
- GDM_FACTORY_SLAVE (slave)->priv->session_relay = gdm_session_relay_new ();
- g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session_relay,
- "info",
- G_CALLBACK (on_relay_info),
- slave);
- g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session_relay,
- "problem",
- G_CALLBACK (on_relay_problem),
- slave);
- g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session_relay,
- "info-query",
- G_CALLBACK (on_relay_info_query),
- slave);
- g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session_relay,
- "secret-info-query",
- G_CALLBACK (on_relay_secret_info_query),
- slave);
- g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session_relay,
- "ready",
- G_CALLBACK (on_relay_ready),
- slave);
- g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session_relay,
- "disconnected",
- G_CALLBACK (on_relay_disconnected),
- slave);
- g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session_relay,
- "session-started",
- G_CALLBACK (on_relay_session_started),
- slave);
-
- gdm_session_relay_start (GDM_FACTORY_SLAVE (slave)->priv->session_relay);
-
- gdm_factory_slave_run (GDM_FACTORY_SLAVE (slave));
-
- ret = TRUE;
-
- return ret;
+ gboolean res;
+ gboolean ret;
+
+ ret = FALSE;
+
+ g_debug ("Starting factory slave");
+
+ res = GDM_SLAVE_CLASS (gdm_factory_slave_parent_class)->start (slave);
+
+
+ GDM_FACTORY_SLAVE (slave)->priv->session_relay = gdm_session_relay_new ();
+ g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session_relay,
+ "info",
+ G_CALLBACK (on_relay_info),
+ slave);
+ g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session_relay,
+ "problem",
+ G_CALLBACK (on_relay_problem),
+ slave);
+ g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session_relay,
+ "info-query",
+ G_CALLBACK (on_relay_info_query),
+ slave);
+ g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session_relay,
+ "secret-info-query",
+ G_CALLBACK (on_relay_secret_info_query),
+ slave);
+ g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session_relay,
+ "ready",
+ G_CALLBACK (on_relay_ready),
+ slave);
+ g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session_relay,
+ "disconnected",
+ G_CALLBACK (on_relay_disconnected),
+ slave);
+ g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session_relay,
+ "session-started",
+ G_CALLBACK (on_relay_session_started),
+ slave);
+
+ gdm_session_relay_start (GDM_FACTORY_SLAVE (slave)->priv->session_relay);
+
+ gdm_factory_slave_run (GDM_FACTORY_SLAVE (slave));
+
+ ret = TRUE;
+
+ return ret;
}
static gboolean
gdm_factory_slave_stop (GdmSlave *slave)
{
- gboolean res;
+ gboolean res;
- g_debug ("Stopping factory_slave");
+ g_debug ("Stopping factory_slave");
- res = GDM_SLAVE_CLASS (gdm_factory_slave_parent_class)->stop (slave);
+ res = GDM_SLAVE_CLASS (gdm_factory_slave_parent_class)->stop (slave);
- if (GDM_FACTORY_SLAVE (slave)->priv->session_relay != NULL) {
- gdm_session_relay_stop (GDM_FACTORY_SLAVE (slave)->priv->session_relay);
- g_object_unref (GDM_FACTORY_SLAVE (slave)->priv->session_relay);
- GDM_FACTORY_SLAVE (slave)->priv->session_relay = NULL;
- }
+ if (GDM_FACTORY_SLAVE (slave)->priv->session_relay != NULL) {
+ gdm_session_relay_stop (GDM_FACTORY_SLAVE (slave)->priv->session_relay);
+ g_object_unref (GDM_FACTORY_SLAVE (slave)->priv->session_relay);
+ GDM_FACTORY_SLAVE (slave)->priv->session_relay = NULL;
+ }
- if (GDM_FACTORY_SLAVE (slave)->priv->greeter_server != NULL) {
- gdm_greeter_server_stop (GDM_FACTORY_SLAVE (slave)->priv->greeter_server);
- g_object_unref (GDM_FACTORY_SLAVE (slave)->priv->greeter_server);
- GDM_FACTORY_SLAVE (slave)->priv->greeter_server = NULL;
- }
+ if (GDM_FACTORY_SLAVE (slave)->priv->greeter_server != NULL) {
+ gdm_greeter_server_stop (GDM_FACTORY_SLAVE (slave)->priv->greeter_server);
+ g_object_unref (GDM_FACTORY_SLAVE (slave)->priv->greeter_server);
+ GDM_FACTORY_SLAVE (slave)->priv->greeter_server = NULL;
+ }
- if (GDM_FACTORY_SLAVE (slave)->priv->greeter != NULL) {
- gdm_greeter_proxy_stop (GDM_FACTORY_SLAVE (slave)->priv->greeter);
- g_object_unref (GDM_FACTORY_SLAVE (slave)->priv->greeter);
- GDM_FACTORY_SLAVE (slave)->priv->greeter = NULL;
- }
+ if (GDM_FACTORY_SLAVE (slave)->priv->greeter != NULL) {
+ gdm_greeter_proxy_stop (GDM_FACTORY_SLAVE (slave)->priv->greeter);
+ g_object_unref (GDM_FACTORY_SLAVE (slave)->priv->greeter);
+ GDM_FACTORY_SLAVE (slave)->priv->greeter = NULL;
+ }
- if (GDM_FACTORY_SLAVE (slave)->priv->server != NULL) {
- gdm_server_stop (GDM_FACTORY_SLAVE (slave)->priv->server);
- g_object_unref (GDM_FACTORY_SLAVE (slave)->priv->server);
- GDM_FACTORY_SLAVE (slave)->priv->server = NULL;
- }
+ if (GDM_FACTORY_SLAVE (slave)->priv->server != NULL) {
+ gdm_server_stop (GDM_FACTORY_SLAVE (slave)->priv->server);
+ g_object_unref (GDM_FACTORY_SLAVE (slave)->priv->server);
+ GDM_FACTORY_SLAVE (slave)->priv->server = NULL;
+ }
- if (GDM_FACTORY_SLAVE (slave)->priv->factory_display_proxy != NULL) {
- g_object_unref (GDM_FACTORY_SLAVE (slave)->priv->factory_display_proxy);
- }
+ if (GDM_FACTORY_SLAVE (slave)->priv->factory_display_proxy != NULL) {
+ g_object_unref (GDM_FACTORY_SLAVE (slave)->priv->factory_display_proxy);
+ }
- return TRUE;
+ return TRUE;
}
static void
gdm_factory_slave_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GdmFactorySlave *self;
+ GdmFactorySlave *self;
- self = GDM_FACTORY_SLAVE (object);
+ self = GDM_FACTORY_SLAVE (object);
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_factory_slave_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GdmFactorySlave *self;
+ GdmFactorySlave *self;
- self = GDM_FACTORY_SLAVE (object);
+ self = GDM_FACTORY_SLAVE (object);
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static GObject *
gdm_factory_slave_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
{
GdmFactorySlave *factory_slave;
GdmFactorySlaveClass *klass;
@@ -949,8 +949,8 @@ gdm_factory_slave_constructor (GType type,
klass = GDM_FACTORY_SLAVE_CLASS (g_type_class_peek (GDM_TYPE_FACTORY_SLAVE));
factory_slave = GDM_FACTORY_SLAVE (G_OBJECT_CLASS (gdm_factory_slave_parent_class)->constructor (type,
- n_construct_properties,
- construct_properties));
+ n_construct_properties,
+ construct_properties));
return G_OBJECT (factory_slave);
}
@@ -958,32 +958,32 @@ gdm_factory_slave_constructor (GType type,
static void
gdm_factory_slave_class_init (GdmFactorySlaveClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GdmSlaveClass *slave_class = GDM_SLAVE_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GdmSlaveClass *slave_class = GDM_SLAVE_CLASS (klass);
- object_class->get_property = gdm_factory_slave_get_property;
- object_class->set_property = gdm_factory_slave_set_property;
+ object_class->get_property = gdm_factory_slave_get_property;
+ object_class->set_property = gdm_factory_slave_set_property;
object_class->constructor = gdm_factory_slave_constructor;
- object_class->finalize = gdm_factory_slave_finalize;
+ object_class->finalize = gdm_factory_slave_finalize;
- slave_class->start = gdm_factory_slave_start;
- slave_class->stop = gdm_factory_slave_stop;
+ slave_class->start = gdm_factory_slave_start;
+ slave_class->stop = gdm_factory_slave_stop;
- g_type_class_add_private (klass, sizeof (GdmFactorySlavePrivate));
+ g_type_class_add_private (klass, sizeof (GdmFactorySlavePrivate));
- dbus_g_object_type_install_info (GDM_TYPE_FACTORY_SLAVE, &dbus_glib_gdm_factory_slave_object_info);
+ dbus_g_object_type_install_info (GDM_TYPE_FACTORY_SLAVE, &dbus_glib_gdm_factory_slave_object_info);
}
static void
gdm_factory_slave_init (GdmFactorySlave *slave)
{
- GError *error;
+ GError *error;
- slave->priv = GDM_FACTORY_SLAVE_GET_PRIVATE (slave);
+ slave->priv = GDM_FACTORY_SLAVE_GET_PRIVATE (slave);
- slave->priv->pid = -1;
+ slave->priv->pid = -1;
- error = NULL;
+ error = NULL;
slave->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
if (slave->priv->connection == NULL) {
if (error != NULL) {
@@ -997,30 +997,30 @@ gdm_factory_slave_init (GdmFactorySlave *slave)
static void
gdm_factory_slave_finalize (GObject *object)
{
- GdmFactorySlave *factory_slave;
+ GdmFactorySlave *factory_slave;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_FACTORY_SLAVE (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_FACTORY_SLAVE (object));
- factory_slave = GDM_FACTORY_SLAVE (object);
+ factory_slave = GDM_FACTORY_SLAVE (object);
- g_debug ("Finalizing slave");
+ g_debug ("Finalizing slave");
- g_return_if_fail (factory_slave->priv != NULL);
+ g_return_if_fail (factory_slave->priv != NULL);
- gdm_factory_slave_stop (GDM_SLAVE (factory_slave));
+ gdm_factory_slave_stop (GDM_SLAVE (factory_slave));
- G_OBJECT_CLASS (gdm_factory_slave_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_factory_slave_parent_class)->finalize (object);
}
GdmSlave *
gdm_factory_slave_new (const char *id)
{
- GObject *object;
+ GObject *object;
- object = g_object_new (GDM_TYPE_FACTORY_SLAVE,
- "display-id", id,
- NULL);
+ object = g_object_new (GDM_TYPE_FACTORY_SLAVE,
+ "display-id", id,
+ NULL);
- return GDM_SLAVE (object);
+ return GDM_SLAVE (object);
}
diff --git a/daemon/gdm-factory-slave.h b/daemon/gdm-factory-slave.h
index acd77a38..9e9770f0 100644
--- a/daemon/gdm-factory-slave.h
+++ b/daemon/gdm-factory-slave.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -38,16 +38,16 @@ typedef struct GdmFactorySlavePrivate GdmFactorySlavePrivate;
typedef struct
{
- GdmSlave parent;
- GdmFactorySlavePrivate *priv;
+ GdmSlave parent;
+ GdmFactorySlavePrivate *priv;
} GdmFactorySlave;
typedef struct
{
- GdmSlaveClass parent_class;
+ GdmSlaveClass parent_class;
} GdmFactorySlaveClass;
-GType gdm_factory_slave_get_type (void);
+GType gdm_factory_slave_get_type (void);
GdmSlave * gdm_factory_slave_new (const char *id);
G_END_DECLS
diff --git a/daemon/gdm-greeter-proxy.c b/daemon/gdm-greeter-proxy.c
index 64c33957..b3f3f11a 100644
--- a/daemon/gdm-greeter-proxy.c
+++ b/daemon/gdm-greeter-proxy.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -54,53 +54,53 @@ extern char **environ;
struct GdmGreeterProxyPrivate
{
- char *command;
- GPid pid;
+ char *command;
+ GPid pid;
- char *user_name;
- char *group_name;
+ char *user_name;
+ char *group_name;
- char *x11_display_name;
- char *x11_display_device;
- char *x11_display_hostname;
- char *x11_authority_file;
- gboolean x11_display_is_local;
+ char *x11_display_name;
+ char *x11_display_device;
+ char *x11_display_hostname;
+ char *x11_authority_file;
+ gboolean x11_display_is_local;
- CkConnector *ckc;
+ CkConnector *ckc;
- int user_max_filesize;
+ int user_max_filesize;
- gboolean interrupted;
- gboolean always_restart_greeter;
+ gboolean interrupted;
+ gboolean always_restart_greeter;
- guint child_watch_id;
+ guint child_watch_id;
- char *server_address;
+ char *server_address;
};
enum {
- PROP_0,
- PROP_X11_DISPLAY_NAME,
- PROP_X11_DISPLAY_DEVICE,
- PROP_X11_DISPLAY_HOSTNAME,
- PROP_X11_DISPLAY_IS_LOCAL,
- PROP_X11_AUTHORITY_FILE,
- PROP_USER_NAME,
- PROP_GROUP_NAME,
- PROP_SERVER_ADDRESS,
+ PROP_0,
+ PROP_X11_DISPLAY_NAME,
+ PROP_X11_DISPLAY_DEVICE,
+ PROP_X11_DISPLAY_HOSTNAME,
+ PROP_X11_DISPLAY_IS_LOCAL,
+ PROP_X11_AUTHORITY_FILE,
+ PROP_USER_NAME,
+ PROP_GROUP_NAME,
+ PROP_SERVER_ADDRESS,
};
enum {
- STARTED,
- STOPPED,
- LAST_SIGNAL
+ STARTED,
+ STOPPED,
+ LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0, };
-static void gdm_greeter_proxy_class_init (GdmGreeterProxyClass *klass);
-static void gdm_greeter_proxy_init (GdmGreeterProxy *greeter_proxy);
-static void gdm_greeter_proxy_finalize (GObject *object);
+static void gdm_greeter_proxy_class_init (GdmGreeterProxyClass *klass);
+static void gdm_greeter_proxy_init (GdmGreeterProxy *greeter_proxy);
+static void gdm_greeter_proxy_finalize (GObject *object);
G_DEFINE_TYPE (GdmGreeterProxy, gdm_greeter_proxy, G_TYPE_OBJECT)
@@ -109,136 +109,136 @@ static void
change_user (GdmGreeterProxy *greeter_proxy)
{
- struct passwd *pwent;
- struct group *grent;
-
- if (greeter_proxy->priv->user_name == NULL) {
- return;
- }
-
- pwent = getpwnam (greeter_proxy->priv->user_name);
- if (pwent == NULL) {
- g_warning (_("GreeterProxy was to be spawned by user %s but that user doesn't exist"),
- greeter_proxy->priv->user_name);
- _exit (1);
- }
-
- grent = getgrnam (greeter_proxy->priv->group_name);
- if (grent == NULL) {
- g_warning (_("GreeterProxy was to be spawned by group %s but that user doesn't exist"),
- greeter_proxy->priv->group_name);
- _exit (1);
- }
-
- g_debug ("Changing (uid:gid) for child process to (%d:%d)",
- pwent->pw_uid,
- grent->gr_gid);
-
- if (pwent->pw_uid != 0) {
- if (setgid (grent->gr_gid) < 0) {
- g_warning (_("Couldn't set groupid to %d"),
- grent->gr_gid);
- _exit (1);
- }
-
- if (initgroups (pwent->pw_name, pwent->pw_gid) < 0) {
- g_warning (_("initgroups () failed for %s"),
- pwent->pw_name);
- _exit (1);
- }
-
- if (setuid (pwent->pw_uid) < 0) {
- g_warning (_("Couldn't set userid to %d"),
- (int)pwent->pw_uid);
- _exit (1);
- }
- } else {
- gid_t groups[1] = { 0 };
-
- if (setgid (0) < 0) {
- g_warning (_("Couldn't set groupid to 0"));
- /* Don't error out, it's not fatal, if it fails we'll
- * just still be */
- }
-
- /* this will get rid of any suplementary groups etc... */
- setgroups (1, groups);
- }
+ struct passwd *pwent;
+ struct group *grent;
+
+ if (greeter_proxy->priv->user_name == NULL) {
+ return;
+ }
+
+ pwent = getpwnam (greeter_proxy->priv->user_name);
+ if (pwent == NULL) {
+ g_warning (_("GreeterProxy was to be spawned by user %s but that user doesn't exist"),
+ greeter_proxy->priv->user_name);
+ _exit (1);
+ }
+
+ grent = getgrnam (greeter_proxy->priv->group_name);
+ if (grent == NULL) {
+ g_warning (_("GreeterProxy was to be spawned by group %s but that user doesn't exist"),
+ greeter_proxy->priv->group_name);
+ _exit (1);
+ }
+
+ g_debug ("Changing (uid:gid) for child process to (%d:%d)",
+ pwent->pw_uid,
+ grent->gr_gid);
+
+ if (pwent->pw_uid != 0) {
+ if (setgid (grent->gr_gid) < 0) {
+ g_warning (_("Couldn't set groupid to %d"),
+ grent->gr_gid);
+ _exit (1);
+ }
+
+ if (initgroups (pwent->pw_name, pwent->pw_gid) < 0) {
+ g_warning (_("initgroups () failed for %s"),
+ pwent->pw_name);
+ _exit (1);
+ }
+
+ if (setuid (pwent->pw_uid) < 0) {
+ g_warning (_("Couldn't set userid to %d"),
+ (int)pwent->pw_uid);
+ _exit (1);
+ }
+ } else {
+ gid_t groups[1] = { 0 };
+
+ if (setgid (0) < 0) {
+ g_warning (_("Couldn't set groupid to 0"));
+ /* Don't error out, it's not fatal, if it fails we'll
+ * just still be */
+ }
+
+ /* this will get rid of any suplementary groups etc... */
+ setgroups (1, groups);
+ }
}
static void
greeter_proxy_child_setup (GdmGreeterProxy *greeter_proxy)
{
- change_user (greeter_proxy);
+ change_user (greeter_proxy);
}
static void
listify_hash (const char *key,
- const char *value,
- GPtrArray *env)
+ const char *value,
+ GPtrArray *env)
{
- char *str;
- str = g_strdup_printf ("%s=%s", key, value);
- g_debug ("greeter environment: %s", str);
- g_ptr_array_add (env, str);
+ char *str;
+ str = g_strdup_printf ("%s=%s", key, value);
+ g_debug ("greeter environment: %s", str);
+ g_ptr_array_add (env, str);
}
static gboolean
open_greeter_session (GdmGreeterProxy *greeter_proxy)
{
- struct passwd *pwent;
- const char *session;
- const char *hostname;
- const char *x11_display_device;
- int res;
- gboolean ret;
- DBusError error;
-
- ret = FALSE;
-
- /* FIXME: */
- session = "greeter";
-
- pwent = getpwnam (greeter_proxy->priv->user_name);
- if (pwent == NULL) {
- /* FIXME: */
- g_warning ("Couldn't look up uid");
- goto out;
- }
-
- greeter_proxy->priv->ckc = ck_connector_new ();
- if (greeter_proxy->priv->ckc == NULL) {
- g_warning ("Couldn't create new ConsoleKit connector");
- goto out;
- }
-
- if (greeter_proxy->priv->x11_display_hostname != NULL) {
- hostname = greeter_proxy->priv->x11_display_hostname;
- } else {
- hostname = "";
- }
-
- if (greeter_proxy->priv->x11_display_device != NULL) {
- x11_display_device = greeter_proxy->priv->x11_display_device;
- } else {
- x11_display_device = "";
- }
-
- g_debug ("Opening ConsoleKit session for user:%d x11-display:'%s' x11-display-device:'%s' remote-host-name:'%s' is-local:%d",
- pwent->pw_uid,
- greeter_proxy->priv->x11_display_name,
- x11_display_device,
- hostname,
- greeter_proxy->priv->x11_display_is_local);
-
- dbus_error_init (&error);
+ struct passwd *pwent;
+ const char *session;
+ const char *hostname;
+ const char *x11_display_device;
+ int res;
+ gboolean ret;
+ DBusError error;
+
+ ret = FALSE;
+
+ /* FIXME: */
+ session = "greeter";
+
+ pwent = getpwnam (greeter_proxy->priv->user_name);
+ if (pwent == NULL) {
+ /* FIXME: */
+ g_warning ("Couldn't look up uid");
+ goto out;
+ }
+
+ greeter_proxy->priv->ckc = ck_connector_new ();
+ if (greeter_proxy->priv->ckc == NULL) {
+ g_warning ("Couldn't create new ConsoleKit connector");
+ goto out;
+ }
+
+ if (greeter_proxy->priv->x11_display_hostname != NULL) {
+ hostname = greeter_proxy->priv->x11_display_hostname;
+ } else {
+ hostname = "";
+ }
+
+ if (greeter_proxy->priv->x11_display_device != NULL) {
+ x11_display_device = greeter_proxy->priv->x11_display_device;
+ } else {
+ x11_display_device = "";
+ }
+
+ g_debug ("Opening ConsoleKit session for user:%d x11-display:'%s' x11-display-device:'%s' remote-host-name:'%s' is-local:%d",
+ pwent->pw_uid,
+ greeter_proxy->priv->x11_display_name,
+ x11_display_device,
+ hostname,
+ greeter_proxy->priv->x11_display_is_local);
+
+ dbus_error_init (&error);
res = ck_connector_open_session_with_parameters (greeter_proxy->priv->ckc,
&error,
"unix-user", &pwent->pw_uid,
"x11-display", &greeter_proxy->priv->x11_display_name,
"x11-display-device", &x11_display_device,
"remote-host-name", &hostname,
- "is-local", &greeter_proxy->priv->x11_display_is_local,
+ "is-local", &greeter_proxy->priv->x11_display_is_local,
NULL);
if (! res) {
if (dbus_error_is_set (&error)) {
@@ -246,158 +246,158 @@ open_greeter_session (GdmGreeterProxy *greeter_proxy)
dbus_error_free (&error);
} else {
g_warning ("cannot open CK session: OOM, D-Bus system bus not available,\n"
- "ConsoleKit not available or insufficient privileges.\n");
+ "ConsoleKit not available or insufficient privileges.\n");
}
- goto out;
+ goto out;
}
- ret = TRUE;
+ ret = TRUE;
out:
- return ret;
+ return ret;
}
static gboolean
close_greeter_session (GdmGreeterProxy *greeter_proxy)
{
- int res;
- gboolean ret;
- DBusError error;
+ int res;
+ gboolean ret;
+ DBusError error;
- ret = FALSE;
+ ret = FALSE;
- if (greeter_proxy->priv->ckc == NULL) {
- return FALSE;
- }
+ if (greeter_proxy->priv->ckc == NULL) {
+ return FALSE;
+ }
- dbus_error_init (&error);
- res = ck_connector_close_session (greeter_proxy->priv->ckc, &error);
+ dbus_error_init (&error);
+ res = ck_connector_close_session (greeter_proxy->priv->ckc, &error);
if (! res) {
if (dbus_error_is_set (&error)) {
g_warning ("%s\n", error.message);
dbus_error_free (&error);
} else {
g_warning ("cannot open CK session: OOM, D-Bus system bus not available,\n"
- "ConsoleKit not available or insufficient privileges.\n");
+ "ConsoleKit not available or insufficient privileges.\n");
}
- goto out;
+ goto out;
}
- ret = TRUE;
+ ret = TRUE;
out:
- return ret;
+ return ret;
}
static GPtrArray *
get_greeter_environment (GdmGreeterProxy *greeter_proxy)
{
- GPtrArray *env;
- GHashTable *hash;
- struct passwd *pwent;
+ GPtrArray *env;
+ GHashTable *hash;
+ struct passwd *pwent;
- env = g_ptr_array_new ();
+ env = g_ptr_array_new ();
- /* create a hash table of current environment, then update keys has necessary */
- hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+ /* create a hash table of current environment, then update keys has necessary */
+ hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- g_hash_table_insert (hash, g_strdup ("GDM_GREETER_DBUS_ADDRESS"), g_strdup (greeter_proxy->priv->server_address));
+ g_hash_table_insert (hash, g_strdup ("GDM_GREETER_DBUS_ADDRESS"), g_strdup (greeter_proxy->priv->server_address));
- g_hash_table_insert (hash, g_strdup ("XAUTHORITY"), g_strdup (greeter_proxy->priv->x11_authority_file));
- g_hash_table_insert (hash, g_strdup ("DISPLAY"), g_strdup (greeter_proxy->priv->x11_display_name));
+ g_hash_table_insert (hash, g_strdup ("XAUTHORITY"), g_strdup (greeter_proxy->priv->x11_authority_file));
+ g_hash_table_insert (hash, g_strdup ("DISPLAY"), g_strdup (greeter_proxy->priv->x11_display_name));
#if 0
- /* hackish ain't it */
- set_xnest_parent_stuff ();
+ /* hackish ain't it */
+ set_xnest_parent_stuff ();
#endif
- if (greeter_proxy->priv->ckc != NULL) {
- const char *cookie;
- cookie = ck_connector_get_cookie (greeter_proxy->priv->ckc);
- if (cookie != NULL) {
- g_hash_table_insert (hash, g_strdup ("XDG_SESSION_COOKIE"), g_strdup (cookie));
- }
- }
+ if (greeter_proxy->priv->ckc != NULL) {
+ const char *cookie;
+ cookie = ck_connector_get_cookie (greeter_proxy->priv->ckc);
+ if (cookie != NULL) {
+ g_hash_table_insert (hash, g_strdup ("XDG_SESSION_COOKIE"), g_strdup (cookie));
+ }
+ }
- g_hash_table_insert (hash, g_strdup ("LOGNAME"), g_strdup (greeter_proxy->priv->user_name));
- g_hash_table_insert (hash, g_strdup ("USER"), g_strdup (greeter_proxy->priv->user_name));
- g_hash_table_insert (hash, g_strdup ("USERNAME"), g_strdup (greeter_proxy->priv->user_name));
+ g_hash_table_insert (hash, g_strdup ("LOGNAME"), g_strdup (greeter_proxy->priv->user_name));
+ g_hash_table_insert (hash, g_strdup ("USER"), g_strdup (greeter_proxy->priv->user_name));
+ g_hash_table_insert (hash, g_strdup ("USERNAME"), g_strdup (greeter_proxy->priv->user_name));
- g_hash_table_insert (hash, g_strdup ("GDM_VERSION"), g_strdup (VERSION));
- g_hash_table_remove (hash, "MAIL");
+ g_hash_table_insert (hash, g_strdup ("GDM_VERSION"), g_strdup (VERSION));
+ g_hash_table_remove (hash, "MAIL");
- g_hash_table_insert (hash, g_strdup ("HOME"), g_strdup ("/"));
- g_hash_table_insert (hash, g_strdup ("PWD"), g_strdup ("/"));
- g_hash_table_insert (hash, g_strdup ("SHELL"), g_strdup ("/bin/sh"));
+ g_hash_table_insert (hash, g_strdup ("HOME"), g_strdup ("/"));
+ g_hash_table_insert (hash, g_strdup ("PWD"), g_strdup ("/"));
+ g_hash_table_insert (hash, g_strdup ("SHELL"), g_strdup ("/bin/sh"));
- pwent = getpwnam (greeter_proxy->priv->user_name);
- if (pwent != NULL) {
- if (pwent->pw_dir != NULL && pwent->pw_dir[0] != '\0') {
- g_hash_table_insert (hash, g_strdup ("HOME"), g_strdup (pwent->pw_dir));
- g_hash_table_insert (hash, g_strdup ("PWD"), g_strdup (pwent->pw_dir));
- }
+ pwent = getpwnam (greeter_proxy->priv->user_name);
+ if (pwent != NULL) {
+ if (pwent->pw_dir != NULL && pwent->pw_dir[0] != '\0') {
+ g_hash_table_insert (hash, g_strdup ("HOME"), g_strdup (pwent->pw_dir));
+ g_hash_table_insert (hash, g_strdup ("PWD"), g_strdup (pwent->pw_dir));
+ }
- g_hash_table_insert (hash, g_strdup ("SHELL"), g_strdup (pwent->pw_shell));
- }
+ g_hash_table_insert (hash, g_strdup ("SHELL"), g_strdup (pwent->pw_shell));
+ }
- g_hash_table_insert (hash, g_strdup ("PATH"), g_strdup (g_getenv ("PATH")));
+ g_hash_table_insert (hash, g_strdup ("PATH"), g_strdup (g_getenv ("PATH")));
#if 0
- defaultpath = gdm_daemon_config_get_value_string (GDM_KEY_PATH);
- if (ve_string_empty (g_getenv ("PATH"))) {
- g_setenv ("PATH", defaultpath, TRUE);
- } else if ( ! ve_string_empty (defaultpath)) {
- gchar *temp_string = g_strconcat (g_getenv ("PATH"),
- ":", defaultpath, NULL);
- g_setenv ("PATH", temp_string, TRUE);
- g_free (temp_string);
- }
+ defaultpath = gdm_daemon_config_get_value_string (GDM_KEY_PATH);
+ if (ve_string_empty (g_getenv ("PATH"))) {
+ g_setenv ("PATH", defaultpath, TRUE);
+ } else if ( ! ve_string_empty (defaultpath)) {
+ gchar *temp_string = g_strconcat (g_getenv ("PATH"),
+ ":", defaultpath, NULL);
+ g_setenv ("PATH", temp_string, TRUE);
+ g_free (temp_string);
+ }
#endif
- g_hash_table_insert (hash, g_strdup ("RUNNING_UNDER_GDM"), g_strdup ("true"));
+ g_hash_table_insert (hash, g_strdup ("RUNNING_UNDER_GDM"), g_strdup ("true"));
#if 0
- if ( ! ve_string_empty (d->theme_name))
- g_setenv ("GDM_GTK_THEME", d->theme_name, TRUE);
- if (gdm_daemon_config_get_value_bool (GDM_KEY_DEBUG_GESTURES)) {
- g_setenv ("G_DEBUG_GESTURES", "true", TRUE);
- }
+ if ( ! ve_string_empty (d->theme_name))
+ g_setenv ("GDM_GTK_THEME", d->theme_name, TRUE);
+ if (gdm_daemon_config_get_value_bool (GDM_KEY_DEBUG_GESTURES)) {
+ g_setenv ("G_DEBUG_GESTURES", "true", TRUE);
+ }
#endif
#if 0
- if (SERVER_IS_FLEXI (d)) {
- g_setenv ("GDM_FLEXI_SERVER", "yes", TRUE);
- } else {
- g_unsetenv ("GDM_FLEXI_SERVER");
- }
+ if (SERVER_IS_FLEXI (d)) {
+ g_setenv ("GDM_FLEXI_SERVER", "yes", TRUE);
+ } else {
+ g_unsetenv ("GDM_FLEXI_SERVER");
+ }
#endif
- g_hash_table_foreach (hash, (GHFunc)listify_hash, env);
- g_hash_table_destroy (hash);
+ g_hash_table_foreach (hash, (GHFunc)listify_hash, env);
+ g_hash_table_destroy (hash);
- g_ptr_array_add (env, NULL);
+ g_ptr_array_add (env, NULL);
- return env;
+ return env;
}
static void
gdm_slave_whack_temp_auth_file (GdmGreeterProxy *greeter_proxy)
{
#if 0
- uid_t old;
-
- old = geteuid ();
- if (old != 0)
- seteuid (0);
- if (d->parent_temp_auth_file != NULL) {
- VE_IGNORE_EINTR (g_unlink (d->parent_temp_auth_file));
- }
- g_free (d->parent_temp_auth_file);
- d->parent_temp_auth_file = NULL;
- if (old != 0)
- seteuid (old);
+ uid_t old;
+
+ old = geteuid ();
+ if (old != 0)
+ seteuid (0);
+ if (d->parent_temp_auth_file != NULL) {
+ VE_IGNORE_EINTR (g_unlink (d->parent_temp_auth_file));
+ }
+ g_free (d->parent_temp_auth_file);
+ d->parent_temp_auth_file = NULL;
+ if (old != 0)
+ seteuid (old);
#endif
}
@@ -406,100 +406,100 @@ static void
create_temp_auth_file (GdmGreeterProxy *greeter_proxy)
{
#if 0
- if (d->type == TYPE_FLEXI_XNEST &&
- d->parent_auth_file != NULL) {
- if (d->parent_temp_auth_file != NULL) {
- VE_IGNORE_EINTR (g_unlink (d->parent_temp_auth_file));
- }
- g_free (d->parent_temp_auth_file);
- d->parent_temp_auth_file =
- copy_auth_file (d->server_uid,
- gdm_daemon_config_get_gdmuid (),
- d->parent_auth_file);
- }
+ if (d->type == TYPE_FLEXI_XNEST &&
+ d->parent_auth_file != NULL) {
+ if (d->parent_temp_auth_file != NULL) {
+ VE_IGNORE_EINTR (g_unlink (d->parent_temp_auth_file));
+ }
+ g_free (d->parent_temp_auth_file);
+ d->parent_temp_auth_file =
+ copy_auth_file (d->server_uid,
+ gdm_daemon_config_get_gdmuid (),
+ d->parent_auth_file);
+ }
#endif
}
static void
greeter_proxy_child_watch (GPid pid,
- int status,
- GdmGreeterProxy *greeter_proxy)
+ int status,
+ GdmGreeterProxy *greeter_proxy)
{
- g_debug ("child (pid:%d) done (%s:%d)",
- (int) pid,
- WIFEXITED (status) ? "status"
- : WIFSIGNALED (status) ? "signal"
- : "unknown",
- WIFEXITED (status) ? WEXITSTATUS (status)
- : WIFSIGNALED (status) ? WTERMSIG (status)
- : -1);
-
- g_spawn_close_pid (greeter_proxy->priv->pid);
- greeter_proxy->priv->pid = -1;
-
- if (greeter_proxy->priv->ckc != NULL) {
- close_greeter_session (greeter_proxy);
- }
+ g_debug ("child (pid:%d) done (%s:%d)",
+ (int) pid,
+ WIFEXITED (status) ? "status"
+ : WIFSIGNALED (status) ? "signal"
+ : "unknown",
+ WIFEXITED (status) ? WEXITSTATUS (status)
+ : WIFSIGNALED (status) ? WTERMSIG (status)
+ : -1);
+
+ g_spawn_close_pid (greeter_proxy->priv->pid);
+ greeter_proxy->priv->pid = -1;
+
+ if (greeter_proxy->priv->ckc != NULL) {
+ close_greeter_session (greeter_proxy);
+ }
}
static gboolean
gdm_greeter_proxy_spawn (GdmGreeterProxy *greeter_proxy)
{
- gchar **argv;
- GError *error;
- GPtrArray *env;
- gboolean ret;
-
- ret = FALSE;
-
- create_temp_auth_file (greeter_proxy);
-
- g_debug ("Running greeter_proxy process: %s", greeter_proxy->priv->command);
-
- argv = NULL;
- if (! g_shell_parse_argv (greeter_proxy->priv->command, NULL, &argv, &error)) {
- g_warning ("Could not parse command: %s", error->message);
- g_error_free (error);
- goto out;
- }
-
- open_greeter_session (greeter_proxy);
-
- env = get_greeter_environment (greeter_proxy);
-
- error = NULL;
- ret = g_spawn_async_with_pipes (NULL,
- argv,
- (char **)env->pdata,
- G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
- (GSpawnChildSetupFunc)greeter_proxy_child_setup,
- greeter_proxy,
- &greeter_proxy->priv->pid,
- NULL,
- NULL,
- NULL,
- &error);
-
- g_ptr_array_foreach (env, (GFunc)g_free, NULL);
+ gchar **argv;
+ GError *error;
+ GPtrArray *env;
+ gboolean ret;
+
+ ret = FALSE;
+
+ create_temp_auth_file (greeter_proxy);
+
+ g_debug ("Running greeter_proxy process: %s", greeter_proxy->priv->command);
+
+ argv = NULL;
+ if (! g_shell_parse_argv (greeter_proxy->priv->command, NULL, &argv, &error)) {
+ g_warning ("Could not parse command: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ open_greeter_session (greeter_proxy);
+
+ env = get_greeter_environment (greeter_proxy);
+
+ error = NULL;
+ ret = g_spawn_async_with_pipes (NULL,
+ argv,
+ (char **)env->pdata,
+ G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
+ (GSpawnChildSetupFunc)greeter_proxy_child_setup,
+ greeter_proxy,
+ &greeter_proxy->priv->pid,
+ NULL,
+ NULL,
+ NULL,
+ &error);
+
+ g_ptr_array_foreach (env, (GFunc)g_free, NULL);
g_ptr_array_free (env, TRUE);
- if (! ret) {
- g_warning ("Could not start command '%s': %s",
- greeter_proxy->priv->command,
- error->message);
- g_error_free (error);
- } else {
- g_debug ("gdm_slave_greeter_proxy: GreeterProxy on pid %d", (int)greeter_proxy->priv->pid);
- }
+ if (! ret) {
+ g_warning ("Could not start command '%s': %s",
+ greeter_proxy->priv->command,
+ error->message);
+ g_error_free (error);
+ } else {
+ g_debug ("gdm_slave_greeter_proxy: GreeterProxy on pid %d", (int)greeter_proxy->priv->pid);
+ }
- greeter_proxy->priv->child_watch_id = g_child_watch_add (greeter_proxy->priv->pid,
- (GChildWatchFunc)greeter_proxy_child_watch,
- greeter_proxy);
+ greeter_proxy->priv->child_watch_id = g_child_watch_add (greeter_proxy->priv->pid,
+ (GChildWatchFunc)greeter_proxy_child_watch,
+ greeter_proxy);
- g_strfreev (argv);
+ g_strfreev (argv);
out:
- return ret;
+ return ret;
}
/**
@@ -511,124 +511,124 @@ gdm_greeter_proxy_spawn (GdmGreeterProxy *greeter_proxy)
gboolean
gdm_greeter_proxy_start (GdmGreeterProxy *greeter_proxy)
{
- gboolean res;
+ gboolean res;
- g_debug ("Starting greeter...");
+ g_debug ("Starting greeter...");
- res = gdm_greeter_proxy_spawn (greeter_proxy);
+ res = gdm_greeter_proxy_spawn (greeter_proxy);
- if (res) {
+ if (res) {
- }
+ }
- return res;
+ return res;
}
static int
signal_pid (int pid,
- int signal)
+ int signal)
{
- int status = -1;
+ int status = -1;
- /* perhaps block sigchld */
+ /* perhaps block sigchld */
- status = kill (pid, signal);
+ status = kill (pid, signal);
- if (status < 0) {
- if (errno == ESRCH) {
- g_warning ("Child process %lu was already dead.",
- (unsigned long) pid);
- } else {
- g_warning ("Couldn't kill child process %lu: %s",
- (unsigned long) pid,
- g_strerror (errno));
- }
- }
+ if (status < 0) {
+ if (errno == ESRCH) {
+ g_warning ("Child process %lu was already dead.",
+ (unsigned long) pid);
+ } else {
+ g_warning ("Couldn't kill child process %lu: %s",
+ (unsigned long) pid,
+ g_strerror (errno));
+ }
+ }
- /* perhaps unblock sigchld */
+ /* perhaps unblock sigchld */
- return status;
+ return status;
}
static int
wait_on_child (int pid)
{
- int status;
+ int status;
wait_again:
- if (waitpid (pid, &status, 0) < 0) {
- if (errno == EINTR) {
- goto wait_again;
- } else if (errno == ECHILD) {
- ; /* do nothing, child already reaped */
- } else {
- g_debug ("waitpid () should not fail");
- }
- }
-
- return status;
+ if (waitpid (pid, &status, 0) < 0) {
+ if (errno == EINTR) {
+ goto wait_again;
+ } else if (errno == ECHILD) {
+ ; /* do nothing, child already reaped */
+ } else {
+ g_debug ("waitpid () should not fail");
+ }
+ }
+
+ return status;
}
static void
greeter_proxy_died (GdmGreeterProxy *greeter_proxy)
{
- int exit_status;
+ int exit_status;
- g_debug ("Waiting on process %d", greeter_proxy->priv->pid);
- exit_status = wait_on_child (greeter_proxy->priv->pid);
+ g_debug ("Waiting on process %d", greeter_proxy->priv->pid);
+ exit_status = wait_on_child (greeter_proxy->priv->pid);
- if (WIFEXITED (exit_status) && (WEXITSTATUS (exit_status) != 0)) {
- g_debug ("Wait on child process failed");
- } else {
- /* exited normally */
- }
+ if (WIFEXITED (exit_status) && (WEXITSTATUS (exit_status) != 0)) {
+ g_debug ("Wait on child process failed");
+ } else {
+ /* exited normally */
+ }
- g_spawn_close_pid (greeter_proxy->priv->pid);
- greeter_proxy->priv->pid = -1;
+ g_spawn_close_pid (greeter_proxy->priv->pid);
+ greeter_proxy->priv->pid = -1;
- g_debug ("GreeterProxy died");
+ g_debug ("GreeterProxy died");
}
gboolean
gdm_greeter_proxy_stop (GdmGreeterProxy *greeter_proxy)
{
- if (greeter_proxy->priv->pid <= 1) {
- return TRUE;
- }
+ if (greeter_proxy->priv->pid <= 1) {
+ return TRUE;
+ }
- /* remove watch source before we can wait on child */
- if (greeter_proxy->priv->child_watch_id > 0) {
- g_source_remove (greeter_proxy->priv->child_watch_id);
- greeter_proxy->priv->child_watch_id = 0;
- }
+ /* remove watch source before we can wait on child */
+ if (greeter_proxy->priv->child_watch_id > 0) {
+ g_source_remove (greeter_proxy->priv->child_watch_id);
+ greeter_proxy->priv->child_watch_id = 0;
+ }
- g_debug ("Stopping greeter_proxy");
+ g_debug ("Stopping greeter_proxy");
- signal_pid (greeter_proxy->priv->pid, SIGTERM);
- greeter_proxy_died (greeter_proxy);
+ signal_pid (greeter_proxy->priv->pid, SIGTERM);
+ greeter_proxy_died (greeter_proxy);
- if (greeter_proxy->priv->ckc != NULL) {
- close_greeter_session (greeter_proxy);
- }
+ if (greeter_proxy->priv->ckc != NULL) {
+ close_greeter_session (greeter_proxy);
+ }
- return TRUE;
+ return TRUE;
}
void
gdm_greeter_proxy_set_server_address (GdmGreeterProxy *greeter_proxy,
- const char *address)
+ const char *address)
{
- g_return_if_fail (GDM_IS_GREETER_PROXY (greeter_proxy));
+ g_return_if_fail (GDM_IS_GREETER_PROXY (greeter_proxy));
- g_free (greeter_proxy->priv->server_address);
- greeter_proxy->priv->server_address = g_strdup (address);
+ g_free (greeter_proxy->priv->server_address);
+ greeter_proxy->priv->server_address = g_strdup (address);
}
static void
_gdm_greeter_proxy_set_x11_display_name (GdmGreeterProxy *greeter_proxy,
- const char *name)
+ const char *name)
{
g_free (greeter_proxy->priv->x11_display_name);
greeter_proxy->priv->x11_display_name = g_strdup (name);
@@ -636,7 +636,7 @@ _gdm_greeter_proxy_set_x11_display_name (GdmGreeterProxy *greeter_proxy,
static void
_gdm_greeter_proxy_set_x11_display_hostname (GdmGreeterProxy *greeter_proxy,
- const char *name)
+ const char *name)
{
g_free (greeter_proxy->priv->x11_display_hostname);
greeter_proxy->priv->x11_display_hostname = g_strdup (name);
@@ -644,7 +644,7 @@ _gdm_greeter_proxy_set_x11_display_hostname (GdmGreeterProxy *greeter_proxy,
static void
_gdm_greeter_proxy_set_x11_display_device (GdmGreeterProxy *greeter_proxy,
- const char *name)
+ const char *name)
{
g_free (greeter_proxy->priv->x11_display_device);
greeter_proxy->priv->x11_display_device = g_strdup (name);
@@ -652,14 +652,14 @@ _gdm_greeter_proxy_set_x11_display_device (GdmGreeterProxy *greeter_proxy,
static void
_gdm_greeter_proxy_set_x11_display_is_local (GdmGreeterProxy *greeter_proxy,
- gboolean is_local)
+ gboolean is_local)
{
greeter_proxy->priv->x11_display_is_local = is_local;
}
static void
_gdm_greeter_proxy_set_x11_authority_file (GdmGreeterProxy *greeter_proxy,
- const char *file)
+ const char *file)
{
g_free (greeter_proxy->priv->x11_authority_file);
greeter_proxy->priv->x11_authority_file = g_strdup (file);
@@ -667,7 +667,7 @@ _gdm_greeter_proxy_set_x11_authority_file (GdmGreeterProxy *greeter_proxy,
static void
_gdm_greeter_proxy_set_user_name (GdmGreeterProxy *greeter_proxy,
- const char *name)
+ const char *name)
{
g_free (greeter_proxy->priv->user_name);
greeter_proxy->priv->user_name = g_strdup (name);
@@ -675,7 +675,7 @@ _gdm_greeter_proxy_set_user_name (GdmGreeterProxy *greeter_proxy,
static void
_gdm_greeter_proxy_set_group_name (GdmGreeterProxy *greeter_proxy,
- const char *name)
+ const char *name)
{
g_free (greeter_proxy->priv->group_name);
greeter_proxy->priv->group_name = g_strdup (name);
@@ -683,90 +683,90 @@ _gdm_greeter_proxy_set_group_name (GdmGreeterProxy *greeter_proxy,
static void
gdm_greeter_proxy_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GdmGreeterProxy *self;
-
- self = GDM_GREETER_PROXY (object);
-
- switch (prop_id) {
- case PROP_X11_DISPLAY_NAME:
- _gdm_greeter_proxy_set_x11_display_name (self, g_value_get_string (value));
- break;
- case PROP_X11_DISPLAY_HOSTNAME:
- _gdm_greeter_proxy_set_x11_display_hostname (self, g_value_get_string (value));
- break;
- case PROP_X11_DISPLAY_DEVICE:
- _gdm_greeter_proxy_set_x11_display_device (self, g_value_get_string (value));
- break;
- case PROP_X11_DISPLAY_IS_LOCAL:
- _gdm_greeter_proxy_set_x11_display_is_local (self, g_value_get_boolean (value));
- break;
- case PROP_X11_AUTHORITY_FILE:
- _gdm_greeter_proxy_set_x11_authority_file (self, g_value_get_string (value));
- break;
- case PROP_USER_NAME:
- _gdm_greeter_proxy_set_user_name (self, g_value_get_string (value));
- break;
- case PROP_GROUP_NAME:
- _gdm_greeter_proxy_set_group_name (self, g_value_get_string (value));
- break;
- case PROP_SERVER_ADDRESS:
- gdm_greeter_proxy_set_server_address (self, g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GdmGreeterProxy *self;
+
+ self = GDM_GREETER_PROXY (object);
+
+ switch (prop_id) {
+ case PROP_X11_DISPLAY_NAME:
+ _gdm_greeter_proxy_set_x11_display_name (self, g_value_get_string (value));
+ break;
+ case PROP_X11_DISPLAY_HOSTNAME:
+ _gdm_greeter_proxy_set_x11_display_hostname (self, g_value_get_string (value));
+ break;
+ case PROP_X11_DISPLAY_DEVICE:
+ _gdm_greeter_proxy_set_x11_display_device (self, g_value_get_string (value));
+ break;
+ case PROP_X11_DISPLAY_IS_LOCAL:
+ _gdm_greeter_proxy_set_x11_display_is_local (self, g_value_get_boolean (value));
+ break;
+ case PROP_X11_AUTHORITY_FILE:
+ _gdm_greeter_proxy_set_x11_authority_file (self, g_value_get_string (value));
+ break;
+ case PROP_USER_NAME:
+ _gdm_greeter_proxy_set_user_name (self, g_value_get_string (value));
+ break;
+ case PROP_GROUP_NAME:
+ _gdm_greeter_proxy_set_group_name (self, g_value_get_string (value));
+ break;
+ case PROP_SERVER_ADDRESS:
+ gdm_greeter_proxy_set_server_address (self, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_greeter_proxy_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GdmGreeterProxy *self;
-
- self = GDM_GREETER_PROXY (object);
-
- switch (prop_id) {
- case PROP_X11_DISPLAY_NAME:
- g_value_set_string (value, self->priv->x11_display_name);
- break;
- case PROP_X11_DISPLAY_HOSTNAME:
- g_value_set_string (value, self->priv->x11_display_hostname);
- break;
- case PROP_X11_DISPLAY_DEVICE:
- g_value_set_string (value, self->priv->x11_display_device);
- break;
- case PROP_X11_DISPLAY_IS_LOCAL:
- g_value_set_boolean (value, self->priv->x11_display_is_local);
- break;
- case PROP_X11_AUTHORITY_FILE:
- g_value_set_string (value, self->priv->x11_authority_file);
- break;
- case PROP_USER_NAME:
- g_value_set_string (value, self->priv->user_name);
- break;
- case PROP_GROUP_NAME:
- g_value_set_string (value, self->priv->group_name);
- break;
- case PROP_SERVER_ADDRESS:
- g_value_set_string (value, self->priv->server_address);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GdmGreeterProxy *self;
+
+ self = GDM_GREETER_PROXY (object);
+
+ switch (prop_id) {
+ case PROP_X11_DISPLAY_NAME:
+ g_value_set_string (value, self->priv->x11_display_name);
+ break;
+ case PROP_X11_DISPLAY_HOSTNAME:
+ g_value_set_string (value, self->priv->x11_display_hostname);
+ break;
+ case PROP_X11_DISPLAY_DEVICE:
+ g_value_set_string (value, self->priv->x11_display_device);
+ break;
+ case PROP_X11_DISPLAY_IS_LOCAL:
+ g_value_set_boolean (value, self->priv->x11_display_is_local);
+ break;
+ case PROP_X11_AUTHORITY_FILE:
+ g_value_set_string (value, self->priv->x11_authority_file);
+ break;
+ case PROP_USER_NAME:
+ g_value_set_string (value, self->priv->user_name);
+ break;
+ case PROP_GROUP_NAME:
+ g_value_set_string (value, self->priv->group_name);
+ break;
+ case PROP_SERVER_ADDRESS:
+ g_value_set_string (value, self->priv->server_address);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static GObject *
gdm_greeter_proxy_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
{
GdmGreeterProxy *greeter_proxy;
GdmGreeterProxyClass *klass;
@@ -774,8 +774,8 @@ gdm_greeter_proxy_constructor (GType type,
klass = GDM_GREETER_PROXY_CLASS (g_type_class_peek (GDM_TYPE_GREETER_PROXY));
greeter_proxy = GDM_GREETER_PROXY (G_OBJECT_CLASS (gdm_greeter_proxy_parent_class)->constructor (type,
- n_construct_properties,
- construct_properties));
+ n_construct_properties,
+ construct_properties));
return G_OBJECT (greeter_proxy);
}
@@ -783,140 +783,140 @@ gdm_greeter_proxy_constructor (GType type,
static void
gdm_greeter_proxy_class_init (GdmGreeterProxyClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->get_property = gdm_greeter_proxy_get_property;
- object_class->set_property = gdm_greeter_proxy_set_property;
+ object_class->get_property = gdm_greeter_proxy_get_property;
+ object_class->set_property = gdm_greeter_proxy_set_property;
object_class->constructor = gdm_greeter_proxy_constructor;
- object_class->finalize = gdm_greeter_proxy_finalize;
-
- g_type_class_add_private (klass, sizeof (GdmGreeterProxyPrivate));
-
- g_object_class_install_property (object_class,
- PROP_X11_DISPLAY_NAME,
- g_param_spec_string ("x11-display-name",
- "name",
- "name",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_X11_DISPLAY_HOSTNAME,
- g_param_spec_string ("x11-display-hostname",
- "hostname",
- "hostname",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_X11_DISPLAY_DEVICE,
- g_param_spec_string ("x11-display-device",
- "device",
- "device",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_X11_DISPLAY_IS_LOCAL,
- g_param_spec_boolean ("x11-display-is-local",
- "is local",
- "is local",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_X11_AUTHORITY_FILE,
- g_param_spec_string ("x11-authority-file",
- "authority file",
- "authority file",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class,
- PROP_USER_NAME,
- g_param_spec_string ("user-name",
- "user name",
- "user name",
- "gdm",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class,
- PROP_GROUP_NAME,
- g_param_spec_string ("group-name",
- "group name",
- "group name",
- "gdm",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class,
- PROP_SERVER_ADDRESS,
- g_param_spec_string ("server-address",
- "server address",
- "server address",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- signals [STARTED] =
- g_signal_new ("started",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmGreeterProxyClass, started),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- signals [STOPPED] =
- g_signal_new ("stopped",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmGreeterProxyClass, stopped),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
+ object_class->finalize = gdm_greeter_proxy_finalize;
+
+ g_type_class_add_private (klass, sizeof (GdmGreeterProxyPrivate));
+
+ g_object_class_install_property (object_class,
+ PROP_X11_DISPLAY_NAME,
+ g_param_spec_string ("x11-display-name",
+ "name",
+ "name",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_X11_DISPLAY_HOSTNAME,
+ g_param_spec_string ("x11-display-hostname",
+ "hostname",
+ "hostname",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_X11_DISPLAY_DEVICE,
+ g_param_spec_string ("x11-display-device",
+ "device",
+ "device",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_X11_DISPLAY_IS_LOCAL,
+ g_param_spec_boolean ("x11-display-is-local",
+ "is local",
+ "is local",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_X11_AUTHORITY_FILE,
+ g_param_spec_string ("x11-authority-file",
+ "authority file",
+ "authority file",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
+ PROP_USER_NAME,
+ g_param_spec_string ("user-name",
+ "user name",
+ "user name",
+ "gdm",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
+ PROP_GROUP_NAME,
+ g_param_spec_string ("group-name",
+ "group name",
+ "group name",
+ "gdm",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
+ PROP_SERVER_ADDRESS,
+ g_param_spec_string ("server-address",
+ "server address",
+ "server address",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ signals [STARTED] =
+ g_signal_new ("started",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmGreeterProxyClass, started),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ signals [STOPPED] =
+ g_signal_new ("stopped",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmGreeterProxyClass, stopped),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
static void
gdm_greeter_proxy_init (GdmGreeterProxy *greeter_proxy)
{
- greeter_proxy->priv = GDM_GREETER_PROXY_GET_PRIVATE (greeter_proxy);
+ greeter_proxy->priv = GDM_GREETER_PROXY_GET_PRIVATE (greeter_proxy);
- greeter_proxy->priv->pid = -1;
+ greeter_proxy->priv->pid = -1;
- greeter_proxy->priv->command = g_strdup ("dbus-launch --exit-with-session " LIBEXECDIR "/gdm-simple-greeter");
- greeter_proxy->priv->user_max_filesize = 65536;
+ greeter_proxy->priv->command = g_strdup ("dbus-launch --exit-with-session " LIBEXECDIR "/gdm-simple-greeter");
+ greeter_proxy->priv->user_max_filesize = 65536;
}
static void
gdm_greeter_proxy_finalize (GObject *object)
{
- GdmGreeterProxy *greeter_proxy;
+ GdmGreeterProxy *greeter_proxy;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_GREETER_PROXY (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_GREETER_PROXY (object));
- greeter_proxy = GDM_GREETER_PROXY (object);
+ greeter_proxy = GDM_GREETER_PROXY (object);
- g_return_if_fail (greeter_proxy->priv != NULL);
+ g_return_if_fail (greeter_proxy->priv != NULL);
- gdm_greeter_proxy_stop (greeter_proxy);
+ gdm_greeter_proxy_stop (greeter_proxy);
- if (greeter_proxy->priv->ckc != NULL) {
- ck_connector_unref (greeter_proxy->priv->ckc);
- }
+ if (greeter_proxy->priv->ckc != NULL) {
+ ck_connector_unref (greeter_proxy->priv->ckc);
+ }
- G_OBJECT_CLASS (gdm_greeter_proxy_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_greeter_proxy_parent_class)->finalize (object);
}
GdmGreeterProxy *
gdm_greeter_proxy_new (const char *display_name,
- const char *display_device,
- const char *display_hostname,
- gboolean display_is_local)
+ const char *display_device,
+ const char *display_hostname,
+ gboolean display_is_local)
{
- GObject *object;
+ GObject *object;
- object = g_object_new (GDM_TYPE_GREETER_PROXY,
- "x11-display-name", display_name,
- "x11-display-device", display_device,
- "x11-display-hostname", display_hostname,
- "x11-display-is-local", display_is_local,
- NULL);
+ object = g_object_new (GDM_TYPE_GREETER_PROXY,
+ "x11-display-name", display_name,
+ "x11-display-device", display_device,
+ "x11-display-hostname", display_hostname,
+ "x11-display-is-local", display_is_local,
+ NULL);
- return GDM_GREETER_PROXY (object);
+ return GDM_GREETER_PROXY (object);
}
diff --git a/daemon/gdm-greeter-proxy.h b/daemon/gdm-greeter-proxy.h
index b2701551..068847d7 100644
--- a/daemon/gdm-greeter-proxy.h
+++ b/daemon/gdm-greeter-proxy.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -37,25 +37,25 @@ typedef struct GdmGreeterProxyPrivate GdmGreeterProxyPrivate;
typedef struct
{
- GObject parent;
- GdmGreeterProxyPrivate *priv;
+ GObject parent;
+ GdmGreeterProxyPrivate *priv;
} GdmGreeterProxy;
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
- void (* started) (GdmGreeterProxy *greeter_proxy);
- void (* stopped) (GdmGreeterProxy *greeter_proxy);
+ void (* started) (GdmGreeterProxy *greeter_proxy);
+ void (* stopped) (GdmGreeterProxy *greeter_proxy);
} GdmGreeterProxyClass;
-GType gdm_greeter_proxy_get_type (void);
-GdmGreeterProxy * gdm_greeter_proxy_new (const char *display_name,
- const char *display_device,
- const char *display_hostname,
- gboolean display_is_local);
+GType gdm_greeter_proxy_get_type (void);
+GdmGreeterProxy * gdm_greeter_proxy_new (const char *display_name,
+ const char *display_device,
+ const char *display_hostname,
+ gboolean display_is_local);
void gdm_greeter_proxy_set_server_address (GdmGreeterProxy *greeter_proxy,
- const char *server_address);
+ const char *server_address);
gboolean gdm_greeter_proxy_start (GdmGreeterProxy *greeter_proxy);
gboolean gdm_greeter_proxy_stop (GdmGreeterProxy *greeter_proxy);
diff --git a/daemon/gdm-greeter-server.c b/daemon/gdm-greeter-server.c
index 9556a13a..d9094a99 100644
--- a/daemon/gdm-greeter-server.c
+++ b/daemon/gdm-greeter-server.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -52,148 +52,148 @@
struct GdmGreeterServerPrivate
{
- char *user_name;
- char *group_name;
+ char *user_name;
+ char *group_name;
- gboolean interrupted;
- gboolean always_restart_greeter;
+ gboolean interrupted;
+ gboolean always_restart_greeter;
- DBusServer *server;
- char *server_address;
- DBusConnection *greeter_connection;
+ DBusServer *server;
+ char *server_address;
+ DBusConnection *greeter_connection;
};
enum {
- PROP_0,
- PROP_USER_NAME,
- PROP_GROUP_NAME,
+ PROP_0,
+ PROP_USER_NAME,
+ PROP_GROUP_NAME,
};
enum {
- QUERY_ANSWER,
- SESSION_SELECTED,
- LANGUAGE_SELECTED,
- USER_SELECTED,
- CANCELLED,
- CONNECTED,
- DISCONNECTED,
- LAST_SIGNAL
+ QUERY_ANSWER,
+ SESSION_SELECTED,
+ LANGUAGE_SELECTED,
+ USER_SELECTED,
+ CANCELLED,
+ CONNECTED,
+ DISCONNECTED,
+ LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0, };
-static void gdm_greeter_server_class_init (GdmGreeterServerClass *klass);
-static void gdm_greeter_server_init (GdmGreeterServer *greeter_server);
-static void gdm_greeter_server_finalize (GObject *object);
+static void gdm_greeter_server_class_init (GdmGreeterServerClass *klass);
+static void gdm_greeter_server_init (GdmGreeterServer *greeter_server);
+static void gdm_greeter_server_finalize (GObject *object);
G_DEFINE_TYPE (GdmGreeterServer, gdm_greeter_server, G_TYPE_OBJECT)
static gboolean
send_dbus_message (DBusConnection *connection,
- DBusMessage *message)
+ DBusMessage *message)
{
- gboolean is_connected;
- gboolean sent;
+ gboolean is_connected;
+ gboolean sent;
- g_return_val_if_fail (message != NULL, FALSE);
+ g_return_val_if_fail (message != NULL, FALSE);
- if (connection == NULL) {
- g_debug ("There is no valid connection");
- return FALSE;
- }
+ if (connection == NULL) {
+ g_debug ("There is no valid connection");
+ return FALSE;
+ }
- is_connected = dbus_connection_get_is_connected (connection);
- if (! is_connected) {
- g_warning ("Not connected!");
- return FALSE;
- }
+ is_connected = dbus_connection_get_is_connected (connection);
+ if (! is_connected) {
+ g_warning ("Not connected!");
+ return FALSE;
+ }
- sent = dbus_connection_send (connection, message, NULL);
+ sent = dbus_connection_send (connection, message, NULL);
- return sent;
+ return sent;
}
static void
send_dbus_string_signal (GdmGreeterServer *greeter_server,
- const char *name,
- const char *text)
+ const char *name,
+ const char *text)
{
- DBusMessage *message;
- DBusMessageIter iter;
+ DBusMessage *message;
+ DBusMessageIter iter;
- g_return_if_fail (greeter_server != NULL);
+ g_return_if_fail (greeter_server != NULL);
- message = dbus_message_new_signal (GDM_GREETER_SERVER_DBUS_PATH,
- GDM_GREETER_SERVER_DBUS_INTERFACE,
- name);
+ message = dbus_message_new_signal (GDM_GREETER_SERVER_DBUS_PATH,
+ GDM_GREETER_SERVER_DBUS_INTERFACE,
+ name);
- dbus_message_iter_init_append (message, &iter);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &text);
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &text);
- if (! send_dbus_message (greeter_server->priv->greeter_connection, message)) {
- g_debug ("Could not send %s signal", name);
- }
+ if (! send_dbus_message (greeter_server->priv->greeter_connection, message)) {
+ g_debug ("Could not send %s signal", name);
+ }
- dbus_message_unref (message);
+ dbus_message_unref (message);
}
static void
send_dbus_void_signal (GdmGreeterServer *greeter_server,
- const char *name)
+ const char *name)
{
- DBusMessage *message;
+ DBusMessage *message;
- g_return_if_fail (greeter_server != NULL);
+ g_return_if_fail (greeter_server != NULL);
- message = dbus_message_new_signal (GDM_GREETER_SERVER_DBUS_PATH,
- GDM_GREETER_SERVER_DBUS_INTERFACE,
- name);
+ message = dbus_message_new_signal (GDM_GREETER_SERVER_DBUS_PATH,
+ GDM_GREETER_SERVER_DBUS_INTERFACE,
+ name);
- if (! send_dbus_message (greeter_server->priv->greeter_connection, message)) {
- g_debug ("Could not send %s signal", name);
- }
+ if (! send_dbus_message (greeter_server->priv->greeter_connection, message)) {
+ g_debug ("Could not send %s signal", name);
+ }
- dbus_message_unref (message);
+ dbus_message_unref (message);
}
gboolean
gdm_greeter_server_info_query (GdmGreeterServer *greeter_server,
- const char *text)
+ const char *text)
{
send_dbus_string_signal (greeter_server, "InfoQuery", text);
- return TRUE;
+ return TRUE;
}
gboolean
gdm_greeter_server_secret_info_query (GdmGreeterServer *greeter_server,
- const char *text)
+ const char *text)
{
send_dbus_string_signal (greeter_server, "SecretInfoQuery", text);
- return TRUE;
+ return TRUE;
}
gboolean
gdm_greeter_server_info (GdmGreeterServer *greeter_server,
- const char *text)
+ const char *text)
{
send_dbus_string_signal (greeter_server, "Info", text);
- return TRUE;
+ return TRUE;
}
gboolean
gdm_greeter_server_problem (GdmGreeterServer *greeter_server,
- const char *text)
+ const char *text)
{
send_dbus_string_signal (greeter_server, "Problem", text);
- return TRUE;
+ return TRUE;
}
gboolean
gdm_greeter_server_reset (GdmGreeterServer *greeter_server)
{
send_dbus_void_signal (greeter_server, "Reset");
- return TRUE;
+ return TRUE;
}
/* Note: Use abstract sockets like dbus does by default on Linux. Abstract
@@ -202,261 +202,261 @@ gdm_greeter_server_reset (GdmGreeterServer *greeter_server)
static char *
generate_address (void)
{
- char *path;
+ char *path;
#if defined (__linux__)
- int i;
- char tmp[9];
-
- for (i = 0; i < 8; i++) {
- if (g_random_int_range (0, 2) == 0) {
- tmp[i] = g_random_int_range ('a', 'z' + 1);
- } else {
- tmp[i] = g_random_int_range ('A', 'Z' + 1);
- }
- }
- tmp[8] = '\0';
-
- path = g_strdup_printf ("unix:abstract=/tmp/gdm-greeter-%s", tmp);
+ int i;
+ char tmp[9];
+
+ for (i = 0; i < 8; i++) {
+ if (g_random_int_range (0, 2) == 0) {
+ tmp[i] = g_random_int_range ('a', 'z' + 1);
+ } else {
+ tmp[i] = g_random_int_range ('A', 'Z' + 1);
+ }
+ }
+ tmp[8] = '\0';
+
+ path = g_strdup_printf ("unix:abstract=/tmp/gdm-greeter-%s", tmp);
#else
- path = g_strdup ("unix:tmpdir=/tmp/gdm-greeter");
+ path = g_strdup ("unix:tmpdir=/tmp/gdm-greeter");
#endif
- return path;
+ return path;
}
static DBusHandlerResult
handle_answer_query (GdmGreeterServer *greeter_server,
- DBusConnection *connection,
- DBusMessage *message)
-{
- DBusMessage *reply;
- DBusError error;
- const char *text;
-
- dbus_error_init (&error);
- if (! dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &text,
- DBUS_TYPE_INVALID)) {
- g_warning ("ERROR: %s", error.message);
- }
+ DBusConnection *connection,
+ DBusMessage *message)
+{
+ DBusMessage *reply;
+ DBusError error;
+ const char *text;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &text,
+ DBUS_TYPE_INVALID)) {
+ g_warning ("ERROR: %s", error.message);
+ }
- g_debug ("AnswerQuery");
+ g_debug ("AnswerQuery");
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
- g_signal_emit (greeter_server, signals [QUERY_ANSWER], 0, text);
+ g_signal_emit (greeter_server, signals [QUERY_ANSWER], 0, text);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
handle_select_session (GdmGreeterServer *greeter_server,
- DBusConnection *connection,
- DBusMessage *message)
-{
- DBusMessage *reply;
- DBusError error;
- const char *text;
-
- dbus_error_init (&error);
- if (! dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &text,
- DBUS_TYPE_INVALID)) {
- g_warning ("ERROR: %s", error.message);
- }
+ DBusConnection *connection,
+ DBusMessage *message)
+{
+ DBusMessage *reply;
+ DBusError error;
+ const char *text;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &text,
+ DBUS_TYPE_INVALID)) {
+ g_warning ("ERROR: %s", error.message);
+ }
- g_debug ("SelectSession: %s", text);
+ g_debug ("SelectSession: %s", text);
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
- g_signal_emit (greeter_server, signals [SESSION_SELECTED], 0, text);
+ g_signal_emit (greeter_server, signals [SESSION_SELECTED], 0, text);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
handle_select_language (GdmGreeterServer *greeter_server,
- DBusConnection *connection,
- DBusMessage *message)
-{
- DBusMessage *reply;
- DBusError error;
- const char *text;
-
- dbus_error_init (&error);
- if (! dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &text,
- DBUS_TYPE_INVALID)) {
- g_warning ("ERROR: %s", error.message);
- }
+ DBusConnection *connection,
+ DBusMessage *message)
+{
+ DBusMessage *reply;
+ DBusError error;
+ const char *text;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &text,
+ DBUS_TYPE_INVALID)) {
+ g_warning ("ERROR: %s", error.message);
+ }
- g_debug ("SelectLanguage: %s", text);
+ g_debug ("SelectLanguage: %s", text);
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
- g_signal_emit (greeter_server, signals [LANGUAGE_SELECTED], 0, text);
+ g_signal_emit (greeter_server, signals [LANGUAGE_SELECTED], 0, text);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
handle_select_user (GdmGreeterServer *greeter_server,
- DBusConnection *connection,
- DBusMessage *message)
-{
- DBusMessage *reply;
- DBusError error;
- const char *text;
-
- dbus_error_init (&error);
- if (! dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &text,
- DBUS_TYPE_INVALID)) {
- g_warning ("ERROR: %s", error.message);
- }
+ DBusConnection *connection,
+ DBusMessage *message)
+{
+ DBusMessage *reply;
+ DBusError error;
+ const char *text;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &text,
+ DBUS_TYPE_INVALID)) {
+ g_warning ("ERROR: %s", error.message);
+ }
- g_debug ("SelectUser: %s", text);
+ g_debug ("SelectUser: %s", text);
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
- g_signal_emit (greeter_server, signals [USER_SELECTED], 0, text);
+ g_signal_emit (greeter_server, signals [USER_SELECTED], 0, text);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
handle_cancel (GdmGreeterServer *greeter_server,
- DBusConnection *connection,
- DBusMessage *message)
+ DBusConnection *connection,
+ DBusMessage *message)
{
- DBusMessage *reply;
+ DBusMessage *reply;
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
- g_signal_emit (greeter_server, signals [CANCELLED], 0);
+ g_signal_emit (greeter_server, signals [CANCELLED], 0);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
greeter_handle_child_message (DBusConnection *connection,
- DBusMessage *message,
- void *user_data)
+ DBusMessage *message,
+ void *user_data)
{
GdmGreeterServer *greeter_server = GDM_GREETER_SERVER (user_data);
- if (dbus_message_is_method_call (message, GDM_GREETER_SERVER_DBUS_INTERFACE, "AnswerQuery")) {
- return handle_answer_query (greeter_server, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_GREETER_SERVER_DBUS_INTERFACE, "SelectSession")) {
- return handle_select_session (greeter_server, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_GREETER_SERVER_DBUS_INTERFACE, "SelectSession")) {
- return handle_select_language (greeter_server, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_GREETER_SERVER_DBUS_INTERFACE, "SelectUser")) {
- return handle_select_user (greeter_server, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_GREETER_SERVER_DBUS_INTERFACE, "Cancel")) {
- return handle_cancel (greeter_server, connection, message);
- }
+ if (dbus_message_is_method_call (message, GDM_GREETER_SERVER_DBUS_INTERFACE, "AnswerQuery")) {
+ return handle_answer_query (greeter_server, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_GREETER_SERVER_DBUS_INTERFACE, "SelectSession")) {
+ return handle_select_session (greeter_server, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_GREETER_SERVER_DBUS_INTERFACE, "SelectSession")) {
+ return handle_select_language (greeter_server, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_GREETER_SERVER_DBUS_INTERFACE, "SelectUser")) {
+ return handle_select_user (greeter_server, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_GREETER_SERVER_DBUS_INTERFACE, "Cancel")) {
+ return handle_cancel (greeter_server, connection, message);
+ }
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
static DBusHandlerResult
do_introspect (DBusConnection *connection,
- DBusMessage *message)
-{
- DBusMessage *reply;
- GString *xml;
- char *xml_string;
-
- g_debug ("Do introspect");
-
- /* standard header */
- xml = g_string_new ("<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
- "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
- "<node>\n"
- " <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
- " <method name=\"Introspect\">\n"
- " <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
- " </method>\n"
- " </interface>\n");
-
- /* interface */
- xml = g_string_append (xml,
- " <interface name=\"org.gnome.DisplayManager.GreeterServer\">\n"
- " <method name=\"AnswerQuery\">\n"
- " <arg name=\"text\" direction=\"in\" type=\"s\"/>\n"
- " </method>\n"
- " <method name=\"SelectSession\">\n"
- " <arg name=\"text\" direction=\"in\" type=\"s\"/>\n"
- " </method>\n"
- " <method name=\"SelectLanguage\">\n"
- " <arg name=\"text\" direction=\"in\" type=\"s\"/>\n"
- " </method>\n"
- " <method name=\"SelectUser\">\n"
- " <arg name=\"text\" direction=\"in\" type=\"s\"/>\n"
- " </method>\n"
- " <method name=\"Cancel\">\n"
- " </method>\n"
- " <signal name=\"Info\">\n"
- " <arg name=\"text\" type=\"s\"/>\n"
- " </signal>\n"
- " <signal name=\"Problem\">\n"
- " <arg name=\"text\" type=\"s\"/>\n"
- " </signal>\n"
- " <signal name=\"InfoQuery\">\n"
- " <arg name=\"text\" type=\"s\"/>\n"
- " </signal>\n"
- " <signal name=\"SecretInfoQuery\">\n"
- " <arg name=\"text\" type=\"s\"/>\n"
- " </signal>\n"
- " <signal name=\"Reset\">\n"
- " </signal>\n"
- " </interface>\n");
-
- reply = dbus_message_new_method_return (message);
-
- xml = g_string_append (xml, "</node>\n");
- xml_string = g_string_free (xml, FALSE);
-
- dbus_message_append_args (reply,
- DBUS_TYPE_STRING, &xml_string,
- DBUS_TYPE_INVALID);
-
- g_free (xml_string);
-
- if (reply == NULL) {
- g_error ("No memory");
- }
-
- if (! dbus_connection_send (connection, reply, NULL)) {
- g_error ("No memory");
- }
-
- dbus_message_unref (reply);
-
- return DBUS_HANDLER_RESULT_HANDLED;
+ DBusMessage *message)
+{
+ DBusMessage *reply;
+ GString *xml;
+ char *xml_string;
+
+ g_debug ("Do introspect");
+
+ /* standard header */
+ xml = g_string_new ("<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
+ "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
+ "<node>\n"
+ " <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
+ " <method name=\"Introspect\">\n"
+ " <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
+ " </method>\n"
+ " </interface>\n");
+
+ /* interface */
+ xml = g_string_append (xml,
+ " <interface name=\"org.gnome.DisplayManager.GreeterServer\">\n"
+ " <method name=\"AnswerQuery\">\n"
+ " <arg name=\"text\" direction=\"in\" type=\"s\"/>\n"
+ " </method>\n"
+ " <method name=\"SelectSession\">\n"
+ " <arg name=\"text\" direction=\"in\" type=\"s\"/>\n"
+ " </method>\n"
+ " <method name=\"SelectLanguage\">\n"
+ " <arg name=\"text\" direction=\"in\" type=\"s\"/>\n"
+ " </method>\n"
+ " <method name=\"SelectUser\">\n"
+ " <arg name=\"text\" direction=\"in\" type=\"s\"/>\n"
+ " </method>\n"
+ " <method name=\"Cancel\">\n"
+ " </method>\n"
+ " <signal name=\"Info\">\n"
+ " <arg name=\"text\" type=\"s\"/>\n"
+ " </signal>\n"
+ " <signal name=\"Problem\">\n"
+ " <arg name=\"text\" type=\"s\"/>\n"
+ " </signal>\n"
+ " <signal name=\"InfoQuery\">\n"
+ " <arg name=\"text\" type=\"s\"/>\n"
+ " </signal>\n"
+ " <signal name=\"SecretInfoQuery\">\n"
+ " <arg name=\"text\" type=\"s\"/>\n"
+ " </signal>\n"
+ " <signal name=\"Reset\">\n"
+ " </signal>\n"
+ " </interface>\n");
+
+ reply = dbus_message_new_method_return (message);
+
+ xml = g_string_append (xml, "</node>\n");
+ xml_string = g_string_free (xml, FALSE);
+
+ dbus_message_append_args (reply,
+ DBUS_TYPE_STRING, &xml_string,
+ DBUS_TYPE_INVALID);
+
+ g_free (xml_string);
+
+ if (reply == NULL) {
+ g_error ("No memory");
+ }
+
+ if (! dbus_connection_send (connection, reply, NULL)) {
+ g_error ("No memory");
+ }
+
+ dbus_message_unref (reply);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
greeter_server_message_handler (DBusConnection *connection,
- DBusMessage *message,
- void *user_data)
+ DBusMessage *message,
+ void *user_data)
{
- g_debug ("greeter_server_message_handler: destination=%s obj_path=%s interface=%s method=%s",
- dbus_message_get_destination (message),
- dbus_message_get_path (message),
- dbus_message_get_interface (message),
- dbus_message_get_member (message));
+ g_debug ("greeter_server_message_handler: destination=%s obj_path=%s interface=%s method=%s",
+ dbus_message_get_destination (message),
+ dbus_message_get_path (message),
+ dbus_message_get_interface (message),
+ dbus_message_get_member (message));
if (dbus_message_is_method_call (message, "org.freedesktop.DBus", "AddMatch")) {
@@ -481,8 +481,8 @@ greeter_server_message_handler (DBusConnection *connection,
/*dbus_connection_unref (connection);*/
return DBUS_HANDLER_RESULT_HANDLED;
- } else if (dbus_message_is_method_call (message, "org.freedesktop.DBus.Introspectable", "Introspect")) {
- return do_introspect (connection, message);
+ } else if (dbus_message_is_method_call (message, "org.freedesktop.DBus.Introspectable", "Introspect")) {
+ return do_introspect (connection, message);
} else {
return greeter_handle_child_message (connection, message, user_data);
}
@@ -492,41 +492,41 @@ greeter_server_message_handler (DBusConnection *connection,
static void
greeter_server_unregister_handler (DBusConnection *connection,
- void *user_data)
+ void *user_data)
{
- g_debug ("greeter_server_unregister_handler");
+ g_debug ("greeter_server_unregister_handler");
}
static DBusHandlerResult
connection_filter_function (DBusConnection *connection,
- DBusMessage *message,
- void *user_data)
+ DBusMessage *message,
+ void *user_data)
{
GdmGreeterServer *greeter_server = GDM_GREETER_SERVER (user_data);
- const char *path;
+ const char *path;
- path = dbus_message_get_path (message);
+ path = dbus_message_get_path (message);
- g_debug ("obj_path=%s interface=%s method=%s",
- dbus_message_get_path (message),
- dbus_message_get_interface (message),
- dbus_message_get_member (message));
+ g_debug ("obj_path=%s interface=%s method=%s",
+ dbus_message_get_path (message),
+ dbus_message_get_interface (message),
+ dbus_message_get_member (message));
- if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected")
- && strcmp (path, DBUS_PATH_LOCAL) == 0) {
+ if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected")
+ && strcmp (path, DBUS_PATH_LOCAL) == 0) {
- g_debug ("Disconnected");
+ g_debug ("Disconnected");
- dbus_connection_unref (connection);
- greeter_server->priv->greeter_connection = NULL;
- } else if (dbus_message_is_signal (message, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {
+ dbus_connection_unref (connection);
+ greeter_server->priv->greeter_connection = NULL;
+ } else if (dbus_message_is_signal (message, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {
- } else {
- return greeter_server_message_handler (connection, message, user_data);
- }
+ } else {
+ return greeter_server_message_handler (connection, message, user_data);
+ }
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static dbus_bool_t
@@ -535,116 +535,116 @@ allow_user_function (DBusConnection *connection,
void *data)
{
GdmGreeterServer *greeter_server = GDM_GREETER_SERVER (data);
- struct passwd *pwent;
+ struct passwd *pwent;
- if (greeter_server->priv->user_name == NULL) {
- return FALSE;
- }
+ if (greeter_server->priv->user_name == NULL) {
+ return FALSE;
+ }
- pwent = getpwnam (greeter_server->priv->user_name);
- if (pwent == NULL) {
- return FALSE;
- }
+ pwent = getpwnam (greeter_server->priv->user_name);
+ if (pwent == NULL) {
+ return FALSE;
+ }
- if (pwent->pw_uid == uid) {
- return TRUE;
- }
+ if (pwent->pw_uid == uid) {
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
static void
handle_connection (DBusServer *server,
- DBusConnection *new_connection,
- void *user_data)
+ DBusConnection *new_connection,
+ void *user_data)
{
GdmGreeterServer *greeter_server = GDM_GREETER_SERVER (user_data);
- g_debug ("Handing new connection");
+ g_debug ("Handing new connection");
- if (greeter_server->priv->greeter_connection == NULL) {
- DBusObjectPathVTable vtable = { &greeter_server_unregister_handler,
- &greeter_server_message_handler,
- NULL, NULL, NULL, NULL
- };
+ if (greeter_server->priv->greeter_connection == NULL) {
+ DBusObjectPathVTable vtable = { &greeter_server_unregister_handler,
+ &greeter_server_message_handler,
+ NULL, NULL, NULL, NULL
+ };
- greeter_server->priv->greeter_connection = new_connection;
- dbus_connection_ref (new_connection);
- dbus_connection_setup_with_g_main (new_connection, NULL);
+ greeter_server->priv->greeter_connection = new_connection;
+ dbus_connection_ref (new_connection);
+ dbus_connection_setup_with_g_main (new_connection, NULL);
- g_debug ("greeter connection is %p", new_connection);
+ g_debug ("greeter connection is %p", new_connection);
- dbus_connection_add_filter (new_connection,
- connection_filter_function,
- greeter_server,
- NULL);
+ dbus_connection_add_filter (new_connection,
+ connection_filter_function,
+ greeter_server,
+ NULL);
- dbus_connection_set_unix_user_function (new_connection,
- allow_user_function,
- greeter_server,
- NULL);
+ dbus_connection_set_unix_user_function (new_connection,
+ allow_user_function,
+ greeter_server,
+ NULL);
- dbus_connection_register_object_path (new_connection,
- GDM_GREETER_SERVER_DBUS_PATH,
- &vtable,
- greeter_server);
+ dbus_connection_register_object_path (new_connection,
+ GDM_GREETER_SERVER_DBUS_PATH,
+ &vtable,
+ greeter_server);
- g_signal_emit (greeter_server, signals[CONNECTED], 0);
+ g_signal_emit (greeter_server, signals[CONNECTED], 0);
- }
+ }
}
gboolean
gdm_greeter_server_start (GdmGreeterServer *greeter_server)
{
- DBusError error;
- gboolean ret;
- char *address;
- const char *auth_mechanisms[] = {"EXTERNAL", NULL};
+ DBusError error;
+ gboolean ret;
+ char *address;
+ const char *auth_mechanisms[] = {"EXTERNAL", NULL};
- ret = FALSE;
+ ret = FALSE;
- g_debug ("Creating D-Bus server for greeter");
+ g_debug ("Creating D-Bus server for greeter");
- address = generate_address ();
+ address = generate_address ();
- dbus_error_init (&error);
- greeter_server->priv->server = dbus_server_listen (address, &error);
- g_free (address);
+ dbus_error_init (&error);
+ greeter_server->priv->server = dbus_server_listen (address, &error);
+ g_free (address);
- if (greeter_server->priv->server == NULL) {
- g_warning ("Cannot create D-BUS server for the greeter: %s", error.message);
- goto out;
- }
+ if (greeter_server->priv->server == NULL) {
+ g_warning ("Cannot create D-BUS server for the greeter: %s", error.message);
+ goto out;
+ }
- dbus_server_setup_with_g_main (greeter_server->priv->server, NULL);
- dbus_server_set_auth_mechanisms (greeter_server->priv->server, auth_mechanisms);
- dbus_server_set_new_connection_function (greeter_server->priv->server,
- handle_connection,
- greeter_server,
- NULL);
- ret = TRUE;
+ dbus_server_setup_with_g_main (greeter_server->priv->server, NULL);
+ dbus_server_set_auth_mechanisms (greeter_server->priv->server, auth_mechanisms);
+ dbus_server_set_new_connection_function (greeter_server->priv->server,
+ handle_connection,
+ greeter_server,
+ NULL);
+ ret = TRUE;
- g_free (greeter_server->priv->server_address);
- greeter_server->priv->server_address = dbus_server_get_address (greeter_server->priv->server);
+ g_free (greeter_server->priv->server_address);
+ greeter_server->priv->server_address = dbus_server_get_address (greeter_server->priv->server);
- g_debug ("D-Bus server listening on %s", greeter_server->priv->server_address);
+ g_debug ("D-Bus server listening on %s", greeter_server->priv->server_address);
out:
- return ret;
+ return ret;
}
gboolean
gdm_greeter_server_stop (GdmGreeterServer *greeter_server)
{
- gboolean ret;
+ gboolean ret;
- ret = FALSE;
+ ret = FALSE;
- g_debug ("Stopping greeter server...");
+ g_debug ("Stopping greeter server...");
- return ret;
+ return ret;
}
char *
@@ -655,7 +655,7 @@ gdm_greeter_server_get_address (GdmGreeterServer *greeter_server)
static void
_gdm_greeter_server_set_user_name (GdmGreeterServer *greeter_server,
- const char *name)
+ const char *name)
{
g_free (greeter_server->priv->user_name);
greeter_server->priv->user_name = g_strdup (name);
@@ -663,7 +663,7 @@ _gdm_greeter_server_set_user_name (GdmGreeterServer *greeter_server,
static void
_gdm_greeter_server_set_group_name (GdmGreeterServer *greeter_server,
- const char *name)
+ const char *name)
{
g_free (greeter_server->priv->group_name);
greeter_server->priv->group_name = g_strdup (name);
@@ -671,54 +671,54 @@ _gdm_greeter_server_set_group_name (GdmGreeterServer *greeter_server,
static void
gdm_greeter_server_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GdmGreeterServer *self;
-
- self = GDM_GREETER_SERVER (object);
-
- switch (prop_id) {
- case PROP_USER_NAME:
- _gdm_greeter_server_set_user_name (self, g_value_get_string (value));
- break;
- case PROP_GROUP_NAME:
- _gdm_greeter_server_set_group_name (self, g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GdmGreeterServer *self;
+
+ self = GDM_GREETER_SERVER (object);
+
+ switch (prop_id) {
+ case PROP_USER_NAME:
+ _gdm_greeter_server_set_user_name (self, g_value_get_string (value));
+ break;
+ case PROP_GROUP_NAME:
+ _gdm_greeter_server_set_group_name (self, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_greeter_server_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GdmGreeterServer *self;
-
- self = GDM_GREETER_SERVER (object);
-
- switch (prop_id) {
- case PROP_USER_NAME:
- g_value_set_string (value, self->priv->user_name);
- break;
- case PROP_GROUP_NAME:
- g_value_set_string (value, self->priv->group_name);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GdmGreeterServer *self;
+
+ self = GDM_GREETER_SERVER (object);
+
+ switch (prop_id) {
+ case PROP_USER_NAME:
+ g_value_set_string (value, self->priv->user_name);
+ break;
+ case PROP_GROUP_NAME:
+ g_value_set_string (value, self->priv->group_name);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static GObject *
gdm_greeter_server_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
{
GdmGreeterServer *greeter_server;
GdmGreeterServerClass *klass;
@@ -726,8 +726,8 @@ gdm_greeter_server_constructor (GType type,
klass = GDM_GREETER_SERVER_CLASS (g_type_class_peek (GDM_TYPE_GREETER_SERVER));
greeter_server = GDM_GREETER_SERVER (G_OBJECT_CLASS (gdm_greeter_server_parent_class)->constructor (type,
- n_construct_properties,
- construct_properties));
+ n_construct_properties,
+ construct_properties));
return G_OBJECT (greeter_server);
}
@@ -735,136 +735,136 @@ gdm_greeter_server_constructor (GType type,
static void
gdm_greeter_server_class_init (GdmGreeterServerClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->get_property = gdm_greeter_server_get_property;
- object_class->set_property = gdm_greeter_server_set_property;
+ object_class->get_property = gdm_greeter_server_get_property;
+ object_class->set_property = gdm_greeter_server_set_property;
object_class->constructor = gdm_greeter_server_constructor;
- object_class->finalize = gdm_greeter_server_finalize;
-
- g_type_class_add_private (klass, sizeof (GdmGreeterServerPrivate));
-
- g_object_class_install_property (object_class,
- PROP_USER_NAME,
- g_param_spec_string ("user-name",
- "user name",
- "user name",
- "gdm",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class,
- PROP_GROUP_NAME,
- g_param_spec_string ("group-name",
- "group name",
- "group name",
- "gdm",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- signals [QUERY_ANSWER] =
- g_signal_new ("query-answer",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmGreeterServerClass, query_answer),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1,
- G_TYPE_STRING);
- signals [SESSION_SELECTED] =
- g_signal_new ("session-selected",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmGreeterServerClass, session_selected),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1,
- G_TYPE_STRING);
- signals [LANGUAGE_SELECTED] =
- g_signal_new ("language-selected",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmGreeterServerClass, language_selected),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1,
- G_TYPE_STRING);
- signals [USER_SELECTED] =
- g_signal_new ("user-selected",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmGreeterServerClass, user_selected),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1,
- G_TYPE_STRING);
- signals [CANCELLED] =
- g_signal_new ("cancelled",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmGreeterServerClass, cancelled),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- signals [CONNECTED] =
- g_signal_new ("connected",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmGreeterServerClass, connected),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- signals [DISCONNECTED] =
- g_signal_new ("disconnected",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmGreeterServerClass, disconnected),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
+ object_class->finalize = gdm_greeter_server_finalize;
+
+ g_type_class_add_private (klass, sizeof (GdmGreeterServerPrivate));
+
+ g_object_class_install_property (object_class,
+ PROP_USER_NAME,
+ g_param_spec_string ("user-name",
+ "user name",
+ "user name",
+ "gdm",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
+ PROP_GROUP_NAME,
+ g_param_spec_string ("group-name",
+ "group name",
+ "group name",
+ "gdm",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ signals [QUERY_ANSWER] =
+ g_signal_new ("query-answer",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmGreeterServerClass, query_answer),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING);
+ signals [SESSION_SELECTED] =
+ g_signal_new ("session-selected",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmGreeterServerClass, session_selected),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING);
+ signals [LANGUAGE_SELECTED] =
+ g_signal_new ("language-selected",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmGreeterServerClass, language_selected),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING);
+ signals [USER_SELECTED] =
+ g_signal_new ("user-selected",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmGreeterServerClass, user_selected),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING);
+ signals [CANCELLED] =
+ g_signal_new ("cancelled",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmGreeterServerClass, cancelled),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ signals [CONNECTED] =
+ g_signal_new ("connected",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmGreeterServerClass, connected),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ signals [DISCONNECTED] =
+ g_signal_new ("disconnected",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmGreeterServerClass, disconnected),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
static void
gdm_greeter_server_init (GdmGreeterServer *greeter_server)
{
- greeter_server->priv = GDM_GREETER_SERVER_GET_PRIVATE (greeter_server);
+ greeter_server->priv = GDM_GREETER_SERVER_GET_PRIVATE (greeter_server);
}
static void
gdm_greeter_server_finalize (GObject *object)
{
- GdmGreeterServer *greeter_server;
+ GdmGreeterServer *greeter_server;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_GREETER_SERVER (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_GREETER_SERVER (object));
- greeter_server = GDM_GREETER_SERVER (object);
+ greeter_server = GDM_GREETER_SERVER (object);
- g_return_if_fail (greeter_server->priv != NULL);
+ g_return_if_fail (greeter_server->priv != NULL);
- gdm_greeter_server_stop (greeter_server);
+ gdm_greeter_server_stop (greeter_server);
- G_OBJECT_CLASS (gdm_greeter_server_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_greeter_server_parent_class)->finalize (object);
}
GdmGreeterServer *
gdm_greeter_server_new (void)
{
- GObject *object;
+ GObject *object;
- object = g_object_new (GDM_TYPE_GREETER_SERVER,
- NULL);
+ object = g_object_new (GDM_TYPE_GREETER_SERVER,
+ NULL);
- return GDM_GREETER_SERVER (object);
+ return GDM_GREETER_SERVER (object);
}
diff --git a/daemon/gdm-greeter-server.h b/daemon/gdm-greeter-server.h
index b2749977..12400621 100644
--- a/daemon/gdm-greeter-server.h
+++ b/daemon/gdm-greeter-server.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -37,42 +37,42 @@ typedef struct GdmGreeterServerPrivate GdmGreeterServerPrivate;
typedef struct
{
- GObject parent;
- GdmGreeterServerPrivate *priv;
+ GObject parent;
+ GdmGreeterServerPrivate *priv;
} GdmGreeterServer;
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
- void (* query_answer) (GdmGreeterServer *greeter_server,
- const char *text);
- void (* session_selected) (GdmGreeterServer *greeter_server,
- const char *name);
- void (* language_selected) (GdmGreeterServer *greeter_server,
- const char *name);
- void (* user_selected) (GdmGreeterServer *greeter_server,
- const char *name);
- void (* cancelled) (GdmGreeterServer *greeter_server);
- void (* connected) (GdmGreeterServer *greeter_server);
- void (* disconnected) (GdmGreeterServer *greeter_server);
+ void (* query_answer) (GdmGreeterServer *greeter_server,
+ const char *text);
+ void (* session_selected) (GdmGreeterServer *greeter_server,
+ const char *name);
+ void (* language_selected) (GdmGreeterServer *greeter_server,
+ const char *name);
+ void (* user_selected) (GdmGreeterServer *greeter_server,
+ const char *name);
+ void (* cancelled) (GdmGreeterServer *greeter_server);
+ void (* connected) (GdmGreeterServer *greeter_server);
+ void (* disconnected) (GdmGreeterServer *greeter_server);
} GdmGreeterServerClass;
-GType gdm_greeter_server_get_type (void);
-GdmGreeterServer * gdm_greeter_server_new (void);
+GType gdm_greeter_server_get_type (void);
+GdmGreeterServer * gdm_greeter_server_new (void);
gboolean gdm_greeter_server_start (GdmGreeterServer *greeter_server);
gboolean gdm_greeter_server_stop (GdmGreeterServer *greeter_server);
char * gdm_greeter_server_get_address (GdmGreeterServer *greeter_server);
gboolean gdm_greeter_server_info_query (GdmGreeterServer *greeter_server,
- const char *text);
+ const char *text);
gboolean gdm_greeter_server_secret_info_query (GdmGreeterServer *greeter_server,
- const char *text);
+ const char *text);
gboolean gdm_greeter_server_info (GdmGreeterServer *greeter_server,
- const char *text);
+ const char *text);
gboolean gdm_greeter_server_problem (GdmGreeterServer *greeter_server,
- const char *text);
+ const char *text);
gboolean gdm_greeter_server_reset (GdmGreeterServer *greeter_server);
G_END_DECLS
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
index c8d01e11..8af6505c 100644
--- a/daemon/gdm-local-display-factory.c
+++ b/daemon/gdm-local-display-factory.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -43,25 +43,25 @@
struct GdmLocalDisplayFactoryPrivate
{
- DBusGConnection *connection;
- DBusGProxy *proxy;
+ DBusGConnection *connection;
+ DBusGProxy *proxy;
};
enum {
- DISPLAY_ADDED,
- DISPLAY_REMOVED,
- LAST_SIGNAL
+ DISPLAY_ADDED,
+ DISPLAY_REMOVED,
+ LAST_SIGNAL
};
enum {
- PROP_0,
+ PROP_0,
};
static guint signals [LAST_SIGNAL] = { 0, };
-static void gdm_local_display_factory_class_init (GdmLocalDisplayFactoryClass *klass);
-static void gdm_local_display_factory_init (GdmLocalDisplayFactory *factory);
-static void gdm_local_display_factory_finalize (GObject *object);
+static void gdm_local_display_factory_class_init (GdmLocalDisplayFactoryClass *klass);
+static void gdm_local_display_factory_init (GdmLocalDisplayFactory *factory);
+static void gdm_local_display_factory_finalize (GObject *object);
static gpointer local_display_factory_object = NULL;
@@ -70,249 +70,249 @@ G_DEFINE_TYPE (GdmLocalDisplayFactory, gdm_local_display_factory, GDM_TYPE_DISPL
GQuark
gdm_local_display_factory_error_quark (void)
{
- static GQuark ret = 0;
- if (ret == 0) {
- ret = g_quark_from_static_string ("gdm_local_display_factory_error");
- }
+ static GQuark ret = 0;
+ if (ret == 0) {
+ ret = g_quark_from_static_string ("gdm_local_display_factory_error");
+ }
- return ret;
+ return ret;
}
static void
create_display_for_device (GdmLocalDisplayFactory *factory,
- DBusGProxy *device_proxy)
+ DBusGProxy *device_proxy)
{
- GdmDisplay *display;
- GdmDisplayStore *store;
+ GdmDisplay *display;
+ GdmDisplayStore *store;
- store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
+ store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
- display = gdm_static_display_new (0);
- if (display == NULL) {
- g_warning ("Unable to create display: %d", 0);
- return;
- }
+ display = gdm_static_display_new (0);
+ if (display == NULL) {
+ g_warning ("Unable to create display: %d", 0);
+ return;
+ }
- gdm_display_store_add (store, display);
- /* let store own the ref */
- g_object_unref (display);
+ gdm_display_store_add (store, display);
+ /* let store own the ref */
+ g_object_unref (display);
- if (! gdm_display_manage (display)) {
- gdm_display_unmanage (display);
- }
+ if (! gdm_display_manage (display)) {
+ gdm_display_unmanage (display);
+ }
}
static void
create_displays_for_pci_devices (GdmLocalDisplayFactory *factory)
{
- char **devices;
- const char *key;
- const char *value;
- GError *error;
- gboolean res;
- int i;
+ char **devices;
+ const char *key;
+ const char *value;
+ GError *error;
+ gboolean res;
+ int i;
- g_debug ("Getting PCI seat devices");
+ g_debug ("Getting PCI seat devices");
- key = "info.bus";
- value = "pci";
+ key = "info.bus";
+ value = "pci";
- devices = NULL;
- error = NULL;
+ devices = NULL;
+ error = NULL;
res = dbus_g_proxy_call (factory->priv->proxy,
- "FindDeviceStringMatch",
- &error,
+ "FindDeviceStringMatch",
+ &error,
G_TYPE_STRING, key,
G_TYPE_STRING, value,
G_TYPE_INVALID,
G_TYPE_STRV, &devices,
G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to query HAL: %s", error->message);
- g_error_free (error);
- }
-
- /* now look for pci class 3 */
- key = "pci.device_class";
- for (i = 0; devices [i] != NULL; i++) {
- DBusGProxy *device_proxy;
- int class_val;
-
- device_proxy = dbus_g_proxy_new_for_name (factory->priv->connection,
- HAL_DBUS_NAME,
- devices [i],
- HAL_DBUS_DEVICE_INTERFACE);
- if (device_proxy == NULL) {
- continue;
- }
-
- res = dbus_g_proxy_call (device_proxy,
- "GetPropertyInteger",
- &error,
- G_TYPE_STRING, key,
- G_TYPE_INVALID,
- G_TYPE_INT, &class_val,
- G_TYPE_INVALID);
-
- if (class_val == SEAT_PCI_DEVICE_CLASS) {
- g_debug ("Found device: %s", devices [i]);
- create_display_for_device (factory, device_proxy);
- }
-
- g_object_unref (device_proxy);
- }
-
- g_strfreev (devices);
+ if (! res) {
+ g_warning ("Unable to query HAL: %s", error->message);
+ g_error_free (error);
+ }
+
+ /* now look for pci class 3 */
+ key = "pci.device_class";
+ for (i = 0; devices [i] != NULL; i++) {
+ DBusGProxy *device_proxy;
+ int class_val;
+
+ device_proxy = dbus_g_proxy_new_for_name (factory->priv->connection,
+ HAL_DBUS_NAME,
+ devices [i],
+ HAL_DBUS_DEVICE_INTERFACE);
+ if (device_proxy == NULL) {
+ continue;
+ }
+
+ res = dbus_g_proxy_call (device_proxy,
+ "GetPropertyInteger",
+ &error,
+ G_TYPE_STRING, key,
+ G_TYPE_INVALID,
+ G_TYPE_INT, &class_val,
+ G_TYPE_INVALID);
+
+ if (class_val == SEAT_PCI_DEVICE_CLASS) {
+ g_debug ("Found device: %s", devices [i]);
+ create_display_for_device (factory, device_proxy);
+ }
+
+ g_object_unref (device_proxy);
+ }
+
+ g_strfreev (devices);
}
static gboolean
gdm_local_display_factory_start (GdmDisplayFactory *base_factory)
{
- gboolean ret;
- GdmLocalDisplayFactory *factory = GDM_LOCAL_DISPLAY_FACTORY (base_factory);
+ gboolean ret;
+ GdmLocalDisplayFactory *factory = GDM_LOCAL_DISPLAY_FACTORY (base_factory);
- g_return_val_if_fail (GDM_IS_LOCAL_DISPLAY_FACTORY (factory), FALSE);
+ g_return_val_if_fail (GDM_IS_LOCAL_DISPLAY_FACTORY (factory), FALSE);
- ret = TRUE;
+ ret = TRUE;
- /* FIXME: */
- create_displays_for_pci_devices (factory);
+ /* FIXME: */
+ create_displays_for_pci_devices (factory);
- return ret;
+ return ret;
}
static gboolean
gdm_local_display_factory_stop (GdmDisplayFactory *base_factory)
{
- GdmLocalDisplayFactory *factory = GDM_LOCAL_DISPLAY_FACTORY (base_factory);
+ GdmLocalDisplayFactory *factory = GDM_LOCAL_DISPLAY_FACTORY (base_factory);
- g_return_val_if_fail (GDM_IS_LOCAL_DISPLAY_FACTORY (factory), FALSE);
+ g_return_val_if_fail (GDM_IS_LOCAL_DISPLAY_FACTORY (factory), FALSE);
- return TRUE;
+ return TRUE;
}
static void
-gdm_local_display_factory_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gdm_local_display_factory_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GdmLocalDisplayFactory *self;
+ GdmLocalDisplayFactory *self;
- self = GDM_LOCAL_DISPLAY_FACTORY (object);
+ self = GDM_LOCAL_DISPLAY_FACTORY (object);
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gdm_local_display_factory_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gdm_local_display_factory_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GdmLocalDisplayFactory *self;
+ GdmLocalDisplayFactory *self;
- self = GDM_LOCAL_DISPLAY_FACTORY (object);
+ self = GDM_LOCAL_DISPLAY_FACTORY (object);
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_local_display_factory_class_init (GdmLocalDisplayFactoryClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GdmDisplayFactoryClass *factory_class = GDM_DISPLAY_FACTORY_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GdmDisplayFactoryClass *factory_class = GDM_DISPLAY_FACTORY_CLASS (klass);
- object_class->get_property = gdm_local_display_factory_get_property;
- object_class->set_property = gdm_local_display_factory_set_property;
- object_class->finalize = gdm_local_display_factory_finalize;
+ object_class->get_property = gdm_local_display_factory_get_property;
+ object_class->set_property = gdm_local_display_factory_set_property;
+ object_class->finalize = gdm_local_display_factory_finalize;
- factory_class->start = gdm_local_display_factory_start;
- factory_class->stop = gdm_local_display_factory_stop;
+ factory_class->start = gdm_local_display_factory_start;
+ factory_class->stop = gdm_local_display_factory_stop;
- g_type_class_add_private (klass, sizeof (GdmLocalDisplayFactoryPrivate));
+ g_type_class_add_private (klass, sizeof (GdmLocalDisplayFactoryPrivate));
}
static gboolean
connect_to_hal (GdmLocalDisplayFactory *factory)
{
- GError *error;
+ GError *error;
- error = NULL;
- factory->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (factory->priv->connection == NULL) {
- g_critical ("Couldn't connect to system bus: %s",
- error->message);
- g_error_free (error);
+ error = NULL;
+ factory->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (factory->priv->connection == NULL) {
+ g_critical ("Couldn't connect to system bus: %s",
+ error->message);
+ g_error_free (error);
- return FALSE;
- }
+ return FALSE;
+ }
factory->priv->proxy = dbus_g_proxy_new_for_name (factory->priv->connection,
- HAL_DBUS_NAME,
- HAL_DBUS_MANAGER_PATH,
- HAL_DBUS_MANAGER_INTERFACE);
- if (factory->priv->proxy == NULL) {
- g_warning ("Couldn't create proxy for HAL Manager");
- return FALSE;
- }
-
- return TRUE;
+ HAL_DBUS_NAME,
+ HAL_DBUS_MANAGER_PATH,
+ HAL_DBUS_MANAGER_INTERFACE);
+ if (factory->priv->proxy == NULL) {
+ g_warning ("Couldn't create proxy for HAL Manager");
+ return FALSE;
+ }
+
+ return TRUE;
}
static void
disconnect_from_hal (GdmLocalDisplayFactory *factory)
{
- if (factory->priv->proxy == NULL) {
- g_object_unref (factory->priv->proxy);
- }
+ if (factory->priv->proxy == NULL) {
+ g_object_unref (factory->priv->proxy);
+ }
}
static void
gdm_local_display_factory_init (GdmLocalDisplayFactory *factory)
{
- factory->priv = GDM_LOCAL_DISPLAY_FACTORY_GET_PRIVATE (factory);
+ factory->priv = GDM_LOCAL_DISPLAY_FACTORY_GET_PRIVATE (factory);
- connect_to_hal (factory);
+ connect_to_hal (factory);
}
static void
gdm_local_display_factory_finalize (GObject *object)
{
- GdmLocalDisplayFactory *factory;
+ GdmLocalDisplayFactory *factory;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_LOCAL_DISPLAY_FACTORY (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_LOCAL_DISPLAY_FACTORY (object));
- factory = GDM_LOCAL_DISPLAY_FACTORY (object);
+ factory = GDM_LOCAL_DISPLAY_FACTORY (object);
- g_return_if_fail (factory->priv != NULL);
+ g_return_if_fail (factory->priv != NULL);
- disconnect_from_hal (factory);
+ disconnect_from_hal (factory);
- G_OBJECT_CLASS (gdm_local_display_factory_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_local_display_factory_parent_class)->finalize (object);
}
GdmLocalDisplayFactory *
gdm_local_display_factory_new (GdmDisplayStore *store)
{
- if (local_display_factory_object != NULL) {
- g_object_ref (local_display_factory_object);
- } else {
- local_display_factory_object = g_object_new (GDM_TYPE_LOCAL_DISPLAY_FACTORY,
- "display-store", store,
- NULL);
- g_object_add_weak_pointer (local_display_factory_object,
- (gpointer *) &local_display_factory_object);
- }
-
- return GDM_LOCAL_DISPLAY_FACTORY (local_display_factory_object);
+ if (local_display_factory_object != NULL) {
+ g_object_ref (local_display_factory_object);
+ } else {
+ local_display_factory_object = g_object_new (GDM_TYPE_LOCAL_DISPLAY_FACTORY,
+ "display-store", store,
+ NULL);
+ g_object_add_weak_pointer (local_display_factory_object,
+ (gpointer *) &local_display_factory_object);
+ }
+
+ return GDM_LOCAL_DISPLAY_FACTORY (local_display_factory_object);
}
diff --git a/daemon/gdm-local-display-factory.h b/daemon/gdm-local-display-factory.h
index a3b8dac9..923fcea4 100644
--- a/daemon/gdm-local-display-factory.h
+++ b/daemon/gdm-local-display-factory.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -40,26 +40,26 @@ typedef struct GdmLocalDisplayFactoryPrivate GdmLocalDisplayFactoryPrivate;
typedef struct
{
- GdmDisplayFactory parent;
- GdmLocalDisplayFactoryPrivate *priv;
+ GdmDisplayFactory parent;
+ GdmLocalDisplayFactoryPrivate *priv;
} GdmLocalDisplayFactory;
typedef struct
{
- GdmDisplayFactoryClass parent_class;
+ GdmDisplayFactoryClass parent_class;
} GdmLocalDisplayFactoryClass;
typedef enum
{
- GDM_LOCAL_DISPLAY_FACTORY_ERROR_GENERAL
+ GDM_LOCAL_DISPLAY_FACTORY_ERROR_GENERAL
} GdmLocalDisplayFactoryError;
#define GDM_LOCAL_DISPLAY_FACTORY_ERROR gdm_local_display_factory_error_quark ()
-GQuark gdm_local_display_factory_error_quark (void);
-GType gdm_local_display_factory_get_type (void);
+GQuark gdm_local_display_factory_error_quark (void);
+GType gdm_local_display_factory_get_type (void);
-GdmLocalDisplayFactory * gdm_local_display_factory_new (GdmDisplayStore *display_store);
+GdmLocalDisplayFactory * gdm_local_display_factory_new (GdmDisplayStore *display_store);
G_END_DECLS
diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c
index d0cfab1f..aa646adb 100644
--- a/daemon/gdm-manager.c
+++ b/daemon/gdm-manager.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -53,36 +53,36 @@
struct GdmManagerPrivate
{
- GdmDisplayStore *display_store;
- GdmLocalDisplayFactory *local_factory;
- GdmXdmcpDisplayFactory *xdmcp_factory;
+ GdmDisplayStore *display_store;
+ GdmLocalDisplayFactory *local_factory;
+ GdmXdmcpDisplayFactory *xdmcp_factory;
- gboolean xdmcp_enabled;
+ gboolean xdmcp_enabled;
- GString *global_cookie;
- gboolean wait_for_go;
- gboolean no_console;
+ GString *global_cookie;
+ gboolean wait_for_go;
+ gboolean no_console;
DBusGProxy *bus_proxy;
DBusGConnection *connection;
};
enum {
- PROP_0,
- PROP_XDMCP_ENABLED
+ PROP_0,
+ PROP_XDMCP_ENABLED
};
enum {
- DISPLAY_ADDED,
- DISPLAY_REMOVED,
- LAST_SIGNAL
+ DISPLAY_ADDED,
+ DISPLAY_REMOVED,
+ LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0, };
-static void gdm_manager_class_init (GdmManagerClass *klass);
-static void gdm_manager_init (GdmManager *manager);
-static void gdm_manager_finalize (GObject *object);
+static void gdm_manager_class_init (GdmManagerClass *klass);
+static void gdm_manager_init (GdmManager *manager);
+static void gdm_manager_finalize (GObject *object);
static gpointer manager_object = NULL;
@@ -91,23 +91,23 @@ G_DEFINE_TYPE (GdmManager, gdm_manager, G_TYPE_OBJECT)
GQuark
gdm_manager_error_quark (void)
{
- static GQuark ret = 0;
- if (ret == 0) {
- ret = g_quark_from_static_string ("gdm_manager_error");
- }
+ static GQuark ret = 0;
+ if (ret == 0) {
+ ret = g_quark_from_static_string ("gdm_manager_error");
+ }
- return ret;
+ return ret;
}
static gboolean
listify_display_ids (const char *id,
- GdmDisplay *display,
- GPtrArray **array)
+ GdmDisplay *display,
+ GPtrArray **array)
{
- g_ptr_array_add (*array, g_strdup (id));
+ g_ptr_array_add (*array, g_strdup (id));
- /* return FALSE to continue */
- return FALSE;
+ /* return FALSE to continue */
+ return FALSE;
}
/*
@@ -119,91 +119,91 @@ listify_display_ids (const char *id,
*/
gboolean
gdm_manager_get_displays (GdmManager *manager,
- GPtrArray **displays,
- GError **error)
+ GPtrArray **displays,
+ GError **error)
{
- g_return_val_if_fail (GDM_IS_MANAGER (manager), FALSE);
+ g_return_val_if_fail (GDM_IS_MANAGER (manager), FALSE);
- if (displays == NULL) {
- return FALSE;
- }
+ if (displays == NULL) {
+ return FALSE;
+ }
- *displays = g_ptr_array_new ();
- gdm_display_store_foreach (manager->priv->display_store,
- (GdmDisplayStoreFunc)listify_display_ids,
- displays);
+ *displays = g_ptr_array_new ();
+ gdm_display_store_foreach (manager->priv->display_store,
+ (GdmDisplayStoreFunc)listify_display_ids,
+ displays);
- return TRUE;
+ return TRUE;
}
static void
make_global_cookie (GdmManager *manager)
{
- FILE *fp;
- char *file;
+ FILE *fp;
+ char *file;
- gdm_generate_cookie (manager->priv->global_cookie);
+ gdm_generate_cookie (manager->priv->global_cookie);
- file = g_build_filename (AUTHDIR, ".cookie", NULL);
- VE_IGNORE_EINTR (g_unlink (file));
+ file = g_build_filename (AUTHDIR, ".cookie", NULL);
+ VE_IGNORE_EINTR (g_unlink (file));
- fp = gdm_safe_fopen_w (file, 077);
- if G_UNLIKELY (fp == NULL) {
- g_warning (_("Can't open %s for writing"), file);
- g_free (file);
- return;
- }
+ fp = gdm_safe_fopen_w (file, 077);
+ if G_UNLIKELY (fp == NULL) {
+ g_warning (_("Can't open %s for writing"), file);
+ g_free (file);
+ return;
+ }
- VE_IGNORE_EINTR (fprintf (fp, "%s\n", manager->priv->global_cookie->str));
+ VE_IGNORE_EINTR (fprintf (fp, "%s\n", manager->priv->global_cookie->str));
- /* FIXME: What about out of disk space errors? */
- errno = 0;
- VE_IGNORE_EINTR (fclose (fp));
- if G_UNLIKELY (errno != 0) {
- g_warning (_("Can't write to %s: %s"),
- file,
- g_strerror (errno));
- }
+ /* FIXME: What about out of disk space errors? */
+ errno = 0;
+ VE_IGNORE_EINTR (fclose (fp));
+ if G_UNLIKELY (errno != 0) {
+ g_warning (_("Can't write to %s: %s"),
+ file,
+ g_strerror (errno));
+ }
- g_free (file);
+ g_free (file);
}
void
gdm_manager_start (GdmManager *manager)
{
- g_debug ("GDM starting to manage");
+ g_debug ("GDM starting to manage");
- if (! manager->priv->wait_for_go) {
- gdm_display_factory_start (GDM_DISPLAY_FACTORY (manager->priv->local_factory));
- }
+ if (! manager->priv->wait_for_go) {
+ gdm_display_factory_start (GDM_DISPLAY_FACTORY (manager->priv->local_factory));
+ }
- /* Accept remote connections */
- if (manager->priv->xdmcp_enabled && ! manager->priv->wait_for_go) {
- if (manager->priv->xdmcp_factory != NULL) {
- g_debug ("Accepting XDMCP connections...");
- gdm_display_factory_start (GDM_DISPLAY_FACTORY (manager->priv->xdmcp_factory));
- }
- }
+ /* Accept remote connections */
+ if (manager->priv->xdmcp_enabled && ! manager->priv->wait_for_go) {
+ if (manager->priv->xdmcp_factory != NULL) {
+ g_debug ("Accepting XDMCP connections...");
+ gdm_display_factory_start (GDM_DISPLAY_FACTORY (manager->priv->xdmcp_factory));
+ }
+ }
}
void
gdm_manager_set_wait_for_go (GdmManager *manager,
- gboolean wait_for_go)
+ gboolean wait_for_go)
{
- if (manager->priv->wait_for_go != wait_for_go) {
- manager->priv->wait_for_go = wait_for_go;
-
- if (! wait_for_go) {
- /* we got a go */
- gdm_display_factory_start (GDM_DISPLAY_FACTORY (manager->priv->local_factory));
-
- if (manager->priv->xdmcp_enabled && manager->priv->xdmcp_factory != NULL) {
- g_debug ("Accepting XDMCP connections...");
- gdm_display_factory_start (GDM_DISPLAY_FACTORY (manager->priv->xdmcp_factory));
- }
- }
- }
+ if (manager->priv->wait_for_go != wait_for_go) {
+ manager->priv->wait_for_go = wait_for_go;
+
+ if (! wait_for_go) {
+ /* we got a go */
+ gdm_display_factory_start (GDM_DISPLAY_FACTORY (manager->priv->local_factory));
+
+ if (manager->priv->xdmcp_enabled && manager->priv->xdmcp_factory != NULL) {
+ g_debug ("Accepting XDMCP connections...");
+ gdm_display_factory_start (GDM_DISPLAY_FACTORY (manager->priv->xdmcp_factory));
+ }
+ }
+ }
}
typedef struct {
@@ -213,12 +213,12 @@ typedef struct {
static gboolean
remove_display_for_connection (GdmDisplay *display,
- RemoveDisplayData *data)
+ RemoveDisplayData *data)
{
g_assert (display != NULL);
g_assert (data->service_name != NULL);
- /* FIXME: compare service name to that of display */
+ /* FIXME: compare service name to that of display */
#if 0
if (strcmp (info->service_name, data->service_name) == 0) {
remove_session_for_cookie (data->manager, cookie, NULL);
@@ -241,9 +241,9 @@ remove_displays_for_connection (GdmManager *manager,
g_debug ("Removing display for service name: %s", service_name);
- gdm_display_store_foreach_remove (manager->priv->display_store,
- (GdmDisplayStoreFunc)remove_display_for_connection,
- &data);
+ gdm_display_store_foreach_remove (manager->priv->display_store,
+ (GdmDisplayStoreFunc)remove_display_for_connection,
+ &data);
}
static void
@@ -299,57 +299,57 @@ register_manager (GdmManager *manager)
void
gdm_manager_set_xdmcp_enabled (GdmManager *manager,
- gboolean enabled)
+ gboolean enabled)
{
- g_return_if_fail (GDM_IS_MANAGER (manager));
+ g_return_if_fail (GDM_IS_MANAGER (manager));
- manager->priv->xdmcp_enabled = enabled;
+ manager->priv->xdmcp_enabled = enabled;
}
static void
gdm_manager_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GdmManager *self;
-
- self = GDM_MANAGER (object);
-
- switch (prop_id) {
- case PROP_XDMCP_ENABLED:
- gdm_manager_set_xdmcp_enabled (self, g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GdmManager *self;
+
+ self = GDM_MANAGER (object);
+
+ switch (prop_id) {
+ case PROP_XDMCP_ENABLED:
+ gdm_manager_set_xdmcp_enabled (self, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_manager_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GdmManager *self;
-
- self = GDM_MANAGER (object);
-
- switch (prop_id) {
- case PROP_XDMCP_ENABLED:
- g_value_set_boolean (value, self->priv->xdmcp_enabled);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GdmManager *self;
+
+ self = GDM_MANAGER (object);
+
+ switch (prop_id) {
+ case PROP_XDMCP_ENABLED:
+ g_value_set_boolean (value, self->priv->xdmcp_enabled);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static GObject *
gdm_manager_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
{
GdmManager *manager;
GdmManagerClass *klass;
@@ -357,14 +357,14 @@ gdm_manager_constructor (GType type,
klass = GDM_MANAGER_CLASS (g_type_class_peek (GDM_TYPE_MANAGER));
manager = GDM_MANAGER (G_OBJECT_CLASS (gdm_manager_parent_class)->constructor (type,
- n_construct_properties,
- construct_properties));
+ n_construct_properties,
+ construct_properties));
- manager->priv->local_factory = gdm_local_display_factory_new (manager->priv->display_store);
+ manager->priv->local_factory = gdm_local_display_factory_new (manager->priv->display_store);
- if (manager->priv->xdmcp_enabled) {
- manager->priv->xdmcp_factory = gdm_xdmcp_display_factory_new (manager->priv->display_store);
- }
+ if (manager->priv->xdmcp_enabled) {
+ manager->priv->xdmcp_factory = gdm_xdmcp_display_factory_new (manager->priv->display_store);
+ }
return G_OBJECT (manager);
}
@@ -372,43 +372,43 @@ gdm_manager_constructor (GType type,
static void
gdm_manager_class_init (GdmManagerClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->get_property = gdm_manager_get_property;
- object_class->set_property = gdm_manager_set_property;
- object_class->constructor = gdm_manager_constructor;
- object_class->finalize = gdm_manager_finalize;
-
- signals [DISPLAY_ADDED] =
- g_signal_new ("display-added",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdmManagerClass, display_added),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1, G_TYPE_STRING);
- signals [DISPLAY_REMOVED] =
- g_signal_new ("display-removed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdmManagerClass, display_removed),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1, G_TYPE_STRING);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->get_property = gdm_manager_get_property;
+ object_class->set_property = gdm_manager_set_property;
+ object_class->constructor = gdm_manager_constructor;
+ object_class->finalize = gdm_manager_finalize;
+
+ signals [DISPLAY_ADDED] =
+ g_signal_new ("display-added",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdmManagerClass, display_added),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1, G_TYPE_STRING);
+ signals [DISPLAY_REMOVED] =
+ g_signal_new ("display-removed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdmManagerClass, display_removed),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1, G_TYPE_STRING);
g_object_class_install_property (object_class,
PROP_XDMCP_ENABLED,
g_param_spec_boolean ("xdmcp-enabled",
NULL,
NULL,
- TRUE,
+ TRUE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_type_class_add_private (klass, sizeof (GdmManagerPrivate));
+ g_type_class_add_private (klass, sizeof (GdmManagerPrivate));
dbus_g_object_type_install_info (GDM_TYPE_MANAGER, &dbus_glib_gdm_manager_object_info);
}
@@ -417,56 +417,56 @@ static void
gdm_manager_init (GdmManager *manager)
{
- manager->priv = GDM_MANAGER_GET_PRIVATE (manager);
+ manager->priv = GDM_MANAGER_GET_PRIVATE (manager);
- manager->priv->global_cookie = g_string_new (NULL);
+ manager->priv->global_cookie = g_string_new (NULL);
- make_global_cookie (manager);
+ make_global_cookie (manager);
- manager->priv->display_store = gdm_display_store_new ();
+ manager->priv->display_store = gdm_display_store_new ();
}
static void
gdm_manager_finalize (GObject *object)
{
- GdmManager *manager;
+ GdmManager *manager;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_MANAGER (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_MANAGER (object));
- manager = GDM_MANAGER (object);
+ manager = GDM_MANAGER (object);
- g_return_if_fail (manager->priv != NULL);
+ g_return_if_fail (manager->priv != NULL);
- if (manager->priv->xdmcp_factory != NULL) {
- g_object_unref (manager->priv->xdmcp_factory);
- }
+ if (manager->priv->xdmcp_factory != NULL) {
+ g_object_unref (manager->priv->xdmcp_factory);
+ }
- gdm_display_store_clear (manager->priv->display_store);
- g_object_unref (manager->priv->display_store);
+ gdm_display_store_clear (manager->priv->display_store);
+ g_object_unref (manager->priv->display_store);
- g_string_free (manager->priv->global_cookie, TRUE);
+ g_string_free (manager->priv->global_cookie, TRUE);
- G_OBJECT_CLASS (gdm_manager_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_manager_parent_class)->finalize (object);
}
GdmManager *
gdm_manager_new (void)
{
- if (manager_object != NULL) {
- g_object_ref (manager_object);
- } else {
- gboolean res;
-
- manager_object = g_object_new (GDM_TYPE_MANAGER, NULL);
- g_object_add_weak_pointer (manager_object,
- (gpointer *) &manager_object);
+ if (manager_object != NULL) {
+ g_object_ref (manager_object);
+ } else {
+ gboolean res;
+
+ manager_object = g_object_new (GDM_TYPE_MANAGER, NULL);
+ g_object_add_weak_pointer (manager_object,
+ (gpointer *) &manager_object);
res = register_manager (manager_object);
if (! res) {
g_object_unref (manager_object);
return NULL;
}
- }
+ }
- return GDM_MANAGER (manager_object);
+ return GDM_MANAGER (manager_object);
}
diff --git a/daemon/gdm-manager.h b/daemon/gdm-manager.h
index afdc3392..0b2a04e0 100644
--- a/daemon/gdm-manager.h
+++ b/daemon/gdm-manager.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2006 William Jon McCann <mccann@jhu.edu>
*
@@ -37,40 +37,40 @@ typedef struct GdmManagerPrivate GdmManagerPrivate;
typedef struct
{
- GObject parent;
- GdmManagerPrivate *priv;
+ GObject parent;
+ GdmManagerPrivate *priv;
} GdmManager;
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
- void (* display_added) (GdmManager *manager,
- const char *id);
- void (* display_removed) (GdmManager *manager,
- const char *id);
+ void (* display_added) (GdmManager *manager,
+ const char *id);
+ void (* display_removed) (GdmManager *manager,
+ const char *id);
} GdmManagerClass;
typedef enum
{
- GDM_MANAGER_ERROR_GENERAL
+ GDM_MANAGER_ERROR_GENERAL
} GdmManagerError;
#define GDM_MANAGER_ERROR gdm_manager_error_quark ()
-GQuark gdm_manager_error_quark (void);
-GType gdm_manager_get_type (void);
+GQuark gdm_manager_error_quark (void);
+GType gdm_manager_get_type (void);
-GdmManager * gdm_manager_new (void);
+GdmManager * gdm_manager_new (void);
void gdm_manager_start (GdmManager *manager);
void gdm_manager_set_wait_for_go (GdmManager *manager,
- gboolean wait_for_go);
+ gboolean wait_for_go);
void gdm_manager_set_xdmcp_enabled (GdmManager *manager,
- gboolean enabled);
+ gboolean enabled);
gboolean gdm_manager_get_displays (GdmManager *manager,
- GPtrArray **displays,
- GError **error);
+ GPtrArray **displays,
+ GError **error);
G_END_DECLS
diff --git a/daemon/gdm-product-display.c b/daemon/gdm-product-display.c
index 09ca7bb8..850de658 100644
--- a/daemon/gdm-product-display.c
+++ b/daemon/gdm-product-display.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -44,147 +44,147 @@
struct GdmProductDisplayPrivate
{
- char *relay_address;
+ char *relay_address;
};
enum {
- PROP_0,
- PROP_RELAY_ADDRESS,
+ PROP_0,
+ PROP_RELAY_ADDRESS,
};
-static void gdm_product_display_class_init (GdmProductDisplayClass *klass);
-static void gdm_product_display_init (GdmProductDisplay *product_display);
-static void gdm_product_display_finalize (GObject *object);
+static void gdm_product_display_class_init (GdmProductDisplayClass *klass);
+static void gdm_product_display_init (GdmProductDisplay *product_display);
+static void gdm_product_display_finalize (GObject *object);
G_DEFINE_TYPE (GdmProductDisplay, gdm_product_display, GDM_TYPE_DISPLAY)
static gboolean
gdm_product_display_create_authority (GdmDisplay *display)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- GDM_DISPLAY_CLASS (gdm_product_display_parent_class)->create_authority (display);
+ GDM_DISPLAY_CLASS (gdm_product_display_parent_class)->create_authority (display);
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_product_display_add_user_authorization (GdmDisplay *display,
- const char *username,
- char **filename,
- GError **error)
+ const char *username,
+ char **filename,
+ GError **error)
{
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_product_display_remove_user_authorization (GdmDisplay *display,
- const char *username,
- GError **error)
+ const char *username,
+ GError **error)
{
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_product_display_manage (GdmDisplay *display)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- GDM_DISPLAY_CLASS (gdm_product_display_parent_class)->manage (display);
+ GDM_DISPLAY_CLASS (gdm_product_display_parent_class)->manage (display);
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_product_display_finish (GdmDisplay *display)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- GDM_DISPLAY_CLASS (gdm_product_display_parent_class)->finish (display);
+ GDM_DISPLAY_CLASS (gdm_product_display_parent_class)->finish (display);
- /* when a product display is done it is done */
- gdm_display_unmanage (display);
+ /* when a product display is done it is done */
+ gdm_display_unmanage (display);
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_product_display_unmanage (GdmDisplay *display)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- GDM_DISPLAY_CLASS (gdm_product_display_parent_class)->unmanage (display);
+ GDM_DISPLAY_CLASS (gdm_product_display_parent_class)->unmanage (display);
- return TRUE;
+ return TRUE;
}
gboolean
gdm_product_display_get_relay_address (GdmProductDisplay *display,
- char **address,
- GError **error)
+ char **address,
+ GError **error)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- if (address != NULL) {
- *address = g_strdup (display->priv->relay_address);
- g_debug ("Returning address: %s", display->priv->relay_address);
- }
+ if (address != NULL) {
+ *address = g_strdup (display->priv->relay_address);
+ g_debug ("Returning address: %s", display->priv->relay_address);
+ }
- return TRUE;
+ return TRUE;
}
static void
gdm_product_display_set_relay_address (GdmProductDisplay *display,
- const char *address)
+ const char *address)
{
- g_free (display->priv->relay_address);
- display->priv->relay_address = g_strdup (address);
+ g_free (display->priv->relay_address);
+ display->priv->relay_address = g_strdup (address);
}
static void
gdm_product_display_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GdmProductDisplay *self;
-
- self = GDM_PRODUCT_DISPLAY (object);
-
- switch (prop_id) {
- case PROP_RELAY_ADDRESS:
- gdm_product_display_set_relay_address (self, g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GdmProductDisplay *self;
+
+ self = GDM_PRODUCT_DISPLAY (object);
+
+ switch (prop_id) {
+ case PROP_RELAY_ADDRESS:
+ gdm_product_display_set_relay_address (self, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_product_display_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GdmProductDisplay *self;
+ GdmProductDisplay *self;
- self = GDM_PRODUCT_DISPLAY (object);
+ self = GDM_PRODUCT_DISPLAY (object);
- switch (prop_id) {
- case PROP_RELAY_ADDRESS:
- g_value_set_string (value, self->priv->relay_address);
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ case PROP_RELAY_ADDRESS:
+ g_value_set_string (value, self->priv->relay_address);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static GObject *
gdm_product_display_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
{
GdmProductDisplay *display;
GdmProductDisplayClass *klass;
@@ -192,79 +192,79 @@ gdm_product_display_constructor (GType type,
klass = GDM_PRODUCT_DISPLAY_CLASS (g_type_class_peek (GDM_TYPE_PRODUCT_DISPLAY));
display = GDM_PRODUCT_DISPLAY (G_OBJECT_CLASS (gdm_product_display_parent_class)->constructor (type,
- n_construct_properties,
- construct_properties));
+ n_construct_properties,
+ construct_properties));
return G_OBJECT (display);
}
static void
gdm_product_display_class_init (GdmProductDisplayClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GdmDisplayClass *display_class = GDM_DISPLAY_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GdmDisplayClass *display_class = GDM_DISPLAY_CLASS (klass);
- object_class->get_property = gdm_product_display_get_property;
- object_class->set_property = gdm_product_display_set_property;
+ object_class->get_property = gdm_product_display_get_property;
+ object_class->set_property = gdm_product_display_set_property;
object_class->constructor = gdm_product_display_constructor;
- object_class->finalize = gdm_product_display_finalize;
-
- display_class->create_authority = gdm_product_display_create_authority;
- display_class->add_user_authorization = gdm_product_display_add_user_authorization;
- display_class->remove_user_authorization = gdm_product_display_remove_user_authorization;
- display_class->manage = gdm_product_display_manage;
- display_class->finish = gdm_product_display_finish;
- display_class->unmanage = gdm_product_display_unmanage;
-
- g_type_class_add_private (klass, sizeof (GdmProductDisplayPrivate));
-
- g_object_class_install_property (object_class,
- PROP_RELAY_ADDRESS,
- g_param_spec_string ("relay-address",
- "relay address",
- "relay address",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- dbus_g_object_type_install_info (GDM_TYPE_PRODUCT_DISPLAY, &dbus_glib_gdm_product_display_object_info);
+ object_class->finalize = gdm_product_display_finalize;
+
+ display_class->create_authority = gdm_product_display_create_authority;
+ display_class->add_user_authorization = gdm_product_display_add_user_authorization;
+ display_class->remove_user_authorization = gdm_product_display_remove_user_authorization;
+ display_class->manage = gdm_product_display_manage;
+ display_class->finish = gdm_product_display_finish;
+ display_class->unmanage = gdm_product_display_unmanage;
+
+ g_type_class_add_private (klass, sizeof (GdmProductDisplayPrivate));
+
+ g_object_class_install_property (object_class,
+ PROP_RELAY_ADDRESS,
+ g_param_spec_string ("relay-address",
+ "relay address",
+ "relay address",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ dbus_g_object_type_install_info (GDM_TYPE_PRODUCT_DISPLAY, &dbus_glib_gdm_product_display_object_info);
}
static void
gdm_product_display_init (GdmProductDisplay *product_display)
{
- product_display->priv = GDM_PRODUCT_DISPLAY_GET_PRIVATE (product_display);
+ product_display->priv = GDM_PRODUCT_DISPLAY_GET_PRIVATE (product_display);
}
static void
gdm_product_display_finalize (GObject *object)
{
- GdmProductDisplay *product_display;
+ GdmProductDisplay *product_display;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_PRODUCT_DISPLAY (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_PRODUCT_DISPLAY (object));
- product_display = GDM_PRODUCT_DISPLAY (object);
+ product_display = GDM_PRODUCT_DISPLAY (object);
- g_return_if_fail (product_display->priv != NULL);
+ g_return_if_fail (product_display->priv != NULL);
- G_OBJECT_CLASS (gdm_product_display_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_product_display_parent_class)->finalize (object);
}
GdmDisplay *
gdm_product_display_new (int display_number,
- const char *relay_address)
+ const char *relay_address)
{
- GObject *object;
- char *x11_display;
-
- x11_display = g_strdup_printf (":%d", display_number);
- object = g_object_new (GDM_TYPE_PRODUCT_DISPLAY,
- "slave-command", DEFAULT_SLAVE_COMMAND,
- "x11-display-number", display_number,
- "x11-display-name", x11_display,
- "relay-address", relay_address,
- NULL);
- g_free (x11_display);
-
- return GDM_DISPLAY (object);
+ GObject *object;
+ char *x11_display;
+
+ x11_display = g_strdup_printf (":%d", display_number);
+ object = g_object_new (GDM_TYPE_PRODUCT_DISPLAY,
+ "slave-command", DEFAULT_SLAVE_COMMAND,
+ "x11-display-number", display_number,
+ "x11-display-name", x11_display,
+ "relay-address", relay_address,
+ NULL);
+ g_free (x11_display);
+
+ return GDM_DISPLAY (object);
}
diff --git a/daemon/gdm-product-display.h b/daemon/gdm-product-display.h
index 66f99387..8806c1f9 100644
--- a/daemon/gdm-product-display.h
+++ b/daemon/gdm-product-display.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -39,23 +39,23 @@ typedef struct GdmProductDisplayPrivate GdmProductDisplayPrivate;
typedef struct
{
- GdmDisplay parent;
- GdmProductDisplayPrivate *priv;
+ GdmDisplay parent;
+ GdmProductDisplayPrivate *priv;
} GdmProductDisplay;
typedef struct
{
- GdmDisplayClass parent_class;
+ GdmDisplayClass parent_class;
} GdmProductDisplayClass;
-GType gdm_product_display_get_type (void);
-GdmDisplay * gdm_product_display_new (int display_number,
- const char *server_address);
+GType gdm_product_display_get_type (void);
+GdmDisplay * gdm_product_display_new (int display_number,
+ const char *server_address);
-gboolean gdm_product_display_get_relay_address (GdmProductDisplay *display,
- char **address,
- GError **error);
+gboolean gdm_product_display_get_relay_address (GdmProductDisplay *display,
+ char **address,
+ GError **error);
G_END_DECLS
diff --git a/daemon/gdm-product-slave.c b/daemon/gdm-product-slave.c
index 0df50503..f50e30d3 100644
--- a/daemon/gdm-product-slave.c
+++ b/daemon/gdm-product-slave.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -55,7 +55,7 @@ extern char **environ;
#define GDM_PRODUCT_SLAVE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_PRODUCT_SLAVE, GdmProductSlavePrivate))
-#define GDM_DBUS_NAME "org.gnome.DisplayManager"
+#define GDM_DBUS_NAME "org.gnome.DisplayManager"
#define GDM_DBUS_PRODUCT_DISPLAY_INTERFACE "org.gnome.DisplayManager.ProductDisplay"
#define SERVER_DBUS_PATH "/org/gnome/DisplayManager/SessionRelay"
@@ -65,72 +65,72 @@ extern char **environ;
struct GdmProductSlavePrivate
{
- char *id;
- GPid pid;
+ char *id;
+ GPid pid;
guint output_watch_id;
guint error_watch_id;
- char *relay_address;
+ char *relay_address;
- GPid server_pid;
- Display *server_display;
- guint connection_attempts;
+ GPid server_pid;
+ Display *server_display;
+ guint connection_attempts;
- /* user selected */
- char *selected_session;
- char *selected_language;
- char *selected_user;
+ /* user selected */
+ char *selected_session;
+ char *selected_language;
+ char *selected_user;
- GdmServer *server;
- GdmSession *session;
- DBusGProxy *session_relay_proxy;
+ GdmServer *server;
+ GdmSession *session;
+ DBusGProxy *session_relay_proxy;
DBusGConnection *session_relay_connection;
- DBusGProxy *product_display_proxy;
+ DBusGProxy *product_display_proxy;
DBusGConnection *connection;
};
enum {
- PROP_0,
- PROP_DISPLAY_ID,
+ PROP_0,
+ PROP_DISPLAY_ID,
};
-static void gdm_product_slave_class_init (GdmProductSlaveClass *klass);
-static void gdm_product_slave_init (GdmProductSlave *product_slave);
-static void gdm_product_slave_finalize (GObject *object);
+static void gdm_product_slave_class_init (GdmProductSlaveClass *klass);
+static void gdm_product_slave_init (GdmProductSlave *product_slave);
+static void gdm_product_slave_finalize (GObject *object);
G_DEFINE_TYPE (GdmProductSlave, gdm_product_slave, GDM_TYPE_SLAVE)
static void
set_busy_cursor (GdmProductSlave *product_slave)
{
- if (product_slave->priv->server_display != NULL) {
- Cursor xcursor;
-
- xcursor = XCreateFontCursor (product_slave->priv->server_display, GDK_WATCH);
- XDefineCursor (product_slave->priv->server_display,
- DefaultRootWindow (product_slave->priv->server_display),
- xcursor);
- XFreeCursor (product_slave->priv->server_display, xcursor);
- XSync (product_slave->priv->server_display, False);
- }
+ if (product_slave->priv->server_display != NULL) {
+ Cursor xcursor;
+
+ xcursor = XCreateFontCursor (product_slave->priv->server_display, GDK_WATCH);
+ XDefineCursor (product_slave->priv->server_display,
+ DefaultRootWindow (product_slave->priv->server_display),
+ xcursor);
+ XFreeCursor (product_slave->priv->server_display, xcursor);
+ XSync (product_slave->priv->server_display, False);
+ }
}
static void
gdm_product_slave_whack_temp_auth_file (GdmProductSlave *product_slave)
{
#if 0
- uid_t old;
-
- old = geteuid ();
- if (old != 0)
- seteuid (0);
- if (d->parent_temp_auth_file != NULL) {
- VE_IGNORE_EINTR (g_unlink (d->parent_temp_auth_file));
- }
- g_free (d->parent_temp_auth_file);
- d->parent_temp_auth_file = NULL;
- if (old != 0)
- seteuid (old);
+ uid_t old;
+
+ old = geteuid ();
+ if (old != 0)
+ seteuid (0);
+ if (d->parent_temp_auth_file != NULL) {
+ VE_IGNORE_EINTR (g_unlink (d->parent_temp_auth_file));
+ }
+ g_free (d->parent_temp_auth_file);
+ d->parent_temp_auth_file = NULL;
+ if (old != 0)
+ seteuid (old);
#endif
}
@@ -139,1045 +139,1045 @@ static void
create_temp_auth_file (GdmProductSlave *product_slave)
{
#if 0
- if (d->type == TYPE_FLEXI_XNEST &&
- d->parent_auth_file != NULL) {
- if (d->parent_temp_auth_file != NULL) {
- VE_IGNORE_EINTR (g_unlink (d->parent_temp_auth_file));
- }
- g_free (d->parent_temp_auth_file);
- d->parent_temp_auth_file =
- copy_auth_file (d->server_uid,
- gdm_daemon_config_get_gdmuid (),
- d->parent_auth_file);
- }
+ if (d->type == TYPE_FLEXI_XNEST &&
+ d->parent_auth_file != NULL) {
+ if (d->parent_temp_auth_file != NULL) {
+ VE_IGNORE_EINTR (g_unlink (d->parent_temp_auth_file));
+ }
+ g_free (d->parent_temp_auth_file);
+ d->parent_temp_auth_file =
+ copy_auth_file (d->server_uid,
+ gdm_daemon_config_get_gdmuid (),
+ d->parent_auth_file);
+ }
#endif
}
static void
listify_hash (const char *key,
- const char *value,
- GPtrArray *env)
+ const char *value,
+ GPtrArray *env)
{
- char *str;
- str = g_strdup_printf ("%s=%s", key, value);
- g_debug ("environment: %s", str);
- g_ptr_array_add (env, str);
+ char *str;
+ str = g_strdup_printf ("%s=%s", key, value);
+ g_debug ("environment: %s", str);
+ g_ptr_array_add (env, str);
}
static GPtrArray *
get_script_environment (GdmProductSlave *slave,
- const char *username)
+ const char *username)
{
- GPtrArray *env;
- GHashTable *hash;
- struct passwd *pwent;
- char *x_servers_file;
- char *display_name;
- char *display_hostname;
- char *display_x11_authority_file;
- gboolean display_is_local;
-
- g_object_get (slave,
- "display-name", &display_name,
- "display-hostname", &display_hostname,
- "display-is-local", &display_is_local,
- "display-x11-authority-file", &display_x11_authority_file,
- NULL);
-
- env = g_ptr_array_new ();
-
- /* create a hash table of current environment, then update keys has necessary */
- hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-
- /* modify environment here */
- g_hash_table_insert (hash, g_strdup ("HOME"), g_strdup ("/"));
- g_hash_table_insert (hash, g_strdup ("PWD"), g_strdup ("/"));
- g_hash_table_insert (hash, g_strdup ("SHELL"), g_strdup ("/bin/sh"));
-
- g_hash_table_insert (hash, g_strdup ("LOGNAME"), g_strdup (username));
- g_hash_table_insert (hash, g_strdup ("USER"), g_strdup (username));
- g_hash_table_insert (hash, g_strdup ("USERNAME"), g_strdup (username));
-
- pwent = getpwnam (username);
- if (pwent != NULL) {
- if (pwent->pw_dir != NULL && pwent->pw_dir[0] != '\0') {
- g_hash_table_insert (hash, g_strdup ("HOME"), g_strdup (pwent->pw_dir));
- g_hash_table_insert (hash, g_strdup ("PWD"), g_strdup (pwent->pw_dir));
- }
-
- g_hash_table_insert (hash, g_strdup ("SHELL"), g_strdup (pwent->pw_shell));
- }
+ GPtrArray *env;
+ GHashTable *hash;
+ struct passwd *pwent;
+ char *x_servers_file;
+ char *display_name;
+ char *display_hostname;
+ char *display_x11_authority_file;
+ gboolean display_is_local;
+
+ g_object_get (slave,
+ "display-name", &display_name,
+ "display-hostname", &display_hostname,
+ "display-is-local", &display_is_local,
+ "display-x11-authority-file", &display_x11_authority_file,
+ NULL);
+
+ env = g_ptr_array_new ();
+
+ /* create a hash table of current environment, then update keys has necessary */
+ hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
+ /* modify environment here */
+ g_hash_table_insert (hash, g_strdup ("HOME"), g_strdup ("/"));
+ g_hash_table_insert (hash, g_strdup ("PWD"), g_strdup ("/"));
+ g_hash_table_insert (hash, g_strdup ("SHELL"), g_strdup ("/bin/sh"));
+
+ g_hash_table_insert (hash, g_strdup ("LOGNAME"), g_strdup (username));
+ g_hash_table_insert (hash, g_strdup ("USER"), g_strdup (username));
+ g_hash_table_insert (hash, g_strdup ("USERNAME"), g_strdup (username));
+
+ pwent = getpwnam (username);
+ if (pwent != NULL) {
+ if (pwent->pw_dir != NULL && pwent->pw_dir[0] != '\0') {
+ g_hash_table_insert (hash, g_strdup ("HOME"), g_strdup (pwent->pw_dir));
+ g_hash_table_insert (hash, g_strdup ("PWD"), g_strdup (pwent->pw_dir));
+ }
+
+ g_hash_table_insert (hash, g_strdup ("SHELL"), g_strdup (pwent->pw_shell));
+ }
#if 0
- if (display_is_parented) {
- g_hash_table_insert (hash, g_strdup ("GDM_PARENT_DISPLAY"), g_strdup (parent_display_name));
+ if (display_is_parented) {
+ g_hash_table_insert (hash, g_strdup ("GDM_PARENT_DISPLAY"), g_strdup (parent_display_name));
- /*g_hash_table_insert (hash, "GDM_PARENT_XAUTHORITY"), slave->priv->parent_temp_auth_file));*/
- }
+ /*g_hash_table_insert (hash, "GDM_PARENT_XAUTHORITY"), slave->priv->parent_temp_auth_file));*/
+ }
#endif
- /* some env for use with the Pre and Post scripts */
- x_servers_file = gdm_make_filename (AUTHDIR,
- display_name,
- ".Xservers");
- g_hash_table_insert (hash, g_strdup ("X_SERVERS"), x_servers_file);
+ /* some env for use with the Pre and Post scripts */
+ x_servers_file = gdm_make_filename (AUTHDIR,
+ display_name,
+ ".Xservers");
+ g_hash_table_insert (hash, g_strdup ("X_SERVERS"), x_servers_file);
- if (! display_is_local) {
- g_hash_table_insert (hash, g_strdup ("REMOTE_HOST"), g_strdup (display_hostname));
- }
+ if (! display_is_local) {
+ g_hash_table_insert (hash, g_strdup ("REMOTE_HOST"), g_strdup (display_hostname));
+ }
- /* Runs as root */
- g_hash_table_insert (hash, g_strdup ("XAUTHORITY"), g_strdup (display_x11_authority_file));
- g_hash_table_insert (hash, g_strdup ("DISPLAY"), g_strdup (display_name));
+ /* Runs as root */
+ g_hash_table_insert (hash, g_strdup ("XAUTHORITY"), g_strdup (display_x11_authority_file));
+ g_hash_table_insert (hash, g_strdup ("DISPLAY"), g_strdup (display_name));
- /*g_setenv ("PATH", gdm_daemon_config_get_value_string (GDM_KEY_ROOT_PATH), TRUE);*/
+ /*g_setenv ("PATH", gdm_daemon_config_get_value_string (GDM_KEY_ROOT_PATH), TRUE);*/
- g_hash_table_insert (hash, g_strdup ("RUNNING_UNDER_GDM"), g_strdup ("true"));
+ g_hash_table_insert (hash, g_strdup ("RUNNING_UNDER_GDM"), g_strdup ("true"));
#if 0
- if ( ! ve_string_empty (d->theme_name))
- g_setenv ("GDM_GTK_THEME", d->theme_name, TRUE);
+ if ( ! ve_string_empty (d->theme_name))
+ g_setenv ("GDM_GTK_THEME", d->theme_name, TRUE);
#endif
- g_hash_table_remove (hash, "MAIL");
+ g_hash_table_remove (hash, "MAIL");
- g_hash_table_foreach (hash, (GHFunc)listify_hash, env);
- g_hash_table_destroy (hash);
+ g_hash_table_foreach (hash, (GHFunc)listify_hash, env);
+ g_hash_table_destroy (hash);
- g_ptr_array_add (env, NULL);
+ g_ptr_array_add (env, NULL);
- g_free (display_name);
- g_free (display_hostname);
- g_free (display_x11_authority_file);
+ g_free (display_name);
+ g_free (display_hostname);
+ g_free (display_x11_authority_file);
- return env;
+ return env;
}
static gboolean
gdm_product_slave_exec_script (GdmProductSlave *slave,
- const char *dir,
- const char *login)
+ const char *dir,
+ const char *login)
{
- char *script;
- char **argv;
- gint status;
- GError *error;
- GPtrArray *env;
- gboolean res;
- gboolean ret;
- char *display_name;
- char *display_hostname;
-
- g_assert (dir != NULL);
- g_assert (login != NULL);
-
- g_object_get (slave,
- "display-name", &display_name,
- "display-hostname", &display_hostname,
- NULL);
-
- script = g_build_filename (dir, display_name, NULL);
- if (g_access (script, R_OK|X_OK) != 0) {
- g_free (script);
- script = NULL;
- }
-
- if (script == NULL &&
- display_hostname != NULL) {
- script = g_build_filename (dir, display_hostname, NULL);
- if (g_access (script, R_OK|X_OK) != 0) {
- g_free (script);
- script = NULL;
- }
- }
+ char *script;
+ char **argv;
+ gint status;
+ GError *error;
+ GPtrArray *env;
+ gboolean res;
+ gboolean ret;
+ char *display_name;
+ char *display_hostname;
+
+ g_assert (dir != NULL);
+ g_assert (login != NULL);
+
+ g_object_get (slave,
+ "display-name", &display_name,
+ "display-hostname", &display_hostname,
+ NULL);
+
+ script = g_build_filename (dir, display_name, NULL);
+ if (g_access (script, R_OK|X_OK) != 0) {
+ g_free (script);
+ script = NULL;
+ }
+
+ if (script == NULL &&
+ display_hostname != NULL) {
+ script = g_build_filename (dir, display_hostname, NULL);
+ if (g_access (script, R_OK|X_OK) != 0) {
+ g_free (script);
+ script = NULL;
+ }
+ }
#if 0
- if (script == NULL &&
- SERVER_IS_XDMCP (d)) {
- script = g_build_filename (dir, "XDMCP", NULL);
- if (g_access (script, R_OK|X_OK) != 0) {
- g_free (script);
- script = NULL;
- }
- }
- if (script == NULL &&
- SERVER_IS_FLEXI (d)) {
- script = g_build_filename (dir, "Flexi", NULL);
- if (g_access (script, R_OK|X_OK) != 0) {
- g_free (script);
- script = NULL;
- }
- }
+ if (script == NULL &&
+ SERVER_IS_XDMCP (d)) {
+ script = g_build_filename (dir, "XDMCP", NULL);
+ if (g_access (script, R_OK|X_OK) != 0) {
+ g_free (script);
+ script = NULL;
+ }
+ }
+ if (script == NULL &&
+ SERVER_IS_FLEXI (d)) {
+ script = g_build_filename (dir, "Flexi", NULL);
+ if (g_access (script, R_OK|X_OK) != 0) {
+ g_free (script);
+ script = NULL;
+ }
+ }
#endif
- if (script == NULL) {
- script = g_build_filename (dir, "Default", NULL);
- if (g_access (script, R_OK|X_OK) != 0) {
- g_free (script);
- script = NULL;
- }
- }
-
- if (script == NULL) {
- return TRUE;
- }
-
- create_temp_auth_file (slave);
-
- g_debug ("Running process: %s", script);
- error = NULL;
- if (! g_shell_parse_argv (script, NULL, &argv, &error)) {
- g_warning ("Could not parse command: %s", error->message);
- g_error_free (error);
- goto out;
- }
-
- env = get_script_environment (slave, login);
-
- res = g_spawn_sync (NULL,
- argv,
- (char **)env->pdata,
- G_SPAWN_SEARCH_PATH,
- NULL,
- NULL,
- NULL,
- NULL,
- &status,
- &error);
-
- g_ptr_array_foreach (env, (GFunc)g_free, NULL);
+ if (script == NULL) {
+ script = g_build_filename (dir, "Default", NULL);
+ if (g_access (script, R_OK|X_OK) != 0) {
+ g_free (script);
+ script = NULL;
+ }
+ }
+
+ if (script == NULL) {
+ return TRUE;
+ }
+
+ create_temp_auth_file (slave);
+
+ g_debug ("Running process: %s", script);
+ error = NULL;
+ if (! g_shell_parse_argv (script, NULL, &argv, &error)) {
+ g_warning ("Could not parse command: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ env = get_script_environment (slave, login);
+
+ res = g_spawn_sync (NULL,
+ argv,
+ (char **)env->pdata,
+ G_SPAWN_SEARCH_PATH,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ &status,
+ &error);
+
+ g_ptr_array_foreach (env, (GFunc)g_free, NULL);
g_ptr_array_free (env, TRUE);
- gdm_product_slave_whack_temp_auth_file (slave);
+ gdm_product_slave_whack_temp_auth_file (slave);
- if (WIFEXITED (status)) {
- g_debug ("Process exit status: %d", WEXITSTATUS (status));
- ret = WEXITSTATUS (status) != 0;
- } else {
- ret = TRUE;
- }
+ if (WIFEXITED (status)) {
+ g_debug ("Process exit status: %d", WEXITSTATUS (status));
+ ret = WEXITSTATUS (status) != 0;
+ } else {
+ ret = TRUE;
+ }
out:
- g_free (script);
- g_free (display_name);
- g_free (display_hostname);
+ g_free (script);
+ g_free (display_name);
+ g_free (display_hostname);
- return ret;
+ return ret;
}
static void
relay_session_started (GdmProductSlave *slave)
{
- GError *error;
- gboolean res;
-
- error = NULL;
- res = dbus_g_proxy_call (slave->priv->session_relay_proxy,
- "SessionStarted",
- &error,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to send SessionStarted: %s", error->message);
- g_error_free (error);
- }
+ GError *error;
+ gboolean res;
+
+ error = NULL;
+ res = dbus_g_proxy_call (slave->priv->session_relay_proxy,
+ "SessionStarted",
+ &error,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Unable to send SessionStarted: %s", error->message);
+ g_error_free (error);
+ }
}
static void
on_opened (GdmSession *session,
- GdmProductSlave *slave)
+ GdmProductSlave *slave)
{
- GError *error;
- gboolean res;
-
- g_debug ("session opened");
- res = gdm_session_begin_verification (session,
- slave->priv->selected_user,
- &error);
- if (! res) {
- g_warning ("Unable to begin verification: %s", error->message);
- g_error_free (error);
- }
+ GError *error;
+ gboolean res;
+
+ g_debug ("session opened");
+ res = gdm_session_begin_verification (session,
+ slave->priv->selected_user,
+ &error);
+ if (! res) {
+ g_warning ("Unable to begin verification: %s", error->message);
+ g_error_free (error);
+ }
}
static void
disconnect_relay (GdmProductSlave *slave)
{
- /* drop the connection */
- g_object_unref (slave->priv->session_relay_proxy);
+ /* drop the connection */
+ g_object_unref (slave->priv->session_relay_proxy);
- dbus_connection_close (dbus_g_connection_get_connection (slave->priv->session_relay_connection));
- slave->priv->session_relay_connection = NULL;
+ dbus_connection_close (dbus_g_connection_get_connection (slave->priv->session_relay_connection));
+ slave->priv->session_relay_connection = NULL;
}
static void
on_session_started (GdmSession *session,
GPid pid,
- GdmProductSlave *slave)
+ GdmProductSlave *slave)
{
- g_debug ("session started on pid %d", (int) pid);
+ g_debug ("session started on pid %d", (int) pid);
- relay_session_started (slave);
+ relay_session_started (slave);
- disconnect_relay (slave);
+ disconnect_relay (slave);
}
static void
on_session_exited (GdmSession *session,
int exit_code,
- GdmProductSlave *slave)
+ GdmProductSlave *slave)
{
- g_debug ("session exited with code %d", exit_code);
+ g_debug ("session exited with code %d", exit_code);
- gdm_slave_stopped (GDM_SLAVE (slave));
+ gdm_slave_stopped (GDM_SLAVE (slave));
}
static void
on_session_died (GdmSession *session,
int signal_number,
- GdmProductSlave *slave)
+ GdmProductSlave *slave)
{
- g_debug ("session died with signal %d, (%s)",
- signal_number,
- g_strsignal (signal_number));
+ g_debug ("session died with signal %d, (%s)",
+ signal_number,
+ g_strsignal (signal_number));
- gdm_slave_stopped (GDM_SLAVE (slave));
+ gdm_slave_stopped (GDM_SLAVE (slave));
}
static gboolean
is_prog_in_path (const char *prog)
{
- char *f;
- gboolean ret;
+ char *f;
+ gboolean ret;
- f = g_find_program_in_path (prog);
- ret = (f != NULL);
- g_free (f);
- return ret;
+ f = g_find_program_in_path (prog);
+ ret = (f != NULL);
+ g_free (f);
+ return ret;
}
static gboolean
get_session_command (const char *file,
- char **command)
+ char **command)
{
- GKeyFile *key_file;
- GError *error;
- char *full_path;
- char *exec;
- gboolean ret;
- gboolean res;
- const char *search_dirs[] = {
- "/etc/X11/sessions/",
- DMCONFDIR "/Sessions/",
- DATADIR "/gdm/BuiltInSessions/",
- DATADIR "/xsessions/",
- NULL
- };
-
- exec = NULL;
- ret = FALSE;
- if (command != NULL) {
- *command = NULL;
- }
-
- key_file = g_key_file_new ();
-
- error = NULL;
- full_path = NULL;
- res = g_key_file_load_from_dirs (key_file,
- file,
- search_dirs,
- &full_path,
- G_KEY_FILE_NONE,
- &error);
- if (! res) {
- g_debug ("File '%s' not found: %s", file, error->message);
- g_error_free (error);
- if (command != NULL) {
- *command = NULL;
- }
- goto out;
- }
-
- error = NULL;
- res = g_key_file_get_boolean (key_file,
- G_KEY_FILE_DESKTOP_GROUP,
- G_KEY_FILE_DESKTOP_KEY_HIDDEN,
- &error);
- if (error == NULL && res) {
- g_debug ("Session %s is marked as hidden", file);
- goto out;
- }
-
- error = NULL;
- exec = g_key_file_get_string (key_file,
- G_KEY_FILE_DESKTOP_GROUP,
- G_KEY_FILE_DESKTOP_KEY_TRY_EXEC,
- &error);
- if (exec == NULL) {
- g_debug ("%s key not found", G_KEY_FILE_DESKTOP_KEY_TRY_EXEC);
- goto out;
- }
-
- res = is_prog_in_path (exec);
- g_free (exec);
-
- if (! res) {
- g_debug ("Command not found: %s", G_KEY_FILE_DESKTOP_KEY_TRY_EXEC);
- goto out;
- }
-
- error = NULL;
- exec = g_key_file_get_string (key_file,
- G_KEY_FILE_DESKTOP_GROUP,
- G_KEY_FILE_DESKTOP_KEY_EXEC,
- &error);
- if (error != NULL) {
- g_debug ("%s key not found: %s",
- G_KEY_FILE_DESKTOP_KEY_EXEC,
- error->message);
- g_error_free (error);
- goto out;
- }
-
- if (command != NULL) {
- *command = g_strdup (exec);
- }
- ret = TRUE;
+ GKeyFile *key_file;
+ GError *error;
+ char *full_path;
+ char *exec;
+ gboolean ret;
+ gboolean res;
+ const char *search_dirs[] = {
+ "/etc/X11/sessions/",
+ DMCONFDIR "/Sessions/",
+ DATADIR "/gdm/BuiltInSessions/",
+ DATADIR "/xsessions/",
+ NULL
+ };
+
+ exec = NULL;
+ ret = FALSE;
+ if (command != NULL) {
+ *command = NULL;
+ }
+
+ key_file = g_key_file_new ();
+
+ error = NULL;
+ full_path = NULL;
+ res = g_key_file_load_from_dirs (key_file,
+ file,
+ search_dirs,
+ &full_path,
+ G_KEY_FILE_NONE,
+ &error);
+ if (! res) {
+ g_debug ("File '%s' not found: %s", file, error->message);
+ g_error_free (error);
+ if (command != NULL) {
+ *command = NULL;
+ }
+ goto out;
+ }
+
+ error = NULL;
+ res = g_key_file_get_boolean (key_file,
+ G_KEY_FILE_DESKTOP_GROUP,
+ G_KEY_FILE_DESKTOP_KEY_HIDDEN,
+ &error);
+ if (error == NULL && res) {
+ g_debug ("Session %s is marked as hidden", file);
+ goto out;
+ }
+
+ error = NULL;
+ exec = g_key_file_get_string (key_file,
+ G_KEY_FILE_DESKTOP_GROUP,
+ G_KEY_FILE_DESKTOP_KEY_TRY_EXEC,
+ &error);
+ if (exec == NULL) {
+ g_debug ("%s key not found", G_KEY_FILE_DESKTOP_KEY_TRY_EXEC);
+ goto out;
+ }
+
+ res = is_prog_in_path (exec);
+ g_free (exec);
+
+ if (! res) {
+ g_debug ("Command not found: %s", G_KEY_FILE_DESKTOP_KEY_TRY_EXEC);
+ goto out;
+ }
+
+ error = NULL;
+ exec = g_key_file_get_string (key_file,
+ G_KEY_FILE_DESKTOP_GROUP,
+ G_KEY_FILE_DESKTOP_KEY_EXEC,
+ &error);
+ if (error != NULL) {
+ g_debug ("%s key not found: %s",
+ G_KEY_FILE_DESKTOP_KEY_EXEC,
+ error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ if (command != NULL) {
+ *command = g_strdup (exec);
+ }
+ ret = TRUE;
out:
- g_free (exec);
+ g_free (exec);
- return ret;
+ return ret;
}
static void
setup_session_environment (GdmProductSlave *slave)
{
- char *display_name;
- char *auth_file;
-
- g_object_get (slave,
- "display-name", &display_name,
- "display-x11-authority-file", &auth_file,
- NULL);
-
- gdm_session_set_environment_variable (slave->priv->session,
- "GDMSESSION",
- slave->priv->selected_session);
- gdm_session_set_environment_variable (slave->priv->session,
- "DESKTOP_SESSION",
- slave->priv->selected_session);
-
- gdm_session_set_environment_variable (slave->priv->session,
- "LANG",
- slave->priv->selected_language);
- gdm_session_set_environment_variable (slave->priv->session,
- "GDM_LANG",
- slave->priv->selected_language);
-
- gdm_session_set_environment_variable (slave->priv->session,
- "DISPLAY",
- display_name);
- gdm_session_set_environment_variable (slave->priv->session,
- "XAUTHORITY",
- auth_file);
-
- gdm_session_set_environment_variable (slave->priv->session,
- "PATH",
- "/bin:/usr/bin:" BINDIR);
-
- g_free (display_name);
- g_free (auth_file);
+ char *display_name;
+ char *auth_file;
+
+ g_object_get (slave,
+ "display-name", &display_name,
+ "display-x11-authority-file", &auth_file,
+ NULL);
+
+ gdm_session_set_environment_variable (slave->priv->session,
+ "GDMSESSION",
+ slave->priv->selected_session);
+ gdm_session_set_environment_variable (slave->priv->session,
+ "DESKTOP_SESSION",
+ slave->priv->selected_session);
+
+ gdm_session_set_environment_variable (slave->priv->session,
+ "LANG",
+ slave->priv->selected_language);
+ gdm_session_set_environment_variable (slave->priv->session,
+ "GDM_LANG",
+ slave->priv->selected_language);
+
+ gdm_session_set_environment_variable (slave->priv->session,
+ "DISPLAY",
+ display_name);
+ gdm_session_set_environment_variable (slave->priv->session,
+ "XAUTHORITY",
+ auth_file);
+
+ gdm_session_set_environment_variable (slave->priv->session,
+ "PATH",
+ "/bin:/usr/bin:" BINDIR);
+
+ g_free (display_name);
+ g_free (auth_file);
}
static void
setup_server (GdmProductSlave *slave)
{
- gboolean display_is_local;
- char *display_name;
- char *auth_file;
+ gboolean display_is_local;
+ char *display_name;
+ char *auth_file;
- g_object_get (slave,
- "display-is-local", &display_is_local,
- "display-name", &display_name,
- "display-x11-authority-file", &auth_file,
- NULL);
+ g_object_get (slave,
+ "display-is-local", &display_is_local,
+ "display-name", &display_name,
+ "display-x11-authority-file", &auth_file,
+ NULL);
- /* Set the busy cursor */
- set_busy_cursor (slave);
+ /* Set the busy cursor */
+ set_busy_cursor (slave);
- /* FIXME: send a signal back to the master */
+ /* FIXME: send a signal back to the master */
#if 0
- /* OK from now on it's really the user whacking us most likely,
- * we have already started up well */
- do_xfailed_on_xio_error = FALSE;
+ /* OK from now on it's really the user whacking us most likely,
+ * we have already started up well */
+ do_xfailed_on_xio_error = FALSE;
#endif
#if 0
- /* checkout xinerama */
- gdm_screen_init (slave);
+ /* checkout xinerama */
+ gdm_screen_init (slave);
#endif
- /* Run the init script. gdmslave suspends until script has terminated */
- gdm_product_slave_exec_script (slave,
- GDMCONFDIR"/Init",
- "gdm");
+ /* Run the init script. gdmslave suspends until script has terminated */
+ gdm_product_slave_exec_script (slave,
+ GDMCONFDIR"/Init",
+ "gdm");
- g_free (display_name);
- g_free (auth_file);
+ g_free (display_name);
+ g_free (auth_file);
}
static void
set_local_auth (GdmProductSlave *slave)
{
- GString *binary_cookie;
- GString *cookie;
- char *display_x11_cookie;
-
- g_object_get (slave,
- "display-x11-cookie", &display_x11_cookie,
- NULL);
-
- g_debug ("Setting authorization key for display %s", display_x11_cookie);
-
- cookie = g_string_new (display_x11_cookie);
- binary_cookie = g_string_new (NULL);
- if (! gdm_string_hex_decode (cookie,
- 0,
- NULL,
- binary_cookie,
- 0)) {
- g_warning ("Unable to decode hex cookie");
- goto out;
- }
-
- g_debug ("Decoded cookie len %d", binary_cookie->len);
-
- XSetAuthorization ("MIT-MAGIC-COOKIE-1",
- (int) strlen ("MIT-MAGIC-COOKIE-1"),
- (char *)binary_cookie->str,
- binary_cookie->len);
+ GString *binary_cookie;
+ GString *cookie;
+ char *display_x11_cookie;
+
+ g_object_get (slave,
+ "display-x11-cookie", &display_x11_cookie,
+ NULL);
+
+ g_debug ("Setting authorization key for display %s", display_x11_cookie);
+
+ cookie = g_string_new (display_x11_cookie);
+ binary_cookie = g_string_new (NULL);
+ if (! gdm_string_hex_decode (cookie,
+ 0,
+ NULL,
+ binary_cookie,
+ 0)) {
+ g_warning ("Unable to decode hex cookie");
+ goto out;
+ }
+
+ g_debug ("Decoded cookie len %d", binary_cookie->len);
+
+ XSetAuthorization ("MIT-MAGIC-COOKIE-1",
+ (int) strlen ("MIT-MAGIC-COOKIE-1"),
+ (char *)binary_cookie->str,
+ binary_cookie->len);
out:
- g_string_free (binary_cookie, TRUE);
- g_string_free (cookie, TRUE);
- g_free (display_x11_cookie);
+ g_string_free (binary_cookie, TRUE);
+ g_string_free (cookie, TRUE);
+ g_free (display_x11_cookie);
}
static gboolean
connect_to_display (GdmProductSlave *slave)
{
- char *display_name;
- gboolean ret;
+ char *display_name;
+ gboolean ret;
- ret = FALSE;
+ ret = FALSE;
- g_object_get (slave,
- "display-name", &display_name,
- NULL);
+ g_object_get (slave,
+ "display-name", &display_name,
+ NULL);
- /* We keep our own (windowless) connection (dsp) open to avoid the
- * X server resetting due to lack of active connections. */
+ /* We keep our own (windowless) connection (dsp) open to avoid the
+ * X server resetting due to lack of active connections. */
- g_debug ("Server is ready - opening display %s", display_name);
+ g_debug ("Server is ready - opening display %s", display_name);
- g_setenv ("DISPLAY", display_name, TRUE);
- g_unsetenv ("XAUTHORITY"); /* just in case it's set */
+ g_setenv ("DISPLAY", display_name, TRUE);
+ g_unsetenv ("XAUTHORITY"); /* just in case it's set */
- set_local_auth (slave);
+ set_local_auth (slave);
#if 0
- /* X error handlers to avoid the default one (i.e. exit (1)) */
- do_xfailed_on_xio_error = TRUE;
- XSetErrorHandler (gdm_product_slave_xerror_handler);
- XSetIOErrorHandler (gdm_product_slave_xioerror_handler);
+ /* X error handlers to avoid the default one (i.e. exit (1)) */
+ do_xfailed_on_xio_error = TRUE;
+ XSetErrorHandler (gdm_product_slave_xerror_handler);
+ XSetIOErrorHandler (gdm_product_slave_xioerror_handler);
#endif
- gdm_sigchld_block_push ();
- slave->priv->server_display = XOpenDisplay (display_name);
- gdm_sigchld_block_pop ();
+ gdm_sigchld_block_push ();
+ slave->priv->server_display = XOpenDisplay (display_name);
+ gdm_sigchld_block_pop ();
- if (slave->priv->server_display == NULL) {
- g_warning ("Unable to connect to display %s", display_name);
- ret = FALSE;
- } else {
- g_debug ("Connected to display %s", display_name);
- ret = TRUE;
- }
+ if (slave->priv->server_display == NULL) {
+ g_warning ("Unable to connect to display %s", display_name);
+ ret = FALSE;
+ } else {
+ g_debug ("Connected to display %s", display_name);
+ ret = TRUE;
+ }
- g_free (display_name);
+ g_free (display_name);
- return ret;
+ return ret;
}
static gboolean
setup_session (GdmProductSlave *slave)
{
- char *username;
- char *command;
- char *filename;
- gboolean res;
-
- username = gdm_session_get_username (slave->priv->session);
-
- g_debug ("%s%ssuccessfully authenticated\n",
- username ? username : "",
- username ? " " : "");
- g_free (username);
-
- if (slave->priv->selected_session != NULL) {
- filename = g_strdup (slave->priv->selected_session);
- } else {
- filename = g_strdup ("gnome.desktop");
- }
+ char *username;
+ char *command;
+ char *filename;
+ gboolean res;
+
+ username = gdm_session_get_username (slave->priv->session);
+
+ g_debug ("%s%ssuccessfully authenticated\n",
+ username ? username : "",
+ username ? " " : "");
+ g_free (username);
+
+ if (slave->priv->selected_session != NULL) {
+ filename = g_strdup (slave->priv->selected_session);
+ } else {
+ filename = g_strdup ("gnome.desktop");
+ }
- setup_session_environment (slave);
+ setup_session_environment (slave);
- res = get_session_command (filename, &command);
- if (! res) {
- g_warning ("Could find session file: %s", filename);
- return FALSE;
- }
+ res = get_session_command (filename, &command);
+ if (! res) {
+ g_warning ("Could find session file: %s", filename);
+ return FALSE;
+ }
- gdm_session_start_program (slave->priv->session, command);
+ gdm_session_start_program (slave->priv->session, command);
- g_free (filename);
- g_free (command);
+ g_free (filename);
+ g_free (command);
- return TRUE;
+ return TRUE;
}
static gboolean
idle_connect_to_display (GdmProductSlave *slave)
{
- gboolean res;
+ gboolean res;
- slave->priv->connection_attempts++;
+ slave->priv->connection_attempts++;
- res = connect_to_display (slave);
- if (res) {
- /* FIXME: handle wait-for-go */
+ res = connect_to_display (slave);
+ if (res) {
+ /* FIXME: handle wait-for-go */
- setup_server (slave);
- setup_session (slave);
- } else {
- if (slave->priv->connection_attempts >= MAX_CONNECT_ATTEMPTS) {
- g_warning ("Unable to connect to display after %d tries - bailing out", slave->priv->connection_attempts);
- exit (1);
- }
- }
+ setup_server (slave);
+ setup_session (slave);
+ } else {
+ if (slave->priv->connection_attempts >= MAX_CONNECT_ATTEMPTS) {
+ g_warning ("Unable to connect to display after %d tries - bailing out", slave->priv->connection_attempts);
+ exit (1);
+ }
+ }
- return FALSE;
+ return FALSE;
}
static void
server_ready_cb (GdmServer *server,
- GdmProductSlave *slave)
+ GdmProductSlave *slave)
{
- g_timeout_add (500, (GSourceFunc)idle_connect_to_display, slave);
+ g_timeout_add (500, (GSourceFunc)idle_connect_to_display, slave);
}
static gboolean
gdm_product_slave_create_server (GdmProductSlave *slave)
{
- char *display_name;
- gboolean display_is_local;
-
- g_object_get (slave,
- "display-is-local", &display_is_local,
- "display-name", &display_name,
- NULL);
-
- /* if this is local display start a server if one doesn't
- * exist */
- if (display_is_local) {
- gboolean res;
-
- slave->priv->server = gdm_server_new (display_name);
-
- g_signal_connect (slave->priv->server,
- "ready",
- G_CALLBACK (server_ready_cb),
- slave);
-
- res = gdm_server_start (slave->priv->server);
- if (! res) {
- g_warning (_("Could not start the X "
- "server (your graphical environment) "
- "due to some internal error. "
- "Please contact your system administrator "
- "or check your syslog to diagnose. "
- "In the meantime this display will be "
- "disabled. Please restart GDM when "
- "the problem is corrected."));
- exit (1);
- }
-
- g_debug ("Started X server");
- } else {
- g_timeout_add (500, (GSourceFunc)idle_connect_to_display, slave);
- }
-
- g_free (display_name);
-
- return TRUE;
+ char *display_name;
+ gboolean display_is_local;
+
+ g_object_get (slave,
+ "display-is-local", &display_is_local,
+ "display-name", &display_name,
+ NULL);
+
+ /* if this is local display start a server if one doesn't
+ * exist */
+ if (display_is_local) {
+ gboolean res;
+
+ slave->priv->server = gdm_server_new (display_name);
+
+ g_signal_connect (slave->priv->server,
+ "ready",
+ G_CALLBACK (server_ready_cb),
+ slave);
+
+ res = gdm_server_start (slave->priv->server);
+ if (! res) {
+ g_warning (_("Could not start the X "
+ "server (your graphical environment) "
+ "due to some internal error. "
+ "Please contact your system administrator "
+ "or check your syslog to diagnose. "
+ "In the meantime this display will be "
+ "disabled. Please restart GDM when "
+ "the problem is corrected."));
+ exit (1);
+ }
+
+ g_debug ("Started X server");
+ } else {
+ g_timeout_add (500, (GSourceFunc)idle_connect_to_display, slave);
+ }
+
+ g_free (display_name);
+
+ return TRUE;
}
static void
on_user_verified (GdmSession *session,
- GdmProductSlave *slave)
+ GdmProductSlave *slave)
{
- gdm_product_slave_create_server (slave);
+ gdm_product_slave_create_server (slave);
}
static void
on_user_verification_error (GdmSession *session,
GError *error,
- GdmProductSlave *slave)
+ GdmProductSlave *slave)
{
- char *username;
+ char *username;
- username = gdm_session_get_username (session);
+ username = gdm_session_get_username (session);
- g_debug ("%s%scould not be successfully authenticated: %s\n",
- username ? username : "",
- username ? " " : "",
- error->message);
+ g_debug ("%s%scould not be successfully authenticated: %s\n",
+ username ? username : "",
+ username ? " " : "",
+ error->message);
- g_free (username);
+ g_free (username);
}
static void
ready_relay (GdmProductSlave *slave)
{
- GError *error;
- gboolean res;
-
- error = NULL;
- res = dbus_g_proxy_call (slave->priv->session_relay_proxy,
- "Ready",
- &error,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to send Ready: %s", error->message);
- g_error_free (error);
- }
+ GError *error;
+ gboolean res;
+
+ error = NULL;
+ res = dbus_g_proxy_call (slave->priv->session_relay_proxy,
+ "Ready",
+ &error,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Unable to send Ready: %s", error->message);
+ g_error_free (error);
+ }
}
static void
on_info (GdmSession *session,
const char *text,
- GdmProductSlave *slave)
+ GdmProductSlave *slave)
{
- GError *error;
- gboolean res;
-
- g_debug ("Info: %s", text);
-
- error = NULL;
- res = dbus_g_proxy_call (slave->priv->session_relay_proxy,
- "Info",
- &error,
- G_TYPE_STRING, text,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to send Info: %s", error->message);
- g_error_free (error);
- }
+ GError *error;
+ gboolean res;
+
+ g_debug ("Info: %s", text);
+
+ error = NULL;
+ res = dbus_g_proxy_call (slave->priv->session_relay_proxy,
+ "Info",
+ &error,
+ G_TYPE_STRING, text,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Unable to send Info: %s", error->message);
+ g_error_free (error);
+ }
}
static void
on_problem (GdmSession *session,
const char *text,
- GdmProductSlave *slave)
+ GdmProductSlave *slave)
{
- GError *error;
- gboolean res;
-
- g_debug ("Problem: %s", text);
-
- error = NULL;
- res = dbus_g_proxy_call (slave->priv->session_relay_proxy,
- "Problem",
- &error,
- G_TYPE_STRING, text,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to send Problem: %s", error->message);
- g_error_free (error);
- }
+ GError *error;
+ gboolean res;
+
+ g_debug ("Problem: %s", text);
+
+ error = NULL;
+ res = dbus_g_proxy_call (slave->priv->session_relay_proxy,
+ "Problem",
+ &error,
+ G_TYPE_STRING, text,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Unable to send Problem: %s", error->message);
+ g_error_free (error);
+ }
}
static void
on_info_query (GdmSession *session,
const char *text,
- GdmProductSlave *slave)
+ GdmProductSlave *slave)
{
- GError *error;
- gboolean res;
-
- g_debug ("Info query: %s", text);
-
- error = NULL;
- res = dbus_g_proxy_call (slave->priv->session_relay_proxy,
- "InfoQuery",
- &error,
- G_TYPE_STRING, text,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to send InfoQuery: %s", error->message);
- g_error_free (error);
- }
+ GError *error;
+ gboolean res;
+
+ g_debug ("Info query: %s", text);
+
+ error = NULL;
+ res = dbus_g_proxy_call (slave->priv->session_relay_proxy,
+ "InfoQuery",
+ &error,
+ G_TYPE_STRING, text,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Unable to send InfoQuery: %s", error->message);
+ g_error_free (error);
+ }
}
static void
on_secret_info_query (GdmSession *session,
const char *text,
- GdmProductSlave *slave)
+ GdmProductSlave *slave)
{
- GError *error;
- gboolean res;
-
-
- g_debug ("Secret info query: %s", text);
-
- error = NULL;
- res = dbus_g_proxy_call (slave->priv->session_relay_proxy,
- "SecretInfoQuery",
- &error,
- G_TYPE_STRING, text,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to send SecretInfoQuery: %s", error->message);
- g_error_free (error);
- }
+ GError *error;
+ gboolean res;
+
+
+ g_debug ("Secret info query: %s", text);
+
+ error = NULL;
+ res = dbus_g_proxy_call (slave->priv->session_relay_proxy,
+ "SecretInfoQuery",
+ &error,
+ G_TYPE_STRING, text,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Unable to send SecretInfoQuery: %s", error->message);
+ g_error_free (error);
+ }
}
static void
on_relay_answer (DBusGProxy *proxy,
- const char *text,
- gpointer data)
+ const char *text,
+ gpointer data)
{
- GdmProductSlave *slave = GDM_PRODUCT_SLAVE (data);
+ GdmProductSlave *slave = GDM_PRODUCT_SLAVE (data);
- g_debug ("Relay Answer");
+ g_debug ("Relay Answer");
- gdm_session_answer_query (slave->priv->session, text);
+ gdm_session_answer_query (slave->priv->session, text);
}
static void
on_relay_session_selected (DBusGProxy *proxy,
- const char *text,
- gpointer data)
+ const char *text,
+ gpointer data)
{
- GdmProductSlave *slave = GDM_PRODUCT_SLAVE (data);
+ GdmProductSlave *slave = GDM_PRODUCT_SLAVE (data);
- g_debug ("Session: %s", text);
+ g_debug ("Session: %s", text);
- g_free (slave->priv->selected_session);
- slave->priv->selected_session = g_strdup (text);
+ g_free (slave->priv->selected_session);
+ slave->priv->selected_session = g_strdup (text);
}
static void
on_relay_language_selected (DBusGProxy *proxy,
- const char *text,
- gpointer data)
+ const char *text,
+ gpointer data)
{
- GdmProductSlave *slave = GDM_PRODUCT_SLAVE (data);
+ GdmProductSlave *slave = GDM_PRODUCT_SLAVE (data);
- g_debug ("Language: %s", text);
+ g_debug ("Language: %s", text);
- g_free (slave->priv->selected_language);
- slave->priv->selected_language = g_strdup (text);
+ g_free (slave->priv->selected_language);
+ slave->priv->selected_language = g_strdup (text);
}
static gboolean
reset_session (GdmProductSlave *slave)
{
- gboolean res;
- GError *error;
-
- gdm_session_close (slave->priv->session);
- res = gdm_session_open (slave->priv->session,
- "gdm",
- "",
- "/dev/console",
- &error);
- if (! res) {
- g_warning ("Unable to open session: %s", error->message);
- g_error_free (error);
- }
-
- return res;
+ gboolean res;
+ GError *error;
+
+ gdm_session_close (slave->priv->session);
+ res = gdm_session_open (slave->priv->session,
+ "gdm",
+ "",
+ "/dev/console",
+ &error);
+ if (! res) {
+ g_warning ("Unable to open session: %s", error->message);
+ g_error_free (error);
+ }
+
+ return res;
}
static void
on_relay_user_selected (DBusGProxy *proxy,
- const char *text,
- gpointer data)
+ const char *text,
+ gpointer data)
{
- GdmProductSlave *slave = GDM_PRODUCT_SLAVE (data);
+ GdmProductSlave *slave = GDM_PRODUCT_SLAVE (data);
- g_debug ("User: %s", text);
+ g_debug ("User: %s", text);
- g_free (slave->priv->selected_user);
- slave->priv->selected_user = g_strdup (text);
+ g_free (slave->priv->selected_user);
+ slave->priv->selected_user = g_strdup (text);
- reset_session (slave);
+ reset_session (slave);
}
static void
on_relay_open (DBusGProxy *proxy,
- gpointer data)
+ gpointer data)
{
- GdmProductSlave *slave = GDM_PRODUCT_SLAVE (data);
- gboolean res;
- GError *error;
-
- g_debug ("Relay open: opening session");
-
- error = NULL;
- res = gdm_session_open (slave->priv->session,
- "gdm",
- "",
- "/dev/console",
- &error);
- if (! res) {
- g_warning ("Unable to open session: %s", error->message);
- g_error_free (error);
- }
+ GdmProductSlave *slave = GDM_PRODUCT_SLAVE (data);
+ gboolean res;
+ GError *error;
+
+ g_debug ("Relay open: opening session");
+
+ error = NULL;
+ res = gdm_session_open (slave->priv->session,
+ "gdm",
+ "",
+ "/dev/console",
+ &error);
+ if (! res) {
+ g_warning ("Unable to open session: %s", error->message);
+ g_error_free (error);
+ }
}
static void
create_new_session (GdmProductSlave *slave)
{
- slave->priv->session = gdm_session_new ();
-
- g_signal_connect (slave->priv->session,
- "opened",
- G_CALLBACK (on_opened),
- slave);
-
- g_signal_connect (slave->priv->session,
- "info",
- G_CALLBACK (on_info),
- slave);
-
- g_signal_connect (slave->priv->session,
- "problem",
- G_CALLBACK (on_problem),
- slave);
-
- g_signal_connect (slave->priv->session,
- "info-query",
- G_CALLBACK (on_info_query),
- slave);
-
- g_signal_connect (slave->priv->session,
- "secret-info-query",
- G_CALLBACK (on_secret_info_query),
- slave);
-
- g_signal_connect (slave->priv->session,
- "user-verified",
- G_CALLBACK (on_user_verified),
- slave);
-
- g_signal_connect (slave->priv->session,
- "user-verification-error",
- G_CALLBACK (on_user_verification_error),
- slave);
-
- g_signal_connect (slave->priv->session,
- "session-started",
- G_CALLBACK (on_session_started),
- slave);
- g_signal_connect (slave->priv->session,
- "session-exited",
- G_CALLBACK (on_session_exited),
- slave);
- g_signal_connect (slave->priv->session,
- "session-died",
- G_CALLBACK (on_session_died),
- slave);
+ slave->priv->session = gdm_session_new ();
+
+ g_signal_connect (slave->priv->session,
+ "opened",
+ G_CALLBACK (on_opened),
+ slave);
+
+ g_signal_connect (slave->priv->session,
+ "info",
+ G_CALLBACK (on_info),
+ slave);
+
+ g_signal_connect (slave->priv->session,
+ "problem",
+ G_CALLBACK (on_problem),
+ slave);
+
+ g_signal_connect (slave->priv->session,
+ "info-query",
+ G_CALLBACK (on_info_query),
+ slave);
+
+ g_signal_connect (slave->priv->session,
+ "secret-info-query",
+ G_CALLBACK (on_secret_info_query),
+ slave);
+
+ g_signal_connect (slave->priv->session,
+ "user-verified",
+ G_CALLBACK (on_user_verified),
+ slave);
+
+ g_signal_connect (slave->priv->session,
+ "user-verification-error",
+ G_CALLBACK (on_user_verification_error),
+ slave);
+
+ g_signal_connect (slave->priv->session,
+ "session-started",
+ G_CALLBACK (on_session_started),
+ slave);
+ g_signal_connect (slave->priv->session,
+ "session-exited",
+ G_CALLBACK (on_session_exited),
+ slave);
+ g_signal_connect (slave->priv->session,
+ "session-died",
+ G_CALLBACK (on_session_died),
+ slave);
}
static void
on_relay_cancelled (DBusGProxy *proxy,
- gpointer data)
+ gpointer data)
{
- GdmProductSlave *slave = GDM_PRODUCT_SLAVE (data);
+ GdmProductSlave *slave = GDM_PRODUCT_SLAVE (data);
- g_debug ("Relay cancelled");
+ g_debug ("Relay cancelled");
- if (slave->priv->session != NULL) {
- gdm_session_close (slave->priv->session);
- g_object_unref (slave->priv->session);
- }
+ if (slave->priv->session != NULL) {
+ gdm_session_close (slave->priv->session);
+ g_object_unref (slave->priv->session);
+ }
- create_new_session (slave);
+ create_new_session (slave);
- ready_relay (slave);
+ ready_relay (slave);
}
static void
session_relay_proxy_destroyed (GObject *object,
- GdmProductSlave *slave)
+ GdmProductSlave *slave)
{
- g_debug ("Session server relay destroyed");
+ g_debug ("Session server relay destroyed");
- slave->priv->session_relay_proxy = NULL;
+ slave->priv->session_relay_proxy = NULL;
}
static void
get_relay_address (GdmProductSlave *slave)
{
- GError *error;
- char *text;
- gboolean res;
-
- text = NULL;
- error = NULL;
- res = dbus_g_proxy_call (slave->priv->product_display_proxy,
- "GetRelayAddress",
- &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &text,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to get relay address: %s", error->message);
- g_error_free (error);
- } else {
- g_free (slave->priv->relay_address);
- slave->priv->relay_address = g_strdup (text);
- g_debug ("Got relay address: %s", slave->priv->relay_address);
- }
-
- g_free (text);
+ GError *error;
+ char *text;
+ gboolean res;
+
+ text = NULL;
+ error = NULL;
+ res = dbus_g_proxy_call (slave->priv->product_display_proxy,
+ "GetRelayAddress",
+ &error,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &text,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Unable to get relay address: %s", error->message);
+ g_error_free (error);
+ } else {
+ g_free (slave->priv->relay_address);
+ slave->priv->relay_address = g_strdup (text);
+ g_debug ("Got relay address: %s", slave->priv->relay_address);
+ }
+
+ g_free (text);
}
static gboolean
connect_to_session_relay (GdmProductSlave *slave)
{
- DBusError error;
- DBusConnection *connection;
+ DBusError error;
+ DBusConnection *connection;
- get_relay_address (slave);
+ get_relay_address (slave);
- g_debug ("connecting to session relay address: %s", slave->priv->relay_address);
+ g_debug ("connecting to session relay address: %s", slave->priv->relay_address);
- dbus_error_init (&error);
- connection = dbus_connection_open_private (slave->priv->relay_address, &error);
- dbus_connection_setup_with_g_main (connection, NULL);
+ dbus_error_init (&error);
+ connection = dbus_connection_open_private (slave->priv->relay_address, &error);
+ dbus_connection_setup_with_g_main (connection, NULL);
slave->priv->session_relay_connection = dbus_connection_get_g_connection (connection);
if (slave->priv->session_relay_connection == NULL) {
@@ -1185,100 +1185,100 @@ connect_to_session_relay (GdmProductSlave *slave)
g_warning ("error opening connection: %s", error.message);
dbus_error_free (&error);
} else {
- g_warning ("Unable to open connection");
- }
- exit (1);
+ g_warning ("Unable to open connection");
+ }
+ exit (1);
}
- g_debug ("creating session server proxy for peer: %s", SERVER_DBUS_PATH);
+ g_debug ("creating session server proxy for peer: %s", SERVER_DBUS_PATH);
slave->priv->session_relay_proxy = dbus_g_proxy_new_for_peer (slave->priv->session_relay_connection,
- SERVER_DBUS_PATH,
- SERVER_DBUS_INTERFACE);
- if (slave->priv->session_relay_proxy == NULL) {
- g_warning ("Unable to create proxy for peer");
- exit (1);
- }
-
- /* FIXME: not sure why introspection isn't working */
- dbus_g_proxy_add_signal (slave->priv->session_relay_proxy,
- "AnswerQuery",
- G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_add_signal (slave->priv->session_relay_proxy,
- "SessionSelected",
- G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_add_signal (slave->priv->session_relay_proxy,
- "LanguageSelected",
- G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_add_signal (slave->priv->session_relay_proxy,
- "UserSelected",
- G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_add_signal (slave->priv->session_relay_proxy,
- "Open",
- G_TYPE_INVALID);
- dbus_g_proxy_add_signal (slave->priv->session_relay_proxy,
- "Cancelled",
- G_TYPE_INVALID);
-
- dbus_g_proxy_connect_signal (slave->priv->session_relay_proxy,
- "AnswerQuery",
- G_CALLBACK (on_relay_answer),
- slave,
- NULL);
- dbus_g_proxy_connect_signal (slave->priv->session_relay_proxy,
- "SessionSelected",
- G_CALLBACK (on_relay_session_selected),
- slave,
- NULL);
- dbus_g_proxy_connect_signal (slave->priv->session_relay_proxy,
- "LanguageSelected",
- G_CALLBACK (on_relay_language_selected),
- slave,
- NULL);
- dbus_g_proxy_connect_signal (slave->priv->session_relay_proxy,
- "UserSelected",
- G_CALLBACK (on_relay_user_selected),
- slave,
- NULL);
- dbus_g_proxy_connect_signal (slave->priv->session_relay_proxy,
- "Open",
- G_CALLBACK (on_relay_open),
- slave,
- NULL);
- dbus_g_proxy_connect_signal (slave->priv->session_relay_proxy,
- "Cancelled",
- G_CALLBACK (on_relay_cancelled),
- slave,
- NULL);
-
- g_signal_connect (slave->priv->session_relay_proxy,
- "destroy",
- G_CALLBACK (session_relay_proxy_destroyed),
- slave);
-
- return TRUE;
+ SERVER_DBUS_PATH,
+ SERVER_DBUS_INTERFACE);
+ if (slave->priv->session_relay_proxy == NULL) {
+ g_warning ("Unable to create proxy for peer");
+ exit (1);
+ }
+
+ /* FIXME: not sure why introspection isn't working */
+ dbus_g_proxy_add_signal (slave->priv->session_relay_proxy,
+ "AnswerQuery",
+ G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (slave->priv->session_relay_proxy,
+ "SessionSelected",
+ G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (slave->priv->session_relay_proxy,
+ "LanguageSelected",
+ G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (slave->priv->session_relay_proxy,
+ "UserSelected",
+ G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (slave->priv->session_relay_proxy,
+ "Open",
+ G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (slave->priv->session_relay_proxy,
+ "Cancelled",
+ G_TYPE_INVALID);
+
+ dbus_g_proxy_connect_signal (slave->priv->session_relay_proxy,
+ "AnswerQuery",
+ G_CALLBACK (on_relay_answer),
+ slave,
+ NULL);
+ dbus_g_proxy_connect_signal (slave->priv->session_relay_proxy,
+ "SessionSelected",
+ G_CALLBACK (on_relay_session_selected),
+ slave,
+ NULL);
+ dbus_g_proxy_connect_signal (slave->priv->session_relay_proxy,
+ "LanguageSelected",
+ G_CALLBACK (on_relay_language_selected),
+ slave,
+ NULL);
+ dbus_g_proxy_connect_signal (slave->priv->session_relay_proxy,
+ "UserSelected",
+ G_CALLBACK (on_relay_user_selected),
+ slave,
+ NULL);
+ dbus_g_proxy_connect_signal (slave->priv->session_relay_proxy,
+ "Open",
+ G_CALLBACK (on_relay_open),
+ slave,
+ NULL);
+ dbus_g_proxy_connect_signal (slave->priv->session_relay_proxy,
+ "Cancelled",
+ G_CALLBACK (on_relay_cancelled),
+ slave,
+ NULL);
+
+ g_signal_connect (slave->priv->session_relay_proxy,
+ "destroy",
+ G_CALLBACK (session_relay_proxy_destroyed),
+ slave);
+
+ return TRUE;
}
static gboolean
gdm_product_slave_start (GdmSlave *slave)
{
- gboolean ret;
- gboolean res;
- GError *error;
- char *display_id;
+ gboolean ret;
+ gboolean res;
+ GError *error;
+ char *display_id;
- ret = FALSE;
+ ret = FALSE;
- res = GDM_SLAVE_CLASS (gdm_product_slave_parent_class)->start (slave);
+ res = GDM_SLAVE_CLASS (gdm_product_slave_parent_class)->start (slave);
- g_object_get (slave,
- "display-id", &display_id,
- NULL);
+ g_object_get (slave,
+ "display-id", &display_id,
+ NULL);
- error = NULL;
+ error = NULL;
GDM_PRODUCT_SLAVE (slave)->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
if (GDM_PRODUCT_SLAVE (slave)->priv->connection == NULL) {
if (error != NULL) {
@@ -1288,102 +1288,102 @@ gdm_product_slave_start (GdmSlave *slave)
exit (1);
}
- error = NULL;
- GDM_PRODUCT_SLAVE (slave)->priv->product_display_proxy = dbus_g_proxy_new_for_name_owner (GDM_PRODUCT_SLAVE (slave)->priv->connection,
- GDM_DBUS_NAME,
- display_id,
- GDM_DBUS_PRODUCT_DISPLAY_INTERFACE,
- &error);
- if (GDM_PRODUCT_SLAVE (slave)->priv->product_display_proxy == NULL) {
- if (error != NULL) {
- g_warning ("Failed to create display proxy %s: %s", display_id, error->message);
- g_error_free (error);
- } else {
- g_warning ("Unable to create display proxy");
- }
- goto out;
- }
+ error = NULL;
+ GDM_PRODUCT_SLAVE (slave)->priv->product_display_proxy = dbus_g_proxy_new_for_name_owner (GDM_PRODUCT_SLAVE (slave)->priv->connection,
+ GDM_DBUS_NAME,
+ display_id,
+ GDM_DBUS_PRODUCT_DISPLAY_INTERFACE,
+ &error);
+ if (GDM_PRODUCT_SLAVE (slave)->priv->product_display_proxy == NULL) {
+ if (error != NULL) {
+ g_warning ("Failed to create display proxy %s: %s", display_id, error->message);
+ g_error_free (error);
+ } else {
+ g_warning ("Unable to create display proxy");
+ }
+ goto out;
+ }
- create_new_session (GDM_PRODUCT_SLAVE (slave));
+ create_new_session (GDM_PRODUCT_SLAVE (slave));
- connect_to_session_relay (GDM_PRODUCT_SLAVE (slave));
+ connect_to_session_relay (GDM_PRODUCT_SLAVE (slave));
- ready_relay (GDM_PRODUCT_SLAVE (slave));
+ ready_relay (GDM_PRODUCT_SLAVE (slave));
- ret = TRUE;
+ ret = TRUE;
out:
- g_free (display_id);
+ g_free (display_id);
- return ret;
+ return ret;
}
static gboolean
gdm_product_slave_stop (GdmSlave *slave)
{
- gboolean res;
+ gboolean res;
- g_debug ("Stopping product_slave");
+ g_debug ("Stopping product_slave");
- res = GDM_SLAVE_CLASS (gdm_product_slave_parent_class)->stop (slave);
+ res = GDM_SLAVE_CLASS (gdm_product_slave_parent_class)->stop (slave);
- if (GDM_PRODUCT_SLAVE (slave)->priv->session != NULL) {
- gdm_session_close (GDM_PRODUCT_SLAVE (slave)->priv->session);
- g_object_unref (GDM_PRODUCT_SLAVE (slave)->priv->session);
- GDM_PRODUCT_SLAVE (slave)->priv->session = NULL;
- }
+ if (GDM_PRODUCT_SLAVE (slave)->priv->session != NULL) {
+ gdm_session_close (GDM_PRODUCT_SLAVE (slave)->priv->session);
+ g_object_unref (GDM_PRODUCT_SLAVE (slave)->priv->session);
+ GDM_PRODUCT_SLAVE (slave)->priv->session = NULL;
+ }
- if (GDM_PRODUCT_SLAVE (slave)->priv->server != NULL) {
- gdm_server_stop (GDM_PRODUCT_SLAVE (slave)->priv->server);
- g_object_unref (GDM_PRODUCT_SLAVE (slave)->priv->server);
- GDM_PRODUCT_SLAVE (slave)->priv->server = NULL;
- }
+ if (GDM_PRODUCT_SLAVE (slave)->priv->server != NULL) {
+ gdm_server_stop (GDM_PRODUCT_SLAVE (slave)->priv->server);
+ g_object_unref (GDM_PRODUCT_SLAVE (slave)->priv->server);
+ GDM_PRODUCT_SLAVE (slave)->priv->server = NULL;
+ }
- if (GDM_PRODUCT_SLAVE (slave)->priv->product_display_proxy != NULL) {
- g_object_unref (GDM_PRODUCT_SLAVE (slave)->priv->product_display_proxy);
- }
+ if (GDM_PRODUCT_SLAVE (slave)->priv->product_display_proxy != NULL) {
+ g_object_unref (GDM_PRODUCT_SLAVE (slave)->priv->product_display_proxy);
+ }
- return TRUE;
+ return TRUE;
}
static void
gdm_product_slave_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GdmProductSlave *self;
+ GdmProductSlave *self;
- self = GDM_PRODUCT_SLAVE (object);
+ self = GDM_PRODUCT_SLAVE (object);
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_product_slave_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GdmProductSlave *self;
+ GdmProductSlave *self;
- self = GDM_PRODUCT_SLAVE (object);
+ self = GDM_PRODUCT_SLAVE (object);
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static GObject *
gdm_product_slave_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
{
GdmProductSlave *product_slave;
GdmProductSlaveClass *klass;
@@ -1391,64 +1391,64 @@ gdm_product_slave_constructor (GType type,
klass = GDM_PRODUCT_SLAVE_CLASS (g_type_class_peek (GDM_TYPE_PRODUCT_SLAVE));
product_slave = GDM_PRODUCT_SLAVE (G_OBJECT_CLASS (gdm_product_slave_parent_class)->constructor (type,
- n_construct_properties,
- construct_properties));
+ n_construct_properties,
+ construct_properties));
return G_OBJECT (product_slave);
}
static void
gdm_product_slave_class_init (GdmProductSlaveClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GdmSlaveClass *slave_class = GDM_SLAVE_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GdmSlaveClass *slave_class = GDM_SLAVE_CLASS (klass);
- object_class->get_property = gdm_product_slave_get_property;
- object_class->set_property = gdm_product_slave_set_property;
+ object_class->get_property = gdm_product_slave_get_property;
+ object_class->set_property = gdm_product_slave_set_property;
object_class->constructor = gdm_product_slave_constructor;
- object_class->finalize = gdm_product_slave_finalize;
+ object_class->finalize = gdm_product_slave_finalize;
- slave_class->start = gdm_product_slave_start;
- slave_class->stop = gdm_product_slave_stop;
+ slave_class->start = gdm_product_slave_start;
+ slave_class->stop = gdm_product_slave_stop;
- g_type_class_add_private (klass, sizeof (GdmProductSlavePrivate));
+ g_type_class_add_private (klass, sizeof (GdmProductSlavePrivate));
- dbus_g_object_type_install_info (GDM_TYPE_PRODUCT_SLAVE, &dbus_glib_gdm_product_slave_object_info);
+ dbus_g_object_type_install_info (GDM_TYPE_PRODUCT_SLAVE, &dbus_glib_gdm_product_slave_object_info);
}
static void
gdm_product_slave_init (GdmProductSlave *product_slave)
{
- product_slave->priv = GDM_PRODUCT_SLAVE_GET_PRIVATE (product_slave);
+ product_slave->priv = GDM_PRODUCT_SLAVE_GET_PRIVATE (product_slave);
- product_slave->priv->pid = -1;
+ product_slave->priv->pid = -1;
}
static void
gdm_product_slave_finalize (GObject *object)
{
- GdmProductSlave *slave;
+ GdmProductSlave *slave;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_PRODUCT_SLAVE (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_PRODUCT_SLAVE (object));
- slave = GDM_PRODUCT_SLAVE (object);
+ slave = GDM_PRODUCT_SLAVE (object);
- g_return_if_fail (slave->priv != NULL);
+ g_return_if_fail (slave->priv != NULL);
- gdm_product_slave_stop (GDM_SLAVE (slave));
+ gdm_product_slave_stop (GDM_SLAVE (slave));
- G_OBJECT_CLASS (gdm_product_slave_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_product_slave_parent_class)->finalize (object);
}
GdmSlave *
gdm_product_slave_new (const char *id)
{
- GObject *object;
+ GObject *object;
- object = g_object_new (GDM_TYPE_PRODUCT_SLAVE,
- "display-id", id,
- NULL);
+ object = g_object_new (GDM_TYPE_PRODUCT_SLAVE,
+ "display-id", id,
+ NULL);
- return GDM_SLAVE (object);
+ return GDM_SLAVE (object);
}
diff --git a/daemon/gdm-product-slave.h b/daemon/gdm-product-slave.h
index befb7c96..ce0d9489 100644
--- a/daemon/gdm-product-slave.h
+++ b/daemon/gdm-product-slave.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -38,16 +38,16 @@ typedef struct GdmProductSlavePrivate GdmProductSlavePrivate;
typedef struct
{
- GdmSlave parent;
- GdmProductSlavePrivate *priv;
+ GdmSlave parent;
+ GdmProductSlavePrivate *priv;
} GdmProductSlave;
typedef struct
{
- GdmSlaveClass parent_class;
+ GdmSlaveClass parent_class;
} GdmProductSlaveClass;
-GType gdm_product_slave_get_type (void);
+GType gdm_product_slave_get_type (void);
GdmSlave * gdm_product_slave_new (const char *id);
G_END_DECLS
diff --git a/daemon/gdm-server.c b/daemon/gdm-server.c
index 72a3053a..fd7f44a3 100644
--- a/daemon/gdm-server.c
+++ b/daemon/gdm-server.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -50,114 +50,114 @@ extern char **environ;
/* These are the servstat values, also used as server
* process exit codes */
-#define SERVER_TIMEOUT 2 /* Server didn't start */
-#define SERVER_DEAD 250 /* Server stopped */
-#define SERVER_PENDING 251 /* Server started but not ready for connections yet */
-#define SERVER_RUNNING 252 /* Server running and ready for connections */
-#define SERVER_ABORT 253 /* Server failed badly. Suspending display. */
+#define SERVER_TIMEOUT 2 /* Server didn't start */
+#define SERVER_DEAD 250 /* Server stopped */
+#define SERVER_PENDING 251 /* Server started but not ready for connections yet */
+#define SERVER_RUNNING 252 /* Server running and ready for connections */
+#define SERVER_ABORT 253 /* Server failed badly. Suspending display. */
struct GdmServerPrivate
{
- char *command;
- GPid pid;
+ char *command;
+ GPid pid;
- gboolean disable_tcp;
- int priority;
- char *user_name;
- char *session_args;
+ gboolean disable_tcp;
+ int priority;
+ char *user_name;
+ char *session_args;
- char *log_dir;
- char *display_name;
- char *auth_file;
+ char *log_dir;
+ char *display_name;
+ char *auth_file;
- gboolean is_parented;
- char *parent_display_name;
- char *parent_auth_file;
- char *chosen_hostname;
+ gboolean is_parented;
+ char *parent_display_name;
+ char *parent_auth_file;
+ char *chosen_hostname;
- guint child_watch_id;
+ guint child_watch_id;
};
enum {
- PROP_0,
- PROP_DISPLAY_NAME,
- PROP_AUTH_FILE,
- PROP_IS_PARENTED,
- PROP_PARENT_DISPLAY_NAME,
- PROP_PARENT_AUTH_FILE,
- PROP_CHOSEN_HOSTNAME,
- PROP_COMMAND,
- PROP_PRIORITY,
- PROP_USER_NAME,
- PROP_SESSION_ARGS,
- PROP_LOG_DIR,
- PROP_DISABLE_TCP,
+ PROP_0,
+ PROP_DISPLAY_NAME,
+ PROP_AUTH_FILE,
+ PROP_IS_PARENTED,
+ PROP_PARENT_DISPLAY_NAME,
+ PROP_PARENT_AUTH_FILE,
+ PROP_CHOSEN_HOSTNAME,
+ PROP_COMMAND,
+ PROP_PRIORITY,
+ PROP_USER_NAME,
+ PROP_SESSION_ARGS,
+ PROP_LOG_DIR,
+ PROP_DISABLE_TCP,
};
enum {
- READY,
- LAST_SIGNAL
+ READY,
+ LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0, };
-static void gdm_server_class_init (GdmServerClass *klass);
-static void gdm_server_init (GdmServer *server);
-static void gdm_server_finalize (GObject *object);
+static void gdm_server_class_init (GdmServerClass *klass);
+static void gdm_server_init (GdmServer *server);
+static void gdm_server_finalize (GObject *object);
G_DEFINE_TYPE (GdmServer, gdm_server, G_TYPE_OBJECT)
char *
gdm_server_get_display_device (GdmServer *server)
{
- char *out;
- char *command;
- int status;
- gboolean res;
- GError *error;
-
- g_return_val_if_fail (GDM_IS_SERVER (server), NULL);
-
- error = NULL;
- command = g_strdup_printf (LIBEXECDIR "/ck-get-x11-display-device --display %s",
- server->priv->display_name);
-
- g_debug ("Running helper %s", command);
- out = NULL;
- res = g_spawn_command_line_sync (command,
- &out,
- NULL,
- &status,
- &error);
- if (! res) {
- g_warning ("Could not run helper: %s", error->message);
- g_error_free (error);
- } else {
- out = g_strstrip (out);
- g_debug ("Got tty: '%s'", out);
- }
-
- g_free (command);
-
- return out;
+ char *out;
+ char *command;
+ int status;
+ gboolean res;
+ GError *error;
+
+ g_return_val_if_fail (GDM_IS_SERVER (server), NULL);
+
+ error = NULL;
+ command = g_strdup_printf (LIBEXECDIR "/ck-get-x11-display-device --display %s",
+ server->priv->display_name);
+
+ g_debug ("Running helper %s", command);
+ out = NULL;
+ res = g_spawn_command_line_sync (command,
+ &out,
+ NULL,
+ &status,
+ &error);
+ if (! res) {
+ g_warning ("Could not run helper: %s", error->message);
+ g_error_free (error);
+ } else {
+ out = g_strstrip (out);
+ g_debug ("Got tty: '%s'", out);
+ }
+
+ g_free (command);
+
+ return out;
}
static gboolean
emit_ready_idle (GdmServer *server)
{
- g_debug ("Got USR1 from X server - emitting READY");
+ g_debug ("Got USR1 from X server - emitting READY");
- g_signal_emit (server, signals[READY], 0);
- return FALSE;
+ g_signal_emit (server, signals[READY], 0);
+ return FALSE;
}
static gboolean
signal_cb (int signo,
- GdmServer *server)
+ GdmServer *server)
{
- g_idle_add ((GSourceFunc)emit_ready_idle, server);
+ g_idle_add ((GSourceFunc)emit_ready_idle, server);
return TRUE;
}
@@ -165,14 +165,14 @@ signal_cb (int signo,
static void
setup_ready_signal (GdmServer *server)
{
- GdmSignalHandler *signal_handler;
-
- signal_handler = gdm_signal_handler_new ();
- gdm_signal_handler_add (signal_handler,
- SIGUSR1,
- (GdmSignalHandlerFunc)signal_cb,
- server);
- g_object_unref (signal_handler);
+ GdmSignalHandler *signal_handler;
+
+ signal_handler = gdm_signal_handler_new ();
+ gdm_signal_handler_add (signal_handler,
+ SIGUSR1,
+ (GdmSignalHandlerFunc)signal_cb,
+ server);
+ g_object_unref (signal_handler);
}
/* We keep a connection (parent_dsp) open with the parent X server
@@ -186,104 +186,104 @@ setup_ready_signal (GdmServer *server)
static gboolean
connect_to_parent (GdmServer *server)
{
- int maxtries;
- int openretries;
+ int maxtries;
+ int openretries;
- g_debug ("gdm_server_start: Connecting to parent display \'%s\'",
- d->parent_disp);
+ g_debug ("gdm_server_start: Connecting to parent display \'%s\'",
+ d->parent_disp);
- d->parent_dsp = NULL;
+ d->parent_dsp = NULL;
- maxtries = SERVER_IS_XDMCP (d) ? 10 : 2;
+ maxtries = SERVER_IS_XDMCP (d) ? 10 : 2;
- openretries = 0;
- while (openretries < maxtries &&
- d->parent_dsp == NULL) {
- d->parent_dsp = XOpenDisplay (d->parent_disp);
+ openretries = 0;
+ while (openretries < maxtries &&
+ d->parent_dsp == NULL) {
+ d->parent_dsp = XOpenDisplay (d->parent_disp);
- if G_UNLIKELY (d->parent_dsp == NULL) {
- g_debug ("gdm_server_start: Sleeping %d on a retry", 1+openretries*2);
- gdm_sleep_no_signal (1+openretries*2);
- openretries++;
- }
- }
+ if G_UNLIKELY (d->parent_dsp == NULL) {
+ g_debug ("gdm_server_start: Sleeping %d on a retry", 1+openretries*2);
+ gdm_sleep_no_signal (1+openretries*2);
+ openretries++;
+ }
+ }
- if (d->parent_dsp == NULL)
- gdm_error (_("%s: failed to connect to parent display \'%s\'"),
- "gdm_server_start", d->parent_disp);
+ if (d->parent_dsp == NULL)
+ gdm_error (_("%s: failed to connect to parent display \'%s\'"),
+ "gdm_server_start", d->parent_disp);
- return d->parent_dsp != NULL;
+ return d->parent_dsp != NULL;
}
#endif
static gboolean
gdm_server_resolve_command_line (GdmServer *server,
- const char *vtarg,
- int *argcp,
- char ***argvp)
+ const char *vtarg,
+ int *argcp,
+ char ***argvp)
{
- int argc;
- char **argv;
- int len;
- int i;
- gboolean gotvtarg = FALSE;
- gboolean query_in_arglist = FALSE;
-
- g_shell_parse_argv (server->priv->command, &argc, &argv, NULL);
-
- for (len = 0; argv != NULL && argv[len] != NULL; len++) {
- char *arg = argv[len];
-
- /* HACK! Not to add vt argument to servers that already force
- * allocation. Mostly for backwards compat only */
- if (strncmp (arg, "vt", 2) == 0 &&
- isdigit (arg[2]) &&
- (arg[3] == '\0' ||
- (isdigit (arg[3]) && arg[4] == '\0')))
- gotvtarg = TRUE;
- if (strcmp (arg, "-query") == 0 ||
- strcmp (arg, "-indirect") == 0)
- query_in_arglist = TRUE;
- }
-
- argv = g_renew (char *, argv, len + 10);
- /* shift args down one */
- for (i = len - 1; i >= 1; i--) {
- argv[i+1] = argv[i];
- }
-
- /* server number is the FIRST argument, before any others */
- argv[1] = g_strdup (server->priv->display_name);
- len++;
-
- if (server->priv->auth_file != NULL) {
- argv[len++] = g_strdup ("-auth");
- argv[len++] = g_strdup (server->priv->auth_file);
- }
-
- if (server->priv->chosen_hostname) {
- /* run just one session */
- argv[len++] = g_strdup ("-terminate");
- argv[len++] = g_strdup ("-query");
- argv[len++] = g_strdup (server->priv->chosen_hostname);
- query_in_arglist = TRUE;
- }
-
- if (server->priv->disable_tcp && ! query_in_arglist) {
- argv[len++] = g_strdup ("-nolisten");
- argv[len++] = g_strdup ("tcp");
- }
-
- if (vtarg != NULL && ! gotvtarg) {
- argv[len++] = g_strdup (vtarg);
- }
-
- argv[len++] = NULL;
-
- *argvp = argv;
- *argcp = len;
-
- return TRUE;
+ int argc;
+ char **argv;
+ int len;
+ int i;
+ gboolean gotvtarg = FALSE;
+ gboolean query_in_arglist = FALSE;
+
+ g_shell_parse_argv (server->priv->command, &argc, &argv, NULL);
+
+ for (len = 0; argv != NULL && argv[len] != NULL; len++) {
+ char *arg = argv[len];
+
+ /* HACK! Not to add vt argument to servers that already force
+ * allocation. Mostly for backwards compat only */
+ if (strncmp (arg, "vt", 2) == 0 &&
+ isdigit (arg[2]) &&
+ (arg[3] == '\0' ||
+ (isdigit (arg[3]) && arg[4] == '\0')))
+ gotvtarg = TRUE;
+ if (strcmp (arg, "-query") == 0 ||
+ strcmp (arg, "-indirect") == 0)
+ query_in_arglist = TRUE;
+ }
+
+ argv = g_renew (char *, argv, len + 10);
+ /* shift args down one */
+ for (i = len - 1; i >= 1; i--) {
+ argv[i+1] = argv[i];
+ }
+
+ /* server number is the FIRST argument, before any others */
+ argv[1] = g_strdup (server->priv->display_name);
+ len++;
+
+ if (server->priv->auth_file != NULL) {
+ argv[len++] = g_strdup ("-auth");
+ argv[len++] = g_strdup (server->priv->auth_file);
+ }
+
+ if (server->priv->chosen_hostname) {
+ /* run just one session */
+ argv[len++] = g_strdup ("-terminate");
+ argv[len++] = g_strdup ("-query");
+ argv[len++] = g_strdup (server->priv->chosen_hostname);
+ query_in_arglist = TRUE;
+ }
+
+ if (server->priv->disable_tcp && ! query_in_arglist) {
+ argv[len++] = g_strdup ("-nolisten");
+ argv[len++] = g_strdup ("tcp");
+ }
+
+ if (vtarg != NULL && ! gotvtarg) {
+ argv[len++] = g_strdup (vtarg);
+ }
+
+ argv[len++] = NULL;
+
+ *argvp = argv;
+ *argcp = len;
+
+ return TRUE;
}
/* somewhat safer rename (safer if the log dir is unsafe), may in fact
@@ -292,353 +292,353 @@ gdm_server_resolve_command_line (GdmServer *server,
static void
safer_rename (const char *a, const char *b)
{
- errno = 0;
- if (link (a, b) < 0) {
- if (errno == EEXIST) {
- VE_IGNORE_EINTR (g_unlink (a));
- return;
- }
- VE_IGNORE_EINTR (g_unlink (b));
- /* likely this system doesn't support hard links */
- g_rename (a, b);
- VE_IGNORE_EINTR (g_unlink (a));
- return;
- }
- VE_IGNORE_EINTR (g_unlink (a));
+ errno = 0;
+ if (link (a, b) < 0) {
+ if (errno == EEXIST) {
+ VE_IGNORE_EINTR (g_unlink (a));
+ return;
+ }
+ VE_IGNORE_EINTR (g_unlink (b));
+ /* likely this system doesn't support hard links */
+ g_rename (a, b);
+ VE_IGNORE_EINTR (g_unlink (a));
+ return;
+ }
+ VE_IGNORE_EINTR (g_unlink (a));
}
static void
rotate_logs (GdmServer *server)
{
- const char *dname;
- const char *logdir;
-
- dname = server->priv->display_name;
- logdir = server->priv->log_dir;
-
- /* I'm too lazy to write a loop */
- char *fname4 = gdm_make_filename (logdir, dname, ".log.4");
- char *fname3 = gdm_make_filename (logdir, dname, ".log.3");
- char *fname2 = gdm_make_filename (logdir, dname, ".log.2");
- char *fname1 = gdm_make_filename (logdir, dname, ".log.1");
- char *fname = gdm_make_filename (logdir, dname, ".log");
-
- /* Rotate the logs (keep 4 last) */
- VE_IGNORE_EINTR (g_unlink (fname4));
- safer_rename (fname3, fname4);
- safer_rename (fname2, fname3);
- safer_rename (fname1, fname2);
- safer_rename (fname, fname1);
-
- g_free (fname4);
- g_free (fname3);
- g_free (fname2);
- g_free (fname1);
- g_free (fname);
+ const char *dname;
+ const char *logdir;
+
+ dname = server->priv->display_name;
+ logdir = server->priv->log_dir;
+
+ /* I'm too lazy to write a loop */
+ char *fname4 = gdm_make_filename (logdir, dname, ".log.4");
+ char *fname3 = gdm_make_filename (logdir, dname, ".log.3");
+ char *fname2 = gdm_make_filename (logdir, dname, ".log.2");
+ char *fname1 = gdm_make_filename (logdir, dname, ".log.1");
+ char *fname = gdm_make_filename (logdir, dname, ".log");
+
+ /* Rotate the logs (keep 4 last) */
+ VE_IGNORE_EINTR (g_unlink (fname4));
+ safer_rename (fname3, fname4);
+ safer_rename (fname2, fname3);
+ safer_rename (fname1, fname2);
+ safer_rename (fname, fname1);
+
+ g_free (fname4);
+ g_free (fname3);
+ g_free (fname2);
+ g_free (fname1);
+ g_free (fname);
}
static void
change_user (GdmServer *server)
{
- struct passwd *pwent;
-
- if (server->priv->user_name == NULL) {
- return;
- }
-
- pwent = getpwnam (server->priv->user_name);
- if (pwent == NULL) {
- g_warning (_("Server was to be spawned by user %s but that user doesn't exist"),
- server->priv->user_name);
- _exit (1);
- }
-
- g_debug ("Changing (uid:gid) for child process to (%d:%d)",
- pwent->pw_uid,
- pwent->pw_gid);
-
- if (pwent->pw_uid != 0) {
- if (setgid (pwent->pw_gid) < 0) {
- g_warning (_("Couldn't set groupid to %d"),
- pwent->pw_gid);
- _exit (1);
- }
-
- if (initgroups (pwent->pw_name, pwent->pw_gid) < 0) {
- g_warning (_("initgroups () failed for %s"),
- pwent->pw_name);
- _exit (1);
- }
-
- if (setuid (pwent->pw_uid) < 0) {
- g_warning (_("Couldn't set userid to %d"),
- (int)pwent->pw_uid);
- _exit (1);
- }
- } else {
- gid_t groups[1] = { 0 };
-
- if (setgid (0) < 0) {
- g_warning (_("Couldn't set groupid to 0"));
- /* Don't error out, it's not fatal, if it fails we'll
- * just still be */
- }
-
- /* this will get rid of any suplementary groups etc... */
- setgroups (1, groups);
- }
+ struct passwd *pwent;
+
+ if (server->priv->user_name == NULL) {
+ return;
+ }
+
+ pwent = getpwnam (server->priv->user_name);
+ if (pwent == NULL) {
+ g_warning (_("Server was to be spawned by user %s but that user doesn't exist"),
+ server->priv->user_name);
+ _exit (1);
+ }
+
+ g_debug ("Changing (uid:gid) for child process to (%d:%d)",
+ pwent->pw_uid,
+ pwent->pw_gid);
+
+ if (pwent->pw_uid != 0) {
+ if (setgid (pwent->pw_gid) < 0) {
+ g_warning (_("Couldn't set groupid to %d"),
+ pwent->pw_gid);
+ _exit (1);
+ }
+
+ if (initgroups (pwent->pw_name, pwent->pw_gid) < 0) {
+ g_warning (_("initgroups () failed for %s"),
+ pwent->pw_name);
+ _exit (1);
+ }
+
+ if (setuid (pwent->pw_uid) < 0) {
+ g_warning (_("Couldn't set userid to %d"),
+ (int)pwent->pw_uid);
+ _exit (1);
+ }
+ } else {
+ gid_t groups[1] = { 0 };
+
+ if (setgid (0) < 0) {
+ g_warning (_("Couldn't set groupid to 0"));
+ /* Don't error out, it's not fatal, if it fails we'll
+ * just still be */
+ }
+
+ /* this will get rid of any suplementary groups etc... */
+ setgroups (1, groups);
+ }
}
static void
server_child_setup (GdmServer *server)
{
- char *logfile;
- int logfd;
- struct sigaction ign_signal;
- sigset_t mask;
-
- /* Rotate the X server logs */
- rotate_logs (server);
-
- /* Log all output from spawned programs to a file */
- logfile = gdm_make_filename (server->priv->log_dir,
- server->priv->display_name,
- ".log");
- g_debug ("Opening logfile for server %s", logfile);
-
- VE_IGNORE_EINTR (g_unlink (logfile));
- VE_IGNORE_EINTR (logfd = open (logfile, O_CREAT|O_TRUNC|O_WRONLY|O_EXCL, 0644));
-
- if (logfd != -1) {
- VE_IGNORE_EINTR (dup2 (logfd, 1));
- VE_IGNORE_EINTR (dup2 (logfd, 2));
- close (logfd);
- } else {
- g_warning (_("%s: Could not open logfile for display %s!"),
- "gdm_server_spawn",
- server->priv->display_name);
- }
-
- /* The X server expects USR1/TTIN/TTOU to be SIG_IGN */
- ign_signal.sa_handler = SIG_IGN;
- ign_signal.sa_flags = SA_RESTART;
- sigemptyset (&ign_signal.sa_mask);
-
- if (sigaction (SIGUSR1, &ign_signal, NULL) < 0) {
- g_warning (_("%s: Error setting %s to %s"),
- "gdm_server_spawn", "USR1", "SIG_IGN");
- _exit (SERVER_ABORT);
- }
-
- if (sigaction (SIGTTIN, &ign_signal, NULL) < 0) {
- g_warning (_("%s: Error setting %s to %s"),
- "gdm_server_spawn", "TTIN", "SIG_IGN");
- _exit (SERVER_ABORT);
- }
-
- if (sigaction (SIGTTOU, &ign_signal, NULL) < 0) {
- g_warning (_("%s: Error setting %s to %s"),
- "gdm_server_spawn", "TTOU", "SIG_IGN");
- _exit (SERVER_ABORT);
- }
-
- /* And HUP and TERM are at SIG_DFL from gdm_unset_signals,
- we also have an empty mask and all that fun stuff */
-
- /* unblock signals (especially HUP/TERM/USR1) so that we
- * can control the X server */
- sigemptyset (&mask);
- sigprocmask (SIG_SETMASK, &mask, NULL);
-
- if (server->priv->priority != 0) {
- if (setpriority (PRIO_PROCESS, 0, server->priv->priority)) {
- g_warning (_("%s: Server priority couldn't be set to %d: %s"),
- "gdm_server_spawn",
- server->priv->priority,
- g_strerror (errno));
- }
- }
-
- setpgid (0, 0);
-
- change_user (server);
+ char *logfile;
+ int logfd;
+ struct sigaction ign_signal;
+ sigset_t mask;
+
+ /* Rotate the X server logs */
+ rotate_logs (server);
+
+ /* Log all output from spawned programs to a file */
+ logfile = gdm_make_filename (server->priv->log_dir,
+ server->priv->display_name,
+ ".log");
+ g_debug ("Opening logfile for server %s", logfile);
+
+ VE_IGNORE_EINTR (g_unlink (logfile));
+ VE_IGNORE_EINTR (logfd = open (logfile, O_CREAT|O_TRUNC|O_WRONLY|O_EXCL, 0644));
+
+ if (logfd != -1) {
+ VE_IGNORE_EINTR (dup2 (logfd, 1));
+ VE_IGNORE_EINTR (dup2 (logfd, 2));
+ close (logfd);
+ } else {
+ g_warning (_("%s: Could not open logfile for display %s!"),
+ "gdm_server_spawn",
+ server->priv->display_name);
+ }
+
+ /* The X server expects USR1/TTIN/TTOU to be SIG_IGN */
+ ign_signal.sa_handler = SIG_IGN;
+ ign_signal.sa_flags = SA_RESTART;
+ sigemptyset (&ign_signal.sa_mask);
+
+ if (sigaction (SIGUSR1, &ign_signal, NULL) < 0) {
+ g_warning (_("%s: Error setting %s to %s"),
+ "gdm_server_spawn", "USR1", "SIG_IGN");
+ _exit (SERVER_ABORT);
+ }
+
+ if (sigaction (SIGTTIN, &ign_signal, NULL) < 0) {
+ g_warning (_("%s: Error setting %s to %s"),
+ "gdm_server_spawn", "TTIN", "SIG_IGN");
+ _exit (SERVER_ABORT);
+ }
+
+ if (sigaction (SIGTTOU, &ign_signal, NULL) < 0) {
+ g_warning (_("%s: Error setting %s to %s"),
+ "gdm_server_spawn", "TTOU", "SIG_IGN");
+ _exit (SERVER_ABORT);
+ }
+
+ /* And HUP and TERM are at SIG_DFL from gdm_unset_signals,
+ we also have an empty mask and all that fun stuff */
+
+ /* unblock signals (especially HUP/TERM/USR1) so that we
+ * can control the X server */
+ sigemptyset (&mask);
+ sigprocmask (SIG_SETMASK, &mask, NULL);
+
+ if (server->priv->priority != 0) {
+ if (setpriority (PRIO_PROCESS, 0, server->priv->priority)) {
+ g_warning (_("%s: Server priority couldn't be set to %d: %s"),
+ "gdm_server_spawn",
+ server->priv->priority,
+ g_strerror (errno));
+ }
+ }
+
+ setpgid (0, 0);
+
+ change_user (server);
}
static void
listify_hash (const char *key,
- const char *value,
- GPtrArray *env)
+ const char *value,
+ GPtrArray *env)
{
- char *str;
- str = g_strdup_printf ("%s=%s", key, value);
- g_ptr_array_add (env, str);
+ char *str;
+ str = g_strdup_printf ("%s=%s", key, value);
+ g_ptr_array_add (env, str);
}
static GPtrArray *
get_server_environment (GdmServer *server)
{
- GPtrArray *env;
- char **l;
- GHashTable *hash;
-
- env = g_ptr_array_new ();
-
- /* create a hash table of current environment, then update keys has necessary */
- hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- for (l = environ; *l != NULL; l++) {
- char **str;
- str = g_strsplit (*l, "=", 2);
- g_hash_table_insert (hash, str[0], str[1]);
- }
-
- /* modify environment here */
- if (server->priv->is_parented) {
- if (server->priv->parent_auth_file != NULL) {
- g_hash_table_insert (hash, g_strdup ("XAUTHORITY"), g_strdup (server->priv->parent_auth_file));
- }
-
- if (server->priv->parent_display_name != NULL) {
- g_hash_table_insert (hash, g_strdup ("DISPLAY"), g_strdup (server->priv->parent_display_name));
- }
- } else {
- g_hash_table_insert (hash, g_strdup ("DISPLAY="), g_strdup (server->priv->display_name));
- }
-
- if (server->priv->user_name != NULL) {
- struct passwd *pwent;
-
- pwent = getpwnam (server->priv->user_name);
-
- if (pwent->pw_dir != NULL
- && g_file_test (pwent->pw_dir, G_FILE_TEST_EXISTS)) {
- g_hash_table_insert (hash, g_strdup ("HOME"), g_strdup (pwent->pw_dir));
- } else {
- /* Hack */
- g_hash_table_insert (hash, g_strdup ("HOME"), g_strdup ("/"));
- }
- g_hash_table_insert (hash, g_strdup ("SHELL"), g_strdup (pwent->pw_shell));
- g_hash_table_remove (hash, "MAIL");
- }
-
- g_hash_table_foreach (hash, (GHFunc)listify_hash, env);
- g_hash_table_destroy (hash);
-
- g_ptr_array_add (env, NULL);
-
- return env;
+ GPtrArray *env;
+ char **l;
+ GHashTable *hash;
+
+ env = g_ptr_array_new ();
+
+ /* create a hash table of current environment, then update keys has necessary */
+ hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+ for (l = environ; *l != NULL; l++) {
+ char **str;
+ str = g_strsplit (*l, "=", 2);
+ g_hash_table_insert (hash, str[0], str[1]);
+ }
+
+ /* modify environment here */
+ if (server->priv->is_parented) {
+ if (server->priv->parent_auth_file != NULL) {
+ g_hash_table_insert (hash, g_strdup ("XAUTHORITY"), g_strdup (server->priv->parent_auth_file));
+ }
+
+ if (server->priv->parent_display_name != NULL) {
+ g_hash_table_insert (hash, g_strdup ("DISPLAY"), g_strdup (server->priv->parent_display_name));
+ }
+ } else {
+ g_hash_table_insert (hash, g_strdup ("DISPLAY="), g_strdup (server->priv->display_name));
+ }
+
+ if (server->priv->user_name != NULL) {
+ struct passwd *pwent;
+
+ pwent = getpwnam (server->priv->user_name);
+
+ if (pwent->pw_dir != NULL
+ && g_file_test (pwent->pw_dir, G_FILE_TEST_EXISTS)) {
+ g_hash_table_insert (hash, g_strdup ("HOME"), g_strdup (pwent->pw_dir));
+ } else {
+ /* Hack */
+ g_hash_table_insert (hash, g_strdup ("HOME"), g_strdup ("/"));
+ }
+ g_hash_table_insert (hash, g_strdup ("SHELL"), g_strdup (pwent->pw_shell));
+ g_hash_table_remove (hash, "MAIL");
+ }
+
+ g_hash_table_foreach (hash, (GHFunc)listify_hash, env);
+ g_hash_table_destroy (hash);
+
+ g_ptr_array_add (env, NULL);
+
+ return env;
}
static void
server_add_xserver_args (GdmServer *server,
- int *argc,
- char ***argv)
+ int *argc,
+ char ***argv)
{
- int count;
- char **args;
- int len;
- int i;
+ int count;
+ char **args;
+ int len;
+ int i;
- len = *argc;
- g_shell_parse_argv (server->priv->session_args, &count, &args, NULL);
- *argv = g_renew (char *, *argv, len + count + 1);
+ len = *argc;
+ g_shell_parse_argv (server->priv->session_args, &count, &args, NULL);
+ *argv = g_renew (char *, *argv, len + count + 1);
- for (i=0; i < count;i++) {
- *argv[len++] = g_strdup (args[i]);
- }
+ for (i=0; i < count;i++) {
+ *argv[len++] = g_strdup (args[i]);
+ }
- *argc += count;
+ *argc += count;
- argv[len] = NULL;
- g_strfreev (args);
+ argv[len] = NULL;
+ g_strfreev (args);
}
static void
server_child_watch (GPid pid,
- int status,
- GdmServer *server)
+ int status,
+ GdmServer *server)
{
- g_debug ("child (pid:%d) done (%s:%d)",
- (int) pid,
- WIFEXITED (status) ? "status"
- : WIFSIGNALED (status) ? "signal"
- : "unknown",
- WIFEXITED (status) ? WEXITSTATUS (status)
- : WIFSIGNALED (status) ? WTERMSIG (status)
- : -1);
-
- g_spawn_close_pid (server->priv->pid);
- server->priv->pid = -1;
+ g_debug ("child (pid:%d) done (%s:%d)",
+ (int) pid,
+ WIFEXITED (status) ? "status"
+ : WIFSIGNALED (status) ? "signal"
+ : "unknown",
+ WIFEXITED (status) ? WEXITSTATUS (status)
+ : WIFSIGNALED (status) ? WTERMSIG (status)
+ : -1);
+
+ g_spawn_close_pid (server->priv->pid);
+ server->priv->pid = -1;
}
static gboolean
gdm_server_spawn (GdmServer *server,
- const char *vtarg)
+ const char *vtarg)
{
- int argc;
- gchar **argv = NULL;
- GError *error;
- GPtrArray *env;
- gboolean ret;
- char *freeme;
-
- ret = FALSE;
-
- /* Figure out the server command */
- argv = NULL;
- argc = 0;
- gdm_server_resolve_command_line (server,
- vtarg,
- &argc,
- &argv);
-
- if (server->priv->session_args) {
- server_add_xserver_args (server, &argc, &argv);
- }
-
- if (argv[0] == NULL) {
- g_warning (_("%s: Empty server command for display %s"),
- "gdm_server_spawn",
- server->priv->display_name);
- _exit (SERVER_ABORT);
- }
-
- env = get_server_environment (server);
-
- freeme = g_strjoinv (" ", argv);
- g_debug ("Starting X server process: %s", freeme);
- g_free (freeme);
-
- error = NULL;
- ret = g_spawn_async_with_pipes (NULL,
- argv,
- (char **)env->pdata,
- G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
- (GSpawnChildSetupFunc)server_child_setup,
- server,
- &server->priv->pid,
- NULL,
- NULL,
- NULL,
- &error);
-
- if (! ret) {
- g_warning ("Could not start command '%s': %s",
- server->priv->command,
- error->message);
- g_error_free (error);
- }
-
- g_strfreev (argv);
- g_ptr_array_foreach (env, (GFunc)g_free, NULL);
+ int argc;
+ gchar **argv = NULL;
+ GError *error;
+ GPtrArray *env;
+ gboolean ret;
+ char *freeme;
+
+ ret = FALSE;
+
+ /* Figure out the server command */
+ argv = NULL;
+ argc = 0;
+ gdm_server_resolve_command_line (server,
+ vtarg,
+ &argc,
+ &argv);
+
+ if (server->priv->session_args) {
+ server_add_xserver_args (server, &argc, &argv);
+ }
+
+ if (argv[0] == NULL) {
+ g_warning (_("%s: Empty server command for display %s"),
+ "gdm_server_spawn",
+ server->priv->display_name);
+ _exit (SERVER_ABORT);
+ }
+
+ env = get_server_environment (server);
+
+ freeme = g_strjoinv (" ", argv);
+ g_debug ("Starting X server process: %s", freeme);
+ g_free (freeme);
+
+ error = NULL;
+ ret = g_spawn_async_with_pipes (NULL,
+ argv,
+ (char **)env->pdata,
+ G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
+ (GSpawnChildSetupFunc)server_child_setup,
+ server,
+ &server->priv->pid,
+ NULL,
+ NULL,
+ NULL,
+ &error);
+
+ if (! ret) {
+ g_warning ("Could not start command '%s': %s",
+ server->priv->command,
+ error->message);
+ g_error_free (error);
+ }
+
+ g_strfreev (argv);
+ g_ptr_array_foreach (env, (GFunc)g_free, NULL);
g_ptr_array_free (env, TRUE);
- g_debug ("Started X server process: %d", (int)server->priv->pid);
+ g_debug ("Started X server process: %d", (int)server->priv->pid);
- server->priv->child_watch_id = g_child_watch_add (server->priv->pid,
- (GChildWatchFunc)server_child_watch,
- server);
+ server->priv->child_watch_id = g_child_watch_add (server->priv->pid,
+ (GChildWatchFunc)server_child_watch,
+ server);
- return ret;
+ return ret;
}
/**
@@ -651,128 +651,128 @@ gdm_server_spawn (GdmServer *server,
gboolean
gdm_server_start (GdmServer *server)
{
- char *vtarg = NULL;
- int vtfd = -1;
- int vt = -1;
- gboolean res;
+ char *vtarg = NULL;
+ int vtfd = -1;
+ int vt = -1;
+ gboolean res;
#if 0
- if (d->type == TYPE_XDMCP_PROXY &&
- ! connect_to_parent (d))
- return FALSE;
+ if (d->type == TYPE_XDMCP_PROXY &&
+ ! connect_to_parent (d))
+ return FALSE;
#endif
#if 0
- if (d->type == TYPE_STATIC ||
- d->type == TYPE_FLEXI) {
- vtarg = gdm_get_empty_vt_argument (&vtfd, &vt);
- }
+ if (d->type == TYPE_STATIC ||
+ d->type == TYPE_FLEXI) {
+ vtarg = gdm_get_empty_vt_argument (&vtfd, &vt);
+ }
#endif
- /* fork X server process */
- res = gdm_server_spawn (server, vtarg);
+ /* fork X server process */
+ res = gdm_server_spawn (server, vtarg);
#if 0
- /* If we were holding a vt open for the server, close it now as it has
- * already taken the bait. */
- if (vtfd > 0) {
- VE_IGNORE_EINTR (close (vtfd));
- }
+ /* If we were holding a vt open for the server, close it now as it has
+ * already taken the bait. */
+ if (vtfd > 0) {
+ VE_IGNORE_EINTR (close (vtfd));
+ }
#endif
- return res;
+ return res;
}
static int
signal_pid (int pid,
- int signal)
+ int signal)
{
- int status = -1;
+ int status = -1;
- /* perhaps block sigchld */
+ /* perhaps block sigchld */
- status = kill (pid, signal);
+ status = kill (pid, signal);
- if (status < 0) {
- if (errno == ESRCH) {
- g_warning ("Child process %lu was already dead.",
- (unsigned long) pid);
- } else {
- g_warning ("Couldn't kill child process %lu: %s",
- (unsigned long) pid,
- g_strerror (errno));
- }
- }
+ if (status < 0) {
+ if (errno == ESRCH) {
+ g_warning ("Child process %lu was already dead.",
+ (unsigned long) pid);
+ } else {
+ g_warning ("Couldn't kill child process %lu: %s",
+ (unsigned long) pid,
+ g_strerror (errno));
+ }
+ }
- /* perhaps unblock sigchld */
+ /* perhaps unblock sigchld */
- return status;
+ return status;
}
static int
wait_on_child (int pid)
{
- int status;
+ int status;
wait_again:
- if (waitpid (pid, &status, 0) < 0) {
- if (errno == EINTR) {
- goto wait_again;
- } else if (errno == ECHILD) {
- ; /* do nothing, child already reaped */
- } else {
- g_debug ("waitpid () should not fail");
- }
- }
-
- return status;
+ if (waitpid (pid, &status, 0) < 0) {
+ if (errno == EINTR) {
+ goto wait_again;
+ } else if (errno == ECHILD) {
+ ; /* do nothing, child already reaped */
+ } else {
+ g_debug ("waitpid () should not fail");
+ }
+ }
+
+ return status;
}
static void
server_died (GdmServer *server)
{
- int exit_status;
+ int exit_status;
- g_debug ("Waiting on process %d", server->priv->pid);
- exit_status = wait_on_child (server->priv->pid);
+ g_debug ("Waiting on process %d", server->priv->pid);
+ exit_status = wait_on_child (server->priv->pid);
- if (WIFEXITED (exit_status) && (WEXITSTATUS (exit_status) != 0)) {
- g_debug ("Wait on child process failed");
- } else {
- /* exited normally */
- }
+ if (WIFEXITED (exit_status) && (WEXITSTATUS (exit_status) != 0)) {
+ g_debug ("Wait on child process failed");
+ } else {
+ /* exited normally */
+ }
- g_spawn_close_pid (server->priv->pid);
- server->priv->pid = -1;
+ g_spawn_close_pid (server->priv->pid);
+ server->priv->pid = -1;
- g_debug ("Server died");
+ g_debug ("Server died");
}
gboolean
gdm_server_stop (GdmServer *server)
{
- if (server->priv->pid <= 1) {
- return TRUE;
- }
+ if (server->priv->pid <= 1) {
+ return TRUE;
+ }
- /* remove watch source before we can wait on child */
- if (server->priv->child_watch_id > 0) {
- g_source_remove (server->priv->child_watch_id);
- server->priv->child_watch_id = 0;
- }
+ /* remove watch source before we can wait on child */
+ if (server->priv->child_watch_id > 0) {
+ g_source_remove (server->priv->child_watch_id);
+ server->priv->child_watch_id = 0;
+ }
- g_debug ("Stopping server");
+ g_debug ("Stopping server");
- signal_pid (server->priv->pid, SIGTERM);
- server_died (server);
+ signal_pid (server->priv->pid, SIGTERM);
+ server_died (server);
- return TRUE;
+ return TRUE;
}
static void
_gdm_server_set_display_name (GdmServer *server,
- const char *name)
+ const char *name)
{
g_free (server->priv->display_name);
server->priv->display_name = g_strdup (name);
@@ -780,7 +780,7 @@ _gdm_server_set_display_name (GdmServer *server,
static void
_gdm_server_set_user_name (GdmServer *server,
- const char *name)
+ const char *name)
{
g_free (server->priv->user_name);
server->priv->user_name = g_strdup (name);
@@ -788,54 +788,54 @@ _gdm_server_set_user_name (GdmServer *server,
static void
gdm_server_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GdmServer *self;
-
- self = GDM_SERVER (object);
-
- switch (prop_id) {
- case PROP_DISPLAY_NAME:
- _gdm_server_set_display_name (self, g_value_get_string (value));
- break;
- case PROP_USER_NAME:
- _gdm_server_set_user_name (self, g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GdmServer *self;
+
+ self = GDM_SERVER (object);
+
+ switch (prop_id) {
+ case PROP_DISPLAY_NAME:
+ _gdm_server_set_display_name (self, g_value_get_string (value));
+ break;
+ case PROP_USER_NAME:
+ _gdm_server_set_user_name (self, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_server_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GdmServer *self;
-
- self = GDM_SERVER (object);
-
- switch (prop_id) {
- case PROP_DISPLAY_NAME:
- g_value_set_string (value, self->priv->display_name);
- break;
- case PROP_USER_NAME:
- g_value_set_string (value, self->priv->user_name);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GdmServer *self;
+
+ self = GDM_SERVER (object);
+
+ switch (prop_id) {
+ case PROP_DISPLAY_NAME:
+ g_value_set_string (value, self->priv->display_name);
+ break;
+ case PROP_USER_NAME:
+ g_value_set_string (value, self->priv->user_name);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static GObject *
gdm_server_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
{
GdmServer *server;
GdmServerClass *klass;
@@ -843,48 +843,48 @@ gdm_server_constructor (GType type,
klass = GDM_SERVER_CLASS (g_type_class_peek (GDM_TYPE_SERVER));
server = GDM_SERVER (G_OBJECT_CLASS (gdm_server_parent_class)->constructor (type,
- n_construct_properties,
- construct_properties));
+ n_construct_properties,
+ construct_properties));
return G_OBJECT (server);
}
static void
gdm_server_class_init (GdmServerClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->get_property = gdm_server_get_property;
- object_class->set_property = gdm_server_set_property;
+ object_class->get_property = gdm_server_get_property;
+ object_class->set_property = gdm_server_set_property;
object_class->constructor = gdm_server_constructor;
- object_class->finalize = gdm_server_finalize;
-
- g_type_class_add_private (klass, sizeof (GdmServerPrivate));
-
- signals [READY] =
- g_signal_new ("ready",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdmServerClass, ready),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- g_object_class_install_property (object_class,
- PROP_DISPLAY_NAME,
- g_param_spec_string ("display-name",
- "name",
- "name",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_USER_NAME,
- g_param_spec_string ("user-name",
- "user name",
- "user name",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ object_class->finalize = gdm_server_finalize;
+
+ g_type_class_add_private (klass, sizeof (GdmServerPrivate));
+
+ signals [READY] =
+ g_signal_new ("ready",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdmServerClass, ready),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
+ g_object_class_install_property (object_class,
+ PROP_DISPLAY_NAME,
+ g_param_spec_string ("display-name",
+ "name",
+ "name",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_USER_NAME,
+ g_param_spec_string ("user-name",
+ "user name",
+ "user name",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
}
@@ -892,40 +892,40 @@ static void
gdm_server_init (GdmServer *server)
{
- server->priv = GDM_SERVER_GET_PRIVATE (server);
+ server->priv = GDM_SERVER_GET_PRIVATE (server);
- server->priv->pid = -1;
- server->priv->command = g_strdup ("/usr/bin/Xorg -br -verbose");
- server->priv->log_dir = g_strdup (LOGDIR);
+ server->priv->pid = -1;
+ server->priv->command = g_strdup ("/usr/bin/Xorg -br -verbose");
+ server->priv->log_dir = g_strdup (LOGDIR);
- setup_ready_signal (server);
+ setup_ready_signal (server);
}
static void
gdm_server_finalize (GObject *object)
{
- GdmServer *server;
+ GdmServer *server;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_SERVER (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_SERVER (object));
- server = GDM_SERVER (object);
+ server = GDM_SERVER (object);
- g_return_if_fail (server->priv != NULL);
+ g_return_if_fail (server->priv != NULL);
- gdm_server_stop (server);
+ gdm_server_stop (server);
- G_OBJECT_CLASS (gdm_server_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_server_parent_class)->finalize (object);
}
GdmServer *
gdm_server_new (const char *display_name)
{
- GObject *object;
+ GObject *object;
- object = g_object_new (GDM_TYPE_SERVER,
- "display-name", display_name,
- NULL);
+ object = g_object_new (GDM_TYPE_SERVER,
+ "display-name", display_name,
+ NULL);
- return GDM_SERVER (object);
+ return GDM_SERVER (object);
}
diff --git a/daemon/gdm-server.h b/daemon/gdm-server.h
index 365dac79..14a3043b 100644
--- a/daemon/gdm-server.h
+++ b/daemon/gdm-server.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -37,19 +37,19 @@ typedef struct GdmServerPrivate GdmServerPrivate;
typedef struct
{
- GObject parent;
- GdmServerPrivate *priv;
+ GObject parent;
+ GdmServerPrivate *priv;
} GdmServer;
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
- void (* ready) (GdmServer *server);
+ void (* ready) (GdmServer *server);
} GdmServerClass;
-GType gdm_server_get_type (void);
-GdmServer * gdm_server_new (const char *display_id);
+GType gdm_server_get_type (void);
+GdmServer * gdm_server_new (const char *display_id);
gboolean gdm_server_start (GdmServer *server);
gboolean gdm_server_stop (GdmServer *server);
char * gdm_server_get_display_device (GdmServer *server);
diff --git a/daemon/gdm-session-relay.c b/daemon/gdm-session-relay.c
index 53447e5e..ec27dc84 100644
--- a/daemon/gdm-session-relay.c
+++ b/daemon/gdm-session-relay.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -52,102 +52,102 @@
struct GdmSessionRelayPrivate
{
- DBusServer *server;
- char *server_address;
- DBusConnection *session_connection;
+ DBusServer *server;
+ char *server_address;
+ DBusConnection *session_connection;
};
enum {
- PROP_0,
+ PROP_0,
};
enum {
- INFO_QUERY,
- SECRET_INFO_QUERY,
- INFO,
- PROBLEM,
- SESSION_STARTED,
- SESSION_STOPPED,
- READY,
- CONNECTED,
- DISCONNECTED,
- LAST_SIGNAL
+ INFO_QUERY,
+ SECRET_INFO_QUERY,
+ INFO,
+ PROBLEM,
+ SESSION_STARTED,
+ SESSION_STOPPED,
+ READY,
+ CONNECTED,
+ DISCONNECTED,
+ LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0, };
-static void gdm_session_relay_class_init (GdmSessionRelayClass *klass);
-static void gdm_session_relay_init (GdmSessionRelay *session_relay);
-static void gdm_session_relay_finalize (GObject *object);
+static void gdm_session_relay_class_init (GdmSessionRelayClass *klass);
+static void gdm_session_relay_init (GdmSessionRelay *session_relay);
+static void gdm_session_relay_finalize (GObject *object);
G_DEFINE_TYPE (GdmSessionRelay, gdm_session_relay, G_TYPE_OBJECT)
static gboolean
send_dbus_message (DBusConnection *connection,
- DBusMessage *message)
+ DBusMessage *message)
{
- gboolean is_connected;
- gboolean sent;
+ gboolean is_connected;
+ gboolean sent;
- g_return_val_if_fail (message != NULL, FALSE);
+ g_return_val_if_fail (message != NULL, FALSE);
- if (connection == NULL) {
- g_debug ("There is no valid connection");
- return FALSE;
- }
+ if (connection == NULL) {
+ g_debug ("There is no valid connection");
+ return FALSE;
+ }
- is_connected = dbus_connection_get_is_connected (connection);
- if (! is_connected) {
- g_warning ("Not connected!");
- return FALSE;
- }
+ is_connected = dbus_connection_get_is_connected (connection);
+ if (! is_connected) {
+ g_warning ("Not connected!");
+ return FALSE;
+ }
- sent = dbus_connection_send (connection, message, NULL);
+ sent = dbus_connection_send (connection, message, NULL);
- return sent;
+ return sent;
}
static void
send_dbus_string_signal (GdmSessionRelay *session_relay,
- const char *name,
- const char *text)
+ const char *name,
+ const char *text)
{
- DBusMessage *message;
- DBusMessageIter iter;
+ DBusMessage *message;
+ DBusMessageIter iter;
- g_return_if_fail (session_relay != NULL);
+ g_return_if_fail (session_relay != NULL);
- message = dbus_message_new_signal (GDM_SESSION_RELAY_DBUS_PATH,
- GDM_SESSION_RELAY_DBUS_INTERFACE,
- name);
+ message = dbus_message_new_signal (GDM_SESSION_RELAY_DBUS_PATH,
+ GDM_SESSION_RELAY_DBUS_INTERFACE,
+ name);
- dbus_message_iter_init_append (message, &iter);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &text);
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &text);
- if (! send_dbus_message (session_relay->priv->session_connection, message)) {
- g_debug ("Could not send %s signal", name);
- }
+ if (! send_dbus_message (session_relay->priv->session_connection, message)) {
+ g_debug ("Could not send %s signal", name);
+ }
- dbus_message_unref (message);
+ dbus_message_unref (message);
}
static void
send_dbus_void_signal (GdmSessionRelay *session_relay,
- const char *name)
+ const char *name)
{
- DBusMessage *message;
+ DBusMessage *message;
- g_return_if_fail (session_relay != NULL);
+ g_return_if_fail (session_relay != NULL);
- message = dbus_message_new_signal (GDM_SESSION_RELAY_DBUS_PATH,
- GDM_SESSION_RELAY_DBUS_INTERFACE,
- name);
+ message = dbus_message_new_signal (GDM_SESSION_RELAY_DBUS_PATH,
+ GDM_SESSION_RELAY_DBUS_INTERFACE,
+ name);
- if (! send_dbus_message (session_relay->priv->session_connection, message)) {
- g_debug ("Could not send %s signal", name);
- }
+ if (! send_dbus_message (session_relay->priv->session_connection, message)) {
+ g_debug ("Could not send %s signal", name);
+ }
- dbus_message_unref (message);
+ dbus_message_unref (message);
}
void
@@ -158,29 +158,29 @@ gdm_session_relay_open (GdmSessionRelay *session_relay)
void
gdm_session_relay_answer_query (GdmSessionRelay *session_relay,
- const char *text)
+ const char *text)
{
- g_debug ("Sending signal AnswerQuery");
+ g_debug ("Sending signal AnswerQuery");
send_dbus_string_signal (session_relay, "AnswerQuery", text);
}
void
gdm_session_relay_select_session (GdmSessionRelay *session_relay,
- const char *text)
+ const char *text)
{
send_dbus_string_signal (session_relay, "SessionSelected", text);
}
void
gdm_session_relay_select_language (GdmSessionRelay *session_relay,
- const char *text)
+ const char *text)
{
send_dbus_string_signal (session_relay, "LanguageSelected", text);
}
void
gdm_session_relay_select_user (GdmSessionRelay *session_relay,
- const char *text)
+ const char *text)
{
send_dbus_string_signal (session_relay, "UserSelected", text);
}
@@ -197,347 +197,347 @@ gdm_session_relay_cancel (GdmSessionRelay *session_relay)
static char *
generate_address (void)
{
- char *path;
+ char *path;
#if defined (__linux__)
- int i;
- char tmp[9];
-
- for (i = 0; i < 8; i++) {
- if (g_random_int_range (0, 2) == 0) {
- tmp[i] = g_random_int_range ('a', 'z' + 1);
- } else {
- tmp[i] = g_random_int_range ('A', 'Z' + 1);
- }
- }
- tmp[8] = '\0';
-
- path = g_strdup_printf ("unix:abstract=/tmp/gdm-session-%s", tmp);
+ int i;
+ char tmp[9];
+
+ for (i = 0; i < 8; i++) {
+ if (g_random_int_range (0, 2) == 0) {
+ tmp[i] = g_random_int_range ('a', 'z' + 1);
+ } else {
+ tmp[i] = g_random_int_range ('A', 'Z' + 1);
+ }
+ }
+ tmp[8] = '\0';
+
+ path = g_strdup_printf ("unix:abstract=/tmp/gdm-session-%s", tmp);
#else
- path = g_strdup ("unix:tmpdir=/tmp/gdm-session");
+ path = g_strdup ("unix:tmpdir=/tmp/gdm-session");
#endif
- return path;
+ return path;
}
static DBusHandlerResult
handle_info_query (GdmSessionRelay *session_relay,
- DBusConnection *connection,
- DBusMessage *message)
-{
- DBusMessage *reply;
- DBusError error;
- const char *text;
-
- dbus_error_init (&error);
- if (! dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &text,
- DBUS_TYPE_INVALID)) {
- g_warning ("ERROR: %s", error.message);
- }
+ DBusConnection *connection,
+ DBusMessage *message)
+{
+ DBusMessage *reply;
+ DBusError error;
+ const char *text;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &text,
+ DBUS_TYPE_INVALID)) {
+ g_warning ("ERROR: %s", error.message);
+ }
- g_debug ("InfoQuery: %s", text);
+ g_debug ("InfoQuery: %s", text);
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
- g_signal_emit (session_relay, signals [INFO_QUERY], 0, text);
+ g_signal_emit (session_relay, signals [INFO_QUERY], 0, text);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
handle_secret_info_query (GdmSessionRelay *session_relay,
- DBusConnection *connection,
- DBusMessage *message)
-{
- DBusMessage *reply;
- DBusError error;
- const char *text;
-
- dbus_error_init (&error);
- if (! dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &text,
- DBUS_TYPE_INVALID)) {
- g_warning ("ERROR: %s", error.message);
- }
+ DBusConnection *connection,
+ DBusMessage *message)
+{
+ DBusMessage *reply;
+ DBusError error;
+ const char *text;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &text,
+ DBUS_TYPE_INVALID)) {
+ g_warning ("ERROR: %s", error.message);
+ }
- g_debug ("SecretInfoQuery: %s", text);
+ g_debug ("SecretInfoQuery: %s", text);
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
- g_signal_emit (session_relay, signals [SECRET_INFO_QUERY], 0, text);
+ g_signal_emit (session_relay, signals [SECRET_INFO_QUERY], 0, text);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
handle_info (GdmSessionRelay *session_relay,
- DBusConnection *connection,
- DBusMessage *message)
-{
- DBusMessage *reply;
- DBusError error;
- const char *text;
-
- dbus_error_init (&error);
- if (! dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &text,
- DBUS_TYPE_INVALID)) {
- g_warning ("ERROR: %s", error.message);
- }
+ DBusConnection *connection,
+ DBusMessage *message)
+{
+ DBusMessage *reply;
+ DBusError error;
+ const char *text;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &text,
+ DBUS_TYPE_INVALID)) {
+ g_warning ("ERROR: %s", error.message);
+ }
- g_debug ("Info: %s", text);
+ g_debug ("Info: %s", text);
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
- g_signal_emit (session_relay, signals [INFO], 0, text);
+ g_signal_emit (session_relay, signals [INFO], 0, text);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
handle_problem (GdmSessionRelay *session_relay,
- DBusConnection *connection,
- DBusMessage *message)
-{
- DBusMessage *reply;
- DBusError error;
- const char *text;
-
- dbus_error_init (&error);
- if (! dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &text,
- DBUS_TYPE_INVALID)) {
- g_warning ("ERROR: %s", error.message);
- }
+ DBusConnection *connection,
+ DBusMessage *message)
+{
+ DBusMessage *reply;
+ DBusError error;
+ const char *text;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &text,
+ DBUS_TYPE_INVALID)) {
+ g_warning ("ERROR: %s", error.message);
+ }
- g_debug ("Problem: %s", text);
+ g_debug ("Problem: %s", text);
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
- g_signal_emit (session_relay, signals [PROBLEM], 0, text);
+ g_signal_emit (session_relay, signals [PROBLEM], 0, text);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
handle_session_started (GdmSessionRelay *session_relay,
- DBusConnection *connection,
- DBusMessage *message)
+ DBusConnection *connection,
+ DBusMessage *message)
{
- DBusMessage *reply;
- DBusError error;
+ DBusMessage *reply;
+ DBusError error;
- dbus_error_init (&error);
+ dbus_error_init (&error);
- g_debug ("SessionStarted");
+ g_debug ("SessionStarted");
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
- g_signal_emit (session_relay, signals [SESSION_STARTED], 0);
+ g_signal_emit (session_relay, signals [SESSION_STARTED], 0);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
handle_session_stopped (GdmSessionRelay *session_relay,
- DBusConnection *connection,
- DBusMessage *message)
+ DBusConnection *connection,
+ DBusMessage *message)
{
- DBusMessage *reply;
- DBusError error;
+ DBusMessage *reply;
+ DBusError error;
- dbus_error_init (&error);
+ dbus_error_init (&error);
- g_debug ("SessionStopped");
+ g_debug ("SessionStopped");
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
- g_signal_emit (session_relay, signals [SESSION_STOPPED], 0);
+ g_signal_emit (session_relay, signals [SESSION_STOPPED], 0);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
handle_ready (GdmSessionRelay *session_relay,
- DBusConnection *connection,
- DBusMessage *message)
+ DBusConnection *connection,
+ DBusMessage *message)
{
- DBusMessage *reply;
- DBusError error;
+ DBusMessage *reply;
+ DBusError error;
- dbus_error_init (&error);
+ dbus_error_init (&error);
- g_debug ("Ready");
+ g_debug ("Ready");
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
- g_signal_emit (session_relay, signals [READY], 0);
+ g_signal_emit (session_relay, signals [READY], 0);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
handle_reset (GdmSessionRelay *session_relay,
- DBusConnection *connection,
- DBusMessage *message)
+ DBusConnection *connection,
+ DBusMessage *message)
{
- DBusMessage *reply;
- DBusError error;
+ DBusMessage *reply;
+ DBusError error;
- dbus_error_init (&error);
+ dbus_error_init (&error);
- g_debug ("Reset");
+ g_debug ("Reset");
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
- /* FIXME: */
- /*g_signal_emit (session_relay, signals [RESET], 0);*/
+ /* FIXME: */
+ /*g_signal_emit (session_relay, signals [RESET], 0);*/
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
session_handle_child_message (DBusConnection *connection,
- DBusMessage *message,
- void *user_data)
+ DBusMessage *message,
+ void *user_data)
{
GdmSessionRelay *session_relay = GDM_SESSION_RELAY (user_data);
- if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "InfoQuery")) {
- return handle_info_query (session_relay, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "SecretInfoQuery")) {
- return handle_secret_info_query (session_relay, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "Info")) {
- return handle_info (session_relay, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "Problem")) {
- return handle_problem (session_relay, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "SessionStarted")) {
- return handle_session_started (session_relay, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "SessionStopped")) {
- return handle_session_started (session_relay, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "Ready")) {
- return handle_ready (session_relay, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "Reset")) {
- return handle_reset (session_relay, connection, message);
- }
+ if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "InfoQuery")) {
+ return handle_info_query (session_relay, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "SecretInfoQuery")) {
+ return handle_secret_info_query (session_relay, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "Info")) {
+ return handle_info (session_relay, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "Problem")) {
+ return handle_problem (session_relay, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "SessionStarted")) {
+ return handle_session_started (session_relay, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "SessionStopped")) {
+ return handle_session_started (session_relay, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "Ready")) {
+ return handle_ready (session_relay, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "Reset")) {
+ return handle_reset (session_relay, connection, message);
+ }
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
static DBusHandlerResult
do_introspect (DBusConnection *connection,
- DBusMessage *message)
-{
- DBusMessage *reply;
- GString *xml;
- char *xml_string;
-
- g_debug ("Do introspect");
-
- /* standard header */
- xml = g_string_new ("<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
- "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
- "<node>\n"
- " <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
- " <method name=\"Introspect\">\n"
- " <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
- " </method>\n"
- " </interface>\n");
-
- /* interface */
- xml = g_string_append (xml,
- " <interface name=\"org.gnome.DisplayManager.SessionRelay\">\n"
- " <method name=\"UserVerified\">\n"
- " </method>\n"
- " <method name=\"InfoQuery\">\n"
- " <arg name=\"text\" type=\"s\"/>\n"
- " </method>\n"
- " <method name=\"SecretInfoQuery\">\n"
- " <arg name=\"text\" type=\"s\"/>\n"
- " </method>\n"
- " <method name=\"Info\">\n"
- " <arg name=\"text\" type=\"s\"/>\n"
- " </method>\n"
- " <method name=\"Problem\">\n"
- " <arg name=\"text\" type=\"s\"/>\n"
- " </method>\n"
- " <method name=\"SessionStarted\">\n"
- " </method>\n"
- " <method name=\"SessionStopped\">\n"
- " </method>\n"
- " <method name=\"Ready\">\n"
- " </method>\n"
- " <method name=\"Reset\">\n"
- " </method>\n"
- " <signal name=\"Open\">\n"
- " </signal>\n"
- " <signal name=\"AnswerQuery\">\n"
- " <arg name=\"text\" type=\"s\"/>\n"
- " </signal>\n"
- " <signal name=\"LanguageSelected\">\n"
- " <arg name=\"language\" type=\"s\"/>\n"
- " </signal>\n"
- " <signal name=\"SessionSelected\">\n"
- " <arg name=\"session\" type=\"s\"/>\n"
- " </signal>\n"
- " <signal name=\"UserSelected\">\n"
- " <arg name=\"session\" type=\"s\"/>\n"
- " </signal>\n"
- " <signal name=\"Cancelled\">\n"
- " <arg name=\"session\" type=\"s\"/>\n"
- " </signal>\n"
- " </interface>\n");
-
- reply = dbus_message_new_method_return (message);
-
- xml = g_string_append (xml, "</node>\n");
- xml_string = g_string_free (xml, FALSE);
-
- dbus_message_append_args (reply,
- DBUS_TYPE_STRING, &xml_string,
- DBUS_TYPE_INVALID);
-
- g_free (xml_string);
-
- if (reply == NULL) {
- g_error ("No memory");
- }
-
- if (! dbus_connection_send (connection, reply, NULL)) {
- g_error ("No memory");
- }
-
- dbus_message_unref (reply);
-
- return DBUS_HANDLER_RESULT_HANDLED;
+ DBusMessage *message)
+{
+ DBusMessage *reply;
+ GString *xml;
+ char *xml_string;
+
+ g_debug ("Do introspect");
+
+ /* standard header */
+ xml = g_string_new ("<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
+ "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
+ "<node>\n"
+ " <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
+ " <method name=\"Introspect\">\n"
+ " <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
+ " </method>\n"
+ " </interface>\n");
+
+ /* interface */
+ xml = g_string_append (xml,
+ " <interface name=\"org.gnome.DisplayManager.SessionRelay\">\n"
+ " <method name=\"UserVerified\">\n"
+ " </method>\n"
+ " <method name=\"InfoQuery\">\n"
+ " <arg name=\"text\" type=\"s\"/>\n"
+ " </method>\n"
+ " <method name=\"SecretInfoQuery\">\n"
+ " <arg name=\"text\" type=\"s\"/>\n"
+ " </method>\n"
+ " <method name=\"Info\">\n"
+ " <arg name=\"text\" type=\"s\"/>\n"
+ " </method>\n"
+ " <method name=\"Problem\">\n"
+ " <arg name=\"text\" type=\"s\"/>\n"
+ " </method>\n"
+ " <method name=\"SessionStarted\">\n"
+ " </method>\n"
+ " <method name=\"SessionStopped\">\n"
+ " </method>\n"
+ " <method name=\"Ready\">\n"
+ " </method>\n"
+ " <method name=\"Reset\">\n"
+ " </method>\n"
+ " <signal name=\"Open\">\n"
+ " </signal>\n"
+ " <signal name=\"AnswerQuery\">\n"
+ " <arg name=\"text\" type=\"s\"/>\n"
+ " </signal>\n"
+ " <signal name=\"LanguageSelected\">\n"
+ " <arg name=\"language\" type=\"s\"/>\n"
+ " </signal>\n"
+ " <signal name=\"SessionSelected\">\n"
+ " <arg name=\"session\" type=\"s\"/>\n"
+ " </signal>\n"
+ " <signal name=\"UserSelected\">\n"
+ " <arg name=\"session\" type=\"s\"/>\n"
+ " </signal>\n"
+ " <signal name=\"Cancelled\">\n"
+ " <arg name=\"session\" type=\"s\"/>\n"
+ " </signal>\n"
+ " </interface>\n");
+
+ reply = dbus_message_new_method_return (message);
+
+ xml = g_string_append (xml, "</node>\n");
+ xml_string = g_string_free (xml, FALSE);
+
+ dbus_message_append_args (reply,
+ DBUS_TYPE_STRING, &xml_string,
+ DBUS_TYPE_INVALID);
+
+ g_free (xml_string);
+
+ if (reply == NULL) {
+ g_error ("No memory");
+ }
+
+ if (! dbus_connection_send (connection, reply, NULL)) {
+ g_error ("No memory");
+ }
+
+ dbus_message_unref (reply);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
session_relay_message_handler (DBusConnection *connection,
- DBusMessage *message,
- void *user_data)
+ DBusMessage *message,
+ void *user_data)
{
- g_debug ("session_relay_message_handler: destination=%s obj_path=%s interface=%s method=%s",
- dbus_message_get_destination (message),
- dbus_message_get_path (message),
- dbus_message_get_interface (message),
- dbus_message_get_member (message));
+ g_debug ("session_relay_message_handler: destination=%s obj_path=%s interface=%s method=%s",
+ dbus_message_get_destination (message),
+ dbus_message_get_path (message),
+ dbus_message_get_interface (message),
+ dbus_message_get_member (message));
if (dbus_message_is_method_call (message, "org.freedesktop.DBus", "AddMatch")) {
@@ -562,8 +562,8 @@ session_relay_message_handler (DBusConnection *connection,
/*dbus_connection_unref (connection);*/
return DBUS_HANDLER_RESULT_HANDLED;
- } else if (dbus_message_is_method_call (message, "org.freedesktop.DBus.Introspectable", "Introspect")) {
- return do_introspect (connection, message);
+ } else if (dbus_message_is_method_call (message, "org.freedesktop.DBus.Introspectable", "Introspect")) {
+ return do_introspect (connection, message);
} else {
return session_handle_child_message (connection, message, user_data);
}
@@ -573,43 +573,43 @@ session_relay_message_handler (DBusConnection *connection,
static void
session_relay_unregister_handler (DBusConnection *connection,
- void *user_data)
+ void *user_data)
{
- g_debug ("session_relay_unregister_handler");
+ g_debug ("session_relay_unregister_handler");
}
static DBusHandlerResult
connection_filter_function (DBusConnection *connection,
- DBusMessage *message,
- void *user_data)
+ DBusMessage *message,
+ void *user_data)
{
GdmSessionRelay *session_relay = GDM_SESSION_RELAY (user_data);
- const char *path;
+ const char *path;
- path = dbus_message_get_path (message);
+ path = dbus_message_get_path (message);
- g_debug ("obj_path=%s interface=%s method=%s",
- dbus_message_get_path (message),
- dbus_message_get_interface (message),
- dbus_message_get_member (message));
+ g_debug ("obj_path=%s interface=%s method=%s",
+ dbus_message_get_path (message),
+ dbus_message_get_interface (message),
+ dbus_message_get_member (message));
- if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected")
- && strcmp (path, DBUS_PATH_LOCAL) == 0) {
+ if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected")
+ && strcmp (path, DBUS_PATH_LOCAL) == 0) {
- g_debug ("Disconnected");
+ g_debug ("Disconnected");
- dbus_connection_unref (connection);
- session_relay->priv->session_connection = NULL;
+ dbus_connection_unref (connection);
+ session_relay->priv->session_connection = NULL;
- g_signal_emit (session_relay, signals[DISCONNECTED], 0);
- } else if (dbus_message_is_signal (message, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {
+ g_signal_emit (session_relay, signals[DISCONNECTED], 0);
+ } else if (dbus_message_is_signal (message, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {
- } else {
- return session_relay_message_handler (connection, message, user_data);
- }
+ } else {
+ return session_relay_message_handler (connection, message, user_data);
+ }
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static dbus_bool_t
@@ -617,107 +617,107 @@ allow_user_function (DBusConnection *connection,
unsigned long uid,
void *data)
{
- if (uid == 0) {
- return TRUE;
- }
+ if (uid == 0) {
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
static void
handle_connection (DBusServer *server,
- DBusConnection *new_connection,
- void *user_data)
+ DBusConnection *new_connection,
+ void *user_data)
{
GdmSessionRelay *session_relay = GDM_SESSION_RELAY (user_data);
- g_debug ("Handling new connection");
+ g_debug ("Handling new connection");
- g_assert (session_relay->priv->session_connection == NULL);
+ g_assert (session_relay->priv->session_connection == NULL);
- if (session_relay->priv->session_connection == NULL) {
- DBusObjectPathVTable vtable = { &session_relay_unregister_handler,
- &session_relay_message_handler,
- NULL, NULL, NULL, NULL
- };
+ if (session_relay->priv->session_connection == NULL) {
+ DBusObjectPathVTable vtable = { &session_relay_unregister_handler,
+ &session_relay_message_handler,
+ NULL, NULL, NULL, NULL
+ };
- session_relay->priv->session_connection = new_connection;
- dbus_connection_ref (new_connection);
- dbus_connection_setup_with_g_main (new_connection, NULL);
+ session_relay->priv->session_connection = new_connection;
+ dbus_connection_ref (new_connection);
+ dbus_connection_setup_with_g_main (new_connection, NULL);
- g_debug ("session connection is %p", new_connection);
+ g_debug ("session connection is %p", new_connection);
- dbus_connection_add_filter (new_connection,
- connection_filter_function,
- session_relay,
- NULL);
+ dbus_connection_add_filter (new_connection,
+ connection_filter_function,
+ session_relay,
+ NULL);
- dbus_connection_set_unix_user_function (new_connection,
- allow_user_function,
- session_relay,
- NULL);
+ dbus_connection_set_unix_user_function (new_connection,
+ allow_user_function,
+ session_relay,
+ NULL);
- dbus_connection_register_object_path (new_connection,
- GDM_SESSION_RELAY_DBUS_PATH,
- &vtable,
- session_relay);
+ dbus_connection_register_object_path (new_connection,
+ GDM_SESSION_RELAY_DBUS_PATH,
+ &vtable,
+ session_relay);
- g_signal_emit (session_relay, signals[CONNECTED], 0);
+ g_signal_emit (session_relay, signals[CONNECTED], 0);
- }
+ }
}
gboolean
gdm_session_relay_start (GdmSessionRelay *session_relay)
{
- DBusError error;
- gboolean ret;
- char *address;
- const char *auth_mechanisms[] = {"EXTERNAL", NULL};
+ DBusError error;
+ gboolean ret;
+ char *address;
+ const char *auth_mechanisms[] = {"EXTERNAL", NULL};
- ret = FALSE;
+ ret = FALSE;
- g_debug ("Creating D-Bus relay for session");
+ g_debug ("Creating D-Bus relay for session");
- address = generate_address ();
+ address = generate_address ();
- dbus_error_init (&error);
- session_relay->priv->server = dbus_server_listen (address, &error);
- g_free (address);
+ dbus_error_init (&error);
+ session_relay->priv->server = dbus_server_listen (address, &error);
+ g_free (address);
- if (session_relay->priv->server == NULL) {
- g_warning ("Cannot create D-BUS relay for the session: %s", error.message);
- goto out;
- }
+ if (session_relay->priv->server == NULL) {
+ g_warning ("Cannot create D-BUS relay for the session: %s", error.message);
+ goto out;
+ }
- dbus_server_setup_with_g_main (session_relay->priv->server, NULL);
- dbus_server_set_auth_mechanisms (session_relay->priv->server, auth_mechanisms);
- dbus_server_set_new_connection_function (session_relay->priv->server,
- handle_connection,
- session_relay,
- NULL);
- ret = TRUE;
+ dbus_server_setup_with_g_main (session_relay->priv->server, NULL);
+ dbus_server_set_auth_mechanisms (session_relay->priv->server, auth_mechanisms);
+ dbus_server_set_new_connection_function (session_relay->priv->server,
+ handle_connection,
+ session_relay,
+ NULL);
+ ret = TRUE;
- g_free (session_relay->priv->server_address);
- session_relay->priv->server_address = dbus_server_get_address (session_relay->priv->server);
+ g_free (session_relay->priv->server_address);
+ session_relay->priv->server_address = dbus_server_get_address (session_relay->priv->server);
- g_debug ("D-Bus relay listening on %s", session_relay->priv->server_address);
+ g_debug ("D-Bus relay listening on %s", session_relay->priv->server_address);
out:
- return ret;
+ return ret;
}
gboolean
gdm_session_relay_stop (GdmSessionRelay *session_relay)
{
- gboolean ret;
+ gboolean ret;
- ret = FALSE;
+ ret = FALSE;
- g_debug ("Stopping session relay...");
+ g_debug ("Stopping session relay...");
- return ret;
+ return ret;
}
char *
@@ -728,42 +728,42 @@ gdm_session_relay_get_address (GdmSessionRelay *session_relay)
static void
gdm_session_relay_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GdmSessionRelay *self;
+ GdmSessionRelay *self;
- self = GDM_SESSION_RELAY (object);
+ self = GDM_SESSION_RELAY (object);
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_session_relay_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GdmSessionRelay *self;
+ GdmSessionRelay *self;
- self = GDM_SESSION_RELAY (object);
+ self = GDM_SESSION_RELAY (object);
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static GObject *
gdm_session_relay_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
{
GdmSessionRelay *session_relay;
GdmSessionRelayClass *klass;
@@ -771,8 +771,8 @@ gdm_session_relay_constructor (GType type,
klass = GDM_SESSION_RELAY_CLASS (g_type_class_peek (GDM_TYPE_SESSION_RELAY));
session_relay = GDM_SESSION_RELAY (G_OBJECT_CLASS (gdm_session_relay_parent_class)->constructor (type,
- n_construct_properties,
- construct_properties));
+ n_construct_properties,
+ construct_properties));
return G_OBJECT (session_relay);
}
@@ -780,132 +780,132 @@ gdm_session_relay_constructor (GType type,
static void
gdm_session_relay_class_init (GdmSessionRelayClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->get_property = gdm_session_relay_get_property;
- object_class->set_property = gdm_session_relay_set_property;
+ object_class->get_property = gdm_session_relay_get_property;
+ object_class->set_property = gdm_session_relay_set_property;
object_class->constructor = gdm_session_relay_constructor;
- object_class->finalize = gdm_session_relay_finalize;
-
- g_type_class_add_private (klass, sizeof (GdmSessionRelayPrivate));
-
- signals [INFO_QUERY] =
- g_signal_new ("info-query",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionRelayClass, info_query),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1,
- G_TYPE_STRING);
- signals [SECRET_INFO_QUERY] =
- g_signal_new ("secret-info-query",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionRelayClass, secret_info_query),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1,
- G_TYPE_STRING);
- signals [INFO] =
- g_signal_new ("info",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionRelayClass, info),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1,
- G_TYPE_STRING);
- signals [PROBLEM] =
- g_signal_new ("problem",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionRelayClass, problem),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1,
- G_TYPE_STRING);
- signals [SESSION_STARTED] =
- g_signal_new ("session-started",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionRelayClass, session_started),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- signals [READY] =
- g_signal_new ("ready",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionRelayClass, ready),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- signals [CONNECTED] =
- g_signal_new ("connected",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionRelayClass, connected),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- signals [DISCONNECTED] =
- g_signal_new ("disconnected",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionRelayClass, disconnected),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
+ object_class->finalize = gdm_session_relay_finalize;
+
+ g_type_class_add_private (klass, sizeof (GdmSessionRelayPrivate));
+
+ signals [INFO_QUERY] =
+ g_signal_new ("info-query",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionRelayClass, info_query),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING);
+ signals [SECRET_INFO_QUERY] =
+ g_signal_new ("secret-info-query",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionRelayClass, secret_info_query),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING);
+ signals [INFO] =
+ g_signal_new ("info",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionRelayClass, info),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING);
+ signals [PROBLEM] =
+ g_signal_new ("problem",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionRelayClass, problem),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING);
+ signals [SESSION_STARTED] =
+ g_signal_new ("session-started",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionRelayClass, session_started),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ signals [READY] =
+ g_signal_new ("ready",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionRelayClass, ready),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ signals [CONNECTED] =
+ g_signal_new ("connected",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionRelayClass, connected),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ signals [DISCONNECTED] =
+ g_signal_new ("disconnected",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionRelayClass, disconnected),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
static void
gdm_session_relay_init (GdmSessionRelay *session_relay)
{
- session_relay->priv = GDM_SESSION_RELAY_GET_PRIVATE (session_relay);
+ session_relay->priv = GDM_SESSION_RELAY_GET_PRIVATE (session_relay);
}
static void
gdm_session_relay_finalize (GObject *object)
{
- GdmSessionRelay *session_relay;
+ GdmSessionRelay *session_relay;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_SESSION_RELAY (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_SESSION_RELAY (object));
- session_relay = GDM_SESSION_RELAY (object);
+ session_relay = GDM_SESSION_RELAY (object);
- g_return_if_fail (session_relay->priv != NULL);
+ g_return_if_fail (session_relay->priv != NULL);
- gdm_session_relay_stop (session_relay);
+ gdm_session_relay_stop (session_relay);
- G_OBJECT_CLASS (gdm_session_relay_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_session_relay_parent_class)->finalize (object);
}
GdmSessionRelay *
gdm_session_relay_new (void)
{
- GObject *object;
+ GObject *object;
- object = g_object_new (GDM_TYPE_SESSION_RELAY,
- NULL);
+ object = g_object_new (GDM_TYPE_SESSION_RELAY,
+ NULL);
- return GDM_SESSION_RELAY (object);
+ return GDM_SESSION_RELAY (object);
}
diff --git a/daemon/gdm-session-relay.h b/daemon/gdm-session-relay.h
index de7655ca..19b24463 100644
--- a/daemon/gdm-session-relay.h
+++ b/daemon/gdm-session-relay.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -37,62 +37,62 @@ typedef struct GdmSessionRelayPrivate GdmSessionRelayPrivate;
typedef struct
{
- GObject parent;
- GdmSessionRelayPrivate *priv;
+ GObject parent;
+ GdmSessionRelayPrivate *priv;
} GdmSessionRelay;
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
- void (* user_verified) (GdmSessionRelay *session_relay);
+ void (* user_verified) (GdmSessionRelay *session_relay);
- void (* user_verification_error) (GdmSessionRelay *session_relay,
- GError *error);
+ void (* user_verification_error) (GdmSessionRelay *session_relay,
+ GError *error);
- void (* info_query) (GdmSessionRelay *session_relay,
- const char *query_text);
+ void (* info_query) (GdmSessionRelay *session_relay,
+ const char *query_text);
- void (* secret_info_query) (GdmSessionRelay *session_relay,
- const char *query_text);
+ void (* secret_info_query) (GdmSessionRelay *session_relay,
+ const char *query_text);
- void (* info) (GdmSessionRelay *session_relay,
- const char *info);
+ void (* info) (GdmSessionRelay *session_relay,
+ const char *info);
- void (* problem) (GdmSessionRelay *session_relay,
- const char *problem);
+ void (* problem) (GdmSessionRelay *session_relay,
+ const char *problem);
- void (* session_started) (GdmSessionRelay *session_relay,
- GPid pid);
+ void (* session_started) (GdmSessionRelay *session_relay,
+ GPid pid);
- void (* session_startup_error) (GdmSessionRelay *session_relay,
- GError *error);
+ void (* session_startup_error) (GdmSessionRelay *session_relay,
+ GError *error);
- void (* session_exited) (GdmSessionRelay *session_relay,
- int exit_code);
+ void (* session_exited) (GdmSessionRelay *session_relay,
+ int exit_code);
- void (* session_died) (GdmSessionRelay *session_relay,
- int signal_number);
+ void (* session_died) (GdmSessionRelay *session_relay,
+ int signal_number);
- void (* ready) (GdmSessionRelay *session_relay);
- void (* connected) (GdmSessionRelay *session_relay);
- void (* disconnected) (GdmSessionRelay *session_relay);
+ void (* ready) (GdmSessionRelay *session_relay);
+ void (* connected) (GdmSessionRelay *session_relay);
+ void (* disconnected) (GdmSessionRelay *session_relay);
} GdmSessionRelayClass;
-GType gdm_session_relay_get_type (void);
-GdmSessionRelay * gdm_session_relay_new (void);
+GType gdm_session_relay_get_type (void);
+GdmSessionRelay * gdm_session_relay_new (void);
void gdm_session_relay_answer_query (GdmSessionRelay *session_relay,
- const char *text);
+ const char *text);
void gdm_session_relay_open (GdmSessionRelay *session_relay);
void gdm_session_relay_select_session (GdmSessionRelay *session_relay,
- const char *session);
+ const char *session);
void gdm_session_relay_select_language (GdmSessionRelay *session_relay,
- const char *language);
+ const char *language);
void gdm_session_relay_select_user (GdmSessionRelay *session_relay,
- const char *user);
+ const char *user);
void gdm_session_relay_cancel (GdmSessionRelay *session_relay);
gboolean gdm_session_relay_start (GdmSessionRelay *session_relay);
diff --git a/daemon/gdm-session-worker-job.c b/daemon/gdm-session-worker-job.c
index 1059d84f..84b8b210 100644
--- a/daemon/gdm-session-worker-job.c
+++ b/daemon/gdm-session-worker-job.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -52,32 +52,32 @@ extern char **environ;
struct GdmSessionWorkerJobPrivate
{
- char *command;
- GPid pid;
+ char *command;
+ GPid pid;
- guint child_watch_id;
+ guint child_watch_id;
- char *server_address;
+ char *server_address;
};
enum {
- PROP_0,
- PROP_SERVER_ADDRESS,
+ PROP_0,
+ PROP_SERVER_ADDRESS,
};
enum {
- STARTED,
- STOPPED,
- EXITED,
- DIED,
- LAST_SIGNAL
+ STARTED,
+ STOPPED,
+ EXITED,
+ DIED,
+ LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0, };
-static void gdm_session_worker_job_class_init (GdmSessionWorkerJobClass *klass);
-static void gdm_session_worker_job_init (GdmSessionWorkerJob *session_worker_job);
-static void gdm_session_worker_job_finalize (GObject *object);
+static void gdm_session_worker_job_class_init (GdmSessionWorkerJobClass *klass);
+static void gdm_session_worker_job_init (GdmSessionWorkerJob *session_worker_job);
+static void gdm_session_worker_job_finalize (GObject *object);
G_DEFINE_TYPE (GdmSessionWorkerJob, gdm_session_worker_job, G_TYPE_OBJECT)
@@ -88,114 +88,114 @@ session_worker_job_child_setup (GdmSessionWorkerJob *session_worker_job)
static void
session_worker_job_child_watch (GPid pid,
- int status,
- GdmSessionWorkerJob *job)
+ int status,
+ GdmSessionWorkerJob *job)
{
- g_debug ("child (pid:%d) done (%s:%d)",
- (int) pid,
- WIFEXITED (status) ? "status"
- : WIFSIGNALED (status) ? "signal"
- : "unknown",
- WIFEXITED (status) ? WEXITSTATUS (status)
- : WIFSIGNALED (status) ? WTERMSIG (status)
- : -1);
- if (WIFEXITED (status)) {
- int code = WEXITSTATUS (status);
- g_signal_emit (job, signals [EXITED], 0, code);
- } else if (WIFSIGNALED (status)) {
- int num = WTERMSIG (status);
- g_signal_emit (job, signals [DIED], 0, num);
- }
-
- g_spawn_close_pid (job->priv->pid);
- job->priv->pid = -1;
+ g_debug ("child (pid:%d) done (%s:%d)",
+ (int) pid,
+ WIFEXITED (status) ? "status"
+ : WIFSIGNALED (status) ? "signal"
+ : "unknown",
+ WIFEXITED (status) ? WEXITSTATUS (status)
+ : WIFSIGNALED (status) ? WTERMSIG (status)
+ : -1);
+ if (WIFEXITED (status)) {
+ int code = WEXITSTATUS (status);
+ g_signal_emit (job, signals [EXITED], 0, code);
+ } else if (WIFSIGNALED (status)) {
+ int num = WTERMSIG (status);
+ g_signal_emit (job, signals [DIED], 0, num);
+ }
+
+ g_spawn_close_pid (job->priv->pid);
+ job->priv->pid = -1;
}
static void
listify_hash (const char *key,
- const char *value,
- GPtrArray *env)
+ const char *value,
+ GPtrArray *env)
{
- char *str;
- str = g_strdup_printf ("%s=%s", key, value);
- g_ptr_array_add (env, str);
+ char *str;
+ str = g_strdup_printf ("%s=%s", key, value);
+ g_ptr_array_add (env, str);
}
static GPtrArray *
get_job_environment (GdmSessionWorkerJob *job)
{
- GPtrArray *env;
- GHashTable *hash;
+ GPtrArray *env;
+ GHashTable *hash;
- env = g_ptr_array_new ();
+ env = g_ptr_array_new ();
- /* create a hash table of current environment, then update keys has necessary */
- hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+ /* create a hash table of current environment, then update keys has necessary */
+ hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- g_hash_table_insert (hash, g_strdup ("GDM_SESSION_DBUS_ADDRESS"), g_strdup (job->priv->server_address));
+ g_hash_table_insert (hash, g_strdup ("GDM_SESSION_DBUS_ADDRESS"), g_strdup (job->priv->server_address));
- g_hash_table_foreach (hash, (GHFunc)listify_hash, env);
- g_hash_table_destroy (hash);
+ g_hash_table_foreach (hash, (GHFunc)listify_hash, env);
+ g_hash_table_destroy (hash);
- g_ptr_array_add (env, NULL);
+ g_ptr_array_add (env, NULL);
- return env;
+ return env;
}
static gboolean
gdm_session_worker_job_spawn (GdmSessionWorkerJob *session_worker_job)
{
- gchar **argv;
- GError *error;
- gboolean ret;
- GPtrArray *env;
-
- ret = FALSE;
-
- g_debug ("Running session_worker_job process: %s", session_worker_job->priv->command);
-
- argv = NULL;
- if (! g_shell_parse_argv (session_worker_job->priv->command, NULL, &argv, &error)) {
- g_warning ("Could not parse command: %s", error->message);
- g_error_free (error);
- goto out;
- }
-
- env = get_job_environment (session_worker_job);
-
- error = NULL;
- ret = g_spawn_async_with_pipes (NULL,
- argv,
- (char **)env->pdata,
- G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
- (GSpawnChildSetupFunc)session_worker_job_child_setup,
- session_worker_job,
- &session_worker_job->priv->pid,
- NULL,
- NULL,
- NULL,
- &error);
-
- g_ptr_array_foreach (env, (GFunc)g_free, NULL);
+ gchar **argv;
+ GError *error;
+ gboolean ret;
+ GPtrArray *env;
+
+ ret = FALSE;
+
+ g_debug ("Running session_worker_job process: %s", session_worker_job->priv->command);
+
+ argv = NULL;
+ if (! g_shell_parse_argv (session_worker_job->priv->command, NULL, &argv, &error)) {
+ g_warning ("Could not parse command: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ env = get_job_environment (session_worker_job);
+
+ error = NULL;
+ ret = g_spawn_async_with_pipes (NULL,
+ argv,
+ (char **)env->pdata,
+ G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
+ (GSpawnChildSetupFunc)session_worker_job_child_setup,
+ session_worker_job,
+ &session_worker_job->priv->pid,
+ NULL,
+ NULL,
+ NULL,
+ &error);
+
+ g_ptr_array_foreach (env, (GFunc)g_free, NULL);
g_ptr_array_free (env, TRUE);
- if (! ret) {
- g_warning ("Could not start command '%s': %s",
- session_worker_job->priv->command,
- error->message);
- g_error_free (error);
- } else {
- g_debug ("gdm_slave_session_worker_job: SessionWorkerJob on pid %d", (int)session_worker_job->priv->pid);
- }
+ if (! ret) {
+ g_warning ("Could not start command '%s': %s",
+ session_worker_job->priv->command,
+ error->message);
+ g_error_free (error);
+ } else {
+ g_debug ("gdm_slave_session_worker_job: SessionWorkerJob on pid %d", (int)session_worker_job->priv->pid);
+ }
- session_worker_job->priv->child_watch_id = g_child_watch_add (session_worker_job->priv->pid,
- (GChildWatchFunc)session_worker_job_child_watch,
- session_worker_job);
+ session_worker_job->priv->child_watch_id = g_child_watch_add (session_worker_job->priv->pid,
+ (GChildWatchFunc)session_worker_job_child_watch,
+ session_worker_job);
- g_strfreev (argv);
+ g_strfreev (argv);
out:
- return ret;
+ return ret;
}
/**
@@ -207,161 +207,161 @@ gdm_session_worker_job_spawn (GdmSessionWorkerJob *session_worker_job)
gboolean
gdm_session_worker_job_start (GdmSessionWorkerJob *session_worker_job)
{
- gboolean res;
+ gboolean res;
- g_debug ("Starting worker...");
+ g_debug ("Starting worker...");
- res = gdm_session_worker_job_spawn (session_worker_job);
+ res = gdm_session_worker_job_spawn (session_worker_job);
- if (res) {
+ if (res) {
- }
+ }
- return res;
+ return res;
}
static int
signal_pid (int pid,
- int signal)
+ int signal)
{
- int status = -1;
+ int status = -1;
- /* perhaps block sigchld */
+ /* perhaps block sigchld */
- status = kill (pid, signal);
+ status = kill (pid, signal);
- if (status < 0) {
- if (errno == ESRCH) {
- g_warning ("Child process %lu was already dead.",
- (unsigned long) pid);
- } else {
- g_warning ("Couldn't kill child process %lu: %s",
- (unsigned long) pid,
- g_strerror (errno));
- }
- }
+ if (status < 0) {
+ if (errno == ESRCH) {
+ g_warning ("Child process %lu was already dead.",
+ (unsigned long) pid);
+ } else {
+ g_warning ("Couldn't kill child process %lu: %s",
+ (unsigned long) pid,
+ g_strerror (errno));
+ }
+ }
- /* perhaps unblock sigchld */
+ /* perhaps unblock sigchld */
- return status;
+ return status;
}
static int
wait_on_child (int pid)
{
- int status;
+ int status;
wait_again:
- if (waitpid (pid, &status, 0) < 0) {
- if (errno == EINTR) {
- goto wait_again;
- } else if (errno == ECHILD) {
- ; /* do nothing, child already reaped */
- } else {
- g_debug ("waitpid () should not fail");
- }
- }
-
- return status;
+ if (waitpid (pid, &status, 0) < 0) {
+ if (errno == EINTR) {
+ goto wait_again;
+ } else if (errno == ECHILD) {
+ ; /* do nothing, child already reaped */
+ } else {
+ g_debug ("waitpid () should not fail");
+ }
+ }
+
+ return status;
}
static void
session_worker_job_died (GdmSessionWorkerJob *session_worker_job)
{
- int exit_status;
+ int exit_status;
- g_debug ("Waiting on process %d", session_worker_job->priv->pid);
- exit_status = wait_on_child (session_worker_job->priv->pid);
+ g_debug ("Waiting on process %d", session_worker_job->priv->pid);
+ exit_status = wait_on_child (session_worker_job->priv->pid);
- if (WIFEXITED (exit_status) && (WEXITSTATUS (exit_status) != 0)) {
- g_debug ("Wait on child process failed");
- } else {
- /* exited normally */
- }
+ if (WIFEXITED (exit_status) && (WEXITSTATUS (exit_status) != 0)) {
+ g_debug ("Wait on child process failed");
+ } else {
+ /* exited normally */
+ }
- g_spawn_close_pid (session_worker_job->priv->pid);
- session_worker_job->priv->pid = -1;
+ g_spawn_close_pid (session_worker_job->priv->pid);
+ session_worker_job->priv->pid = -1;
- g_debug ("SessionWorkerJob died");
+ g_debug ("SessionWorkerJob died");
}
gboolean
gdm_session_worker_job_stop (GdmSessionWorkerJob *session_worker_job)
{
- if (session_worker_job->priv->pid <= 1) {
- return TRUE;
- }
+ if (session_worker_job->priv->pid <= 1) {
+ return TRUE;
+ }
- /* remove watch source before we can wait on child */
- if (session_worker_job->priv->child_watch_id > 0) {
- g_source_remove (session_worker_job->priv->child_watch_id);
- session_worker_job->priv->child_watch_id = 0;
- }
+ /* remove watch source before we can wait on child */
+ if (session_worker_job->priv->child_watch_id > 0) {
+ g_source_remove (session_worker_job->priv->child_watch_id);
+ session_worker_job->priv->child_watch_id = 0;
+ }
- g_debug ("Stopping session_worker_job pid:%d", session_worker_job->priv->pid);
+ g_debug ("Stopping session_worker_job pid:%d", session_worker_job->priv->pid);
- signal_pid (session_worker_job->priv->pid, SIGTERM);
- session_worker_job_died (session_worker_job);
+ signal_pid (session_worker_job->priv->pid, SIGTERM);
+ session_worker_job_died (session_worker_job);
- return TRUE;
+ return TRUE;
}
void
gdm_session_worker_job_set_server_address (GdmSessionWorkerJob *session_worker_job,
- const char *address)
+ const char *address)
{
- g_return_if_fail (GDM_IS_SESSION_WORKER_JOB (session_worker_job));
+ g_return_if_fail (GDM_IS_SESSION_WORKER_JOB (session_worker_job));
- g_free (session_worker_job->priv->server_address);
- session_worker_job->priv->server_address = g_strdup (address);
+ g_free (session_worker_job->priv->server_address);
+ session_worker_job->priv->server_address = g_strdup (address);
}
static void
gdm_session_worker_job_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GdmSessionWorkerJob *self;
-
- self = GDM_SESSION_WORKER_JOB (object);
-
- switch (prop_id) {
- case PROP_SERVER_ADDRESS:
- gdm_session_worker_job_set_server_address (self, g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GdmSessionWorkerJob *self;
+
+ self = GDM_SESSION_WORKER_JOB (object);
+
+ switch (prop_id) {
+ case PROP_SERVER_ADDRESS:
+ gdm_session_worker_job_set_server_address (self, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_session_worker_job_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GdmSessionWorkerJob *self;
-
- self = GDM_SESSION_WORKER_JOB (object);
-
- switch (prop_id) {
- case PROP_SERVER_ADDRESS:
- g_value_set_string (value, self->priv->server_address);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GdmSessionWorkerJob *self;
+
+ self = GDM_SESSION_WORKER_JOB (object);
+
+ switch (prop_id) {
+ case PROP_SERVER_ADDRESS:
+ g_value_set_string (value, self->priv->server_address);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static GObject *
gdm_session_worker_job_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
{
GdmSessionWorkerJob *session_worker_job;
GdmSessionWorkerJobClass *klass;
@@ -369,8 +369,8 @@ gdm_session_worker_job_constructor (GType type,
klass = GDM_SESSION_WORKER_JOB_CLASS (g_type_class_peek (GDM_TYPE_SESSION_WORKER_JOB));
session_worker_job = GDM_SESSION_WORKER_JOB (G_OBJECT_CLASS (gdm_session_worker_job_parent_class)->constructor (type,
- n_construct_properties,
- construct_properties));
+ n_construct_properties,
+ construct_properties));
return G_OBJECT (session_worker_job);
}
@@ -378,102 +378,102 @@ gdm_session_worker_job_constructor (GType type,
static void
gdm_session_worker_job_class_init (GdmSessionWorkerJobClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->get_property = gdm_session_worker_job_get_property;
- object_class->set_property = gdm_session_worker_job_set_property;
+ object_class->get_property = gdm_session_worker_job_get_property;
+ object_class->set_property = gdm_session_worker_job_set_property;
object_class->constructor = gdm_session_worker_job_constructor;
- object_class->finalize = gdm_session_worker_job_finalize;
-
- g_type_class_add_private (klass, sizeof (GdmSessionWorkerJobPrivate));
-
- g_object_class_install_property (object_class,
- PROP_SERVER_ADDRESS,
- g_param_spec_string ("server-address",
- "server address",
- "server address",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- signals [STARTED] =
- g_signal_new ("started",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionWorkerJobClass, started),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- signals [STOPPED] =
- g_signal_new ("stopped",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionWorkerJobClass, stopped),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- signals [EXITED] =
- g_signal_new ("exited",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionWorkerJobClass, exited),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE,
- 1,
- G_TYPE_INT);
-
- signals [DIED] =
- g_signal_new ("died",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionWorkerJobClass, died),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE,
- 1,
- G_TYPE_INT);
+ object_class->finalize = gdm_session_worker_job_finalize;
+
+ g_type_class_add_private (klass, sizeof (GdmSessionWorkerJobPrivate));
+
+ g_object_class_install_property (object_class,
+ PROP_SERVER_ADDRESS,
+ g_param_spec_string ("server-address",
+ "server address",
+ "server address",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ signals [STARTED] =
+ g_signal_new ("started",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionWorkerJobClass, started),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ signals [STOPPED] =
+ g_signal_new ("stopped",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionWorkerJobClass, stopped),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ signals [EXITED] =
+ g_signal_new ("exited",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionWorkerJobClass, exited),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__INT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_INT);
+
+ signals [DIED] =
+ g_signal_new ("died",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionWorkerJobClass, died),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__INT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_INT);
}
static void
gdm_session_worker_job_init (GdmSessionWorkerJob *session_worker_job)
{
- session_worker_job->priv = GDM_SESSION_WORKER_JOB_GET_PRIVATE (session_worker_job);
+ session_worker_job->priv = GDM_SESSION_WORKER_JOB_GET_PRIVATE (session_worker_job);
- session_worker_job->priv->pid = -1;
+ session_worker_job->priv->pid = -1;
- session_worker_job->priv->command = g_strdup (LIBEXECDIR "/gdm-session-worker");
+ session_worker_job->priv->command = g_strdup (LIBEXECDIR "/gdm-session-worker");
}
static void
gdm_session_worker_job_finalize (GObject *object)
{
- GdmSessionWorkerJob *session_worker_job;
+ GdmSessionWorkerJob *session_worker_job;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_SESSION_WORKER_JOB (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_SESSION_WORKER_JOB (object));
- session_worker_job = GDM_SESSION_WORKER_JOB (object);
+ session_worker_job = GDM_SESSION_WORKER_JOB (object);
- g_return_if_fail (session_worker_job->priv != NULL);
+ g_return_if_fail (session_worker_job->priv != NULL);
- gdm_session_worker_job_stop (session_worker_job);
+ gdm_session_worker_job_stop (session_worker_job);
- G_OBJECT_CLASS (gdm_session_worker_job_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_session_worker_job_parent_class)->finalize (object);
}
GdmSessionWorkerJob *
gdm_session_worker_job_new (void)
{
- GObject *object;
+ GObject *object;
- object = g_object_new (GDM_TYPE_SESSION_WORKER_JOB,
- NULL);
+ object = g_object_new (GDM_TYPE_SESSION_WORKER_JOB,
+ NULL);
- return GDM_SESSION_WORKER_JOB (object);
+ return GDM_SESSION_WORKER_JOB (object);
}
diff --git a/daemon/gdm-session-worker-job.h b/daemon/gdm-session-worker-job.h
index 5c35fe16..d42eb37c 100644
--- a/daemon/gdm-session-worker-job.h
+++ b/daemon/gdm-session-worker-job.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -37,27 +37,27 @@ typedef struct GdmSessionWorkerJobPrivate GdmSessionWorkerJobPrivate;
typedef struct
{
- GObject parent;
- GdmSessionWorkerJobPrivate *priv;
+ GObject parent;
+ GdmSessionWorkerJobPrivate *priv;
} GdmSessionWorkerJob;
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
- void (* started) (GdmSessionWorkerJob *session_worker_job);
- void (* stopped) (GdmSessionWorkerJob *session_worker_job);
- void (* exited) (GdmSessionWorkerJob *session_worker_job,
- int exit_code);
+ void (* started) (GdmSessionWorkerJob *session_worker_job);
+ void (* stopped) (GdmSessionWorkerJob *session_worker_job);
+ void (* exited) (GdmSessionWorkerJob *session_worker_job,
+ int exit_code);
- void (* died) (GdmSessionWorkerJob *session_worker_job,
- int signal_number);
+ void (* died) (GdmSessionWorkerJob *session_worker_job,
+ int signal_number);
} GdmSessionWorkerJobClass;
-GType gdm_session_worker_job_get_type (void);
-GdmSessionWorkerJob * gdm_session_worker_job_new (void);
+GType gdm_session_worker_job_get_type (void);
+GdmSessionWorkerJob * gdm_session_worker_job_new (void);
void gdm_session_worker_job_set_server_address (GdmSessionWorkerJob *session_worker_job,
- const char *server_address);
+ const char *server_address);
gboolean gdm_session_worker_job_start (GdmSessionWorkerJob *session_worker_job);
gboolean gdm_session_worker_job_stop (GdmSessionWorkerJob *session_worker_job);
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
index 0ab03166..143ca034 100644
--- a/daemon/gdm-session-worker.c
+++ b/daemon/gdm-session-worker.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2006 Ray Strode <rstrode@redhat.com>
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
@@ -66,1587 +66,1587 @@
struct GdmSessionWorkerPrivate
{
- int exit_code;
+ int exit_code;
- pam_handle_t *pam_handle;
+ pam_handle_t *pam_handle;
- GPid child_pid;
- guint child_watch_id;
+ GPid child_pid;
+ guint child_watch_id;
- char *username;
- char **arguments;
+ char *username;
+ char **arguments;
- GHashTable *environment;
+ GHashTable *environment;
- guint32 credentials_are_established : 1;
- guint32 is_running : 1;
- guint open_idle_id;
+ guint32 credentials_are_established : 1;
+ guint32 is_running : 1;
+ guint open_idle_id;
- char *server_address;
- DBusGConnection *connection;
- DBusGProxy *server_proxy;
+ char *server_address;
+ DBusGConnection *connection;
+ DBusGProxy *server_proxy;
};
enum {
- PROP_0,
- PROP_SERVER_ADDRESS,
+ PROP_0,
+ PROP_SERVER_ADDRESS,
};
enum {
- USER_VERIFIED = 0,
- USER_VERIFICATION_ERROR,
- INFO,
- PROBLEM,
- INFO_QUERY,
- SECRET_INFO_QUERY,
- SESSION_STARTED,
- SESSION_STARTUP_ERROR,
- SESSION_EXITED,
- SESSION_DIED,
- LAST_SIGNAL
+ USER_VERIFIED = 0,
+ USER_VERIFICATION_ERROR,
+ INFO,
+ PROBLEM,
+ INFO_QUERY,
+ SECRET_INFO_QUERY,
+ SESSION_STARTED,
+ SESSION_STARTUP_ERROR,
+ SESSION_EXITED,
+ SESSION_DIED,
+ LAST_SIGNAL
};
-static void gdm_session_worker_class_init (GdmSessionWorkerClass *klass);
-static void gdm_session_worker_init (GdmSessionWorker *session_worker);
-static void gdm_session_worker_finalize (GObject *object);
+static void gdm_session_worker_class_init (GdmSessionWorkerClass *klass);
+static void gdm_session_worker_init (GdmSessionWorker *session_worker);
+static void gdm_session_worker_finalize (GObject *object);
typedef int (* GdmSessionWorkerPamNewMessagesFunc) (int,
- const struct pam_message **,
- struct pam_response **,
- gpointer);
+ const struct pam_message **,
+ struct pam_response **,
+ gpointer);
G_DEFINE_TYPE (GdmSessionWorker, gdm_session_worker, G_TYPE_OBJECT)
GQuark
gdm_session_worker_error_quark (void)
{
- static GQuark error_quark = 0;
+ static GQuark error_quark = 0;
- if (error_quark == 0)
- error_quark = g_quark_from_static_string ("gdm-session-worker");
+ if (error_quark == 0)
+ error_quark = g_quark_from_static_string ("gdm-session-worker");
- return error_quark;
+ return error_quark;
}
/* adapted from glib script_execute */
static void
script_execute (const gchar *file,
- char **argv,
- char **envp,
- gboolean search_path)
+ char **argv,
+ char **envp,
+ gboolean search_path)
{
- /* Count the arguments. */
- int argc = 0;
+ /* Count the arguments. */
+ int argc = 0;
- while (argv[argc])
- ++argc;
+ while (argv[argc])
+ ++argc;
- /* Construct an argument list for the shell. */
- {
- char **new_argv;
+ /* Construct an argument list for the shell. */
+ {
+ char **new_argv;
- new_argv = g_new0 (gchar*, argc + 2); /* /bin/sh and NULL */
+ new_argv = g_new0 (gchar*, argc + 2); /* /bin/sh and NULL */
- new_argv[0] = (char *) "/bin/sh";
- new_argv[1] = (char *) file;
- while (argc > 0) {
- new_argv[argc + 1] = argv[argc];
- --argc;
- }
+ new_argv[0] = (char *) "/bin/sh";
+ new_argv[1] = (char *) file;
+ while (argc > 0) {
+ new_argv[argc + 1] = argv[argc];
+ --argc;
+ }
- /* Execute the shell. */
- if (envp)
- execve (new_argv[0], new_argv, envp);
- else
- execv (new_argv[0], new_argv);
+ /* Execute the shell. */
+ if (envp)
+ execve (new_argv[0], new_argv, envp);
+ else
+ execv (new_argv[0], new_argv);
- g_free (new_argv);
- }
+ g_free (new_argv);
+ }
}
static char *
my_strchrnul (const char *str, char c)
{
- char *p = (char*) str;
- while (*p && (*p != c))
- ++p;
+ char *p = (char*) str;
+ while (*p && (*p != c))
+ ++p;
- return p;
+ return p;
}
/* adapted from glib g_execute */
static gint
gdm_session_execute (const char *file,
- char **argv,
- char **envp,
- gboolean search_path)
+ char **argv,
+ char **envp,
+ gboolean search_path)
{
- if (*file == '\0') {
- /* We check the simple case first. */
- errno = ENOENT;
- return -1;
- }
-
- if (!search_path || strchr (file, '/') != NULL) {
- /* Don't search when it contains a slash. */
- if (envp)
- execve (file, argv, envp);
- else
- execv (file, argv);
-
- if (errno == ENOEXEC)
- script_execute (file, argv, envp, FALSE);
- } else {
- gboolean got_eacces = 0;
- const char *path, *p;
- char *name, *freeme;
- gsize len;
- gsize pathlen;
-
- path = g_getenv ("PATH");
- if (path == NULL) {
- /* There is no `PATH' in the environment. The default
- * search path in libc is the current directory followed by
- * the path `confstr' returns for `_CS_PATH'.
- */
-
- /* In GLib we put . last, for security, and don't use the
- * unportable confstr(); UNIX98 does not actually specify
- * what to search if PATH is unset. POSIX may, dunno.
- */
-
- path = "/bin:/usr/bin:.";
- }
-
- len = strlen (file) + 1;
- pathlen = strlen (path);
- freeme = name = g_malloc (pathlen + len + 1);
-
- /* Copy the file name at the top, including '\0' */
- memcpy (name + pathlen + 1, file, len);
- name = name + pathlen;
- /* And add the slash before the filename */
- *name = '/';
-
- p = path;
- do {
- char *startp;
-
- path = p;
- p = my_strchrnul (path, ':');
-
- if (p == path)
- /* Two adjacent colons, or a colon at the beginning or the end
- * of `PATH' means to search the current directory.
- */
- startp = name + 1;
- else
- startp = memcpy (name - (p - path), path, p - path);
-
- /* Try to execute this name. If it works, execv will not return. */
- if (envp)
- execve (startp, argv, envp);
- else
- execv (startp, argv);
-
- if (errno == ENOEXEC)
- script_execute (startp, argv, envp, search_path);
-
- switch (errno) {
- case EACCES:
- /* Record the we got a `Permission denied' error. If we end
- * up finding no executable we can use, we want to diagnose
- * that we did find one but were denied access.
- */
- got_eacces = TRUE;
-
- /* FALL THRU */
-
- case ENOENT:
+ if (*file == '\0') {
+ /* We check the simple case first. */
+ errno = ENOENT;
+ return -1;
+ }
+
+ if (!search_path || strchr (file, '/') != NULL) {
+ /* Don't search when it contains a slash. */
+ if (envp)
+ execve (file, argv, envp);
+ else
+ execv (file, argv);
+
+ if (errno == ENOEXEC)
+ script_execute (file, argv, envp, FALSE);
+ } else {
+ gboolean got_eacces = 0;
+ const char *path, *p;
+ char *name, *freeme;
+ gsize len;
+ gsize pathlen;
+
+ path = g_getenv ("PATH");
+ if (path == NULL) {
+ /* There is no `PATH' in the environment. The default
+ * search path in libc is the current directory followed by
+ * the path `confstr' returns for `_CS_PATH'.
+ */
+
+ /* In GLib we put . last, for security, and don't use the
+ * unportable confstr(); UNIX98 does not actually specify
+ * what to search if PATH is unset. POSIX may, dunno.
+ */
+
+ path = "/bin:/usr/bin:.";
+ }
+
+ len = strlen (file) + 1;
+ pathlen = strlen (path);
+ freeme = name = g_malloc (pathlen + len + 1);
+
+ /* Copy the file name at the top, including '\0' */
+ memcpy (name + pathlen + 1, file, len);
+ name = name + pathlen;
+ /* And add the slash before the filename */
+ *name = '/';
+
+ p = path;
+ do {
+ char *startp;
+
+ path = p;
+ p = my_strchrnul (path, ':');
+
+ if (p == path)
+ /* Two adjacent colons, or a colon at the beginning or the end
+ * of `PATH' means to search the current directory.
+ */
+ startp = name + 1;
+ else
+ startp = memcpy (name - (p - path), path, p - path);
+
+ /* Try to execute this name. If it works, execv will not return. */
+ if (envp)
+ execve (startp, argv, envp);
+ else
+ execv (startp, argv);
+
+ if (errno == ENOEXEC)
+ script_execute (startp, argv, envp, search_path);
+
+ switch (errno) {
+ case EACCES:
+ /* Record the we got a `Permission denied' error. If we end
+ * up finding no executable we can use, we want to diagnose
+ * that we did find one but were denied access.
+ */
+ got_eacces = TRUE;
+
+ /* FALL THRU */
+
+ case ENOENT:
#ifdef ESTALE
- case ESTALE:
+ case ESTALE:
#endif
#ifdef ENOTDIR
- case ENOTDIR:
+ case ENOTDIR:
#endif
- /* Those errors indicate the file is missing or not executable
- * by us, in which case we want to just try the next path
- * directory.
- */
- break;
-
- default:
- /* Some other error means we found an executable file, but
- * something went wrong executing it; return the error to our
- * caller.
- */
- g_free (freeme);
- return -1;
- }
- } while (*p++ != '\0');
-
- /* We tried every element and none of them worked. */
- if (got_eacces)
- /* At least one failure was due to permissions, so report that
- * error.
- */
- errno = EACCES;
-
- g_free (freeme);
- }
-
- /* Return the error from the last attempt (probably ENOENT). */
- return -1;
+ /* Those errors indicate the file is missing or not executable
+ * by us, in which case we want to just try the next path
+ * directory.
+ */
+ break;
+
+ default:
+ /* Some other error means we found an executable file, but
+ * something went wrong executing it; return the error to our
+ * caller.
+ */
+ g_free (freeme);
+ return -1;
+ }
+ } while (*p++ != '\0');
+
+ /* We tried every element and none of them worked. */
+ if (got_eacces)
+ /* At least one failure was due to permissions, so report that
+ * error.
+ */
+ errno = EACCES;
+
+ g_free (freeme);
+ }
+
+ /* Return the error from the last attempt (probably ENOENT). */
+ return -1;
}
static void
send_user_verified (GdmSessionWorker *worker)
{
- GError *error;
- gboolean res;
-
- error = NULL;
- res = dbus_g_proxy_call (worker->priv->server_proxy,
- "Verified",
- &error,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to send Verified: %s", error->message);
- g_error_free (error);
- }
+ GError *error;
+ gboolean res;
+
+ error = NULL;
+ res = dbus_g_proxy_call (worker->priv->server_proxy,
+ "Verified",
+ &error,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Unable to send Verified: %s", error->message);
+ g_error_free (error);
+ }
}
static void
send_startup_failed (GdmSessionWorker *worker,
- const char *message)
+ const char *message)
{
- GError *error;
- gboolean res;
-
- error = NULL;
- res = dbus_g_proxy_call (worker->priv->server_proxy,
- "StartupFailed",
- &error,
- G_TYPE_STRING, message,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to send StartupFailed: %s", error->message);
- g_error_free (error);
- }
+ GError *error;
+ gboolean res;
+
+ error = NULL;
+ res = dbus_g_proxy_call (worker->priv->server_proxy,
+ "StartupFailed",
+ &error,
+ G_TYPE_STRING, message,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Unable to send StartupFailed: %s", error->message);
+ g_error_free (error);
+ }
}
static void
send_session_exited (GdmSessionWorker *worker,
- int code)
+ int code)
{
- GError *error;
- gboolean res;
-
- error = NULL;
- res = dbus_g_proxy_call (worker->priv->server_proxy,
- "SessionExited",
- &error,
- G_TYPE_INT, code,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to send SessionExited: %s", error->message);
- g_error_free (error);
- }
+ GError *error;
+ gboolean res;
+
+ error = NULL;
+ res = dbus_g_proxy_call (worker->priv->server_proxy,
+ "SessionExited",
+ &error,
+ G_TYPE_INT, code,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Unable to send SessionExited: %s", error->message);
+ g_error_free (error);
+ }
}
static void
send_session_died (GdmSessionWorker *worker,
- int num)
+ int num)
{
- GError *error;
- gboolean res;
-
- error = NULL;
- res = dbus_g_proxy_call (worker->priv->server_proxy,
- "SessionDied",
- &error,
- G_TYPE_INT, num,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to send SessionDied: %s", error->message);
- g_error_free (error);
- }
+ GError *error;
+ gboolean res;
+
+ error = NULL;
+ res = dbus_g_proxy_call (worker->priv->server_proxy,
+ "SessionDied",
+ &error,
+ G_TYPE_INT, num,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Unable to send SessionDied: %s", error->message);
+ g_error_free (error);
+ }
}
static void
send_username_changed (GdmSessionWorker *worker)
{
- GError *error;
- gboolean res;
-
- error = NULL;
- res = dbus_g_proxy_call (worker->priv->server_proxy,
- "UsernameChanged",
- &error,
- G_TYPE_STRING, worker->priv->username,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to send UsernameChanged: %s", error->message);
- g_error_free (error);
- }
+ GError *error;
+ gboolean res;
+
+ error = NULL;
+ res = dbus_g_proxy_call (worker->priv->server_proxy,
+ "UsernameChanged",
+ &error,
+ G_TYPE_STRING, worker->priv->username,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Unable to send UsernameChanged: %s", error->message);
+ g_error_free (error);
+ }
}
static void
send_user_verification_error (GdmSessionWorker *worker,
- const char *message)
+ const char *message)
{
- GError *error;
- gboolean res;
-
- error = NULL;
- res = dbus_g_proxy_call (worker->priv->server_proxy,
- "VerificationFailed",
- &error,
- G_TYPE_STRING, message,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to send VerificationFailed: %s", error->message);
- g_error_free (error);
- }
+ GError *error;
+ gboolean res;
+
+ error = NULL;
+ res = dbus_g_proxy_call (worker->priv->server_proxy,
+ "VerificationFailed",
+ &error,
+ G_TYPE_STRING, message,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Unable to send VerificationFailed: %s", error->message);
+ g_error_free (error);
+ }
}
static void
send_session_started (GdmSessionWorker *worker,
- GPid pid)
+ GPid pid)
{
- GError *error;
- gboolean res;
-
- error = NULL;
- res = dbus_g_proxy_call (worker->priv->server_proxy,
- "SessionStarted",
- &error,
- G_TYPE_INT, (int)pid,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to send SessionStarted: %s", error->message);
- g_error_free (error);
- }
+ GError *error;
+ gboolean res;
+
+ error = NULL;
+ res = dbus_g_proxy_call (worker->priv->server_proxy,
+ "SessionStarted",
+ &error,
+ G_TYPE_INT, (int)pid,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Unable to send SessionStarted: %s", error->message);
+ g_error_free (error);
+ }
}
static gboolean
gdm_session_worker_get_username (GdmSessionWorker *worker,
- char **username)
+ char **username)
{
- gconstpointer item;
-
- g_assert (worker->priv->pam_handle != NULL);
-
- if (pam_get_item (worker->priv->pam_handle, PAM_USER, &item) == PAM_SUCCESS) {
- if (username) {
- *username = g_strdup ((char *) item);
- g_debug ("username is '%s'",
- *username != NULL ? *username :
- "<unset>");
- }
- return TRUE;
- }
+ gconstpointer item;
+
+ g_assert (worker->priv->pam_handle != NULL);
+
+ if (pam_get_item (worker->priv->pam_handle, PAM_USER, &item) == PAM_SUCCESS) {
+ if (username) {
+ *username = g_strdup ((char *) item);
+ g_debug ("username is '%s'",
+ *username != NULL ? *username :
+ "<unset>");
+ }
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
static void
gdm_session_worker_update_username (GdmSessionWorker *worker)
{
- char *username;
- gboolean res;
+ char *username;
+ gboolean res;
- username = NULL;
- res = gdm_session_worker_get_username (worker, &username);
- if (res) {
- if ((worker->priv->username == username) ||
- ((worker->priv->username != NULL) && (username != NULL) &&
- (strcmp (worker->priv->username, username) == 0)))
- goto out;
+ username = NULL;
+ res = gdm_session_worker_get_username (worker, &username);
+ if (res) {
+ if ((worker->priv->username == username) ||
+ ((worker->priv->username != NULL) && (username != NULL) &&
+ (strcmp (worker->priv->username, username) == 0)))
+ goto out;
- g_debug ("setting username to '%s'", username);
+ g_debug ("setting username to '%s'", username);
- g_free (worker->priv->username);
- worker->priv->username = username;
- username = NULL;
+ g_free (worker->priv->username);
+ worker->priv->username = username;
+ username = NULL;
- send_username_changed (worker);
- }
+ send_username_changed (worker);
+ }
out:
- g_free (username);
+ g_free (username);
}
static gboolean
gdm_session_worker_ask_question (GdmSessionWorker *worker,
- const char *question,
- char **answer)
+ const char *question,
+ char **answer)
{
- GError *error;
- gboolean res;
-
- g_assert (answer != NULL);
-
- error = NULL;
- res = dbus_g_proxy_call_with_timeout (worker->priv->server_proxy,
- "InfoQuery",
- MESSAGE_REPLY_TIMEOUT,
- &error,
- G_TYPE_STRING, question,
- G_TYPE_INVALID,
- G_TYPE_STRING, answer,
- G_TYPE_INVALID);
- if (! res) {
- /* FIXME: handle timeout */
- g_warning ("Unable to send InfoQuery: %s", error->message);
- g_error_free (error);
- }
-
- return res;
+ GError *error;
+ gboolean res;
+
+ g_assert (answer != NULL);
+
+ error = NULL;
+ res = dbus_g_proxy_call_with_timeout (worker->priv->server_proxy,
+ "InfoQuery",
+ MESSAGE_REPLY_TIMEOUT,
+ &error,
+ G_TYPE_STRING, question,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, answer,
+ G_TYPE_INVALID);
+ if (! res) {
+ /* FIXME: handle timeout */
+ g_warning ("Unable to send InfoQuery: %s", error->message);
+ g_error_free (error);
+ }
+
+ return res;
}
static gboolean
gdm_session_worker_ask_for_secret (GdmSessionWorker *worker,
- const char *secret,
- char **answer)
+ const char *secret,
+ char **answer)
{
- GError *error;
- gboolean res;
-
- g_debug ("Secret info query: %s", secret);
-
- g_assert (answer != NULL);
-
- error = NULL;
- res = dbus_g_proxy_call_with_timeout (worker->priv->server_proxy,
- "SecretInfoQuery",
- MESSAGE_REPLY_TIMEOUT,
- &error,
- G_TYPE_STRING, secret,
- G_TYPE_INVALID,
- G_TYPE_STRING, answer,
- G_TYPE_INVALID);
- if (! res) {
- /* FIXME: handle timeout */
- g_warning ("Unable to send SecretInfoQuery: %s", error->message);
- g_error_free (error);
- }
-
- return res;
+ GError *error;
+ gboolean res;
+
+ g_debug ("Secret info query: %s", secret);
+
+ g_assert (answer != NULL);
+
+ error = NULL;
+ res = dbus_g_proxy_call_with_timeout (worker->priv->server_proxy,
+ "SecretInfoQuery",
+ MESSAGE_REPLY_TIMEOUT,
+ &error,
+ G_TYPE_STRING, secret,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, answer,
+ G_TYPE_INVALID);
+ if (! res) {
+ /* FIXME: handle timeout */
+ g_warning ("Unable to send SecretInfoQuery: %s", error->message);
+ g_error_free (error);
+ }
+
+ return res;
}
static gboolean
gdm_session_worker_report_info (GdmSessionWorker *worker,
- const char *info)
+ const char *info)
{
- GError *error;
- gboolean res;
-
- g_debug ("Info: %s", info);
-
- error = NULL;
- res = dbus_g_proxy_call (worker->priv->server_proxy,
- "Info",
- &error,
- G_TYPE_STRING, info,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to send Info: %s", error->message);
- g_error_free (error);
- }
-
- return res;
+ GError *error;
+ gboolean res;
+
+ g_debug ("Info: %s", info);
+
+ error = NULL;
+ res = dbus_g_proxy_call (worker->priv->server_proxy,
+ "Info",
+ &error,
+ G_TYPE_STRING, info,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Unable to send Info: %s", error->message);
+ g_error_free (error);
+ }
+
+ return res;
}
static gboolean
gdm_session_worker_report_problem (GdmSessionWorker *worker,
- const char *problem)
+ const char *problem)
{
- GError *error;
- gboolean res;
-
- g_debug ("Problem: %s", problem);
-
- error = NULL;
- res = dbus_g_proxy_call (worker->priv->server_proxy,
- "Problem",
- &error,
- G_TYPE_STRING, problem,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to send Problem: %s", error->message);
- g_error_free (error);
- }
-
- return res;
+ GError *error;
+ gboolean res;
+
+ g_debug ("Problem: %s", problem);
+
+ error = NULL;
+ res = dbus_g_proxy_call (worker->priv->server_proxy,
+ "Problem",
+ &error,
+ G_TYPE_STRING, problem,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Unable to send Problem: %s", error->message);
+ g_error_free (error);
+ }
+
+ return res;
}
static char *
convert_to_utf8 (const char *str)
{
- char *utf8;
- utf8 = g_locale_to_utf8 (str,
- -1,
- NULL,
- NULL,
- NULL);
-
- /* if we couldn't convert text from locale then
- * assume utf-8 and hope for the best */
- if (utf8 == NULL) {
- char *p;
- char *q;
-
- utf8 = g_strdup (str);
-
- p = utf8;
- while (*p != '\0' && !g_utf8_validate ((const char *)p, -1, (const char **)&q)) {
- *q = '?';
- p = q + 1;
- }
- }
-
- return utf8;
+ char *utf8;
+ utf8 = g_locale_to_utf8 (str,
+ -1,
+ NULL,
+ NULL,
+ NULL);
+
+ /* if we couldn't convert text from locale then
+ * assume utf-8 and hope for the best */
+ if (utf8 == NULL) {
+ char *p;
+ char *q;
+
+ utf8 = g_strdup (str);
+
+ p = utf8;
+ while (*p != '\0' && !g_utf8_validate ((const char *)p, -1, (const char **)&q)) {
+ *q = '?';
+ p = q + 1;
+ }
+ }
+
+ return utf8;
}
static gboolean
gdm_session_worker_process_pam_message (GdmSessionWorker *worker,
- const struct pam_message *query,
- char **response_text)
+ const struct pam_message *query,
+ char **response_text)
{
- char *user_answer;
- gboolean res;
- char *utf8_msg;
-
- if (response_text != NULL) {
- *response_text = NULL;
- }
-
- g_debug ("received pam message of type %u with payload '%s'",
- query->msg_style, query->msg);
-
- utf8_msg = convert_to_utf8 (query->msg);
-
- user_answer = NULL;
- res = FALSE;
- switch (query->msg_style) {
- case PAM_PROMPT_ECHO_ON:
- res = gdm_session_worker_ask_question (worker, utf8_msg, &user_answer);
- break;
- case PAM_PROMPT_ECHO_OFF:
- res = gdm_session_worker_ask_for_secret (worker, utf8_msg, &user_answer);
- break;
- case PAM_TEXT_INFO:
- res = gdm_session_worker_report_info (worker, utf8_msg);
- break;
- case PAM_ERROR_MSG:
- res = gdm_session_worker_report_problem (worker, utf8_msg);
- break;
- default:
- g_debug ("unknown query of type %u\n", query->msg_style);
- break;
- }
-
- if (user_answer != NULL) {
- /* we strdup and g_free to make sure we return malloc'd
- * instead of g_malloc'd memory
- */
- if (res && response_text != NULL) {
- *response_text = strdup (user_answer);
- }
-
- g_free (user_answer);
-
- g_debug ("trying to get updated username");
- gdm_session_worker_update_username (worker);
- res = TRUE;
- }
-
- g_free (utf8_msg);
-
- return res;
+ char *user_answer;
+ gboolean res;
+ char *utf8_msg;
+
+ if (response_text != NULL) {
+ *response_text = NULL;
+ }
+
+ g_debug ("received pam message of type %u with payload '%s'",
+ query->msg_style, query->msg);
+
+ utf8_msg = convert_to_utf8 (query->msg);
+
+ user_answer = NULL;
+ res = FALSE;
+ switch (query->msg_style) {
+ case PAM_PROMPT_ECHO_ON:
+ res = gdm_session_worker_ask_question (worker, utf8_msg, &user_answer);
+ break;
+ case PAM_PROMPT_ECHO_OFF:
+ res = gdm_session_worker_ask_for_secret (worker, utf8_msg, &user_answer);
+ break;
+ case PAM_TEXT_INFO:
+ res = gdm_session_worker_report_info (worker, utf8_msg);
+ break;
+ case PAM_ERROR_MSG:
+ res = gdm_session_worker_report_problem (worker, utf8_msg);
+ break;
+ default:
+ g_debug ("unknown query of type %u\n", query->msg_style);
+ break;
+ }
+
+ if (user_answer != NULL) {
+ /* we strdup and g_free to make sure we return malloc'd
+ * instead of g_malloc'd memory
+ */
+ if (res && response_text != NULL) {
+ *response_text = strdup (user_answer);
+ }
+
+ g_free (user_answer);
+
+ g_debug ("trying to get updated username");
+ gdm_session_worker_update_username (worker);
+ res = TRUE;
+ }
+
+ g_free (utf8_msg);
+
+ return res;
}
static int
gdm_session_worker_pam_new_messages_handler (int number_of_messages,
- const struct pam_message **messages,
- struct pam_response **responses,
- GdmSessionWorker *worker)
+ const struct pam_message **messages,
+ struct pam_response **responses,
+ GdmSessionWorker *worker)
{
- struct pam_response *replies;
- int return_value;
- int i;
+ struct pam_response *replies;
+ int return_value;
+ int i;
- g_debug ("%d new messages received from PAM\n", number_of_messages);
+ g_debug ("%d new messages received from PAM\n", number_of_messages);
- return_value = PAM_CONV_ERR;
+ return_value = PAM_CONV_ERR;
- if (number_of_messages < 0) {
- return PAM_CONV_ERR;
- }
+ if (number_of_messages < 0) {
+ return PAM_CONV_ERR;
+ }
- if (number_of_messages == 0) {
- if (responses) {
- *responses = NULL;
- }
+ if (number_of_messages == 0) {
+ if (responses) {
+ *responses = NULL;
+ }
- return PAM_SUCCESS;
- }
+ return PAM_SUCCESS;
+ }
- /* we want to generate one reply for every question
- */
- replies = (struct pam_response *) calloc (number_of_messages,
- sizeof (struct pam_response));
- for (i = 0; i < number_of_messages; i++) {
- gboolean got_response;
- char *response_text;
+ /* we want to generate one reply for every question
+ */
+ replies = (struct pam_response *) calloc (number_of_messages,
+ sizeof (struct pam_response));
+ for (i = 0; i < number_of_messages; i++) {
+ gboolean got_response;
+ char *response_text;
+
+ response_text = NULL;
+ got_response = gdm_session_worker_process_pam_message (worker,
+ messages[i],
+ &response_text);
+ if (!got_response) {
+ goto out;
+ }
+
+ replies[i].resp = response_text;
+ replies[i].resp_retcode = PAM_SUCCESS;
+ }
- response_text = NULL;
- got_response = gdm_session_worker_process_pam_message (worker,
- messages[i],
- &response_text);
- if (!got_response) {
- goto out;
- }
+ return_value = PAM_SUCCESS;
+
+ out:
+ if (return_value != PAM_SUCCESS) {
+ for (i = 0; i < number_of_messages; i++) {
+ if (replies[i].resp != NULL) {
+ memset (replies[i].resp, 0, strlen (replies[i].resp));
+ free (replies[i].resp);
+ }
+ memset (&replies[i], 0, sizeof (replies[i]));
+ }
+ free (replies);
+ replies = NULL;
+ }
- replies[i].resp = response_text;
- replies[i].resp_retcode = PAM_SUCCESS;
- }
+ if (responses) {
+ *responses = replies;
+ }
- return_value = PAM_SUCCESS;
+ g_debug ("PAM conversation returning %d", return_value);
- out:
- if (return_value != PAM_SUCCESS) {
- for (i = 0; i < number_of_messages; i++) {
- if (replies[i].resp != NULL) {
- memset (replies[i].resp, 0, strlen (replies[i].resp));
- free (replies[i].resp);
- }
- memset (&replies[i], 0, sizeof (replies[i]));
- }
- free (replies);
- replies = NULL;
- }
-
- if (responses) {
- *responses = replies;
- }
-
- g_debug ("PAM conversation returning %d", return_value);
-
- return return_value;
+ return return_value;
}
static void
gdm_session_worker_uninitialize_pam (GdmSessionWorker *worker,
- int error_code)
+ int error_code)
{
- g_debug ("uninitializing PAM");
+ g_debug ("uninitializing PAM");
- if (worker->priv->pam_handle == NULL)
- return;
+ if (worker->priv->pam_handle == NULL)
+ return;
- if (worker->priv->credentials_are_established) {
- pam_setcred (worker->priv->pam_handle, PAM_DELETE_CRED);
- worker->priv->credentials_are_established = FALSE;
- }
+ if (worker->priv->credentials_are_established) {
+ pam_setcred (worker->priv->pam_handle, PAM_DELETE_CRED);
+ worker->priv->credentials_are_established = FALSE;
+ }
- if (worker->priv->is_running) {
- pam_close_session (worker->priv->pam_handle, 0);
- worker->priv->is_running = FALSE;
- }
+ if (worker->priv->is_running) {
+ pam_close_session (worker->priv->pam_handle, 0);
+ worker->priv->is_running = FALSE;
+ }
- pam_end (worker->priv->pam_handle, error_code);
- worker->priv->pam_handle = NULL;
+ pam_end (worker->priv->pam_handle, error_code);
+ worker->priv->pam_handle = NULL;
}
static gboolean
gdm_session_worker_initialize_pam (GdmSessionWorker *worker,
- const char *service,
- const char *username,
- const char *hostname,
- const char *console_name,
- GError **error)
+ const char *service,
+ const char *username,
+ const char *hostname,
+ const char *console_name,
+ GError **error)
{
- struct pam_conv pam_conversation;
- int error_code;
-
- g_assert (worker->priv->pam_handle == NULL);
-
- g_debug ("initializing PAM");
-
- pam_conversation.conv = (GdmSessionWorkerPamNewMessagesFunc) gdm_session_worker_pam_new_messages_handler;
- pam_conversation.appdata_ptr = worker;
-
- error_code = pam_start (service,
- username,
- &pam_conversation,
- &worker->priv->pam_handle);
-
- if (error_code != PAM_SUCCESS) {
- g_debug ("could not initialize pam");
- /* we don't use pam_strerror here because it requires a valid
- * pam handle, and if pam_start fails pam_handle is undefined
- */
- g_set_error (error,
- GDM_SESSION_WORKER_ERROR,
- GDM_SESSION_WORKER_ERROR_AUTHENTICATING,
- _("error initiating conversation with authentication system - %s"),
- error_code == PAM_ABORT? _("general failure") :
- error_code == PAM_BUF_ERR? _("out of memory") :
- error_code == PAM_SYSTEM_ERR? _("application programmer error") :
- _("unscoped error"));
-
- goto out;
- }
-
- if (username == NULL) {
- error_code = pam_set_item (worker->priv->pam_handle, PAM_USER_PROMPT, _("Username:"));
-
- if (error_code != PAM_SUCCESS) {
- g_set_error (error,
- GDM_SESSION_WORKER_ERROR,
- GDM_SESSION_WORKER_ERROR_AUTHENTICATING,
- _("error informing authentication system of preferred username prompt - %s"),
- pam_strerror (worker->priv->pam_handle, error_code));
- goto out;
- }
- }
-
- if (hostname != NULL) {
- error_code = pam_set_item (worker->priv->pam_handle, PAM_RHOST, hostname);
-
- if (error_code != PAM_SUCCESS) {
- g_set_error (error,
- GDM_SESSION_WORKER_ERROR,
- GDM_SESSION_WORKER_ERROR_AUTHENTICATING,
- _("error informing authentication system of user's hostname - %s"),
- pam_strerror (worker->priv->pam_handle, error_code));
- goto out;
- }
- }
-
- error_code = pam_set_item (worker->priv->pam_handle, PAM_TTY, console_name);
-
- if (error_code != PAM_SUCCESS) {
- g_set_error (error,
- GDM_SESSION_WORKER_ERROR,
- GDM_SESSION_WORKER_ERROR_AUTHENTICATING,
- _("error informing authentication system of user's console - %s"),
- pam_strerror (worker->priv->pam_handle, error_code));
- goto out;
- }
+ struct pam_conv pam_conversation;
+ int error_code;
+
+ g_assert (worker->priv->pam_handle == NULL);
+
+ g_debug ("initializing PAM");
+
+ pam_conversation.conv = (GdmSessionWorkerPamNewMessagesFunc) gdm_session_worker_pam_new_messages_handler;
+ pam_conversation.appdata_ptr = worker;
+
+ error_code = pam_start (service,
+ username,
+ &pam_conversation,
+ &worker->priv->pam_handle);
+
+ if (error_code != PAM_SUCCESS) {
+ g_debug ("could not initialize pam");
+ /* we don't use pam_strerror here because it requires a valid
+ * pam handle, and if pam_start fails pam_handle is undefined
+ */
+ g_set_error (error,
+ GDM_SESSION_WORKER_ERROR,
+ GDM_SESSION_WORKER_ERROR_AUTHENTICATING,
+ _("error initiating conversation with authentication system - %s"),
+ error_code == PAM_ABORT? _("general failure") :
+ error_code == PAM_BUF_ERR? _("out of memory") :
+ error_code == PAM_SYSTEM_ERR? _("application programmer error") :
+ _("unscoped error"));
+
+ goto out;
+ }
+
+ if (username == NULL) {
+ error_code = pam_set_item (worker->priv->pam_handle, PAM_USER_PROMPT, _("Username:"));
+
+ if (error_code != PAM_SUCCESS) {
+ g_set_error (error,
+ GDM_SESSION_WORKER_ERROR,
+ GDM_SESSION_WORKER_ERROR_AUTHENTICATING,
+ _("error informing authentication system of preferred username prompt - %s"),
+ pam_strerror (worker->priv->pam_handle, error_code));
+ goto out;
+ }
+ }
+
+ if (hostname != NULL) {
+ error_code = pam_set_item (worker->priv->pam_handle, PAM_RHOST, hostname);
+
+ if (error_code != PAM_SUCCESS) {
+ g_set_error (error,
+ GDM_SESSION_WORKER_ERROR,
+ GDM_SESSION_WORKER_ERROR_AUTHENTICATING,
+ _("error informing authentication system of user's hostname - %s"),
+ pam_strerror (worker->priv->pam_handle, error_code));
+ goto out;
+ }
+ }
+
+ error_code = pam_set_item (worker->priv->pam_handle, PAM_TTY, console_name);
+
+ if (error_code != PAM_SUCCESS) {
+ g_set_error (error,
+ GDM_SESSION_WORKER_ERROR,
+ GDM_SESSION_WORKER_ERROR_AUTHENTICATING,
+ _("error informing authentication system of user's console - %s"),
+ pam_strerror (worker->priv->pam_handle, error_code));
+ goto out;
+ }
out:
- if (error_code != PAM_SUCCESS) {
- gdm_session_worker_uninitialize_pam (worker, error_code);
- return FALSE;
- }
+ if (error_code != PAM_SUCCESS) {
+ gdm_session_worker_uninitialize_pam (worker, error_code);
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_session_worker_authenticate_user (GdmSessionWorker *worker,
- gboolean password_is_required,
- GError **error)
+ gboolean password_is_required,
+ GError **error)
{
- int error_code;
- int authentication_flags;
+ int error_code;
+ int authentication_flags;
- g_debug ("authenticating user");
+ g_debug ("authenticating user");
- authentication_flags = 0;
+ authentication_flags = 0;
- if (password_is_required) {
- authentication_flags |= PAM_DISALLOW_NULL_AUTHTOK;
- }
+ if (password_is_required) {
+ authentication_flags |= PAM_DISALLOW_NULL_AUTHTOK;
+ }
- /* blocking call, does the actual conversation
- */
- error_code = pam_authenticate (worker->priv->pam_handle, authentication_flags);
+ /* blocking call, does the actual conversation
+ */
+ error_code = pam_authenticate (worker->priv->pam_handle, authentication_flags);
- if (error_code != PAM_SUCCESS) {
- g_debug ("authentication returned %d: %s", error_code, pam_strerror (worker->priv->pam_handle, error_code));
+ if (error_code != PAM_SUCCESS) {
+ g_debug ("authentication returned %d: %s", error_code, pam_strerror (worker->priv->pam_handle, error_code));
- g_set_error (error,
- GDM_SESSION_WORKER_ERROR,
- GDM_SESSION_WORKER_ERROR_AUTHENTICATING,
- "%s", pam_strerror (worker->priv->pam_handle, error_code));
- goto out;
- }
+ g_set_error (error,
+ GDM_SESSION_WORKER_ERROR,
+ GDM_SESSION_WORKER_ERROR_AUTHENTICATING,
+ "%s", pam_strerror (worker->priv->pam_handle, error_code));
+ goto out;
+ }
out:
- if (error_code != PAM_SUCCESS) {
- gdm_session_worker_uninitialize_pam (worker, error_code);
- return FALSE;
- }
+ if (error_code != PAM_SUCCESS) {
+ gdm_session_worker_uninitialize_pam (worker, error_code);
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_session_worker_authorize_user (GdmSessionWorker *worker,
- gboolean password_is_required,
- GError **error)
+ gboolean password_is_required,
+ GError **error)
{
- int error_code;
- int authentication_flags;
-
- g_debug ("determining if authenticated user is authorized to session");
+ int error_code;
+ int authentication_flags;
- authentication_flags = 0;
+ g_debug ("determining if authenticated user is authorized to session");
- if (password_is_required) {
- authentication_flags |= PAM_DISALLOW_NULL_AUTHTOK;
- }
+ authentication_flags = 0;
- /* check that the account isn't disabled or expired
- */
- error_code = pam_acct_mgmt (worker->priv->pam_handle, authentication_flags);
-
- /* it's possible that the user needs to change their password or pin code
- */
- if (error_code == PAM_NEW_AUTHTOK_REQD)
- error_code = pam_chauthtok (worker->priv->pam_handle, PAM_CHANGE_EXPIRED_AUTHTOK);
+ if (password_is_required) {
+ authentication_flags |= PAM_DISALLOW_NULL_AUTHTOK;
+ }
- if (error_code != PAM_SUCCESS) {
- g_debug ("user is not authorized to log in: %s",
- pam_strerror (worker->priv->pam_handle, error_code));
- g_set_error (error,
- GDM_SESSION_WORKER_ERROR,
- GDM_SESSION_WORKER_ERROR_AUTHORIZING,
- "%s", pam_strerror (worker->priv->pam_handle, error_code));
- goto out;
- }
+ /* check that the account isn't disabled or expired
+ */
+ error_code = pam_acct_mgmt (worker->priv->pam_handle, authentication_flags);
+
+ /* it's possible that the user needs to change their password or pin code
+ */
+ if (error_code == PAM_NEW_AUTHTOK_REQD)
+ error_code = pam_chauthtok (worker->priv->pam_handle, PAM_CHANGE_EXPIRED_AUTHTOK);
+
+ if (error_code != PAM_SUCCESS) {
+ g_debug ("user is not authorized to log in: %s",
+ pam_strerror (worker->priv->pam_handle, error_code));
+ g_set_error (error,
+ GDM_SESSION_WORKER_ERROR,
+ GDM_SESSION_WORKER_ERROR_AUTHORIZING,
+ "%s", pam_strerror (worker->priv->pam_handle, error_code));
+ goto out;
+ }
out:
- if (error_code != PAM_SUCCESS) {
- gdm_session_worker_uninitialize_pam (worker, error_code);
- return FALSE;
- }
+ if (error_code != PAM_SUCCESS) {
+ gdm_session_worker_uninitialize_pam (worker, error_code);
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
static void
gdm_session_worker_set_environment_variable (GdmSessionWorker *worker,
- const char *key,
- const char *value)
+ const char *key,
+ const char *value)
{
- /* FIXME: maybe we should use use pam_putenv instead of our
- * own hash table, so pam can override our choices if it knows
- * better?
- */
- g_hash_table_replace (worker->priv->environment,
- g_strdup (key),
- g_strdup (value));
+ /* FIXME: maybe we should use use pam_putenv instead of our
+ * own hash table, so pam can override our choices if it knows
+ * better?
+ */
+ g_hash_table_replace (worker->priv->environment,
+ g_strdup (key),
+ g_strdup (value));
}
static void
gdm_session_worker_update_environment_from_passwd_entry (GdmSessionWorker *worker,
- struct passwd *passwd_entry)
+ struct passwd *passwd_entry)
{
- gdm_session_worker_set_environment_variable (worker, "LOGNAME", worker->priv->username);
- gdm_session_worker_set_environment_variable (worker, "USER", worker->priv->username);
- gdm_session_worker_set_environment_variable (worker, "USERNAME", worker->priv->username);
- gdm_session_worker_set_environment_variable (worker, "HOME", passwd_entry->pw_dir);
- gdm_session_worker_set_environment_variable (worker, "SHELL", passwd_entry->pw_shell);
+ gdm_session_worker_set_environment_variable (worker, "LOGNAME", worker->priv->username);
+ gdm_session_worker_set_environment_variable (worker, "USER", worker->priv->username);
+ gdm_session_worker_set_environment_variable (worker, "USERNAME", worker->priv->username);
+ gdm_session_worker_set_environment_variable (worker, "HOME", passwd_entry->pw_dir);
+ gdm_session_worker_set_environment_variable (worker, "SHELL", passwd_entry->pw_shell);
}
static gboolean
gdm_session_worker_environment_variable_is_set (GdmSessionWorker *worker,
- const char *name)
+ const char *name)
{
- return g_hash_table_lookup (worker->priv->environment, name) != NULL;
+ return g_hash_table_lookup (worker->priv->environment, name) != NULL;
}
static gboolean
gdm_session_worker_give_user_credentials (GdmSessionWorker *worker,
- GError **error)
+ GError **error)
{
- int error_code;
- struct passwd *passwd_entry;
- struct passwd passwd_buffer;
- char *aux_buffer;
- long required_aux_buffer_size;
- gsize aux_buffer_size;
-
- aux_buffer = NULL;
- aux_buffer_size = 0;
-
- if (worker->priv->username == NULL) {
- error_code = PAM_USER_UNKNOWN;
- g_set_error (error,
- GDM_SESSION_WORKER_ERROR,
- GDM_SESSION_WORKER_ERROR_GIVING_CREDENTIALS,
- _("no user account available"));
- goto out;
- }
-
- required_aux_buffer_size = sysconf (_SC_GETPW_R_SIZE_MAX);
-
- if (required_aux_buffer_size < 0)
- aux_buffer_size = GDM_PASSWD_AUXILLARY_BUFFER_SIZE;
- else
- aux_buffer_size = (gsize) required_aux_buffer_size;
-
- aux_buffer = g_slice_alloc0 (aux_buffer_size);
-
- /* we use the _r variant of getpwnam()
- * (with its weird semantics) so that the
- * passwd_entry doesn't potentially get stomped on
- * by a PAM module
- */
- passwd_entry = NULL;
+ int error_code;
+ struct passwd *passwd_entry;
+ struct passwd passwd_buffer;
+ char *aux_buffer;
+ long required_aux_buffer_size;
+ gsize aux_buffer_size;
+
+ aux_buffer = NULL;
+ aux_buffer_size = 0;
+
+ if (worker->priv->username == NULL) {
+ error_code = PAM_USER_UNKNOWN;
+ g_set_error (error,
+ GDM_SESSION_WORKER_ERROR,
+ GDM_SESSION_WORKER_ERROR_GIVING_CREDENTIALS,
+ _("no user account available"));
+ goto out;
+ }
+
+ required_aux_buffer_size = sysconf (_SC_GETPW_R_SIZE_MAX);
+
+ if (required_aux_buffer_size < 0)
+ aux_buffer_size = GDM_PASSWD_AUXILLARY_BUFFER_SIZE;
+ else
+ aux_buffer_size = (gsize) required_aux_buffer_size;
+
+ aux_buffer = g_slice_alloc0 (aux_buffer_size);
+
+ /* we use the _r variant of getpwnam()
+ * (with its weird semantics) so that the
+ * passwd_entry doesn't potentially get stomped on
+ * by a PAM module
+ */
+ passwd_entry = NULL;
#ifdef HAVE_POSIX_GETPWNAM_R
errno = getpwnam_r (worker->priv->username,
- &passwd_buffer,
+ &passwd_buffer,
aux_buffer,
- (size_t) aux_buffer_size,
+ (size_t) aux_buffer_size,
&passwd_entry);
#else
passwd_entry = getpwnam_r (worker->priv->username,
- &passwd_buffer,
+ &passwd_buffer,
aux_buffer,
- (size_t) aux_buffer_size);
+ (size_t) aux_buffer_size);
errno = 0;
#endif /* !HAVE_POSIX_GETPWNAM_R */
- if (errno != 0) {
- error_code = PAM_SYSTEM_ERR;
- g_set_error (error,
- GDM_SESSION_WORKER_ERROR,
- GDM_SESSION_WORKER_ERROR_GIVING_CREDENTIALS,
- "%s",
- g_strerror (errno));
- goto out;
- }
-
- if (passwd_entry == NULL) {
- error_code = PAM_USER_UNKNOWN;
- g_set_error (error,
- GDM_SESSION_WORKER_ERROR,
- GDM_SESSION_WORKER_ERROR_GIVING_CREDENTIALS,
- _("user account not available on system"));
- goto out;
- }
-
- gdm_session_worker_update_environment_from_passwd_entry (worker, passwd_entry);
-
- /* Let's give the user a default PATH if he doesn't already have one
- */
- if (!gdm_session_worker_environment_variable_is_set (worker, "PATH")) {
- gdm_session_worker_set_environment_variable (worker, "PATH", GDM_SESSION_DEFAULT_PATH);
- }
-
- /* pam_setcred wants to be called as the authenticated user
- * but pam_open_session needs to be called as super-user.
- *
- * Set the real uid and gid to the user and give the user a
- * temporary super-user effective id.
- */
- if (setreuid (passwd_entry->pw_uid, GDM_SESSION_ROOT_UID) < 0) {
- error_code = PAM_SYSTEM_ERR;
- g_set_error (error, GDM_SESSION_WORKER_ERROR,
- GDM_SESSION_WORKER_ERROR_GIVING_CREDENTIALS,
- "%s", g_strerror (errno));
- goto out;
- }
-
- if (setgid (passwd_entry->pw_gid) < 0) {
- error_code = PAM_SYSTEM_ERR;
- g_set_error (error, GDM_SESSION_WORKER_ERROR,
- GDM_SESSION_WORKER_ERROR_GIVING_CREDENTIALS,
- "%s", g_strerror (errno));
- goto out;
- }
-
- if (initgroups (passwd_entry->pw_name, passwd_entry->pw_gid) < 0) {
- error_code = PAM_SYSTEM_ERR;
- g_set_error (error, GDM_SESSION_WORKER_ERROR,
- GDM_SESSION_WORKER_ERROR_GIVING_CREDENTIALS,
- "%s", g_strerror (errno));
- goto out;
- }
-
- error_code = pam_setcred (worker->priv->pam_handle, PAM_ESTABLISH_CRED);
-
- if (error_code != PAM_SUCCESS) {
- g_set_error (error,
- GDM_SESSION_WORKER_ERROR,
- GDM_SESSION_WORKER_ERROR_GIVING_CREDENTIALS,
- "%s",
- pam_strerror (worker->priv->pam_handle, error_code));
- goto out;
- }
-
- worker->priv->credentials_are_established = TRUE;
+ if (errno != 0) {
+ error_code = PAM_SYSTEM_ERR;
+ g_set_error (error,
+ GDM_SESSION_WORKER_ERROR,
+ GDM_SESSION_WORKER_ERROR_GIVING_CREDENTIALS,
+ "%s",
+ g_strerror (errno));
+ goto out;
+ }
+
+ if (passwd_entry == NULL) {
+ error_code = PAM_USER_UNKNOWN;
+ g_set_error (error,
+ GDM_SESSION_WORKER_ERROR,
+ GDM_SESSION_WORKER_ERROR_GIVING_CREDENTIALS,
+ _("user account not available on system"));
+ goto out;
+ }
+
+ gdm_session_worker_update_environment_from_passwd_entry (worker, passwd_entry);
+
+ /* Let's give the user a default PATH if he doesn't already have one
+ */
+ if (!gdm_session_worker_environment_variable_is_set (worker, "PATH")) {
+ gdm_session_worker_set_environment_variable (worker, "PATH", GDM_SESSION_DEFAULT_PATH);
+ }
+
+ /* pam_setcred wants to be called as the authenticated user
+ * but pam_open_session needs to be called as super-user.
+ *
+ * Set the real uid and gid to the user and give the user a
+ * temporary super-user effective id.
+ */
+ if (setreuid (passwd_entry->pw_uid, GDM_SESSION_ROOT_UID) < 0) {
+ error_code = PAM_SYSTEM_ERR;
+ g_set_error (error, GDM_SESSION_WORKER_ERROR,
+ GDM_SESSION_WORKER_ERROR_GIVING_CREDENTIALS,
+ "%s", g_strerror (errno));
+ goto out;
+ }
+
+ if (setgid (passwd_entry->pw_gid) < 0) {
+ error_code = PAM_SYSTEM_ERR;
+ g_set_error (error, GDM_SESSION_WORKER_ERROR,
+ GDM_SESSION_WORKER_ERROR_GIVING_CREDENTIALS,
+ "%s", g_strerror (errno));
+ goto out;
+ }
+
+ if (initgroups (passwd_entry->pw_name, passwd_entry->pw_gid) < 0) {
+ error_code = PAM_SYSTEM_ERR;
+ g_set_error (error, GDM_SESSION_WORKER_ERROR,
+ GDM_SESSION_WORKER_ERROR_GIVING_CREDENTIALS,
+ "%s", g_strerror (errno));
+ goto out;
+ }
+
+ error_code = pam_setcred (worker->priv->pam_handle, PAM_ESTABLISH_CRED);
+
+ if (error_code != PAM_SUCCESS) {
+ g_set_error (error,
+ GDM_SESSION_WORKER_ERROR,
+ GDM_SESSION_WORKER_ERROR_GIVING_CREDENTIALS,
+ "%s",
+ pam_strerror (worker->priv->pam_handle, error_code));
+ goto out;
+ }
+
+ worker->priv->credentials_are_established = TRUE;
out:
- if (aux_buffer != NULL) {
- g_assert (aux_buffer_size > 0);
- g_slice_free1 (aux_buffer_size, aux_buffer);
- }
+ if (aux_buffer != NULL) {
+ g_assert (aux_buffer_size > 0);
+ g_slice_free1 (aux_buffer_size, aux_buffer);
+ }
- if (error_code != PAM_SUCCESS) {
- gdm_session_worker_uninitialize_pam (worker, error_code);
- return FALSE;
- }
+ if (error_code != PAM_SUCCESS) {
+ gdm_session_worker_uninitialize_pam (worker, error_code);
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_session_worker_verify_user (GdmSessionWorker *worker,
- const char *service_name,
- const char *hostname,
- const char *console_name,
- const char *username,
- gboolean password_is_required,
- GError **error)
+ const char *service_name,
+ const char *hostname,
+ const char *console_name,
+ const char *username,
+ gboolean password_is_required,
+ GError **error)
{
- GError *pam_error;
- gboolean res;
-
- g_debug ("Verifying user: %s host: %s service: %s tty: %s", username, hostname, service_name, console_name);
-
- pam_error = NULL;
- res = gdm_session_worker_initialize_pam (worker,
- service_name,
- username,
- hostname,
- console_name,
- &pam_error);
- if (! res) {
- g_propagate_error (error, pam_error);
- return FALSE;
- }
-
- /* find out who the user is and ensure they are who they say they are
- */
- res = gdm_session_worker_authenticate_user (worker,
- password_is_required,
- &pam_error);
- if (! res) {
- g_debug ("Unable to verify user");
- g_propagate_error (error, pam_error);
- return FALSE;
- }
-
- /* we're authenticated. Let's make sure we've been given
- * a valid username for the system
- */
- g_debug ("trying to get updated username");
- gdm_session_worker_update_username (worker);
-
- /* make sure the user is allowed to log in to this system
- */
- res = gdm_session_worker_authorize_user (worker,
- password_is_required,
- &pam_error);
- if (! res) {
- g_propagate_error (error, pam_error);
- return FALSE;
- }
-
- /* get kerberos tickets, setup group lists, etc
- */
- res = gdm_session_worker_give_user_credentials (worker, &pam_error);
- if (! res) {
- g_propagate_error (error, pam_error);
- return FALSE;
- }
-
- g_debug ("verification process completed, creating reply...");
-
- send_user_verified (worker);
-
- return TRUE;
+ GError *pam_error;
+ gboolean res;
+
+ g_debug ("Verifying user: %s host: %s service: %s tty: %s", username, hostname, service_name, console_name);
+
+ pam_error = NULL;
+ res = gdm_session_worker_initialize_pam (worker,
+ service_name,
+ username,
+ hostname,
+ console_name,
+ &pam_error);
+ if (! res) {
+ g_propagate_error (error, pam_error);
+ return FALSE;
+ }
+
+ /* find out who the user is and ensure they are who they say they are
+ */
+ res = gdm_session_worker_authenticate_user (worker,
+ password_is_required,
+ &pam_error);
+ if (! res) {
+ g_debug ("Unable to verify user");
+ g_propagate_error (error, pam_error);
+ return FALSE;
+ }
+
+ /* we're authenticated. Let's make sure we've been given
+ * a valid username for the system
+ */
+ g_debug ("trying to get updated username");
+ gdm_session_worker_update_username (worker);
+
+ /* make sure the user is allowed to log in to this system
+ */
+ res = gdm_session_worker_authorize_user (worker,
+ password_is_required,
+ &pam_error);
+ if (! res) {
+ g_propagate_error (error, pam_error);
+ return FALSE;
+ }
+
+ /* get kerberos tickets, setup group lists, etc
+ */
+ res = gdm_session_worker_give_user_credentials (worker, &pam_error);
+ if (! res) {
+ g_propagate_error (error, pam_error);
+ return FALSE;
+ }
+
+ g_debug ("verification process completed, creating reply...");
+
+ send_user_verified (worker);
+
+ return TRUE;
}
static void
gdm_session_worker_update_environment_from_pam (GdmSessionWorker *worker)
{
- char **environment;
- gsize i;
+ char **environment;
+ gsize i;
- environment = pam_getenvlist (worker->priv->pam_handle);
+ environment = pam_getenvlist (worker->priv->pam_handle);
- for (i = 0; environment[i] != NULL; i++) {
- char **key_and_value;
+ for (i = 0; environment[i] != NULL; i++) {
+ char **key_and_value;
- key_and_value = g_strsplit (environment[i], "=", 2);
+ key_and_value = g_strsplit (environment[i], "=", 2);
- gdm_session_worker_set_environment_variable (worker, key_and_value[0], key_and_value[1]);
+ gdm_session_worker_set_environment_variable (worker, key_and_value[0], key_and_value[1]);
- g_strfreev (key_and_value);
- }
+ g_strfreev (key_and_value);
+ }
- for (i = 0; environment[i]; i++) {
- free (environment[i]);
- }
+ for (i = 0; environment[i]; i++) {
+ free (environment[i]);
+ }
- free (environment);
+ free (environment);
}
static void
gdm_session_worker_fill_environment_array (const char *key,
- const char *value,
- GPtrArray *environment)
+ const char *value,
+ GPtrArray *environment)
{
- char *variable;
+ char *variable;
- if (value == NULL)
- return;
+ if (value == NULL)
+ return;
- variable = g_strdup_printf ("%s=%s", key, value);
+ variable = g_strdup_printf ("%s=%s", key, value);
- g_ptr_array_add (environment, variable);
+ g_ptr_array_add (environment, variable);
}
static char **
gdm_session_worker_get_environment (GdmSessionWorker *worker)
{
- GPtrArray *environment;
+ GPtrArray *environment;
- environment = g_ptr_array_new ();
- g_hash_table_foreach (worker->priv->environment,
- (GHFunc) gdm_session_worker_fill_environment_array,
- environment);
- g_ptr_array_add (environment, NULL);
+ environment = g_ptr_array_new ();
+ g_hash_table_foreach (worker->priv->environment,
+ (GHFunc) gdm_session_worker_fill_environment_array,
+ environment);
+ g_ptr_array_add (environment, NULL);
- return (char **) g_ptr_array_free (environment, FALSE);
+ return (char **) g_ptr_array_free (environment, FALSE);
}
static void
session_worker_child_watch (GPid pid,
- int status,
- GdmSessionWorker *worker)
+ int status,
+ GdmSessionWorker *worker)
{
- g_debug ("child (pid:%d) done (%s:%d)",
- (int) pid,
- WIFEXITED (status) ? "status"
- : WIFSIGNALED (status) ? "signal"
- : "unknown",
- WIFEXITED (status) ? WEXITSTATUS (status)
- : WIFSIGNALED (status) ? WTERMSIG (status)
- : -1);
-
- if (WIFEXITED (status)) {
- int code = WEXITSTATUS (status);
-
- send_session_exited (worker, code);
- } else if (WIFSIGNALED (status)) {
- int num = WTERMSIG (status);
-
- send_session_died (worker, num);
- }
-
- worker->priv->child_pid = -1;
+ g_debug ("child (pid:%d) done (%s:%d)",
+ (int) pid,
+ WIFEXITED (status) ? "status"
+ : WIFSIGNALED (status) ? "signal"
+ : "unknown",
+ WIFEXITED (status) ? WEXITSTATUS (status)
+ : WIFSIGNALED (status) ? WTERMSIG (status)
+ : -1);
+
+ if (WIFEXITED (status)) {
+ int code = WEXITSTATUS (status);
+
+ send_session_exited (worker, code);
+ } else if (WIFSIGNALED (status)) {
+ int num = WTERMSIG (status);
+
+ send_session_died (worker, num);
+ }
+
+ worker->priv->child_pid = -1;
}
static void
gdm_session_worker_watch_child (GdmSessionWorker *worker)
{
- worker->priv->child_watch_id = g_child_watch_add (worker->priv->child_pid,
- (GChildWatchFunc)session_worker_child_watch,
- worker);
+ worker->priv->child_watch_id = g_child_watch_add (worker->priv->child_pid,
+ (GChildWatchFunc)session_worker_child_watch,
+ worker);
}
static gboolean
gdm_session_worker_open_user_session (GdmSessionWorker *worker,
- GError **error)
+ GError **error)
{
- int error_code;
- pid_t session_pid;
-
- g_assert (!worker->priv->is_running);
- g_assert (geteuid () == 0);
- error_code = pam_open_session (worker->priv->pam_handle, 0);
-
- if (error_code != PAM_SUCCESS) {
- g_set_error (error,
- GDM_SESSION_WORKER_ERROR,
- GDM_SESSION_WORKER_ERROR_OPENING_SESSION,
- "%s", pam_strerror (worker->priv->pam_handle, error_code));
- goto out;
- }
- worker->priv->is_running = TRUE;
+ int error_code;
+ pid_t session_pid;
+
+ g_assert (!worker->priv->is_running);
+ g_assert (geteuid () == 0);
+ error_code = pam_open_session (worker->priv->pam_handle, 0);
+
+ if (error_code != PAM_SUCCESS) {
+ g_set_error (error,
+ GDM_SESSION_WORKER_ERROR,
+ GDM_SESSION_WORKER_ERROR_OPENING_SESSION,
+ "%s", pam_strerror (worker->priv->pam_handle, error_code));
+ goto out;
+ }
+ worker->priv->is_running = TRUE;
- g_debug ("querying pam for user environment");
- gdm_session_worker_update_environment_from_pam (worker);
+ g_debug ("querying pam for user environment");
+ gdm_session_worker_update_environment_from_pam (worker);
- g_debug ("opening user session with program '%s'",
- worker->priv->arguments[0]);
+ g_debug ("opening user session with program '%s'",
+ worker->priv->arguments[0]);
- session_pid = fork ();
+ session_pid = fork ();
- if (session_pid < 0) {
- g_set_error (error,
- GDM_SESSION_WORKER_ERROR,
- GDM_SESSION_WORKER_ERROR_OPENING_SESSION,
- "%s", g_strerror (errno));
- error_code = PAM_ABORT;
- goto out;
- }
+ if (session_pid < 0) {
+ g_set_error (error,
+ GDM_SESSION_WORKER_ERROR,
+ GDM_SESSION_WORKER_ERROR_OPENING_SESSION,
+ "%s", g_strerror (errno));
+ error_code = PAM_ABORT;
+ goto out;
+ }
- if (session_pid == 0) {
- char **environment;
- char *home_dir;
+ if (session_pid == 0) {
+ char **environment;
+ char *home_dir;
- if (setuid (getuid ()) < 0) {
- g_debug ("could not reset uid - %s", g_strerror (errno));
- _exit (1);
- }
+ if (setuid (getuid ()) < 0) {
+ g_debug ("could not reset uid - %s", g_strerror (errno));
+ _exit (1);
+ }
- if (setsid () < 0) {
- g_debug ("could not set pid '%u' as leader of new session and process group - %s",
- (guint) getpid (), g_strerror (errno));
- _exit (2);
- }
+ if (setsid () < 0) {
+ g_debug ("could not set pid '%u' as leader of new session and process group - %s",
+ (guint) getpid (), g_strerror (errno));
+ _exit (2);
+ }
- environment = gdm_session_worker_get_environment (worker);
+ environment = gdm_session_worker_get_environment (worker);
- g_assert (geteuid () == getuid ());
+ g_assert (geteuid () == getuid ());
- home_dir = g_hash_table_lookup (worker->priv->environment,
- "HOME");
+ home_dir = g_hash_table_lookup (worker->priv->environment,
+ "HOME");
- if ((home_dir == NULL) || g_chdir (home_dir) < 0) {
- g_chdir ("/");
- }
+ if ((home_dir == NULL) || g_chdir (home_dir) < 0) {
+ g_chdir ("/");
+ }
- gdm_session_execute (worker->priv->arguments[0],
- worker->priv->arguments,
- environment,
- TRUE);
+ gdm_session_execute (worker->priv->arguments[0],
+ worker->priv->arguments,
+ environment,
+ TRUE);
- g_debug ("child '%s' could not be started - %s",
- worker->priv->arguments[0],
- g_strerror (errno));
- g_strfreev (environment);
+ g_debug ("child '%s' could not be started - %s",
+ worker->priv->arguments[0],
+ g_strerror (errno));
+ g_strfreev (environment);
- _exit (127);
- }
+ _exit (127);
+ }
- worker->priv->child_pid = session_pid;
+ worker->priv->child_pid = session_pid;
- g_debug ("session opened creating reply...");
- g_assert (sizeof (GPid) <= sizeof (int));
+ g_debug ("session opened creating reply...");
+ g_assert (sizeof (GPid) <= sizeof (int));
- send_session_started (worker, session_pid);
+ send_session_started (worker, session_pid);
- gdm_session_worker_watch_child (worker);
+ gdm_session_worker_watch_child (worker);
out:
- if (error_code != PAM_SUCCESS) {
- gdm_session_worker_uninitialize_pam (worker, error_code);
- return FALSE;
- }
+ if (error_code != PAM_SUCCESS) {
+ gdm_session_worker_uninitialize_pam (worker, error_code);
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_session_worker_open (GdmSessionWorker *worker,
- const char *service_name,
- const char *hostname,
- const char *console_name,
- const char *username,
- GError **error)
+ const char *service_name,
+ const char *hostname,
+ const char *console_name,
+ const char *username,
+ GError **error)
{
- GError *verification_error;
- gboolean res;
- gboolean ret;
+ GError *verification_error;
+ gboolean res;
+ gboolean ret;
- ret = FALSE;
+ ret = FALSE;
- verification_error = NULL;
- res = gdm_session_worker_verify_user (worker,
- service_name,
- hostname,
- console_name,
- username,
- TRUE /* password is required */,
- &verification_error);
- if (! res) {
- g_assert (verification_error != NULL);
+ verification_error = NULL;
+ res = gdm_session_worker_verify_user (worker,
+ service_name,
+ hostname,
+ console_name,
+ username,
+ TRUE /* password is required */,
+ &verification_error);
+ if (! res) {
+ g_assert (verification_error != NULL);
- g_debug ("%s", verification_error->message);
+ g_debug ("%s", verification_error->message);
- g_propagate_error (error, verification_error);
+ g_propagate_error (error, verification_error);
- goto out;
- }
+ goto out;
+ }
- /* Did start_program get called early? if so, process it now,
- * otherwise we'll do it asynchronously later.
- */
- if ((worker->priv->arguments != NULL) &&
- !gdm_session_worker_open_user_session (worker, &verification_error)) {
- g_assert (verification_error != NULL);
+ /* Did start_program get called early? if so, process it now,
+ * otherwise we'll do it asynchronously later.
+ */
+ if ((worker->priv->arguments != NULL) &&
+ !gdm_session_worker_open_user_session (worker, &verification_error)) {
+ g_assert (verification_error != NULL);
- g_debug ("%s", verification_error->message);
+ g_debug ("%s", verification_error->message);
- g_propagate_error (error, verification_error);
+ g_propagate_error (error, verification_error);
- goto out;
- }
+ goto out;
+ }
- ret = TRUE;
+ ret = TRUE;
out:
- return ret;
+ return ret;
}
static gboolean
gdm_session_worker_start_program (GdmSessionWorker *worker,
- const char *command)
+ const char *command)
{
- GError *start_error;
- GError *error;
- gboolean res;
-
- if (worker->priv->arguments != NULL)
- g_strfreev (worker->priv->arguments);
-
- error = NULL;
- if (! g_shell_parse_argv (command, NULL, &worker->priv->arguments, &error)) {
- g_warning ("Unable to parse command: %s", error->message);
- g_error_free (error);
- return FALSE;
- }
-
- /* Did start_program get called early? if so, we will process the request
- * later, synchronously after getting credentials
- */
- if (!worker->priv->credentials_are_established) {
- return FALSE;
- }
-
- start_error = NULL;
- res = gdm_session_worker_open_user_session (worker, &start_error);
- if (! res) {
- g_assert (start_error != NULL);
-
- g_warning ("%s", start_error->message);
-
- send_startup_failed (worker, start_error->message);
- return FALSE;
- }
-
- return TRUE;
+ GError *start_error;
+ GError *error;
+ gboolean res;
+
+ if (worker->priv->arguments != NULL)
+ g_strfreev (worker->priv->arguments);
+
+ error = NULL;
+ if (! g_shell_parse_argv (command, NULL, &worker->priv->arguments, &error)) {
+ g_warning ("Unable to parse command: %s", error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+
+ /* Did start_program get called early? if so, we will process the request
+ * later, synchronously after getting credentials
+ */
+ if (!worker->priv->credentials_are_established) {
+ return FALSE;
+ }
+
+ start_error = NULL;
+ res = gdm_session_worker_open_user_session (worker, &start_error);
+ if (! res) {
+ g_assert (start_error != NULL);
+
+ g_warning ("%s", start_error->message);
+
+ send_startup_failed (worker, start_error->message);
+ return FALSE;
+ }
+
+ return TRUE;
}
static void
gdm_session_worker_set_server_address (GdmSessionWorker *worker,
- const char *address)
+ const char *address)
{
- g_free (worker->priv->server_address);
- worker->priv->server_address = g_strdup (address);
+ g_free (worker->priv->server_address);
+ worker->priv->server_address = g_strdup (address);
}
static void
gdm_session_worker_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GdmSessionWorker *self;
-
- self = GDM_SESSION_WORKER (object);
-
- switch (prop_id) {
- case PROP_SERVER_ADDRESS:
- gdm_session_worker_set_server_address (self, g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GdmSessionWorker *self;
+
+ self = GDM_SESSION_WORKER (object);
+
+ switch (prop_id) {
+ case PROP_SERVER_ADDRESS:
+ gdm_session_worker_set_server_address (self, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_session_worker_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GdmSessionWorker *self;
-
- self = GDM_SESSION_WORKER (object);
-
- switch (prop_id) {
- case PROP_SERVER_ADDRESS:
- g_value_set_string (value, self->priv->server_address);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GdmSessionWorker *self;
+
+ self = GDM_SESSION_WORKER (object);
+
+ switch (prop_id) {
+ case PROP_SERVER_ADDRESS:
+ g_value_set_string (value, self->priv->server_address);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
on_set_environment_variable (DBusGProxy *proxy,
- const char *key,
- const char *value,
- gpointer data)
+ const char *key,
+ const char *value,
+ gpointer data)
{
- GdmSessionWorker *worker = GDM_SESSION_WORKER (data);
+ GdmSessionWorker *worker = GDM_SESSION_WORKER (data);
- g_debug ("set env: %s = %s", key, value);
+ g_debug ("set env: %s = %s", key, value);
- gdm_session_worker_set_environment_variable (worker, key, value);
+ gdm_session_worker_set_environment_variable (worker, key, value);
}
static void
on_start_program (DBusGProxy *proxy,
- const char *text,
- gpointer data)
+ const char *text,
+ gpointer data)
{
- GdmSessionWorker *worker = GDM_SESSION_WORKER (data);
+ GdmSessionWorker *worker = GDM_SESSION_WORKER (data);
- g_debug ("start program: %s", text);
+ g_debug ("start program: %s", text);
- gdm_session_worker_start_program (worker, text);
+ gdm_session_worker_start_program (worker, text);
}
typedef struct {
- GdmSessionWorker *worker;
- char *service;
- char *console;
- char *hostname;
- char *username;
+ GdmSessionWorker *worker;
+ char *service;
+ char *console;
+ char *hostname;
+ char *username;
} OpenData;
static gboolean
open_idle (OpenData *data)
{
- GError *error;
- gboolean res;
-
- g_debug ("begin verification: %s %s", data->service, data->console);
-
- error = NULL;
- res = gdm_session_worker_open (data->worker,
- data->service,
- data->console,
- data->hostname,
- data->username,
- &error);
- if (! res) {
- g_debug ("Verification failed: %s", error->message);
- g_error_free (error);
- send_user_verification_error (data->worker, error->message);
- }
-
- data->worker->priv->open_idle_id = 0;
- return FALSE;
+ GError *error;
+ gboolean res;
+
+ g_debug ("begin verification: %s %s", data->service, data->console);
+
+ error = NULL;
+ res = gdm_session_worker_open (data->worker,
+ data->service,
+ data->console,
+ data->hostname,
+ data->username,
+ &error);
+ if (! res) {
+ g_debug ("Verification failed: %s", error->message);
+ g_error_free (error);
+ send_user_verification_error (data->worker, error->message);
+ }
+
+ data->worker->priv->open_idle_id = 0;
+ return FALSE;
}
static void
free_open_data (OpenData *data)
{
- g_free (data->service);
- g_free (data->console);
- g_free (data->hostname);
- g_free (data->username);
- g_free (data);
+ g_free (data->service);
+ g_free (data->console);
+ g_free (data->hostname);
+ g_free (data->username);
+ g_free (data);
}
static void
queue_open (GdmSessionWorker *worker,
- const char *service,
- const char *console,
- const char *hostname,
- const char *username)
+ const char *service,
+ const char *console,
+ const char *hostname,
+ const char *username)
{
- OpenData *data;
-
- if (worker->priv->open_idle_id > 0) {
- return;
- }
-
- data = g_new0 (OpenData, 1);
- data->worker = worker;
- data->service = g_strdup (service);
- data->console = g_strdup (console);
- data->hostname = g_strdup (hostname);
- data->username = g_strdup (username);
- worker->priv->open_idle_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
- (GSourceFunc)open_idle,
- data,
- (GDestroyNotify)free_open_data);
+ OpenData *data;
+
+ if (worker->priv->open_idle_id > 0) {
+ return;
+ }
+
+ data = g_new0 (OpenData, 1);
+ data->worker = worker;
+ data->service = g_strdup (service);
+ data->console = g_strdup (console);
+ data->hostname = g_strdup (hostname);
+ data->username = g_strdup (username);
+ worker->priv->open_idle_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
+ (GSourceFunc)open_idle,
+ data,
+ (GDestroyNotify)free_open_data);
}
static void
on_begin_verification (DBusGProxy *proxy,
- const char *service,
- const char *console,
- const char *hostname,
- gpointer data)
+ const char *service,
+ const char *console,
+ const char *hostname,
+ gpointer data)
{
- GdmSessionWorker *worker = GDM_SESSION_WORKER (data);
+ GdmSessionWorker *worker = GDM_SESSION_WORKER (data);
- g_debug ("begin verification: %s %s", service, console);
- queue_open (worker, service, console, hostname, NULL);
+ g_debug ("begin verification: %s %s", service, console);
+ queue_open (worker, service, console, hostname, NULL);
}
static void
on_begin_verification_for_user (DBusGProxy *proxy,
- const char *service,
- const char *console,
- const char *hostname,
- const char *username,
- gpointer data)
+ const char *service,
+ const char *console,
+ const char *hostname,
+ const char *username,
+ gpointer data)
{
- GdmSessionWorker *worker = GDM_SESSION_WORKER (data);
+ GdmSessionWorker *worker = GDM_SESSION_WORKER (data);
- g_debug ("begin verification: %s %s", service, console);
- queue_open (worker, service, console, hostname, username);
+ g_debug ("begin verification: %s %s", service, console);
+ queue_open (worker, service, console, hostname, username);
}
static void
proxy_destroyed (DBusGProxy *bus_proxy,
- GdmSessionWorker *worker)
+ GdmSessionWorker *worker)
{
- g_debug ("Disconnected");
+ g_debug ("Disconnected");
- /* do cleanup */
- exit (1);
+ /* do cleanup */
+ exit (1);
}
static GObject *
gdm_session_worker_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
{
GdmSessionWorker *worker;
GdmSessionWorkerClass *klass;
- GError *error;
+ GError *error;
klass = GDM_SESSION_WORKER_CLASS (g_type_class_peek (GDM_TYPE_SESSION_WORKER));
worker = GDM_SESSION_WORKER (G_OBJECT_CLASS (gdm_session_worker_parent_class)->constructor (type,
- n_construct_properties,
- construct_properties));
+ n_construct_properties,
+ construct_properties));
- g_debug ("connecting to address: %s", worker->priv->server_address);
+ g_debug ("connecting to address: %s", worker->priv->server_address);
error = NULL;
worker->priv->connection = dbus_g_connection_open (worker->priv->server_address, &error);
@@ -1655,63 +1655,63 @@ gdm_session_worker_constructor (GType type,
g_warning ("error opening connection: %s", error->message);
g_error_free (error);
} else {
- g_warning ("Unable to open connection");
- }
- exit (1);
+ g_warning ("Unable to open connection");
+ }
+ exit (1);
}
- /*dbus_connection_set_exit_on_disconnect (dbus_g_connection_get_connection (worker->priv->connection), TRUE);*/
+ /*dbus_connection_set_exit_on_disconnect (dbus_g_connection_get_connection (worker->priv->connection), TRUE);*/
- g_debug ("creating proxy for peer: %s", GDM_SESSION_DBUS_PATH);
+ g_debug ("creating proxy for peer: %s", GDM_SESSION_DBUS_PATH);
worker->priv->server_proxy = dbus_g_proxy_new_for_peer (worker->priv->connection,
- GDM_SESSION_DBUS_PATH,
- GDM_SESSION_DBUS_INTERFACE);
- if (worker->priv->server_proxy == NULL) {
- g_warning ("Unable to create proxy for peer");
- exit (1);
- }
-
- g_signal_connect (worker->priv->server_proxy, "destroy", G_CALLBACK (proxy_destroyed), NULL);
-
- dbus_g_object_register_marshaller (gdm_marshal_VOID__STRING_STRING,
- G_TYPE_NONE,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_object_register_marshaller (gdm_marshal_VOID__STRING_STRING_STRING_STRING,
- G_TYPE_NONE,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_INVALID);
-
- /* FIXME: not sure why introspection isn't working */
- dbus_g_proxy_add_signal (worker->priv->server_proxy, "StartProgram", G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_add_signal (worker->priv->server_proxy, "SetEnvironmentVariable", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_add_signal (worker->priv->server_proxy, "BeginVerification", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_add_signal (worker->priv->server_proxy, "BeginVerificationForUser", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
-
- dbus_g_proxy_connect_signal (worker->priv->server_proxy,
- "StartProgram",
- G_CALLBACK (on_start_program),
- worker,
- NULL);
- dbus_g_proxy_connect_signal (worker->priv->server_proxy,
- "SetEnvironmentVariable",
- G_CALLBACK (on_set_environment_variable),
- worker,
- NULL);
- dbus_g_proxy_connect_signal (worker->priv->server_proxy,
- "BeginVerification",
- G_CALLBACK (on_begin_verification),
- worker,
- NULL);
- dbus_g_proxy_connect_signal (worker->priv->server_proxy,
- "BeginVerificationForUser",
- G_CALLBACK (on_begin_verification_for_user),
- worker,
- NULL);
+ GDM_SESSION_DBUS_PATH,
+ GDM_SESSION_DBUS_INTERFACE);
+ if (worker->priv->server_proxy == NULL) {
+ g_warning ("Unable to create proxy for peer");
+ exit (1);
+ }
+
+ g_signal_connect (worker->priv->server_proxy, "destroy", G_CALLBACK (proxy_destroyed), NULL);
+
+ dbus_g_object_register_marshaller (gdm_marshal_VOID__STRING_STRING,
+ G_TYPE_NONE,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_object_register_marshaller (gdm_marshal_VOID__STRING_STRING_STRING_STRING,
+ G_TYPE_NONE,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_INVALID);
+
+ /* FIXME: not sure why introspection isn't working */
+ dbus_g_proxy_add_signal (worker->priv->server_proxy, "StartProgram", G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (worker->priv->server_proxy, "SetEnvironmentVariable", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (worker->priv->server_proxy, "BeginVerification", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (worker->priv->server_proxy, "BeginVerificationForUser", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+
+ dbus_g_proxy_connect_signal (worker->priv->server_proxy,
+ "StartProgram",
+ G_CALLBACK (on_start_program),
+ worker,
+ NULL);
+ dbus_g_proxy_connect_signal (worker->priv->server_proxy,
+ "SetEnvironmentVariable",
+ G_CALLBACK (on_set_environment_variable),
+ worker,
+ NULL);
+ dbus_g_proxy_connect_signal (worker->priv->server_proxy,
+ "BeginVerification",
+ G_CALLBACK (on_begin_verification),
+ worker,
+ NULL);
+ dbus_g_proxy_connect_signal (worker->priv->server_proxy,
+ "BeginVerificationForUser",
+ G_CALLBACK (on_begin_verification_for_user),
+ worker,
+ NULL);
return G_OBJECT (worker);
}
@@ -1719,86 +1719,86 @@ gdm_session_worker_constructor (GType type,
static void
gdm_session_worker_class_init (GdmSessionWorkerClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->get_property = gdm_session_worker_get_property;
- object_class->set_property = gdm_session_worker_set_property;
+ object_class->get_property = gdm_session_worker_get_property;
+ object_class->set_property = gdm_session_worker_set_property;
object_class->constructor = gdm_session_worker_constructor;
- object_class->finalize = gdm_session_worker_finalize;
+ object_class->finalize = gdm_session_worker_finalize;
- g_type_class_add_private (klass, sizeof (GdmSessionWorkerPrivate));
+ g_type_class_add_private (klass, sizeof (GdmSessionWorkerPrivate));
- g_object_class_install_property (object_class,
- PROP_SERVER_ADDRESS,
- g_param_spec_string ("server-address",
- "server address",
- "server address",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
+ PROP_SERVER_ADDRESS,
+ g_param_spec_string ("server-address",
+ "server address",
+ "server address",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
}
static void
gdm_session_worker_init (GdmSessionWorker *worker)
{
- worker->priv = GDM_SESSION_WORKER_GET_PRIVATE (worker);
- worker->priv->environment = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_free);
+ worker->priv = GDM_SESSION_WORKER_GET_PRIVATE (worker);
+ worker->priv->environment = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) g_free);
}
static void
gdm_session_worker_unwatch_child (GdmSessionWorker *worker)
{
- if (worker->priv->child_watch_id == 0)
- return;
+ if (worker->priv->child_watch_id == 0)
+ return;
- g_source_remove (worker->priv->child_watch_id);
- worker->priv->child_watch_id = 0;
+ g_source_remove (worker->priv->child_watch_id);
+ worker->priv->child_watch_id = 0;
}
static void
gdm_session_worker_finalize (GObject *object)
{
- GdmSessionWorker *worker;
+ GdmSessionWorker *worker;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_SESSION_WORKER (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_SESSION_WORKER (object));
- worker = GDM_SESSION_WORKER (object);
+ worker = GDM_SESSION_WORKER (object);
- g_return_if_fail (worker->priv != NULL);
+ g_return_if_fail (worker->priv != NULL);
- gdm_session_worker_unwatch_child (worker);
+ gdm_session_worker_unwatch_child (worker);
- if (worker->priv->username != NULL) {
- g_free (worker->priv->username);
- worker->priv->username = NULL;
- }
+ if (worker->priv->username != NULL) {
+ g_free (worker->priv->username);
+ worker->priv->username = NULL;
+ }
- if (worker->priv->arguments != NULL) {
- g_strfreev (worker->priv->arguments);
- worker->priv->arguments = NULL;
- }
+ if (worker->priv->arguments != NULL) {
+ g_strfreev (worker->priv->arguments);
+ worker->priv->arguments = NULL;
+ }
- if (worker->priv->environment != NULL) {
- g_hash_table_destroy (worker->priv->environment);
- worker->priv->environment = NULL;
- }
+ if (worker->priv->environment != NULL) {
+ g_hash_table_destroy (worker->priv->environment);
+ worker->priv->environment = NULL;
+ }
- G_OBJECT_CLASS (gdm_session_worker_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_session_worker_parent_class)->finalize (object);
}
GdmSessionWorker *
gdm_session_worker_new (const char *address)
{
- GObject *object;
+ GObject *object;
- object = g_object_new (GDM_TYPE_SESSION_WORKER,
- "server-address", address,
- NULL);
+ object = g_object_new (GDM_TYPE_SESSION_WORKER,
+ "server-address", address,
+ NULL);
- return GDM_SESSION_WORKER (object);
+ return GDM_SESSION_WORKER (object);
}
diff --git a/daemon/gdm-session-worker.h b/daemon/gdm-session-worker.h
index 308c3b35..6d598f6f 100644
--- a/daemon/gdm-session-worker.h
+++ b/daemon/gdm-session-worker.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2006 Ray Strode <rstrode@redhat.com>
*
@@ -35,32 +35,32 @@ G_BEGIN_DECLS
#define GDM_SESSION_WORKER_ERROR (gdm_session_worker_error_quark ())
typedef enum _GdmSessionWorkerError {
- GDM_SESSION_WORKER_ERROR_GENERIC = 0,
- GDM_SESSION_WORKER_ERROR_WITH_SESSION_COMMAND,
- GDM_SESSION_WORKER_ERROR_FORKING,
- GDM_SESSION_WORKER_ERROR_OPENING_MESSAGE_PIPE,
- GDM_SESSION_WORKER_ERROR_COMMUNICATING,
- GDM_SESSION_WORKER_ERROR_WORKER_DIED,
- GDM_SESSION_WORKER_ERROR_AUTHENTICATING,
- GDM_SESSION_WORKER_ERROR_AUTHORIZING,
- GDM_SESSION_WORKER_ERROR_OPENING_LOG_FILE,
- GDM_SESSION_WORKER_ERROR_OPENING_SESSION,
- GDM_SESSION_WORKER_ERROR_GIVING_CREDENTIALS
+ GDM_SESSION_WORKER_ERROR_GENERIC = 0,
+ GDM_SESSION_WORKER_ERROR_WITH_SESSION_COMMAND,
+ GDM_SESSION_WORKER_ERROR_FORKING,
+ GDM_SESSION_WORKER_ERROR_OPENING_MESSAGE_PIPE,
+ GDM_SESSION_WORKER_ERROR_COMMUNICATING,
+ GDM_SESSION_WORKER_ERROR_WORKER_DIED,
+ GDM_SESSION_WORKER_ERROR_AUTHENTICATING,
+ GDM_SESSION_WORKER_ERROR_AUTHORIZING,
+ GDM_SESSION_WORKER_ERROR_OPENING_LOG_FILE,
+ GDM_SESSION_WORKER_ERROR_OPENING_SESSION,
+ GDM_SESSION_WORKER_ERROR_GIVING_CREDENTIALS
} GdmSessionWorkerError;
typedef struct GdmSessionWorkerPrivate GdmSessionWorkerPrivate;
typedef struct
{
- GObject parent;
+ GObject parent;
- /*< private > */
- GdmSessionWorkerPrivate *priv;
+ /*< private > */
+ GdmSessionWorkerPrivate *priv;
} GdmSessionWorker;
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
} GdmSessionWorkerClass;
diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c
index d9283361..832b9cd1 100644
--- a/daemon/gdm-session.c
+++ b/daemon/gdm-session.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* session.c - authenticates and authorizes users with system
*
@@ -61,11 +61,11 @@
#ifndef GDM_BAD_SESSION_RECORDS_FILE
-#define GDM_BAD_SESSION_RECORDS_FILE "/var/log/btmp"
+#define GDM_BAD_SESSION_RECORDS_FILE "/var/log/btmp"
#endif
#ifndef GDM_NEW_SESSION_RECORDS_FILE
-#define GDM_NEW_SESSION_RECORDS_FILE "/var/log/wtmp"
+#define GDM_NEW_SESSION_RECORDS_FILE "/var/log/wtmp"
#endif
#ifndef GDM_MAX_OPEN_FILE_DESCRIPTORS
@@ -98,47 +98,47 @@
typedef enum _GdmSessionRecordType {
- GDM_SESSION_RECORD_TYPE_LOGIN,
- GDM_SESSION_RECORD_TYPE_FAILED_ATTEMPT,
- GDM_SESSION_RECORD_TYPE_LOGOUT,
+ GDM_SESSION_RECORD_TYPE_LOGIN,
+ GDM_SESSION_RECORD_TYPE_FAILED_ATTEMPT,
+ GDM_SESSION_RECORD_TYPE_LOGOUT,
} GdmSessionRecordType;
struct _GdmSessionPrivate
{
- GdmSessionWorkerJob *job;
- GPid session_pid;
+ GdmSessionWorkerJob *job;
+ GPid session_pid;
- char *service_name;
- char *username;
- char *hostname;
- char *console_name;
+ char *service_name;
+ char *username;
+ char *hostname;
+ char *console_name;
- DBusMessage *message_pending_reply;
+ DBusMessage *message_pending_reply;
- GHashTable *environment;
+ GHashTable *environment;
- DBusServer *server;
- char *server_address;
- DBusConnection *worker_connection;
+ DBusServer *server;
+ char *server_address;
+ DBusConnection *worker_connection;
- guint32 is_verified : 1;
- guint32 is_running : 1;
+ guint32 is_verified : 1;
+ guint32 is_running : 1;
};
enum {
- USER_VERIFIED = 0,
- USER_VERIFICATION_ERROR,
- INFO,
- PROBLEM,
- INFO_QUERY,
- SECRET_INFO_QUERY,
- SESSION_STARTED,
- SESSION_STARTUP_ERROR,
- SESSION_EXITED,
- SESSION_DIED,
- OPENED,
- CLOSED,
- LAST_SIGNAL
+ USER_VERIFIED = 0,
+ USER_VERIFICATION_ERROR,
+ INFO,
+ PROBLEM,
+ INFO_QUERY,
+ SECRET_INFO_QUERY,
+ SESSION_STARTED,
+ SESSION_STARTUP_ERROR,
+ SESSION_EXITED,
+ SESSION_DIED,
+ OPENED,
+ CLOSED,
+ LAST_SIGNAL
};
static guint gdm_session_signals [LAST_SIGNAL];
@@ -148,200 +148,200 @@ G_DEFINE_TYPE (GdmSession, gdm_session, G_TYPE_OBJECT);
GQuark
gdm_session_error_quark (void)
{
- static GQuark error_quark = 0;
+ static GQuark error_quark = 0;
- if (error_quark == 0)
- error_quark = g_quark_from_static_string ("gdm-session");
+ if (error_quark == 0)
+ error_quark = g_quark_from_static_string ("gdm-session");
- return error_quark;
+ return error_quark;
}
static gboolean
send_dbus_message (DBusConnection *connection,
- DBusMessage *message)
+ DBusMessage *message)
{
- gboolean is_connected;
- gboolean sent;
+ gboolean is_connected;
+ gboolean sent;
- g_return_val_if_fail (message != NULL, FALSE);
+ g_return_val_if_fail (message != NULL, FALSE);
- if (connection == NULL) {
- g_warning ("There is no valid connection");
- return FALSE;
- }
+ if (connection == NULL) {
+ g_warning ("There is no valid connection");
+ return FALSE;
+ }
- is_connected = dbus_connection_get_is_connected (connection);
- if (! is_connected) {
- g_warning ("Not connected!");
- return FALSE;
- }
+ is_connected = dbus_connection_get_is_connected (connection);
+ if (! is_connected) {
+ g_warning ("Not connected!");
+ return FALSE;
+ }
- sent = dbus_connection_send (connection, message, NULL);
+ sent = dbus_connection_send (connection, message, NULL);
- return sent;
+ return sent;
}
static void
send_dbus_string_signal (GdmSession *session,
- const char *name,
- const char *text)
+ const char *name,
+ const char *text)
{
- DBusMessage *message;
- DBusMessageIter iter;
+ DBusMessage *message;
+ DBusMessageIter iter;
- g_return_if_fail (session != NULL);
+ g_return_if_fail (session != NULL);
- message = dbus_message_new_signal (GDM_SESSION_DBUS_PATH,
- GDM_SESSION_DBUS_INTERFACE,
- name);
+ message = dbus_message_new_signal (GDM_SESSION_DBUS_PATH,
+ GDM_SESSION_DBUS_INTERFACE,
+ name);
- dbus_message_iter_init_append (message, &iter);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &text);
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &text);
- if (! send_dbus_message (session->priv->worker_connection, message)) {
- g_debug ("Could not send %s signal", name);
- }
+ if (! send_dbus_message (session->priv->worker_connection, message)) {
+ g_debug ("Could not send %s signal", name);
+ }
- dbus_message_unref (message);
+ dbus_message_unref (message);
}
static void
send_dbus_void_signal (GdmSession *session,
- const char *name)
+ const char *name)
{
- DBusMessage *message;
+ DBusMessage *message;
- g_return_if_fail (session != NULL);
+ g_return_if_fail (session != NULL);
- message = dbus_message_new_signal (GDM_SESSION_DBUS_PATH,
- GDM_SESSION_DBUS_INTERFACE,
- name);
+ message = dbus_message_new_signal (GDM_SESSION_DBUS_PATH,
+ GDM_SESSION_DBUS_INTERFACE,
+ name);
- if (! send_dbus_message (session->priv->worker_connection, message)) {
- g_debug ("Could not send %s signal", name);
- }
+ if (! send_dbus_message (session->priv->worker_connection, message)) {
+ g_debug ("Could not send %s signal", name);
+ }
- dbus_message_unref (message);
+ dbus_message_unref (message);
}
static void
gdm_session_write_record (GdmSession *session,
- GdmSessionRecordType record_type)
+ GdmSessionRecordType record_type)
{
- struct utmp session_record = { 0 };
- GTimeVal now = { 0 };
- char *hostname;
-
- g_debug ("writing %s record",
- record_type == GDM_SESSION_RECORD_TYPE_LOGIN? "session" :
- record_type == GDM_SESSION_RECORD_TYPE_LOGOUT? "logout" :
- "failed session attempt");
-
- if (record_type != GDM_SESSION_RECORD_TYPE_LOGOUT) {
- /* it's possible that PAM failed before it mapped the user input
- * into a valid username, so we fallback to try using "(unknown)"
- */
- if (session->priv->username != NULL)
- strncpy (session_record.ut_user, session->priv->username,
- sizeof (session_record.ut_user));
- else
- strncpy (session_record.ut_user, "(unknown)",
- sizeof (session_record.ut_user));
- }
-
- g_debug ("using username %.*s",
- sizeof (session_record.ut_user),
- session_record.ut_user);
-
- /* FIXME: I have no idea what to do for ut_id.
- */
- strncpy (session_record.ut_id,
- session->priv->console_name +
- strlen (session->priv->console_name) -
- sizeof (session_record.ut_id),
- sizeof (session_record.ut_id));
-
- g_debug ("using id %.*s", sizeof (session_record.ut_id), session_record.ut_id);
-
- if (g_str_has_prefix (session->priv->console_name, "/dev/")) {
- strncpy (session_record.ut_line,
- session->priv->console_name + strlen ("/dev/"),
- sizeof (session_record.ut_line));
- } else if (g_str_has_prefix (session->priv->console_name, ":")) {
- strncpy (session_record.ut_line,
- session->priv->console_name,
- sizeof (session_record.ut_line));
- }
-
- g_debug ("using line %.*s",
- sizeof (session_record.ut_line),
- session_record.ut_line);
-
- /* FIXME: this is a bit of a mess. Figure out how
- * wrong the logic is
- */
- hostname = NULL;
- if ((session->priv->hostname != NULL) &&
- g_str_has_prefix (session->priv->console_name, ":"))
- hostname = g_strdup_printf ("%s%s", session->priv->hostname,
- session->priv->console_name);
- else if ((session->priv->hostname != NULL) &&
- !strstr (session->priv->console_name, ":"))
- hostname = g_strdup (session->priv->hostname);
- else if (!g_str_has_prefix (session->priv->console_name, ":") &&
- strstr (session->priv->console_name, ":"))
- hostname = g_strdup (session->priv->console_name);
-
- if (hostname) {
- g_debug ("using hostname %.*s",
- sizeof (session_record.ut_host),
- session_record.ut_host);
- strncpy (session_record.ut_host,
- hostname, sizeof (session_record.ut_host));
- g_free (hostname);
- }
-
- g_get_current_time (&now);
- session_record.ut_tv.tv_sec = now.tv_sec;
- session_record.ut_tv.tv_usec = now.tv_usec;
-
- g_debug ("using time %ld",
- (glong) session_record.ut_tv.tv_sec);
-
- session_record.ut_type = USER_PROCESS;
- g_debug ("using type USER_PROCESS");
-
- if (session->priv->session_pid != 0) {
- session_record.ut_pid = session->priv->session_pid;
- }
-
- g_debug ("using pid %d", (int) session_record.ut_pid);
-
- switch (record_type) {
- case GDM_SESSION_RECORD_TYPE_LOGIN:
- g_debug ("writing session record to " GDM_NEW_SESSION_RECORDS_FILE);
- updwtmp (GDM_NEW_SESSION_RECORDS_FILE, &session_record);
- break;
-
- case GDM_SESSION_RECORD_TYPE_LOGOUT:
- g_debug ("writing logout record to " GDM_NEW_SESSION_RECORDS_FILE);
- updwtmp (GDM_NEW_SESSION_RECORDS_FILE, &session_record);
- break;
-
- case GDM_SESSION_RECORD_TYPE_FAILED_ATTEMPT:
- g_debug ("writing failed session attempt record to "
- GDM_BAD_SESSION_RECORDS_FILE);
- updwtmp (GDM_BAD_SESSION_RECORDS_FILE, &session_record);
- break;
- }
+ struct utmp session_record = { 0 };
+ GTimeVal now = { 0 };
+ char *hostname;
+
+ g_debug ("writing %s record",
+ record_type == GDM_SESSION_RECORD_TYPE_LOGIN? "session" :
+ record_type == GDM_SESSION_RECORD_TYPE_LOGOUT? "logout" :
+ "failed session attempt");
+
+ if (record_type != GDM_SESSION_RECORD_TYPE_LOGOUT) {
+ /* it's possible that PAM failed before it mapped the user input
+ * into a valid username, so we fallback to try using "(unknown)"
+ */
+ if (session->priv->username != NULL)
+ strncpy (session_record.ut_user, session->priv->username,
+ sizeof (session_record.ut_user));
+ else
+ strncpy (session_record.ut_user, "(unknown)",
+ sizeof (session_record.ut_user));
+ }
+
+ g_debug ("using username %.*s",
+ sizeof (session_record.ut_user),
+ session_record.ut_user);
+
+ /* FIXME: I have no idea what to do for ut_id.
+ */
+ strncpy (session_record.ut_id,
+ session->priv->console_name +
+ strlen (session->priv->console_name) -
+ sizeof (session_record.ut_id),
+ sizeof (session_record.ut_id));
+
+ g_debug ("using id %.*s", sizeof (session_record.ut_id), session_record.ut_id);
+
+ if (g_str_has_prefix (session->priv->console_name, "/dev/")) {
+ strncpy (session_record.ut_line,
+ session->priv->console_name + strlen ("/dev/"),
+ sizeof (session_record.ut_line));
+ } else if (g_str_has_prefix (session->priv->console_name, ":")) {
+ strncpy (session_record.ut_line,
+ session->priv->console_name,
+ sizeof (session_record.ut_line));
+ }
+
+ g_debug ("using line %.*s",
+ sizeof (session_record.ut_line),
+ session_record.ut_line);
+
+ /* FIXME: this is a bit of a mess. Figure out how
+ * wrong the logic is
+ */
+ hostname = NULL;
+ if ((session->priv->hostname != NULL) &&
+ g_str_has_prefix (session->priv->console_name, ":"))
+ hostname = g_strdup_printf ("%s%s", session->priv->hostname,
+ session->priv->console_name);
+ else if ((session->priv->hostname != NULL) &&
+ !strstr (session->priv->console_name, ":"))
+ hostname = g_strdup (session->priv->hostname);
+ else if (!g_str_has_prefix (session->priv->console_name, ":") &&
+ strstr (session->priv->console_name, ":"))
+ hostname = g_strdup (session->priv->console_name);
+
+ if (hostname) {
+ g_debug ("using hostname %.*s",
+ sizeof (session_record.ut_host),
+ session_record.ut_host);
+ strncpy (session_record.ut_host,
+ hostname, sizeof (session_record.ut_host));
+ g_free (hostname);
+ }
+
+ g_get_current_time (&now);
+ session_record.ut_tv.tv_sec = now.tv_sec;
+ session_record.ut_tv.tv_usec = now.tv_usec;
+
+ g_debug ("using time %ld",
+ (glong) session_record.ut_tv.tv_sec);
+
+ session_record.ut_type = USER_PROCESS;
+ g_debug ("using type USER_PROCESS");
+
+ if (session->priv->session_pid != 0) {
+ session_record.ut_pid = session->priv->session_pid;
+ }
+
+ g_debug ("using pid %d", (int) session_record.ut_pid);
+
+ switch (record_type) {
+ case GDM_SESSION_RECORD_TYPE_LOGIN:
+ g_debug ("writing session record to " GDM_NEW_SESSION_RECORDS_FILE);
+ updwtmp (GDM_NEW_SESSION_RECORDS_FILE, &session_record);
+ break;
+
+ case GDM_SESSION_RECORD_TYPE_LOGOUT:
+ g_debug ("writing logout record to " GDM_NEW_SESSION_RECORDS_FILE);
+ updwtmp (GDM_NEW_SESSION_RECORDS_FILE, &session_record);
+ break;
+
+ case GDM_SESSION_RECORD_TYPE_FAILED_ATTEMPT:
+ g_debug ("writing failed session attempt record to "
+ GDM_BAD_SESSION_RECORDS_FILE);
+ updwtmp (GDM_BAD_SESSION_RECORDS_FILE, &session_record);
+ break;
+ }
}
static void
gdm_session_user_verification_error_handler (GdmSession *session,
- GError *error)
+ GError *error)
{
- gdm_session_write_record (session,
- GDM_SESSION_RECORD_TYPE_FAILED_ATTEMPT);
+ gdm_session_write_record (session,
+ GDM_SESSION_RECORD_TYPE_FAILED_ATTEMPT);
}
static void
@@ -349,731 +349,731 @@ gdm_session_started_handler (GdmSession *session,
GPid pid)
{
- gdm_session_write_record (session,
- GDM_SESSION_RECORD_TYPE_LOGIN);
+ gdm_session_write_record (session,
+ GDM_SESSION_RECORD_TYPE_LOGIN);
}
static void
gdm_session_startup_error_handler (GdmSession *session,
GError *error)
{
- gdm_session_write_record (session,
- GDM_SESSION_RECORD_TYPE_LOGIN);
+ gdm_session_write_record (session,
+ GDM_SESSION_RECORD_TYPE_LOGIN);
}
static void
gdm_session_exited_handler (GdmSession *session,
int exit_code)
{
- gdm_session_write_record (session, GDM_SESSION_RECORD_TYPE_LOGOUT);
+ gdm_session_write_record (session, GDM_SESSION_RECORD_TYPE_LOGOUT);
}
static void
gdm_session_class_install_signals (GdmSessionClass *session_class)
{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (session_class);
-
- gdm_session_signals[OPENED] =
- g_signal_new ("opened",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionClass, opened),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- gdm_session_signals[CLOSED] =
- g_signal_new ("closed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionClass, closed),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- session_class->user_verified = NULL;
- gdm_session_signals[USER_VERIFIED] =
- g_signal_new ("user-verified",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionClass, user_verified),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- session_class->user_verified = NULL;
-
- gdm_session_signals[USER_VERIFICATION_ERROR] =
- g_signal_new ("user-verification-error",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionClass, user_verification_error),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE,
- 1,
- G_TYPE_POINTER);
- session_class->user_verification_error = gdm_session_user_verification_error_handler;
-
- gdm_session_signals[INFO_QUERY] =
- g_signal_new ("info-query",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdmSessionClass, info_query),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1,
- G_TYPE_STRING);
- session_class->info_query = NULL;
-
- gdm_session_signals[SECRET_INFO_QUERY] =
- g_signal_new ("secret-info-query",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdmSessionClass, secret_info_query),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1,
- G_TYPE_STRING);
- session_class->secret_info_query = NULL;
-
- gdm_session_signals[INFO] =
- g_signal_new ("info",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionClass, info),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1,
- G_TYPE_STRING);
- session_class->info = NULL;
-
- gdm_session_signals[PROBLEM] =
- g_signal_new ("problem",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionClass, problem),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1,
- G_TYPE_STRING);
- session_class->problem = NULL;
-
- gdm_session_signals[SESSION_STARTED] =
- g_signal_new ("session-started",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionClass, session_started),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE,
- 1,
- G_TYPE_INT);
- session_class->session_started = gdm_session_started_handler;
-
- gdm_session_signals[SESSION_STARTUP_ERROR] =
- g_signal_new ("session-startup-error",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionClass, session_startup_error),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE,
- 1,
- G_TYPE_POINTER);
- session_class->session_startup_error = gdm_session_startup_error_handler;
-
- gdm_session_signals[SESSION_EXITED] =
- g_signal_new ("session-exited",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionClass, session_exited),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE,
- 1,
- G_TYPE_INT);
- session_class->session_exited = gdm_session_exited_handler;
-
- gdm_session_signals[SESSION_DIED] =
- g_signal_new ("session-died",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionClass, session_died),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE,
- 1,
- G_TYPE_INT);
- session_class->session_died = NULL;
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (session_class);
+
+ gdm_session_signals[OPENED] =
+ g_signal_new ("opened",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionClass, opened),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ gdm_session_signals[CLOSED] =
+ g_signal_new ("closed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionClass, closed),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ session_class->user_verified = NULL;
+ gdm_session_signals[USER_VERIFIED] =
+ g_signal_new ("user-verified",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionClass, user_verified),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ session_class->user_verified = NULL;
+
+ gdm_session_signals[USER_VERIFICATION_ERROR] =
+ g_signal_new ("user-verification-error",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionClass, user_verification_error),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
+ session_class->user_verification_error = gdm_session_user_verification_error_handler;
+
+ gdm_session_signals[INFO_QUERY] =
+ g_signal_new ("info-query",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdmSessionClass, info_query),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING);
+ session_class->info_query = NULL;
+
+ gdm_session_signals[SECRET_INFO_QUERY] =
+ g_signal_new ("secret-info-query",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdmSessionClass, secret_info_query),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING);
+ session_class->secret_info_query = NULL;
+
+ gdm_session_signals[INFO] =
+ g_signal_new ("info",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionClass, info),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING);
+ session_class->info = NULL;
+
+ gdm_session_signals[PROBLEM] =
+ g_signal_new ("problem",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionClass, problem),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING);
+ session_class->problem = NULL;
+
+ gdm_session_signals[SESSION_STARTED] =
+ g_signal_new ("session-started",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionClass, session_started),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__INT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_INT);
+ session_class->session_started = gdm_session_started_handler;
+
+ gdm_session_signals[SESSION_STARTUP_ERROR] =
+ g_signal_new ("session-startup-error",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionClass, session_startup_error),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
+ session_class->session_startup_error = gdm_session_startup_error_handler;
+
+ gdm_session_signals[SESSION_EXITED] =
+ g_signal_new ("session-exited",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionClass, session_exited),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__INT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_INT);
+ session_class->session_exited = gdm_session_exited_handler;
+
+ gdm_session_signals[SESSION_DIED] =
+ g_signal_new ("session-died",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSessionClass, session_died),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__INT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_INT);
+ session_class->session_died = NULL;
}
static void
gdm_session_finalize (GObject *object)
{
- GdmSession *session;
- GObjectClass *parent_class;
+ GdmSession *session;
+ GObjectClass *parent_class;
- session = GDM_SESSION (object);
+ session = GDM_SESSION (object);
- g_free (session->priv->username);
+ g_free (session->priv->username);
- parent_class = G_OBJECT_CLASS (gdm_session_parent_class);
+ parent_class = G_OBJECT_CLASS (gdm_session_parent_class);
- if (session->priv->environment != NULL) {
- g_hash_table_destroy (session->priv->environment);
- session->priv->environment = NULL;
- }
+ if (session->priv->environment != NULL) {
+ g_hash_table_destroy (session->priv->environment);
+ session->priv->environment = NULL;
+ }
- if (parent_class->finalize != NULL)
- parent_class->finalize (object);
+ if (parent_class->finalize != NULL)
+ parent_class->finalize (object);
}
static void
gdm_session_class_init (GdmSessionClass *session_class)
{
- GObjectClass *object_class;
+ GObjectClass *object_class;
- object_class = G_OBJECT_CLASS (session_class);
+ object_class = G_OBJECT_CLASS (session_class);
- object_class->finalize = gdm_session_finalize;
+ object_class->finalize = gdm_session_finalize;
- gdm_session_class_install_signals (session_class);
+ gdm_session_class_install_signals (session_class);
- g_type_class_add_private (session_class,
- sizeof (GdmSessionPrivate));
+ g_type_class_add_private (session_class,
+ sizeof (GdmSessionPrivate));
}
static DBusHandlerResult
gdm_session_handle_verified (GdmSession *session,
- DBusConnection *connection,
- DBusMessage *message)
+ DBusConnection *connection,
+ DBusMessage *message)
{
- DBusMessage *reply;
+ DBusMessage *reply;
- g_debug ("Emitting 'user-verified' signal");
+ g_debug ("Emitting 'user-verified' signal");
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
- session->priv->is_verified = TRUE;
- g_signal_emit (session,
- gdm_session_signals[USER_VERIFIED],
- 0);
+ session->priv->is_verified = TRUE;
+ g_signal_emit (session,
+ gdm_session_signals[USER_VERIFIED],
+ 0);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
gdm_session_handle_verification_failed (GdmSession *session,
- DBusConnection *connection,
- DBusMessage *message)
+ DBusConnection *connection,
+ DBusMessage *message)
{
- DBusMessage *reply;
- DBusError error;
- GError *gerror;
- const char *text;
-
- dbus_error_init (&error);
- if (! dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &text,
- DBUS_TYPE_INVALID)) {
- g_warning ("ERROR: %s", error.message);
- }
-
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
-
- g_debug ("Emitting 'verification-failed' signal");
-
- gerror = g_error_new (GDM_SESSION_ERROR,
- GDM_SESSION_ERROR_AUTHENTICATING,
- "%s",
- text);
-
- g_signal_emit (session,
- gdm_session_signals[USER_VERIFICATION_ERROR],
- 0, gerror);
- g_error_free (gerror);
-
- return DBUS_HANDLER_RESULT_HANDLED;
+ DBusMessage *reply;
+ DBusError error;
+ GError *gerror;
+ const char *text;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &text,
+ DBUS_TYPE_INVALID)) {
+ g_warning ("ERROR: %s", error.message);
+ }
+
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
+
+ g_debug ("Emitting 'verification-failed' signal");
+
+ gerror = g_error_new (GDM_SESSION_ERROR,
+ GDM_SESSION_ERROR_AUTHENTICATING,
+ "%s",
+ text);
+
+ g_signal_emit (session,
+ gdm_session_signals[USER_VERIFICATION_ERROR],
+ 0, gerror);
+ g_error_free (gerror);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
gdm_session_handle_username_changed (GdmSession *session,
- DBusConnection *connection,
- DBusMessage *message)
+ DBusConnection *connection,
+ DBusMessage *message)
{
- DBusMessage *reply;
- DBusError error;
- const char *text;
-
- dbus_error_init (&error);
- if (! dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &text,
- DBUS_TYPE_INVALID)) {
- g_warning ("ERROR: %s", error.message);
- }
+ DBusMessage *reply;
+ DBusError error;
+ const char *text;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &text,
+ DBUS_TYPE_INVALID)) {
+ g_warning ("ERROR: %s", error.message);
+ }
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
- g_debug ("changing username from '%s' to '%s'",
- session->priv->username != NULL ? session->priv->username : "<unset>",
- (strlen (text)) ? text : "<unset>");
+ g_debug ("changing username from '%s' to '%s'",
+ session->priv->username != NULL ? session->priv->username : "<unset>",
+ (strlen (text)) ? text : "<unset>");
- g_free (session->priv->username);
- session->priv->username = (strlen (text) > 0) ? g_strdup (text) : NULL;
+ g_free (session->priv->username);
+ session->priv->username = (strlen (text) > 0) ? g_strdup (text) : NULL;
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static void
cancel_pending_query (GdmSession *session)
{
- DBusMessage *reply;
+ DBusMessage *reply;
- if (session->priv->message_pending_reply == NULL) {
- return;
- }
+ if (session->priv->message_pending_reply == NULL) {
+ return;
+ }
- g_debug ("Cancelling pending query");
+ g_debug ("Cancelling pending query");
- reply = dbus_message_new_error (session->priv->message_pending_reply,
- GDM_SESSION_DBUS_ERROR_NAME,
- "Operation cancelled");
- dbus_connection_send (session->priv->worker_connection, reply, NULL);
- dbus_message_unref (reply);
- dbus_message_unref (session->priv->message_pending_reply);
- session->priv->message_pending_reply = NULL;
+ reply = dbus_message_new_error (session->priv->message_pending_reply,
+ GDM_SESSION_DBUS_ERROR_NAME,
+ "Operation cancelled");
+ dbus_connection_send (session->priv->worker_connection, reply, NULL);
+ dbus_message_unref (reply);
+ dbus_message_unref (session->priv->message_pending_reply);
+ session->priv->message_pending_reply = NULL;
}
static void
answer_pending_query (GdmSession *session,
- const char *answer)
+ const char *answer)
{
- DBusMessage *reply;
- DBusMessageIter iter;
+ DBusMessage *reply;
+ DBusMessageIter iter;
- g_assert (session->priv->message_pending_reply != NULL);
+ g_assert (session->priv->message_pending_reply != NULL);
- reply = dbus_message_new_method_return (session->priv->message_pending_reply);
- dbus_message_iter_init_append (reply, &iter);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &answer);
+ reply = dbus_message_new_method_return (session->priv->message_pending_reply);
+ dbus_message_iter_init_append (reply, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &answer);
- dbus_connection_send (session->priv->worker_connection, reply, NULL);
- dbus_message_unref (reply);
+ dbus_connection_send (session->priv->worker_connection, reply, NULL);
+ dbus_message_unref (reply);
- dbus_message_unref (session->priv->message_pending_reply);
- session->priv->message_pending_reply = NULL;
+ dbus_message_unref (session->priv->message_pending_reply);
+ session->priv->message_pending_reply = NULL;
}
static void
set_pending_query (GdmSession *session,
- DBusMessage *message)
+ DBusMessage *message)
{
- g_assert (session->priv->message_pending_reply == NULL);
+ g_assert (session->priv->message_pending_reply == NULL);
- session->priv->message_pending_reply = dbus_message_ref (message);
+ session->priv->message_pending_reply = dbus_message_ref (message);
}
static DBusHandlerResult
gdm_session_handle_info_query (GdmSession *session,
- DBusConnection *connection,
- DBusMessage *message)
+ DBusConnection *connection,
+ DBusMessage *message)
{
- DBusError error;
- const char *text;
-
- dbus_error_init (&error);
- if (! dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &text,
- DBUS_TYPE_INVALID)) {
- g_warning ("ERROR: %s", error.message);
- }
+ DBusError error;
+ const char *text;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &text,
+ DBUS_TYPE_INVALID)) {
+ g_warning ("ERROR: %s", error.message);
+ }
- set_pending_query (session, message);
+ set_pending_query (session, message);
- g_debug ("Emitting 'info-query' signal");
- g_signal_emit (session,
- gdm_session_signals[INFO_QUERY],
- 0, text);
+ g_debug ("Emitting 'info-query' signal");
+ g_signal_emit (session,
+ gdm_session_signals[INFO_QUERY],
+ 0, text);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
gdm_session_handle_secret_info_query (GdmSession *session,
- DBusConnection *connection,
- DBusMessage *message)
+ DBusConnection *connection,
+ DBusMessage *message)
{
- DBusError error;
- const char *text;
-
- dbus_error_init (&error);
- if (! dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &text,
- DBUS_TYPE_INVALID)) {
- g_warning ("ERROR: %s", error.message);
- }
+ DBusError error;
+ const char *text;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &text,
+ DBUS_TYPE_INVALID)) {
+ g_warning ("ERROR: %s", error.message);
+ }
- set_pending_query (session, message);
+ set_pending_query (session, message);
- g_debug ("Emitting 'secret-info-query' signal");
+ g_debug ("Emitting 'secret-info-query' signal");
- g_signal_emit (session,
- gdm_session_signals[SECRET_INFO_QUERY],
- 0, text);
+ g_signal_emit (session,
+ gdm_session_signals[SECRET_INFO_QUERY],
+ 0, text);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
gdm_session_handle_info (GdmSession *session,
- DBusConnection *connection,
- DBusMessage *message)
+ DBusConnection *connection,
+ DBusMessage *message)
{
- DBusMessage *reply;
- DBusError error;
- const char *text;
-
- dbus_error_init (&error);
- if (! dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &text,
- DBUS_TYPE_INVALID)) {
- g_warning ("ERROR: %s", error.message);
- }
-
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
-
- g_debug ("Emitting 'info' signal");
- g_signal_emit (session,
- gdm_session_signals[INFO],
- 0, text);
-
- return DBUS_HANDLER_RESULT_HANDLED;
+ DBusMessage *reply;
+ DBusError error;
+ const char *text;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &text,
+ DBUS_TYPE_INVALID)) {
+ g_warning ("ERROR: %s", error.message);
+ }
+
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
+
+ g_debug ("Emitting 'info' signal");
+ g_signal_emit (session,
+ gdm_session_signals[INFO],
+ 0, text);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
gdm_session_handle_problem (GdmSession *session,
- DBusConnection *connection,
- DBusMessage *message)
+ DBusConnection *connection,
+ DBusMessage *message)
{
- DBusMessage *reply;
- DBusError error;
- const char *text;
-
- dbus_error_init (&error);
- if (! dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &text,
- DBUS_TYPE_INVALID)) {
- g_warning ("ERROR: %s", error.message);
- }
-
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
-
- g_debug ("Emitting 'problem' signal");
- g_signal_emit (session,
- gdm_session_signals[PROBLEM],
- 0, text);
- return DBUS_HANDLER_RESULT_HANDLED;
+ DBusMessage *reply;
+ DBusError error;
+ const char *text;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &text,
+ DBUS_TYPE_INVALID)) {
+ g_warning ("ERROR: %s", error.message);
+ }
+
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
+
+ g_debug ("Emitting 'problem' signal");
+ g_signal_emit (session,
+ gdm_session_signals[PROBLEM],
+ 0, text);
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
gdm_session_handle_session_started (GdmSession *session,
- DBusConnection *connection,
- DBusMessage *message)
+ DBusConnection *connection,
+ DBusMessage *message)
{
- DBusMessage *reply;
- DBusError error;
- int pid;
-
- dbus_error_init (&error);
- if (! dbus_message_get_args (message, &error,
- DBUS_TYPE_INT32, &pid,
- DBUS_TYPE_INVALID)) {
- g_warning ("ERROR: %s", error.message);
- }
+ DBusMessage *reply;
+ DBusError error;
+ int pid;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_INT32, &pid,
+ DBUS_TYPE_INVALID)) {
+ g_warning ("ERROR: %s", error.message);
+ }
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
- g_debug ("Emitting 'session-started' signal with pid '%d'",
- pid);
+ g_debug ("Emitting 'session-started' signal with pid '%d'",
+ pid);
- session->priv->session_pid = pid;
- session->priv->is_running = TRUE;
+ session->priv->session_pid = pid;
+ session->priv->is_running = TRUE;
- g_signal_emit (session,
- gdm_session_signals[SESSION_STARTED],
- 0, pid);
+ g_signal_emit (session,
+ gdm_session_signals[SESSION_STARTED],
+ 0, pid);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
gdm_session_handle_startup_failed (GdmSession *session,
- DBusConnection *connection,
- DBusMessage *message)
+ DBusConnection *connection,
+ DBusMessage *message)
{
- DBusMessage *reply;
- DBusError error;
- const char *text;
-
- dbus_error_init (&error);
- if (! dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &text,
- DBUS_TYPE_INVALID)) {
- g_warning ("ERROR: %s", error.message);
- }
+ DBusMessage *reply;
+ DBusError error;
+ const char *text;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &text,
+ DBUS_TYPE_INVALID)) {
+ g_warning ("ERROR: %s", error.message);
+ }
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
- g_debug ("Emitting 'session-startup-error' signal");
+ g_debug ("Emitting 'session-startup-error' signal");
- g_signal_emit (session,
- gdm_session_signals[SESSION_STARTUP_ERROR],
- 0, text);
+ g_signal_emit (session,
+ gdm_session_signals[SESSION_STARTUP_ERROR],
+ 0, text);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
gdm_session_handle_session_exited (GdmSession *session,
- DBusConnection *connection,
- DBusMessage *message)
+ DBusConnection *connection,
+ DBusMessage *message)
{
- DBusMessage *reply;
- DBusError error;
- int code;
-
- dbus_error_init (&error);
- if (! dbus_message_get_args (message, &error,
- DBUS_TYPE_INT32, &code,
- DBUS_TYPE_INVALID)) {
- g_warning ("ERROR: %s", error.message);
- }
-
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
-
- g_debug ("Emitting 'session-exited' signal with exit code '%d'",
- code);
-
- session->priv->is_running = FALSE;
- g_signal_emit (session,
- gdm_session_signals[SESSION_EXITED],
- 0, code);
-
- return DBUS_HANDLER_RESULT_HANDLED;
+ DBusMessage *reply;
+ DBusError error;
+ int code;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_INT32, &code,
+ DBUS_TYPE_INVALID)) {
+ g_warning ("ERROR: %s", error.message);
+ }
+
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
+
+ g_debug ("Emitting 'session-exited' signal with exit code '%d'",
+ code);
+
+ session->priv->is_running = FALSE;
+ g_signal_emit (session,
+ gdm_session_signals[SESSION_EXITED],
+ 0, code);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
gdm_session_handle_session_died (GdmSession *session,
- DBusConnection *connection,
- DBusMessage *message)
+ DBusConnection *connection,
+ DBusMessage *message)
{
- DBusMessage *reply;
- DBusError error;
- int code;
-
- dbus_error_init (&error);
- if (! dbus_message_get_args (message, &error,
- DBUS_TYPE_INT32, &code,
- DBUS_TYPE_INVALID)) {
- g_warning ("ERROR: %s", error.message);
- }
-
- reply = dbus_message_new_method_return (message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
-
- g_debug ("Emitting 'session-died' signal with signal number '%d'",
- code);
-
- session->priv->is_running = FALSE;
- g_signal_emit (session,
- gdm_session_signals[SESSION_DIED],
- 0, code);
- return DBUS_HANDLER_RESULT_HANDLED;
+ DBusMessage *reply;
+ DBusError error;
+ int code;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_INT32, &code,
+ DBUS_TYPE_INVALID)) {
+ g_warning ("ERROR: %s", error.message);
+ }
+
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
+
+ g_debug ("Emitting 'session-died' signal with signal number '%d'",
+ code);
+
+ session->priv->is_running = FALSE;
+ g_signal_emit (session,
+ gdm_session_signals[SESSION_DIED],
+ 0, code);
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
session_worker_message (DBusConnection *connection,
- DBusMessage *message,
- void *user_data)
+ DBusMessage *message,
+ void *user_data)
{
GdmSession *session = GDM_SESSION (user_data);
- if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "Verified")) {
- return gdm_session_handle_verified (session, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "VerificationFailed")) {
- return gdm_session_handle_verification_failed (session, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "UsernameChanged")) {
- return gdm_session_handle_username_changed (session, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "InfoQuery")) {
- return gdm_session_handle_info_query (session, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "SecretInfoQuery")) {
- return gdm_session_handle_secret_info_query (session, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "Info")) {
- return gdm_session_handle_info (session, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "Problem")) {
- return gdm_session_handle_problem (session, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "SessionStarted")) {
- return gdm_session_handle_session_started (session, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "StartupFailed")) {
- return gdm_session_handle_startup_failed (session, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "SessionExited")) {
- return gdm_session_handle_session_exited (session, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "SessionDied")) {
- return gdm_session_handle_session_died (session, connection, message);
- }
+ if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "Verified")) {
+ return gdm_session_handle_verified (session, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "VerificationFailed")) {
+ return gdm_session_handle_verification_failed (session, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "UsernameChanged")) {
+ return gdm_session_handle_username_changed (session, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "InfoQuery")) {
+ return gdm_session_handle_info_query (session, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "SecretInfoQuery")) {
+ return gdm_session_handle_secret_info_query (session, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "Info")) {
+ return gdm_session_handle_info (session, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "Problem")) {
+ return gdm_session_handle_problem (session, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "SessionStarted")) {
+ return gdm_session_handle_session_started (session, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "StartupFailed")) {
+ return gdm_session_handle_startup_failed (session, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "SessionExited")) {
+ return gdm_session_handle_session_exited (session, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "SessionDied")) {
+ return gdm_session_handle_session_died (session, connection, message);
+ }
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
static DBusHandlerResult
do_introspect (DBusConnection *connection,
- DBusMessage *message)
+ DBusMessage *message)
{
- DBusMessage *reply;
- GString *xml;
- char *xml_string;
-
- g_debug ("Do introspect");
-
- /* standard header */
- xml = g_string_new ("<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
- "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
- "<node>\n"
- " <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
- " <method name=\"Introspect\">\n"
- " <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
- " </method>\n"
- " </interface>\n");
-
- /* interface */
- xml = g_string_append (xml,
- " <interface name=\"org.gnome.DisplayManager.Session\">\n"
- " <method name=\"Verified\">\n"
- " </method>\n"
- " <method name=\"VerificationFailed\">\n"
- " <arg name=\"message\" direction=\"in\" type=\"s\"/>\n"
- " </method>\n"
- " <method name=\"InfoQuery\">\n"
- " <arg name=\"query\" direction=\"in\" type=\"s\"/>\n"
- " <arg name=\"answer\" direction=\"out\" type=\"s\"/>\n"
- " </method>\n"
- " <method name=\"SecretInfoQuery\">\n"
- " <arg name=\"query\" direction=\"in\" type=\"s\"/>\n"
- " <arg name=\"answer\" direction=\"out\" type=\"s\"/>\n"
- " </method>\n"
- " <method name=\"Info\">\n"
- " <arg name=\"text\" direction=\"in\" type=\"s\"/>\n"
- " </method>\n"
- " <method name=\"Problem\">\n"
- " <arg name=\"text\" direction=\"in\" type=\"s\"/>\n"
- " </method>\n"
- " <method name=\"UsernameChanged\">\n"
- " <arg name=\"text\" direction=\"in\" type=\"s\"/>\n"
- " </method>\n"
- " <method name=\"StartupFailed\">\n"
- " <arg name=\"message\" direction=\"in\" type=\"s\"/>\n"
- " </method>\n"
- " <method name=\"SessionStarted\">\n"
- " <arg name=\"pid\" direction=\"in\" type=\"i\"/>\n"
- " </method>\n"
- " <method name=\"SessionExited\">\n"
- " <arg name=\"code\" direction=\"in\" type=\"i\"/>\n"
- " </method>\n"
- " <method name=\"SessionDied\">\n"
- " <arg name=\"signal\" direction=\"in\" type=\"i\"/>\n"
- " </method>\n"
- " <signal name=\"BeginVerification\">\n"
- " <arg name=\"service_name\" type=\"s\"/>\n"
- " <arg name=\"hostname\" type=\"s\"/>\n"
- " <arg name=\"console\" type=\"s\"/>\n"
- " </signal>\n"
- " <signal name=\"BeginVerificationForUser\">\n"
- " <arg name=\"service_name\" type=\"s\"/>\n"
- " <arg name=\"hostname\" type=\"s\"/>\n"
- " <arg name=\"console\" type=\"s\"/>\n"
- " <arg name=\"username\" type=\"s\"/>\n"
- " </signal>\n"
- " <signal name=\"StartProgram\">\n"
- " <arg name=\"command\" type=\"s\"/>\n"
- " </signal>\n"
- " <signal name=\"SetEnvironmentVariable\">\n"
- " <arg name=\"name\" type=\"s\"/>\n"
- " <arg name=\"value\" type=\"s\"/>\n"
- " </signal>\n"
- " <signal name=\"Reset\">\n"
- " </signal>\n"
- " </interface>\n");
-
- reply = dbus_message_new_method_return (message);
-
- xml = g_string_append (xml, "</node>\n");
- xml_string = g_string_free (xml, FALSE);
-
- dbus_message_append_args (reply,
- DBUS_TYPE_STRING, &xml_string,
- DBUS_TYPE_INVALID);
-
- g_free (xml_string);
-
- if (reply == NULL) {
- g_error ("No memory");
- }
-
- if (! dbus_connection_send (connection, reply, NULL)) {
- g_error ("No memory");
- }
-
- dbus_message_unref (reply);
-
- return DBUS_HANDLER_RESULT_HANDLED;
+ DBusMessage *reply;
+ GString *xml;
+ char *xml_string;
+
+ g_debug ("Do introspect");
+
+ /* standard header */
+ xml = g_string_new ("<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
+ "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
+ "<node>\n"
+ " <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
+ " <method name=\"Introspect\">\n"
+ " <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
+ " </method>\n"
+ " </interface>\n");
+
+ /* interface */
+ xml = g_string_append (xml,
+ " <interface name=\"org.gnome.DisplayManager.Session\">\n"
+ " <method name=\"Verified\">\n"
+ " </method>\n"
+ " <method name=\"VerificationFailed\">\n"
+ " <arg name=\"message\" direction=\"in\" type=\"s\"/>\n"
+ " </method>\n"
+ " <method name=\"InfoQuery\">\n"
+ " <arg name=\"query\" direction=\"in\" type=\"s\"/>\n"
+ " <arg name=\"answer\" direction=\"out\" type=\"s\"/>\n"
+ " </method>\n"
+ " <method name=\"SecretInfoQuery\">\n"
+ " <arg name=\"query\" direction=\"in\" type=\"s\"/>\n"
+ " <arg name=\"answer\" direction=\"out\" type=\"s\"/>\n"
+ " </method>\n"
+ " <method name=\"Info\">\n"
+ " <arg name=\"text\" direction=\"in\" type=\"s\"/>\n"
+ " </method>\n"
+ " <method name=\"Problem\">\n"
+ " <arg name=\"text\" direction=\"in\" type=\"s\"/>\n"
+ " </method>\n"
+ " <method name=\"UsernameChanged\">\n"
+ " <arg name=\"text\" direction=\"in\" type=\"s\"/>\n"
+ " </method>\n"
+ " <method name=\"StartupFailed\">\n"
+ " <arg name=\"message\" direction=\"in\" type=\"s\"/>\n"
+ " </method>\n"
+ " <method name=\"SessionStarted\">\n"
+ " <arg name=\"pid\" direction=\"in\" type=\"i\"/>\n"
+ " </method>\n"
+ " <method name=\"SessionExited\">\n"
+ " <arg name=\"code\" direction=\"in\" type=\"i\"/>\n"
+ " </method>\n"
+ " <method name=\"SessionDied\">\n"
+ " <arg name=\"signal\" direction=\"in\" type=\"i\"/>\n"
+ " </method>\n"
+ " <signal name=\"BeginVerification\">\n"
+ " <arg name=\"service_name\" type=\"s\"/>\n"
+ " <arg name=\"hostname\" type=\"s\"/>\n"
+ " <arg name=\"console\" type=\"s\"/>\n"
+ " </signal>\n"
+ " <signal name=\"BeginVerificationForUser\">\n"
+ " <arg name=\"service_name\" type=\"s\"/>\n"
+ " <arg name=\"hostname\" type=\"s\"/>\n"
+ " <arg name=\"console\" type=\"s\"/>\n"
+ " <arg name=\"username\" type=\"s\"/>\n"
+ " </signal>\n"
+ " <signal name=\"StartProgram\">\n"
+ " <arg name=\"command\" type=\"s\"/>\n"
+ " </signal>\n"
+ " <signal name=\"SetEnvironmentVariable\">\n"
+ " <arg name=\"name\" type=\"s\"/>\n"
+ " <arg name=\"value\" type=\"s\"/>\n"
+ " </signal>\n"
+ " <signal name=\"Reset\">\n"
+ " </signal>\n"
+ " </interface>\n");
+
+ reply = dbus_message_new_method_return (message);
+
+ xml = g_string_append (xml, "</node>\n");
+ xml_string = g_string_free (xml, FALSE);
+
+ dbus_message_append_args (reply,
+ DBUS_TYPE_STRING, &xml_string,
+ DBUS_TYPE_INVALID);
+
+ g_free (xml_string);
+
+ if (reply == NULL) {
+ g_error ("No memory");
+ }
+
+ if (! dbus_connection_send (connection, reply, NULL)) {
+ g_error ("No memory");
+ }
+
+ dbus_message_unref (reply);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
session_message_handler (DBusConnection *connection,
- DBusMessage *message,
- void *user_data)
+ DBusMessage *message,
+ void *user_data)
{
- g_debug ("session_message_handler: destination=%s obj_path=%s interface=%s method=%s",
- dbus_message_get_destination (message),
- dbus_message_get_path (message),
- dbus_message_get_interface (message),
- dbus_message_get_member (message));
+ g_debug ("session_message_handler: destination=%s obj_path=%s interface=%s method=%s",
+ dbus_message_get_destination (message),
+ dbus_message_get_path (message),
+ dbus_message_get_interface (message),
+ dbus_message_get_member (message));
if (dbus_message_is_method_call (message, "org.freedesktop.DBus", "AddMatch")) {
@@ -1095,13 +1095,13 @@ session_message_handler (DBusConnection *connection,
} else if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected") &&
strcmp (dbus_message_get_path (message), DBUS_PATH_LOCAL) == 0) {
- g_debug ("Disconnected here");
+ g_debug ("Disconnected here");
/*dbus_connection_unref (connection);*/
return DBUS_HANDLER_RESULT_HANDLED;
- } else if (dbus_message_is_method_call (message, "org.freedesktop.DBus.Introspectable", "Introspect")) {
- return do_introspect (connection, message);
+ } else if (dbus_message_is_method_call (message, "org.freedesktop.DBus.Introspectable", "Introspect")) {
+ return do_introspect (connection, message);
} else {
return session_worker_message (connection, message, user_data);
}
@@ -1115,68 +1115,68 @@ session_message_handler (DBusConnection *connection,
static char *
generate_address (void)
{
- char *path;
+ char *path;
#if defined (__linux__)
- int i;
- char tmp[9];
-
- for (i = 0; i < 8; i++) {
- if (g_random_int_range (0, 2) == 0) {
- tmp[i] = g_random_int_range ('a', 'z' + 1);
- } else {
- tmp[i] = g_random_int_range ('A', 'Z' + 1);
- }
- }
- tmp[8] = '\0';
-
- path = g_strdup_printf ("unix:abstract=/tmp/gdm-session-%s", tmp);
+ int i;
+ char tmp[9];
+
+ for (i = 0; i < 8; i++) {
+ if (g_random_int_range (0, 2) == 0) {
+ tmp[i] = g_random_int_range ('a', 'z' + 1);
+ } else {
+ tmp[i] = g_random_int_range ('A', 'Z' + 1);
+ }
+ }
+ tmp[8] = '\0';
+
+ path = g_strdup_printf ("unix:abstract=/tmp/gdm-session-%s", tmp);
#else
- path = g_strdup ("unix:tmpdir=/tmp/gdm-session");
+ path = g_strdup ("unix:tmpdir=/tmp/gdm-session");
#endif
- return path;
+ return path;
}
static void
session_unregister_handler (DBusConnection *connection,
- void *user_data)
+ void *user_data)
{
- g_debug ("session_unregister_handler");
+ g_debug ("session_unregister_handler");
}
static DBusHandlerResult
connection_filter_function (DBusConnection *connection,
- DBusMessage *message,
- void *user_data)
+ DBusMessage *message,
+ void *user_data)
{
GdmSession *session = GDM_SESSION (user_data);
- const char *path;
+ const char *path;
- path = dbus_message_get_path (message);
+ path = dbus_message_get_path (message);
- g_debug ("obj_path=%s interface=%s method=%s",
- dbus_message_get_path (message),
- dbus_message_get_interface (message),
- dbus_message_get_member (message));
+ g_debug ("obj_path=%s interface=%s method=%s",
+ dbus_message_get_path (message),
+ dbus_message_get_interface (message),
+ dbus_message_get_member (message));
- if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected")
- && strcmp (path, DBUS_PATH_LOCAL) == 0) {
+ if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected")
+ && strcmp (path, DBUS_PATH_LOCAL) == 0) {
- g_debug ("Disconnected");
+ g_debug ("Disconnected");
- /*dbus_connection_unref (connection);*/
- session->priv->worker_connection = NULL;
+ /*dbus_connection_unref (connection);*/
+ session->priv->worker_connection = NULL;
- g_debug ("Emitting closed signal");
- g_signal_emit (session, gdm_session_signals [CLOSED], 0);
- } else if (dbus_message_is_signal (message, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {
+ g_debug ("Emitting closed signal");
+ g_signal_emit (session, gdm_session_signals [CLOSED], 0);
+ } else if (dbus_message_is_signal (message, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {
- } else {
- return session_message_handler (connection, message, user_data);
- }
+ } else {
+ return session_message_handler (connection, message, user_data);
+ }
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static dbus_bool_t
@@ -1184,215 +1184,215 @@ allow_user_function (DBusConnection *connection,
unsigned long uid,
void *data)
{
- if (0 == uid) {
- return TRUE;
- }
+ if (0 == uid) {
+ return TRUE;
+ }
- g_debug ("User not allowed");
+ g_debug ("User not allowed");
- return FALSE;
+ return FALSE;
}
static void
handle_connection (DBusServer *server,
- DBusConnection *new_connection,
- void *user_data)
+ DBusConnection *new_connection,
+ void *user_data)
{
GdmSession *session = GDM_SESSION (user_data);
- g_debug ("Handing new connection");
+ g_debug ("Handing new connection");
- if (session->priv->worker_connection == NULL) {
- DBusObjectPathVTable vtable = { &session_unregister_handler,
- &session_message_handler,
- NULL, NULL, NULL, NULL
- };
+ if (session->priv->worker_connection == NULL) {
+ DBusObjectPathVTable vtable = { &session_unregister_handler,
+ &session_message_handler,
+ NULL, NULL, NULL, NULL
+ };
- session->priv->worker_connection = new_connection;
- dbus_connection_ref (new_connection);
- dbus_connection_setup_with_g_main (new_connection, NULL);
+ session->priv->worker_connection = new_connection;
+ dbus_connection_ref (new_connection);
+ dbus_connection_setup_with_g_main (new_connection, NULL);
- g_debug ("worker connection is %p", new_connection);
+ g_debug ("worker connection is %p", new_connection);
#if 0
- dbus_connection_add_filter (new_connection,
- connection_filter_function,
- session,
- NULL);
+ dbus_connection_add_filter (new_connection,
+ connection_filter_function,
+ session,
+ NULL);
#endif
- dbus_connection_set_exit_on_disconnect (new_connection, FALSE);
+ dbus_connection_set_exit_on_disconnect (new_connection, FALSE);
- dbus_connection_set_unix_user_function (new_connection,
- allow_user_function,
- session,
- NULL);
+ dbus_connection_set_unix_user_function (new_connection,
+ allow_user_function,
+ session,
+ NULL);
- dbus_connection_register_object_path (new_connection,
- GDM_SESSION_DBUS_PATH,
- &vtable,
- session);
+ dbus_connection_register_object_path (new_connection,
+ GDM_SESSION_DBUS_PATH,
+ &vtable,
+ session);
- g_debug ("Emitting opened signal");
- g_signal_emit (session, gdm_session_signals [OPENED], 0);
- }
+ g_debug ("Emitting opened signal");
+ g_signal_emit (session, gdm_session_signals [OPENED], 0);
+ }
}
static gboolean
setup_server (GdmSession *session)
{
- DBusError error;
- gboolean ret;
- char *address;
- const char *auth_mechanisms[] = {"EXTERNAL", NULL};
+ DBusError error;
+ gboolean ret;
+ char *address;
+ const char *auth_mechanisms[] = {"EXTERNAL", NULL};
- ret = FALSE;
+ ret = FALSE;
- g_debug ("Creating D-Bus server for session");
+ g_debug ("Creating D-Bus server for session");
- address = generate_address ();
+ address = generate_address ();
- dbus_error_init (&error);
- session->priv->server = dbus_server_listen (address, &error);
- g_free (address);
+ dbus_error_init (&error);
+ session->priv->server = dbus_server_listen (address, &error);
+ g_free (address);
- if (session->priv->server == NULL) {
- g_warning ("Cannot create D-BUS server for the session: %s", error.message);
- goto out;
- }
+ if (session->priv->server == NULL) {
+ g_warning ("Cannot create D-BUS server for the session: %s", error.message);
+ goto out;
+ }
- dbus_server_setup_with_g_main (session->priv->server, NULL);
- dbus_server_set_auth_mechanisms (session->priv->server, auth_mechanisms);
- dbus_server_set_new_connection_function (session->priv->server,
- handle_connection,
- session,
- NULL);
- ret = TRUE;
+ dbus_server_setup_with_g_main (session->priv->server, NULL);
+ dbus_server_set_auth_mechanisms (session->priv->server, auth_mechanisms);
+ dbus_server_set_new_connection_function (session->priv->server,
+ handle_connection,
+ session,
+ NULL);
+ ret = TRUE;
- g_free (session->priv->server_address);
- session->priv->server_address = dbus_server_get_address (session->priv->server);
+ g_free (session->priv->server_address);
+ session->priv->server_address = dbus_server_get_address (session->priv->server);
- g_debug ("D-Bus server listening on %s", session->priv->server_address);
+ g_debug ("D-Bus server listening on %s", session->priv->server_address);
out:
- return ret;
+ return ret;
}
static void
gdm_session_init (GdmSession *session)
{
- session->priv = G_TYPE_INSTANCE_GET_PRIVATE (session,
- GDM_TYPE_SESSION,
- GdmSessionPrivate);
+ session->priv = G_TYPE_INSTANCE_GET_PRIVATE (session,
+ GDM_TYPE_SESSION,
+ GdmSessionPrivate);
- session->priv->environment = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_free);
+ session->priv->environment = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) g_free);
- setup_server (session);
+ setup_server (session);
}
GdmSession *
gdm_session_new (void)
{
- GdmSession *session;
+ GdmSession *session;
- session = g_object_new (GDM_TYPE_SESSION, NULL);
+ session = g_object_new (GDM_TYPE_SESSION, NULL);
- return session;
+ return session;
}
static void
worker_stopped (GdmSessionWorkerJob *job,
- GdmSession *session)
+ GdmSession *session)
{
- g_debug ("Worker job stopped");
+ g_debug ("Worker job stopped");
}
static void
worker_started (GdmSessionWorkerJob *job,
- GdmSession *session)
+ GdmSession *session)
{
- g_debug ("Worker job started");
+ g_debug ("Worker job started");
}
static void
worker_exited (GdmSessionWorkerJob *job,
- int code,
- GdmSession *session)
+ int code,
+ GdmSession *session)
{
- g_debug ("Worker job exited: %d", code);
-
- if (!session->priv->is_verified) {
- GError *error;
-
- error = g_error_new (GDM_SESSION_ERROR,
- GDM_SESSION_ERROR_WORKER_DIED,
- _("worker exited with status %d"),
- code);
-
- g_signal_emit (session,
- gdm_session_signals [USER_VERIFICATION_ERROR],
- 0, error);
- g_error_free (error);
- } else if (session->priv->is_running) {
- g_signal_emit (session,
- gdm_session_signals [SESSION_EXITED],
- 0, code);
- }
+ g_debug ("Worker job exited: %d", code);
+
+ if (!session->priv->is_verified) {
+ GError *error;
+
+ error = g_error_new (GDM_SESSION_ERROR,
+ GDM_SESSION_ERROR_WORKER_DIED,
+ _("worker exited with status %d"),
+ code);
+
+ g_signal_emit (session,
+ gdm_session_signals [USER_VERIFICATION_ERROR],
+ 0, error);
+ g_error_free (error);
+ } else if (session->priv->is_running) {
+ g_signal_emit (session,
+ gdm_session_signals [SESSION_EXITED],
+ 0, code);
+ }
}
static void
worker_died (GdmSessionWorkerJob *job,
- int signum,
- GdmSession *session)
+ int signum,
+ GdmSession *session)
{
- g_debug ("Worker job died: %d", signum);
-
- if (!session->priv->is_verified) {
- GError *error;
- error = g_error_new (GDM_SESSION_ERROR,
- GDM_SESSION_ERROR_WORKER_DIED,
- _("worker got signal '%s' and was subsequently killed"),
- g_strsignal (signum));
- g_signal_emit (session,
- gdm_session_signals[USER_VERIFICATION_ERROR],
- 0, error);
- g_error_free (error);
- } else if (session->priv->is_running) {
- g_signal_emit (session,
- gdm_session_signals[SESSION_EXITED],
- 0, signum);
- }
+ g_debug ("Worker job died: %d", signum);
+
+ if (!session->priv->is_verified) {
+ GError *error;
+ error = g_error_new (GDM_SESSION_ERROR,
+ GDM_SESSION_ERROR_WORKER_DIED,
+ _("worker got signal '%s' and was subsequently killed"),
+ g_strsignal (signum));
+ g_signal_emit (session,
+ gdm_session_signals[USER_VERIFICATION_ERROR],
+ 0, error);
+ g_error_free (error);
+ } else if (session->priv->is_running) {
+ g_signal_emit (session,
+ gdm_session_signals[SESSION_EXITED],
+ 0, signum);
+ }
}
static gboolean
start_worker (GdmSession *session)
{
- gboolean res;
-
- session->priv->job = gdm_session_worker_job_new ();
- gdm_session_worker_job_set_server_address (session->priv->job, session->priv->server_address);
- g_signal_connect (session->priv->job,
- "stopped",
- G_CALLBACK (worker_stopped),
- session);
- g_signal_connect (session->priv->job,
- "started",
- G_CALLBACK (worker_started),
- session);
- g_signal_connect (session->priv->job,
- "exited",
- G_CALLBACK (worker_exited),
- session);
- g_signal_connect (session->priv->job,
- "died",
- G_CALLBACK (worker_died),
- session);
-
- res = gdm_session_worker_job_start (session->priv->job);
-
- return res;
+ gboolean res;
+
+ session->priv->job = gdm_session_worker_job_new ();
+ gdm_session_worker_job_set_server_address (session->priv->job, session->priv->server_address);
+ g_signal_connect (session->priv->job,
+ "stopped",
+ G_CALLBACK (worker_stopped),
+ session);
+ g_signal_connect (session->priv->job,
+ "started",
+ G_CALLBACK (worker_started),
+ session);
+ g_signal_connect (session->priv->job,
+ "exited",
+ G_CALLBACK (worker_exited),
+ session);
+ g_signal_connect (session->priv->job,
+ "died",
+ G_CALLBACK (worker_died),
+ session);
+
+ res = gdm_session_worker_job_start (session->priv->job);
+
+ return res;
}
gboolean
@@ -1402,185 +1402,185 @@ gdm_session_open (GdmSession *session,
const char *console_name,
GError **error)
{
- gboolean res;
+ gboolean res;
- g_return_val_if_fail (session != NULL, FALSE);
- g_return_val_if_fail (service_name != NULL, FALSE);
- g_return_val_if_fail (console_name != NULL, FALSE);
- g_return_val_if_fail (hostname != NULL, FALSE);
+ g_return_val_if_fail (session != NULL, FALSE);
+ g_return_val_if_fail (service_name != NULL, FALSE);
+ g_return_val_if_fail (console_name != NULL, FALSE);
+ g_return_val_if_fail (hostname != NULL, FALSE);
- g_debug ("Openning session");
+ g_debug ("Openning session");
- res = start_worker (session);
+ res = start_worker (session);
- session->priv->service_name = g_strdup (service_name);
- session->priv->hostname = g_strdup (hostname);
- session->priv->console_name = g_strdup (console_name);
+ session->priv->service_name = g_strdup (service_name);
+ session->priv->hostname = g_strdup (hostname);
+ session->priv->console_name = g_strdup (console_name);
- return res;
+ return res;
}
static void
send_begin_verification (GdmSession *session)
{
- DBusMessage *message;
- DBusMessageIter iter;
+ DBusMessage *message;
+ DBusMessageIter iter;
- g_debug ("Beginning verification");
+ g_debug ("Beginning verification");
- message = dbus_message_new_signal (GDM_SESSION_DBUS_PATH,
- GDM_SESSION_DBUS_INTERFACE,
- "BeginVerification");
+ message = dbus_message_new_signal (GDM_SESSION_DBUS_PATH,
+ GDM_SESSION_DBUS_INTERFACE,
+ "BeginVerification");
- dbus_message_iter_init_append (message, &iter);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &session->priv->service_name);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &session->priv->hostname);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &session->priv->console_name);
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &session->priv->service_name);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &session->priv->hostname);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &session->priv->console_name);
- if (! send_dbus_message (session->priv->worker_connection, message)) {
- g_debug ("Could not send %s signal", "BeginVerification");
- }
+ if (! send_dbus_message (session->priv->worker_connection, message)) {
+ g_debug ("Could not send %s signal", "BeginVerification");
+ }
- dbus_message_unref (message);
+ dbus_message_unref (message);
}
static void
send_begin_verification_for_user (GdmSession *session)
{
- DBusMessage *message;
- DBusMessageIter iter;
+ DBusMessage *message;
+ DBusMessageIter iter;
- g_debug ("Beginning verification for user %s", session->priv->username);
+ g_debug ("Beginning verification for user %s", session->priv->username);
- message = dbus_message_new_signal (GDM_SESSION_DBUS_PATH,
- GDM_SESSION_DBUS_INTERFACE,
- "BeginVerificationForUser");
+ message = dbus_message_new_signal (GDM_SESSION_DBUS_PATH,
+ GDM_SESSION_DBUS_INTERFACE,
+ "BeginVerificationForUser");
- dbus_message_iter_init_append (message, &iter);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &session->priv->service_name);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &session->priv->hostname);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &session->priv->console_name);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &session->priv->username);
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &session->priv->service_name);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &session->priv->hostname);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &session->priv->console_name);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &session->priv->username);
- if (! send_dbus_message (session->priv->worker_connection, message)) {
- g_debug ("Could not send %s signal", "BeginVerificationForUser");
- }
+ if (! send_dbus_message (session->priv->worker_connection, message)) {
+ g_debug ("Could not send %s signal", "BeginVerificationForUser");
+ }
- dbus_message_unref (message);
+ dbus_message_unref (message);
}
gboolean
gdm_session_begin_verification (GdmSession *session,
- const char *username,
- GError **error)
+ const char *username,
+ GError **error)
{
- g_return_val_if_fail (session != NULL, FALSE);
- g_return_val_if_fail (dbus_connection_get_is_connected (session->priv->worker_connection), FALSE);
+ g_return_val_if_fail (session != NULL, FALSE);
+ g_return_val_if_fail (dbus_connection_get_is_connected (session->priv->worker_connection), FALSE);
- session->priv->username = g_strdup (username);
+ session->priv->username = g_strdup (username);
- if (username == NULL) {
- send_begin_verification (session);
- } else {
- send_begin_verification_for_user (session);
- }
+ if (username == NULL) {
+ send_begin_verification (session);
+ } else {
+ send_begin_verification_for_user (session);
+ }
- return TRUE;
+ return TRUE;
}
static void
send_environment_variable (const char *key,
- const char *value,
- GdmSession *session)
+ const char *value,
+ GdmSession *session)
{
- DBusMessage *message;
- DBusMessageIter iter;
+ DBusMessage *message;
+ DBusMessageIter iter;
- message = dbus_message_new_signal (GDM_SESSION_DBUS_PATH,
- GDM_SESSION_DBUS_INTERFACE,
- "SetEnvironmentVariable");
+ message = dbus_message_new_signal (GDM_SESSION_DBUS_PATH,
+ GDM_SESSION_DBUS_INTERFACE,
+ "SetEnvironmentVariable");
- dbus_message_iter_init_append (message, &iter);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &key);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &value);
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &key);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &value);
- if (! send_dbus_message (session->priv->worker_connection, message)) {
- g_debug ("Could not send %s signal", "SetEnvironmentVariable");
- }
+ if (! send_dbus_message (session->priv->worker_connection, message)) {
+ g_debug ("Could not send %s signal", "SetEnvironmentVariable");
+ }
- dbus_message_unref (message);
+ dbus_message_unref (message);
}
static void
send_environment (GdmSession *session)
{
- g_hash_table_foreach (session->priv->environment,
- (GHFunc) send_environment_variable,
- session);
+ g_hash_table_foreach (session->priv->environment,
+ (GHFunc) send_environment_variable,
+ session);
}
void
gdm_session_start_program (GdmSession *session,
- const char *command)
+ const char *command)
{
- g_return_if_fail (session != NULL);
- g_return_if_fail (session != NULL);
- g_return_if_fail (gdm_session_is_running (session) == FALSE);
- g_return_if_fail (command != NULL);
+ g_return_if_fail (session != NULL);
+ g_return_if_fail (session != NULL);
+ g_return_if_fail (gdm_session_is_running (session) == FALSE);
+ g_return_if_fail (command != NULL);
- send_environment (session);
+ send_environment (session);
- send_dbus_string_signal (session, "StartProgram", command);
+ send_dbus_string_signal (session, "StartProgram", command);
}
void
gdm_session_close (GdmSession *session)
{
- g_return_if_fail (session != NULL);
+ g_return_if_fail (session != NULL);
- g_debug ("Closing session");
+ g_debug ("Closing session");
- if (session->priv->job != NULL) {
- if (session->priv->is_running) {
- gdm_session_write_record (session,
- GDM_SESSION_RECORD_TYPE_LOGOUT);
- }
+ if (session->priv->job != NULL) {
+ if (session->priv->is_running) {
+ gdm_session_write_record (session,
+ GDM_SESSION_RECORD_TYPE_LOGOUT);
+ }
- cancel_pending_query (session);
+ cancel_pending_query (session);
- if (session->priv->worker_connection != NULL) {
- dbus_connection_close (session->priv->worker_connection);
- }
+ if (session->priv->worker_connection != NULL) {
+ dbus_connection_close (session->priv->worker_connection);
+ }
- gdm_session_worker_job_stop (session->priv->job);
- }
+ gdm_session_worker_job_stop (session->priv->job);
+ }
- session->priv->is_running = FALSE;
- session->priv->is_verified = FALSE;
+ session->priv->is_running = FALSE;
+ session->priv->is_verified = FALSE;
- if (session->priv->service_name) {
- g_free (session->priv->service_name);
- session->priv->service_name = NULL;
- }
+ if (session->priv->service_name) {
+ g_free (session->priv->service_name);
+ session->priv->service_name = NULL;
+ }
- if (session->priv->hostname) {
- g_free (session->priv->hostname);
- session->priv->hostname = NULL;
- }
+ if (session->priv->hostname) {
+ g_free (session->priv->hostname);
+ session->priv->hostname = NULL;
+ }
- if (session->priv->username) {
- g_free (session->priv->username);
- session->priv->username = NULL;
- }
+ if (session->priv->username) {
+ g_free (session->priv->username);
+ session->priv->username = NULL;
+ }
}
gboolean
gdm_session_is_running (GdmSession *session)
{
- g_return_val_if_fail (session != NULL, FALSE);
+ g_return_val_if_fail (session != NULL, FALSE);
- return session->priv->is_running;
+ return session->priv->is_running;
}
void
@@ -1588,29 +1588,29 @@ gdm_session_set_environment_variable (GdmSession *session,
const char *key,
const char *value)
{
- g_return_if_fail (session != NULL);
- g_return_if_fail (session != NULL);
- g_return_if_fail (key != NULL);
- g_return_if_fail (value != NULL);
-
- g_hash_table_replace (session->priv->environment,
- g_strdup (key),
- g_strdup (value));
+ g_return_if_fail (session != NULL);
+ g_return_if_fail (session != NULL);
+ g_return_if_fail (key != NULL);
+ g_return_if_fail (value != NULL);
+
+ g_hash_table_replace (session->priv->environment,
+ g_strdup (key),
+ g_strdup (value));
}
void
gdm_session_answer_query (GdmSession *session,
const char *answer)
{
- g_return_if_fail (session != NULL);
+ g_return_if_fail (session != NULL);
- answer_pending_query (session, answer);
+ answer_pending_query (session, answer);
}
char *
gdm_session_get_username (GdmSession *session)
{
- g_return_val_if_fail (session != NULL, NULL);
+ g_return_val_if_fail (session != NULL, NULL);
- return g_strdup (session->priv->username);
+ return g_strdup (session->priv->username);
}
diff --git a/daemon/gdm-session.h b/daemon/gdm-session.h
index a1db5375..8b43d02c 100644
--- a/daemon/gdm-session.h
+++ b/daemon/gdm-session.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* session.h - authenticates and authorizes users with system
*
@@ -39,61 +39,61 @@ typedef struct _GdmSessionPrivate GdmSessionPrivate;
typedef struct
{
- GObject parent;
+ GObject parent;
- /*< private > */
- GdmSessionPrivate *priv;
+ /*< private > */
+ GdmSessionPrivate *priv;
} GdmSession;
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
- /* signals */
- void (* opened) (GdmSession *session);
- void (* closed) (GdmSession *session);
+ /* signals */
+ void (* opened) (GdmSession *session);
+ void (* closed) (GdmSession *session);
- void (* user_verified) (GdmSession *session);
+ void (* user_verified) (GdmSession *session);
- void (* user_verification_error) (GdmSession *session,
- GError *error);
+ void (* user_verification_error) (GdmSession *session,
+ GError *error);
- void (* info_query) (GdmSession *session,
- const char *query_text);
+ void (* info_query) (GdmSession *session,
+ const char *query_text);
- void (* secret_info_query) (GdmSession *session,
- const char *query_text);
+ void (* secret_info_query) (GdmSession *session,
+ const char *query_text);
- void (* info) (GdmSession *session,
- const char *info);
+ void (* info) (GdmSession *session,
+ const char *info);
- void (* problem) (GdmSession *session,
- const char *problem);
+ void (* problem) (GdmSession *session,
+ const char *problem);
- void (* session_started) (GdmSession *session,
- GPid pid);
+ void (* session_started) (GdmSession *session,
+ GPid pid);
- void (* session_startup_error) (GdmSession *session,
- GError *error);
+ void (* session_startup_error) (GdmSession *session,
+ GError *error);
- void (* session_exited) (GdmSession *session,
- int exit_code);
+ void (* session_exited) (GdmSession *session,
+ int exit_code);
- void (* session_died) (GdmSession *session,
- int signal_number);
+ void (* session_died) (GdmSession *session,
+ int signal_number);
} GdmSessionClass;
typedef enum _GdmSessionError {
- GDM_SESSION_ERROR_GENERIC = 0,
- GDM_SESSION_ERROR_WITH_SESSION_COMMAND,
- GDM_SESSION_ERROR_FORKING,
- GDM_SESSION_ERROR_COMMUNICATING,
- GDM_SESSION_ERROR_WORKER_DIED,
- GDM_SESSION_ERROR_AUTHENTICATING,
- GDM_SESSION_ERROR_AUTHORIZING,
- GDM_SESSION_ERROR_OPENING_LOG_FILE,
- GDM_SESSION_ERROR_OPENING_SESSION,
- GDM_SESSION_ERROR_GIVING_CREDENTIALS
+ GDM_SESSION_ERROR_GENERIC = 0,
+ GDM_SESSION_ERROR_WITH_SESSION_COMMAND,
+ GDM_SESSION_ERROR_FORKING,
+ GDM_SESSION_ERROR_COMMUNICATING,
+ GDM_SESSION_ERROR_WORKER_DIED,
+ GDM_SESSION_ERROR_AUTHENTICATING,
+ GDM_SESSION_ERROR_AUTHORIZING,
+ GDM_SESSION_ERROR_OPENING_LOG_FILE,
+ GDM_SESSION_ERROR_OPENING_SESSION,
+ GDM_SESSION_ERROR_GIVING_CREDENTIALS
} GdmSessionError;
GType gdm_session_get_type (void);
@@ -102,22 +102,22 @@ GQuark gdm_session_error_quark (void);
GdmSession * gdm_session_new (void) G_GNUC_MALLOC;
gboolean gdm_session_open (GdmSession *session,
- const char *service_name,
- const char *hostname,
- const char *console_name,
- GError **error);
+ const char *service_name,
+ const char *hostname,
+ const char *console_name,
+ GError **error);
void gdm_session_close (GdmSession *session);
gboolean gdm_session_begin_verification (GdmSession *session,
- const char *username,
- GError **error);
+ const char *username,
+ GError **error);
void gdm_session_start_program (GdmSession *session,
- const char *command);
+ const char *command);
void gdm_session_set_environment_variable (GdmSession *session,
- const char *key,
- const char *value);
+ const char *key,
+ const char *value);
void gdm_session_answer_query (GdmSession *session,
- const char *answer);
+ const char *answer);
char * gdm_session_get_username (GdmSession *session);
diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c
index 7428b8f3..dbbcf15b 100644
--- a/daemon/gdm-simple-slave.c
+++ b/daemon/gdm-simple-slave.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -57,91 +57,91 @@
#define GDM_SIMPLE_SLAVE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_SIMPLE_SLAVE, GdmSimpleSlavePrivate))
-#define GDM_DBUS_NAME "org.gnome.DisplayManager"
+#define GDM_DBUS_NAME "org.gnome.DisplayManager"
#define GDM_DBUS_DISPLAY_INTERFACE "org.gnome.DisplayManager.Display"
#define MAX_CONNECT_ATTEMPTS 10
struct GdmSimpleSlavePrivate
{
- char *id;
- GPid pid;
+ char *id;
+ GPid pid;
guint output_watch_id;
guint error_watch_id;
- guint greeter_reset_id;
+ guint greeter_reset_id;
- int ping_interval;
+ int ping_interval;
- GPid server_pid;
- Display *server_display;
- guint connection_attempts;
+ GPid server_pid;
+ Display *server_display;
+ guint connection_attempts;
- /* user selected */
- char *selected_session;
- char *selected_language;
- char *selected_user;
+ /* user selected */
+ char *selected_session;
+ char *selected_language;
+ char *selected_user;
- CkConnector *ckc;
- GdmServer *server;
- GdmGreeterServer *greeter_server;
- GdmGreeterProxy *greeter;
- GdmSession *session;
- DBusGProxy *display_proxy;
+ CkConnector *ckc;
+ GdmServer *server;
+ GdmGreeterServer *greeter_server;
+ GdmGreeterProxy *greeter;
+ GdmSession *session;
+ DBusGProxy *display_proxy;
DBusGConnection *connection;
};
enum {
- PROP_0,
- PROP_DISPLAY_ID,
+ PROP_0,
+ PROP_DISPLAY_ID,
};
enum {
- SESSION_STARTED,
- SESSION_EXITED,
- SESSION_DIED,
- LAST_SIGNAL
+ SESSION_STARTED,
+ SESSION_EXITED,
+ SESSION_DIED,
+ LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0, };
-static void gdm_simple_slave_class_init (GdmSimpleSlaveClass *klass);
-static void gdm_simple_slave_init (GdmSimpleSlave *simple_slave);
-static void gdm_simple_slave_finalize (GObject *object);
+static void gdm_simple_slave_class_init (GdmSimpleSlaveClass *klass);
+static void gdm_simple_slave_init (GdmSimpleSlave *simple_slave);
+static void gdm_simple_slave_finalize (GObject *object);
G_DEFINE_TYPE (GdmSimpleSlave, gdm_simple_slave, GDM_TYPE_SLAVE)
static void
set_busy_cursor (GdmSimpleSlave *simple_slave)
{
- if (simple_slave->priv->server_display != NULL) {
- Cursor xcursor;
-
- xcursor = XCreateFontCursor (simple_slave->priv->server_display, GDK_WATCH);
- XDefineCursor (simple_slave->priv->server_display,
- DefaultRootWindow (simple_slave->priv->server_display),
- xcursor);
- XFreeCursor (simple_slave->priv->server_display, xcursor);
- XSync (simple_slave->priv->server_display, False);
- }
+ if (simple_slave->priv->server_display != NULL) {
+ Cursor xcursor;
+
+ xcursor = XCreateFontCursor (simple_slave->priv->server_display, GDK_WATCH);
+ XDefineCursor (simple_slave->priv->server_display,
+ DefaultRootWindow (simple_slave->priv->server_display),
+ xcursor);
+ XFreeCursor (simple_slave->priv->server_display, xcursor);
+ XSync (simple_slave->priv->server_display, False);
+ }
}
static void
gdm_simple_slave_whack_temp_auth_file (GdmSimpleSlave *simple_slave)
{
#if 0
- uid_t old;
-
- old = geteuid ();
- if (old != 0)
- seteuid (0);
- if (d->parent_temp_auth_file != NULL) {
- VE_IGNORE_EINTR (g_unlink (d->parent_temp_auth_file));
- }
- g_free (d->parent_temp_auth_file);
- d->parent_temp_auth_file = NULL;
- if (old != 0)
- seteuid (old);
+ uid_t old;
+
+ old = geteuid ();
+ if (old != 0)
+ seteuid (0);
+ if (d->parent_temp_auth_file != NULL) {
+ VE_IGNORE_EINTR (g_unlink (d->parent_temp_auth_file));
+ }
+ g_free (d->parent_temp_auth_file);
+ d->parent_temp_auth_file = NULL;
+ if (old != 0)
+ seteuid (old);
#endif
}
@@ -150,439 +150,439 @@ static void
create_temp_auth_file (GdmSimpleSlave *simple_slave)
{
#if 0
- if (d->type == TYPE_FLEXI_XNEST &&
- d->parent_auth_file != NULL) {
- if (d->parent_temp_auth_file != NULL) {
- VE_IGNORE_EINTR (g_unlink (d->parent_temp_auth_file));
- }
- g_free (d->parent_temp_auth_file);
- d->parent_temp_auth_file =
- copy_auth_file (d->server_uid,
- gdm_daemon_config_get_gdmuid (),
- d->parent_auth_file);
- }
+ if (d->type == TYPE_FLEXI_XNEST &&
+ d->parent_auth_file != NULL) {
+ if (d->parent_temp_auth_file != NULL) {
+ VE_IGNORE_EINTR (g_unlink (d->parent_temp_auth_file));
+ }
+ g_free (d->parent_temp_auth_file);
+ d->parent_temp_auth_file =
+ copy_auth_file (d->server_uid,
+ gdm_daemon_config_get_gdmuid (),
+ d->parent_auth_file);
+ }
#endif
}
static void
listify_hash (const char *key,
- const char *value,
- GPtrArray *env)
+ const char *value,
+ GPtrArray *env)
{
- char *str;
- str = g_strdup_printf ("%s=%s", key, value);
- g_debug ("script environment: %s", str);
- g_ptr_array_add (env, str);
+ char *str;
+ str = g_strdup_printf ("%s=%s", key, value);
+ g_debug ("script environment: %s", str);
+ g_ptr_array_add (env, str);
}
static GPtrArray *
get_script_environment (GdmSimpleSlave *slave,
- const char *username)
+ const char *username)
{
- GPtrArray *env;
- GHashTable *hash;
- struct passwd *pwent;
- char *x_servers_file;
- char *display_name;
- char *display_hostname;
- char *display_x11_authority_file;
- gboolean display_is_local;
-
- display_name = NULL;
- display_hostname = NULL;
- display_x11_authority_file = NULL;
- display_is_local = FALSE;
-
- g_object_get (slave,
- "display-name", &display_name,
- "display-hostname", &display_hostname,
- "display-is-local", &display_is_local,
- "display-x11-authority-file", &display_x11_authority_file,
- NULL);
-
- env = g_ptr_array_new ();
-
- /* create a hash table of current environment, then update keys has necessary */
- hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-
- /* modify environment here */
- g_hash_table_insert (hash, g_strdup ("HOME"), g_strdup ("/"));
- g_hash_table_insert (hash, g_strdup ("PWD"), g_strdup ("/"));
- g_hash_table_insert (hash, g_strdup ("SHELL"), g_strdup ("/bin/sh"));
-
- g_hash_table_insert (hash, g_strdup ("LOGNAME"), g_strdup (username));
- g_hash_table_insert (hash, g_strdup ("USER"), g_strdup (username));
- g_hash_table_insert (hash, g_strdup ("USERNAME"), g_strdup (username));
-
- pwent = getpwnam (username);
- if (pwent != NULL) {
- if (pwent->pw_dir != NULL && pwent->pw_dir[0] != '\0') {
- g_hash_table_insert (hash, g_strdup ("HOME"), g_strdup (pwent->pw_dir));
- g_hash_table_insert (hash, g_strdup ("PWD"), g_strdup (pwent->pw_dir));
- }
-
- g_hash_table_insert (hash, g_strdup ("SHELL"), g_strdup (pwent->pw_shell));
- }
+ GPtrArray *env;
+ GHashTable *hash;
+ struct passwd *pwent;
+ char *x_servers_file;
+ char *display_name;
+ char *display_hostname;
+ char *display_x11_authority_file;
+ gboolean display_is_local;
+
+ display_name = NULL;
+ display_hostname = NULL;
+ display_x11_authority_file = NULL;
+ display_is_local = FALSE;
+
+ g_object_get (slave,
+ "display-name", &display_name,
+ "display-hostname", &display_hostname,
+ "display-is-local", &display_is_local,
+ "display-x11-authority-file", &display_x11_authority_file,
+ NULL);
+
+ env = g_ptr_array_new ();
+
+ /* create a hash table of current environment, then update keys has necessary */
+ hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
+ /* modify environment here */
+ g_hash_table_insert (hash, g_strdup ("HOME"), g_strdup ("/"));
+ g_hash_table_insert (hash, g_strdup ("PWD"), g_strdup ("/"));
+ g_hash_table_insert (hash, g_strdup ("SHELL"), g_strdup ("/bin/sh"));
+
+ g_hash_table_insert (hash, g_strdup ("LOGNAME"), g_strdup (username));
+ g_hash_table_insert (hash, g_strdup ("USER"), g_strdup (username));
+ g_hash_table_insert (hash, g_strdup ("USERNAME"), g_strdup (username));
+
+ pwent = getpwnam (username);
+ if (pwent != NULL) {
+ if (pwent->pw_dir != NULL && pwent->pw_dir[0] != '\0') {
+ g_hash_table_insert (hash, g_strdup ("HOME"), g_strdup (pwent->pw_dir));
+ g_hash_table_insert (hash, g_strdup ("PWD"), g_strdup (pwent->pw_dir));
+ }
+
+ g_hash_table_insert (hash, g_strdup ("SHELL"), g_strdup (pwent->pw_shell));
+ }
#if 0
- if (display_is_parented) {
- g_hash_table_insert (hash, g_strdup ("GDM_PARENT_DISPLAY"), g_strdup (parent_display_name));
+ if (display_is_parented) {
+ g_hash_table_insert (hash, g_strdup ("GDM_PARENT_DISPLAY"), g_strdup (parent_display_name));
- /*g_hash_table_insert (hash, "GDM_PARENT_XAUTHORITY"), slave->priv->parent_temp_auth_file));*/
- }
+ /*g_hash_table_insert (hash, "GDM_PARENT_XAUTHORITY"), slave->priv->parent_temp_auth_file));*/
+ }
#endif
- /* some env for use with the Pre and Post scripts */
- x_servers_file = gdm_make_filename (AUTHDIR,
- display_name,
- ".Xservers");
- g_hash_table_insert (hash, g_strdup ("X_SERVERS"), x_servers_file);
+ /* some env for use with the Pre and Post scripts */
+ x_servers_file = gdm_make_filename (AUTHDIR,
+ display_name,
+ ".Xservers");
+ g_hash_table_insert (hash, g_strdup ("X_SERVERS"), x_servers_file);
- if (! display_is_local) {
- g_hash_table_insert (hash, g_strdup ("REMOTE_HOST"), g_strdup (display_hostname));
- }
+ if (! display_is_local) {
+ g_hash_table_insert (hash, g_strdup ("REMOTE_HOST"), g_strdup (display_hostname));
+ }
- /* Runs as root */
- g_hash_table_insert (hash, g_strdup ("XAUTHORITY"), g_strdup (display_x11_authority_file));
- g_hash_table_insert (hash, g_strdup ("DISPLAY"), g_strdup (display_name));
+ /* Runs as root */
+ g_hash_table_insert (hash, g_strdup ("XAUTHORITY"), g_strdup (display_x11_authority_file));
+ g_hash_table_insert (hash, g_strdup ("DISPLAY"), g_strdup (display_name));
- /*g_setenv ("PATH", gdm_daemon_config_get_value_string (GDM_KEY_ROOT_PATH), TRUE);*/
+ /*g_setenv ("PATH", gdm_daemon_config_get_value_string (GDM_KEY_ROOT_PATH), TRUE);*/
- g_hash_table_insert (hash, g_strdup ("RUNNING_UNDER_GDM"), g_strdup ("true"));
+ g_hash_table_insert (hash, g_strdup ("RUNNING_UNDER_GDM"), g_strdup ("true"));
#if 0
- if ( ! ve_string_empty (d->theme_name))
- g_setenv ("GDM_GTK_THEME", d->theme_name, TRUE);
+ if ( ! ve_string_empty (d->theme_name))
+ g_setenv ("GDM_GTK_THEME", d->theme_name, TRUE);
#endif
- g_hash_table_remove (hash, "MAIL");
+ g_hash_table_remove (hash, "MAIL");
- g_hash_table_foreach (hash, (GHFunc)listify_hash, env);
- g_hash_table_destroy (hash);
+ g_hash_table_foreach (hash, (GHFunc)listify_hash, env);
+ g_hash_table_destroy (hash);
- g_ptr_array_add (env, NULL);
+ g_ptr_array_add (env, NULL);
- g_free (display_name);
- g_free (display_hostname);
- g_free (display_x11_authority_file);
+ g_free (display_name);
+ g_free (display_hostname);
+ g_free (display_x11_authority_file);
- return env;
+ return env;
}
static gboolean
gdm_simple_slave_exec_script (GdmSimpleSlave *slave,
- const char *dir,
- const char *login)
+ const char *dir,
+ const char *login)
{
- char *script;
- char **argv;
- gint status;
- GError *error;
- GPtrArray *env;
- gboolean res;
- gboolean ret;
- char *display_name;
- char *display_hostname;
-
- g_assert (dir != NULL);
- g_assert (login != NULL);
-
- g_object_get (slave,
- "display-name", &display_name,
- "display-hostname", &display_hostname,
- NULL);
-
- script = g_build_filename (dir, display_name, NULL);
- if (g_access (script, R_OK|X_OK) != 0) {
- g_free (script);
- script = NULL;
- }
-
- if (script == NULL &&
- display_hostname != NULL) {
- script = g_build_filename (dir, display_hostname, NULL);
- if (g_access (script, R_OK|X_OK) != 0) {
- g_free (script);
- script = NULL;
- }
- }
+ char *script;
+ char **argv;
+ gint status;
+ GError *error;
+ GPtrArray *env;
+ gboolean res;
+ gboolean ret;
+ char *display_name;
+ char *display_hostname;
+
+ g_assert (dir != NULL);
+ g_assert (login != NULL);
+
+ g_object_get (slave,
+ "display-name", &display_name,
+ "display-hostname", &display_hostname,
+ NULL);
+
+ script = g_build_filename (dir, display_name, NULL);
+ if (g_access (script, R_OK|X_OK) != 0) {
+ g_free (script);
+ script = NULL;
+ }
+
+ if (script == NULL &&
+ display_hostname != NULL) {
+ script = g_build_filename (dir, display_hostname, NULL);
+ if (g_access (script, R_OK|X_OK) != 0) {
+ g_free (script);
+ script = NULL;
+ }
+ }
#if 0
- if (script == NULL &&
- SERVER_IS_XDMCP (d)) {
- script = g_build_filename (dir, "XDMCP", NULL);
- if (g_access (script, R_OK|X_OK) != 0) {
- g_free (script);
- script = NULL;
- }
- }
- if (script == NULL &&
- SERVER_IS_FLEXI (d)) {
- script = g_build_filename (dir, "Flexi", NULL);
- if (g_access (script, R_OK|X_OK) != 0) {
- g_free (script);
- script = NULL;
- }
- }
+ if (script == NULL &&
+ SERVER_IS_XDMCP (d)) {
+ script = g_build_filename (dir, "XDMCP", NULL);
+ if (g_access (script, R_OK|X_OK) != 0) {
+ g_free (script);
+ script = NULL;
+ }
+ }
+ if (script == NULL &&
+ SERVER_IS_FLEXI (d)) {
+ script = g_build_filename (dir, "Flexi", NULL);
+ if (g_access (script, R_OK|X_OK) != 0) {
+ g_free (script);
+ script = NULL;
+ }
+ }
#endif
- if (script == NULL) {
- script = g_build_filename (dir, "Default", NULL);
- if (g_access (script, R_OK|X_OK) != 0) {
- g_free (script);
- script = NULL;
- }
- }
-
- if (script == NULL) {
- return TRUE;
- }
-
- create_temp_auth_file (slave);
-
- g_debug ("Running process: %s", script);
- error = NULL;
- if (! g_shell_parse_argv (script, NULL, &argv, &error)) {
- g_warning ("Could not parse command: %s", error->message);
- g_error_free (error);
- goto out;
- }
-
- env = get_script_environment (slave, login);
-
- res = g_spawn_sync (NULL,
- argv,
- (char **)env->pdata,
- G_SPAWN_SEARCH_PATH,
- NULL,
- NULL,
- NULL,
- NULL,
- &status,
- &error);
-
- g_ptr_array_foreach (env, (GFunc)g_free, NULL);
+ if (script == NULL) {
+ script = g_build_filename (dir, "Default", NULL);
+ if (g_access (script, R_OK|X_OK) != 0) {
+ g_free (script);
+ script = NULL;
+ }
+ }
+
+ if (script == NULL) {
+ return TRUE;
+ }
+
+ create_temp_auth_file (slave);
+
+ g_debug ("Running process: %s", script);
+ error = NULL;
+ if (! g_shell_parse_argv (script, NULL, &argv, &error)) {
+ g_warning ("Could not parse command: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ env = get_script_environment (slave, login);
+
+ res = g_spawn_sync (NULL,
+ argv,
+ (char **)env->pdata,
+ G_SPAWN_SEARCH_PATH,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ &status,
+ &error);
+
+ g_ptr_array_foreach (env, (GFunc)g_free, NULL);
g_ptr_array_free (env, TRUE);
- gdm_simple_slave_whack_temp_auth_file (slave);
+ gdm_simple_slave_whack_temp_auth_file (slave);
- if (WIFEXITED (status)) {
- g_debug ("Process exit status: %d", WEXITSTATUS (status));
- ret = WEXITSTATUS (status) != 0;
- } else {
- ret = TRUE;
- }
+ if (WIFEXITED (status)) {
+ g_debug ("Process exit status: %d", WEXITSTATUS (status));
+ ret = WEXITSTATUS (status) != 0;
+ } else {
+ ret = TRUE;
+ }
out:
- g_free (script);
- g_free (display_name);
- g_free (display_hostname);
+ g_free (script);
+ g_free (display_name);
+ g_free (display_hostname);
- return ret;
+ return ret;
}
static void
on_session_started (GdmSession *session,
GPid pid,
- GdmSimpleSlave *slave)
+ GdmSimpleSlave *slave)
{
- g_debug ("session started on pid %d\n", (int) pid);
- g_signal_emit (slave, signals [SESSION_STARTED], 0, pid);
+ g_debug ("session started on pid %d\n", (int) pid);
+ g_signal_emit (slave, signals [SESSION_STARTED], 0, pid);
}
static void
on_session_exited (GdmSession *session,
int exit_code,
- GdmSimpleSlave *slave)
+ GdmSimpleSlave *slave)
{
- g_debug ("session exited with code %d\n", exit_code);
+ g_debug ("session exited with code %d\n", exit_code);
- gdm_slave_stopped (GDM_SLAVE (slave));
+ gdm_slave_stopped (GDM_SLAVE (slave));
}
static void
on_session_died (GdmSession *session,
int signal_number,
- GdmSimpleSlave *slave)
+ GdmSimpleSlave *slave)
{
- g_debug ("session died with signal %d, (%s)",
- signal_number,
- g_strsignal (signal_number));
+ g_debug ("session died with signal %d, (%s)",
+ signal_number,
+ g_strsignal (signal_number));
- gdm_slave_stopped (GDM_SLAVE (slave));
+ gdm_slave_stopped (GDM_SLAVE (slave));
}
static gboolean
is_prog_in_path (const char *prog)
{
- char *f;
- gboolean ret;
+ char *f;
+ gboolean ret;
- f = g_find_program_in_path (prog);
- ret = (f != NULL);
- g_free (f);
- return ret;
+ f = g_find_program_in_path (prog);
+ ret = (f != NULL);
+ g_free (f);
+ return ret;
}
static gboolean
get_session_command (const char *file,
- char **command)
+ char **command)
{
- GKeyFile *key_file;
- GError *error;
- char *full_path;
- char *exec;
- gboolean ret;
- gboolean res;
- const char *search_dirs[] = {
- "/etc/X11/sessions/",
- DMCONFDIR "/Sessions/",
- DATADIR "/gdm/BuiltInSessions/",
- DATADIR "/xsessions/",
- NULL
- };
-
- exec = NULL;
- ret = FALSE;
- if (command != NULL) {
- *command = NULL;
- }
-
- key_file = g_key_file_new ();
-
- error = NULL;
- full_path = NULL;
- res = g_key_file_load_from_dirs (key_file,
- file,
- search_dirs,
- &full_path,
- G_KEY_FILE_NONE,
- &error);
- if (! res) {
- g_debug ("File '%s' not found: %s", file, error->message);
- g_error_free (error);
- if (command != NULL) {
- *command = NULL;
- }
- goto out;
- }
-
- error = NULL;
- res = g_key_file_get_boolean (key_file,
- G_KEY_FILE_DESKTOP_GROUP,
- G_KEY_FILE_DESKTOP_KEY_HIDDEN,
- &error);
- if (error == NULL && res) {
- g_debug ("Session %s is marked as hidden", file);
- goto out;
- }
-
- error = NULL;
- exec = g_key_file_get_string (key_file,
- G_KEY_FILE_DESKTOP_GROUP,
- G_KEY_FILE_DESKTOP_KEY_TRY_EXEC,
- &error);
- if (exec == NULL) {
- g_debug ("%s key not found", G_KEY_FILE_DESKTOP_KEY_TRY_EXEC);
- goto out;
- }
-
- res = is_prog_in_path (exec);
- g_free (exec);
-
- if (! res) {
- g_debug ("Command not found: %s", G_KEY_FILE_DESKTOP_KEY_TRY_EXEC);
- goto out;
- }
-
- error = NULL;
- exec = g_key_file_get_string (key_file,
- G_KEY_FILE_DESKTOP_GROUP,
- G_KEY_FILE_DESKTOP_KEY_EXEC,
- &error);
- if (error != NULL) {
- g_debug ("%s key not found: %s",
- G_KEY_FILE_DESKTOP_KEY_EXEC,
- error->message);
- g_error_free (error);
- goto out;
- }
-
- if (command != NULL) {
- *command = g_strdup (exec);
- }
- ret = TRUE;
+ GKeyFile *key_file;
+ GError *error;
+ char *full_path;
+ char *exec;
+ gboolean ret;
+ gboolean res;
+ const char *search_dirs[] = {
+ "/etc/X11/sessions/",
+ DMCONFDIR "/Sessions/",
+ DATADIR "/gdm/BuiltInSessions/",
+ DATADIR "/xsessions/",
+ NULL
+ };
+
+ exec = NULL;
+ ret = FALSE;
+ if (command != NULL) {
+ *command = NULL;
+ }
+
+ key_file = g_key_file_new ();
+
+ error = NULL;
+ full_path = NULL;
+ res = g_key_file_load_from_dirs (key_file,
+ file,
+ search_dirs,
+ &full_path,
+ G_KEY_FILE_NONE,
+ &error);
+ if (! res) {
+ g_debug ("File '%s' not found: %s", file, error->message);
+ g_error_free (error);
+ if (command != NULL) {
+ *command = NULL;
+ }
+ goto out;
+ }
+
+ error = NULL;
+ res = g_key_file_get_boolean (key_file,
+ G_KEY_FILE_DESKTOP_GROUP,
+ G_KEY_FILE_DESKTOP_KEY_HIDDEN,
+ &error);
+ if (error == NULL && res) {
+ g_debug ("Session %s is marked as hidden", file);
+ goto out;
+ }
+
+ error = NULL;
+ exec = g_key_file_get_string (key_file,
+ G_KEY_FILE_DESKTOP_GROUP,
+ G_KEY_FILE_DESKTOP_KEY_TRY_EXEC,
+ &error);
+ if (exec == NULL) {
+ g_debug ("%s key not found", G_KEY_FILE_DESKTOP_KEY_TRY_EXEC);
+ goto out;
+ }
+
+ res = is_prog_in_path (exec);
+ g_free (exec);
+
+ if (! res) {
+ g_debug ("Command not found: %s", G_KEY_FILE_DESKTOP_KEY_TRY_EXEC);
+ goto out;
+ }
+
+ error = NULL;
+ exec = g_key_file_get_string (key_file,
+ G_KEY_FILE_DESKTOP_GROUP,
+ G_KEY_FILE_DESKTOP_KEY_EXEC,
+ &error);
+ if (error != NULL) {
+ g_debug ("%s key not found: %s",
+ G_KEY_FILE_DESKTOP_KEY_EXEC,
+ error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ if (command != NULL) {
+ *command = g_strdup (exec);
+ }
+ ret = TRUE;
out:
- g_free (exec);
+ g_free (exec);
- return ret;
+ return ret;
}
static gboolean
add_user_authorization (GdmSimpleSlave *slave,
- char **filename)
+ char **filename)
{
- char *username;
- gboolean ret;
+ char *username;
+ gboolean ret;
- username = gdm_session_get_username (slave->priv->session);
- ret = gdm_slave_add_user_authorization (GDM_SLAVE (slave),
- username,
- filename);
- g_free (username);
+ username = gdm_session_get_username (slave->priv->session);
+ ret = gdm_slave_add_user_authorization (GDM_SLAVE (slave),
+ username,
+ filename);
+ g_free (username);
- return ret;
+ return ret;
}
static gboolean
slave_open_ck_session (GdmSimpleSlave *slave,
- const char *display_name,
- const char *display_hostname,
- gboolean display_is_local)
+ const char *display_name,
+ const char *display_hostname,
+ gboolean display_is_local)
{
- char *username;
- char *x11_display_device;
- struct passwd *pwent;
- gboolean ret;
- int res;
- DBusError error;
+ char *username;
+ char *x11_display_device;
+ struct passwd *pwent;
+ gboolean ret;
+ int res;
+ DBusError error;
- g_return_val_if_fail (GDM_IS_SLAVE (slave), FALSE);
+ g_return_val_if_fail (GDM_IS_SLAVE (slave), FALSE);
- username = gdm_session_get_username (slave->priv->session);
+ username = gdm_session_get_username (slave->priv->session);
- x11_display_device = NULL;
+ x11_display_device = NULL;
- pwent = getpwnam (username);
- if (pwent == NULL) {
- return FALSE;
- }
+ pwent = getpwnam (username);
+ if (pwent == NULL) {
+ return FALSE;
+ }
- slave->priv->ckc = ck_connector_new ();
- if (slave->priv->ckc == NULL) {
- g_warning ("Couldn't create new ConsoleKit connector");
- goto out;
- }
+ slave->priv->ckc = ck_connector_new ();
+ if (slave->priv->ckc == NULL) {
+ g_warning ("Couldn't create new ConsoleKit connector");
+ goto out;
+ }
- if (slave->priv->server != NULL) {
- x11_display_device = gdm_server_get_display_device (slave->priv->server);
- }
+ if (slave->priv->server != NULL) {
+ x11_display_device = gdm_server_get_display_device (slave->priv->server);
+ }
- if (x11_display_device == NULL) {
- x11_display_device = g_strdup ("");
- }
+ if (x11_display_device == NULL) {
+ x11_display_device = g_strdup ("");
+ }
- dbus_error_init (&error);
+ dbus_error_init (&error);
res = ck_connector_open_session_with_parameters (slave->priv->ckc,
&error,
"unix-user", &pwent->pw_uid,
"x11-display", &display_name,
"x11-display-device", &x11_display_device,
"remote-host-name", &display_hostname,
- "is-local", &display_is_local,
+ "is-local", &display_is_local,
NULL);
- g_free (x11_display_device);
+ g_free (x11_display_device);
if (! res) {
if (dbus_error_is_set (&error)) {
@@ -590,723 +590,723 @@ slave_open_ck_session (GdmSimpleSlave *slave,
dbus_error_free (&error);
} else {
g_warning ("cannot open CK session: OOM, D-Bus system bus not available,\n"
- "ConsoleKit not available or insufficient privileges.\n");
+ "ConsoleKit not available or insufficient privileges.\n");
}
- goto out;
+ goto out;
}
- ret = TRUE;
+ ret = TRUE;
out:
- return ret;
+ return ret;
}
static void
setup_session_environment (GdmSimpleSlave *slave)
{
- int display_number;
- char *display_x11_cookie;
- char *display_name;
- char *display_hostname;
- char *auth_file;
- const char *session_cookie;
- gboolean display_is_local;
-
- display_name = NULL;
- display_hostname = NULL;
- display_x11_cookie = NULL;
- auth_file = NULL;
- session_cookie = NULL;
- display_is_local = FALSE;
-
- g_object_get (slave,
- "display-number", &display_number,
- "display-name", &display_name,
- "display-hostname", &display_hostname,
- "display-is-local", &display_is_local,
- "display-x11-cookie", &display_x11_cookie,
- NULL);
-
- add_user_authorization (slave, &auth_file);
-
- if (slave_open_ck_session (slave,
- display_name,
- display_hostname,
- display_is_local)) {
- session_cookie = ck_connector_get_cookie (slave->priv->ckc);
- }
-
- gdm_session_set_environment_variable (slave->priv->session,
- "GDMSESSION",
- slave->priv->selected_session);
- gdm_session_set_environment_variable (slave->priv->session,
- "DESKTOP_SESSION",
- slave->priv->selected_session);
-
- gdm_session_set_environment_variable (slave->priv->session,
- "LANG",
- slave->priv->selected_language);
- gdm_session_set_environment_variable (slave->priv->session,
- "GDM_LANG",
- slave->priv->selected_language);
-
- gdm_session_set_environment_variable (slave->priv->session,
- "DISPLAY",
- display_name);
- gdm_session_set_environment_variable (slave->priv->session,
- "XAUTHORITY",
- auth_file);
- if (session_cookie != NULL) {
- gdm_session_set_environment_variable (slave->priv->session,
- "XDG_SESSION_COOKIE",
- session_cookie);
- }
-
- gdm_session_set_environment_variable (slave->priv->session,
- "PATH",
- "/bin:/usr/bin:" BINDIR);
-
- g_free (display_name);
- g_free (display_hostname);
- g_free (display_x11_cookie);
- g_free (auth_file);
+ int display_number;
+ char *display_x11_cookie;
+ char *display_name;
+ char *display_hostname;
+ char *auth_file;
+ const char *session_cookie;
+ gboolean display_is_local;
+
+ display_name = NULL;
+ display_hostname = NULL;
+ display_x11_cookie = NULL;
+ auth_file = NULL;
+ session_cookie = NULL;
+ display_is_local = FALSE;
+
+ g_object_get (slave,
+ "display-number", &display_number,
+ "display-name", &display_name,
+ "display-hostname", &display_hostname,
+ "display-is-local", &display_is_local,
+ "display-x11-cookie", &display_x11_cookie,
+ NULL);
+
+ add_user_authorization (slave, &auth_file);
+
+ if (slave_open_ck_session (slave,
+ display_name,
+ display_hostname,
+ display_is_local)) {
+ session_cookie = ck_connector_get_cookie (slave->priv->ckc);
+ }
+
+ gdm_session_set_environment_variable (slave->priv->session,
+ "GDMSESSION",
+ slave->priv->selected_session);
+ gdm_session_set_environment_variable (slave->priv->session,
+ "DESKTOP_SESSION",
+ slave->priv->selected_session);
+
+ gdm_session_set_environment_variable (slave->priv->session,
+ "LANG",
+ slave->priv->selected_language);
+ gdm_session_set_environment_variable (slave->priv->session,
+ "GDM_LANG",
+ slave->priv->selected_language);
+
+ gdm_session_set_environment_variable (slave->priv->session,
+ "DISPLAY",
+ display_name);
+ gdm_session_set_environment_variable (slave->priv->session,
+ "XAUTHORITY",
+ auth_file);
+ if (session_cookie != NULL) {
+ gdm_session_set_environment_variable (slave->priv->session,
+ "XDG_SESSION_COOKIE",
+ session_cookie);
+ }
+
+ gdm_session_set_environment_variable (slave->priv->session,
+ "PATH",
+ "/bin:/usr/bin:" BINDIR);
+
+ g_free (display_name);
+ g_free (display_hostname);
+ g_free (display_x11_cookie);
+ g_free (auth_file);
}
static void
on_user_verified (GdmSession *session,
- GdmSimpleSlave *slave)
+ GdmSimpleSlave *slave)
{
- char *username;
- char *command;
- char *filename;
- gboolean res;
+ char *username;
+ char *command;
+ char *filename;
+ gboolean res;
- gdm_greeter_proxy_stop (slave->priv->greeter);
- gdm_greeter_server_stop (slave->priv->greeter_server);
+ gdm_greeter_proxy_stop (slave->priv->greeter);
+ gdm_greeter_server_stop (slave->priv->greeter_server);
- username = gdm_session_get_username (session);
+ username = gdm_session_get_username (session);
- g_debug ("%s%ssuccessfully authenticated\n",
- username ? username : "",
- username ? " " : "");
- g_free (username);
+ g_debug ("%s%ssuccessfully authenticated\n",
+ username ? username : "",
+ username ? " " : "");
+ g_free (username);
- if (slave->priv->selected_session != NULL) {
- filename = g_strdup (slave->priv->selected_session);
- } else {
- filename = g_strdup ("gnome.desktop");
- }
+ if (slave->priv->selected_session != NULL) {
+ filename = g_strdup (slave->priv->selected_session);
+ } else {
+ filename = g_strdup ("gnome.desktop");
+ }
- setup_session_environment (slave);
+ setup_session_environment (slave);
- res = get_session_command (filename, &command);
- if (! res) {
- g_warning ("Could find session file: %s", filename);
- return;
- }
+ res = get_session_command (filename, &command);
+ if (! res) {
+ g_warning ("Could find session file: %s", filename);
+ return;
+ }
- gdm_session_start_program (session, command);
+ gdm_session_start_program (session, command);
- g_free (filename);
- g_free (command);
+ g_free (filename);
+ g_free (command);
}
static gboolean
greeter_reset_timeout (GdmSimpleSlave *slave)
{
- gdm_greeter_server_reset (slave->priv->greeter_server);
- slave->priv->greeter_reset_id = 0;
- return FALSE;
+ gdm_greeter_server_reset (slave->priv->greeter_server);
+ slave->priv->greeter_reset_id = 0;
+ return FALSE;
}
static void
queue_greeter_reset (GdmSimpleSlave *slave)
{
- if (slave->priv->greeter_reset_id > 0) {
- return;
- }
+ if (slave->priv->greeter_reset_id > 0) {
+ return;
+ }
- slave->priv->greeter_reset_id = g_timeout_add_seconds (2, (GSourceFunc)greeter_reset_timeout, slave);
+ slave->priv->greeter_reset_id = g_timeout_add_seconds (2, (GSourceFunc)greeter_reset_timeout, slave);
}
static void
on_user_verification_error (GdmSession *session,
GError *error,
- GdmSimpleSlave *slave)
+ GdmSimpleSlave *slave)
{
- char *username;
+ char *username;
- username = gdm_session_get_username (session);
+ username = gdm_session_get_username (session);
- g_debug ("could not successfully authenticate user '%s': %s",
- username,
- error->message);
+ g_debug ("could not successfully authenticate user '%s': %s",
+ username,
+ error->message);
- gdm_greeter_server_problem (slave->priv->greeter_server, _("Unable to authenticate user"));
+ gdm_greeter_server_problem (slave->priv->greeter_server, _("Unable to authenticate user"));
- g_free (username);
+ g_free (username);
- queue_greeter_reset (slave);
+ queue_greeter_reset (slave);
}
static void
on_info (GdmSession *session,
const char *text,
- GdmSimpleSlave *slave)
+ GdmSimpleSlave *slave)
{
- g_debug ("Info: %s", text);
- gdm_greeter_server_info (slave->priv->greeter_server, text);
+ g_debug ("Info: %s", text);
+ gdm_greeter_server_info (slave->priv->greeter_server, text);
}
static void
on_problem (GdmSession *session,
const char *text,
- GdmSimpleSlave *slave)
+ GdmSimpleSlave *slave)
{
- g_debug ("Problem: %s", text);
- gdm_greeter_server_problem (slave->priv->greeter_server, text);
+ g_debug ("Problem: %s", text);
+ gdm_greeter_server_problem (slave->priv->greeter_server, text);
}
static void
on_info_query (GdmSession *session,
const char *text,
- GdmSimpleSlave *slave)
+ GdmSimpleSlave *slave)
{
- g_debug ("Info query: %s", text);
- gdm_greeter_server_info_query (slave->priv->greeter_server, text);
+ g_debug ("Info query: %s", text);
+ gdm_greeter_server_info_query (slave->priv->greeter_server, text);
}
static void
on_secret_info_query (GdmSession *session,
const char *text,
- GdmSimpleSlave *slave)
+ GdmSimpleSlave *slave)
{
- g_debug ("Secret info query: %s", text);
- gdm_greeter_server_secret_info_query (slave->priv->greeter_server, text);
+ g_debug ("Secret info query: %s", text);
+ gdm_greeter_server_secret_info_query (slave->priv->greeter_server, text);
}
static void
on_opened (GdmSession *session,
- GdmSimpleSlave *slave)
+ GdmSimpleSlave *slave)
{
- GError *error;
- gboolean res;
-
- g_debug ("session opened");
- res = gdm_session_begin_verification (session,
- slave->priv->selected_user,
- &error);
- if (! res) {
- g_warning ("Unable to begin verification: %s", error->message);
- g_error_free (error);
- }
+ GError *error;
+ gboolean res;
+
+ g_debug ("session opened");
+ res = gdm_session_begin_verification (session,
+ slave->priv->selected_user,
+ &error);
+ if (! res) {
+ g_warning ("Unable to begin verification: %s", error->message);
+ g_error_free (error);
+ }
}
static void
create_new_session (GdmSimpleSlave *slave)
{
- g_debug ("Creating new session");
-
- slave->priv->session = gdm_session_new ();
-
- g_signal_connect (slave->priv->session,
- "opened",
- G_CALLBACK (on_opened),
- slave);
-
- g_signal_connect (slave->priv->session,
- "info",
- G_CALLBACK (on_info),
- slave);
-
- g_signal_connect (slave->priv->session,
- "problem",
- G_CALLBACK (on_problem),
- slave);
-
- g_signal_connect (slave->priv->session,
- "info-query",
- G_CALLBACK (on_info_query),
- slave);
-
- g_signal_connect (slave->priv->session,
- "secret-info-query",
- G_CALLBACK (on_secret_info_query),
- slave);
-
- g_signal_connect (slave->priv->session,
- "user-verified",
- G_CALLBACK (on_user_verified),
- slave);
-
- g_signal_connect (slave->priv->session,
- "user-verification-error",
- G_CALLBACK (on_user_verification_error),
- slave);
-
- g_signal_connect (slave->priv->session,
- "session-started",
- G_CALLBACK (on_session_started),
- slave);
- g_signal_connect (slave->priv->session,
- "session-exited",
- G_CALLBACK (on_session_exited),
- slave);
- g_signal_connect (slave->priv->session,
- "session-died",
- G_CALLBACK (on_session_died),
- slave);
+ g_debug ("Creating new session");
+
+ slave->priv->session = gdm_session_new ();
+
+ g_signal_connect (slave->priv->session,
+ "opened",
+ G_CALLBACK (on_opened),
+ slave);
+
+ g_signal_connect (slave->priv->session,
+ "info",
+ G_CALLBACK (on_info),
+ slave);
+
+ g_signal_connect (slave->priv->session,
+ "problem",
+ G_CALLBACK (on_problem),
+ slave);
+
+ g_signal_connect (slave->priv->session,
+ "info-query",
+ G_CALLBACK (on_info_query),
+ slave);
+
+ g_signal_connect (slave->priv->session,
+ "secret-info-query",
+ G_CALLBACK (on_secret_info_query),
+ slave);
+
+ g_signal_connect (slave->priv->session,
+ "user-verified",
+ G_CALLBACK (on_user_verified),
+ slave);
+
+ g_signal_connect (slave->priv->session,
+ "user-verification-error",
+ G_CALLBACK (on_user_verification_error),
+ slave);
+
+ g_signal_connect (slave->priv->session,
+ "session-started",
+ G_CALLBACK (on_session_started),
+ slave);
+ g_signal_connect (slave->priv->session,
+ "session-exited",
+ G_CALLBACK (on_session_exited),
+ slave);
+ g_signal_connect (slave->priv->session,
+ "session-died",
+ G_CALLBACK (on_session_died),
+ slave);
}
static void
on_greeter_start (GdmGreeterProxy *greeter,
- GdmSimpleSlave *slave)
+ GdmSimpleSlave *slave)
{
- g_debug ("Greeter started");
+ g_debug ("Greeter started");
}
static void
on_greeter_stop (GdmGreeterProxy *greeter,
- GdmSimpleSlave *slave)
+ GdmSimpleSlave *slave)
{
- g_debug ("Greeter stopped");
+ g_debug ("Greeter stopped");
}
static void
on_greeter_answer (GdmGreeterServer *greeter_server,
- const char *text,
- GdmSimpleSlave *slave)
+ const char *text,
+ GdmSimpleSlave *slave)
{
- gdm_session_answer_query (slave->priv->session, text);
+ gdm_session_answer_query (slave->priv->session, text);
}
static void
on_greeter_session_selected (GdmGreeterServer *greeter_server,
- const char *text,
- GdmSimpleSlave *slave)
+ const char *text,
+ GdmSimpleSlave *slave)
{
- g_free (slave->priv->selected_session);
- slave->priv->selected_session = g_strdup (text);
+ g_free (slave->priv->selected_session);
+ slave->priv->selected_session = g_strdup (text);
}
static void
on_greeter_language_selected (GdmGreeterServer *greeter_server,
- const char *text,
- GdmSimpleSlave *slave)
+ const char *text,
+ GdmSimpleSlave *slave)
{
- g_free (slave->priv->selected_language);
- slave->priv->selected_language = g_strdup (text);
+ g_free (slave->priv->selected_language);
+ slave->priv->selected_language = g_strdup (text);
}
static void
on_greeter_user_selected (GdmGreeterServer *greeter_server,
- const char *text,
- GdmSimpleSlave *slave)
+ const char *text,
+ GdmSimpleSlave *slave)
{
}
static void
on_greeter_cancel (GdmGreeterServer *greeter_server,
- GdmSimpleSlave *slave)
+ GdmSimpleSlave *slave)
{
- g_debug ("Greeter cancelled");
+ g_debug ("Greeter cancelled");
- if (slave->priv->session != NULL) {
- gdm_session_close (slave->priv->session);
- g_object_unref (slave->priv->session);
- }
+ if (slave->priv->session != NULL) {
+ gdm_session_close (slave->priv->session);
+ g_object_unref (slave->priv->session);
+ }
- create_new_session (slave);
+ create_new_session (slave);
- gdm_session_open (slave->priv->session,
- "gdm",
- "" /* hostname */,
- "/dev/console",
- NULL);
+ gdm_session_open (slave->priv->session,
+ "gdm",
+ "" /* hostname */,
+ "/dev/console",
+ NULL);
}
static void
on_greeter_connected (GdmGreeterServer *greeter_server,
- GdmSimpleSlave *slave)
+ GdmSimpleSlave *slave)
{
- gboolean display_is_local;
+ gboolean display_is_local;
- g_object_get (slave,
- "display-is-local", &display_is_local,
- NULL);
+ g_object_get (slave,
+ "display-is-local", &display_is_local,
+ NULL);
- g_debug ("Greeter started");
+ g_debug ("Greeter started");
- gdm_session_open (slave->priv->session,
- "gdm",
- "" /* hostname */,
- "/dev/console",
- NULL);
+ gdm_session_open (slave->priv->session,
+ "gdm",
+ "" /* hostname */,
+ "/dev/console",
+ NULL);
- /* If XDMCP stop pinging */
- if ( ! display_is_local) {
- alarm (0);
- }
+ /* If XDMCP stop pinging */
+ if ( ! display_is_local) {
+ alarm (0);
+ }
}
static void
run_greeter (GdmSimpleSlave *slave)
{
- gboolean display_is_local;
- char *display_name;
- char *display_device;
- char *display_hostname;
- char *auth_file;
- char *address;
-
- g_debug ("Running greeter");
-
- display_is_local = FALSE;
- display_name = NULL;
- auth_file = NULL;
- display_device = NULL;
- display_hostname = NULL;
-
- g_object_get (slave,
- "display-is-local", &display_is_local,
- "display-name", &display_name,
- "display-hostname", &display_hostname,
- "display-x11-authority-file", &auth_file,
- NULL);
-
- g_debug ("Creating greeter for %s %s", display_name, display_hostname);
-
- if (slave->priv->server != NULL) {
- display_device = gdm_server_get_display_device (slave->priv->server);
- }
+ gboolean display_is_local;
+ char *display_name;
+ char *display_device;
+ char *display_hostname;
+ char *auth_file;
+ char *address;
+
+ g_debug ("Running greeter");
+
+ display_is_local = FALSE;
+ display_name = NULL;
+ auth_file = NULL;
+ display_device = NULL;
+ display_hostname = NULL;
+
+ g_object_get (slave,
+ "display-is-local", &display_is_local,
+ "display-name", &display_name,
+ "display-hostname", &display_hostname,
+ "display-x11-authority-file", &auth_file,
+ NULL);
+
+ g_debug ("Creating greeter for %s %s", display_name, display_hostname);
+
+ if (slave->priv->server != NULL) {
+ display_device = gdm_server_get_display_device (slave->priv->server);
+ }
- /* Set the busy cursor */
- set_busy_cursor (slave);
+ /* Set the busy cursor */
+ set_busy_cursor (slave);
- /* FIXME: send a signal back to the master */
+ /* FIXME: send a signal back to the master */
#if 0
- /* OK from now on it's really the user whacking us most likely,
- * we have already started up well */
- do_xfailed_on_xio_error = FALSE;
+ /* OK from now on it's really the user whacking us most likely,
+ * we have already started up well */
+ do_xfailed_on_xio_error = FALSE;
#endif
- /* If XDMCP setup pinging */
- if ( ! display_is_local && slave->priv->ping_interval > 0) {
- alarm (slave->priv->ping_interval);
- }
+ /* If XDMCP setup pinging */
+ if ( ! display_is_local && slave->priv->ping_interval > 0) {
+ alarm (slave->priv->ping_interval);
+ }
#if 0
- /* checkout xinerama */
- gdm_screen_init (slave);
+ /* checkout xinerama */
+ gdm_screen_init (slave);
#endif
- /* Run the init script. gdmslave suspends until script has terminated */
- gdm_simple_slave_exec_script (slave,
- GDMCONFDIR"/Init",
- "gdm");
-
- create_new_session (slave);
-
- slave->priv->greeter_server = gdm_greeter_server_new ();
- g_signal_connect (slave->priv->greeter_server,
- "query-answer",
- G_CALLBACK (on_greeter_answer),
- slave);
- g_signal_connect (slave->priv->greeter_server,
- "session-selected",
- G_CALLBACK (on_greeter_session_selected),
- slave);
- g_signal_connect (slave->priv->greeter_server,
- "language-selected",
- G_CALLBACK (on_greeter_language_selected),
- slave);
- g_signal_connect (slave->priv->greeter_server,
- "user-selected",
- G_CALLBACK (on_greeter_user_selected),
- slave);
- g_signal_connect (slave->priv->greeter_server,
- "connected",
- G_CALLBACK (on_greeter_connected),
- slave);
- g_signal_connect (slave->priv->greeter_server,
- "cancelled",
- G_CALLBACK (on_greeter_cancel),
- slave);
- gdm_greeter_server_start (slave->priv->greeter_server);
-
- address = gdm_greeter_server_get_address (slave->priv->greeter_server);
-
- g_debug ("Creating greeter on %s %s %s", display_name, display_device, display_hostname);
- slave->priv->greeter = gdm_greeter_proxy_new (display_name,
- display_device,
- display_hostname,
- display_is_local);
- g_signal_connect (slave->priv->greeter,
- "started",
- G_CALLBACK (on_greeter_start),
- slave);
- g_signal_connect (slave->priv->greeter,
- "stopped",
- G_CALLBACK (on_greeter_stop),
- slave);
- g_object_set (slave->priv->greeter,
- "x11-authority-file", auth_file,
- NULL);
- gdm_greeter_proxy_set_server_address (slave->priv->greeter, address);
- gdm_greeter_proxy_start (slave->priv->greeter);
-
- g_free (display_name);
- g_free (display_device);
- g_free (display_hostname);
- g_free (auth_file);
+ /* Run the init script. gdmslave suspends until script has terminated */
+ gdm_simple_slave_exec_script (slave,
+ GDMCONFDIR"/Init",
+ "gdm");
+
+ create_new_session (slave);
+
+ slave->priv->greeter_server = gdm_greeter_server_new ();
+ g_signal_connect (slave->priv->greeter_server,
+ "query-answer",
+ G_CALLBACK (on_greeter_answer),
+ slave);
+ g_signal_connect (slave->priv->greeter_server,
+ "session-selected",
+ G_CALLBACK (on_greeter_session_selected),
+ slave);
+ g_signal_connect (slave->priv->greeter_server,
+ "language-selected",
+ G_CALLBACK (on_greeter_language_selected),
+ slave);
+ g_signal_connect (slave->priv->greeter_server,
+ "user-selected",
+ G_CALLBACK (on_greeter_user_selected),
+ slave);
+ g_signal_connect (slave->priv->greeter_server,
+ "connected",
+ G_CALLBACK (on_greeter_connected),
+ slave);
+ g_signal_connect (slave->priv->greeter_server,
+ "cancelled",
+ G_CALLBACK (on_greeter_cancel),
+ slave);
+ gdm_greeter_server_start (slave->priv->greeter_server);
+
+ address = gdm_greeter_server_get_address (slave->priv->greeter_server);
+
+ g_debug ("Creating greeter on %s %s %s", display_name, display_device, display_hostname);
+ slave->priv->greeter = gdm_greeter_proxy_new (display_name,
+ display_device,
+ display_hostname,
+ display_is_local);
+ g_signal_connect (slave->priv->greeter,
+ "started",
+ G_CALLBACK (on_greeter_start),
+ slave);
+ g_signal_connect (slave->priv->greeter,
+ "stopped",
+ G_CALLBACK (on_greeter_stop),
+ slave);
+ g_object_set (slave->priv->greeter,
+ "x11-authority-file", auth_file,
+ NULL);
+ gdm_greeter_proxy_set_server_address (slave->priv->greeter, address);
+ gdm_greeter_proxy_start (slave->priv->greeter);
+
+ g_free (display_name);
+ g_free (display_device);
+ g_free (display_hostname);
+ g_free (auth_file);
}
static void
set_local_auth (GdmSimpleSlave *slave)
{
- GString *binary_cookie;
- GString *cookie;
- char *display_x11_cookie;
-
- g_object_get (slave,
- "display-x11-cookie", &display_x11_cookie,
- NULL);
-
- g_debug ("Setting authorization key for display %s", display_x11_cookie);
-
- cookie = g_string_new (display_x11_cookie);
- binary_cookie = g_string_new (NULL);
- if (! gdm_string_hex_decode (cookie,
- 0,
- NULL,
- binary_cookie,
- 0)) {
- g_warning ("Unable to decode hex cookie");
- goto out;
- }
-
- g_debug ("Decoded cookie len %d", binary_cookie->len);
-
- XSetAuthorization ("MIT-MAGIC-COOKIE-1",
- (int) strlen ("MIT-MAGIC-COOKIE-1"),
- (char *)binary_cookie->str,
- binary_cookie->len);
+ GString *binary_cookie;
+ GString *cookie;
+ char *display_x11_cookie;
+
+ g_object_get (slave,
+ "display-x11-cookie", &display_x11_cookie,
+ NULL);
+
+ g_debug ("Setting authorization key for display %s", display_x11_cookie);
+
+ cookie = g_string_new (display_x11_cookie);
+ binary_cookie = g_string_new (NULL);
+ if (! gdm_string_hex_decode (cookie,
+ 0,
+ NULL,
+ binary_cookie,
+ 0)) {
+ g_warning ("Unable to decode hex cookie");
+ goto out;
+ }
+
+ g_debug ("Decoded cookie len %d", binary_cookie->len);
+
+ XSetAuthorization ("MIT-MAGIC-COOKIE-1",
+ (int) strlen ("MIT-MAGIC-COOKIE-1"),
+ (char *)binary_cookie->str,
+ binary_cookie->len);
out:
- g_string_free (binary_cookie, TRUE);
- g_string_free (cookie, TRUE);
- g_free (display_x11_cookie);
+ g_string_free (binary_cookie, TRUE);
+ g_string_free (cookie, TRUE);
+ g_free (display_x11_cookie);
}
static gboolean
connect_to_display (GdmSimpleSlave *slave)
{
- char *display_name;
- gboolean ret;
+ char *display_name;
+ gboolean ret;
- ret = FALSE;
+ ret = FALSE;
- g_object_get (slave,
- "display-name", &display_name,
- NULL);
+ g_object_get (slave,
+ "display-name", &display_name,
+ NULL);
- /* We keep our own (windowless) connection (dsp) open to avoid the
- * X server resetting due to lack of active connections. */
+ /* We keep our own (windowless) connection (dsp) open to avoid the
+ * X server resetting due to lack of active connections. */
- g_debug ("Server is ready - opening display %s", display_name);
+ g_debug ("Server is ready - opening display %s", display_name);
- g_setenv ("DISPLAY", display_name, TRUE);
- g_unsetenv ("XAUTHORITY"); /* just in case it's set */
+ g_setenv ("DISPLAY", display_name, TRUE);
+ g_unsetenv ("XAUTHORITY"); /* just in case it's set */
- set_local_auth (slave);
+ set_local_auth (slave);
#if 0
- /* X error handlers to avoid the default one (i.e. exit (1)) */
- do_xfailed_on_xio_error = TRUE;
- XSetErrorHandler (gdm_simple_slave_xerror_handler);
- XSetIOErrorHandler (gdm_simple_slave_xioerror_handler);
+ /* X error handlers to avoid the default one (i.e. exit (1)) */
+ do_xfailed_on_xio_error = TRUE;
+ XSetErrorHandler (gdm_simple_slave_xerror_handler);
+ XSetIOErrorHandler (gdm_simple_slave_xioerror_handler);
#endif
- gdm_sigchld_block_push ();
- slave->priv->server_display = XOpenDisplay (display_name);
- gdm_sigchld_block_pop ();
+ gdm_sigchld_block_push ();
+ slave->priv->server_display = XOpenDisplay (display_name);
+ gdm_sigchld_block_pop ();
- if (slave->priv->server_display == NULL) {
- g_warning ("Unable to connect to display %s", display_name);
- ret = FALSE;
- } else {
- g_debug ("Connected to display %s", display_name);
- ret = TRUE;
- }
+ if (slave->priv->server_display == NULL) {
+ g_warning ("Unable to connect to display %s", display_name);
+ ret = FALSE;
+ } else {
+ g_debug ("Connected to display %s", display_name);
+ ret = TRUE;
+ }
- g_free (display_name);
+ g_free (display_name);
- return ret;
+ return ret;
}
static gboolean
idle_connect_to_display (GdmSimpleSlave *slave)
{
- gboolean res;
+ gboolean res;
- slave->priv->connection_attempts++;
+ slave->priv->connection_attempts++;
- res = connect_to_display (slave);
- if (res) {
- /* FIXME: handle wait-for-go */
+ res = connect_to_display (slave);
+ if (res) {
+ /* FIXME: handle wait-for-go */
- run_greeter (slave);
- } else {
- if (slave->priv->connection_attempts >= MAX_CONNECT_ATTEMPTS) {
- g_warning ("Unable to connect to display after %d tries - bailing out", slave->priv->connection_attempts);
- exit (1);
- }
- }
+ run_greeter (slave);
+ } else {
+ if (slave->priv->connection_attempts >= MAX_CONNECT_ATTEMPTS) {
+ g_warning ("Unable to connect to display after %d tries - bailing out", slave->priv->connection_attempts);
+ exit (1);
+ }
+ }
- return FALSE;
+ return FALSE;
}
static void
server_ready_cb (GdmServer *server,
- GdmSimpleSlave *slave)
+ GdmSimpleSlave *slave)
{
- g_timeout_add (500, (GSourceFunc)idle_connect_to_display, slave);
+ g_timeout_add (500, (GSourceFunc)idle_connect_to_display, slave);
}
static gboolean
gdm_simple_slave_run (GdmSimpleSlave *slave)
{
- char *display_name;
- gboolean display_is_local;
-
- g_object_get (slave,
- "display-is-local", &display_is_local,
- "display-name", &display_name,
- NULL);
-
- /* if this is local display start a server if one doesn't
- * exist */
- if (display_is_local) {
- gboolean res;
-
- slave->priv->server = gdm_server_new (display_name);
-
- g_signal_connect (slave->priv->server,
- "ready",
- G_CALLBACK (server_ready_cb),
- slave);
-
- res = gdm_server_start (slave->priv->server);
- if (! res) {
- g_warning (_("Could not start the X "
- "server (your graphical environment) "
- "due to some internal error. "
- "Please contact your system administrator "
- "or check your syslog to diagnose. "
- "In the meantime this display will be "
- "disabled. Please restart GDM when "
- "the problem is corrected."));
- exit (1);
- }
-
- g_debug ("Started X server");
- } else {
- g_timeout_add (500, (GSourceFunc)idle_connect_to_display, slave);
- }
-
- g_free (display_name);
-
- return TRUE;
+ char *display_name;
+ gboolean display_is_local;
+
+ g_object_get (slave,
+ "display-is-local", &display_is_local,
+ "display-name", &display_name,
+ NULL);
+
+ /* if this is local display start a server if one doesn't
+ * exist */
+ if (display_is_local) {
+ gboolean res;
+
+ slave->priv->server = gdm_server_new (display_name);
+
+ g_signal_connect (slave->priv->server,
+ "ready",
+ G_CALLBACK (server_ready_cb),
+ slave);
+
+ res = gdm_server_start (slave->priv->server);
+ if (! res) {
+ g_warning (_("Could not start the X "
+ "server (your graphical environment) "
+ "due to some internal error. "
+ "Please contact your system administrator "
+ "or check your syslog to diagnose. "
+ "In the meantime this display will be "
+ "disabled. Please restart GDM when "
+ "the problem is corrected."));
+ exit (1);
+ }
+
+ g_debug ("Started X server");
+ } else {
+ g_timeout_add (500, (GSourceFunc)idle_connect_to_display, slave);
+ }
+
+ g_free (display_name);
+
+ return TRUE;
}
static gboolean
gdm_simple_slave_start (GdmSlave *slave)
{
- gboolean res;
+ gboolean res;
- res = GDM_SLAVE_CLASS (gdm_simple_slave_parent_class)->start (slave);
+ res = GDM_SLAVE_CLASS (gdm_simple_slave_parent_class)->start (slave);
- gdm_simple_slave_run (GDM_SIMPLE_SLAVE (slave));
+ gdm_simple_slave_run (GDM_SIMPLE_SLAVE (slave));
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_simple_slave_stop (GdmSlave *slave)
{
- gboolean res;
+ gboolean res;
- g_debug ("Stopping simple_slave");
+ g_debug ("Stopping simple_slave");
- res = GDM_SLAVE_CLASS (gdm_simple_slave_parent_class)->stop (slave);
+ res = GDM_SLAVE_CLASS (gdm_simple_slave_parent_class)->stop (slave);
- if (GDM_SIMPLE_SLAVE (slave)->priv->greeter != NULL) {
- gdm_greeter_proxy_stop (GDM_SIMPLE_SLAVE (slave)->priv->greeter);
- g_object_unref (GDM_SIMPLE_SLAVE (slave)->priv->greeter);
- GDM_SIMPLE_SLAVE (slave)->priv->greeter = NULL;
- }
+ if (GDM_SIMPLE_SLAVE (slave)->priv->greeter != NULL) {
+ gdm_greeter_proxy_stop (GDM_SIMPLE_SLAVE (slave)->priv->greeter);
+ g_object_unref (GDM_SIMPLE_SLAVE (slave)->priv->greeter);
+ GDM_SIMPLE_SLAVE (slave)->priv->greeter = NULL;
+ }
- if (GDM_SIMPLE_SLAVE (slave)->priv->session != NULL) {
- gdm_session_close (GDM_SIMPLE_SLAVE (slave)->priv->session);
- g_object_unref (GDM_SIMPLE_SLAVE (slave)->priv->session);
- GDM_SIMPLE_SLAVE (slave)->priv->session = NULL;
- }
+ if (GDM_SIMPLE_SLAVE (slave)->priv->session != NULL) {
+ gdm_session_close (GDM_SIMPLE_SLAVE (slave)->priv->session);
+ g_object_unref (GDM_SIMPLE_SLAVE (slave)->priv->session);
+ GDM_SIMPLE_SLAVE (slave)->priv->session = NULL;
+ }
- if (GDM_SIMPLE_SLAVE (slave)->priv->server != NULL) {
- gdm_server_stop (GDM_SIMPLE_SLAVE (slave)->priv->server);
- g_object_unref (GDM_SIMPLE_SLAVE (slave)->priv->server);
- GDM_SIMPLE_SLAVE (slave)->priv->server = NULL;
- }
+ if (GDM_SIMPLE_SLAVE (slave)->priv->server != NULL) {
+ gdm_server_stop (GDM_SIMPLE_SLAVE (slave)->priv->server);
+ g_object_unref (GDM_SIMPLE_SLAVE (slave)->priv->server);
+ GDM_SIMPLE_SLAVE (slave)->priv->server = NULL;
+ }
- if (GDM_SIMPLE_SLAVE (slave)->priv->display_proxy != NULL) {
- g_object_unref (GDM_SIMPLE_SLAVE (slave)->priv->display_proxy);
- }
+ if (GDM_SIMPLE_SLAVE (slave)->priv->display_proxy != NULL) {
+ g_object_unref (GDM_SIMPLE_SLAVE (slave)->priv->display_proxy);
+ }
- return TRUE;
+ return TRUE;
}
static void
gdm_simple_slave_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GdmSimpleSlave *self;
+ GdmSimpleSlave *self;
- self = GDM_SIMPLE_SLAVE (object);
+ self = GDM_SIMPLE_SLAVE (object);
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_simple_slave_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GdmSimpleSlave *self;
+ GdmSimpleSlave *self;
- self = GDM_SIMPLE_SLAVE (object);
+ self = GDM_SIMPLE_SLAVE (object);
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static GObject *
gdm_simple_slave_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
{
GdmSimpleSlave *simple_slave;
GdmSimpleSlaveClass *klass;
@@ -1314,8 +1314,8 @@ gdm_simple_slave_constructor (GType type,
klass = GDM_SIMPLE_SLAVE_CLASS (g_type_class_peek (GDM_TYPE_SIMPLE_SLAVE));
simple_slave = GDM_SIMPLE_SLAVE (G_OBJECT_CLASS (gdm_simple_slave_parent_class)->constructor (type,
- n_construct_properties,
- construct_properties));
+ n_construct_properties,
+ construct_properties));
return G_OBJECT (simple_slave);
}
@@ -1323,64 +1323,64 @@ gdm_simple_slave_constructor (GType type,
static void
gdm_simple_slave_class_init (GdmSimpleSlaveClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GdmSlaveClass *slave_class = GDM_SLAVE_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GdmSlaveClass *slave_class = GDM_SLAVE_CLASS (klass);
- object_class->get_property = gdm_simple_slave_get_property;
- object_class->set_property = gdm_simple_slave_set_property;
+ object_class->get_property = gdm_simple_slave_get_property;
+ object_class->set_property = gdm_simple_slave_set_property;
object_class->constructor = gdm_simple_slave_constructor;
- object_class->finalize = gdm_simple_slave_finalize;
+ object_class->finalize = gdm_simple_slave_finalize;
- slave_class->start = gdm_simple_slave_start;
- slave_class->stop = gdm_simple_slave_stop;
+ slave_class->start = gdm_simple_slave_start;
+ slave_class->stop = gdm_simple_slave_stop;
- g_type_class_add_private (klass, sizeof (GdmSimpleSlavePrivate));
+ g_type_class_add_private (klass, sizeof (GdmSimpleSlavePrivate));
- dbus_g_object_type_install_info (GDM_TYPE_SIMPLE_SLAVE, &dbus_glib_gdm_simple_slave_object_info);
+ dbus_g_object_type_install_info (GDM_TYPE_SIMPLE_SLAVE, &dbus_glib_gdm_simple_slave_object_info);
}
static void
gdm_simple_slave_init (GdmSimpleSlave *slave)
{
- const char * const *languages;
+ const char * const *languages;
- slave->priv = GDM_SIMPLE_SLAVE_GET_PRIVATE (slave);
+ slave->priv = GDM_SIMPLE_SLAVE_GET_PRIVATE (slave);
- slave->priv->pid = -1;
+ slave->priv->pid = -1;
- languages = g_get_language_names ();
- if (languages != NULL) {
- slave->priv->selected_language = g_strdup (languages[0]);
- }
+ languages = g_get_language_names ();
+ if (languages != NULL) {
+ slave->priv->selected_language = g_strdup (languages[0]);
+ }
- slave->priv->selected_session = g_strdup ("gnome.desktop");
+ slave->priv->selected_session = g_strdup ("gnome.desktop");
}
static void
gdm_simple_slave_finalize (GObject *object)
{
- GdmSimpleSlave *simple_slave;
+ GdmSimpleSlave *simple_slave;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_SIMPLE_SLAVE (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_SIMPLE_SLAVE (object));
- simple_slave = GDM_SIMPLE_SLAVE (object);
+ simple_slave = GDM_SIMPLE_SLAVE (object);
- g_return_if_fail (simple_slave->priv != NULL);
+ g_return_if_fail (simple_slave->priv != NULL);
- gdm_simple_slave_stop (GDM_SLAVE (simple_slave));
+ gdm_simple_slave_stop (GDM_SLAVE (simple_slave));
- G_OBJECT_CLASS (gdm_simple_slave_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_simple_slave_parent_class)->finalize (object);
}
GdmSlave *
gdm_simple_slave_new (const char *id)
{
- GObject *object;
+ GObject *object;
- object = g_object_new (GDM_TYPE_SIMPLE_SLAVE,
- "display-id", id,
- NULL);
+ object = g_object_new (GDM_TYPE_SIMPLE_SLAVE,
+ "display-id", id,
+ NULL);
- return GDM_SLAVE (object);
+ return GDM_SLAVE (object);
}
diff --git a/daemon/gdm-simple-slave.h b/daemon/gdm-simple-slave.h
index 37d5c5b9..1f1aa1de 100644
--- a/daemon/gdm-simple-slave.h
+++ b/daemon/gdm-simple-slave.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -38,16 +38,16 @@ typedef struct GdmSimpleSlavePrivate GdmSimpleSlavePrivate;
typedef struct
{
- GdmSlave parent;
- GdmSimpleSlavePrivate *priv;
+ GdmSlave parent;
+ GdmSimpleSlavePrivate *priv;
} GdmSimpleSlave;
typedef struct
{
- GdmSlaveClass parent_class;
+ GdmSlaveClass parent_class;
} GdmSimpleSlaveClass;
-GType gdm_simple_slave_get_type (void);
+GType gdm_simple_slave_get_type (void);
GdmSlave * gdm_simple_slave_new (const char *id);
G_END_DECLS
diff --git a/daemon/gdm-slave-proxy.c b/daemon/gdm-slave-proxy.c
index 329a4198..b3fb3f1f 100644
--- a/daemon/gdm-slave-proxy.c
+++ b/daemon/gdm-slave-proxy.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -39,34 +39,34 @@
struct GdmSlaveProxyPrivate
{
- char *command;
- GPid pid;
- guint child_watch_id;
+ char *command;
+ GPid pid;
+ guint child_watch_id;
};
enum {
- PROP_0,
- PROP_COMMAND,
+ PROP_0,
+ PROP_COMMAND,
};
enum {
- EXITED,
- DIED,
- LAST_SIGNAL
+ EXITED,
+ DIED,
+ LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0, };
-static void gdm_slave_proxy_class_init (GdmSlaveProxyClass *klass);
-static void gdm_slave_proxy_init (GdmSlaveProxy *slave);
-static void gdm_slave_proxy_finalize (GObject *object);
+static void gdm_slave_proxy_class_init (GdmSlaveProxyClass *klass);
+static void gdm_slave_proxy_init (GdmSlaveProxy *slave);
+static void gdm_slave_proxy_finalize (GObject *object);
G_DEFINE_TYPE (GdmSlaveProxy, gdm_slave_proxy, G_TYPE_OBJECT)
static void
child_watch (GPid pid,
- int status,
- GdmSlaveProxy *slave)
+ int status,
+ GdmSlaveProxy *slave)
{
g_debug ("slave (pid:%d) done (%s:%d)",
(int) pid,
@@ -78,9 +78,9 @@ child_watch (GPid pid,
: -1);
g_spawn_close_pid (slave->priv->pid);
- slave->priv->pid = -1;
+ slave->priv->pid = -1;
- if (WIFEXITED (status)) {
+ if (WIFEXITED (status)) {
int code = WEXITSTATUS (status);
g_signal_emit (slave, signals [EXITED], 0, code);
} else if (WIFSIGNALED (status)) {
@@ -92,117 +92,117 @@ child_watch (GPid pid,
static gboolean
spawn_slave (GdmSlaveProxy *slave)
{
- char **argv;
- gboolean result;
- GError *error = NULL;
-
- result = FALSE;
-
- if (! g_shell_parse_argv (slave->priv->command, NULL, &argv, &error)) {
- g_warning ("Could not parse command: %s", error->message);
- g_error_free (error);
- goto out;
- }
-
- g_debug ("Running command: %s", slave->priv->command);
-
- error = NULL;
- result = g_spawn_async_with_pipes (NULL,
- argv,
- NULL,
- G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
- NULL,
- NULL,
- &slave->priv->pid,
- NULL,
- NULL,
- NULL,
- &error);
-
- if (! result) {
- g_warning ("Could not start command '%s': %s", slave->priv->command, error->message);
- g_error_free (error);
- g_strfreev (argv);
- goto out;
- }
-
- g_strfreev (argv);
-
- g_debug ("Started slave with pid %d", slave->priv->pid);
-
- slave->priv->child_watch_id = g_child_watch_add (slave->priv->pid,
- (GChildWatchFunc)child_watch,
- slave);
-
- result = TRUE;
+ char **argv;
+ gboolean result;
+ GError *error = NULL;
+
+ result = FALSE;
+
+ if (! g_shell_parse_argv (slave->priv->command, NULL, &argv, &error)) {
+ g_warning ("Could not parse command: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ g_debug ("Running command: %s", slave->priv->command);
+
+ error = NULL;
+ result = g_spawn_async_with_pipes (NULL,
+ argv,
+ NULL,
+ G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
+ NULL,
+ NULL,
+ &slave->priv->pid,
+ NULL,
+ NULL,
+ NULL,
+ &error);
+
+ if (! result) {
+ g_warning ("Could not start command '%s': %s", slave->priv->command, error->message);
+ g_error_free (error);
+ g_strfreev (argv);
+ goto out;
+ }
+
+ g_strfreev (argv);
+
+ g_debug ("Started slave with pid %d", slave->priv->pid);
+
+ slave->priv->child_watch_id = g_child_watch_add (slave->priv->pid,
+ (GChildWatchFunc)child_watch,
+ slave);
+
+ result = TRUE;
out:
- return result;
+ return result;
}
static int
signal_pid (int pid,
- int signal)
+ int signal)
{
- int status = -1;
-
- /* perhaps block sigchld */
- g_debug ("Sending signal %d to pid %d", signal, pid);
-
- status = kill (pid, signal);
-
- if (status < 0) {
- if (errno == ESRCH) {
- g_warning ("Child process %lu was already dead.",
- (unsigned long) pid);
- } else {
- g_warning ("Couldn't kill child process %lu: %s",
- (unsigned long) pid,
- g_strerror (errno));
- }
- }
+ int status = -1;
+
+ /* perhaps block sigchld */
+ g_debug ("Sending signal %d to pid %d", signal, pid);
+
+ status = kill (pid, signal);
+
+ if (status < 0) {
+ if (errno == ESRCH) {
+ g_warning ("Child process %lu was already dead.",
+ (unsigned long) pid);
+ } else {
+ g_warning ("Couldn't kill child process %lu: %s",
+ (unsigned long) pid,
+ g_strerror (errno));
+ }
+ }
- /* perhaps unblock sigchld */
+ /* perhaps unblock sigchld */
- return status;
+ return status;
}
static void
kill_slave (GdmSlaveProxy *slave)
{
- if (slave->priv->pid <= 1) {
- return;
- }
+ if (slave->priv->pid <= 1) {
+ return;
+ }
- signal_pid (slave->priv->pid, SIGTERM);
+ signal_pid (slave->priv->pid, SIGTERM);
}
gboolean
gdm_slave_proxy_start (GdmSlaveProxy *slave)
{
- spawn_slave (slave);
+ spawn_slave (slave);
- return TRUE;
+ return TRUE;
}
gboolean
gdm_slave_proxy_stop (GdmSlaveProxy *slave)
{
- g_debug ("Killing slave");
+ g_debug ("Killing slave");
- kill_slave (slave);
+ kill_slave (slave);
- if (slave->priv->child_watch_id > 0) {
- g_source_remove (slave->priv->child_watch_id);
- }
+ if (slave->priv->child_watch_id > 0) {
+ g_source_remove (slave->priv->child_watch_id);
+ }
- return TRUE;
+ return TRUE;
}
void
gdm_slave_proxy_set_command (GdmSlaveProxy *slave,
- const char *command)
+ const char *command)
{
g_free (slave->priv->command);
slave->priv->command = g_strdup (command);
@@ -210,135 +210,135 @@ gdm_slave_proxy_set_command (GdmSlaveProxy *slave,
static void
gdm_slave_proxy_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GdmSlaveProxy *self;
-
- self = GDM_SLAVE_PROXY (object);
-
- switch (prop_id) {
- case PROP_COMMAND:
- gdm_slave_proxy_set_command (self, g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GdmSlaveProxy *self;
+
+ self = GDM_SLAVE_PROXY (object);
+
+ switch (prop_id) {
+ case PROP_COMMAND:
+ gdm_slave_proxy_set_command (self, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_slave_proxy_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GdmSlaveProxy *self;
-
- self = GDM_SLAVE_PROXY (object);
-
- switch (prop_id) {
- case PROP_COMMAND:
- g_value_set_string (value, self->priv->command);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GdmSlaveProxy *self;
+
+ self = GDM_SLAVE_PROXY (object);
+
+ switch (prop_id) {
+ case PROP_COMMAND:
+ g_value_set_string (value, self->priv->command);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_slave_proxy_dispose (GObject *object)
{
- GdmSlaveProxy *slave;
+ GdmSlaveProxy *slave;
- slave = GDM_SLAVE_PROXY (object);
+ slave = GDM_SLAVE_PROXY (object);
- g_debug ("Disposing slave proxy");
- if (slave->priv->child_watch_id > 0) {
- g_source_remove (slave->priv->child_watch_id);
- slave->priv->child_watch_id = 0;
- }
+ g_debug ("Disposing slave proxy");
+ if (slave->priv->child_watch_id > 0) {
+ g_source_remove (slave->priv->child_watch_id);
+ slave->priv->child_watch_id = 0;
+ }
- G_OBJECT_CLASS (gdm_slave_proxy_parent_class)->dispose (object);
+ G_OBJECT_CLASS (gdm_slave_proxy_parent_class)->dispose (object);
}
static void
gdm_slave_proxy_class_init (GdmSlaveProxyClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->get_property = gdm_slave_proxy_get_property;
- object_class->set_property = gdm_slave_proxy_set_property;
- object_class->dispose = gdm_slave_proxy_dispose;
- object_class->finalize = gdm_slave_proxy_finalize;
-
- g_type_class_add_private (klass, sizeof (GdmSlaveProxyPrivate));
-
- g_object_class_install_property (object_class,
- PROP_COMMAND,
- g_param_spec_string ("command",
- "command",
- "command",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- signals [EXITED] =
- g_signal_new ("exited",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSlaveProxyClass, exited),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE,
- 1,
- G_TYPE_INT);
-
- signals [DIED] =
- g_signal_new ("died",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSlaveProxyClass, died),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE,
- 1,
- G_TYPE_INT);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->get_property = gdm_slave_proxy_get_property;
+ object_class->set_property = gdm_slave_proxy_set_property;
+ object_class->dispose = gdm_slave_proxy_dispose;
+ object_class->finalize = gdm_slave_proxy_finalize;
+
+ g_type_class_add_private (klass, sizeof (GdmSlaveProxyPrivate));
+
+ g_object_class_install_property (object_class,
+ PROP_COMMAND,
+ g_param_spec_string ("command",
+ "command",
+ "command",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ signals [EXITED] =
+ g_signal_new ("exited",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSlaveProxyClass, exited),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__INT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_INT);
+
+ signals [DIED] =
+ g_signal_new ("died",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmSlaveProxyClass, died),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__INT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_INT);
}
static void
gdm_slave_proxy_init (GdmSlaveProxy *slave)
{
- slave->priv = GDM_SLAVE_PROXY_GET_PRIVATE (slave);
+ slave->priv = GDM_SLAVE_PROXY_GET_PRIVATE (slave);
- slave->priv->pid = -1;
+ slave->priv->pid = -1;
}
static void
gdm_slave_proxy_finalize (GObject *object)
{
- GdmSlaveProxy *slave;
+ GdmSlaveProxy *slave;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_SLAVE_PROXY (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_SLAVE_PROXY (object));
- slave = GDM_SLAVE_PROXY (object);
+ slave = GDM_SLAVE_PROXY (object);
- g_return_if_fail (slave->priv != NULL);
+ g_return_if_fail (slave->priv != NULL);
- G_OBJECT_CLASS (gdm_slave_proxy_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_slave_proxy_parent_class)->finalize (object);
}
GdmSlaveProxy *
gdm_slave_proxy_new (void)
{
- GObject *object;
+ GObject *object;
- object = g_object_new (GDM_TYPE_SLAVE_PROXY,
- NULL);
+ object = g_object_new (GDM_TYPE_SLAVE_PROXY,
+ NULL);
- return GDM_SLAVE_PROXY (object);
+ return GDM_SLAVE_PROXY (object);
}
diff --git a/daemon/gdm-slave-proxy.h b/daemon/gdm-slave-proxy.h
index d4b2fdf9..80f096b9 100644
--- a/daemon/gdm-slave-proxy.h
+++ b/daemon/gdm-slave-proxy.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -37,24 +37,24 @@ typedef struct GdmSlaveProxyPrivate GdmSlaveProxyPrivate;
typedef struct
{
- GObject parent;
- GdmSlaveProxyPrivate *priv;
+ GObject parent;
+ GdmSlaveProxyPrivate *priv;
} GdmSlaveProxy;
typedef struct
{
- GObjectClass parent_class;
- void (* exited) (GdmSlaveProxy *proxy,
- int exit_code);
+ GObjectClass parent_class;
+ void (* exited) (GdmSlaveProxy *proxy,
+ int exit_code);
- void (* died) (GdmSlaveProxy *proxy,
- int signal_number);
+ void (* died) (GdmSlaveProxy *proxy,
+ int signal_number);
} GdmSlaveProxyClass;
-GType gdm_slave_proxy_get_type (void);
-GdmSlaveProxy * gdm_slave_proxy_new (void);
+GType gdm_slave_proxy_get_type (void);
+GdmSlaveProxy * gdm_slave_proxy_new (void);
void gdm_slave_proxy_set_command (GdmSlaveProxy *slave,
- const char *command);
+ const char *command);
gboolean gdm_slave_proxy_start (GdmSlaveProxy *slave);
gboolean gdm_slave_proxy_stop (GdmSlaveProxy *slave);
diff --git a/daemon/gdm-slave.c b/daemon/gdm-slave.c
index 4372fe14..1e4fdd2d 100644
--- a/daemon/gdm-slave.c
+++ b/daemon/gdm-slave.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -54,344 +54,344 @@
#define GDM_SLAVE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_SLAVE, GdmSlavePrivate))
-#define GDM_DBUS_NAME "org.gnome.DisplayManager"
+#define GDM_DBUS_NAME "org.gnome.DisplayManager"
#define GDM_DBUS_DISPLAY_INTERFACE "org.gnome.DisplayManager.Display"
#define MAX_CONNECT_ATTEMPTS 10
struct GdmSlavePrivate
{
- char *id;
- GPid pid;
+ char *id;
+ GPid pid;
guint output_watch_id;
guint error_watch_id;
- GPid server_pid;
- Display *server_display;
- guint connection_attempts;
-
- /* cached display values */
- char *display_id;
- char *display_name;
- int *display_number;
- char *display_hostname;
- gboolean display_is_local;
- gboolean display_is_parented;
- char *display_x11_authority_file;
- char *display_x11_cookie;
- char *parent_display_name;
- char *parent_display_x11_authority_file;
-
- /* user selected */
- char *selected_session;
- char *selected_language;
-
- GdmServer *server;
- GdmGreeterProxy *greeter;
- GdmSession *session;
- DBusGProxy *display_proxy;
+ GPid server_pid;
+ Display *server_display;
+ guint connection_attempts;
+
+ /* cached display values */
+ char *display_id;
+ char *display_name;
+ int *display_number;
+ char *display_hostname;
+ gboolean display_is_local;
+ gboolean display_is_parented;
+ char *display_x11_authority_file;
+ char *display_x11_cookie;
+ char *parent_display_name;
+ char *parent_display_x11_authority_file;
+
+ /* user selected */
+ char *selected_session;
+ char *selected_language;
+
+ GdmServer *server;
+ GdmGreeterProxy *greeter;
+ GdmSession *session;
+ DBusGProxy *display_proxy;
DBusGConnection *connection;
};
enum {
- PROP_0,
- PROP_DISPLAY_ID,
- PROP_DISPLAY_NAME,
- PROP_DISPLAY_NUMBER,
- PROP_DISPLAY_HOSTNAME,
- PROP_DISPLAY_IS_LOCAL,
- PROP_DISPLAY_X11_AUTHORITY_FILE,
- PROP_DISPLAY_X11_COOKIE,
+ PROP_0,
+ PROP_DISPLAY_ID,
+ PROP_DISPLAY_NAME,
+ PROP_DISPLAY_NUMBER,
+ PROP_DISPLAY_HOSTNAME,
+ PROP_DISPLAY_IS_LOCAL,
+ PROP_DISPLAY_X11_AUTHORITY_FILE,
+ PROP_DISPLAY_X11_COOKIE,
};
enum {
- STOPPED,
- LAST_SIGNAL
+ STOPPED,
+ LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0, };
-static void gdm_slave_class_init (GdmSlaveClass *klass);
-static void gdm_slave_init (GdmSlave *slave);
-static void gdm_slave_finalize (GObject *object);
+static void gdm_slave_class_init (GdmSlaveClass *klass);
+static void gdm_slave_init (GdmSlave *slave);
+static void gdm_slave_finalize (GObject *object);
G_DEFINE_ABSTRACT_TYPE (GdmSlave, gdm_slave, G_TYPE_OBJECT)
static void
display_proxy_destroyed_cb (DBusGProxy *display_proxy,
- GdmSlave *slave)
+ GdmSlave *slave)
{
- g_debug ("Disconnected from display");
+ g_debug ("Disconnected from display");
- slave->priv->display_proxy = NULL;
+ slave->priv->display_proxy = NULL;
}
static gboolean
gdm_slave_real_start (GdmSlave *slave)
{
- gboolean res;
- char *id;
- GError *error;
-
- g_debug ("Starting slave");
-
- g_assert (slave->priv->display_proxy == NULL);
-
- g_debug ("Creating proxy for %s", slave->priv->display_id);
- error = NULL;
- slave->priv->display_proxy = dbus_g_proxy_new_for_name_owner (slave->priv->connection,
- GDM_DBUS_NAME,
- slave->priv->display_id,
- GDM_DBUS_DISPLAY_INTERFACE,
- &error);
- g_signal_connect (slave->priv->display_proxy,
- "destroy",
- G_CALLBACK (display_proxy_destroyed_cb),
- slave);
-
- if (slave->priv->display_proxy == NULL) {
- if (error != NULL) {
- g_warning ("Failed to create display proxy %s: %s", slave->priv->display_id, error->message);
- g_error_free (error);
- } else {
- g_warning ("Unable to create display proxy");
- }
- return FALSE;
- }
-
- /* Make sure display ID works */
- error = NULL;
- res = dbus_g_proxy_call (slave->priv->display_proxy,
- "GetId",
- &error,
- G_TYPE_INVALID,
- DBUS_TYPE_G_OBJECT_PATH, &id,
- G_TYPE_INVALID);
- if (! res) {
- if (error != NULL) {
- g_warning ("Failed to get display id %s: %s", slave->priv->display_id, error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to get display id %s", slave->priv->display_id);
- }
-
- return FALSE;
- }
-
- g_debug ("Got display id: %s", id);
-
- if (strcmp (id, slave->priv->display_id) != 0) {
- g_critical ("Display ID doesn't match");
- exit (1);
- }
-
- /* cache some values up front */
- error = NULL;
- res = dbus_g_proxy_call (slave->priv->display_proxy,
- "IsLocal",
- &error,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &slave->priv->display_is_local,
- G_TYPE_INVALID);
- if (! res) {
- if (error != NULL) {
- g_warning ("Failed to get value: %s", error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to get value");
- }
-
- return FALSE;
- }
-
- error = NULL;
- res = dbus_g_proxy_call (slave->priv->display_proxy,
- "GetX11DisplayName",
- &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &slave->priv->display_name,
- G_TYPE_INVALID);
- if (! res) {
- if (error != NULL) {
- g_warning ("Failed to get value: %s", error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to get value");
- }
-
- return FALSE;
- }
-
- error = NULL;
- res = dbus_g_proxy_call (slave->priv->display_proxy,
- "GetX11DisplayNumber",
- &error,
- G_TYPE_INVALID,
- G_TYPE_INT, &slave->priv->display_number,
- G_TYPE_INVALID);
- if (! res) {
- if (error != NULL) {
- g_warning ("Failed to get value: %s", error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to get value");
- }
-
- return FALSE;
- }
-
- error = NULL;
- res = dbus_g_proxy_call (slave->priv->display_proxy,
- "GetRemoteHostname",
- &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &slave->priv->display_hostname,
- G_TYPE_INVALID);
- if (! res) {
- if (error != NULL) {
- g_warning ("Failed to get value: %s", error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to get value");
- }
-
- return FALSE;
- }
-
- error = NULL;
- res = dbus_g_proxy_call (slave->priv->display_proxy,
- "GetX11Cookie",
- &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &slave->priv->display_x11_cookie,
- G_TYPE_INVALID);
- if (! res) {
- if (error != NULL) {
- g_warning ("Failed to get value: %s", error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to get value");
- }
-
- return FALSE;
- }
-
- error = NULL;
- res = dbus_g_proxy_call (slave->priv->display_proxy,
- "GetX11AuthorityFile",
- &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &slave->priv->display_x11_authority_file,
- G_TYPE_INVALID);
- if (! res) {
- if (error != NULL) {
- g_warning ("Failed to get value: %s", error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to get value");
- }
-
- return FALSE;
- }
-
- return TRUE;
+ gboolean res;
+ char *id;
+ GError *error;
+
+ g_debug ("Starting slave");
+
+ g_assert (slave->priv->display_proxy == NULL);
+
+ g_debug ("Creating proxy for %s", slave->priv->display_id);
+ error = NULL;
+ slave->priv->display_proxy = dbus_g_proxy_new_for_name_owner (slave->priv->connection,
+ GDM_DBUS_NAME,
+ slave->priv->display_id,
+ GDM_DBUS_DISPLAY_INTERFACE,
+ &error);
+ g_signal_connect (slave->priv->display_proxy,
+ "destroy",
+ G_CALLBACK (display_proxy_destroyed_cb),
+ slave);
+
+ if (slave->priv->display_proxy == NULL) {
+ if (error != NULL) {
+ g_warning ("Failed to create display proxy %s: %s", slave->priv->display_id, error->message);
+ g_error_free (error);
+ } else {
+ g_warning ("Unable to create display proxy");
+ }
+ return FALSE;
+ }
+
+ /* Make sure display ID works */
+ error = NULL;
+ res = dbus_g_proxy_call (slave->priv->display_proxy,
+ "GetId",
+ &error,
+ G_TYPE_INVALID,
+ DBUS_TYPE_G_OBJECT_PATH, &id,
+ G_TYPE_INVALID);
+ if (! res) {
+ if (error != NULL) {
+ g_warning ("Failed to get display id %s: %s", slave->priv->display_id, error->message);
+ g_error_free (error);
+ } else {
+ g_warning ("Failed to get display id %s", slave->priv->display_id);
+ }
+
+ return FALSE;
+ }
+
+ g_debug ("Got display id: %s", id);
+
+ if (strcmp (id, slave->priv->display_id) != 0) {
+ g_critical ("Display ID doesn't match");
+ exit (1);
+ }
+
+ /* cache some values up front */
+ error = NULL;
+ res = dbus_g_proxy_call (slave->priv->display_proxy,
+ "IsLocal",
+ &error,
+ G_TYPE_INVALID,
+ G_TYPE_BOOLEAN, &slave->priv->display_is_local,
+ G_TYPE_INVALID);
+ if (! res) {
+ if (error != NULL) {
+ g_warning ("Failed to get value: %s", error->message);
+ g_error_free (error);
+ } else {
+ g_warning ("Failed to get value");
+ }
+
+ return FALSE;
+ }
+
+ error = NULL;
+ res = dbus_g_proxy_call (slave->priv->display_proxy,
+ "GetX11DisplayName",
+ &error,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &slave->priv->display_name,
+ G_TYPE_INVALID);
+ if (! res) {
+ if (error != NULL) {
+ g_warning ("Failed to get value: %s", error->message);
+ g_error_free (error);
+ } else {
+ g_warning ("Failed to get value");
+ }
+
+ return FALSE;
+ }
+
+ error = NULL;
+ res = dbus_g_proxy_call (slave->priv->display_proxy,
+ "GetX11DisplayNumber",
+ &error,
+ G_TYPE_INVALID,
+ G_TYPE_INT, &slave->priv->display_number,
+ G_TYPE_INVALID);
+ if (! res) {
+ if (error != NULL) {
+ g_warning ("Failed to get value: %s", error->message);
+ g_error_free (error);
+ } else {
+ g_warning ("Failed to get value");
+ }
+
+ return FALSE;
+ }
+
+ error = NULL;
+ res = dbus_g_proxy_call (slave->priv->display_proxy,
+ "GetRemoteHostname",
+ &error,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &slave->priv->display_hostname,
+ G_TYPE_INVALID);
+ if (! res) {
+ if (error != NULL) {
+ g_warning ("Failed to get value: %s", error->message);
+ g_error_free (error);
+ } else {
+ g_warning ("Failed to get value");
+ }
+
+ return FALSE;
+ }
+
+ error = NULL;
+ res = dbus_g_proxy_call (slave->priv->display_proxy,
+ "GetX11Cookie",
+ &error,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &slave->priv->display_x11_cookie,
+ G_TYPE_INVALID);
+ if (! res) {
+ if (error != NULL) {
+ g_warning ("Failed to get value: %s", error->message);
+ g_error_free (error);
+ } else {
+ g_warning ("Failed to get value");
+ }
+
+ return FALSE;
+ }
+
+ error = NULL;
+ res = dbus_g_proxy_call (slave->priv->display_proxy,
+ "GetX11AuthorityFile",
+ &error,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &slave->priv->display_x11_authority_file,
+ G_TYPE_INVALID);
+ if (! res) {
+ if (error != NULL) {
+ g_warning ("Failed to get value: %s", error->message);
+ g_error_free (error);
+ } else {
+ g_warning ("Failed to get value");
+ }
+
+ return FALSE;
+ }
+
+ return TRUE;
}
static gboolean
gdm_slave_real_stop (GdmSlave *slave)
{
- g_debug ("Stopping slave");
+ g_debug ("Stopping slave");
- if (slave->priv->display_proxy != NULL) {
- g_object_unref (slave->priv->display_proxy);
- }
+ if (slave->priv->display_proxy != NULL) {
+ g_object_unref (slave->priv->display_proxy);
+ }
- return TRUE;
+ return TRUE;
}
gboolean
gdm_slave_start (GdmSlave *slave)
{
- gboolean ret;
+ gboolean ret;
- g_return_val_if_fail (GDM_IS_SLAVE (slave), FALSE);
+ g_return_val_if_fail (GDM_IS_SLAVE (slave), FALSE);
- g_debug ("starting slave");
+ g_debug ("starting slave");
- g_object_ref (slave);
- ret = GDM_SLAVE_GET_CLASS (slave)->start (slave);
- g_object_unref (slave);
+ g_object_ref (slave);
+ ret = GDM_SLAVE_GET_CLASS (slave)->start (slave);
+ g_object_unref (slave);
- return ret;
+ return ret;
}
gboolean
gdm_slave_stop (GdmSlave *slave)
{
- gboolean ret;
+ gboolean ret;
- g_return_val_if_fail (GDM_IS_SLAVE (slave), FALSE);
+ g_return_val_if_fail (GDM_IS_SLAVE (slave), FALSE);
- g_debug ("stopping slave");
+ g_debug ("stopping slave");
- g_object_ref (slave);
- ret = GDM_SLAVE_GET_CLASS (slave)->stop (slave);
- g_object_unref (slave);
+ g_object_ref (slave);
+ ret = GDM_SLAVE_GET_CLASS (slave)->stop (slave);
+ g_object_unref (slave);
- return ret;
+ return ret;
}
void
gdm_slave_stopped (GdmSlave *slave)
{
- g_return_if_fail (GDM_IS_SLAVE (slave));
+ g_return_if_fail (GDM_IS_SLAVE (slave));
- g_signal_emit (slave, signals [STOPPED], 0);
+ g_signal_emit (slave, signals [STOPPED], 0);
}
gboolean
gdm_slave_add_user_authorization (GdmSlave *slave,
- const char *username,
- char **filenamep)
+ const char *username,
+ char **filenamep)
{
- gboolean res;
- GError *error;
- char *filename;
-
- filename = NULL;
-
- if (filenamep != NULL) {
- *filenamep = NULL;
- }
-
- error = NULL;
- res = dbus_g_proxy_call (slave->priv->display_proxy,
- "AddUserAuthorization",
- &error,
- G_TYPE_STRING, username,
- G_TYPE_INVALID,
- G_TYPE_STRING, &filename,
- G_TYPE_INVALID);
- if (filenamep != NULL) {
- *filenamep = g_strdup (filename);
- }
- g_free (filename);
-
- if (! res) {
- if (error != NULL) {
- g_warning ("Failed to add user authorization: %s", error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to add user authorization");
- }
- }
-
- return res;
+ gboolean res;
+ GError *error;
+ char *filename;
+
+ filename = NULL;
+
+ if (filenamep != NULL) {
+ *filenamep = NULL;
+ }
+
+ error = NULL;
+ res = dbus_g_proxy_call (slave->priv->display_proxy,
+ "AddUserAuthorization",
+ &error,
+ G_TYPE_STRING, username,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &filename,
+ G_TYPE_INVALID);
+ if (filenamep != NULL) {
+ *filenamep = g_strdup (filename);
+ }
+ g_free (filename);
+
+ if (! res) {
+ if (error != NULL) {
+ g_warning ("Failed to add user authorization: %s", error->message);
+ g_error_free (error);
+ } else {
+ g_warning ("Failed to add user authorization");
+ }
+ }
+
+ return res;
}
static void
_gdm_slave_set_display_id (GdmSlave *slave,
- const char *id)
+ const char *id)
{
g_free (slave->priv->display_id);
slave->priv->display_id = g_strdup (id);
@@ -399,7 +399,7 @@ _gdm_slave_set_display_id (GdmSlave *slave,
static void
_gdm_slave_set_display_name (GdmSlave *slave,
- const char *name)
+ const char *name)
{
g_free (slave->priv->display_name);
slave->priv->display_name = g_strdup (name);
@@ -407,14 +407,14 @@ _gdm_slave_set_display_name (GdmSlave *slave,
static void
_gdm_slave_set_display_number (GdmSlave *slave,
- int number)
+ int number)
{
slave->priv->display_number = number;
}
static void
_gdm_slave_set_display_hostname (GdmSlave *slave,
- const char *name)
+ const char *name)
{
g_free (slave->priv->display_hostname);
slave->priv->display_hostname = g_strdup (name);
@@ -422,7 +422,7 @@ _gdm_slave_set_display_hostname (GdmSlave *slave,
static void
_gdm_slave_set_display_x11_authority_file (GdmSlave *slave,
- const char *name)
+ const char *name)
{
g_free (slave->priv->display_x11_authority_file);
slave->priv->display_x11_authority_file = g_strdup (name);
@@ -430,7 +430,7 @@ _gdm_slave_set_display_x11_authority_file (GdmSlave *slave,
static void
_gdm_slave_set_display_x11_cookie (GdmSlave *slave,
- const char *name)
+ const char *name)
{
g_free (slave->priv->display_x11_cookie);
slave->priv->display_x11_cookie = g_strdup (name);
@@ -438,85 +438,85 @@ _gdm_slave_set_display_x11_cookie (GdmSlave *slave,
static void
_gdm_slave_set_display_is_local (GdmSlave *slave,
- gboolean is)
+ gboolean is)
{
slave->priv->display_is_local = is;
}
static void
gdm_slave_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GdmSlave *self;
-
- self = GDM_SLAVE (object);
-
- switch (prop_id) {
- case PROP_DISPLAY_ID:
- _gdm_slave_set_display_id (self, g_value_get_string (value));
- break;
- case PROP_DISPLAY_NAME:
- _gdm_slave_set_display_name (self, g_value_get_string (value));
- break;
- case PROP_DISPLAY_NUMBER:
- _gdm_slave_set_display_number (self, g_value_get_int (value));
- break;
- case PROP_DISPLAY_HOSTNAME:
- _gdm_slave_set_display_hostname (self, g_value_get_string (value));
- break;
- case PROP_DISPLAY_X11_AUTHORITY_FILE:
- _gdm_slave_set_display_x11_authority_file (self, g_value_get_string (value));
- break;
- case PROP_DISPLAY_X11_COOKIE:
- _gdm_slave_set_display_x11_cookie (self, g_value_get_string (value));
- break;
- case PROP_DISPLAY_IS_LOCAL:
- _gdm_slave_set_display_is_local (self, g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GdmSlave *self;
+
+ self = GDM_SLAVE (object);
+
+ switch (prop_id) {
+ case PROP_DISPLAY_ID:
+ _gdm_slave_set_display_id (self, g_value_get_string (value));
+ break;
+ case PROP_DISPLAY_NAME:
+ _gdm_slave_set_display_name (self, g_value_get_string (value));
+ break;
+ case PROP_DISPLAY_NUMBER:
+ _gdm_slave_set_display_number (self, g_value_get_int (value));
+ break;
+ case PROP_DISPLAY_HOSTNAME:
+ _gdm_slave_set_display_hostname (self, g_value_get_string (value));
+ break;
+ case PROP_DISPLAY_X11_AUTHORITY_FILE:
+ _gdm_slave_set_display_x11_authority_file (self, g_value_get_string (value));
+ break;
+ case PROP_DISPLAY_X11_COOKIE:
+ _gdm_slave_set_display_x11_cookie (self, g_value_get_string (value));
+ break;
+ case PROP_DISPLAY_IS_LOCAL:
+ _gdm_slave_set_display_is_local (self, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_slave_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GdmSlave *self;
-
- self = GDM_SLAVE (object);
-
- switch (prop_id) {
- case PROP_DISPLAY_ID:
- g_value_set_string (value, self->priv->display_id);
- break;
- case PROP_DISPLAY_NAME:
- g_value_set_string (value, self->priv->display_name);
- break;
- case PROP_DISPLAY_NUMBER:
- g_value_set_int (value, self->priv->display_number);
- break;
- case PROP_DISPLAY_HOSTNAME:
- g_value_set_string (value, self->priv->display_hostname);
- break;
- case PROP_DISPLAY_X11_AUTHORITY_FILE:
- g_value_set_string (value, self->priv->display_x11_authority_file);
- break;
- case PROP_DISPLAY_X11_COOKIE:
- g_value_set_string (value, self->priv->display_x11_cookie);
- break;
- case PROP_DISPLAY_IS_LOCAL:
- g_value_set_boolean (value, self->priv->display_is_local);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GdmSlave *self;
+
+ self = GDM_SLAVE (object);
+
+ switch (prop_id) {
+ case PROP_DISPLAY_ID:
+ g_value_set_string (value, self->priv->display_id);
+ break;
+ case PROP_DISPLAY_NAME:
+ g_value_set_string (value, self->priv->display_name);
+ break;
+ case PROP_DISPLAY_NUMBER:
+ g_value_set_int (value, self->priv->display_number);
+ break;
+ case PROP_DISPLAY_HOSTNAME:
+ g_value_set_string (value, self->priv->display_hostname);
+ break;
+ case PROP_DISPLAY_X11_AUTHORITY_FILE:
+ g_value_set_string (value, self->priv->display_x11_authority_file);
+ break;
+ case PROP_DISPLAY_X11_COOKIE:
+ g_value_set_string (value, self->priv->display_x11_cookie);
+ break;
+ case PROP_DISPLAY_IS_LOCAL:
+ g_value_set_boolean (value, self->priv->display_is_local);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static gboolean
@@ -541,31 +541,31 @@ register_slave (GdmSlave *slave)
static GObject *
gdm_slave_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
{
GdmSlave *slave;
GdmSlaveClass *klass;
- gboolean res;
- const char *id;
+ gboolean res;
+ const char *id;
klass = GDM_SLAVE_CLASS (g_type_class_peek (GDM_TYPE_SLAVE));
slave = GDM_SLAVE (G_OBJECT_CLASS (gdm_slave_parent_class)->constructor (type,
- n_construct_properties,
- construct_properties));
+ n_construct_properties,
+ construct_properties));
- id = NULL;
- if (g_str_has_prefix (slave->priv->display_id, "/org/gnome/DisplayManager/Display")) {
- id = slave->priv->display_id + strlen ("/org/gnome/DisplayManager/Display");
- }
+ id = NULL;
+ if (g_str_has_prefix (slave->priv->display_id, "/org/gnome/DisplayManager/Display")) {
+ id = slave->priv->display_id + strlen ("/org/gnome/DisplayManager/Display");
+ }
- slave->priv->id = g_strdup_printf ("/org/gnome/DisplayManager/Slave%s", id);
- g_debug ("Registering %s", slave->priv->id);
+ slave->priv->id = g_strdup_printf ("/org/gnome/DisplayManager/Slave%s", id);
+ g_debug ("Registering %s", slave->priv->id);
res = register_slave (slave);
if (! res) {
- g_warning ("Unable to register slave with system bus");
+ g_warning ("Unable to register slave with system bus");
}
return G_OBJECT (slave);
@@ -574,106 +574,106 @@ gdm_slave_constructor (GType type,
static void
gdm_slave_class_init (GdmSlaveClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->get_property = gdm_slave_get_property;
- object_class->set_property = gdm_slave_set_property;
+ object_class->get_property = gdm_slave_get_property;
+ object_class->set_property = gdm_slave_set_property;
object_class->constructor = gdm_slave_constructor;
- object_class->finalize = gdm_slave_finalize;
-
- klass->start = gdm_slave_real_start;
- klass->stop = gdm_slave_real_stop;
-
- g_type_class_add_private (klass, sizeof (GdmSlavePrivate));
-
- g_object_class_install_property (object_class,
- PROP_DISPLAY_ID,
- g_param_spec_string ("display-id",
- "id",
- "id",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_DISPLAY_NAME,
- g_param_spec_string ("display-name",
- "display name",
- "display name",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_DISPLAY_NUMBER,
- g_param_spec_int ("display-number",
- "display number",
- "display number",
- -1,
- G_MAXINT,
- -1,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_DISPLAY_HOSTNAME,
- g_param_spec_string ("display-hostname",
- "display hostname",
- "display hostname",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_DISPLAY_X11_AUTHORITY_FILE,
- g_param_spec_string ("display-x11-authority-file",
- "",
- "",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_DISPLAY_X11_COOKIE,
- g_param_spec_string ("display-x11-cookie",
- "",
- "",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_DISPLAY_IS_LOCAL,
- g_param_spec_boolean ("display-is-local",
- "display is local",
- "display is local",
- TRUE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- signals [STOPPED] =
- g_signal_new ("stopped",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdmSlaveClass, stopped),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- dbus_g_object_type_install_info (GDM_TYPE_SLAVE, &dbus_glib_gdm_slave_object_info);
+ object_class->finalize = gdm_slave_finalize;
+
+ klass->start = gdm_slave_real_start;
+ klass->stop = gdm_slave_real_stop;
+
+ g_type_class_add_private (klass, sizeof (GdmSlavePrivate));
+
+ g_object_class_install_property (object_class,
+ PROP_DISPLAY_ID,
+ g_param_spec_string ("display-id",
+ "id",
+ "id",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_DISPLAY_NAME,
+ g_param_spec_string ("display-name",
+ "display name",
+ "display name",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_DISPLAY_NUMBER,
+ g_param_spec_int ("display-number",
+ "display number",
+ "display number",
+ -1,
+ G_MAXINT,
+ -1,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_DISPLAY_HOSTNAME,
+ g_param_spec_string ("display-hostname",
+ "display hostname",
+ "display hostname",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_DISPLAY_X11_AUTHORITY_FILE,
+ g_param_spec_string ("display-x11-authority-file",
+ "",
+ "",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_DISPLAY_X11_COOKIE,
+ g_param_spec_string ("display-x11-cookie",
+ "",
+ "",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_DISPLAY_IS_LOCAL,
+ g_param_spec_boolean ("display-is-local",
+ "display is local",
+ "display is local",
+ TRUE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ signals [STOPPED] =
+ g_signal_new ("stopped",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdmSlaveClass, stopped),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
+ dbus_g_object_type_install_info (GDM_TYPE_SLAVE, &dbus_glib_gdm_slave_object_info);
}
static void
gdm_slave_init (GdmSlave *slave)
{
- slave->priv = GDM_SLAVE_GET_PRIVATE (slave);
+ slave->priv = GDM_SLAVE_GET_PRIVATE (slave);
- slave->priv->pid = -1;
+ slave->priv->pid = -1;
}
static void
gdm_slave_finalize (GObject *object)
{
- GdmSlave *slave;
+ GdmSlave *slave;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_SLAVE (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_SLAVE (object));
- slave = GDM_SLAVE (object);
+ slave = GDM_SLAVE (object);
- g_return_if_fail (slave->priv != NULL);
+ g_return_if_fail (slave->priv != NULL);
- gdm_slave_real_stop (slave);
+ gdm_slave_real_stop (slave);
- G_OBJECT_CLASS (gdm_slave_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_slave_parent_class)->finalize (object);
}
diff --git a/daemon/gdm-slave.h b/daemon/gdm-slave.h
index 87957505..1ef8a88c 100644
--- a/daemon/gdm-slave.h
+++ b/daemon/gdm-slave.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -37,29 +37,29 @@ typedef struct GdmSlavePrivate GdmSlavePrivate;
typedef struct
{
- GObject parent;
- GdmSlavePrivate *priv;
+ GObject parent;
+ GdmSlavePrivate *priv;
} GdmSlave;
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
- /* methods */
- gboolean (*start) (GdmSlave *slave);
- gboolean (*stop) (GdmSlave *slave);
+ /* methods */
+ gboolean (*start) (GdmSlave *slave);
+ gboolean (*stop) (GdmSlave *slave);
- /* signals */
- void (*stopped) (GdmSlave *slave);
+ /* signals */
+ void (*stopped) (GdmSlave *slave);
} GdmSlaveClass;
-GType gdm_slave_get_type (void);
+GType gdm_slave_get_type (void);
gboolean gdm_slave_start (GdmSlave *slave);
gboolean gdm_slave_stop (GdmSlave *slave);
gboolean gdm_slave_add_user_authorization (GdmSlave *slave,
- const char *username,
- char **filename);
+ const char *username,
+ char **filename);
void gdm_slave_stopped (GdmSlave *slave);
diff --git a/daemon/gdm-static-display.c b/daemon/gdm-static-display.c
index e6e4a647..3750f5ea 100644
--- a/daemon/gdm-static-display.c
+++ b/daemon/gdm-static-display.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -42,170 +42,170 @@
struct GdmStaticDisplayPrivate
{
- gpointer dummy;
+ gpointer dummy;
};
enum {
- PROP_0,
+ PROP_0,
};
-static void gdm_static_display_class_init (GdmStaticDisplayClass *klass);
-static void gdm_static_display_init (GdmStaticDisplay *static_display);
-static void gdm_static_display_finalize (GObject *object);
+static void gdm_static_display_class_init (GdmStaticDisplayClass *klass);
+static void gdm_static_display_init (GdmStaticDisplay *static_display);
+static void gdm_static_display_finalize (GObject *object);
G_DEFINE_TYPE (GdmStaticDisplay, gdm_static_display, GDM_TYPE_DISPLAY)
static gboolean
gdm_static_display_create_authority (GdmDisplay *display)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->create_authority (display);
+ GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->create_authority (display);
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_static_display_add_user_authorization (GdmDisplay *display,
- const char *username,
- char **filename,
- GError **error)
+ const char *username,
+ char **filename,
+ GError **error)
{
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_static_display_remove_user_authorization (GdmDisplay *display,
- const char *username,
- GError **error)
+ const char *username,
+ GError **error)
{
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_static_display_manage (GdmDisplay *display)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->manage (display);
+ GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->manage (display);
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_static_display_finish (GdmDisplay *display)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->finish (display);
+ GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->finish (display);
- /* restart static displays */
- gdm_display_unmanage (display);
- gdm_display_manage (display);
+ /* restart static displays */
+ gdm_display_unmanage (display);
+ gdm_display_manage (display);
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_static_display_unmanage (GdmDisplay *display)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->unmanage (display);
+ GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->unmanage (display);
- return TRUE;
+ return TRUE;
}
static void
gdm_static_display_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GdmStaticDisplay *self;
+ GdmStaticDisplay *self;
- self = GDM_STATIC_DISPLAY (object);
+ self = GDM_STATIC_DISPLAY (object);
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_static_display_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GdmStaticDisplay *self;
+ GdmStaticDisplay *self;
- self = GDM_STATIC_DISPLAY (object);
+ self = GDM_STATIC_DISPLAY (object);
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_static_display_class_init (GdmStaticDisplayClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GdmDisplayClass *display_class = GDM_DISPLAY_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GdmDisplayClass *display_class = GDM_DISPLAY_CLASS (klass);
- object_class->get_property = gdm_static_display_get_property;
- object_class->set_property = gdm_static_display_set_property;
- object_class->finalize = gdm_static_display_finalize;
+ object_class->get_property = gdm_static_display_get_property;
+ object_class->set_property = gdm_static_display_set_property;
+ object_class->finalize = gdm_static_display_finalize;
- display_class->create_authority = gdm_static_display_create_authority;
- display_class->add_user_authorization = gdm_static_display_add_user_authorization;
- display_class->remove_user_authorization = gdm_static_display_remove_user_authorization;
- display_class->manage = gdm_static_display_manage;
- display_class->finish = gdm_static_display_finish;
- display_class->unmanage = gdm_static_display_unmanage;
+ display_class->create_authority = gdm_static_display_create_authority;
+ display_class->add_user_authorization = gdm_static_display_add_user_authorization;
+ display_class->remove_user_authorization = gdm_static_display_remove_user_authorization;
+ display_class->manage = gdm_static_display_manage;
+ display_class->finish = gdm_static_display_finish;
+ display_class->unmanage = gdm_static_display_unmanage;
- g_type_class_add_private (klass, sizeof (GdmStaticDisplayPrivate));
+ g_type_class_add_private (klass, sizeof (GdmStaticDisplayPrivate));
- dbus_g_object_type_install_info (GDM_TYPE_STATIC_DISPLAY, &dbus_glib_gdm_static_display_object_info);
+ dbus_g_object_type_install_info (GDM_TYPE_STATIC_DISPLAY, &dbus_glib_gdm_static_display_object_info);
}
static void
gdm_static_display_init (GdmStaticDisplay *static_display)
{
- static_display->priv = GDM_STATIC_DISPLAY_GET_PRIVATE (static_display);
+ static_display->priv = GDM_STATIC_DISPLAY_GET_PRIVATE (static_display);
}
static void
gdm_static_display_finalize (GObject *object)
{
- GdmStaticDisplay *static_display;
+ GdmStaticDisplay *static_display;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_STATIC_DISPLAY (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_STATIC_DISPLAY (object));
- static_display = GDM_STATIC_DISPLAY (object);
+ static_display = GDM_STATIC_DISPLAY (object);
- g_return_if_fail (static_display->priv != NULL);
+ g_return_if_fail (static_display->priv != NULL);
- G_OBJECT_CLASS (gdm_static_display_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_static_display_parent_class)->finalize (object);
}
GdmDisplay *
gdm_static_display_new (int display_number)
{
- GObject *object;
- char *x11_display;
+ GObject *object;
+ char *x11_display;
- x11_display = g_strdup_printf (":%d", display_number);
- object = g_object_new (GDM_TYPE_STATIC_DISPLAY,
- "x11-display-number", display_number,
- "x11-display-name", x11_display,
- NULL);
- g_free (x11_display);
+ x11_display = g_strdup_printf (":%d", display_number);
+ object = g_object_new (GDM_TYPE_STATIC_DISPLAY,
+ "x11-display-number", display_number,
+ "x11-display-name", x11_display,
+ NULL);
+ g_free (x11_display);
- return GDM_DISPLAY (object);
+ return GDM_DISPLAY (object);
}
diff --git a/daemon/gdm-static-display.h b/daemon/gdm-static-display.h
index 56f96109..f5fd4247 100644
--- a/daemon/gdm-static-display.h
+++ b/daemon/gdm-static-display.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -39,18 +39,18 @@ typedef struct GdmStaticDisplayPrivate GdmStaticDisplayPrivate;
typedef struct
{
- GdmDisplay parent;
- GdmStaticDisplayPrivate *priv;
+ GdmDisplay parent;
+ GdmStaticDisplayPrivate *priv;
} GdmStaticDisplay;
typedef struct
{
- GdmDisplayClass parent_class;
+ GdmDisplayClass parent_class;
} GdmStaticDisplayClass;
-GType gdm_static_display_get_type (void);
-GdmDisplay * gdm_static_display_new (int display_number);
+GType gdm_static_display_get_type (void);
+GdmDisplay * gdm_static_display_new (int display_number);
G_END_DECLS
diff --git a/daemon/gdm-static-factory-display.c b/daemon/gdm-static-factory-display.c
index 91cd1195..d3350ab0 100644
--- a/daemon/gdm-static-factory-display.c
+++ b/daemon/gdm-static-factory-display.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -47,17 +47,17 @@
struct GdmStaticFactoryDisplayPrivate
{
- GdmDisplayStore *display_store;
+ GdmDisplayStore *display_store;
};
enum {
- PROP_0,
- PROP_DISPLAY_STORE,
+ PROP_0,
+ PROP_DISPLAY_STORE,
};
-static void gdm_static_factory_display_class_init (GdmStaticFactoryDisplayClass *klass);
-static void gdm_static_factory_display_init (GdmStaticFactoryDisplay *static_factory_display);
-static void gdm_static_factory_display_finalize (GObject *object);
+static void gdm_static_factory_display_class_init (GdmStaticFactoryDisplayClass *klass);
+static void gdm_static_factory_display_init (GdmStaticFactoryDisplay *static_factory_display);
+static void gdm_static_factory_display_finalize (GObject *object);
static guint32 display_number = 100;
@@ -66,181 +66,181 @@ G_DEFINE_TYPE (GdmStaticFactoryDisplay, gdm_static_factory_display, GDM_TYPE_DIS
static guint32
get_next_display_number (void)
{
- guint32 num;
+ guint32 num;
- num = display_number++;
+ num = display_number++;
- if ((gint32)display_number < 0) {
- display_number = 100;
- }
+ if ((gint32)display_number < 0) {
+ display_number = 100;
+ }
- return num;
+ return num;
}
gboolean
gdm_static_factory_display_create_product_display (GdmStaticFactoryDisplay *display,
- const char *relay_address,
- char **id,
- GError **error)
+ const char *relay_address,
+ char **id,
+ GError **error)
{
- gboolean ret;
- GdmDisplay *product;
- guint32 num;
+ gboolean ret;
+ GdmDisplay *product;
+ guint32 num;
- g_return_val_if_fail (GDM_IS_STATIC_FACTORY_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_STATIC_FACTORY_DISPLAY (display), FALSE);
- ret = FALSE;
+ ret = FALSE;
- num = get_next_display_number ();
+ num = get_next_display_number ();
- g_debug ("Creating product display %d address:%s", num, relay_address);
+ g_debug ("Creating product display %d address:%s", num, relay_address);
- product = gdm_product_display_new (num, relay_address);
+ product = gdm_product_display_new (num, relay_address);
- if (! gdm_display_create_authority (product)) {
- product = NULL;
- goto out;
- }
+ if (! gdm_display_create_authority (product)) {
+ product = NULL;
+ goto out;
+ }
- gdm_display_store_add (display->priv->display_store, product);
+ gdm_display_store_add (display->priv->display_store, product);
- if (! gdm_display_manage (product)) {
- product = NULL;
- goto out;
- }
+ if (! gdm_display_manage (product)) {
+ product = NULL;
+ goto out;
+ }
- if (! gdm_display_get_id (product, id, NULL)) {
- product = NULL;
- goto out;
- }
+ if (! gdm_display_get_id (product, id, NULL)) {
+ product = NULL;
+ goto out;
+ }
- ret = TRUE;
+ ret = TRUE;
out:
- /* ref either held by store or not at all */
- g_object_unref (product);
+ /* ref either held by store or not at all */
+ g_object_unref (product);
- return ret;
+ return ret;
}
static gboolean
gdm_static_factory_display_add_user_authorization (GdmDisplay *display,
- const char *username,
- char **filename,
- GError **error)
+ const char *username,
+ char **filename,
+ GError **error)
{
- return FALSE;
+ return FALSE;
}
static gboolean
gdm_static_factory_display_remove_user_authorization (GdmDisplay *display,
- const char *username,
- GError **error)
+ const char *username,
+ GError **error)
{
- return FALSE;
+ return FALSE;
}
static gboolean
gdm_static_factory_display_create_authority (GdmDisplay *display)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- GDM_DISPLAY_CLASS (gdm_static_factory_display_parent_class)->create_authority (display);
+ GDM_DISPLAY_CLASS (gdm_static_factory_display_parent_class)->create_authority (display);
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_static_factory_display_manage (GdmDisplay *display)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- GDM_DISPLAY_CLASS (gdm_static_factory_display_parent_class)->manage (display);
+ GDM_DISPLAY_CLASS (gdm_static_factory_display_parent_class)->manage (display);
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_static_factory_display_finish (GdmDisplay *display)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- GDM_DISPLAY_CLASS (gdm_static_factory_display_parent_class)->finish (display);
+ GDM_DISPLAY_CLASS (gdm_static_factory_display_parent_class)->finish (display);
- /* restart static displays */
- gdm_display_unmanage (display);
- gdm_display_manage (display);
+ /* restart static displays */
+ gdm_display_unmanage (display);
+ gdm_display_manage (display);
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_static_factory_display_unmanage (GdmDisplay *display)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- GDM_DISPLAY_CLASS (gdm_static_factory_display_parent_class)->unmanage (display);
+ GDM_DISPLAY_CLASS (gdm_static_factory_display_parent_class)->unmanage (display);
- return TRUE;
+ return TRUE;
}
static void
gdm_static_factory_display_set_display_store (GdmStaticFactoryDisplay *display,
- GdmDisplayStore *display_store)
+ GdmDisplayStore *display_store)
{
- if (display->priv->display_store != NULL) {
- g_object_unref (display->priv->display_store);
- display->priv->display_store = NULL;
- }
-
- if (display_store != NULL) {
- display->priv->display_store = g_object_ref (display_store);
- }
+ if (display->priv->display_store != NULL) {
+ g_object_unref (display->priv->display_store);
+ display->priv->display_store = NULL;
+ }
+
+ if (display_store != NULL) {
+ display->priv->display_store = g_object_ref (display_store);
+ }
}
static void
gdm_static_factory_display_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GdmStaticFactoryDisplay *self;
-
- self = GDM_STATIC_FACTORY_DISPLAY (object);
-
- switch (prop_id) {
- case PROP_DISPLAY_STORE:
- gdm_static_factory_display_set_display_store (self, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GdmStaticFactoryDisplay *self;
+
+ self = GDM_STATIC_FACTORY_DISPLAY (object);
+
+ switch (prop_id) {
+ case PROP_DISPLAY_STORE:
+ gdm_static_factory_display_set_display_store (self, g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_static_factory_display_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GdmStaticFactoryDisplay *self;
-
- self = GDM_STATIC_FACTORY_DISPLAY (object);
-
- switch (prop_id) {
- case PROP_DISPLAY_STORE:
- g_value_set_object (value, self->priv->display_store);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GdmStaticFactoryDisplay *self;
+
+ self = GDM_STATIC_FACTORY_DISPLAY (object);
+
+ switch (prop_id) {
+ case PROP_DISPLAY_STORE:
+ g_value_set_object (value, self->priv->display_store);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static GObject *
gdm_static_factory_display_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
{
GdmStaticFactoryDisplay *display;
GdmStaticFactoryDisplayClass *klass;
@@ -248,8 +248,8 @@ gdm_static_factory_display_constructor (GType type,
klass = GDM_STATIC_FACTORY_DISPLAY_CLASS (g_type_class_peek (GDM_TYPE_STATIC_FACTORY_DISPLAY));
display = GDM_STATIC_FACTORY_DISPLAY (G_OBJECT_CLASS (gdm_static_factory_display_parent_class)->constructor (type,
- n_construct_properties,
- construct_properties));
+ n_construct_properties,
+ construct_properties));
return G_OBJECT (display);
}
@@ -257,71 +257,71 @@ gdm_static_factory_display_constructor (GType type,
static void
gdm_static_factory_display_class_init (GdmStaticFactoryDisplayClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GdmDisplayClass *display_class = GDM_DISPLAY_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GdmDisplayClass *display_class = GDM_DISPLAY_CLASS (klass);
- object_class->get_property = gdm_static_factory_display_get_property;
- object_class->set_property = gdm_static_factory_display_set_property;
+ object_class->get_property = gdm_static_factory_display_get_property;
+ object_class->set_property = gdm_static_factory_display_set_property;
object_class->constructor = gdm_static_factory_display_constructor;
- object_class->finalize = gdm_static_factory_display_finalize;
+ object_class->finalize = gdm_static_factory_display_finalize;
- display_class->create_authority = gdm_static_factory_display_create_authority;
- display_class->add_user_authorization = gdm_static_factory_display_add_user_authorization;
- display_class->remove_user_authorization = gdm_static_factory_display_remove_user_authorization;
- display_class->manage = gdm_static_factory_display_manage;
- display_class->finish = gdm_static_factory_display_finish;
- display_class->unmanage = gdm_static_factory_display_unmanage;
+ display_class->create_authority = gdm_static_factory_display_create_authority;
+ display_class->add_user_authorization = gdm_static_factory_display_add_user_authorization;
+ display_class->remove_user_authorization = gdm_static_factory_display_remove_user_authorization;
+ display_class->manage = gdm_static_factory_display_manage;
+ display_class->finish = gdm_static_factory_display_finish;
+ display_class->unmanage = gdm_static_factory_display_unmanage;
g_object_class_install_property (object_class,
PROP_DISPLAY_STORE,
g_param_spec_object ("display-store",
- "display store",
- "display store",
- GDM_TYPE_DISPLAY_STORE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ "display store",
+ "display store",
+ GDM_TYPE_DISPLAY_STORE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_type_class_add_private (klass, sizeof (GdmStaticFactoryDisplayPrivate));
+ g_type_class_add_private (klass, sizeof (GdmStaticFactoryDisplayPrivate));
- dbus_g_object_type_install_info (GDM_TYPE_STATIC_FACTORY_DISPLAY, &dbus_glib_gdm_static_factory_display_object_info);
+ dbus_g_object_type_install_info (GDM_TYPE_STATIC_FACTORY_DISPLAY, &dbus_glib_gdm_static_factory_display_object_info);
}
static void
gdm_static_factory_display_init (GdmStaticFactoryDisplay *static_factory_display)
{
- static_factory_display->priv = GDM_STATIC_FACTORY_DISPLAY_GET_PRIVATE (static_factory_display);
+ static_factory_display->priv = GDM_STATIC_FACTORY_DISPLAY_GET_PRIVATE (static_factory_display);
}
static void
gdm_static_factory_display_finalize (GObject *object)
{
- GdmStaticFactoryDisplay *static_factory_display;
+ GdmStaticFactoryDisplay *static_factory_display;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_STATIC_FACTORY_DISPLAY (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_STATIC_FACTORY_DISPLAY (object));
- static_factory_display = GDM_STATIC_FACTORY_DISPLAY (object);
+ static_factory_display = GDM_STATIC_FACTORY_DISPLAY (object);
- g_return_if_fail (static_factory_display->priv != NULL);
+ g_return_if_fail (static_factory_display->priv != NULL);
- G_OBJECT_CLASS (gdm_static_factory_display_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_static_factory_display_parent_class)->finalize (object);
}
GdmDisplay *
gdm_static_factory_display_new (int display_number,
- GdmDisplayStore *store)
+ GdmDisplayStore *store)
{
- GObject *object;
- char *x11_display;
-
- x11_display = g_strdup_printf (":%d", display_number);
- object = g_object_new (GDM_TYPE_STATIC_FACTORY_DISPLAY,
- "slave-command", DEFAULT_SLAVE_COMMAND,
- "x11-display-number", display_number,
- "x11-display-name", x11_display,
- "display-store", store,
- NULL);
- g_free (x11_display);
-
- return GDM_DISPLAY (object);
+ GObject *object;
+ char *x11_display;
+
+ x11_display = g_strdup_printf (":%d", display_number);
+ object = g_object_new (GDM_TYPE_STATIC_FACTORY_DISPLAY,
+ "slave-command", DEFAULT_SLAVE_COMMAND,
+ "x11-display-number", display_number,
+ "x11-display-name", x11_display,
+ "display-store", store,
+ NULL);
+ g_free (x11_display);
+
+ return GDM_DISPLAY (object);
}
diff --git a/daemon/gdm-static-factory-display.h b/daemon/gdm-static-factory-display.h
index b3e1c40f..d2cc0201 100644
--- a/daemon/gdm-static-factory-display.h
+++ b/daemon/gdm-static-factory-display.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -41,24 +41,24 @@ typedef struct GdmStaticFactoryDisplayPrivate GdmStaticFactoryDisplayPrivate;
typedef struct
{
- GdmDisplay parent;
- GdmStaticFactoryDisplayPrivate *priv;
+ GdmDisplay parent;
+ GdmStaticFactoryDisplayPrivate *priv;
} GdmStaticFactoryDisplay;
typedef struct
{
- GdmDisplayClass parent_class;
+ GdmDisplayClass parent_class;
} GdmStaticFactoryDisplayClass;
-GType gdm_static_factory_display_get_type (void);
-GdmDisplay * gdm_static_factory_display_new (int display_number,
- GdmDisplayStore *store);
+GType gdm_static_factory_display_get_type (void);
+GdmDisplay * gdm_static_factory_display_new (int display_number,
+ GdmDisplayStore *store);
gboolean gdm_static_factory_display_create_product_display (GdmStaticFactoryDisplay *display,
- const char *server_address,
- char **id,
- GError **error);
+ const char *server_address,
+ char **id,
+ GError **error);
G_END_DECLS
diff --git a/daemon/gdm-xdmcp-display-factory.c b/daemon/gdm-xdmcp-display-factory.c
index 70037ef1..eacc89f1 100644
--- a/daemon/gdm-xdmcp-display-factory.c
+++ b/daemon/gdm-xdmcp-display-factory.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 1998, 1999, 2000 Martin K. Petersen <mkp@mkp.net>
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
@@ -88,30 +88,30 @@ int deny_severity = LOG_WARNING;
* the wrong XDMCP version anyway */
#define GDM_XDMCP_PROTOCOL_VERSION 1001
enum {
- GDM_XDMCP_FIRST_OPCODE = 1000, /*just a marker, not an opcode */
-
- GDM_XDMCP_MANAGED_FORWARD = 1000,
- /* manager (master) -> manager
- * A packet with MANAGED_FORWARD is sent to the
- * manager that sent the forward query from the manager to
- * which forward query was sent. It indicates that the forward
- * was fully processed and that the client now has either
- * a managed session, or has been sent denial, refuse or failed.
- * (if the denial gets lost then client gets dumped into the
- * chooser again). This should be resent a few times
- * until some (short) timeout or until GOT_MANAGED_FORWARD
- * is sent. GDM sends at most 3 packates with 1.5 seconds
- * between each.
- *
- * Argument is ARRAY8 with the address of the originating host */
- GDM_XDMCP_GOT_MANAGED_FORWARD,
- /* manager -> manager (master)
- * A single packet with GOT_MANAGED_FORWARD is sent to indicate
- * that we did receive the MANAGED_FORWARD packet. The argument
- * must match the MANAGED_FORWARD one or it will just be ignored.
- *
- * Argument is ARRAY8 with the address of the originating host */
- GDM_XDMCP_LAST_OPCODE /*just a marker, not an opcode */
+ GDM_XDMCP_FIRST_OPCODE = 1000, /*just a marker, not an opcode */
+
+ GDM_XDMCP_MANAGED_FORWARD = 1000,
+ /* manager (master) -> manager
+ * A packet with MANAGED_FORWARD is sent to the
+ * manager that sent the forward query from the manager to
+ * which forward query was sent. It indicates that the forward
+ * was fully processed and that the client now has either
+ * a managed session, or has been sent denial, refuse or failed.
+ * (if the denial gets lost then client gets dumped into the
+ * chooser again). This should be resent a few times
+ * until some (short) timeout or until GOT_MANAGED_FORWARD
+ * is sent. GDM sends at most 3 packates with 1.5 seconds
+ * between each.
+ *
+ * Argument is ARRAY8 with the address of the originating host */
+ GDM_XDMCP_GOT_MANAGED_FORWARD,
+ /* manager -> manager (master)
+ * A single packet with GOT_MANAGED_FORWARD is sent to indicate
+ * that we did receive the MANAGED_FORWARD packet. The argument
+ * must match the MANAGED_FORWARD one or it will just be ignored.
+ *
+ * Argument is ARRAY8 with the address of the originating host */
+ GDM_XDMCP_LAST_OPCODE /*just a marker, not an opcode */
};
/*
@@ -127,75 +127,75 @@ enum {
*/
typedef struct _XdmAuth {
- ARRAY8 authentication;
- ARRAY8 authorization;
+ ARRAY8 authentication;
+ ARRAY8 authorization;
} XdmAuthRec, *XdmAuthPtr;
static XdmAuthRec serv_authlist = {
- { (CARD16) 0, (CARD8 *) 0 },
- { (CARD16) 0, (CARD8 *) 0 }
+ { (CARD16) 0, (CARD8 *) 0 },
+ { (CARD16) 0, (CARD8 *) 0 }
};
/* NOTE: Timeout and max are hardcoded */
typedef struct _GdmForwardQuery {
- time_t acctime;
- GdmAddress *dsp_address;
- GdmAddress *from_address;
+ time_t acctime;
+ GdmAddress *dsp_address;
+ GdmAddress *from_address;
} GdmForwardQuery;
typedef struct {
- int times;
- guint handler;
- GdmAddress *manager;
- GdmAddress *origin;
- GdmXdmcpDisplayFactory *xdmcp_display_factory;
+ int times;
+ guint handler;
+ GdmAddress *manager;
+ GdmAddress *origin;
+ GdmXdmcpDisplayFactory *xdmcp_display_factory;
} ManagedForward;
struct GdmXdmcpDisplayFactoryPrivate
{
- GSList *forward_queries;
- GSList *managed_forwards;
-
- int socket_fd;
- gint32 session_serial;
- guint socket_watch_id;
- XdmcpBuffer buf;
-
- guint num_sessions;
- guint num_pending_sessions;
-
- char *sysid;
- char *hostname;
- ARRAY8 servhost;
-
- /* configuration */
- guint port;
- gboolean use_multicast;
- char *multicast_address;
- gboolean honor_indirect;
- char *willing_script;
- guint max_displays_per_host;
- guint max_displays;
- guint max_pending_displays;
- guint max_wait;
+ GSList *forward_queries;
+ GSList *managed_forwards;
+
+ int socket_fd;
+ gint32 session_serial;
+ guint socket_watch_id;
+ XdmcpBuffer buf;
+
+ guint num_sessions;
+ guint num_pending_sessions;
+
+ char *sysid;
+ char *hostname;
+ ARRAY8 servhost;
+
+ /* configuration */
+ guint port;
+ gboolean use_multicast;
+ char *multicast_address;
+ gboolean honor_indirect;
+ char *willing_script;
+ guint max_displays_per_host;
+ guint max_displays;
+ guint max_pending_displays;
+ guint max_wait;
};
enum {
- PROP_0,
- PROP_PORT,
- PROP_USE_MULTICAST,
- PROP_MULTICAST_ADDRESS,
- PROP_HONOR_INDIRECT,
- PROP_WILLING_SCRIPT,
- PROP_MAX_DISPLAYS_PER_HOST,
- PROP_MAX_DISPLAYS,
- PROP_MAX_PENDING_DISPLAYS,
- PROP_MAX_WAIT,
+ PROP_0,
+ PROP_PORT,
+ PROP_USE_MULTICAST,
+ PROP_MULTICAST_ADDRESS,
+ PROP_HONOR_INDIRECT,
+ PROP_WILLING_SCRIPT,
+ PROP_MAX_DISPLAYS_PER_HOST,
+ PROP_MAX_DISPLAYS,
+ PROP_MAX_PENDING_DISPLAYS,
+ PROP_MAX_WAIT,
};
-static void gdm_xdmcp_display_factory_class_init (GdmXdmcpDisplayFactoryClass *klass);
-static void gdm_xdmcp_display_factory_init (GdmXdmcpDisplayFactory *manager);
-static void gdm_xdmcp_display_factory_finalize (GObject *object);
+static void gdm_xdmcp_display_factory_class_init (GdmXdmcpDisplayFactoryClass *klass);
+static void gdm_xdmcp_display_factory_init (GdmXdmcpDisplayFactory *manager);
+static void gdm_xdmcp_display_factory_finalize (GObject *object);
static gpointer xdmcp_display_factory_object = NULL;
@@ -238,342 +238,342 @@ G_DEFINE_TYPE (GdmXdmcpDisplayFactory, gdm_xdmcp_display_factory, GDM_TYPE_DISPL
GQuark
gdm_xdmcp_display_factory_error_quark (void)
{
- static GQuark ret = 0;
- if (ret == 0) {
- ret = g_quark_from_static_string ("gdm_xdmcp_display_factory_error");
- }
+ static GQuark ret = 0;
+ if (ret == 0) {
+ ret = g_quark_from_static_string ("gdm_xdmcp_display_factory_error");
+ }
- return ret;
+ return ret;
}
static gint32
get_next_session_serial (GdmXdmcpDisplayFactory *factory)
{
- gint32 serial;
+ gint32 serial;
again:
- if (factory->priv->session_serial != G_MAXINT32) {
- serial = factory->priv->session_serial++;
- } else {
- serial = g_random_int ();
- }
+ if (factory->priv->session_serial != G_MAXINT32) {
+ serial = factory->priv->session_serial++;
+ } else {
+ serial = g_random_int ();
+ }
- if (serial == 0) {
- goto again;
- }
+ if (serial == 0) {
+ goto again;
+ }
- return serial;
+ return serial;
}
/* for debugging */
static const char *
ai_family_str (struct addrinfo *ai)
{
- const char *str;
- switch (ai->ai_family) {
- case AF_INET:
- str = "inet";
- break;
- case AF_INET6:
- str = "inet6";
- break;
- case AF_UNIX:
- str = "unix";
- break;
- case AF_UNSPEC:
- str = "unspecified";
- break;
- default:
- str = "unknown";
- break;
- }
- return str;
+ const char *str;
+ switch (ai->ai_family) {
+ case AF_INET:
+ str = "inet";
+ break;
+ case AF_INET6:
+ str = "inet6";
+ break;
+ case AF_UNIX:
+ str = "unix";
+ break;
+ case AF_UNSPEC:
+ str = "unspecified";
+ break;
+ default:
+ str = "unknown";
+ break;
+ }
+ return str;
}
/* for debugging */
static const char *
ai_type_str (struct addrinfo *ai)
{
- const char *str;
- switch (ai->ai_socktype) {
- case SOCK_STREAM:
- str = "stream";
- break;
- case SOCK_DGRAM:
- str = "datagram";
- break;
- case SOCK_SEQPACKET:
- str = "seqpacket";
- break;
- case SOCK_RAW:
- str = "raw";
- break;
- default:
- str = "unknown";
- break;
- }
- return str;
+ const char *str;
+ switch (ai->ai_socktype) {
+ case SOCK_STREAM:
+ str = "stream";
+ break;
+ case SOCK_DGRAM:
+ str = "datagram";
+ break;
+ case SOCK_SEQPACKET:
+ str = "seqpacket";
+ break;
+ case SOCK_RAW:
+ str = "raw";
+ break;
+ default:
+ str = "unknown";
+ break;
+ }
+ return str;
}
/* for debugging */
static const char *
ai_protocol_str (struct addrinfo *ai)
{
- const char *str;
- switch (ai->ai_protocol) {
- case 0:
- str = "default";
- break;
- case IPPROTO_TCP:
- str = "TCP";
- break;
- case IPPROTO_UDP:
- str = "UDP";
- break;
- case IPPROTO_RAW:
- str = "raw";
- break;
- default:
- str = "unknown";
- break;
- }
-
- return str;
+ const char *str;
+ switch (ai->ai_protocol) {
+ case 0:
+ str = "default";
+ break;
+ case IPPROTO_TCP:
+ str = "TCP";
+ break;
+ case IPPROTO_UDP:
+ str = "UDP";
+ break;
+ case IPPROTO_RAW:
+ str = "raw";
+ break;
+ default:
+ str = "unknown";
+ break;
+ }
+
+ return str;
}
/* for debugging */
static char *
ai_flags_str (struct addrinfo *ai)
{
- GString *str;
-
- str = g_string_new ("");
- if (ai->ai_flags == 0) {
- g_string_append (str, "none");
- } else {
- if (ai->ai_flags & AI_PASSIVE) {
- g_string_append (str, "passive ");
- }
- if (ai->ai_flags & AI_CANONNAME) {
- g_string_append (str, "canon ");
- }
- if (ai->ai_flags & AI_NUMERICHOST) {
- g_string_append (str, "numhost ");
- }
- if (ai->ai_flags & AI_NUMERICSERV) {
- g_string_append (str, "numserv ");
- }
- if (ai->ai_flags & AI_V4MAPPED) {
- g_string_append (str, "v4mapped ");
- }
- if (ai->ai_flags & AI_ALL) {
- g_string_append (str, "all ");
- }
- }
- return g_string_free (str, FALSE);
+ GString *str;
+
+ str = g_string_new ("");
+ if (ai->ai_flags == 0) {
+ g_string_append (str, "none");
+ } else {
+ if (ai->ai_flags & AI_PASSIVE) {
+ g_string_append (str, "passive ");
+ }
+ if (ai->ai_flags & AI_CANONNAME) {
+ g_string_append (str, "canon ");
+ }
+ if (ai->ai_flags & AI_NUMERICHOST) {
+ g_string_append (str, "numhost ");
+ }
+ if (ai->ai_flags & AI_NUMERICSERV) {
+ g_string_append (str, "numserv ");
+ }
+ if (ai->ai_flags & AI_V4MAPPED) {
+ g_string_append (str, "v4mapped ");
+ }
+ if (ai->ai_flags & AI_ALL) {
+ g_string_append (str, "all ");
+ }
+ }
+ return g_string_free (str, FALSE);
}
/* for debugging */
static void
debug_addrinfo (struct addrinfo *ai)
{
- char *str;
- str = ai_flags_str (ai);
- g_debug ("XDMCP: addrinfo family=%s type=%s proto=%s flags=%s",
- ai_family_str (ai),
- ai_type_str (ai),
- ai_protocol_str (ai),
- str);
- g_free (str);
+ char *str;
+ str = ai_flags_str (ai);
+ g_debug ("XDMCP: addrinfo family=%s type=%s proto=%s flags=%s",
+ ai_family_str (ai),
+ ai_type_str (ai),
+ ai_protocol_str (ai),
+ str);
+ g_free (str);
}
static int
create_socket (struct addrinfo *ai)
{
- int sock;
+ int sock;
- sock = socket (ai->ai_family, ai->ai_socktype, ai->ai_protocol);
- if (sock < 0) {
- g_warning ("socket: %s", g_strerror (errno));
- return sock;
- }
+ sock = socket (ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+ if (sock < 0) {
+ g_warning ("socket: %s", g_strerror (errno));
+ return sock;
+ }
- if (bind (sock, ai->ai_addr, ai->ai_addrlen) < 0) {
- g_warning ("bind: %s", g_strerror (errno));
- close (sock);
- return -1;
- }
+ if (bind (sock, ai->ai_addr, ai->ai_addrlen) < 0) {
+ g_warning ("bind: %s", g_strerror (errno));
+ close (sock);
+ return -1;
+ }
- return sock;
+ return sock;
}
static int
do_bind (guint port,
- int family,
- struct sockaddr_storage * hostaddr)
-{
- struct addrinfo hints;
- struct addrinfo *ai_list;
- struct addrinfo *ai;
- char strport[NI_MAXSERV];
- int gaierr;
- int sock;
-
- sock = -1;
-
- memset (&hints, 0, sizeof (hints));
- hints.ai_family = family;
- hints.ai_socktype = SOCK_DGRAM;
- hints.ai_flags = AI_PASSIVE;
-
- snprintf (strport, sizeof (strport), "%u", port);
- if ((gaierr = getaddrinfo (NULL, strport, &hints, &ai_list)) != 0) {
- g_error ("Unable to connect to socket: %s", gai_strerror (gaierr));
- return -1;
- }
-
- /* should only be one but.. */
- for (ai = ai_list; ai != NULL; ai = ai->ai_next) {
- if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6) {
- continue;
- }
-
- debug_addrinfo (ai);
-
- if (sock < 0) {
- char *host;
- char *serv;
- GdmAddress *addr;
-
- addr = gdm_address_new_from_sockaddr_storage ((struct sockaddr_storage *)ai->ai_addr);
-
- host = NULL;
- serv = NULL;
- gdm_address_get_numeric_info (addr, &host, &serv);
- g_debug ("XDMCP: Attempting to bind to host %s port %s", host, serv);
- g_free (host);
- g_free (serv);
- gdm_address_free (addr);
-
- sock = create_socket (ai);
- if (sock >= 0) {
- if (hostaddr != NULL) {
- memcpy (hostaddr, ai->ai_addr, ai->ai_addrlen);
- }
- }
- }
- }
-
- freeaddrinfo (ai_list);
-
- return sock;
+ int family,
+ struct sockaddr_storage * hostaddr)
+{
+ struct addrinfo hints;
+ struct addrinfo *ai_list;
+ struct addrinfo *ai;
+ char strport[NI_MAXSERV];
+ int gaierr;
+ int sock;
+
+ sock = -1;
+
+ memset (&hints, 0, sizeof (hints));
+ hints.ai_family = family;
+ hints.ai_socktype = SOCK_DGRAM;
+ hints.ai_flags = AI_PASSIVE;
+
+ snprintf (strport, sizeof (strport), "%u", port);
+ if ((gaierr = getaddrinfo (NULL, strport, &hints, &ai_list)) != 0) {
+ g_error ("Unable to connect to socket: %s", gai_strerror (gaierr));
+ return -1;
+ }
+
+ /* should only be one but.. */
+ for (ai = ai_list; ai != NULL; ai = ai->ai_next) {
+ if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6) {
+ continue;
+ }
+
+ debug_addrinfo (ai);
+
+ if (sock < 0) {
+ char *host;
+ char *serv;
+ GdmAddress *addr;
+
+ addr = gdm_address_new_from_sockaddr_storage ((struct sockaddr_storage *)ai->ai_addr);
+
+ host = NULL;
+ serv = NULL;
+ gdm_address_get_numeric_info (addr, &host, &serv);
+ g_debug ("XDMCP: Attempting to bind to host %s port %s", host, serv);
+ g_free (host);
+ g_free (serv);
+ gdm_address_free (addr);
+
+ sock = create_socket (ai);
+ if (sock >= 0) {
+ if (hostaddr != NULL) {
+ memcpy (hostaddr, ai->ai_addr, ai->ai_addrlen);
+ }
+ }
+ }
+ }
+
+ freeaddrinfo (ai_list);
+
+ return sock;
}
static void
setup_multicast (GdmXdmcpDisplayFactory *factory)
{
#ifdef ENABLE_IPV6
- /* Checking and Setting Multicast options */
- {
- /*
- * socktemp is a temporary socket for getting info about
- * available interfaces
- */
- int socktemp;
- int i;
- int num;
- char *buf;
- struct ipv6_mreq mreq;
-
- /* For interfaces' list */
- struct ifconf ifc;
- struct ifreq *ifr;
-
- socktemp = socket (AF_INET, SOCK_DGRAM, 0);
+ /* Checking and Setting Multicast options */
+ {
+ /*
+ * socktemp is a temporary socket for getting info about
+ * available interfaces
+ */
+ int socktemp;
+ int i;
+ int num;
+ char *buf;
+ struct ipv6_mreq mreq;
+
+ /* For interfaces' list */
+ struct ifconf ifc;
+ struct ifreq *ifr;
+
+ socktemp = socket (AF_INET, SOCK_DGRAM, 0);
#ifdef SIOCGIFNUM
- if (ioctl (socktemp, SIOCGIFNUM, &num) < 0) {
- num = 64;
- }
+ if (ioctl (socktemp, SIOCGIFNUM, &num) < 0) {
+ num = 64;
+ }
#else
- num = 64;
+ num = 64;
#endif /* SIOCGIFNUM */
- ifc.ifc_len = sizeof (struct ifreq) * num;
- ifc.ifc_buf = buf = malloc (ifc.ifc_len);
-
- if (ioctl (socktemp, SIOCGIFCONF, &ifc) >= 0) {
- ifr = ifc.ifc_req;
- num = ifc.ifc_len / sizeof (struct ifreq); /* No of interfaces */
-
- /* Joining multicast group with all interfaces */
- for (i = 0 ; i < num ; i++) {
- struct ifreq ifreq;
- int ifindex;
-
- memset (&ifreq, 0, sizeof (ifreq));
- strncpy (ifreq.ifr_name, ifr[i].ifr_name, sizeof (ifreq.ifr_name));
- /* paranoia */
- ifreq.ifr_name[sizeof (ifreq.ifr_name) - 1] = '\0';
-
- if (ioctl (socktemp, SIOCGIFFLAGS, &ifreq) < 0) {
- g_debug ("XDMCP: Could not get SIOCGIFFLAGS for %s",
- ifr[i].ifr_name);
- }
-
- ifindex = if_nametoindex (ifr[i].ifr_name);
-
- if ((!(ifreq.ifr_flags & IFF_UP) ||
- (ifreq.ifr_flags & IFF_LOOPBACK)) ||
- ((ifindex == 0 ) && (errno == ENXIO))) {
- /* Not a valid interface or loopback interface*/
- continue;
- }
-
- mreq.ipv6mr_interface = ifindex;
- inet_pton (AF_INET6,
- factory->priv->multicast_address,
- &mreq.ipv6mr_multiaddr);
-
- setsockopt (factory->priv->socket_fd,
- IPPROTO_IPV6,
- IPV6_JOIN_GROUP,
- &mreq,
- sizeof (mreq));
- }
- }
- g_free (buf);
- close (socktemp);
- }
+ ifc.ifc_len = sizeof (struct ifreq) * num;
+ ifc.ifc_buf = buf = malloc (ifc.ifc_len);
+
+ if (ioctl (socktemp, SIOCGIFCONF, &ifc) >= 0) {
+ ifr = ifc.ifc_req;
+ num = ifc.ifc_len / sizeof (struct ifreq); /* No of interfaces */
+
+ /* Joining multicast group with all interfaces */
+ for (i = 0 ; i < num ; i++) {
+ struct ifreq ifreq;
+ int ifindex;
+
+ memset (&ifreq, 0, sizeof (ifreq));
+ strncpy (ifreq.ifr_name, ifr[i].ifr_name, sizeof (ifreq.ifr_name));
+ /* paranoia */
+ ifreq.ifr_name[sizeof (ifreq.ifr_name) - 1] = '\0';
+
+ if (ioctl (socktemp, SIOCGIFFLAGS, &ifreq) < 0) {
+ g_debug ("XDMCP: Could not get SIOCGIFFLAGS for %s",
+ ifr[i].ifr_name);
+ }
+
+ ifindex = if_nametoindex (ifr[i].ifr_name);
+
+ if ((!(ifreq.ifr_flags & IFF_UP) ||
+ (ifreq.ifr_flags & IFF_LOOPBACK)) ||
+ ((ifindex == 0 ) && (errno == ENXIO))) {
+ /* Not a valid interface or loopback interface*/
+ continue;
+ }
+
+ mreq.ipv6mr_interface = ifindex;
+ inet_pton (AF_INET6,
+ factory->priv->multicast_address,
+ &mreq.ipv6mr_multiaddr);
+
+ setsockopt (factory->priv->socket_fd,
+ IPPROTO_IPV6,
+ IPV6_JOIN_GROUP,
+ &mreq,
+ sizeof (mreq));
+ }
+ }
+ g_free (buf);
+ close (socktemp);
+ }
#endif /* ENABLE_IPV6 */
}
static gboolean
open_port (GdmXdmcpDisplayFactory *factory)
{
- struct sockaddr_storage serv_sa = { 0 };
+ struct sockaddr_storage serv_sa = { 0 };
- g_debug ("XDMCP: Start up on host %s, port %d",
- factory->priv->hostname,
- factory->priv->port);
+ g_debug ("XDMCP: Start up on host %s, port %d",
+ factory->priv->hostname,
+ factory->priv->port);
- /* Open socket for communications */
+ /* Open socket for communications */
#ifdef ENABLE_IPV6
- factory->priv->socket_fd = do_bind (factory->priv->port, AF_INET6, &serv_sa);
- if (factory->priv->socket_fd < 0)
+ factory->priv->socket_fd = do_bind (factory->priv->port, AF_INET6, &serv_sa);
+ if (factory->priv->socket_fd < 0)
#endif
- factory->priv->socket_fd = do_bind (factory->priv->port, AF_INET, &serv_sa);
+ factory->priv->socket_fd = do_bind (factory->priv->port, AF_INET, &serv_sa);
- if G_UNLIKELY (factory->priv->socket_fd < 0) {
- g_warning (_("Could not create socket!"));
- return FALSE;
- }
+ if G_UNLIKELY (factory->priv->socket_fd < 0) {
+ g_warning (_("Could not create socket!"));
+ return FALSE;
+ }
- gdm_fd_set_close_on_exec (factory->priv->socket_fd);
+ gdm_fd_set_close_on_exec (factory->priv->socket_fd);
- if (factory->priv->use_multicast) {
- setup_multicast (factory);
- }
+ if (factory->priv->use_multicast) {
+ setup_multicast (factory);
+ }
- return TRUE;
+ return TRUE;
}
static gboolean
@@ -581,277 +581,277 @@ gdm_xdmcp_host_allow (GdmAddress *address)
{
#ifdef HAVE_TCPWRAPPERS
- /*
- * Avoids a warning, my tcpd.h file doesn't include this prototype, even
- * though the library does include the function and the manpage mentions it
- */
- extern int hosts_ctl (char *daemon,
- char *client_name,
- char *client_addr,
- char *client_user);
+ /*
+ * Avoids a warning, my tcpd.h file doesn't include this prototype, even
+ * though the library does include the function and the manpage mentions it
+ */
+ extern int hosts_ctl (char *daemon,
+ char *client_name,
+ char *client_addr,
+ char *client_user);
- char *client;
- char *host;
- gboolean ret;
+ char *client;
+ char *host;
+ gboolean ret;
- host = NULL;
- client = NULL;
+ host = NULL;
+ client = NULL;
- /* Find client hostname */
- gdm_address_get_hostname (address, &client);
- gdm_address_get_numeric_info (address, &host, NULL);
+ /* Find client hostname */
+ gdm_address_get_hostname (address, &client);
+ gdm_address_get_numeric_info (address, &host, NULL);
- /* Check with tcp_wrappers if client is allowed to access */
- ret = hosts_ctl ("gdm", client, host, "");
+ /* Check with tcp_wrappers if client is allowed to access */
+ ret = hosts_ctl ("gdm", client, host, "");
- g_free (host);
- g_free (client);
+ g_free (host);
+ g_free (client);
- return ret;
+ return ret;
#else /* HAVE_TCPWRAPPERS */
- return (TRUE);
+ return (TRUE);
#endif /* HAVE_TCPWRAPPERS */
}
typedef struct {
- GdmAddress *address;
- int count;
+ GdmAddress *address;
+ int count;
} CountDisplayData;
static gboolean
count_displays_from_host (const char *id,
- GdmDisplay *display,
- CountDisplayData *data)
+ GdmDisplay *display,
+ CountDisplayData *data)
{
- GdmAddress *address;
+ GdmAddress *address;
- if (GDM_IS_XDMCP_DISPLAY (display)) {
- address = gdm_xdmcp_display_get_remote_address (GDM_XDMCP_DISPLAY (display));
+ if (GDM_IS_XDMCP_DISPLAY (display)) {
+ address = gdm_xdmcp_display_get_remote_address (GDM_XDMCP_DISPLAY (display));
- if (gdm_address_equal (address, data->address)) {
- data->count++;
- }
- }
+ if (gdm_address_equal (address, data->address)) {
+ data->count++;
+ }
+ }
- return TRUE;
+ return TRUE;
}
static int
gdm_xdmcp_num_displays_from_host (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address)
+ GdmAddress *address)
{
- CountDisplayData data;
- GdmDisplayStore *store;
+ CountDisplayData data;
+ GdmDisplayStore *store;
- data.count = 0;
- data.address = address;
+ data.count = 0;
+ data.address = address;
- store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
- gdm_display_store_foreach (store,
- (GdmDisplayStoreFunc)count_displays_from_host,
- &data);
+ store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
+ gdm_display_store_foreach (store,
+ (GdmDisplayStoreFunc)count_displays_from_host,
+ &data);
- return data.count;
+ return data.count;
}
typedef struct {
- GdmAddress *address;
- int display_num;
+ GdmAddress *address;
+ int display_num;
} LookupHostData;
static gboolean
lookup_by_host (const char *id,
- GdmDisplay *display,
- LookupHostData *data)
+ GdmDisplay *display,
+ LookupHostData *data)
{
- GdmAddress *this_address;
- int disp_num;
+ GdmAddress *this_address;
+ int disp_num;
- if (! GDM_IS_XDMCP_DISPLAY (display)) {
- return FALSE;
- }
+ if (! GDM_IS_XDMCP_DISPLAY (display)) {
+ return FALSE;
+ }
- this_address = gdm_xdmcp_display_get_remote_address (GDM_XDMCP_DISPLAY (display));
- gdm_display_get_x11_display_number (display, &disp_num, NULL);
+ this_address = gdm_xdmcp_display_get_remote_address (GDM_XDMCP_DISPLAY (display));
+ gdm_display_get_x11_display_number (display, &disp_num, NULL);
- if (gdm_address_equal (this_address, data->address)
- && disp_num == data->display_num) {
- return TRUE;
- }
+ if (gdm_address_equal (this_address, data->address)
+ && disp_num == data->display_num) {
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
static GdmDisplay *
gdm_xdmcp_display_lookup_by_host (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
- int display_num)
+ GdmAddress *address,
+ int display_num)
{
- GdmDisplay *display;
- LookupHostData *data;
- GdmDisplayStore *store;
+ GdmDisplay *display;
+ LookupHostData *data;
+ GdmDisplayStore *store;
- data = g_new0 (LookupHostData, 1);
- data->address = address;
- data->display_num = display_num;
+ data = g_new0 (LookupHostData, 1);
+ data->address = address;
+ data->display_num = display_num;
- store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
- display = gdm_display_store_find (store,
- (GdmDisplayStoreFunc)lookup_by_host,
- data);
- g_free (data);
+ store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
+ display = gdm_display_store_find (store,
+ (GdmDisplayStoreFunc)lookup_by_host,
+ data);
+ g_free (data);
- return display;
+ return display;
}
static char *
get_willing_output (GdmXdmcpDisplayFactory *factory)
{
- char *output;
- char **argv;
- FILE *fd;
- char buf[256];
+ char *output;
+ char **argv;
+ FILE *fd;
+ char buf[256];
- output = NULL;
- buf[0] = '\0';
+ output = NULL;
+ buf[0] = '\0';
- if (factory->priv->willing_script == NULL) {
- goto out;
- }
+ if (factory->priv->willing_script == NULL) {
+ goto out;
+ }
- argv = NULL;
- if (! g_shell_parse_argv (factory->priv->willing_script, NULL, &argv, NULL)) {
- goto out;
- }
+ argv = NULL;
+ if (! g_shell_parse_argv (factory->priv->willing_script, NULL, &argv, NULL)) {
+ goto out;
+ }
- if (argv == NULL ||
- argv[0] == NULL ||
- g_access (argv[0], X_OK) != 0) {
- goto out;
- }
+ if (argv == NULL ||
+ argv[0] == NULL ||
+ g_access (argv[0], X_OK) != 0) {
+ goto out;
+ }
- fd = popen (factory->priv->willing_script, "r");
- if (fd == NULL) {
- goto out;
- }
+ fd = popen (factory->priv->willing_script, "r");
+ if (fd == NULL) {
+ goto out;
+ }
- if (fgets (buf, sizeof (buf), fd) == NULL) {
- pclose (fd);
- goto out;
- }
+ if (fgets (buf, sizeof (buf), fd) == NULL) {
+ pclose (fd);
+ goto out;
+ }
- pclose (fd);
+ pclose (fd);
- output = g_strdup (buf);
+ output = g_strdup (buf);
out:
- return output;
+ return output;
}
static void
gdm_xdmcp_send_willing (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address)
-{
- ARRAY8 status;
- XdmcpHeader header;
- static char *last_status = NULL;
- static time_t last_willing = 0;
- char *host;
-
- host = NULL;
- gdm_address_get_numeric_info (address, &host, NULL);
- g_debug ("XDMCP: Sending WILLING to %s", host);
- g_free (host);
-
- if (last_willing == 0 || time (NULL) - 3 > last_willing) {
- char *s;
-
- g_free (last_status);
-
- s = get_willing_output (factory);
- if (s != NULL) {
- g_free (last_status);
- last_status = s;
- } else {
- last_status = g_strdup (factory->priv->sysid);
- }
- }
-
- if (! gdm_address_is_local (address) &&
- gdm_xdmcp_num_displays_from_host (factory, address) >= factory->priv->max_displays_per_host) {
- /*
- * Don't translate, this goes over the wire to servers where we
- * don't know the charset or language, so it must be ascii
- */
- status.data = (CARD8 *) g_strdup_printf ("%s (Server is busy)",
- last_status);
- } else {
- status.data = (CARD8 *) g_strdup (last_status);
- }
-
- status.length = strlen ((char *) status.data);
-
- header.opcode = (CARD16) WILLING;
- header.length = 6 + serv_authlist.authentication.length;
- header.length += factory->priv->servhost.length + status.length;
- header.version = XDM_PROTOCOL_VERSION;
- XdmcpWriteHeader (&factory->priv->buf, &header);
-
- /* Hardcoded authentication */
- XdmcpWriteARRAY8 (&factory->priv->buf, &serv_authlist.authentication);
- XdmcpWriteARRAY8 (&factory->priv->buf, &factory->priv->servhost);
- XdmcpWriteARRAY8 (&factory->priv->buf, &status);
-
- XdmcpFlush (factory->priv->socket_fd,
- &factory->priv->buf,
- (XdmcpNetaddr)gdm_address_peek_sockaddr_storage (address),
- (int)sizeof (struct sockaddr_storage));
-
- g_free (status.data);
+ GdmAddress *address)
+{
+ ARRAY8 status;
+ XdmcpHeader header;
+ static char *last_status = NULL;
+ static time_t last_willing = 0;
+ char *host;
+
+ host = NULL;
+ gdm_address_get_numeric_info (address, &host, NULL);
+ g_debug ("XDMCP: Sending WILLING to %s", host);
+ g_free (host);
+
+ if (last_willing == 0 || time (NULL) - 3 > last_willing) {
+ char *s;
+
+ g_free (last_status);
+
+ s = get_willing_output (factory);
+ if (s != NULL) {
+ g_free (last_status);
+ last_status = s;
+ } else {
+ last_status = g_strdup (factory->priv->sysid);
+ }
+ }
+
+ if (! gdm_address_is_local (address) &&
+ gdm_xdmcp_num_displays_from_host (factory, address) >= factory->priv->max_displays_per_host) {
+ /*
+ * Don't translate, this goes over the wire to servers where we
+ * don't know the charset or language, so it must be ascii
+ */
+ status.data = (CARD8 *) g_strdup_printf ("%s (Server is busy)",
+ last_status);
+ } else {
+ status.data = (CARD8 *) g_strdup (last_status);
+ }
+
+ status.length = strlen ((char *) status.data);
+
+ header.opcode = (CARD16) WILLING;
+ header.length = 6 + serv_authlist.authentication.length;
+ header.length += factory->priv->servhost.length + status.length;
+ header.version = XDM_PROTOCOL_VERSION;
+ XdmcpWriteHeader (&factory->priv->buf, &header);
+
+ /* Hardcoded authentication */
+ XdmcpWriteARRAY8 (&factory->priv->buf, &serv_authlist.authentication);
+ XdmcpWriteARRAY8 (&factory->priv->buf, &factory->priv->servhost);
+ XdmcpWriteARRAY8 (&factory->priv->buf, &status);
+
+ XdmcpFlush (factory->priv->socket_fd,
+ &factory->priv->buf,
+ (XdmcpNetaddr)gdm_address_peek_sockaddr_storage (address),
+ (int)sizeof (struct sockaddr_storage));
+
+ g_free (status.data);
}
static void
gdm_xdmcp_send_unwilling (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
- int type)
-{
- ARRAY8 status;
- XdmcpHeader header;
- static time_t last_time = 0;
- char *host;
-
- /* only send at most one packet per second,
- no harm done if we don't send it at all */
- if (last_time + 1 >= time (NULL)) {
- return;
- }
-
- host = NULL;
- gdm_address_get_numeric_info (address, &host, NULL);
- g_debug ("XDMCP: Sending UNWILLING to %s", host);
- g_warning (_("Denied XDMCP query from host %s"), host);
- g_free (host);
-
- /*
- * Don't translate, this goes over the wire to servers where we
- * don't know the charset or language, so it must be ascii
- */
- status.data = (CARD8 *) "Display not authorized to connect";
- status.length = strlen ((char *) status.data);
-
- header.opcode = (CARD16) UNWILLING;
- header.length = 4 + factory->priv->servhost.length + status.length;
- header.version = XDM_PROTOCOL_VERSION;
- XdmcpWriteHeader (&factory->priv->buf, &header);
-
- XdmcpWriteARRAY8 (&factory->priv->buf, &factory->priv->servhost);
- XdmcpWriteARRAY8 (&factory->priv->buf, &status);
- XdmcpFlush (factory->priv->socket_fd,
- &factory->priv->buf,
- (XdmcpNetaddr)gdm_address_peek_sockaddr_storage (address),
- (int)sizeof (struct sockaddr_storage));
-
- last_time = time (NULL);
+ GdmAddress *address,
+ int type)
+{
+ ARRAY8 status;
+ XdmcpHeader header;
+ static time_t last_time = 0;
+ char *host;
+
+ /* only send at most one packet per second,
+ no harm done if we don't send it at all */
+ if (last_time + 1 >= time (NULL)) {
+ return;
+ }
+
+ host = NULL;
+ gdm_address_get_numeric_info (address, &host, NULL);
+ g_debug ("XDMCP: Sending UNWILLING to %s", host);
+ g_warning (_("Denied XDMCP query from host %s"), host);
+ g_free (host);
+
+ /*
+ * Don't translate, this goes over the wire to servers where we
+ * don't know the charset or language, so it must be ascii
+ */
+ status.data = (CARD8 *) "Display not authorized to connect";
+ status.length = strlen ((char *) status.data);
+
+ header.opcode = (CARD16) UNWILLING;
+ header.length = 4 + factory->priv->servhost.length + status.length;
+ header.version = XDM_PROTOCOL_VERSION;
+ XdmcpWriteHeader (&factory->priv->buf, &header);
+
+ XdmcpWriteARRAY8 (&factory->priv->buf, &factory->priv->servhost);
+ XdmcpWriteARRAY8 (&factory->priv->buf, &status);
+ XdmcpFlush (factory->priv->socket_fd,
+ &factory->priv->buf,
+ (XdmcpNetaddr)gdm_address_peek_sockaddr_storage (address),
+ (int)sizeof (struct sockaddr_storage));
+
+ last_time = time (NULL);
}
#define SIN(__s) ((struct sockaddr_in *) __s)
@@ -859,2056 +859,2056 @@ gdm_xdmcp_send_unwilling (GdmXdmcpDisplayFactory *factory,
static void
set_port_for_request (GdmAddress *address,
- ARRAY8 *port)
+ ARRAY8 *port)
{
- struct sockaddr_storage *ss;
+ struct sockaddr_storage *ss;
- ss = gdm_address_peek_sockaddr_storage (address);
+ ss = gdm_address_peek_sockaddr_storage (address);
- /* we depend on this being 2 elsewhere as well */
- port->length = 2;
+ /* we depend on this being 2 elsewhere as well */
+ port->length = 2;
- switch (ss->ss_family) {
- case AF_INET:
- port->data = (CARD8 *)g_memdup (&(SIN (ss)->sin_port), port->length);
- break;
- case AF_INET6:
- port->data = (CARD8 *)g_memdup (&(SIN6 (ss)->sin6_port), port->length);
- break;
- default:
- port->data = NULL;
- break;
- }
+ switch (ss->ss_family) {
+ case AF_INET:
+ port->data = (CARD8 *)g_memdup (&(SIN (ss)->sin_port), port->length);
+ break;
+ case AF_INET6:
+ port->data = (CARD8 *)g_memdup (&(SIN6 (ss)->sin6_port), port->length);
+ break;
+ default:
+ port->data = NULL;
+ break;
+ }
}
static void
set_address_for_request (GdmAddress *address,
- ARRAY8 *addr)
+ ARRAY8 *addr)
{
- struct sockaddr_storage *ss;
+ struct sockaddr_storage *ss;
- ss = gdm_address_peek_sockaddr_storage (address);
+ ss = gdm_address_peek_sockaddr_storage (address);
- switch (ss->ss_family) {
- case AF_INET:
- addr->length = sizeof (struct in_addr);
- addr->data = g_memdup (&SIN (ss)->sin_addr, addr->length);
- break;
- case AF_INET6:
- addr->length = sizeof (struct in6_addr);
- addr->data = g_memdup (&SIN6 (ss)->sin6_addr, addr->length);
- break;
- default:
- addr->length = 0;
- addr->data = NULL;
- break;
- }
+ switch (ss->ss_family) {
+ case AF_INET:
+ addr->length = sizeof (struct in_addr);
+ addr->data = g_memdup (&SIN (ss)->sin_addr, addr->length);
+ break;
+ case AF_INET6:
+ addr->length = sizeof (struct in6_addr);
+ addr->data = g_memdup (&SIN6 (ss)->sin6_addr, addr->length);
+ break;
+ default:
+ addr->length = 0;
+ addr->data = NULL;
+ break;
+ }
}
static void
gdm_xdmcp_send_forward_query (GdmXdmcpDisplayFactory *factory,
- GdmIndirectDisplay *id,
- GdmAddress *address,
- GdmAddress *display_address,
- ARRAYofARRAY8Ptr authlist)
-{
- XdmcpHeader header;
- int i;
- ARRAY8 addr;
- ARRAY8 port;
- char *host;
- char *serv;
-
- g_assert (id != NULL);
- g_assert (id->chosen_host != NULL);
-
- host = NULL;
- gdm_address_get_numeric_info (id->chosen_host, &host, NULL);
- g_debug ("XDMCP: Sending forward query to %s",
- host);
- g_free (host);
-
- host = NULL;
- serv = NULL;
- gdm_address_get_numeric_info (display_address, &host, &serv);
- g_debug ("gdm_xdmcp_send_forward_query: Query contains %s:%s",
- host, serv);
- g_free (host);
- g_free (serv);
-
- set_port_for_request (address, &port);
- set_address_for_request (display_address, &addr);
-
- header.version = XDM_PROTOCOL_VERSION;
- header.opcode = (CARD16) FORWARD_QUERY;
- header.length = 0;
- header.length += 2 + addr.length;
- header.length += 2 + port.length;
- header.length += 1;
- for (i = 0; i < authlist->length; i++) {
- header.length += 2 + authlist->data[i].length;
- }
-
- XdmcpWriteHeader (&factory->priv->buf, &header);
- XdmcpWriteARRAY8 (&factory->priv->buf, &addr);
- XdmcpWriteARRAY8 (&factory->priv->buf, &port);
- XdmcpWriteARRAYofARRAY8 (&factory->priv->buf, authlist);
-
- XdmcpFlush (factory->priv->socket_fd,
- &factory->priv->buf,
- (XdmcpNetaddr)gdm_address_peek_sockaddr_storage (id->chosen_host),
- (int)sizeof (struct sockaddr_storage));
-
- g_free (port.data);
- g_free (addr.data);
+ GdmIndirectDisplay *id,
+ GdmAddress *address,
+ GdmAddress *display_address,
+ ARRAYofARRAY8Ptr authlist)
+{
+ XdmcpHeader header;
+ int i;
+ ARRAY8 addr;
+ ARRAY8 port;
+ char *host;
+ char *serv;
+
+ g_assert (id != NULL);
+ g_assert (id->chosen_host != NULL);
+
+ host = NULL;
+ gdm_address_get_numeric_info (id->chosen_host, &host, NULL);
+ g_debug ("XDMCP: Sending forward query to %s",
+ host);
+ g_free (host);
+
+ host = NULL;
+ serv = NULL;
+ gdm_address_get_numeric_info (display_address, &host, &serv);
+ g_debug ("gdm_xdmcp_send_forward_query: Query contains %s:%s",
+ host, serv);
+ g_free (host);
+ g_free (serv);
+
+ set_port_for_request (address, &port);
+ set_address_for_request (display_address, &addr);
+
+ header.version = XDM_PROTOCOL_VERSION;
+ header.opcode = (CARD16) FORWARD_QUERY;
+ header.length = 0;
+ header.length += 2 + addr.length;
+ header.length += 2 + port.length;
+ header.length += 1;
+ for (i = 0; i < authlist->length; i++) {
+ header.length += 2 + authlist->data[i].length;
+ }
+
+ XdmcpWriteHeader (&factory->priv->buf, &header);
+ XdmcpWriteARRAY8 (&factory->priv->buf, &addr);
+ XdmcpWriteARRAY8 (&factory->priv->buf, &port);
+ XdmcpWriteARRAYofARRAY8 (&factory->priv->buf, authlist);
+
+ XdmcpFlush (factory->priv->socket_fd,
+ &factory->priv->buf,
+ (XdmcpNetaddr)gdm_address_peek_sockaddr_storage (id->chosen_host),
+ (int)sizeof (struct sockaddr_storage));
+
+ g_free (port.data);
+ g_free (addr.data);
}
static void
handle_any_query (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
- ARRAYofARRAY8Ptr authentication_names,
- int type)
+ GdmAddress *address,
+ ARRAYofARRAY8Ptr authentication_names,
+ int type)
{
- gdm_xdmcp_send_willing (factory, address);
+ gdm_xdmcp_send_willing (factory, address);
}
static void
handle_direct_query (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
- int len,
- int type)
+ GdmAddress *address,
+ int len,
+ int type)
{
- ARRAYofARRAY8 clnt_authlist;
- int expected_len;
- int i;
- int res;
+ ARRAYofARRAY8 clnt_authlist;
+ int expected_len;
+ int i;
+ int res;
- res = XdmcpReadARRAYofARRAY8 (&factory->priv->buf, &clnt_authlist);
- if G_UNLIKELY (! res) {
- g_warning (_("Could not extract authlist from packet"));
- return;
- }
+ res = XdmcpReadARRAYofARRAY8 (&factory->priv->buf, &clnt_authlist);
+ if G_UNLIKELY (! res) {
+ g_warning (_("Could not extract authlist from packet"));
+ return;
+ }
- expected_len = 1;
+ expected_len = 1;
- for (i = 0 ; i < clnt_authlist.length ; i++) {
- expected_len += 2 + clnt_authlist.data[i].length;
- }
+ for (i = 0 ; i < clnt_authlist.length ; i++) {
+ expected_len += 2 + clnt_authlist.data[i].length;
+ }
- if (len == expected_len) {
- handle_any_query (factory, address, &clnt_authlist, type);
- } else {
- g_warning (_("Error in checksum"));
- }
+ if (len == expected_len) {
+ handle_any_query (factory, address, &clnt_authlist, type);
+ } else {
+ g_warning (_("Error in checksum"));
+ }
- XdmcpDisposeARRAYofARRAY8 (&clnt_authlist);
+ XdmcpDisposeARRAYofARRAY8 (&clnt_authlist);
}
static void
gdm_xdmcp_handle_broadcast_query (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
- int len)
+ GdmAddress *address,
+ int len)
{
- if (gdm_xdmcp_host_allow (address)) {
- handle_direct_query (factory, address, len, BROADCAST_QUERY);
- } else {
- /* just ignore it */
- }
+ if (gdm_xdmcp_host_allow (address)) {
+ handle_direct_query (factory, address, len, BROADCAST_QUERY);
+ } else {
+ /* just ignore it */
+ }
}
static void
gdm_xdmcp_handle_query (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
- int len)
+ GdmAddress *address,
+ int len)
{
- if (gdm_xdmcp_host_allow (address)) {
- handle_direct_query (factory, address, len, QUERY);
- } else {
- gdm_xdmcp_send_unwilling (factory, address, QUERY);
- }
+ if (gdm_xdmcp_host_allow (address)) {
+ handle_direct_query (factory, address, len, QUERY);
+ } else {
+ gdm_xdmcp_send_unwilling (factory, address, QUERY);
+ }
}
static void
gdm_xdmcp_handle_indirect_query (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
- int len)
-{
- ARRAYofARRAY8 clnt_authlist;
- int expected_len;
- int i;
- int res;
- GdmIndirectDisplay *id;
-
- if (! gdm_xdmcp_host_allow (address)) {
- /* ignore the request */
- return;
- }
-
- if (! factory->priv->honor_indirect) {
- /* ignore it */
- return;
- }
-
- res = XdmcpReadARRAYofARRAY8 (&factory->priv->buf, &clnt_authlist);
- if G_UNLIKELY (! res) {
- g_warning (_("Could not extract authlist from packet"));
- return;
- }
-
- expected_len = 1;
-
- for (i = 0 ; i < clnt_authlist.length ; i++) {
- expected_len += 2 + clnt_authlist.data[i].length;
- }
-
- /* Try to look up the display in
- * the pending list. If found send a FORWARD_QUERY to the
- * chosen factory. Otherwise alloc a new indirect display. */
-
- if (len != expected_len) {
- g_warning (_("Error in checksum"));
- goto out;
- }
-
-
- id = gdm_choose_indirect_lookup (address);
-
- if (id != NULL && id->chosen_host != NULL) {
- /* if user chose us, then just send willing */
- if (gdm_address_is_local (id->chosen_host)) {
- /* get rid of indirect, so that we don't get
- * the chooser */
- gdm_choose_indirect_dispose (id);
- gdm_xdmcp_send_willing (factory, address);
- } else if (gdm_address_is_loopback (address)) {
- /* woohoo! fun, I have no clue how to get
- * the correct ip, SO I just send forward
- * queries with all the different IPs */
- const GList *list = gdm_address_peek_local_list ();
-
- while (list != NULL) {
- GdmAddress *saddr = list->data;
-
- if (! gdm_address_is_loopback (saddr)) {
- /* forward query to * chosen host */
- gdm_xdmcp_send_forward_query (factory,
- id,
- address,
- saddr,
- &clnt_authlist);
- }
-
- list = list->next;
- }
- } else {
- /* or send forward query to chosen host */
- gdm_xdmcp_send_forward_query (factory,
- id,
- address,
- address,
- &clnt_authlist);
- }
- } else if (id == NULL) {
- id = gdm_choose_indirect_alloc (address);
- if (id != NULL) {
- gdm_xdmcp_send_willing (factory, address);
- }
- } else {
- gdm_xdmcp_send_willing (factory, address);
- }
+ GdmAddress *address,
+ int len)
+{
+ ARRAYofARRAY8 clnt_authlist;
+ int expected_len;
+ int i;
+ int res;
+ GdmIndirectDisplay *id;
+
+ if (! gdm_xdmcp_host_allow (address)) {
+ /* ignore the request */
+ return;
+ }
+
+ if (! factory->priv->honor_indirect) {
+ /* ignore it */
+ return;
+ }
+
+ res = XdmcpReadARRAYofARRAY8 (&factory->priv->buf, &clnt_authlist);
+ if G_UNLIKELY (! res) {
+ g_warning (_("Could not extract authlist from packet"));
+ return;
+ }
+
+ expected_len = 1;
+
+ for (i = 0 ; i < clnt_authlist.length ; i++) {
+ expected_len += 2 + clnt_authlist.data[i].length;
+ }
+
+ /* Try to look up the display in
+ * the pending list. If found send a FORWARD_QUERY to the
+ * chosen factory. Otherwise alloc a new indirect display. */
+
+ if (len != expected_len) {
+ g_warning (_("Error in checksum"));
+ goto out;
+ }
+
+
+ id = gdm_choose_indirect_lookup (address);
+
+ if (id != NULL && id->chosen_host != NULL) {
+ /* if user chose us, then just send willing */
+ if (gdm_address_is_local (id->chosen_host)) {
+ /* get rid of indirect, so that we don't get
+ * the chooser */
+ gdm_choose_indirect_dispose (id);
+ gdm_xdmcp_send_willing (factory, address);
+ } else if (gdm_address_is_loopback (address)) {
+ /* woohoo! fun, I have no clue how to get
+ * the correct ip, SO I just send forward
+ * queries with all the different IPs */
+ const GList *list = gdm_address_peek_local_list ();
+
+ while (list != NULL) {
+ GdmAddress *saddr = list->data;
+
+ if (! gdm_address_is_loopback (saddr)) {
+ /* forward query to * chosen host */
+ gdm_xdmcp_send_forward_query (factory,
+ id,
+ address,
+ saddr,
+ &clnt_authlist);
+ }
+
+ list = list->next;
+ }
+ } else {
+ /* or send forward query to chosen host */
+ gdm_xdmcp_send_forward_query (factory,
+ id,
+ address,
+ address,
+ &clnt_authlist);
+ }
+ } else if (id == NULL) {
+ id = gdm_choose_indirect_alloc (address);
+ if (id != NULL) {
+ gdm_xdmcp_send_willing (factory, address);
+ }
+ } else {
+ gdm_xdmcp_send_willing (factory, address);
+ }
out:
- XdmcpDisposeARRAYofARRAY8 (&clnt_authlist);
+ XdmcpDisposeARRAYofARRAY8 (&clnt_authlist);
}
static void
gdm_forward_query_dispose (GdmXdmcpDisplayFactory *factory,
- GdmForwardQuery *q)
+ GdmForwardQuery *q)
{
- if (q == NULL) {
- return;
- }
+ if (q == NULL) {
+ return;
+ }
- factory->priv->forward_queries = g_slist_remove (factory->priv->forward_queries, q);
+ factory->priv->forward_queries = g_slist_remove (factory->priv->forward_queries, q);
- q->acctime = 0;
+ q->acctime = 0;
- {
- char *host;
+ {
+ char *host;
- host = NULL;
- gdm_address_get_numeric_info (q->dsp_address, &host, NULL);
- g_debug ("gdm_forward_query_dispose: Disposing %s", host);
- g_free (host);
- }
+ host = NULL;
+ gdm_address_get_numeric_info (q->dsp_address, &host, NULL);
+ g_debug ("gdm_forward_query_dispose: Disposing %s", host);
+ g_free (host);
+ }
- g_free (q->dsp_address);
- q->dsp_address = NULL;
- g_free (q->from_address);
- q->from_address = NULL;
+ g_free (q->dsp_address);
+ q->dsp_address = NULL;
+ g_free (q->from_address);
+ q->from_address = NULL;
- g_free (q);
+ g_free (q);
}
static gboolean
remove_oldest_forward (GdmXdmcpDisplayFactory *factory)
{
- GSList *li;
- GdmForwardQuery *oldest = NULL;
+ GSList *li;
+ GdmForwardQuery *oldest = NULL;
- for (li = factory->priv->forward_queries; li != NULL; li = li->next) {
- GdmForwardQuery *query = li->data;
+ for (li = factory->priv->forward_queries; li != NULL; li = li->next) {
+ GdmForwardQuery *query = li->data;
- if (oldest == NULL || query->acctime < oldest->acctime) {
- oldest = query;
- }
- }
+ if (oldest == NULL || query->acctime < oldest->acctime) {
+ oldest = query;
+ }
+ }
- if (oldest != NULL) {
- gdm_forward_query_dispose (factory, oldest);
- return TRUE;
- } else {
- return FALSE;
- }
+ if (oldest != NULL) {
+ gdm_forward_query_dispose (factory, oldest);
+ return TRUE;
+ } else {
+ return FALSE;
+ }
}
static GdmForwardQuery *
gdm_forward_query_alloc (GdmXdmcpDisplayFactory *factory,
- GdmAddress *mgr_address,
- GdmAddress *dsp_address)
+ GdmAddress *mgr_address,
+ GdmAddress *dsp_address)
{
- GdmForwardQuery *q;
- int count;
+ GdmForwardQuery *q;
+ int count;
- count = g_slist_length (factory->priv->forward_queries);
+ count = g_slist_length (factory->priv->forward_queries);
- while (count > GDM_MAX_FORWARD_QUERIES && remove_oldest_forward (factory)) {
- count--;
- }
+ while (count > GDM_MAX_FORWARD_QUERIES && remove_oldest_forward (factory)) {
+ count--;
+ }
- q = g_new0 (GdmForwardQuery, 1);
- q->dsp_address = gdm_address_copy (dsp_address);
- q->from_address = gdm_address_copy (mgr_address);
+ q = g_new0 (GdmForwardQuery, 1);
+ q->dsp_address = gdm_address_copy (dsp_address);
+ q->from_address = gdm_address_copy (mgr_address);
- factory->priv->forward_queries = g_slist_prepend (factory->priv->forward_queries, q);
+ factory->priv->forward_queries = g_slist_prepend (factory->priv->forward_queries, q);
- return q;
+ return q;
}
static GdmForwardQuery *
gdm_forward_query_lookup (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address)
+ GdmAddress *address)
{
- GSList *li;
- GSList *qlist;
- GdmForwardQuery *ret;
- time_t curtime;
+ GSList *li;
+ GSList *qlist;
+ GdmForwardQuery *ret;
+ time_t curtime;
- curtime = time (NULL);
- ret = NULL;
+ curtime = time (NULL);
+ ret = NULL;
- qlist = g_slist_copy (factory->priv->forward_queries);
+ qlist = g_slist_copy (factory->priv->forward_queries);
- for (li = qlist; li != NULL; li = li->next) {
- GdmForwardQuery *q;
- char *host;
- char *serv;
+ for (li = qlist; li != NULL; li = li->next) {
+ GdmForwardQuery *q;
+ char *host;
+ char *serv;
- q = (GdmForwardQuery *) li->data;
+ q = (GdmForwardQuery *) li->data;
- if (q == NULL) {
- continue;
- }
+ if (q == NULL) {
+ continue;
+ }
- host = NULL;
- serv = NULL;
- gdm_address_get_numeric_info (q->dsp_address, &host, &serv);
+ host = NULL;
+ serv = NULL;
+ gdm_address_get_numeric_info (q->dsp_address, &host, &serv);
- g_debug ("gdm_forward_query_lookup: comparing %s:%s", host, serv);
- if (gdm_address_equal (q->dsp_address, address)) {
- ret = q;
- g_free (host);
- g_free (serv);
- break;
- }
+ g_debug ("gdm_forward_query_lookup: comparing %s:%s", host, serv);
+ if (gdm_address_equal (q->dsp_address, address)) {
+ ret = q;
+ g_free (host);
+ g_free (serv);
+ break;
+ }
- if (q->acctime > 0 && curtime > q->acctime + GDM_FORWARD_QUERY_TIMEOUT) {
- g_debug ("gdm_forward_query_lookup: Disposing stale forward query from %s:%s",
- host, serv);
+ if (q->acctime > 0 && curtime > q->acctime + GDM_FORWARD_QUERY_TIMEOUT) {
+ g_debug ("gdm_forward_query_lookup: Disposing stale forward query from %s:%s",
+ host, serv);
- gdm_forward_query_dispose (factory, q);
- }
+ gdm_forward_query_dispose (factory, q);
+ }
- g_free (host);
- g_free (serv);
- }
+ g_free (host);
+ g_free (serv);
+ }
- g_slist_free (qlist);
+ g_slist_free (qlist);
- if (ret == NULL) {
- char *host;
+ if (ret == NULL) {
+ char *host;
- host = NULL;
- gdm_address_get_numeric_info (address, &host, NULL);
- g_debug ("gdm_forward_query_lookup: Host %s not found",
- host);
- g_free (host);
- }
+ host = NULL;
+ gdm_address_get_numeric_info (address, &host, NULL);
+ g_debug ("gdm_forward_query_lookup: Host %s not found",
+ host);
+ g_free (host);
+ }
- return ret;
+ return ret;
}
static gboolean
create_address_from_request (ARRAY8 *req_addr,
- ARRAY8 *req_port,
- int family,
- GdmAddress **address)
-{
- uint16_t port;
- char host_buf [NI_MAXHOST];
- char serv_buf [NI_MAXSERV];
- char *serv;
- const char *host;
- struct addrinfo hints;
- struct addrinfo *ai_list;
- struct addrinfo *ai;
- int gaierr;
- gboolean found;
-
- if (address != NULL) {
- *address = NULL;
- }
-
- if (req_addr == NULL) {
- return FALSE;
- }
-
- serv = NULL;
- if (req_port != NULL) {
- /* port must always be length 2 */
- if (req_port->length != 2) {
- return FALSE;
- }
-
- memcpy (&port, req_port->data, 2);
- snprintf (serv_buf, sizeof (serv_buf), "%d", ntohs (port));
- serv = serv_buf;
- } else {
- /* assume XDM_UDP_PORT */
- snprintf (serv_buf, sizeof (serv_buf), "%d", XDM_UDP_PORT);
- serv = serv_buf;
- }
-
- host = NULL;
- if (req_addr->length == 4) {
- host = inet_ntop (AF_INET,
- (const void *)req_addr->data,
- host_buf,
- sizeof (host_buf));
- } else if (req_addr->length == 16) {
- host = inet_ntop (AF_INET6,
- (const void *)req_addr->data,
- host_buf,
- sizeof (host_buf));
- }
-
- if (host == NULL) {
- g_warning (_("Bad address"));
- return FALSE;
- }
-
- memset (&hints, 0, sizeof (hints));
- hints.ai_family = family;
- hints.ai_flags = AI_V4MAPPED; /* this should convert IPv4 address to IPv6 if needed */
- if ((gaierr = getaddrinfo (host, serv, &hints, &ai_list)) != 0) {
- g_warning ("Unable get address: %s", gai_strerror (gaierr));
- return FALSE;
- }
-
- /* just take the first one */
- ai = ai_list;
-
- found = FALSE;
- if (ai != NULL) {
- found = TRUE;
- if (address != NULL) {
- *address = gdm_address_new_from_sockaddr_storage ((struct sockaddr_storage *)ai->ai_addr);
- }
- }
-
- freeaddrinfo (ai_list);
-
- return found;
+ ARRAY8 *req_port,
+ int family,
+ GdmAddress **address)
+{
+ uint16_t port;
+ char host_buf [NI_MAXHOST];
+ char serv_buf [NI_MAXSERV];
+ char *serv;
+ const char *host;
+ struct addrinfo hints;
+ struct addrinfo *ai_list;
+ struct addrinfo *ai;
+ int gaierr;
+ gboolean found;
+
+ if (address != NULL) {
+ *address = NULL;
+ }
+
+ if (req_addr == NULL) {
+ return FALSE;
+ }
+
+ serv = NULL;
+ if (req_port != NULL) {
+ /* port must always be length 2 */
+ if (req_port->length != 2) {
+ return FALSE;
+ }
+
+ memcpy (&port, req_port->data, 2);
+ snprintf (serv_buf, sizeof (serv_buf), "%d", ntohs (port));
+ serv = serv_buf;
+ } else {
+ /* assume XDM_UDP_PORT */
+ snprintf (serv_buf, sizeof (serv_buf), "%d", XDM_UDP_PORT);
+ serv = serv_buf;
+ }
+
+ host = NULL;
+ if (req_addr->length == 4) {
+ host = inet_ntop (AF_INET,
+ (const void *)req_addr->data,
+ host_buf,
+ sizeof (host_buf));
+ } else if (req_addr->length == 16) {
+ host = inet_ntop (AF_INET6,
+ (const void *)req_addr->data,
+ host_buf,
+ sizeof (host_buf));
+ }
+
+ if (host == NULL) {
+ g_warning (_("Bad address"));
+ return FALSE;
+ }
+
+ memset (&hints, 0, sizeof (hints));
+ hints.ai_family = family;
+ hints.ai_flags = AI_V4MAPPED; /* this should convert IPv4 address to IPv6 if needed */
+ if ((gaierr = getaddrinfo (host, serv, &hints, &ai_list)) != 0) {
+ g_warning ("Unable get address: %s", gai_strerror (gaierr));
+ return FALSE;
+ }
+
+ /* just take the first one */
+ ai = ai_list;
+
+ found = FALSE;
+ if (ai != NULL) {
+ found = TRUE;
+ if (address != NULL) {
+ *address = gdm_address_new_from_sockaddr_storage ((struct sockaddr_storage *)ai->ai_addr);
+ }
+ }
+
+ freeaddrinfo (ai_list);
+
+ return found;
}
static void
gdm_xdmcp_whack_queued_managed_forwards (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
- GdmAddress *origin)
+ GdmAddress *address,
+ GdmAddress *origin)
{
- GSList *li;
+ GSList *li;
- for (li = factory->priv->managed_forwards; li != NULL; li = li->next) {
- ManagedForward *mf = li->data;
+ for (li = factory->priv->managed_forwards; li != NULL; li = li->next) {
+ ManagedForward *mf = li->data;
- if (gdm_address_equal (mf->manager, address) &&
- gdm_address_equal (mf->origin, origin)) {
- factory->priv->managed_forwards = g_slist_remove_link (factory->priv->managed_forwards, li);
- g_slist_free_1 (li);
- g_source_remove (mf->handler);
- /* mf freed by glib */
- return;
- }
- }
+ if (gdm_address_equal (mf->manager, address) &&
+ gdm_address_equal (mf->origin, origin)) {
+ factory->priv->managed_forwards = g_slist_remove_link (factory->priv->managed_forwards, li);
+ g_slist_free_1 (li);
+ g_source_remove (mf->handler);
+ /* mf freed by glib */
+ return;
+ }
+ }
}
static void
gdm_xdmcp_handle_forward_query (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
- int len)
-{
- ARRAY8 clnt_addr;
- ARRAY8 clnt_port;
- ARRAYofARRAY8 clnt_authlist;
- int i;
- int explen;
- GdmAddress *disp_address;
- char *host;
- char *serv;
-
- disp_address = NULL;
-
- /* Check with tcp_wrappers if client is allowed to access */
- if (! gdm_xdmcp_host_allow (address)) {
- char *host;
-
- host = NULL;
- gdm_address_get_numeric_info (address, &host, NULL);
-
- g_warning ("%s: Got FORWARD_QUERY from banned host %s",
- "gdm_xdmcp_handle_forward query",
- host);
- g_free (host);
- return;
- }
-
- /* Read display address */
- if G_UNLIKELY (! XdmcpReadARRAY8 (&factory->priv->buf, &clnt_addr)) {
- g_warning (_("%s: Could not read display address"),
- "gdm_xdmcp_handle_forward_query");
- return;
- }
-
- /* Read display port */
- if G_UNLIKELY (! XdmcpReadARRAY8 (&factory->priv->buf, &clnt_port)) {
- XdmcpDisposeARRAY8 (&clnt_addr);
- g_warning (_("%s: Could not read display port number"),
- "gdm_xdmcp_handle_forward_query");
- return;
- }
-
- /* Extract array of authentication names from Xdmcp packet */
- if G_UNLIKELY (! XdmcpReadARRAYofARRAY8 (&factory->priv->buf, &clnt_authlist)) {
- XdmcpDisposeARRAY8 (&clnt_addr);
- XdmcpDisposeARRAY8 (&clnt_port);
- g_warning (_("%s: Could not extract authlist from packet"),
- "gdm_xdmcp_handle_forward_query");
- return;
- }
-
- /* Crude checksumming */
- explen = 1;
- explen += 2 + clnt_addr.length;
- explen += 2 + clnt_port.length;
-
- for (i = 0 ; i < clnt_authlist.length ; i++) {
- char *s = g_strndup ((char *) clnt_authlist.data[i].data,
- clnt_authlist.length);
- g_debug ("gdm_xdmcp_handle_forward_query: authlist: %s", s);
- g_free (s);
-
- explen += 2 + clnt_authlist.data[i].length;
- }
-
- if G_UNLIKELY (len != explen) {
- g_warning (_("%s: Error in checksum"),
- "gdm_xdmcp_handle_forward_query");
- goto out;
- }
-
- if (! create_address_from_request (&clnt_addr, &clnt_port, gdm_address_get_family_type (address), &disp_address)) {
- g_warning ("Unable to parse address for request");
- goto out;
- }
-
- gdm_xdmcp_whack_queued_managed_forwards (factory,
- address,
- disp_address);
-
- host = NULL;
- serv = NULL;
- gdm_address_get_numeric_info (disp_address, &host, &serv);
- g_debug ("gdm_xdmcp_handle_forward_query: Got FORWARD_QUERY for display: %s, port %s",
- host, serv);
- g_free (host);
- g_free (serv);
-
- /* Check with tcp_wrappers if display is allowed to access */
- if (gdm_xdmcp_host_allow (disp_address)) {
- GdmForwardQuery *q;
-
- q = gdm_forward_query_lookup (factory, disp_address);
- if (q != NULL) {
- gdm_forward_query_dispose (factory, q);
- }
-
- gdm_forward_query_alloc (factory, address, disp_address);
-
- gdm_xdmcp_send_willing (factory, disp_address);
- }
+ GdmAddress *address,
+ int len)
+{
+ ARRAY8 clnt_addr;
+ ARRAY8 clnt_port;
+ ARRAYofARRAY8 clnt_authlist;
+ int i;
+ int explen;
+ GdmAddress *disp_address;
+ char *host;
+ char *serv;
+
+ disp_address = NULL;
+
+ /* Check with tcp_wrappers if client is allowed to access */
+ if (! gdm_xdmcp_host_allow (address)) {
+ char *host;
+
+ host = NULL;
+ gdm_address_get_numeric_info (address, &host, NULL);
+
+ g_warning ("%s: Got FORWARD_QUERY from banned host %s",
+ "gdm_xdmcp_handle_forward query",
+ host);
+ g_free (host);
+ return;
+ }
+
+ /* Read display address */
+ if G_UNLIKELY (! XdmcpReadARRAY8 (&factory->priv->buf, &clnt_addr)) {
+ g_warning (_("%s: Could not read display address"),
+ "gdm_xdmcp_handle_forward_query");
+ return;
+ }
+
+ /* Read display port */
+ if G_UNLIKELY (! XdmcpReadARRAY8 (&factory->priv->buf, &clnt_port)) {
+ XdmcpDisposeARRAY8 (&clnt_addr);
+ g_warning (_("%s: Could not read display port number"),
+ "gdm_xdmcp_handle_forward_query");
+ return;
+ }
+
+ /* Extract array of authentication names from Xdmcp packet */
+ if G_UNLIKELY (! XdmcpReadARRAYofARRAY8 (&factory->priv->buf, &clnt_authlist)) {
+ XdmcpDisposeARRAY8 (&clnt_addr);
+ XdmcpDisposeARRAY8 (&clnt_port);
+ g_warning (_("%s: Could not extract authlist from packet"),
+ "gdm_xdmcp_handle_forward_query");
+ return;
+ }
+
+ /* Crude checksumming */
+ explen = 1;
+ explen += 2 + clnt_addr.length;
+ explen += 2 + clnt_port.length;
+
+ for (i = 0 ; i < clnt_authlist.length ; i++) {
+ char *s = g_strndup ((char *) clnt_authlist.data[i].data,
+ clnt_authlist.length);
+ g_debug ("gdm_xdmcp_handle_forward_query: authlist: %s", s);
+ g_free (s);
+
+ explen += 2 + clnt_authlist.data[i].length;
+ }
+
+ if G_UNLIKELY (len != explen) {
+ g_warning (_("%s: Error in checksum"),
+ "gdm_xdmcp_handle_forward_query");
+ goto out;
+ }
+
+ if (! create_address_from_request (&clnt_addr, &clnt_port, gdm_address_get_family_type (address), &disp_address)) {
+ g_warning ("Unable to parse address for request");
+ goto out;
+ }
+
+ gdm_xdmcp_whack_queued_managed_forwards (factory,
+ address,
+ disp_address);
+
+ host = NULL;
+ serv = NULL;
+ gdm_address_get_numeric_info (disp_address, &host, &serv);
+ g_debug ("gdm_xdmcp_handle_forward_query: Got FORWARD_QUERY for display: %s, port %s",
+ host, serv);
+ g_free (host);
+ g_free (serv);
+
+ /* Check with tcp_wrappers if display is allowed to access */
+ if (gdm_xdmcp_host_allow (disp_address)) {
+ GdmForwardQuery *q;
+
+ q = gdm_forward_query_lookup (factory, disp_address);
+ if (q != NULL) {
+ gdm_forward_query_dispose (factory, q);
+ }
+
+ gdm_forward_query_alloc (factory, address, disp_address);
+
+ gdm_xdmcp_send_willing (factory, disp_address);
+ }
out:
- gdm_address_free (disp_address);
+ gdm_address_free (disp_address);
- XdmcpDisposeARRAYofARRAY8 (&clnt_authlist);
- XdmcpDisposeARRAY8 (&clnt_port);
- XdmcpDisposeARRAY8 (&clnt_addr);
+ XdmcpDisposeARRAYofARRAY8 (&clnt_authlist);
+ XdmcpDisposeARRAY8 (&clnt_port);
+ XdmcpDisposeARRAY8 (&clnt_addr);
}
static void
gdm_xdmcp_really_send_managed_forward (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
- GdmAddress *origin)
+ GdmAddress *address,
+ GdmAddress *origin)
{
- ARRAY8 addr;
- XdmcpHeader header;
- char *host;
+ ARRAY8 addr;
+ XdmcpHeader header;
+ char *host;
- host = NULL;
- gdm_address_get_numeric_info (address, &host, NULL);
- g_debug ("XDMCP: Sending MANAGED_FORWARD to %s", host);
- g_free (host);
+ host = NULL;
+ gdm_address_get_numeric_info (address, &host, NULL);
+ g_debug ("XDMCP: Sending MANAGED_FORWARD to %s", host);
+ g_free (host);
- set_address_for_request (origin, &addr);
+ set_address_for_request (origin, &addr);
- header.opcode = (CARD16) GDM_XDMCP_MANAGED_FORWARD;
- header.length = 4 + addr.length;
- header.version = GDM_XDMCP_PROTOCOL_VERSION;
- XdmcpWriteHeader (&factory->priv->buf, &header);
+ header.opcode = (CARD16) GDM_XDMCP_MANAGED_FORWARD;
+ header.length = 4 + addr.length;
+ header.version = GDM_XDMCP_PROTOCOL_VERSION;
+ XdmcpWriteHeader (&factory->priv->buf, &header);
- XdmcpWriteARRAY8 (&factory->priv->buf, &addr);
- XdmcpFlush (factory->priv->socket_fd,
- &factory->priv->buf,
- (XdmcpNetaddr)gdm_address_peek_sockaddr_storage (address),
- (int)sizeof (struct sockaddr_storage));
+ XdmcpWriteARRAY8 (&factory->priv->buf, &addr);
+ XdmcpFlush (factory->priv->socket_fd,
+ &factory->priv->buf,
+ (XdmcpNetaddr)gdm_address_peek_sockaddr_storage (address),
+ (int)sizeof (struct sockaddr_storage));
- g_free (addr.data);
+ g_free (addr.data);
}
static gboolean
managed_forward_handler (ManagedForward *mf)
{
- if (mf->xdmcp_display_factory->priv->socket_fd > 0) {
- gdm_xdmcp_really_send_managed_forward (mf->xdmcp_display_factory,
- mf->manager,
- mf->origin);
- }
+ if (mf->xdmcp_display_factory->priv->socket_fd > 0) {
+ gdm_xdmcp_really_send_managed_forward (mf->xdmcp_display_factory,
+ mf->manager,
+ mf->origin);
+ }
- mf->times++;
- if (mf->xdmcp_display_factory->priv->socket_fd <= 0 || mf->times >= 2) {
- mf->xdmcp_display_factory->priv->managed_forwards = g_slist_remove (mf->xdmcp_display_factory->priv->managed_forwards, mf);
- mf->handler = 0;
- /* mf freed by glib */
- return FALSE;
- }
- return TRUE;
+ mf->times++;
+ if (mf->xdmcp_display_factory->priv->socket_fd <= 0 || mf->times >= 2) {
+ mf->xdmcp_display_factory->priv->managed_forwards = g_slist_remove (mf->xdmcp_display_factory->priv->managed_forwards, mf);
+ mf->handler = 0;
+ /* mf freed by glib */
+ return FALSE;
+ }
+ return TRUE;
}
static void
managed_forward_free (ManagedForward *mf)
{
- gdm_address_free (mf->origin);
- gdm_address_free (mf->manager);
- g_free (mf);
+ gdm_address_free (mf->origin);
+ gdm_address_free (mf->manager);
+ g_free (mf);
}
static void
gdm_xdmcp_send_managed_forward (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
- GdmAddress *origin)
+ GdmAddress *address,
+ GdmAddress *origin)
{
- ManagedForward *mf;
+ ManagedForward *mf;
- gdm_xdmcp_really_send_managed_forward (factory, address, origin);
+ gdm_xdmcp_really_send_managed_forward (factory, address, origin);
- mf = g_new0 (ManagedForward, 1);
- mf->times = 0;
- mf->xdmcp_display_factory = factory;
+ mf = g_new0 (ManagedForward, 1);
+ mf->times = 0;
+ mf->xdmcp_display_factory = factory;
- mf->manager = gdm_address_copy (address);
- mf->origin = gdm_address_copy (origin);
+ mf->manager = gdm_address_copy (address);
+ mf->origin = gdm_address_copy (origin);
- mf->handler = g_timeout_add_full (G_PRIORITY_DEFAULT,
- MANAGED_FORWARD_INTERVAL,
- (GSourceFunc)managed_forward_handler,
- mf,
- (GDestroyNotify)managed_forward_free);
- factory->priv->managed_forwards = g_slist_prepend (factory->priv->managed_forwards, mf);
+ mf->handler = g_timeout_add_full (G_PRIORITY_DEFAULT,
+ MANAGED_FORWARD_INTERVAL,
+ (GSourceFunc)managed_forward_handler,
+ mf,
+ (GDestroyNotify)managed_forward_free);
+ factory->priv->managed_forwards = g_slist_prepend (factory->priv->managed_forwards, mf);
}
static void
gdm_xdmcp_send_got_managed_forward (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
- GdmAddress *origin)
+ GdmAddress *address,
+ GdmAddress *origin)
{
- ARRAY8 addr;
- XdmcpHeader header;
- char *host;
+ ARRAY8 addr;
+ XdmcpHeader header;
+ char *host;
- host = NULL;
- gdm_address_get_numeric_info (address, &host, NULL);
- g_debug ("XDMCP: Sending GOT_MANAGED_FORWARD to %s", host);
- g_free (host);
+ host = NULL;
+ gdm_address_get_numeric_info (address, &host, NULL);
+ g_debug ("XDMCP: Sending GOT_MANAGED_FORWARD to %s", host);
+ g_free (host);
- set_address_for_request (origin, &addr);
+ set_address_for_request (origin, &addr);
- header.opcode = (CARD16) GDM_XDMCP_GOT_MANAGED_FORWARD;
- header.length = 4 + addr.length;
- header.version = GDM_XDMCP_PROTOCOL_VERSION;
- XdmcpWriteHeader (&factory->priv->buf, &header);
+ header.opcode = (CARD16) GDM_XDMCP_GOT_MANAGED_FORWARD;
+ header.length = 4 + addr.length;
+ header.version = GDM_XDMCP_PROTOCOL_VERSION;
+ XdmcpWriteHeader (&factory->priv->buf, &header);
- XdmcpWriteARRAY8 (&factory->priv->buf, &addr);
- XdmcpFlush (factory->priv->socket_fd,
- &factory->priv->buf,
- (XdmcpNetaddr)gdm_address_peek_sockaddr_storage (address),
- (int)sizeof (struct sockaddr_storage));
+ XdmcpWriteARRAY8 (&factory->priv->buf, &addr);
+ XdmcpFlush (factory->priv->socket_fd,
+ &factory->priv->buf,
+ (XdmcpNetaddr)gdm_address_peek_sockaddr_storage (address),
+ (int)sizeof (struct sockaddr_storage));
}
static gboolean
count_sessions (const char *id,
- GdmDisplay *display,
- GdmXdmcpDisplayFactory *factory)
+ GdmDisplay *display,
+ GdmXdmcpDisplayFactory *factory)
{
- if (GDM_IS_XDMCP_DISPLAY (display)) {
- int status;
+ if (GDM_IS_XDMCP_DISPLAY (display)) {
+ int status;
- status = gdm_display_get_status (display);
+ status = gdm_display_get_status (display);
- if (status == GDM_DISPLAY_MANAGED) {
- factory->priv->num_sessions++;
- } else if (status == GDM_DISPLAY_UNMANAGED) {
- factory->priv->num_pending_sessions++;
- }
- }
+ if (status == GDM_DISPLAY_MANAGED) {
+ factory->priv->num_sessions++;
+ } else if (status == GDM_DISPLAY_UNMANAGED) {
+ factory->priv->num_pending_sessions++;
+ }
+ }
- return TRUE;
+ return TRUE;
}
static void
gdm_xdmcp_recount_sessions (GdmXdmcpDisplayFactory *factory)
{
- GdmDisplayStore *store;
+ GdmDisplayStore *store;
- factory->priv->num_sessions = 0;
- factory->priv->num_pending_sessions = 0;
+ factory->priv->num_sessions = 0;
+ factory->priv->num_pending_sessions = 0;
- store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
- gdm_display_store_foreach (store,
- (GdmDisplayStoreFunc)count_sessions,
- factory);
+ store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
+ gdm_display_store_foreach (store,
+ (GdmDisplayStoreFunc)count_sessions,
+ factory);
}
static gboolean
purge_displays (const char *id,
- GdmDisplay *display,
- GdmXdmcpDisplayFactory *factory)
+ GdmDisplay *display,
+ GdmXdmcpDisplayFactory *factory)
{
- if (GDM_IS_XDMCP_DISPLAY (display)) {
- int status;
- time_t currtime;
- time_t acctime;
+ if (GDM_IS_XDMCP_DISPLAY (display)) {
+ int status;
+ time_t currtime;
+ time_t acctime;
- currtime = time (NULL);
- status = gdm_display_get_status (display);
- acctime = gdm_display_get_creation_time (display);
+ currtime = time (NULL);
+ status = gdm_display_get_status (display);
+ acctime = gdm_display_get_creation_time (display);
- if (status == GDM_DISPLAY_UNMANAGED &&
- currtime > acctime + factory->priv->max_wait) {
- /* return TRUE to remove display */
- return TRUE;
- }
- }
+ if (status == GDM_DISPLAY_UNMANAGED &&
+ currtime > acctime + factory->priv->max_wait) {
+ /* return TRUE to remove display */
+ return TRUE;
+ }
+ }
- return FALSE;
+ return FALSE;
}
static void
gdm_xdmcp_displays_purge (GdmXdmcpDisplayFactory *factory)
{
- GdmDisplayStore *store;
+ GdmDisplayStore *store;
- store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
+ store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
- gdm_display_store_foreach_remove (store,
- (GdmDisplayStoreFunc)purge_displays,
- factory);
+ gdm_display_store_foreach_remove (store,
+ (GdmDisplayStoreFunc)purge_displays,
+ factory);
- gdm_xdmcp_recount_sessions (factory);
+ gdm_xdmcp_recount_sessions (factory);
}
typedef struct {
- const char *hostname;
- int display_num;
+ const char *hostname;
+ int display_num;
} RemoveHostData;
static gboolean
remove_host (const char *id,
- GdmDisplay *display,
- RemoveHostData *data)
+ GdmDisplay *display,
+ RemoveHostData *data)
{
- char *hostname;
- int disp_num;
+ char *hostname;
+ int disp_num;
- if (! GDM_IS_XDMCP_DISPLAY (display)) {
- return FALSE;
- }
+ if (! GDM_IS_XDMCP_DISPLAY (display)) {
+ return FALSE;
+ }
- gdm_display_get_remote_hostname (display, &hostname, NULL);
- gdm_display_get_x11_display_number (display, &disp_num, NULL);
+ gdm_display_get_remote_hostname (display, &hostname, NULL);
+ gdm_display_get_x11_display_number (display, &disp_num, NULL);
- if (disp_num == data->display_num &&
- hostname != NULL &&
- data->hostname != NULL &&
- strcmp (hostname, data->hostname) == 0) {
- /* return TRUE to remove */
- return TRUE;
- }
+ if (disp_num == data->display_num &&
+ hostname != NULL &&
+ data->hostname != NULL &&
+ strcmp (hostname, data->hostname) == 0) {
+ /* return TRUE to remove */
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
static void
display_dispose_check (GdmXdmcpDisplayFactory *factory,
- const char *hostname,
- int display_num)
+ const char *hostname,
+ int display_num)
{
- RemoveHostData *data;
- GdmDisplayStore *store;
+ RemoveHostData *data;
+ GdmDisplayStore *store;
- if (hostname == NULL) {
- return;
- }
+ if (hostname == NULL) {
+ return;
+ }
- store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
+ store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
- g_debug ("display_dispose_check (%s:%d)", hostname, display_num);
+ g_debug ("display_dispose_check (%s:%d)", hostname, display_num);
- data = g_new0 (RemoveHostData, 1);
- data->hostname = hostname;
- data->display_num = display_num;
- gdm_display_store_foreach_remove (store,
- (GdmDisplayStoreFunc)remove_host,
- data);
- g_free (data);
+ data = g_new0 (RemoveHostData, 1);
+ data->hostname = hostname;
+ data->display_num = display_num;
+ gdm_display_store_foreach_remove (store,
+ (GdmDisplayStoreFunc)remove_host,
+ data);
+ g_free (data);
- gdm_xdmcp_recount_sessions (factory);
+ gdm_xdmcp_recount_sessions (factory);
}
static void
gdm_xdmcp_send_decline (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
- const char *reason)
-{
- XdmcpHeader header;
- ARRAY8 authentype;
- ARRAY8 authendata;
- ARRAY8 status;
- GdmForwardQuery *fq;
- char *host;
-
- host = NULL;
- gdm_address_get_numeric_info (address, &host, NULL);
- g_debug ("XMDCP: Sending DECLINE to %s", host);
- g_free (host);
-
- authentype.data = (CARD8 *) 0;
- authentype.length = (CARD16) 0;
-
- authendata.data = (CARD8 *) 0;
- authendata.length = (CARD16) 0;
-
- status.data = (CARD8 *) reason;
- status.length = strlen ((char *) status.data);
-
- header.version = XDM_PROTOCOL_VERSION;
- header.opcode = (CARD16) DECLINE;
- header.length = 2 + status.length;
- header.length += 2 + authentype.length;
- header.length += 2 + authendata.length;
-
- XdmcpWriteHeader (&factory->priv->buf, &header);
- XdmcpWriteARRAY8 (&factory->priv->buf, &status);
- XdmcpWriteARRAY8 (&factory->priv->buf, &authentype);
- XdmcpWriteARRAY8 (&factory->priv->buf, &authendata);
-
- XdmcpFlush (factory->priv->socket_fd,
- &factory->priv->buf,
- (XdmcpNetaddr)gdm_address_peek_sockaddr_storage (address),
- (int)sizeof (struct sockaddr_storage));
-
- /* Send MANAGED_FORWARD to indicate that the connection
- * reached some sort of resolution */
- fq = gdm_forward_query_lookup (factory, address);
- if (fq != NULL) {
- gdm_xdmcp_send_managed_forward (factory, fq->from_address, address);
- gdm_forward_query_dispose (factory, fq);
- }
+ GdmAddress *address,
+ const char *reason)
+{
+ XdmcpHeader header;
+ ARRAY8 authentype;
+ ARRAY8 authendata;
+ ARRAY8 status;
+ GdmForwardQuery *fq;
+ char *host;
+
+ host = NULL;
+ gdm_address_get_numeric_info (address, &host, NULL);
+ g_debug ("XMDCP: Sending DECLINE to %s", host);
+ g_free (host);
+
+ authentype.data = (CARD8 *) 0;
+ authentype.length = (CARD16) 0;
+
+ authendata.data = (CARD8 *) 0;
+ authendata.length = (CARD16) 0;
+
+ status.data = (CARD8 *) reason;
+ status.length = strlen ((char *) status.data);
+
+ header.version = XDM_PROTOCOL_VERSION;
+ header.opcode = (CARD16) DECLINE;
+ header.length = 2 + status.length;
+ header.length += 2 + authentype.length;
+ header.length += 2 + authendata.length;
+
+ XdmcpWriteHeader (&factory->priv->buf, &header);
+ XdmcpWriteARRAY8 (&factory->priv->buf, &status);
+ XdmcpWriteARRAY8 (&factory->priv->buf, &authentype);
+ XdmcpWriteARRAY8 (&factory->priv->buf, &authendata);
+
+ XdmcpFlush (factory->priv->socket_fd,
+ &factory->priv->buf,
+ (XdmcpNetaddr)gdm_address_peek_sockaddr_storage (address),
+ (int)sizeof (struct sockaddr_storage));
+
+ /* Send MANAGED_FORWARD to indicate that the connection
+ * reached some sort of resolution */
+ fq = gdm_forward_query_lookup (factory, address);
+ if (fq != NULL) {
+ gdm_xdmcp_send_managed_forward (factory, fq->from_address, address);
+ gdm_forward_query_dispose (factory, fq);
+ }
}
static GdmDisplay *
gdm_xdmcp_display_alloc (GdmXdmcpDisplayFactory *factory,
- const char *hostname,
- GdmAddress *address,
- int displaynum)
+ const char *hostname,
+ GdmAddress *address,
+ int displaynum)
{
- GdmDisplay *display;
- GdmDisplayStore *store;
+ GdmDisplay *display;
+ GdmDisplayStore *store;
- g_debug ("Creating xdmcp display for %s:%d", hostname, displaynum);
+ g_debug ("Creating xdmcp display for %s:%d", hostname, displaynum);
- display = gdm_xdmcp_display_new (hostname,
- displaynum,
- address,
- get_next_session_serial (factory));
- if (display == NULL) {
- goto out;
- }
+ display = gdm_xdmcp_display_new (hostname,
+ displaynum,
+ address,
+ get_next_session_serial (factory));
+ if (display == NULL) {
+ goto out;
+ }
- if (! gdm_display_create_authority (display)) {
- g_object_unref (display);
- display = NULL;
- goto out;
- }
+ if (! gdm_display_create_authority (display)) {
+ g_object_unref (display);
+ display = NULL;
+ goto out;
+ }
- store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
- gdm_display_store_add (store, display);
+ store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
+ gdm_display_store_add (store, display);
- factory->priv->num_pending_sessions++;
+ factory->priv->num_pending_sessions++;
out:
- return display;
+ return display;
}
static void
gdm_xdmcp_send_accept (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
- CARD32 session_id,
- ARRAY8Ptr authentication_name,
- ARRAY8Ptr authentication_data,
- ARRAY8Ptr authorization_name,
- ARRAY8Ptr authorization_data)
-{
- XdmcpHeader header;
- char *host;
-
- header.version = XDM_PROTOCOL_VERSION;
- header.opcode = (CARD16) ACCEPT;
- header.length = 4;
- header.length += 2 + authentication_name->length;
- header.length += 2 + authentication_data->length;
- header.length += 2 + authorization_name->length;
- header.length += 2 + authorization_data->length;
-
- XdmcpWriteHeader (&factory->priv->buf, &header);
- XdmcpWriteCARD32 (&factory->priv->buf, session_id);
- XdmcpWriteARRAY8 (&factory->priv->buf, authentication_name);
- XdmcpWriteARRAY8 (&factory->priv->buf, authentication_data);
- XdmcpWriteARRAY8 (&factory->priv->buf, authorization_name);
- XdmcpWriteARRAY8 (&factory->priv->buf, authorization_data);
-
- XdmcpFlush (factory->priv->socket_fd,
- &factory->priv->buf,
- (XdmcpNetaddr)gdm_address_peek_sockaddr_storage (address),
- (int)sizeof (struct sockaddr_storage));
-
- host = NULL;
- gdm_address_get_numeric_info (address, &host, NULL);
- g_debug ("XDMCP: Sending ACCEPT to %s with SessionID=%ld",
- host,
- (long)session_id);
- g_free (host);
+ GdmAddress *address,
+ CARD32 session_id,
+ ARRAY8Ptr authentication_name,
+ ARRAY8Ptr authentication_data,
+ ARRAY8Ptr authorization_name,
+ ARRAY8Ptr authorization_data)
+{
+ XdmcpHeader header;
+ char *host;
+
+ header.version = XDM_PROTOCOL_VERSION;
+ header.opcode = (CARD16) ACCEPT;
+ header.length = 4;
+ header.length += 2 + authentication_name->length;
+ header.length += 2 + authentication_data->length;
+ header.length += 2 + authorization_name->length;
+ header.length += 2 + authorization_data->length;
+
+ XdmcpWriteHeader (&factory->priv->buf, &header);
+ XdmcpWriteCARD32 (&factory->priv->buf, session_id);
+ XdmcpWriteARRAY8 (&factory->priv->buf, authentication_name);
+ XdmcpWriteARRAY8 (&factory->priv->buf, authentication_data);
+ XdmcpWriteARRAY8 (&factory->priv->buf, authorization_name);
+ XdmcpWriteARRAY8 (&factory->priv->buf, authorization_data);
+
+ XdmcpFlush (factory->priv->socket_fd,
+ &factory->priv->buf,
+ (XdmcpNetaddr)gdm_address_peek_sockaddr_storage (address),
+ (int)sizeof (struct sockaddr_storage));
+
+ host = NULL;
+ gdm_address_get_numeric_info (address, &host, NULL);
+ g_debug ("XDMCP: Sending ACCEPT to %s with SessionID=%ld",
+ host,
+ (long)session_id);
+ g_free (host);
}
static void
gdm_xdmcp_handle_request (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
- int len)
-{
- CARD16 clnt_dspnum;
- ARRAY16 clnt_conntyp;
- ARRAYofARRAY8 clnt_addr;
- ARRAY8 clnt_authname;
- ARRAY8 clnt_authdata;
- ARRAYofARRAY8 clnt_authorization_names;
- ARRAY8 clnt_manufacturer;
- int explen;
- int i;
- gboolean mitauth;
- gboolean entered;
- char *hostname;
-
- mitauth = FALSE;
- entered = FALSE;
-
- hostname = NULL;
- gdm_address_get_numeric_info (address, &hostname, NULL);
- g_debug ("gdm_xdmcp_handle_request: Got REQUEST from %s", hostname);
-
- /* Check with tcp_wrappers if client is allowed to access */
- if (! gdm_xdmcp_host_allow (address)) {
- g_warning (_("%s: Got REQUEST from banned host %s"),
- "gdm_xdmcp_handle_request",
- hostname);
- goto out;
- }
-
- gdm_xdmcp_displays_purge (factory); /* Purge pending displays */
-
- /* Remote display number */
- if G_UNLIKELY (! XdmcpReadCARD16 (&factory->priv->buf, &clnt_dspnum)) {
- g_warning (_("%s: Could not read Display Number"),
- "gdm_xdmcp_handle_request");
- goto out;
- }
-
- /* We don't care about connection type. Address says it all */
- if G_UNLIKELY (! XdmcpReadARRAY16 (&factory->priv->buf, &clnt_conntyp)) {
- g_warning (_("%s: Could not read Connection Type"),
- "gdm_xdmcp_handle_request");
- goto out;
- }
-
- /* This is TCP/IP - we don't care */
- if G_UNLIKELY (! XdmcpReadARRAYofARRAY8 (&factory->priv->buf, &clnt_addr)) {
- g_warning (_("%s: Could not read Client Address"),
- "gdm_xdmcp_handle_request");
- XdmcpDisposeARRAY16 (&clnt_conntyp);
- goto out;
- }
-
- /* Read authentication type */
- if G_UNLIKELY (! XdmcpReadARRAY8 (&factory->priv->buf, &clnt_authname)) {
- g_warning (_("%s: Could not read Authentication Names"),
- "gdm_xdmcp_handle_request");
- XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
- XdmcpDisposeARRAY16 (&clnt_conntyp);
- goto out;
- }
-
- /* Read authentication data */
- if G_UNLIKELY (! XdmcpReadARRAY8 (&factory->priv->buf, &clnt_authdata)) {
- g_warning (_("%s: Could not read Authentication Data"),
- "gdm_xdmcp_handle_request");
- XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
- XdmcpDisposeARRAY16 (&clnt_conntyp);
- XdmcpDisposeARRAY8 (&clnt_authname);
- goto out;
- }
-
- /* Read and select from supported authorization list */
- if G_UNLIKELY (! XdmcpReadARRAYofARRAY8 (&factory->priv->buf, &clnt_authorization_names)) {
- g_warning (_("%s: Could not read Authorization List"),
- "gdm_xdmcp_handle_request");
- XdmcpDisposeARRAY8 (&clnt_authdata);
- XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
- XdmcpDisposeARRAY16 (&clnt_conntyp);
- XdmcpDisposeARRAY8 (&clnt_authname);
- goto out;
- }
-
- /* libXdmcp doesn't terminate strings properly so we cheat and use strncmp () */
- for (i = 0 ; i < clnt_authorization_names.length ; i++) {
- if (clnt_authorization_names.data[i].length == 18 &&
- strncmp ((char *) clnt_authorization_names.data[i].data, "MIT-MAGIC-COOKIE-1", 18) == 0) {
- mitauth = TRUE;
- }
- }
-
- /* Manufacturer ID */
- if G_UNLIKELY (! XdmcpReadARRAY8 (&factory->priv->buf, &clnt_manufacturer)) {
- g_warning (_("%s: Could not read Manufacturer ID"),
- "gdm_xdmcp_handle_request");
- XdmcpDisposeARRAY8 (&clnt_authname);
- XdmcpDisposeARRAY8 (&clnt_authdata);
- XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
- XdmcpDisposeARRAYofARRAY8 (&clnt_authorization_names);
- XdmcpDisposeARRAY16 (&clnt_conntyp);
- goto out;
- }
-
- /* Crude checksumming */
- explen = 2; /* Display Number */
- explen += 1 + 2 * clnt_conntyp.length; /* Connection Type */
- explen += 1; /* Connection Address */
- for (i = 0 ; i < clnt_addr.length ; i++) {
- explen += 2 + clnt_addr.data[i].length;
- }
- explen += 2 + clnt_authname.length; /* Authentication Name */
- explen += 2 + clnt_authdata.length; /* Authentication Data */
- explen += 1; /* Authorization Names */
- for (i = 0 ; i < clnt_authorization_names.length ; i++) {
- explen += 2 + clnt_authorization_names.data[i].length;
- }
-
- explen += 2 + clnt_manufacturer.length;
-
- if G_UNLIKELY (explen != len) {
- g_warning (_("%s: Failed checksum from %s"),
- "gdm_xdmcp_handle_request",
- hostname);
-
- XdmcpDisposeARRAY8 (&clnt_authname);
- XdmcpDisposeARRAY8 (&clnt_authdata);
- XdmcpDisposeARRAY8 (&clnt_manufacturer);
- XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
- XdmcpDisposeARRAYofARRAY8 (&clnt_authorization_names);
- XdmcpDisposeARRAY16 (&clnt_conntyp);
- goto out;
- }
-
- {
- char *s = g_strndup ((char *) clnt_manufacturer.data, clnt_manufacturer.length);
- g_debug ("gdm_xdmcp_handle_request: xdmcp_pending=%d, MaxPending=%d, xdmcp_sessions=%d, MaxSessions=%d, ManufacturerID=%s",
- factory->priv->num_pending_sessions,
- factory->priv->max_pending_displays,
- factory->priv->num_sessions,
- factory->priv->max_displays,
- ve_sure_string (s));
- g_free (s);
- }
-
- /* Check if ok to manage display */
- if (mitauth &&
- factory->priv->num_sessions < factory->priv->max_displays &&
- (gdm_address_is_local (address) ||
- gdm_xdmcp_num_displays_from_host (factory, address) < factory->priv->max_displays_per_host)) {
- entered = TRUE;
- }
-
- if (entered) {
-
- /* Check if we are already talking to this host */
- display_dispose_check (factory, hostname, clnt_dspnum);
-
- if (factory->priv->num_pending_sessions >= factory->priv->max_pending_displays) {
- g_debug ("gdm_xdmcp_handle_request: maximum pending");
- /* Don't translate, this goes over the wire to servers where we
- * don't know the charset or language, so it must be ascii */
- gdm_xdmcp_send_decline (factory, address, "Maximum pending servers");
- } else {
- GdmDisplay *display;
-
- display = gdm_xdmcp_display_alloc (factory,
- hostname,
- address,
- clnt_dspnum);
-
- if (display != NULL) {
- ARRAY8 authentication_name;
- ARRAY8 authentication_data;
- ARRAY8 authorization_name;
- ARRAY8 authorization_data;
- gint32 session_number;
- char *x11_cookie;
- GString *cookie;
- GString *binary_cookie;
- GString *test_cookie;
-
- gdm_display_get_x11_cookie (display, &x11_cookie, NULL);
- cookie = g_string_new (x11_cookie);
- g_free (x11_cookie);
-
- binary_cookie = g_string_new (NULL);
-
- if (! gdm_string_hex_decode (cookie,
- 0,
- NULL,
- binary_cookie,
- 0)) {
- g_warning ("Unable to decode hex cookie");
- /* FIXME: handle error */
- }
-
- test_cookie = g_string_new (NULL);
- if (! gdm_string_hex_encode (binary_cookie,
- 0,
- test_cookie,
- 0)) {
- g_warning ("Unable to encode hex cookie");
- /* FIXME: handle error */
- }
-
- /* sanity check cookie */
- g_debug ("Reencoded cookie len:%d '%s'", test_cookie->len, test_cookie->str);
- g_assert (test_cookie->len == cookie->len);
- g_assert (strcmp (test_cookie->str, cookie->str) == 0);
- g_string_free (test_cookie, TRUE);
-
- g_debug ("Sending authorization key for display %s", cookie->str);
- g_debug ("Decoded cookie len %d", binary_cookie->len);
-
- session_number = gdm_xdmcp_display_get_session_number (GDM_XDMCP_DISPLAY (display));
-
- /* the send accept will fail if cookie is null */
- g_assert (binary_cookie != NULL);
-
- authentication_name.data = NULL;
- authentication_name.length = 0;
- authentication_data.data = NULL;
- authentication_data.length = 0;
-
- authorization_name.data = (CARD8 *) "MIT-MAGIC-COOKIE-1";
- authorization_name.length = strlen ((char *) authorization_name.data);
-
- authorization_data.data = (CARD8 *) binary_cookie->str;
- authorization_data.length = binary_cookie->len;
-
- /* the addrs are NOT copied */
- gdm_xdmcp_send_accept (factory,
- address,
- session_number,
- &authentication_name,
- &authentication_data,
- &authorization_name,
- &authorization_data);
-
- g_string_free (binary_cookie, TRUE);
- g_string_free (cookie, TRUE);
- }
- }
- } else {
- /* Don't translate, this goes over the wire to servers where we
- * don't know the charset or language, so it must be ascii */
- if ( ! mitauth) {
- gdm_xdmcp_send_decline (factory,
- address,
- "Only MIT-MAGIC-COOKIE-1 supported");
- } else if (factory->priv->num_sessions >= factory->priv->max_displays) {
- g_warning ("Maximum number of open XDMCP sessions reached");
- gdm_xdmcp_send_decline (factory,
- address,
- "Maximum number of open sessions reached");
- } else {
- g_debug ("Maximum number of open XDMCP sessions from host %s reached",
- hostname);
- gdm_xdmcp_send_decline (factory,
- address,
- "Maximum number of open sessions from your host reached");
- }
- }
-
- XdmcpDisposeARRAY8 (&clnt_authname);
- XdmcpDisposeARRAY8 (&clnt_authdata);
- XdmcpDisposeARRAY8 (&clnt_manufacturer);
- XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
- XdmcpDisposeARRAYofARRAY8 (&clnt_authorization_names);
- XdmcpDisposeARRAY16 (&clnt_conntyp);
+ GdmAddress *address,
+ int len)
+{
+ CARD16 clnt_dspnum;
+ ARRAY16 clnt_conntyp;
+ ARRAYofARRAY8 clnt_addr;
+ ARRAY8 clnt_authname;
+ ARRAY8 clnt_authdata;
+ ARRAYofARRAY8 clnt_authorization_names;
+ ARRAY8 clnt_manufacturer;
+ int explen;
+ int i;
+ gboolean mitauth;
+ gboolean entered;
+ char *hostname;
+
+ mitauth = FALSE;
+ entered = FALSE;
+
+ hostname = NULL;
+ gdm_address_get_numeric_info (address, &hostname, NULL);
+ g_debug ("gdm_xdmcp_handle_request: Got REQUEST from %s", hostname);
+
+ /* Check with tcp_wrappers if client is allowed to access */
+ if (! gdm_xdmcp_host_allow (address)) {
+ g_warning (_("%s: Got REQUEST from banned host %s"),
+ "gdm_xdmcp_handle_request",
+ hostname);
+ goto out;
+ }
+
+ gdm_xdmcp_displays_purge (factory); /* Purge pending displays */
+
+ /* Remote display number */
+ if G_UNLIKELY (! XdmcpReadCARD16 (&factory->priv->buf, &clnt_dspnum)) {
+ g_warning (_("%s: Could not read Display Number"),
+ "gdm_xdmcp_handle_request");
+ goto out;
+ }
+
+ /* We don't care about connection type. Address says it all */
+ if G_UNLIKELY (! XdmcpReadARRAY16 (&factory->priv->buf, &clnt_conntyp)) {
+ g_warning (_("%s: Could not read Connection Type"),
+ "gdm_xdmcp_handle_request");
+ goto out;
+ }
+
+ /* This is TCP/IP - we don't care */
+ if G_UNLIKELY (! XdmcpReadARRAYofARRAY8 (&factory->priv->buf, &clnt_addr)) {
+ g_warning (_("%s: Could not read Client Address"),
+ "gdm_xdmcp_handle_request");
+ XdmcpDisposeARRAY16 (&clnt_conntyp);
+ goto out;
+ }
+
+ /* Read authentication type */
+ if G_UNLIKELY (! XdmcpReadARRAY8 (&factory->priv->buf, &clnt_authname)) {
+ g_warning (_("%s: Could not read Authentication Names"),
+ "gdm_xdmcp_handle_request");
+ XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
+ XdmcpDisposeARRAY16 (&clnt_conntyp);
+ goto out;
+ }
+
+ /* Read authentication data */
+ if G_UNLIKELY (! XdmcpReadARRAY8 (&factory->priv->buf, &clnt_authdata)) {
+ g_warning (_("%s: Could not read Authentication Data"),
+ "gdm_xdmcp_handle_request");
+ XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
+ XdmcpDisposeARRAY16 (&clnt_conntyp);
+ XdmcpDisposeARRAY8 (&clnt_authname);
+ goto out;
+ }
+
+ /* Read and select from supported authorization list */
+ if G_UNLIKELY (! XdmcpReadARRAYofARRAY8 (&factory->priv->buf, &clnt_authorization_names)) {
+ g_warning (_("%s: Could not read Authorization List"),
+ "gdm_xdmcp_handle_request");
+ XdmcpDisposeARRAY8 (&clnt_authdata);
+ XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
+ XdmcpDisposeARRAY16 (&clnt_conntyp);
+ XdmcpDisposeARRAY8 (&clnt_authname);
+ goto out;
+ }
+
+ /* libXdmcp doesn't terminate strings properly so we cheat and use strncmp () */
+ for (i = 0 ; i < clnt_authorization_names.length ; i++) {
+ if (clnt_authorization_names.data[i].length == 18 &&
+ strncmp ((char *) clnt_authorization_names.data[i].data, "MIT-MAGIC-COOKIE-1", 18) == 0) {
+ mitauth = TRUE;
+ }
+ }
+
+ /* Manufacturer ID */
+ if G_UNLIKELY (! XdmcpReadARRAY8 (&factory->priv->buf, &clnt_manufacturer)) {
+ g_warning (_("%s: Could not read Manufacturer ID"),
+ "gdm_xdmcp_handle_request");
+ XdmcpDisposeARRAY8 (&clnt_authname);
+ XdmcpDisposeARRAY8 (&clnt_authdata);
+ XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
+ XdmcpDisposeARRAYofARRAY8 (&clnt_authorization_names);
+ XdmcpDisposeARRAY16 (&clnt_conntyp);
+ goto out;
+ }
+
+ /* Crude checksumming */
+ explen = 2; /* Display Number */
+ explen += 1 + 2 * clnt_conntyp.length; /* Connection Type */
+ explen += 1; /* Connection Address */
+ for (i = 0 ; i < clnt_addr.length ; i++) {
+ explen += 2 + clnt_addr.data[i].length;
+ }
+ explen += 2 + clnt_authname.length; /* Authentication Name */
+ explen += 2 + clnt_authdata.length; /* Authentication Data */
+ explen += 1; /* Authorization Names */
+ for (i = 0 ; i < clnt_authorization_names.length ; i++) {
+ explen += 2 + clnt_authorization_names.data[i].length;
+ }
+
+ explen += 2 + clnt_manufacturer.length;
+
+ if G_UNLIKELY (explen != len) {
+ g_warning (_("%s: Failed checksum from %s"),
+ "gdm_xdmcp_handle_request",
+ hostname);
+
+ XdmcpDisposeARRAY8 (&clnt_authname);
+ XdmcpDisposeARRAY8 (&clnt_authdata);
+ XdmcpDisposeARRAY8 (&clnt_manufacturer);
+ XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
+ XdmcpDisposeARRAYofARRAY8 (&clnt_authorization_names);
+ XdmcpDisposeARRAY16 (&clnt_conntyp);
+ goto out;
+ }
+
+ {
+ char *s = g_strndup ((char *) clnt_manufacturer.data, clnt_manufacturer.length);
+ g_debug ("gdm_xdmcp_handle_request: xdmcp_pending=%d, MaxPending=%d, xdmcp_sessions=%d, MaxSessions=%d, ManufacturerID=%s",
+ factory->priv->num_pending_sessions,
+ factory->priv->max_pending_displays,
+ factory->priv->num_sessions,
+ factory->priv->max_displays,
+ ve_sure_string (s));
+ g_free (s);
+ }
+
+ /* Check if ok to manage display */
+ if (mitauth &&
+ factory->priv->num_sessions < factory->priv->max_displays &&
+ (gdm_address_is_local (address) ||
+ gdm_xdmcp_num_displays_from_host (factory, address) < factory->priv->max_displays_per_host)) {
+ entered = TRUE;
+ }
+
+ if (entered) {
+
+ /* Check if we are already talking to this host */
+ display_dispose_check (factory, hostname, clnt_dspnum);
+
+ if (factory->priv->num_pending_sessions >= factory->priv->max_pending_displays) {
+ g_debug ("gdm_xdmcp_handle_request: maximum pending");
+ /* Don't translate, this goes over the wire to servers where we
+ * don't know the charset or language, so it must be ascii */
+ gdm_xdmcp_send_decline (factory, address, "Maximum pending servers");
+ } else {
+ GdmDisplay *display;
+
+ display = gdm_xdmcp_display_alloc (factory,
+ hostname,
+ address,
+ clnt_dspnum);
+
+ if (display != NULL) {
+ ARRAY8 authentication_name;
+ ARRAY8 authentication_data;
+ ARRAY8 authorization_name;
+ ARRAY8 authorization_data;
+ gint32 session_number;
+ char *x11_cookie;
+ GString *cookie;
+ GString *binary_cookie;
+ GString *test_cookie;
+
+ gdm_display_get_x11_cookie (display, &x11_cookie, NULL);
+ cookie = g_string_new (x11_cookie);
+ g_free (x11_cookie);
+
+ binary_cookie = g_string_new (NULL);
+
+ if (! gdm_string_hex_decode (cookie,
+ 0,
+ NULL,
+ binary_cookie,
+ 0)) {
+ g_warning ("Unable to decode hex cookie");
+ /* FIXME: handle error */
+ }
+
+ test_cookie = g_string_new (NULL);
+ if (! gdm_string_hex_encode (binary_cookie,
+ 0,
+ test_cookie,
+ 0)) {
+ g_warning ("Unable to encode hex cookie");
+ /* FIXME: handle error */
+ }
+
+ /* sanity check cookie */
+ g_debug ("Reencoded cookie len:%d '%s'", test_cookie->len, test_cookie->str);
+ g_assert (test_cookie->len == cookie->len);
+ g_assert (strcmp (test_cookie->str, cookie->str) == 0);
+ g_string_free (test_cookie, TRUE);
+
+ g_debug ("Sending authorization key for display %s", cookie->str);
+ g_debug ("Decoded cookie len %d", binary_cookie->len);
+
+ session_number = gdm_xdmcp_display_get_session_number (GDM_XDMCP_DISPLAY (display));
+
+ /* the send accept will fail if cookie is null */
+ g_assert (binary_cookie != NULL);
+
+ authentication_name.data = NULL;
+ authentication_name.length = 0;
+ authentication_data.data = NULL;
+ authentication_data.length = 0;
+
+ authorization_name.data = (CARD8 *) "MIT-MAGIC-COOKIE-1";
+ authorization_name.length = strlen ((char *) authorization_name.data);
+
+ authorization_data.data = (CARD8 *) binary_cookie->str;
+ authorization_data.length = binary_cookie->len;
+
+ /* the addrs are NOT copied */
+ gdm_xdmcp_send_accept (factory,
+ address,
+ session_number,
+ &authentication_name,
+ &authentication_data,
+ &authorization_name,
+ &authorization_data);
+
+ g_string_free (binary_cookie, TRUE);
+ g_string_free (cookie, TRUE);
+ }
+ }
+ } else {
+ /* Don't translate, this goes over the wire to servers where we
+ * don't know the charset or language, so it must be ascii */
+ if ( ! mitauth) {
+ gdm_xdmcp_send_decline (factory,
+ address,
+ "Only MIT-MAGIC-COOKIE-1 supported");
+ } else if (factory->priv->num_sessions >= factory->priv->max_displays) {
+ g_warning ("Maximum number of open XDMCP sessions reached");
+ gdm_xdmcp_send_decline (factory,
+ address,
+ "Maximum number of open sessions reached");
+ } else {
+ g_debug ("Maximum number of open XDMCP sessions from host %s reached",
+ hostname);
+ gdm_xdmcp_send_decline (factory,
+ address,
+ "Maximum number of open sessions from your host reached");
+ }
+ }
+
+ XdmcpDisposeARRAY8 (&clnt_authname);
+ XdmcpDisposeARRAY8 (&clnt_authdata);
+ XdmcpDisposeARRAY8 (&clnt_manufacturer);
+ XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
+ XdmcpDisposeARRAYofARRAY8 (&clnt_authorization_names);
+ XdmcpDisposeARRAY16 (&clnt_conntyp);
out:
- g_free (hostname);
+ g_free (hostname);
}
static gboolean
lookup_by_session_id (const char *id,
- GdmDisplay *display,
- gpointer data)
+ GdmDisplay *display,
+ gpointer data)
{
- CARD32 sessid;
- CARD32 session_id;
+ CARD32 sessid;
+ CARD32 session_id;
- sessid = GPOINTER_TO_INT (data);
+ sessid = GPOINTER_TO_INT (data);
- if (! GDM_IS_XDMCP_DISPLAY (display)) {
- return FALSE;
- }
+ if (! GDM_IS_XDMCP_DISPLAY (display)) {
+ return FALSE;
+ }
- session_id = gdm_xdmcp_display_get_session_number (GDM_XDMCP_DISPLAY (display));
+ session_id = gdm_xdmcp_display_get_session_number (GDM_XDMCP_DISPLAY (display));
- if (session_id == sessid) {
- return TRUE;
- }
+ if (session_id == sessid) {
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
static GdmDisplay *
gdm_xdmcp_display_lookup (GdmXdmcpDisplayFactory *factory,
- CARD32 sessid)
+ CARD32 sessid)
{
- GdmDisplay *display;
- GdmDisplayStore *store;
+ GdmDisplay *display;
+ GdmDisplayStore *store;
- if (sessid == 0) {
- return NULL;
- }
+ if (sessid == 0) {
+ return NULL;
+ }
- store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
- display = gdm_display_store_find (store,
- (GdmDisplayStoreFunc)lookup_by_session_id,
- GINT_TO_POINTER (sessid));
+ store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
+ display = gdm_display_store_find (store,
+ (GdmDisplayStoreFunc)lookup_by_session_id,
+ GINT_TO_POINTER (sessid));
- return display;
+ return display;
}
static void
gdm_xdmcp_send_failed (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
- CARD32 sessid)
+ GdmAddress *address,
+ CARD32 sessid)
{
- XdmcpHeader header;
- ARRAY8 status;
+ XdmcpHeader header;
+ ARRAY8 status;
- g_debug ("XDMCP: Sending FAILED to %ld", (long)sessid);
+ g_debug ("XDMCP: Sending FAILED to %ld", (long)sessid);
- /*
- * Don't translate, this goes over the wire to servers where we
- * don't know the charset or language, so it must be ascii
- */
- status.data = (CARD8 *) "Failed to start session";
- status.length = strlen ((char *) status.data);
+ /*
+ * Don't translate, this goes over the wire to servers where we
+ * don't know the charset or language, so it must be ascii
+ */
+ status.data = (CARD8 *) "Failed to start session";
+ status.length = strlen ((char *) status.data);
- header.version = XDM_PROTOCOL_VERSION;
- header.opcode = (CARD16) FAILED;
- header.length = 6+status.length;
+ header.version = XDM_PROTOCOL_VERSION;
+ header.opcode = (CARD16) FAILED;
+ header.length = 6+status.length;
- XdmcpWriteHeader (&factory->priv->buf, &header);
- XdmcpWriteCARD32 (&factory->priv->buf, sessid);
- XdmcpWriteARRAY8 (&factory->priv->buf, &status);
+ XdmcpWriteHeader (&factory->priv->buf, &header);
+ XdmcpWriteCARD32 (&factory->priv->buf, sessid);
+ XdmcpWriteARRAY8 (&factory->priv->buf, &status);
- XdmcpFlush (factory->priv->socket_fd,
- &factory->priv->buf,
- (XdmcpNetaddr)gdm_address_peek_sockaddr_storage (address),
- (int)sizeof (struct sockaddr_storage));
+ XdmcpFlush (factory->priv->socket_fd,
+ &factory->priv->buf,
+ (XdmcpNetaddr)gdm_address_peek_sockaddr_storage (address),
+ (int)sizeof (struct sockaddr_storage));
}
static void
gdm_xdmcp_send_refuse (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
- CARD32 sessid)
+ GdmAddress *address,
+ CARD32 sessid)
{
- XdmcpHeader header;
- GdmForwardQuery *fq;
+ XdmcpHeader header;
+ GdmForwardQuery *fq;
- g_debug ("XDMCP: Sending REFUSE to %ld",
- (long)sessid);
+ g_debug ("XDMCP: Sending REFUSE to %ld",
+ (long)sessid);
- header.version = XDM_PROTOCOL_VERSION;
- header.opcode = (CARD16) REFUSE;
- header.length = 4;
+ header.version = XDM_PROTOCOL_VERSION;
+ header.opcode = (CARD16) REFUSE;
+ header.length = 4;
- XdmcpWriteHeader (&factory->priv->buf, &header);
- XdmcpWriteCARD32 (&factory->priv->buf, sessid);
+ XdmcpWriteHeader (&factory->priv->buf, &header);
+ XdmcpWriteCARD32 (&factory->priv->buf, sessid);
- XdmcpFlush (factory->priv->socket_fd,
- &factory->priv->buf,
- (XdmcpNetaddr)gdm_address_peek_sockaddr_storage (address),
- (int)sizeof (struct sockaddr_storage));
+ XdmcpFlush (factory->priv->socket_fd,
+ &factory->priv->buf,
+ (XdmcpNetaddr)gdm_address_peek_sockaddr_storage (address),
+ (int)sizeof (struct sockaddr_storage));
- /*
- * This was from a forwarded query quite apparently so
- * send MANAGED_FORWARD
- */
- fq = gdm_forward_query_lookup (factory, address);
- if (fq != NULL) {
- gdm_xdmcp_send_managed_forward (factory, fq->from_address, address);
- gdm_forward_query_dispose (factory, fq);
- }
+ /*
+ * This was from a forwarded query quite apparently so
+ * send MANAGED_FORWARD
+ */
+ fq = gdm_forward_query_lookup (factory, address);
+ if (fq != NULL) {
+ gdm_xdmcp_send_managed_forward (factory, fq->from_address, address);
+ gdm_forward_query_dispose (factory, fq);
+ }
}
static void
gdm_xdmcp_handle_manage (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
- int len)
-{
- CARD32 clnt_sessid;
- CARD16 clnt_dspnum;
- ARRAY8 clnt_dspclass;
- GdmDisplay *display;
- GdmForwardQuery *fq;
- char *host;
-
- host = NULL;
- gdm_address_get_numeric_info (address, &host, NULL);
- g_debug ("gdm_xdmcp_handle_manage: Got MANAGE from %s", host);
-
- /* Check with tcp_wrappers if client is allowed to access */
- if (! gdm_xdmcp_host_allow (address)) {
- g_warning (_("%s: Got Manage from banned host %s"),
- "gdm_xdmcp_handle_manage",
- host);
- g_free (host);
- return;
- }
-
- /* SessionID */
- if G_UNLIKELY (! XdmcpReadCARD32 (&factory->priv->buf, &clnt_sessid)) {
- g_warning (_("%s: Could not read Session ID"),
- "gdm_xdmcp_handle_manage");
- goto out;
- }
-
- /* Remote display number */
- if G_UNLIKELY (! XdmcpReadCARD16 (&factory->priv->buf, &clnt_dspnum)) {
- g_warning (_("%s: Could not read Display Number"),
- "gdm_xdmcp_handle_manage");
- goto out;
- }
-
- /* Display Class */
- if G_UNLIKELY (! XdmcpReadARRAY8 (&factory->priv->buf, &clnt_dspclass)) {
- g_warning (_("%s: Could not read Display Class"),
- "gdm_xdmcp_handle_manage");
- goto out;
- }
-
- {
- char *s = g_strndup ((char *) clnt_dspclass.data, clnt_dspclass.length);
- g_debug ("gdm_xdmcp-handle_manage: Got display=%d, SessionID=%ld Class=%s from %s",
- (int)clnt_dspnum,
- (long)clnt_sessid,
- ve_sure_string (s),
- host);
-
- g_free (s);
- }
-
- display = gdm_xdmcp_display_lookup (factory, clnt_sessid);
- if (display != NULL &&
- gdm_display_get_status (display) == GDM_DISPLAY_UNMANAGED) {
- char *name;
-
- name = NULL;
- gdm_display_get_x11_display_name (display, &name, NULL);
- g_debug ("gdm_xdmcp_handle_manage: Looked up %s", name);
- g_free (name);
+ GdmAddress *address,
+ int len)
+{
+ CARD32 clnt_sessid;
+ CARD16 clnt_dspnum;
+ ARRAY8 clnt_dspclass;
+ GdmDisplay *display;
+ GdmForwardQuery *fq;
+ char *host;
+
+ host = NULL;
+ gdm_address_get_numeric_info (address, &host, NULL);
+ g_debug ("gdm_xdmcp_handle_manage: Got MANAGE from %s", host);
+
+ /* Check with tcp_wrappers if client is allowed to access */
+ if (! gdm_xdmcp_host_allow (address)) {
+ g_warning (_("%s: Got Manage from banned host %s"),
+ "gdm_xdmcp_handle_manage",
+ host);
+ g_free (host);
+ return;
+ }
+
+ /* SessionID */
+ if G_UNLIKELY (! XdmcpReadCARD32 (&factory->priv->buf, &clnt_sessid)) {
+ g_warning (_("%s: Could not read Session ID"),
+ "gdm_xdmcp_handle_manage");
+ goto out;
+ }
+
+ /* Remote display number */
+ if G_UNLIKELY (! XdmcpReadCARD16 (&factory->priv->buf, &clnt_dspnum)) {
+ g_warning (_("%s: Could not read Display Number"),
+ "gdm_xdmcp_handle_manage");
+ goto out;
+ }
+
+ /* Display Class */
+ if G_UNLIKELY (! XdmcpReadARRAY8 (&factory->priv->buf, &clnt_dspclass)) {
+ g_warning (_("%s: Could not read Display Class"),
+ "gdm_xdmcp_handle_manage");
+ goto out;
+ }
+
+ {
+ char *s = g_strndup ((char *) clnt_dspclass.data, clnt_dspclass.length);
+ g_debug ("gdm_xdmcp-handle_manage: Got display=%d, SessionID=%ld Class=%s from %s",
+ (int)clnt_dspnum,
+ (long)clnt_sessid,
+ ve_sure_string (s),
+ host);
+
+ g_free (s);
+ }
+
+ display = gdm_xdmcp_display_lookup (factory, clnt_sessid);
+ if (display != NULL &&
+ gdm_display_get_status (display) == GDM_DISPLAY_UNMANAGED) {
+ char *name;
+
+ name = NULL;
+ gdm_display_get_x11_display_name (display, &name, NULL);
+ g_debug ("gdm_xdmcp_handle_manage: Looked up %s", name);
+ g_free (name);
#if 0 /* FIXME: */
- if (factory->priv->honor_indirect) {
- GdmIndirectDisplay *id;
-
- id = gdm_choose_indirect_lookup (address);
-
- /* This was an indirect thingie and nothing was yet chosen,
- * use a chooser */
- if (id != NULL &&
- id->chosen_host == NULL) {
- d->use_chooser = TRUE;
- d->indirect_id = id->id;
- } else {
- d->indirect_id = 0;
- d->use_chooser = FALSE;
- if (id != NULL) {
- gdm_choose_indirect_dispose (id);
- }
- }
- } else {
-
- }
+ if (factory->priv->honor_indirect) {
+ GdmIndirectDisplay *id;
+
+ id = gdm_choose_indirect_lookup (address);
+
+ /* This was an indirect thingie and nothing was yet chosen,
+ * use a chooser */
+ if (id != NULL &&
+ id->chosen_host == NULL) {
+ d->use_chooser = TRUE;
+ d->indirect_id = id->id;
+ } else {
+ d->indirect_id = 0;
+ d->use_chooser = FALSE;
+ if (id != NULL) {
+ gdm_choose_indirect_dispose (id);
+ }
+ }
+ } else {
+
+ }
#endif
- /* this was from a forwarded query quite apparently so
- * send MANAGED_FORWARD */
- fq = gdm_forward_query_lookup (factory, address);
- if (fq != NULL) {
- gdm_xdmcp_send_managed_forward (factory, fq->from_address, address);
- gdm_forward_query_dispose (factory, fq);
- }
-
- factory->priv->num_sessions++;
- factory->priv->num_pending_sessions--;
-
- /* Start greeter/session */
- if (! gdm_display_manage (display)) {
- gdm_xdmcp_send_failed (factory, address, clnt_sessid);
- g_debug ("Failed to manage display");
- }
- } else if (display != NULL &&
- gdm_display_get_status (display) == GDM_DISPLAY_MANAGED) {
- g_debug ("gdm_xdmcp_handle_manage: Session id %ld already managed",
- (long)clnt_sessid);
- } else {
- g_warning ("gdm_xdmcp_handle_manage: Failed to look up session id %ld",
- (long)clnt_sessid);
- gdm_xdmcp_send_refuse (factory, address, clnt_sessid);
- }
+ /* this was from a forwarded query quite apparently so
+ * send MANAGED_FORWARD */
+ fq = gdm_forward_query_lookup (factory, address);
+ if (fq != NULL) {
+ gdm_xdmcp_send_managed_forward (factory, fq->from_address, address);
+ gdm_forward_query_dispose (factory, fq);
+ }
+
+ factory->priv->num_sessions++;
+ factory->priv->num_pending_sessions--;
+
+ /* Start greeter/session */
+ if (! gdm_display_manage (display)) {
+ gdm_xdmcp_send_failed (factory, address, clnt_sessid);
+ g_debug ("Failed to manage display");
+ }
+ } else if (display != NULL &&
+ gdm_display_get_status (display) == GDM_DISPLAY_MANAGED) {
+ g_debug ("gdm_xdmcp_handle_manage: Session id %ld already managed",
+ (long)clnt_sessid);
+ } else {
+ g_warning ("gdm_xdmcp_handle_manage: Failed to look up session id %ld",
+ (long)clnt_sessid);
+ gdm_xdmcp_send_refuse (factory, address, clnt_sessid);
+ }
out:
- XdmcpDisposeARRAY8 (&clnt_dspclass);
- g_free (host);
+ XdmcpDisposeARRAY8 (&clnt_dspclass);
+ g_free (host);
}
static void
gdm_xdmcp_handle_managed_forward (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
- int len)
-{
- ARRAY8 clnt_address;
- GdmIndirectDisplay *id;
- char *host;
- GdmAddress *disp_address;
-
- host = NULL;
- gdm_address_get_numeric_info (address, &host, NULL);
- g_debug ("gdm_xdmcp_handle_managed_forward: Got MANAGED_FORWARD from %s",
- host);
-
- /* Check with tcp_wrappers if client is allowed to access */
- if (! gdm_xdmcp_host_allow (address)) {
- g_warning ("%s: Got MANAGED_FORWARD from banned host %s",
- "gdm_xdmcp_handle_request", host);
- g_free (host);
- return;
- }
- g_free (host);
-
- /* Hostname */
- if G_UNLIKELY ( ! XdmcpReadARRAY8 (&factory->priv->buf, &clnt_address)) {
- g_warning (_("%s: Could not read address"),
- "gdm_xdmcp_handle_managed_forward");
- return;
- }
-
- disp_address = NULL;
- if (! create_address_from_request (&clnt_address, NULL, gdm_address_get_family_type (address), &disp_address)) {
- g_warning ("Unable to parse address for request");
- XdmcpDisposeARRAY8 (&clnt_address);
- return;
- }
-
- id = gdm_choose_indirect_lookup_by_chosen (address, disp_address);
- if (id != NULL) {
- gdm_choose_indirect_dispose (id);
- }
-
- /* Note: we send GOT even on not found, just in case our previous
- * didn't get through and this was a second managed forward */
- gdm_xdmcp_send_got_managed_forward (factory, address, disp_address);
-
- gdm_address_free (disp_address);
-
- XdmcpDisposeARRAY8 (&clnt_address);
+ GdmAddress *address,
+ int len)
+{
+ ARRAY8 clnt_address;
+ GdmIndirectDisplay *id;
+ char *host;
+ GdmAddress *disp_address;
+
+ host = NULL;
+ gdm_address_get_numeric_info (address, &host, NULL);
+ g_debug ("gdm_xdmcp_handle_managed_forward: Got MANAGED_FORWARD from %s",
+ host);
+
+ /* Check with tcp_wrappers if client is allowed to access */
+ if (! gdm_xdmcp_host_allow (address)) {
+ g_warning ("%s: Got MANAGED_FORWARD from banned host %s",
+ "gdm_xdmcp_handle_request", host);
+ g_free (host);
+ return;
+ }
+ g_free (host);
+
+ /* Hostname */
+ if G_UNLIKELY ( ! XdmcpReadARRAY8 (&factory->priv->buf, &clnt_address)) {
+ g_warning (_("%s: Could not read address"),
+ "gdm_xdmcp_handle_managed_forward");
+ return;
+ }
+
+ disp_address = NULL;
+ if (! create_address_from_request (&clnt_address, NULL, gdm_address_get_family_type (address), &disp_address)) {
+ g_warning ("Unable to parse address for request");
+ XdmcpDisposeARRAY8 (&clnt_address);
+ return;
+ }
+
+ id = gdm_choose_indirect_lookup_by_chosen (address, disp_address);
+ if (id != NULL) {
+ gdm_choose_indirect_dispose (id);
+ }
+
+ /* Note: we send GOT even on not found, just in case our previous
+ * didn't get through and this was a second managed forward */
+ gdm_xdmcp_send_got_managed_forward (factory, address, disp_address);
+
+ gdm_address_free (disp_address);
+
+ XdmcpDisposeARRAY8 (&clnt_address);
}
static void
gdm_xdmcp_handle_got_managed_forward (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
- int len)
+ GdmAddress *address,
+ int len)
{
- GdmAddress *disp_address;
- ARRAY8 clnt_address;
- char *host;
+ GdmAddress *disp_address;
+ ARRAY8 clnt_address;
+ char *host;
- host = NULL;
- gdm_address_get_numeric_info (address, &host, NULL);
- g_debug ("gdm_xdmcp_handle_got_managed_forward: Got MANAGED_FORWARD from %s",
- host);
+ host = NULL;
+ gdm_address_get_numeric_info (address, &host, NULL);
+ g_debug ("gdm_xdmcp_handle_got_managed_forward: Got MANAGED_FORWARD from %s",
+ host);
- if (! gdm_xdmcp_host_allow (address)) {
- g_warning ("%s: Got GOT_MANAGED_FORWARD from banned host %s",
- "gdm_xdmcp_handle_request", host);
- g_free (host);
- return;
- }
- g_free (host);
+ if (! gdm_xdmcp_host_allow (address)) {
+ g_warning ("%s: Got GOT_MANAGED_FORWARD from banned host %s",
+ "gdm_xdmcp_handle_request", host);
+ g_free (host);
+ return;
+ }
+ g_free (host);
- /* Hostname */
- if G_UNLIKELY ( ! XdmcpReadARRAY8 (&factory->priv->buf, &clnt_address)) {
- g_warning (_("%s: Could not read address"),
- "gdm_xdmcp_handle_got_managed_forward");
- return;
- }
+ /* Hostname */
+ if G_UNLIKELY ( ! XdmcpReadARRAY8 (&factory->priv->buf, &clnt_address)) {
+ g_warning (_("%s: Could not read address"),
+ "gdm_xdmcp_handle_got_managed_forward");
+ return;
+ }
- if (! create_address_from_request (&clnt_address, NULL, gdm_address_get_family_type (address), &disp_address)) {
- g_warning (_("%s: Could not read address"),
- "gdm_xdmcp_handle_got_managed_forward");
- XdmcpDisposeARRAY8 (&clnt_address);
- return;
- }
+ if (! create_address_from_request (&clnt_address, NULL, gdm_address_get_family_type (address), &disp_address)) {
+ g_warning (_("%s: Could not read address"),
+ "gdm_xdmcp_handle_got_managed_forward");
+ XdmcpDisposeARRAY8 (&clnt_address);
+ return;
+ }
- gdm_xdmcp_whack_queued_managed_forwards (factory, address, disp_address);
+ gdm_xdmcp_whack_queued_managed_forwards (factory, address, disp_address);
- gdm_address_free (disp_address);
+ gdm_address_free (disp_address);
- XdmcpDisposeARRAY8 (&clnt_address);
+ XdmcpDisposeARRAY8 (&clnt_address);
}
static void
gdm_xdmcp_send_alive (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
+ GdmAddress *address,
CARD16 dspnum,
- CARD32 sessid)
+ CARD32 sessid)
{
- XdmcpHeader header;
- GdmDisplay *display;
- int send_running = 0;
- CARD32 send_sessid = 0;
+ XdmcpHeader header;
+ GdmDisplay *display;
+ int send_running = 0;
+ CARD32 send_sessid = 0;
- display = gdm_xdmcp_display_lookup (factory, sessid);
- if (display == NULL) {
- display = gdm_xdmcp_display_lookup_by_host (factory, address, dspnum);
- }
+ display = gdm_xdmcp_display_lookup (factory, sessid);
+ if (display == NULL) {
+ display = gdm_xdmcp_display_lookup_by_host (factory, address, dspnum);
+ }
- if (display != NULL) {
- int status;
+ if (display != NULL) {
+ int status;
- send_sessid = gdm_xdmcp_display_get_session_number (GDM_XDMCP_DISPLAY (display));
- status = gdm_display_get_status (display);
+ send_sessid = gdm_xdmcp_display_get_session_number (GDM_XDMCP_DISPLAY (display));
+ status = gdm_display_get_status (display);
- if (status == GDM_DISPLAY_MANAGED) {
- send_running = 1;
- }
- }
+ if (status == GDM_DISPLAY_MANAGED) {
+ send_running = 1;
+ }
+ }
- g_debug ("XDMCP: Sending ALIVE to %ld (running %d, sessid %ld)",
- (long)sessid,
- send_running,
- (long)send_sessid);
+ g_debug ("XDMCP: Sending ALIVE to %ld (running %d, sessid %ld)",
+ (long)sessid,
+ send_running,
+ (long)send_sessid);
- header.version = XDM_PROTOCOL_VERSION;
- header.opcode = (CARD16) ALIVE;
- header.length = 5;
+ header.version = XDM_PROTOCOL_VERSION;
+ header.opcode = (CARD16) ALIVE;
+ header.length = 5;
- XdmcpWriteHeader (&factory->priv->buf, &header);
- XdmcpWriteCARD8 (&factory->priv->buf, send_running);
- XdmcpWriteCARD32 (&factory->priv->buf, send_sessid);
+ XdmcpWriteHeader (&factory->priv->buf, &header);
+ XdmcpWriteCARD8 (&factory->priv->buf, send_running);
+ XdmcpWriteCARD32 (&factory->priv->buf, send_sessid);
- XdmcpFlush (factory->priv->socket_fd,
- &factory->priv->buf,
- (XdmcpNetaddr)gdm_address_peek_sockaddr_storage (address),
- (int)sizeof (struct sockaddr_storage));
+ XdmcpFlush (factory->priv->socket_fd,
+ &factory->priv->buf,
+ (XdmcpNetaddr)gdm_address_peek_sockaddr_storage (address),
+ (int)sizeof (struct sockaddr_storage));
}
static void
gdm_xdmcp_handle_keepalive (GdmXdmcpDisplayFactory *factory,
- GdmAddress *address,
- int len)
-{
- CARD16 clnt_dspnum;
- CARD32 clnt_sessid;
- char *host;
-
- host = NULL;
- gdm_address_get_numeric_info (address, &host, NULL);
- g_debug ("XDMCP: Got KEEPALIVE from %s", host);
-
- /* Check with tcp_wrappers if client is allowed to access */
- if (! gdm_xdmcp_host_allow (address)) {
- g_warning (_("%s: Got KEEPALIVE from banned host %s"),
- "gdm_xdmcp_handle_keepalive",
- host);
- g_free (host);
- return;
- }
- g_free (host);
-
- /* Remote display number */
- if G_UNLIKELY (! XdmcpReadCARD16 (&factory->priv->buf, &clnt_dspnum)) {
- g_warning (_("%s: Could not read Display Number"),
- "gdm_xdmcp_handle_keepalive");
- return;
- }
-
- /* SessionID */
- if G_UNLIKELY (! XdmcpReadCARD32 (&factory->priv->buf, &clnt_sessid)) {
- g_warning (_("%s: Could not read Session ID"),
- "gdm_xdmcp_handle_keepalive");
- return;
- }
-
- gdm_xdmcp_send_alive (factory, address, clnt_dspnum, clnt_sessid);
+ GdmAddress *address,
+ int len)
+{
+ CARD16 clnt_dspnum;
+ CARD32 clnt_sessid;
+ char *host;
+
+ host = NULL;
+ gdm_address_get_numeric_info (address, &host, NULL);
+ g_debug ("XDMCP: Got KEEPALIVE from %s", host);
+
+ /* Check with tcp_wrappers if client is allowed to access */
+ if (! gdm_xdmcp_host_allow (address)) {
+ g_warning (_("%s: Got KEEPALIVE from banned host %s"),
+ "gdm_xdmcp_handle_keepalive",
+ host);
+ g_free (host);
+ return;
+ }
+ g_free (host);
+
+ /* Remote display number */
+ if G_UNLIKELY (! XdmcpReadCARD16 (&factory->priv->buf, &clnt_dspnum)) {
+ g_warning (_("%s: Could not read Display Number"),
+ "gdm_xdmcp_handle_keepalive");
+ return;
+ }
+
+ /* SessionID */
+ if G_UNLIKELY (! XdmcpReadCARD32 (&factory->priv->buf, &clnt_sessid)) {
+ g_warning (_("%s: Could not read Session ID"),
+ "gdm_xdmcp_handle_keepalive");
+ return;
+ }
+
+ gdm_xdmcp_send_alive (factory, address, clnt_dspnum, clnt_sessid);
}
static const char *
opcode_string (int opcode)
{
- static const char * const opcode_names[] = {
- NULL,
- "BROADCAST_QUERY",
- "QUERY",
- "INDIRECT_QUERY",
- "FORWARD_QUERY",
- "WILLING",
- "UNWILLING",
- "REQUEST",
- "ACCEPT",
- "DECLINE",
- "MANAGE",
- "REFUSE",
- "FAILED",
- "KEEPALIVE",
- "ALIVE"
- };
- static const char * const gdm_opcode_names[] = {
- "MANAGED_FORWARD",
- "GOT_MANAGED_FORWARD"
- };
-
-
- if (opcode < G_N_ELEMENTS (opcode_names)) {
- return opcode_names [opcode];
- } else if (opcode >= GDM_XDMCP_FIRST_OPCODE &&
- opcode < GDM_XDMCP_LAST_OPCODE) {
- return gdm_opcode_names [opcode - GDM_XDMCP_FIRST_OPCODE];
- } else {
- return "UNKNOWN";
- }
+ static const char * const opcode_names[] = {
+ NULL,
+ "BROADCAST_QUERY",
+ "QUERY",
+ "INDIRECT_QUERY",
+ "FORWARD_QUERY",
+ "WILLING",
+ "UNWILLING",
+ "REQUEST",
+ "ACCEPT",
+ "DECLINE",
+ "MANAGE",
+ "REFUSE",
+ "FAILED",
+ "KEEPALIVE",
+ "ALIVE"
+ };
+ static const char * const gdm_opcode_names[] = {
+ "MANAGED_FORWARD",
+ "GOT_MANAGED_FORWARD"
+ };
+
+
+ if (opcode < G_N_ELEMENTS (opcode_names)) {
+ return opcode_names [opcode];
+ } else if (opcode >= GDM_XDMCP_FIRST_OPCODE &&
+ opcode < GDM_XDMCP_LAST_OPCODE) {
+ return gdm_opcode_names [opcode - GDM_XDMCP_FIRST_OPCODE];
+ } else {
+ return "UNKNOWN";
+ }
}
static gboolean
decode_packet (GIOChannel *source,
- GIOCondition cond,
- GdmXdmcpDisplayFactory *factory)
-{
- struct sockaddr_storage clnt_ss;
- GdmAddress *address;
- gint ss_len;
- XdmcpHeader header;
- char *host;
- char *port;
- int res;
+ GIOCondition cond,
+ GdmXdmcpDisplayFactory *factory)
+{
+ struct sockaddr_storage clnt_ss;
+ GdmAddress *address;
+ gint ss_len;
+ XdmcpHeader header;
+ char *host;
+ char *port;
+ int res;
- g_debug ("decode_packet: GIOCondition %d", (int)cond);
+ g_debug ("decode_packet: GIOCondition %d", (int)cond);
- if ( ! (cond & G_IO_IN)) {
- return TRUE;
- }
+ if ( ! (cond & G_IO_IN)) {
+ return TRUE;
+ }
- ss_len = sizeof (clnt_ss);
- res = XdmcpFill (factory->priv->socket_fd, &factory->priv->buf, (XdmcpNetaddr)&clnt_ss, &ss_len);
- if G_UNLIKELY (! res) {
- g_debug (_("XMCP: Could not create XDMCP buffer!"));
- return TRUE;
- }
+ ss_len = sizeof (clnt_ss);
+ res = XdmcpFill (factory->priv->socket_fd, &factory->priv->buf, (XdmcpNetaddr)&clnt_ss, &ss_len);
+ if G_UNLIKELY (! res) {
+ g_debug (_("XMCP: Could not create XDMCP buffer!"));
+ return TRUE;
+ }
- res = XdmcpReadHeader (&factory->priv->buf, &header);
- if G_UNLIKELY (! res) {
- g_warning (_("XDMCP: Could not read XDMCP header!"));
- return TRUE;
- }
+ res = XdmcpReadHeader (&factory->priv->buf, &header);
+ if G_UNLIKELY (! res) {
+ g_warning (_("XDMCP: Could not read XDMCP header!"));
+ return TRUE;
+ }
- if G_UNLIKELY (header.version != XDM_PROTOCOL_VERSION &&
- header.version != GDM_XDMCP_PROTOCOL_VERSION) {
- g_warning (_("XMDCP: Incorrect XDMCP version!"));
- return TRUE;
- }
+ if G_UNLIKELY (header.version != XDM_PROTOCOL_VERSION &&
+ header.version != GDM_XDMCP_PROTOCOL_VERSION) {
+ g_warning (_("XMDCP: Incorrect XDMCP version!"));
+ return TRUE;
+ }
- address = gdm_address_new_from_sockaddr_storage (&clnt_ss);
- if (address == NULL) {
- g_warning (_("XMDCP: Unable to parse address"));
- return TRUE;
- }
+ address = gdm_address_new_from_sockaddr_storage (&clnt_ss);
+ if (address == NULL) {
+ g_warning (_("XMDCP: Unable to parse address"));
+ return TRUE;
+ }
- gdm_address_debug (address);
+ gdm_address_debug (address);
- host = NULL;
- port = NULL;
- gdm_address_get_numeric_info (address, &host, &port);
+ host = NULL;
+ port = NULL;
+ gdm_address_get_numeric_info (address, &host, &port);
- g_debug ("XDMCP: Received opcode %s from client %s : %s",
- opcode_string (header.opcode),
- host,
- port);
+ g_debug ("XDMCP: Received opcode %s from client %s : %s",
+ opcode_string (header.opcode),
+ host,
+ port);
- switch (header.opcode) {
- case BROADCAST_QUERY:
- gdm_xdmcp_handle_broadcast_query (factory, address, header.length);
- break;
+ switch (header.opcode) {
+ case BROADCAST_QUERY:
+ gdm_xdmcp_handle_broadcast_query (factory, address, header.length);
+ break;
- case QUERY:
- gdm_xdmcp_handle_query (factory, address, header.length);
- break;
+ case QUERY:
+ gdm_xdmcp_handle_query (factory, address, header.length);
+ break;
- case INDIRECT_QUERY:
- gdm_xdmcp_handle_indirect_query (factory, address, header.length);
- break;
+ case INDIRECT_QUERY:
+ gdm_xdmcp_handle_indirect_query (factory, address, header.length);
+ break;
- case FORWARD_QUERY:
- gdm_xdmcp_handle_forward_query (factory, address, header.length);
- break;
+ case FORWARD_QUERY:
+ gdm_xdmcp_handle_forward_query (factory, address, header.length);
+ break;
- case REQUEST:
- gdm_xdmcp_handle_request (factory, address, header.length);
- break;
+ case REQUEST:
+ gdm_xdmcp_handle_request (factory, address, header.length);
+ break;
- case MANAGE:
- gdm_xdmcp_handle_manage (factory, address, header.length);
- break;
+ case MANAGE:
+ gdm_xdmcp_handle_manage (factory, address, header.length);
+ break;
- case KEEPALIVE:
- gdm_xdmcp_handle_keepalive (factory, address, header.length);
- break;
+ case KEEPALIVE:
+ gdm_xdmcp_handle_keepalive (factory, address, header.length);
+ break;
- case GDM_XDMCP_MANAGED_FORWARD:
- gdm_xdmcp_handle_managed_forward (factory, address, header.length);
- break;
+ case GDM_XDMCP_MANAGED_FORWARD:
+ gdm_xdmcp_handle_managed_forward (factory, address, header.length);
+ break;
- case GDM_XDMCP_GOT_MANAGED_FORWARD:
- gdm_xdmcp_handle_got_managed_forward (factory, address, header.length);
- break;
+ case GDM_XDMCP_GOT_MANAGED_FORWARD:
+ gdm_xdmcp_handle_got_managed_forward (factory, address, header.length);
+ break;
- default:
- g_debug ("XDMCP: Unknown opcode from client %s : %s",
- host,
- port);
+ default:
+ g_debug ("XDMCP: Unknown opcode from client %s : %s",
+ host,
+ port);
- break;
- }
+ break;
+ }
- g_free (host);
- g_free (port);
+ g_free (host);
+ g_free (port);
- gdm_address_free (address);
+ gdm_address_free (address);
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_xdmcp_display_factory_start (GdmDisplayFactory *base_factory)
{
- gboolean ret;
- GIOChannel *ioc;
- GdmXdmcpDisplayFactory *factory = GDM_XDMCP_DISPLAY_FACTORY (base_factory);
+ gboolean ret;
+ GIOChannel *ioc;
+ GdmXdmcpDisplayFactory *factory = GDM_XDMCP_DISPLAY_FACTORY (base_factory);
- g_return_val_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory), FALSE);
- g_return_val_if_fail (factory->priv->socket_fd == -1, FALSE);
+ g_return_val_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory), FALSE);
+ g_return_val_if_fail (factory->priv->socket_fd == -1, FALSE);
- ret = open_port (factory);
- if (! ret) {
- return ret;
- }
+ ret = open_port (factory);
+ if (! ret) {
+ return ret;
+ }
- g_debug ("XDMCP: Starting to listen on XDMCP port");
+ g_debug ("XDMCP: Starting to listen on XDMCP port");
- ioc = g_io_channel_unix_new (factory->priv->socket_fd);
+ ioc = g_io_channel_unix_new (factory->priv->socket_fd);
- g_io_channel_set_encoding (ioc, NULL, NULL);
- g_io_channel_set_buffered (ioc, FALSE);
+ g_io_channel_set_encoding (ioc, NULL, NULL);
+ g_io_channel_set_buffered (ioc, FALSE);
- factory->priv->socket_watch_id = g_io_add_watch_full (ioc,
- G_PRIORITY_DEFAULT,
- G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
- (GIOFunc)decode_packet,
- factory,
- NULL);
- g_io_channel_unref (ioc);
+ factory->priv->socket_watch_id = g_io_add_watch_full (ioc,
+ G_PRIORITY_DEFAULT,
+ G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+ (GIOFunc)decode_packet,
+ factory,
+ NULL);
+ g_io_channel_unref (ioc);
- return ret;
+ return ret;
}
static gboolean
gdm_xdmcp_display_factory_stop (GdmDisplayFactory *base_factory)
{
- GdmXdmcpDisplayFactory *factory = GDM_XDMCP_DISPLAY_FACTORY (base_factory);
+ GdmXdmcpDisplayFactory *factory = GDM_XDMCP_DISPLAY_FACTORY (base_factory);
- g_return_val_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory), FALSE);
- g_return_val_if_fail (factory->priv->socket_fd != -1, FALSE);
+ g_return_val_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory), FALSE);
+ g_return_val_if_fail (factory->priv->socket_fd != -1, FALSE);
- if (factory->priv->socket_watch_id > 0) {
- g_source_remove (factory->priv->socket_watch_id);
- factory->priv->socket_watch_id = 0;
- }
+ if (factory->priv->socket_watch_id > 0) {
+ g_source_remove (factory->priv->socket_watch_id);
+ factory->priv->socket_watch_id = 0;
+ }
- if (factory->priv->socket_fd > 0) {
- VE_IGNORE_EINTR (close (factory->priv->socket_fd));
- factory->priv->socket_fd = -1;
- }
+ if (factory->priv->socket_fd > 0) {
+ VE_IGNORE_EINTR (close (factory->priv->socket_fd));
+ factory->priv->socket_fd = -1;
+ }
- return TRUE;
+ return TRUE;
}
void
gdm_xdmcp_display_factory_set_port (GdmXdmcpDisplayFactory *factory,
- guint port)
+ guint port)
{
- g_return_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory));
+ g_return_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory));
- factory->priv->port = port;
+ factory->priv->port = port;
}
static void
gdm_xdmcp_display_factory_set_use_multicast (GdmXdmcpDisplayFactory *factory,
- gboolean use_multicast)
+ gboolean use_multicast)
{
- g_return_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory));
+ g_return_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory));
- factory->priv->use_multicast = use_multicast;
+ factory->priv->use_multicast = use_multicast;
}
static void
gdm_xdmcp_display_factory_set_multicast_address (GdmXdmcpDisplayFactory *factory,
- const char *address)
+ const char *address)
{
- g_return_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory));
+ g_return_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory));
- g_free (factory->priv->multicast_address);
- factory->priv->multicast_address = g_strdup (address);
+ g_free (factory->priv->multicast_address);
+ factory->priv->multicast_address = g_strdup (address);
}
static void
gdm_xdmcp_display_factory_set_honor_indirect (GdmXdmcpDisplayFactory *factory,
- gboolean honor_indirect)
+ gboolean honor_indirect)
{
- g_return_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory));
+ g_return_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory));
- factory->priv->honor_indirect = honor_indirect;
+ factory->priv->honor_indirect = honor_indirect;
}
static void
gdm_xdmcp_display_factory_set_max_displays_per_host (GdmXdmcpDisplayFactory *factory,
- guint num)
+ guint num)
{
- g_return_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory));
+ g_return_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory));
- factory->priv->max_displays_per_host = num;
+ factory->priv->max_displays_per_host = num;
}
static void
gdm_xdmcp_display_factory_set_max_displays (GdmXdmcpDisplayFactory *factory,
- guint num)
+ guint num)
{
- g_return_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory));
+ g_return_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory));
- factory->priv->max_displays = num;
+ factory->priv->max_displays = num;
}
static void
gdm_xdmcp_display_factory_set_max_pending_displays (GdmXdmcpDisplayFactory *factory,
- guint num)
+ guint num)
{
- g_return_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory));
+ g_return_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory));
- factory->priv->max_pending_displays = num;
+ factory->priv->max_pending_displays = num;
}
static void
gdm_xdmcp_display_factory_set_max_wait (GdmXdmcpDisplayFactory *factory,
- guint num)
+ guint num)
{
- g_return_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory));
+ g_return_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory));
- factory->priv->max_wait = num;
+ factory->priv->max_wait = num;
}
static void
gdm_xdmcp_display_factory_set_willing_script (GdmXdmcpDisplayFactory *factory,
- const char *script)
+ const char *script)
{
- g_return_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory));
+ g_return_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (factory));
- g_free (factory->priv->willing_script);
- factory->priv->willing_script = g_strdup (script);
+ g_free (factory->priv->willing_script);
+ factory->priv->willing_script = g_strdup (script);
}
static void
-gdm_xdmcp_display_factory_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GdmXdmcpDisplayFactory *self;
-
- self = GDM_XDMCP_DISPLAY_FACTORY (object);
-
- switch (prop_id) {
- case PROP_PORT:
- gdm_xdmcp_display_factory_set_port (self, g_value_get_uint (value));
- break;
- case PROP_USE_MULTICAST:
- gdm_xdmcp_display_factory_set_use_multicast (self, g_value_get_boolean (value));
- break;
- case PROP_MULTICAST_ADDRESS:
- gdm_xdmcp_display_factory_set_multicast_address (self, g_value_get_string (value));
- break;
- case PROP_HONOR_INDIRECT:
- gdm_xdmcp_display_factory_set_honor_indirect (self, g_value_get_boolean (value));
- break;
- case PROP_MAX_DISPLAYS_PER_HOST:
- gdm_xdmcp_display_factory_set_max_displays_per_host (self, g_value_get_uint (value));
- break;
- case PROP_MAX_DISPLAYS:
- gdm_xdmcp_display_factory_set_max_displays (self, g_value_get_uint (value));
- break;
- case PROP_MAX_PENDING_DISPLAYS:
- gdm_xdmcp_display_factory_set_max_pending_displays (self, g_value_get_uint (value));
- break;
- case PROP_MAX_WAIT:
- gdm_xdmcp_display_factory_set_max_wait (self, g_value_get_uint (value));
- break;
- case PROP_WILLING_SCRIPT:
- gdm_xdmcp_display_factory_set_willing_script (self, g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+gdm_xdmcp_display_factory_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GdmXdmcpDisplayFactory *self;
+
+ self = GDM_XDMCP_DISPLAY_FACTORY (object);
+
+ switch (prop_id) {
+ case PROP_PORT:
+ gdm_xdmcp_display_factory_set_port (self, g_value_get_uint (value));
+ break;
+ case PROP_USE_MULTICAST:
+ gdm_xdmcp_display_factory_set_use_multicast (self, g_value_get_boolean (value));
+ break;
+ case PROP_MULTICAST_ADDRESS:
+ gdm_xdmcp_display_factory_set_multicast_address (self, g_value_get_string (value));
+ break;
+ case PROP_HONOR_INDIRECT:
+ gdm_xdmcp_display_factory_set_honor_indirect (self, g_value_get_boolean (value));
+ break;
+ case PROP_MAX_DISPLAYS_PER_HOST:
+ gdm_xdmcp_display_factory_set_max_displays_per_host (self, g_value_get_uint (value));
+ break;
+ case PROP_MAX_DISPLAYS:
+ gdm_xdmcp_display_factory_set_max_displays (self, g_value_get_uint (value));
+ break;
+ case PROP_MAX_PENDING_DISPLAYS:
+ gdm_xdmcp_display_factory_set_max_pending_displays (self, g_value_get_uint (value));
+ break;
+ case PROP_MAX_WAIT:
+ gdm_xdmcp_display_factory_set_max_wait (self, g_value_get_uint (value));
+ break;
+ case PROP_WILLING_SCRIPT:
+ gdm_xdmcp_display_factory_set_willing_script (self, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gdm_xdmcp_display_factory_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GdmXdmcpDisplayFactory *self;
-
- self = GDM_XDMCP_DISPLAY_FACTORY (object);
-
- switch (prop_id) {
- case PROP_PORT:
- g_value_set_uint (value, self->priv->port);
- break;
- case PROP_USE_MULTICAST:
- g_value_set_boolean (value, self->priv->use_multicast);
- break;
- case PROP_MULTICAST_ADDRESS:
- g_value_set_string (value, self->priv->multicast_address);
- break;
- case PROP_HONOR_INDIRECT:
- g_value_set_boolean (value, self->priv->honor_indirect);
- break;
- case PROP_MAX_DISPLAYS_PER_HOST:
- g_value_set_uint (value, self->priv->max_displays_per_host);
- break;
- case PROP_MAX_DISPLAYS:
- g_value_set_uint (value, self->priv->max_displays);
- break;
- case PROP_MAX_PENDING_DISPLAYS:
- g_value_set_uint (value, self->priv->max_pending_displays);
- break;
- case PROP_MAX_WAIT:
- g_value_set_uint (value, self->priv->max_wait);
- break;
- case PROP_WILLING_SCRIPT:
- g_value_set_string (value, self->priv->willing_script);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+gdm_xdmcp_display_factory_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GdmXdmcpDisplayFactory *self;
+
+ self = GDM_XDMCP_DISPLAY_FACTORY (object);
+
+ switch (prop_id) {
+ case PROP_PORT:
+ g_value_set_uint (value, self->priv->port);
+ break;
+ case PROP_USE_MULTICAST:
+ g_value_set_boolean (value, self->priv->use_multicast);
+ break;
+ case PROP_MULTICAST_ADDRESS:
+ g_value_set_string (value, self->priv->multicast_address);
+ break;
+ case PROP_HONOR_INDIRECT:
+ g_value_set_boolean (value, self->priv->honor_indirect);
+ break;
+ case PROP_MAX_DISPLAYS_PER_HOST:
+ g_value_set_uint (value, self->priv->max_displays_per_host);
+ break;
+ case PROP_MAX_DISPLAYS:
+ g_value_set_uint (value, self->priv->max_displays);
+ break;
+ case PROP_MAX_PENDING_DISPLAYS:
+ g_value_set_uint (value, self->priv->max_pending_displays);
+ break;
+ case PROP_MAX_WAIT:
+ g_value_set_uint (value, self->priv->max_wait);
+ break;
+ case PROP_WILLING_SCRIPT:
+ g_value_set_string (value, self->priv->willing_script);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_xdmcp_display_factory_class_init (GdmXdmcpDisplayFactoryClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GdmDisplayFactoryClass *factory_class = GDM_DISPLAY_FACTORY_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GdmDisplayFactoryClass *factory_class = GDM_DISPLAY_FACTORY_CLASS (klass);
- object_class->get_property = gdm_xdmcp_display_factory_get_property;
- object_class->set_property = gdm_xdmcp_display_factory_set_property;
- object_class->finalize = gdm_xdmcp_display_factory_finalize;
+ object_class->get_property = gdm_xdmcp_display_factory_get_property;
+ object_class->set_property = gdm_xdmcp_display_factory_set_property;
+ object_class->finalize = gdm_xdmcp_display_factory_finalize;
- factory_class->start = gdm_xdmcp_display_factory_start;
- factory_class->stop = gdm_xdmcp_display_factory_stop;
+ factory_class->start = gdm_xdmcp_display_factory_start;
+ factory_class->stop = gdm_xdmcp_display_factory_stop;
g_object_class_install_property (object_class,
PROP_PORT,
@@ -2945,7 +2945,7 @@ gdm_xdmcp_display_factory_class_init (GdmXdmcpDisplayFactoryClass *klass)
g_param_spec_string ("willing-script",
"willing-script",
"willing-script",
- NULL,
+ NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_MAX_DISPLAYS_PER_HOST,
@@ -2984,81 +2984,81 @@ gdm_xdmcp_display_factory_class_init (GdmXdmcpDisplayFactoryClass *klass)
DEFAULT_MAX_WAIT,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_type_class_add_private (klass, sizeof (GdmXdmcpDisplayFactoryPrivate));
+ g_type_class_add_private (klass, sizeof (GdmXdmcpDisplayFactoryPrivate));
}
static void
gdm_xdmcp_display_factory_init (GdmXdmcpDisplayFactory *factory)
{
- char hostbuf[1024];
- struct utsname name;
+ char hostbuf[1024];
+ struct utsname name;
- factory->priv = GDM_XDMCP_DISPLAY_FACTORY_GET_PRIVATE (factory);
+ factory->priv = GDM_XDMCP_DISPLAY_FACTORY_GET_PRIVATE (factory);
- factory->priv->socket_fd = -1;
+ factory->priv->socket_fd = -1;
- factory->priv->session_serial = g_random_int ();
+ factory->priv->session_serial = g_random_int ();
- /* Fetch and store local hostname in XDMCP friendly format */
- hostbuf[1023] = '\0';
- if G_UNLIKELY (gethostname (hostbuf, 1023) != 0) {
- g_warning (_("Could not get server hostname: %s!"), g_strerror (errno));
- strcpy (hostbuf, "localhost.localdomain");
- }
+ /* Fetch and store local hostname in XDMCP friendly format */
+ hostbuf[1023] = '\0';
+ if G_UNLIKELY (gethostname (hostbuf, 1023) != 0) {
+ g_warning (_("Could not get server hostname: %s!"), g_strerror (errno));
+ strcpy (hostbuf, "localhost.localdomain");
+ }
- uname (&name);
- factory->priv->sysid = g_strconcat (name.sysname,
- " ",
- name.release,
- NULL);
+ uname (&name);
+ factory->priv->sysid = g_strconcat (name.sysname,
+ " ",
+ name.release,
+ NULL);
- factory->priv->hostname = g_strdup (hostbuf);
+ factory->priv->hostname = g_strdup (hostbuf);
- factory->priv->servhost.data = (CARD8 *) g_strdup (hostbuf);
- factory->priv->servhost.length = strlen ((char *) factory->priv->servhost.data);
+ factory->priv->servhost.data = (CARD8 *) g_strdup (hostbuf);
+ factory->priv->servhost.length = strlen ((char *) factory->priv->servhost.data);
}
static void
gdm_xdmcp_display_factory_finalize (GObject *object)
{
- GdmXdmcpDisplayFactory *factory;
+ GdmXdmcpDisplayFactory *factory;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_XDMCP_DISPLAY_FACTORY (object));
- factory = GDM_XDMCP_DISPLAY_FACTORY (object);
+ factory = GDM_XDMCP_DISPLAY_FACTORY (object);
- g_return_if_fail (factory->priv != NULL);
+ g_return_if_fail (factory->priv != NULL);
- if (factory->priv->socket_watch_id > 0) {
- g_source_remove (factory->priv->socket_watch_id);
- }
+ if (factory->priv->socket_watch_id > 0) {
+ g_source_remove (factory->priv->socket_watch_id);
+ }
- g_slist_free (factory->priv->forward_queries);
- g_slist_free (factory->priv->managed_forwards);
+ g_slist_free (factory->priv->forward_queries);
+ g_slist_free (factory->priv->managed_forwards);
- g_free (factory->priv->sysid);
- g_free (factory->priv->hostname);
- g_free (factory->priv->multicast_address);
- g_free (factory->priv->willing_script);
+ g_free (factory->priv->sysid);
+ g_free (factory->priv->hostname);
+ g_free (factory->priv->multicast_address);
+ g_free (factory->priv->willing_script);
- /* FIXME: Free servhost */
+ /* FIXME: Free servhost */
- G_OBJECT_CLASS (gdm_xdmcp_display_factory_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_xdmcp_display_factory_parent_class)->finalize (object);
}
GdmXdmcpDisplayFactory *
gdm_xdmcp_display_factory_new (GdmDisplayStore *store)
{
- if (xdmcp_display_factory_object != NULL) {
- g_object_ref (xdmcp_display_factory_object);
- } else {
- xdmcp_display_factory_object = g_object_new (GDM_TYPE_XDMCP_DISPLAY_FACTORY,
- "display-store", store,
- NULL);
- g_object_add_weak_pointer (xdmcp_display_factory_object,
- (gpointer *) &xdmcp_display_factory_object);
- }
-
- return GDM_XDMCP_DISPLAY_FACTORY (xdmcp_display_factory_object);
+ if (xdmcp_display_factory_object != NULL) {
+ g_object_ref (xdmcp_display_factory_object);
+ } else {
+ xdmcp_display_factory_object = g_object_new (GDM_TYPE_XDMCP_DISPLAY_FACTORY,
+ "display-store", store,
+ NULL);
+ g_object_add_weak_pointer (xdmcp_display_factory_object,
+ (gpointer *) &xdmcp_display_factory_object);
+ }
+
+ return GDM_XDMCP_DISPLAY_FACTORY (xdmcp_display_factory_object);
}
diff --git a/daemon/gdm-xdmcp-display-factory.h b/daemon/gdm-xdmcp-display-factory.h
index 5d515b0a..d6a0d3db 100644
--- a/daemon/gdm-xdmcp-display-factory.h
+++ b/daemon/gdm-xdmcp-display-factory.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2006 William Jon McCann <mccann@jhu.edu>
*
@@ -40,29 +40,29 @@ typedef struct GdmXdmcpDisplayFactoryPrivate GdmXdmcpDisplayFactoryPrivate;
typedef struct
{
- GdmDisplayFactory parent;
- GdmXdmcpDisplayFactoryPrivate *priv;
+ GdmDisplayFactory parent;
+ GdmXdmcpDisplayFactoryPrivate *priv;
} GdmXdmcpDisplayFactory;
typedef struct
{
- GdmDisplayFactoryClass parent_class;
+ GdmDisplayFactoryClass parent_class;
} GdmXdmcpDisplayFactoryClass;
typedef enum
{
- GDM_XDMCP_DISPLAY_FACTORY_ERROR_GENERAL
+ GDM_XDMCP_DISPLAY_FACTORY_ERROR_GENERAL
} GdmXdmcpDisplayFactoryError;
#define GDM_XDMCP_DISPLAY_FACTORY_ERROR gdm_xdmcp_display_factory_error_quark ()
-GQuark gdm_xdmcp_display_factory_error_quark (void);
-GType gdm_xdmcp_display_factory_get_type (void);
+GQuark gdm_xdmcp_display_factory_error_quark (void);
+GType gdm_xdmcp_display_factory_get_type (void);
-GdmXdmcpDisplayFactory * gdm_xdmcp_display_factory_new (GdmDisplayStore *display_store);
+GdmXdmcpDisplayFactory * gdm_xdmcp_display_factory_new (GdmDisplayStore *display_store);
void gdm_xdmcp_display_factory_set_port (GdmXdmcpDisplayFactory *manager,
- guint port);
+ guint port);
G_END_DECLS
diff --git a/daemon/gdm-xdmcp-display.c b/daemon/gdm-xdmcp-display.c
index a2faea18..178caba9 100644
--- a/daemon/gdm-xdmcp-display.c
+++ b/daemon/gdm-xdmcp-display.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -48,308 +48,308 @@
struct GdmXdmcpDisplayPrivate
{
- GdmAddress *remote_address;
- gint32 session_number;
+ GdmAddress *remote_address;
+ gint32 session_number;
};
enum {
- PROP_0,
- PROP_REMOTE_ADDRESS,
- PROP_SESSION_NUMBER,
+ PROP_0,
+ PROP_REMOTE_ADDRESS,
+ PROP_SESSION_NUMBER,
};
-static void gdm_xdmcp_display_class_init (GdmXdmcpDisplayClass *klass);
-static void gdm_xdmcp_display_init (GdmXdmcpDisplay *xdmcp_display);
-static void gdm_xdmcp_display_finalize (GObject *object);
+static void gdm_xdmcp_display_class_init (GdmXdmcpDisplayClass *klass);
+static void gdm_xdmcp_display_init (GdmXdmcpDisplay *xdmcp_display);
+static void gdm_xdmcp_display_finalize (GObject *object);
G_DEFINE_TYPE (GdmXdmcpDisplay, gdm_xdmcp_display, GDM_TYPE_DISPLAY)
gint32
gdm_xdmcp_display_get_session_number (GdmXdmcpDisplay *display)
{
- g_return_val_if_fail (GDM_IS_XDMCP_DISPLAY (display), 0);
+ g_return_val_if_fail (GDM_IS_XDMCP_DISPLAY (display), 0);
- return display->priv->session_number;
+ return display->priv->session_number;
}
GdmAddress *
gdm_xdmcp_display_get_remote_address (GdmXdmcpDisplay *display)
{
- g_return_val_if_fail (GDM_IS_XDMCP_DISPLAY (display), NULL);
+ g_return_val_if_fail (GDM_IS_XDMCP_DISPLAY (display), NULL);
- return display->priv->remote_address;
+ return display->priv->remote_address;
}
static gboolean
gdm_xdmcp_display_create_authority (GdmDisplay *display)
{
- FILE *af;
- int closeret;
- gboolean ret;
- char *authfile;
- int display_num;
- char *x11_display;
- GString *cookie;
- GSList *authlist;
- char *basename;
-
- ret = FALSE;
- x11_display = NULL;
-
- g_object_get (display,
- "x11-display-name", &x11_display,
- "x11-display-number", &display_num,
- NULL);
-
- /* Create new random cookie */
- cookie = g_string_new (NULL);
- gdm_generate_cookie (cookie);
-
- g_debug ("Setting up access for %s", x11_display);
-
- /* gdm and xserver authfile can be the same, server will run as root */
- basename = g_strconcat (x11_display, ".Xauth", NULL);
- authfile = g_build_filename (AUTHDIR, basename, NULL);
- g_free (basename);
-
- af = gdm_safe_fopen_w (authfile, 0644);
- if (af == NULL) {
- g_warning (_("Cannot safely open %s"), authfile);
- g_free (authfile);
- goto out;
- }
-
- g_debug ("Adding auth entry for xdmcp display:%d cookie:%s", display_num, cookie->str);
- authlist = NULL;
- if (! gdm_auth_add_entry_for_display (display_num, NULL, cookie, af, &authlist)) {
- goto out;
- }
-
- g_debug ("gdm_auth_secure_display: Setting up access");
-
- VE_IGNORE_EINTR (closeret = fclose (af));
- if (closeret < 0) {
- g_warning (_("Could not write new authorization entry: %s"),
- g_strerror (errno));
- goto out;
- }
-
- g_debug ("Set up access for %s - %d entries",
- x11_display,
- g_slist_length (authlist));
-
- /* FIXME: save authlist */
-
- g_object_set (display,
- "x11-authority-file", authfile,
- "x11-cookie", cookie->str,
- NULL);
-
- ret = TRUE;
+ FILE *af;
+ int closeret;
+ gboolean ret;
+ char *authfile;
+ int display_num;
+ char *x11_display;
+ GString *cookie;
+ GSList *authlist;
+ char *basename;
+
+ ret = FALSE;
+ x11_display = NULL;
+
+ g_object_get (display,
+ "x11-display-name", &x11_display,
+ "x11-display-number", &display_num,
+ NULL);
+
+ /* Create new random cookie */
+ cookie = g_string_new (NULL);
+ gdm_generate_cookie (cookie);
+
+ g_debug ("Setting up access for %s", x11_display);
+
+ /* gdm and xserver authfile can be the same, server will run as root */
+ basename = g_strconcat (x11_display, ".Xauth", NULL);
+ authfile = g_build_filename (AUTHDIR, basename, NULL);
+ g_free (basename);
+
+ af = gdm_safe_fopen_w (authfile, 0644);
+ if (af == NULL) {
+ g_warning (_("Cannot safely open %s"), authfile);
+ g_free (authfile);
+ goto out;
+ }
+
+ g_debug ("Adding auth entry for xdmcp display:%d cookie:%s", display_num, cookie->str);
+ authlist = NULL;
+ if (! gdm_auth_add_entry_for_display (display_num, NULL, cookie, af, &authlist)) {
+ goto out;
+ }
+
+ g_debug ("gdm_auth_secure_display: Setting up access");
+
+ VE_IGNORE_EINTR (closeret = fclose (af));
+ if (closeret < 0) {
+ g_warning (_("Could not write new authorization entry: %s"),
+ g_strerror (errno));
+ goto out;
+ }
+
+ g_debug ("Set up access for %s - %d entries",
+ x11_display,
+ g_slist_length (authlist));
+
+ /* FIXME: save authlist */
+
+ g_object_set (display,
+ "x11-authority-file", authfile,
+ "x11-cookie", cookie->str,
+ NULL);
+
+ ret = TRUE;
out:
- g_free (x11_display);
- g_string_free (cookie, TRUE);
+ g_free (x11_display);
+ g_string_free (cookie, TRUE);
- return ret;
+ return ret;
}
static gboolean
gdm_xdmcp_display_add_user_authorization (GdmDisplay *display,
- const char *username,
- char **filename,
- GError **error)
+ const char *username,
+ char **filename,
+ GError **error)
{
- gboolean res;
- char *cookie;
- char *hostname;
- int display_num;
-
- res = gdm_display_get_x11_cookie (display, &cookie, NULL);
- res = gdm_display_get_x11_display_number (display, &display_num, NULL);
-
- hostname = NULL;
- res = gdm_address_get_hostname (GDM_XDMCP_DISPLAY (display)->priv->remote_address, &hostname);
- g_debug ("add user auth for xdmcp display: %s host:%s", username, hostname);
- gdm_address_debug (GDM_XDMCP_DISPLAY (display)->priv->remote_address);
- g_free (hostname);
-
- res = gdm_auth_user_add (display_num,
- GDM_XDMCP_DISPLAY (display)->priv->remote_address,
- username,
- cookie,
- filename);
- return res;
+ gboolean res;
+ char *cookie;
+ char *hostname;
+ int display_num;
+
+ res = gdm_display_get_x11_cookie (display, &cookie, NULL);
+ res = gdm_display_get_x11_display_number (display, &display_num, NULL);
+
+ hostname = NULL;
+ res = gdm_address_get_hostname (GDM_XDMCP_DISPLAY (display)->priv->remote_address, &hostname);
+ g_debug ("add user auth for xdmcp display: %s host:%s", username, hostname);
+ gdm_address_debug (GDM_XDMCP_DISPLAY (display)->priv->remote_address);
+ g_free (hostname);
+
+ res = gdm_auth_user_add (display_num,
+ GDM_XDMCP_DISPLAY (display)->priv->remote_address,
+ username,
+ cookie,
+ filename);
+ return res;
}
static gboolean
gdm_xdmcp_display_remove_user_authorization (GdmDisplay *display,
- const char *username,
- GError **error)
+ const char *username,
+ GError **error)
{
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_xdmcp_display_manage (GdmDisplay *display)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- GDM_DISPLAY_CLASS (gdm_xdmcp_display_parent_class)->manage (display);
+ GDM_DISPLAY_CLASS (gdm_xdmcp_display_parent_class)->manage (display);
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_xdmcp_display_unmanage (GdmDisplay *display)
{
- g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- GDM_DISPLAY_CLASS (gdm_xdmcp_display_parent_class)->unmanage (display);
+ GDM_DISPLAY_CLASS (gdm_xdmcp_display_parent_class)->unmanage (display);
- return TRUE;
+ return TRUE;
}
static void
_gdm_xdmcp_display_set_remote_address (GdmXdmcpDisplay *display,
- GdmAddress *address)
+ GdmAddress *address)
{
- if (display->priv->remote_address != NULL) {
- gdm_address_free (display->priv->remote_address);
- }
+ if (display->priv->remote_address != NULL) {
+ gdm_address_free (display->priv->remote_address);
+ }
- g_assert (address != NULL);
+ g_assert (address != NULL);
- gdm_address_debug (address);
- display->priv->remote_address = gdm_address_copy (address);
+ gdm_address_debug (address);
+ display->priv->remote_address = gdm_address_copy (address);
}
static void
-gdm_xdmcp_display_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gdm_xdmcp_display_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GdmXdmcpDisplay *self;
-
- self = GDM_XDMCP_DISPLAY (object);
-
- switch (prop_id) {
- case PROP_REMOTE_ADDRESS:
- _gdm_xdmcp_display_set_remote_address (self, g_value_get_boxed (value));
- break;
- case PROP_SESSION_NUMBER:
- self->priv->session_number = g_value_get_int (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GdmXdmcpDisplay *self;
+
+ self = GDM_XDMCP_DISPLAY (object);
+
+ switch (prop_id) {
+ case PROP_REMOTE_ADDRESS:
+ _gdm_xdmcp_display_set_remote_address (self, g_value_get_boxed (value));
+ break;
+ case PROP_SESSION_NUMBER:
+ self->priv->session_number = g_value_get_int (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gdm_xdmcp_display_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gdm_xdmcp_display_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GdmXdmcpDisplay *self;
-
- self = GDM_XDMCP_DISPLAY (object);
-
- switch (prop_id) {
- case PROP_REMOTE_ADDRESS:
- g_value_set_boxed (value, self->priv->remote_address);
- break;
- case PROP_SESSION_NUMBER:
- g_value_set_int (value, self->priv->session_number);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GdmXdmcpDisplay *self;
+
+ self = GDM_XDMCP_DISPLAY (object);
+
+ switch (prop_id) {
+ case PROP_REMOTE_ADDRESS:
+ g_value_set_boxed (value, self->priv->remote_address);
+ break;
+ case PROP_SESSION_NUMBER:
+ g_value_set_int (value, self->priv->session_number);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_xdmcp_display_class_init (GdmXdmcpDisplayClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GdmDisplayClass *display_class = GDM_DISPLAY_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GdmDisplayClass *display_class = GDM_DISPLAY_CLASS (klass);
- object_class->get_property = gdm_xdmcp_display_get_property;
- object_class->set_property = gdm_xdmcp_display_set_property;
- object_class->finalize = gdm_xdmcp_display_finalize;
+ object_class->get_property = gdm_xdmcp_display_get_property;
+ object_class->set_property = gdm_xdmcp_display_set_property;
+ object_class->finalize = gdm_xdmcp_display_finalize;
- display_class->create_authority = gdm_xdmcp_display_create_authority;
- display_class->add_user_authorization = gdm_xdmcp_display_add_user_authorization;
- display_class->remove_user_authorization = gdm_xdmcp_display_remove_user_authorization;
- display_class->manage = gdm_xdmcp_display_manage;
- display_class->unmanage = gdm_xdmcp_display_unmanage;
+ display_class->create_authority = gdm_xdmcp_display_create_authority;
+ display_class->add_user_authorization = gdm_xdmcp_display_add_user_authorization;
+ display_class->remove_user_authorization = gdm_xdmcp_display_remove_user_authorization;
+ display_class->manage = gdm_xdmcp_display_manage;
+ display_class->unmanage = gdm_xdmcp_display_unmanage;
- g_type_class_add_private (klass, sizeof (GdmXdmcpDisplayPrivate));
+ g_type_class_add_private (klass, sizeof (GdmXdmcpDisplayPrivate));
- g_object_class_install_property (object_class,
- PROP_REMOTE_ADDRESS,
- g_param_spec_boxed ("remote-address",
- "Remote address",
- "Remote address",
- GDM_TYPE_ADDRESS,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_REMOTE_ADDRESS,
+ g_param_spec_boxed ("remote-address",
+ "Remote address",
+ "Remote address",
+ GDM_TYPE_ADDRESS,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_SESSION_NUMBER,
g_param_spec_int ("session-number",
- "session-number",
- "session-number",
- G_MININT,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- dbus_g_object_type_install_info (GDM_TYPE_XDMCP_DISPLAY, &dbus_glib_gdm_xdmcp_display_object_info);
+ "session-number",
+ "session-number",
+ G_MININT,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ dbus_g_object_type_install_info (GDM_TYPE_XDMCP_DISPLAY, &dbus_glib_gdm_xdmcp_display_object_info);
}
static void
gdm_xdmcp_display_init (GdmXdmcpDisplay *xdmcp_display)
{
- xdmcp_display->priv = GDM_XDMCP_DISPLAY_GET_PRIVATE (xdmcp_display);
+ xdmcp_display->priv = GDM_XDMCP_DISPLAY_GET_PRIVATE (xdmcp_display);
}
static void
gdm_xdmcp_display_finalize (GObject *object)
{
- GdmXdmcpDisplay *xdmcp_display;
+ GdmXdmcpDisplay *xdmcp_display;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_XDMCP_DISPLAY (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_XDMCP_DISPLAY (object));
- xdmcp_display = GDM_XDMCP_DISPLAY (object);
+ xdmcp_display = GDM_XDMCP_DISPLAY (object);
- g_return_if_fail (xdmcp_display->priv != NULL);
+ g_return_if_fail (xdmcp_display->priv != NULL);
- G_OBJECT_CLASS (gdm_xdmcp_display_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_xdmcp_display_parent_class)->finalize (object);
}
GdmDisplay *
gdm_xdmcp_display_new (const char *hostname,
- int number,
- GdmAddress *address,
- gint32 session_number)
+ int number,
+ GdmAddress *address,
+ gint32 session_number)
{
- GObject *object;
- char *x11_display;
-
- x11_display = g_strdup_printf ("%s:%d", hostname, number);
- object = g_object_new (GDM_TYPE_XDMCP_DISPLAY,
- "remote-hostname", hostname,
- "x11-display-number", number,
- "x11-display-name", x11_display,
- "is-local", FALSE,
- "remote-address", address,
- "session-number", session_number,
- NULL);
- g_free (x11_display);
-
- return GDM_DISPLAY (object);
+ GObject *object;
+ char *x11_display;
+
+ x11_display = g_strdup_printf ("%s:%d", hostname, number);
+ object = g_object_new (GDM_TYPE_XDMCP_DISPLAY,
+ "remote-hostname", hostname,
+ "x11-display-number", number,
+ "x11-display-name", x11_display,
+ "is-local", FALSE,
+ "remote-address", address,
+ "session-number", session_number,
+ NULL);
+ g_free (x11_display);
+
+ return GDM_DISPLAY (object);
}
diff --git a/daemon/gdm-xdmcp-display.h b/daemon/gdm-xdmcp-display.h
index eefe7556..1748bc96 100644
--- a/daemon/gdm-xdmcp-display.h
+++ b/daemon/gdm-xdmcp-display.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -43,23 +43,23 @@ typedef struct GdmXdmcpDisplayPrivate GdmXdmcpDisplayPrivate;
typedef struct
{
- GdmDisplay parent;
- GdmXdmcpDisplayPrivate *priv;
+ GdmDisplay parent;
+ GdmXdmcpDisplayPrivate *priv;
} GdmXdmcpDisplay;
typedef struct
{
- GdmDisplayClass parent_class;
+ GdmDisplayClass parent_class;
} GdmXdmcpDisplayClass;
-GType gdm_xdmcp_display_get_type (void);
+GType gdm_xdmcp_display_get_type (void);
-GdmDisplay * gdm_xdmcp_display_new (const char *hostname,
- int number,
- GdmAddress *addr,
- gint32 serial_number);
+GdmDisplay * gdm_xdmcp_display_new (const char *hostname,
+ int number,
+ GdmAddress *addr,
+ gint32 serial_number);
gint32 gdm_xdmcp_display_get_session_number (GdmXdmcpDisplay *display);
GdmAddress * gdm_xdmcp_display_get_remote_address (GdmXdmcpDisplay *display);
diff --git a/daemon/main.c b/daemon/main.c
index 1ef6c841..822d719a 100644
--- a/daemon/main.c
+++ b/daemon/main.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -68,246 +68,246 @@ static gid_t gdm_gid = -1;
static gboolean
timed_exit_cb (GMainLoop *loop)
{
- g_main_loop_quit (loop);
- return FALSE;
+ g_main_loop_quit (loop);
+ return FALSE;
}
static DBusGProxy *
get_bus_proxy (DBusGConnection *connection)
{
- DBusGProxy *bus_proxy;
+ DBusGProxy *bus_proxy;
- bus_proxy = dbus_g_proxy_new_for_name (connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
- return bus_proxy;
+ bus_proxy = dbus_g_proxy_new_for_name (connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);
+ return bus_proxy;
}
static gboolean
acquire_name_on_proxy (DBusGProxy *bus_proxy)
{
- GError *error;
- guint result;
- gboolean res;
- gboolean ret;
-
- ret = FALSE;
-
- if (bus_proxy == NULL) {
- goto out;
- }
-
- error = NULL;
- res = dbus_g_proxy_call (bus_proxy,
- "RequestName",
- &error,
- G_TYPE_STRING, GDM_DBUS_NAME,
- G_TYPE_UINT, 0,
- G_TYPE_INVALID,
- G_TYPE_UINT, &result,
- G_TYPE_INVALID);
- if (! res) {
- if (error != NULL) {
- g_warning ("Failed to acquire %s: %s", GDM_DBUS_NAME, error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to acquire %s", GDM_DBUS_NAME);
- }
- goto out;
- }
-
- if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
- if (error != NULL) {
- g_warning ("Failed to acquire %s: %s", GDM_DBUS_NAME, error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to acquire %s", GDM_DBUS_NAME);
- }
- goto out;
- }
-
- ret = TRUE;
+ GError *error;
+ guint result;
+ gboolean res;
+ gboolean ret;
+
+ ret = FALSE;
+
+ if (bus_proxy == NULL) {
+ goto out;
+ }
+
+ error = NULL;
+ res = dbus_g_proxy_call (bus_proxy,
+ "RequestName",
+ &error,
+ G_TYPE_STRING, GDM_DBUS_NAME,
+ G_TYPE_UINT, 0,
+ G_TYPE_INVALID,
+ G_TYPE_UINT, &result,
+ G_TYPE_INVALID);
+ if (! res) {
+ if (error != NULL) {
+ g_warning ("Failed to acquire %s: %s", GDM_DBUS_NAME, error->message);
+ g_error_free (error);
+ } else {
+ g_warning ("Failed to acquire %s", GDM_DBUS_NAME);
+ }
+ goto out;
+ }
+
+ if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+ if (error != NULL) {
+ g_warning ("Failed to acquire %s: %s", GDM_DBUS_NAME, error->message);
+ g_error_free (error);
+ } else {
+ g_warning ("Failed to acquire %s", GDM_DBUS_NAME);
+ }
+ goto out;
+ }
+
+ ret = TRUE;
out:
- return ret;
+ return ret;
}
static DBusGConnection *
get_system_bus (void)
{
- GError *error;
- DBusGConnection *bus;
- DBusConnection *connection;
-
- error = NULL;
- bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (bus == NULL) {
- g_warning ("Couldn't connect to system bus: %s",
- error->message);
- g_error_free (error);
- goto out;
- }
-
- connection = dbus_g_connection_get_connection (bus);
- dbus_connection_set_exit_on_disconnect (connection, FALSE);
+ GError *error;
+ DBusGConnection *bus;
+ DBusConnection *connection;
+
+ error = NULL;
+ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (bus == NULL) {
+ g_warning ("Couldn't connect to system bus: %s",
+ error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ connection = dbus_g_connection_get_connection (bus);
+ dbus_connection_set_exit_on_disconnect (connection, FALSE);
out:
- return bus;
+ return bus;
}
static gboolean
bus_reconnect (GdmManager *manager)
{
- DBusGConnection *bus;
- DBusGProxy *bus_proxy;
- gboolean ret;
+ DBusGConnection *bus;
+ DBusGProxy *bus_proxy;
+ gboolean ret;
- ret = TRUE;
+ ret = TRUE;
- bus = get_system_bus ();
- if (bus == NULL) {
- goto out;
- }
+ bus = get_system_bus ();
+ if (bus == NULL) {
+ goto out;
+ }
- bus_proxy = get_bus_proxy (bus);
- if (bus_proxy == NULL) {
- g_warning ("Could not construct bus_proxy object; will retry");
- goto out;
- }
+ bus_proxy = get_bus_proxy (bus);
+ if (bus_proxy == NULL) {
+ g_warning ("Could not construct bus_proxy object; will retry");
+ goto out;
+ }
- if (! acquire_name_on_proxy (bus_proxy) ) {
- g_warning ("Could not acquire name; will retry");
- goto out;
- }
+ if (! acquire_name_on_proxy (bus_proxy) ) {
+ g_warning ("Could not acquire name; will retry");
+ goto out;
+ }
- manager = gdm_manager_new ();
- if (manager == NULL) {
- g_warning ("Could not construct manager object");
- exit (1);
- }
+ manager = gdm_manager_new ();
+ if (manager == NULL) {
+ g_warning ("Could not construct manager object");
+ exit (1);
+ }
- g_signal_connect (bus_proxy,
- "destroy",
- G_CALLBACK (bus_proxy_destroyed_cb),
- manager);
+ g_signal_connect (bus_proxy,
+ "destroy",
+ G_CALLBACK (bus_proxy_destroyed_cb),
+ manager);
- g_debug ("Successfully reconnected to D-Bus");
+ g_debug ("Successfully reconnected to D-Bus");
- ret = FALSE;
+ ret = FALSE;
out:
- return ret;
+ return ret;
}
static void
bus_proxy_destroyed_cb (DBusGProxy *bus_proxy,
- GdmManager *manager)
+ GdmManager *manager)
{
- g_debug ("Disconnected from D-Bus");
+ g_debug ("Disconnected from D-Bus");
- g_object_unref (manager);
- manager = NULL;
+ g_object_unref (manager);
+ manager = NULL;
- g_timeout_add (3000, (GSourceFunc)bus_reconnect, manager);
+ g_timeout_add (3000, (GSourceFunc)bus_reconnect, manager);
}
static void
delete_pid (void)
{
- unlink (GDM_PID_FILE);
+ unlink (GDM_PID_FILE);
}
static void
write_pid (void)
{
- int pf;
- ssize_t written;
- char pid[9];
-
- errno = 0;
- pf = open (GDM_PID_FILE, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644);
- if (pf < 0) {
- g_warning (_("Cannot write PID file %s: possibly out of diskspace: %s"),
- GDM_PID_FILE,
- g_strerror (errno));
-
- return;
- }
-
- snprintf (pid, sizeof (pid), "%lu\n", (long unsigned) getpid ());
- errno = 0;
- written = write (pf, pid, strlen (pid));
- close (pf);
-
- if (written < 0) {
- g_warning (_("Cannot write PID file %s: possibly out of diskspace: %s"),
- GDM_PID_FILE,
- g_strerror (errno));
- return;
- }
-
- g_atexit (delete_pid);
+ int pf;
+ ssize_t written;
+ char pid[9];
+
+ errno = 0;
+ pf = open (GDM_PID_FILE, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644);
+ if (pf < 0) {
+ g_warning (_("Cannot write PID file %s: possibly out of diskspace: %s"),
+ GDM_PID_FILE,
+ g_strerror (errno));
+
+ return;
+ }
+
+ snprintf (pid, sizeof (pid), "%lu\n", (long unsigned) getpid ());
+ errno = 0;
+ written = write (pf, pid, strlen (pid));
+ close (pf);
+
+ if (written < 0) {
+ g_warning (_("Cannot write PID file %s: possibly out of diskspace: %s"),
+ GDM_PID_FILE,
+ g_strerror (errno));
+ return;
+ }
+
+ g_atexit (delete_pid);
}
static void
gdm_final_cleanup (void)
{
- g_object_unref (manager);
+ g_object_unref (manager);
}
static void
main_saveenv (void)
{
- int i;
+ int i;
- g_list_foreach (stored_env, (GFunc)g_free, NULL);
- g_list_free (stored_env);
- stored_env = NULL;
+ g_list_foreach (stored_env, (GFunc)g_free, NULL);
+ g_list_free (stored_env);
+ stored_env = NULL;
- for (i = 0; environ[i] != NULL; i++) {
- char *env = environ[i];
- stored_env = g_list_prepend (stored_env, g_strdup (env));
- }
+ for (i = 0; environ[i] != NULL; i++) {
+ char *env = environ[i];
+ stored_env = g_list_prepend (stored_env, g_strdup (env));
+ }
}
static void
main_restoreenv (void)
{
- GList *li;
+ GList *li;
- ve_clearenv ();
+ ve_clearenv ();
- /* FIXME: leaks */
+ /* FIXME: leaks */
- for (li = stored_env; li != NULL; li = li->next) {
- putenv (g_strdup (li->data));
- }
+ for (li = stored_env; li != NULL; li = li->next) {
+ putenv (g_strdup (li->data));
+ }
}
static void
gdm_restart_now (void)
{
- gdm_info (_("GDM restarting ..."));
- gdm_final_cleanup ();
- main_restoreenv ();
- VE_IGNORE_EINTR (execvp (stored_argv[0], stored_argv));
- g_warning (_("Failed to restart self"));
- _exit (1);
+ gdm_info (_("GDM restarting ..."));
+ gdm_final_cleanup ();
+ main_restoreenv ();
+ VE_IGNORE_EINTR (execvp (stored_argv[0], stored_argv));
+ g_warning (_("Failed to restart self"));
+ _exit (1);
}
static void
-store_argv (int argc,
- char *argv[])
+store_argv (int argc,
+ char *argv[])
{
- int i;
-
- stored_argv = g_new0 (char *, argc + 1);
- for (i = 0; i < argc; i++) {
- stored_argv[i] = g_strdup (argv[i]);
- }
- stored_argv[i] = NULL;
- stored_argc = argc;
+ int i;
+
+ stored_argv = g_new0 (char *, argc + 1);
+ for (i = 0; i < argc; i++) {
+ stored_argv[i] = g_strdup (argv[i]);
+ }
+ stored_argv[i] = NULL;
+ stored_argc = argc;
}
static void
@@ -315,9 +315,9 @@ check_logdir (void)
{
struct stat statbuf;
int r;
- const char *log_path;
+ const char *log_path;
- log_path = LOGDIR;
+ log_path = LOGDIR;
VE_IGNORE_EINTR (r = g_stat (log_path, &statbuf));
if (r < 0 || ! S_ISDIR (statbuf.st_mode)) {
@@ -327,371 +327,371 @@ check_logdir (void)
static void
check_servauthdir (const char *auth_path,
- struct stat *statbuf)
+ struct stat *statbuf)
{
- int r;
+ int r;
- /* Enter paranoia mode */
- VE_IGNORE_EINTR (r = g_stat (auth_path, statbuf));
- if G_UNLIKELY (r < 0) {
- gdm_fail (_("Authdir %s does not exist. Aborting."), auth_path);
- }
+ /* Enter paranoia mode */
+ VE_IGNORE_EINTR (r = g_stat (auth_path, statbuf));
+ if G_UNLIKELY (r < 0) {
+ gdm_fail (_("Authdir %s does not exist. Aborting."), auth_path);
+ }
- if G_UNLIKELY (! S_ISDIR (statbuf->st_mode)) {
- gdm_fail (_("Authdir %s is not a directory. Aborting."), auth_path);
- }
+ if G_UNLIKELY (! S_ISDIR (statbuf->st_mode)) {
+ gdm_fail (_("Authdir %s is not a directory. Aborting."), auth_path);
+ }
}
static void
gdm_daemon_check_permissions (uid_t uid,
- gid_t gid)
+ gid_t gid)
{
- struct stat statbuf;
- const char *auth_path;
+ struct stat statbuf;
+ const char *auth_path;
- auth_path = LOGDIR;
+ auth_path = LOGDIR;
- /* Enter paranoia mode */
- check_servauthdir (auth_path, &statbuf);
+ /* Enter paranoia mode */
+ check_servauthdir (auth_path, &statbuf);
- NEVER_FAILS_root_set_euid_egid (0, 0);
+ NEVER_FAILS_root_set_euid_egid (0, 0);
- /* Now set things up for us as */
- chown (auth_path, 0, gid);
- g_chmod (auth_path, (S_IRWXU|S_IRWXG|S_ISVTX));
+ /* Now set things up for us as */
+ chown (auth_path, 0, gid);
+ g_chmod (auth_path, (S_IRWXU|S_IRWXG|S_ISVTX));
- NEVER_FAILS_root_set_euid_egid (uid, gid);
+ NEVER_FAILS_root_set_euid_egid (uid, gid);
- /* Again paranoid */
- check_servauthdir (auth_path, &statbuf);
+ /* Again paranoid */
+ check_servauthdir (auth_path, &statbuf);
- if G_UNLIKELY (statbuf.st_uid != 0 || statbuf.st_gid != gid) {
- gdm_fail (_("Authdir %s is not owned by user %d, group %d. Aborting."),
- auth_path,
- (int)uid,
- (int)gid);
- }
+ if G_UNLIKELY (statbuf.st_uid != 0 || statbuf.st_gid != gid) {
+ gdm_fail (_("Authdir %s is not owned by user %d, group %d. Aborting."),
+ auth_path,
+ (int)uid,
+ (int)gid);
+ }
- if G_UNLIKELY (statbuf.st_mode != (S_IFDIR|S_IRWXU|S_IRWXG|S_ISVTX)) {
- gdm_fail (_("Authdir %s has wrong permissions %o. Should be %o. Aborting."),
- auth_path,
- statbuf.st_mode,
- (S_IRWXU|S_IRWXG|S_ISVTX));
- }
+ if G_UNLIKELY (statbuf.st_mode != (S_IFDIR|S_IRWXU|S_IRWXG|S_ISVTX)) {
+ gdm_fail (_("Authdir %s has wrong permissions %o. Should be %o. Aborting."),
+ auth_path,
+ statbuf.st_mode,
+ (S_IRWXU|S_IRWXG|S_ISVTX));
+ }
}
static void
gdm_daemon_change_user (uid_t *uidp,
- gid_t *gidp)
+ gid_t *gidp)
{
- char *username;
- char *groupname;
- uid_t uid;
- gid_t gid;
- struct passwd *pwent;
- struct group *grent;
-
- username = NULL;
- groupname = NULL;
- uid = 0;
- gid = 0;
-
- gdm_settings_direct_get_string (GDM_KEY_USER, &username);
- gdm_settings_direct_get_string (GDM_KEY_GROUP, &groupname);
-
- if (username == NULL || groupname == NULL) {
- return;
- }
-
- g_debug ("Changing user:group to %s:%s", username, groupname);
-
- /* Lookup user and groupid for the GDM user */
- pwent = getpwnam (username);
-
- /* Set uid and gid */
- if G_UNLIKELY (pwent == NULL) {
- gdm_fail (_("Can't find the GDM user '%s'. Aborting!"), username);
- } else {
- uid = pwent->pw_uid;
- }
-
- if G_UNLIKELY (uid == 0) {
- gdm_fail (_("The GDM user should not be root. Aborting!"));
- }
-
- grent = getgrnam (groupname);
-
- if G_UNLIKELY (grent == NULL) {
- gdm_fail (_("Can't find the GDM group '%s'. Aborting!"), groupname);
- } else {
- gid = grent->gr_gid;
- }
-
- if G_UNLIKELY (gid == 0) {
- gdm_fail (_("The GDM group should not be root. Aborting!"));
- }
-
- /* gid remains `gdm' */
- NEVER_FAILS_root_set_euid_egid (uid, gid);
-
- if (uidp != NULL) {
- *uidp = uid;
- }
-
- if (gidp != NULL) {
- *gidp = gid;
- }
-
- g_free (username);
- g_free (groupname);
+ char *username;
+ char *groupname;
+ uid_t uid;
+ gid_t gid;
+ struct passwd *pwent;
+ struct group *grent;
+
+ username = NULL;
+ groupname = NULL;
+ uid = 0;
+ gid = 0;
+
+ gdm_settings_direct_get_string (GDM_KEY_USER, &username);
+ gdm_settings_direct_get_string (GDM_KEY_GROUP, &groupname);
+
+ if (username == NULL || groupname == NULL) {
+ return;
+ }
+
+ g_debug ("Changing user:group to %s:%s", username, groupname);
+
+ /* Lookup user and groupid for the GDM user */
+ pwent = getpwnam (username);
+
+ /* Set uid and gid */
+ if G_UNLIKELY (pwent == NULL) {
+ gdm_fail (_("Can't find the GDM user '%s'. Aborting!"), username);
+ } else {
+ uid = pwent->pw_uid;
+ }
+
+ if G_UNLIKELY (uid == 0) {
+ gdm_fail (_("The GDM user should not be root. Aborting!"));
+ }
+
+ grent = getgrnam (groupname);
+
+ if G_UNLIKELY (grent == NULL) {
+ gdm_fail (_("Can't find the GDM group '%s'. Aborting!"), groupname);
+ } else {
+ gid = grent->gr_gid;
+ }
+
+ if G_UNLIKELY (gid == 0) {
+ gdm_fail (_("The GDM group should not be root. Aborting!"));
+ }
+
+ /* gid remains `gdm' */
+ NEVER_FAILS_root_set_euid_egid (uid, gid);
+
+ if (uidp != NULL) {
+ *uidp = uid;
+ }
+
+ if (gidp != NULL) {
+ *gidp = gid;
+ }
+
+ g_free (username);
+ g_free (groupname);
}
static gboolean
signal_cb (int signo,
- gpointer data)
+ gpointer data)
{
- int ret;
+ int ret;
- g_debug ("Got callback for signal %d", signo);
+ g_debug ("Got callback for signal %d", signo);
- ret = TRUE;
+ ret = TRUE;
- switch (signo) {
- case SIGSEGV:
- case SIGBUS:
- case SIGILL:
- case SIGABRT:
- g_debug ("Caught signal %d.", signo);
+ switch (signo) {
+ case SIGSEGV:
+ case SIGBUS:
+ case SIGILL:
+ case SIGABRT:
+ g_debug ("Caught signal %d.", signo);
- ret = FALSE;
- break;
+ ret = FALSE;
+ break;
- case SIGFPE:
- case SIGPIPE:
- /* let the fatal signals interrupt us */
- g_debug ("Caught signal %d, shutting down abnormally.", signo);
- ret = FALSE;
+ case SIGFPE:
+ case SIGPIPE:
+ /* let the fatal signals interrupt us */
+ g_debug ("Caught signal %d, shutting down abnormally.", signo);
+ ret = FALSE;
- break;
+ break;
- case SIGINT:
- case SIGTERM:
- /* let the fatal signals interrupt us */
- g_debug ("Caught signal %d, shutting down normally.", signo);
- ret = FALSE;
+ case SIGINT:
+ case SIGTERM:
+ /* let the fatal signals interrupt us */
+ g_debug ("Caught signal %d, shutting down normally.", signo);
+ ret = FALSE;
- break;
+ break;
- case SIGHUP:
- g_debug ("Got HUP signal");
- /* FIXME:
- * Reread config stuff like system config files, VPN service files, etc
- */
- ret = TRUE;
+ case SIGHUP:
+ g_debug ("Got HUP signal");
+ /* FIXME:
+ * Reread config stuff like system config files, VPN service files, etc
+ */
+ ret = TRUE;
- break;
+ break;
- case SIGUSR1:
- g_debug ("Got USR1 signal");
- /* FIXME:
- * Play with log levels or something
- */
- ret = TRUE;
+ case SIGUSR1:
+ g_debug ("Got USR1 signal");
+ /* FIXME:
+ * Play with log levels or something
+ */
+ ret = TRUE;
- gdm_log_toggle_debug ();
+ gdm_log_toggle_debug ();
- break;
+ break;
- default:
- g_debug ("Caught unhandled signal %d", signo);
- ret = TRUE;
+ default:
+ g_debug ("Caught unhandled signal %d", signo);
+ ret = TRUE;
- break;
- }
+ break;
+ }
- return ret;
+ return ret;
}
int
main (int argc,
char **argv)
{
- GMainLoop *main_loop;
- GOptionContext *context;
- DBusGProxy *bus_proxy;
- DBusGConnection *connection;
- GError *error;
- int ret;
- int i;
- gboolean res;
- GdmSignalHandler *signal_handler;
- static char *config_file = NULL;
- static gboolean debug = FALSE;
- static gboolean no_daemon = FALSE;
- static gboolean no_console = FALSE;
- static gboolean do_timed_exit = FALSE;
- static gboolean print_version = FALSE;
- static gboolean fatal_warnings = FALSE;
- static GOptionEntry entries [] = {
- { "config", 0, 0, G_OPTION_ARG_STRING, &config_file, N_("Alternative GDM System Defaults configuration file"), N_("CONFIGFILE") },
-
- { "debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debugging code"), NULL },
- { "fatal-warnings", 0, 0, G_OPTION_ARG_NONE, &fatal_warnings, N_("Make all warnings fatal"), NULL },
- { "no-daemon", 0, 0, G_OPTION_ARG_NONE, &no_daemon, N_("Don't become a daemon"), NULL },
- { "no-console", 0, 0, G_OPTION_ARG_NONE, &no_console, N_("No console (static) servers to be run"), NULL },
-
- { "timed-exit", 0, 0, G_OPTION_ARG_NONE, &do_timed_exit, N_("Exit after a time - for debugging"), NULL },
- { "version", 0, 0, G_OPTION_ARG_NONE, &print_version, N_("Print GDM version"), NULL },
-
- { NULL }
- };
-
- bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
- textdomain (GETTEXT_PACKAGE);
- setlocale (LC_ALL, "");
-
- ret = 1;
-
- g_type_init ();
-
- store_argv (argc, argv);
- main_saveenv ();
-
- context = g_option_context_new (_("GNOME Display Manager"));
- g_option_context_add_main_entries (context, entries, NULL);
-
- /* preprocess the arguments to support the xdm style -nodaemon
- * option
- */
- for (i = 0; i < argc; i++) {
- if (strcmp (argv[i], "-nodaemon") == 0) {
- argv[i] = (char *) "--no-daemon";
- }
- }
-
- error = NULL;
- res = g_option_context_parse (context, &argc, &argv, &error);
- g_option_context_free (context);
- if (! res) {
- g_warning ("%s", error->message);
- g_error_free (error);
- goto out;
- }
-
- if (fatal_warnings) {
- GLogLevelFlags fatal_mask;
-
- fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
- fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
- g_log_set_always_fatal (fatal_mask);
- }
-
- if (! no_daemon && daemon (0, 0)) {
- g_error ("Could not daemonize: %s", g_strerror (errno));
- }
-
- connection = get_system_bus ();
- if (connection == NULL) {
- goto out;
- }
-
- bus_proxy = get_bus_proxy (connection);
- if (bus_proxy == NULL) {
- g_warning ("Could not construct bus_proxy object; bailing out");
- goto out;
- }
-
- if (! acquire_name_on_proxy (bus_proxy) ) {
- g_warning ("Could not acquire name; bailing out");
- goto out;
- }
-
- gdm_log_init ();
-
- settings = gdm_settings_new ();
- if (settings == NULL) {
- g_warning ("Unable to initialize settings");
- goto out;
+ GMainLoop *main_loop;
+ GOptionContext *context;
+ DBusGProxy *bus_proxy;
+ DBusGConnection *connection;
+ GError *error;
+ int ret;
+ int i;
+ gboolean res;
+ GdmSignalHandler *signal_handler;
+ static char *config_file = NULL;
+ static gboolean debug = FALSE;
+ static gboolean no_daemon = FALSE;
+ static gboolean no_console = FALSE;
+ static gboolean do_timed_exit = FALSE;
+ static gboolean print_version = FALSE;
+ static gboolean fatal_warnings = FALSE;
+ static GOptionEntry entries [] = {
+ { "config", 0, 0, G_OPTION_ARG_STRING, &config_file, N_("Alternative GDM System Defaults configuration file"), N_("CONFIGFILE") },
+
+ { "debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debugging code"), NULL },
+ { "fatal-warnings", 0, 0, G_OPTION_ARG_NONE, &fatal_warnings, N_("Make all warnings fatal"), NULL },
+ { "no-daemon", 0, 0, G_OPTION_ARG_NONE, &no_daemon, N_("Don't become a daemon"), NULL },
+ { "no-console", 0, 0, G_OPTION_ARG_NONE, &no_console, N_("No console (static) servers to be run"), NULL },
+
+ { "timed-exit", 0, 0, G_OPTION_ARG_NONE, &do_timed_exit, N_("Exit after a time - for debugging"), NULL },
+ { "version", 0, 0, G_OPTION_ARG_NONE, &print_version, N_("Print GDM version"), NULL },
+
+ { NULL }
+ };
+
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ textdomain (GETTEXT_PACKAGE);
+ setlocale (LC_ALL, "");
+
+ ret = 1;
+
+ g_type_init ();
+
+ store_argv (argc, argv);
+ main_saveenv ();
+
+ context = g_option_context_new (_("GNOME Display Manager"));
+ g_option_context_add_main_entries (context, entries, NULL);
+
+ /* preprocess the arguments to support the xdm style -nodaemon
+ * option
+ */
+ for (i = 0; i < argc; i++) {
+ if (strcmp (argv[i], "-nodaemon") == 0) {
+ argv[i] = (char *) "--no-daemon";
+ }
}
- if (! gdm_settings_direct_init (settings, GDMCONFDIR "/gdm.schemas", "/")) {
- g_warning ("Unable to initialize settings");
- goto out;
+ error = NULL;
+ res = g_option_context_parse (context, &argc, &argv, &error);
+ g_option_context_free (context);
+ if (! res) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ goto out;
}
- gdm_log_set_debug (debug);
+ if (fatal_warnings) {
+ GLogLevelFlags fatal_mask;
- gdm_daemon_change_user (&gdm_uid, &gdm_gid);
- gdm_daemon_check_permissions (gdm_uid, gdm_gid);
- NEVER_FAILS_root_set_euid_egid (0, 0);
- check_logdir ();
+ fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
+ fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
+ g_log_set_always_fatal (fatal_mask);
+ }
- /* XDM compliant error message */
- if (getuid () != 0) {
- /* make sure the pid file doesn't get wiped */
- g_warning (_("Only root wants to run GDM"));
- exit (-1);
- }
+ if (! no_daemon && daemon (0, 0)) {
+ g_error ("Could not daemonize: %s", g_strerror (errno));
+ }
- /* pid file */
- delete_pid ();
- write_pid ();
+ connection = get_system_bus ();
+ if (connection == NULL) {
+ goto out;
+ }
- g_chdir (AUTHDIR);
+ bus_proxy = get_bus_proxy (connection);
+ if (bus_proxy == NULL) {
+ g_warning ("Could not construct bus_proxy object; bailing out");
+ goto out;
+ }
+
+ if (! acquire_name_on_proxy (bus_proxy) ) {
+ g_warning ("Could not acquire name; bailing out");
+ goto out;
+ }
+
+ gdm_log_init ();
+
+ settings = gdm_settings_new ();
+ if (settings == NULL) {
+ g_warning ("Unable to initialize settings");
+ goto out;
+ }
+
+ if (! gdm_settings_direct_init (settings, GDMCONFDIR "/gdm.schemas", "/")) {
+ g_warning ("Unable to initialize settings");
+ goto out;
+ }
+
+ gdm_log_set_debug (debug);
- manager = gdm_manager_new ();
+ gdm_daemon_change_user (&gdm_uid, &gdm_gid);
+ gdm_daemon_check_permissions (gdm_uid, gdm_gid);
+ NEVER_FAILS_root_set_euid_egid (0, 0);
+ check_logdir ();
- if (manager == NULL) {
- goto out;
- }
+ /* XDM compliant error message */
+ if (getuid () != 0) {
+ /* make sure the pid file doesn't get wiped */
+ g_warning (_("Only root wants to run GDM"));
+ exit (-1);
+ }
- /* FIXME: pull from settings */
- gdm_manager_set_xdmcp_enabled (manager, TRUE);
+ /* pid file */
+ delete_pid ();
+ write_pid ();
- g_signal_connect (bus_proxy,
- "destroy",
- G_CALLBACK (bus_proxy_destroyed_cb),
- manager);
+ g_chdir (AUTHDIR);
- main_loop = g_main_loop_new (NULL, FALSE);
+ manager = gdm_manager_new ();
- signal_handler = gdm_signal_handler_new ();
- gdm_signal_handler_set_main_loop (signal_handler, main_loop);
- gdm_signal_handler_add (signal_handler, SIGTERM, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGINT, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGILL, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGBUS, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGFPE, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGHUP, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGSEGV, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGABRT, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGUSR1, signal_cb, NULL);
+ if (manager == NULL) {
+ goto out;
+ }
- if (do_timed_exit) {
- g_timeout_add (1000 * 30, (GSourceFunc) timed_exit_cb, main_loop);
- }
+ /* FIXME: pull from settings */
+ gdm_manager_set_xdmcp_enabled (manager, TRUE);
+
+ g_signal_connect (bus_proxy,
+ "destroy",
+ G_CALLBACK (bus_proxy_destroyed_cb),
+ manager);
+
+ main_loop = g_main_loop_new (NULL, FALSE);
+
+ signal_handler = gdm_signal_handler_new ();
+ gdm_signal_handler_set_main_loop (signal_handler, main_loop);
+ gdm_signal_handler_add (signal_handler, SIGTERM, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGINT, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGILL, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGBUS, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGFPE, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGHUP, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGSEGV, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGABRT, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGUSR1, signal_cb, NULL);
+
+ if (do_timed_exit) {
+ g_timeout_add (1000 * 30, (GSourceFunc) timed_exit_cb, main_loop);
+ }
- gdm_manager_start (manager);
+ gdm_manager_start (manager);
- g_main_loop_run (main_loop);
+ g_main_loop_run (main_loop);
- if (manager != NULL) {
- g_object_unref (manager);
- }
+ if (manager != NULL) {
+ g_object_unref (manager);
+ }
- if (settings != NULL) {
- g_object_unref (settings);
- }
+ if (settings != NULL) {
+ g_object_unref (settings);
+ }
- if (signal_handler != NULL) {
- g_object_unref (signal_handler);
- }
+ if (signal_handler != NULL) {
+ g_object_unref (signal_handler);
+ }
- g_main_loop_unref (main_loop);
+ g_main_loop_unref (main_loop);
- ret = 0;
+ ret = 0;
out:
- return ret;
+ return ret;
}
diff --git a/daemon/product-slave-main.c b/daemon/product-slave-main.c
index 0c626300..4f5a0651 100644
--- a/daemon/product-slave-main.c
+++ b/daemon/product-slave-main.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -48,181 +48,181 @@ static int gdm_return_code = 0;
static DBusGConnection *
get_system_bus (void)
{
- GError *error;
- DBusGConnection *bus;
- DBusConnection *connection;
-
- error = NULL;
- bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (bus == NULL) {
- g_warning ("Couldn't connect to system bus: %s",
- error->message);
- g_error_free (error);
- goto out;
- }
-
- connection = dbus_g_connection_get_connection (bus);
- dbus_connection_set_exit_on_disconnect (connection, FALSE);
+ GError *error;
+ DBusGConnection *bus;
+ DBusConnection *connection;
+
+ error = NULL;
+ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (bus == NULL) {
+ g_warning ("Couldn't connect to system bus: %s",
+ error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ connection = dbus_g_connection_get_connection (bus);
+ dbus_connection_set_exit_on_disconnect (connection, FALSE);
out:
- return bus;
+ return bus;
}
static gboolean
signal_cb (int signo,
- gpointer data)
+ gpointer data)
{
- int ret;
+ int ret;
- g_debug ("Got callback for signal %d", signo);
+ g_debug ("Got callback for signal %d", signo);
- ret = TRUE;
+ ret = TRUE;
- switch (signo) {
- case SIGSEGV:
- case SIGBUS:
- case SIGILL:
- case SIGABRT:
- g_debug ("Caught signal %d.", signo);
+ switch (signo) {
+ case SIGSEGV:
+ case SIGBUS:
+ case SIGILL:
+ case SIGABRT:
+ g_debug ("Caught signal %d.", signo);
- ret = FALSE;
- break;
+ ret = FALSE;
+ break;
- case SIGFPE:
- case SIGPIPE:
- /* let the fatal signals interrupt us */
- g_debug ("Caught signal %d, shutting down abnormally.", signo);
- ret = FALSE;
+ case SIGFPE:
+ case SIGPIPE:
+ /* let the fatal signals interrupt us */
+ g_debug ("Caught signal %d, shutting down abnormally.", signo);
+ ret = FALSE;
- break;
+ break;
- case SIGINT:
- case SIGTERM:
- /* let the fatal signals interrupt us */
- g_debug ("Caught signal %d, shutting down normally.", signo);
- ret = FALSE;
+ case SIGINT:
+ case SIGTERM:
+ /* let the fatal signals interrupt us */
+ g_debug ("Caught signal %d, shutting down normally.", signo);
+ ret = FALSE;
- break;
+ break;
- case SIGHUP:
- g_debug ("Got HUP signal");
- /* FIXME:
- * Reread config stuff like system config files, VPN service files, etc
- */
- ret = TRUE;
+ case SIGHUP:
+ g_debug ("Got HUP signal");
+ /* FIXME:
+ * Reread config stuff like system config files, VPN service files, etc
+ */
+ ret = TRUE;
- break;
+ break;
- case SIGUSR1:
- g_debug ("Got USR1 signal");
- /* FIXME:
- * Play with log levels or something
- */
- ret = TRUE;
+ case SIGUSR1:
+ g_debug ("Got USR1 signal");
+ /* FIXME:
+ * Play with log levels or something
+ */
+ ret = TRUE;
- break;
+ break;
- default:
- g_debug ("Caught unhandled signal %d", signo);
- ret = TRUE;
+ default:
+ g_debug ("Caught unhandled signal %d", signo);
+ ret = TRUE;
- break;
- }
+ break;
+ }
- return ret;
+ return ret;
}
static void
on_slave_stopped (GdmSlave *slave,
- GMainLoop *main_loop)
+ GMainLoop *main_loop)
{
- g_debug ("slave finished");
- gdm_return_code = 0;
- g_main_loop_quit (main_loop);
+ g_debug ("slave finished");
+ gdm_return_code = 0;
+ g_main_loop_quit (main_loop);
}
int
main (int argc,
char **argv)
{
- GMainLoop *main_loop;
- GOptionContext *context;
- DBusGConnection *connection;
- GdmSlave *slave;
- static char *display_id = NULL;
- GdmSignalHandler *signal_handler;
- static GOptionEntry entries [] = {
- { "display-id", 0, 0, G_OPTION_ARG_STRING, &display_id, N_("Display ID"), N_("id") },
- { NULL }
- };
-
- bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
- textdomain (GETTEXT_PACKAGE);
- setlocale (LC_ALL, "");
-
- g_type_init ();
-
- context = g_option_context_new (_("GNOME Display Manager Slave"));
- g_option_context_add_main_entries (context, entries, NULL);
-
- g_option_context_parse (context, &argc, &argv, NULL);
- g_option_context_free (context);
-
- connection = get_system_bus ();
- if (connection == NULL) {
- goto out;
- }
-
- gdm_log_init ();
-
- gdm_log_set_debug (TRUE);
-
- if (display_id == NULL) {
- g_critical ("No display ID set");
- exit (1);
- }
-
- main_loop = g_main_loop_new (NULL, FALSE);
-
- signal_handler = gdm_signal_handler_new ();
- gdm_signal_handler_set_main_loop (signal_handler, main_loop);
- gdm_signal_handler_add (signal_handler, SIGTERM, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGINT, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGILL, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGBUS, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGFPE, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGHUP, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGSEGV, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGABRT, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGUSR1, signal_cb, NULL);
-
- slave = gdm_product_slave_new (display_id);
- if (slave == NULL) {
- goto out;
- }
- g_signal_connect (slave,
- "stopped",
- G_CALLBACK (on_slave_stopped),
- main_loop);
- gdm_slave_start (slave);
-
- g_main_loop_run (main_loop);
-
- if (slave != NULL) {
- g_object_unref (slave);
- }
-
- if (signal_handler != NULL) {
- g_object_unref (signal_handler);
- }
-
- if (main_loop != NULL) {
- g_main_loop_unref (main_loop);
- }
+ GMainLoop *main_loop;
+ GOptionContext *context;
+ DBusGConnection *connection;
+ GdmSlave *slave;
+ static char *display_id = NULL;
+ GdmSignalHandler *signal_handler;
+ static GOptionEntry entries [] = {
+ { "display-id", 0, 0, G_OPTION_ARG_STRING, &display_id, N_("Display ID"), N_("id") },
+ { NULL }
+ };
+
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ textdomain (GETTEXT_PACKAGE);
+ setlocale (LC_ALL, "");
+
+ g_type_init ();
+
+ context = g_option_context_new (_("GNOME Display Manager Slave"));
+ g_option_context_add_main_entries (context, entries, NULL);
+
+ g_option_context_parse (context, &argc, &argv, NULL);
+ g_option_context_free (context);
+
+ connection = get_system_bus ();
+ if (connection == NULL) {
+ goto out;
+ }
+
+ gdm_log_init ();
+
+ gdm_log_set_debug (TRUE);
+
+ if (display_id == NULL) {
+ g_critical ("No display ID set");
+ exit (1);
+ }
+
+ main_loop = g_main_loop_new (NULL, FALSE);
+
+ signal_handler = gdm_signal_handler_new ();
+ gdm_signal_handler_set_main_loop (signal_handler, main_loop);
+ gdm_signal_handler_add (signal_handler, SIGTERM, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGINT, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGILL, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGBUS, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGFPE, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGHUP, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGSEGV, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGABRT, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGUSR1, signal_cb, NULL);
+
+ slave = gdm_product_slave_new (display_id);
+ if (slave == NULL) {
+ goto out;
+ }
+ g_signal_connect (slave,
+ "stopped",
+ G_CALLBACK (on_slave_stopped),
+ main_loop);
+ gdm_slave_start (slave);
+
+ g_main_loop_run (main_loop);
+
+ if (slave != NULL) {
+ g_object_unref (slave);
+ }
+
+ if (signal_handler != NULL) {
+ g_object_unref (signal_handler);
+ }
+
+ if (main_loop != NULL) {
+ g_main_loop_unref (main_loop);
+ }
out:
- g_debug ("Slave finished");
+ g_debug ("Slave finished");
- return gdm_return_code;
+ return gdm_return_code;
}
diff --git a/daemon/session-worker-main.c b/daemon/session-worker-main.c
index d435faa2..2a52e03c 100644
--- a/daemon/session-worker-main.c
+++ b/daemon/session-worker-main.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -48,133 +48,133 @@
static gboolean
signal_cb (int signo,
- gpointer data)
+ gpointer data)
{
- int ret;
+ int ret;
- g_debug ("Got callback for signal %d", signo);
+ g_debug ("Got callback for signal %d", signo);
- ret = TRUE;
+ ret = TRUE;
- switch (signo) {
- case SIGSEGV:
- case SIGBUS:
- case SIGILL:
- case SIGABRT:
- g_debug ("Caught signal %d.", signo);
+ switch (signo) {
+ case SIGSEGV:
+ case SIGBUS:
+ case SIGILL:
+ case SIGABRT:
+ g_debug ("Caught signal %d.", signo);
- ret = FALSE;
- break;
+ ret = FALSE;
+ break;
- case SIGFPE:
- case SIGPIPE:
- /* let the fatal signals interrupt us */
- g_debug ("Caught signal %d, shutting down abnormally.", signo);
- ret = FALSE;
+ case SIGFPE:
+ case SIGPIPE:
+ /* let the fatal signals interrupt us */
+ g_debug ("Caught signal %d, shutting down abnormally.", signo);
+ ret = FALSE;
- break;
+ break;
- case SIGINT:
- case SIGTERM:
- /* let the fatal signals interrupt us */
- g_debug ("Caught signal %d, shutting down normally.", signo);
- ret = FALSE;
+ case SIGINT:
+ case SIGTERM:
+ /* let the fatal signals interrupt us */
+ g_debug ("Caught signal %d, shutting down normally.", signo);
+ ret = FALSE;
- break;
+ break;
- case SIGHUP:
- g_debug ("Got HUP signal");
- /* FIXME:
- * Reread config stuff like system config files, VPN service files, etc
- */
- ret = TRUE;
+ case SIGHUP:
+ g_debug ("Got HUP signal");
+ /* FIXME:
+ * Reread config stuff like system config files, VPN service files, etc
+ */
+ ret = TRUE;
- break;
+ break;
- case SIGUSR1:
- g_debug ("Got USR1 signal");
- /* FIXME:
- * Play with log levels or something
- */
- ret = TRUE;
+ case SIGUSR1:
+ g_debug ("Got USR1 signal");
+ /* FIXME:
+ * Play with log levels or something
+ */
+ ret = TRUE;
- break;
+ break;
- default:
- g_debug ("Caught unhandled signal %d", signo);
- ret = TRUE;
+ default:
+ g_debug ("Caught unhandled signal %d", signo);
+ ret = TRUE;
- break;
- }
+ break;
+ }
- return ret;
+ return ret;
}
int
main (int argc,
char **argv)
{
- GMainLoop *main_loop;
- GOptionContext *context;
- GdmSessionWorker *worker;
- GdmSignalHandler *signal_handler;
- const char *address;
- static GOptionEntry entries [] = {
- { NULL }
- };
+ GMainLoop *main_loop;
+ GOptionContext *context;
+ GdmSessionWorker *worker;
+ GdmSignalHandler *signal_handler;
+ const char *address;
+ static GOptionEntry entries [] = {
+ { NULL }
+ };
- bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
- textdomain (GETTEXT_PACKAGE);
- setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ textdomain (GETTEXT_PACKAGE);
+ setlocale (LC_ALL, "");
- g_type_init ();
+ g_type_init ();
- context = g_option_context_new (_("GNOME Display Manager Session Worker"));
- g_option_context_add_main_entries (context, entries, NULL);
+ context = g_option_context_new (_("GNOME Display Manager Session Worker"));
+ g_option_context_add_main_entries (context, entries, NULL);
- g_option_context_parse (context, &argc, &argv, NULL);
- g_option_context_free (context);
+ g_option_context_parse (context, &argc, &argv, NULL);
+ g_option_context_free (context);
- gdm_log_init ();
- gdm_log_set_debug (TRUE);
+ gdm_log_init ();
+ gdm_log_set_debug (TRUE);
- address = g_getenv ("GDM_SESSION_DBUS_ADDRESS");
- if (address == NULL) {
- g_warning ("GDM_SESSION_DBUS_ADDRESS not set");
- exit (1);
- }
+ address = g_getenv ("GDM_SESSION_DBUS_ADDRESS");
+ if (address == NULL) {
+ g_warning ("GDM_SESSION_DBUS_ADDRESS not set");
+ exit (1);
+ }
- worker = gdm_session_worker_new (address);
+ worker = gdm_session_worker_new (address);
- main_loop = g_main_loop_new (NULL, FALSE);
+ main_loop = g_main_loop_new (NULL, FALSE);
- signal_handler = gdm_signal_handler_new ();
- gdm_signal_handler_set_main_loop (signal_handler, main_loop);
- gdm_signal_handler_add (signal_handler, SIGTERM, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGINT, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGILL, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGBUS, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGFPE, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGHUP, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGSEGV, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGABRT, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGUSR1, signal_cb, NULL);
+ signal_handler = gdm_signal_handler_new ();
+ gdm_signal_handler_set_main_loop (signal_handler, main_loop);
+ gdm_signal_handler_add (signal_handler, SIGTERM, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGINT, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGILL, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGBUS, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGFPE, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGHUP, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGSEGV, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGABRT, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGUSR1, signal_cb, NULL);
- g_main_loop_run (main_loop);
+ g_main_loop_run (main_loop);
- if (worker != NULL) {
- g_object_unref (worker);
- }
+ if (worker != NULL) {
+ g_object_unref (worker);
+ }
- if (signal_handler != NULL) {
- g_object_unref (signal_handler);
- }
+ if (signal_handler != NULL) {
+ g_object_unref (signal_handler);
+ }
- g_main_loop_unref (main_loop);
+ g_main_loop_unref (main_loop);
out:
- g_debug ("Worker finished");
+ g_debug ("Worker finished");
- return 0;
+ return 0;
}
diff --git a/daemon/simple-slave-main.c b/daemon/simple-slave-main.c
index 34e79dd2..f020be42 100644
--- a/daemon/simple-slave-main.c
+++ b/daemon/simple-slave-main.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -48,179 +48,179 @@ static int gdm_return_code = 0;
static DBusGConnection *
get_system_bus (void)
{
- GError *error;
- DBusGConnection *bus;
- DBusConnection *connection;
-
- error = NULL;
- bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (bus == NULL) {
- g_warning ("Couldn't connect to system bus: %s",
- error->message);
- g_error_free (error);
- goto out;
- }
-
- connection = dbus_g_connection_get_connection (bus);
- dbus_connection_set_exit_on_disconnect (connection, FALSE);
+ GError *error;
+ DBusGConnection *bus;
+ DBusConnection *connection;
+
+ error = NULL;
+ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (bus == NULL) {
+ g_warning ("Couldn't connect to system bus: %s",
+ error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ connection = dbus_g_connection_get_connection (bus);
+ dbus_connection_set_exit_on_disconnect (connection, FALSE);
out:
- return bus;
+ return bus;
}
static gboolean
signal_cb (int signo,
- gpointer data)
+ gpointer data)
{
- int ret;
+ int ret;
- g_debug ("Got callback for signal %d", signo);
+ g_debug ("Got callback for signal %d", signo);
- ret = TRUE;
+ ret = TRUE;
- switch (signo) {
- case SIGSEGV:
- case SIGBUS:
- case SIGILL:
- case SIGABRT:
- g_debug ("Caught signal %d.", signo);
+ switch (signo) {
+ case SIGSEGV:
+ case SIGBUS:
+ case SIGILL:
+ case SIGABRT:
+ g_debug ("Caught signal %d.", signo);
- ret = FALSE;
- break;
+ ret = FALSE;
+ break;
- case SIGFPE:
- case SIGPIPE:
- /* let the fatal signals interrupt us */
- g_debug ("Caught signal %d, shutting down abnormally.", signo);
- ret = FALSE;
+ case SIGFPE:
+ case SIGPIPE:
+ /* let the fatal signals interrupt us */
+ g_debug ("Caught signal %d, shutting down abnormally.", signo);
+ ret = FALSE;
- break;
+ break;
- case SIGINT:
- case SIGTERM:
- /* let the fatal signals interrupt us */
- g_debug ("Caught signal %d, shutting down normally.", signo);
- ret = FALSE;
+ case SIGINT:
+ case SIGTERM:
+ /* let the fatal signals interrupt us */
+ g_debug ("Caught signal %d, shutting down normally.", signo);
+ ret = FALSE;
- break;
+ break;
- case SIGHUP:
- g_debug ("Got HUP signal");
- /* FIXME:
- * Reread config stuff like system config files, VPN service files, etc
- */
- ret = TRUE;
+ case SIGHUP:
+ g_debug ("Got HUP signal");
+ /* FIXME:
+ * Reread config stuff like system config files, VPN service files, etc
+ */
+ ret = TRUE;
- break;
+ break;
- case SIGUSR1:
- g_debug ("Got USR1 signal");
- /* FIXME:
- * Play with log levels or something
- */
- ret = TRUE;
+ case SIGUSR1:
+ g_debug ("Got USR1 signal");
+ /* FIXME:
+ * Play with log levels or something
+ */
+ ret = TRUE;
- break;
+ break;
- default:
- g_debug ("Caught unhandled signal %d", signo);
- ret = TRUE;
+ default:
+ g_debug ("Caught unhandled signal %d", signo);
+ ret = TRUE;
- break;
- }
+ break;
+ }
- return ret;
+ return ret;
}
static void
on_slave_stopped (GdmSlave *slave,
- GMainLoop *main_loop)
+ GMainLoop *main_loop)
{
- g_debug ("slave finished");
- gdm_return_code = 0;
- g_main_loop_quit (main_loop);
+ g_debug ("slave finished");
+ gdm_return_code = 0;
+ g_main_loop_quit (main_loop);
}
int
main (int argc,
char **argv)
{
- GMainLoop *main_loop;
- GOptionContext *context;
- DBusGConnection *connection;
- GdmSlave *slave;
- static char *display_id = NULL;
- GdmSignalHandler *signal_handler;
- static GOptionEntry entries [] = {
- { "display-id", 0, 0, G_OPTION_ARG_STRING, &display_id, N_("Display ID"), N_("id") },
- { NULL }
- };
-
- bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
- textdomain (GETTEXT_PACKAGE);
- setlocale (LC_ALL, "");
-
- g_type_init ();
-
- context = g_option_context_new (_("GNOME Display Manager Slave"));
- g_option_context_add_main_entries (context, entries, NULL);
-
- g_option_context_parse (context, &argc, &argv, NULL);
- g_option_context_free (context);
-
- connection = get_system_bus ();
- if (connection == NULL) {
- goto out;
- }
-
- gdm_log_init ();
-
- gdm_log_set_debug (TRUE);
-
- if (display_id == NULL) {
- g_critical ("No display ID set");
- exit (1);
- }
-
- main_loop = g_main_loop_new (NULL, FALSE);
-
- signal_handler = gdm_signal_handler_new ();
- gdm_signal_handler_set_main_loop (signal_handler, main_loop);
- gdm_signal_handler_add (signal_handler, SIGTERM, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGINT, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGILL, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGBUS, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGFPE, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGHUP, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGSEGV, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGABRT, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGUSR1, signal_cb, NULL);
-
- slave = gdm_simple_slave_new (display_id);
- if (slave == NULL) {
- goto out;
- }
- g_signal_connect (slave,
- "stopped",
- G_CALLBACK (on_slave_stopped),
- main_loop);
- gdm_slave_start (slave);
-
- g_main_loop_run (main_loop);
-
- if (slave != NULL) {
- g_object_unref (slave);
- }
-
- if (signal_handler != NULL) {
- g_object_unref (signal_handler);
- }
-
- g_main_loop_unref (main_loop);
+ GMainLoop *main_loop;
+ GOptionContext *context;
+ DBusGConnection *connection;
+ GdmSlave *slave;
+ static char *display_id = NULL;
+ GdmSignalHandler *signal_handler;
+ static GOptionEntry entries [] = {
+ { "display-id", 0, 0, G_OPTION_ARG_STRING, &display_id, N_("Display ID"), N_("id") },
+ { NULL }
+ };
+
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ textdomain (GETTEXT_PACKAGE);
+ setlocale (LC_ALL, "");
+
+ g_type_init ();
+
+ context = g_option_context_new (_("GNOME Display Manager Slave"));
+ g_option_context_add_main_entries (context, entries, NULL);
+
+ g_option_context_parse (context, &argc, &argv, NULL);
+ g_option_context_free (context);
+
+ connection = get_system_bus ();
+ if (connection == NULL) {
+ goto out;
+ }
+
+ gdm_log_init ();
+
+ gdm_log_set_debug (TRUE);
+
+ if (display_id == NULL) {
+ g_critical ("No display ID set");
+ exit (1);
+ }
+
+ main_loop = g_main_loop_new (NULL, FALSE);
+
+ signal_handler = gdm_signal_handler_new ();
+ gdm_signal_handler_set_main_loop (signal_handler, main_loop);
+ gdm_signal_handler_add (signal_handler, SIGTERM, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGINT, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGILL, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGBUS, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGFPE, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGHUP, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGSEGV, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGABRT, signal_cb, NULL);
+ gdm_signal_handler_add (signal_handler, SIGUSR1, signal_cb, NULL);
+
+ slave = gdm_simple_slave_new (display_id);
+ if (slave == NULL) {
+ goto out;
+ }
+ g_signal_connect (slave,
+ "stopped",
+ G_CALLBACK (on_slave_stopped),
+ main_loop);
+ gdm_slave_start (slave);
+
+ g_main_loop_run (main_loop);
+
+ if (slave != NULL) {
+ g_object_unref (slave);
+ }
+
+ if (signal_handler != NULL) {
+ g_object_unref (signal_handler);
+ }
+
+ g_main_loop_unref (main_loop);
out:
- g_debug ("Slave finished");
+ g_debug ("Slave finished");
- return gdm_return_code;
+ return gdm_return_code;
}
diff --git a/daemon/test-hal-seats.c b/daemon/test-hal-seats.c
index 6b51a586..deb76f32 100644
--- a/daemon/test-hal-seats.c
+++ b/daemon/test-hal-seats.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -36,132 +36,132 @@ static GMainLoop *loop;
static void
get_pci_seats (DBusGConnection *bus,
- DBusGProxy *proxy,
- GList *seats)
+ DBusGProxy *proxy,
+ GList *seats)
{
- char **devices;
- const char *key;
- const char *value;
- GError *error;
- gboolean res;
- int i;
+ char **devices;
+ const char *key;
+ const char *value;
+ GError *error;
+ gboolean res;
+ int i;
- g_message ("Getting PCI seats");
+ g_message ("Getting PCI seats");
- key = "info.bus";
- value = "pci";
+ key = "info.bus";
+ value = "pci";
- devices = NULL;
- error = NULL;
+ devices = NULL;
+ error = NULL;
res = dbus_g_proxy_call (proxy,
- "FindDeviceStringMatch",
- &error,
+ "FindDeviceStringMatch",
+ &error,
G_TYPE_STRING, key,
G_TYPE_STRING, value,
G_TYPE_INVALID,
G_TYPE_STRV, &devices,
G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to query HAL: %s", error->message);
- g_error_free (error);
- }
-
- /* now look for pci class 3 */
- key = "pci.device_class";
- for (i = 0; devices [i] != NULL; i++) {
- DBusGProxy *device_proxy;
- int class_val;
-
- device_proxy = dbus_g_proxy_new_for_name (bus,
- HAL_DBUS_NAME,
- devices [i],
- HAL_DBUS_DEVICE_INTERFACE);
- if (device_proxy == NULL) {
- continue;
- }
-
- res = dbus_g_proxy_call (device_proxy,
- "GetPropertyInteger",
- &error,
- G_TYPE_STRING, key,
- G_TYPE_INVALID,
- G_TYPE_INT, &class_val,
- G_TYPE_INVALID);
- if (class_val == SEAT_PCI_DEVICE_CLASS) {
- g_message ("Found device: %s", devices [i]);
- seats = g_list_prepend (seats, devices [i]);
- }
-
- g_object_unref (device_proxy);
- }
-
- g_strfreev (devices);
+ if (! res) {
+ g_warning ("Unable to query HAL: %s", error->message);
+ g_error_free (error);
+ }
+
+ /* now look for pci class 3 */
+ key = "pci.device_class";
+ for (i = 0; devices [i] != NULL; i++) {
+ DBusGProxy *device_proxy;
+ int class_val;
+
+ device_proxy = dbus_g_proxy_new_for_name (bus,
+ HAL_DBUS_NAME,
+ devices [i],
+ HAL_DBUS_DEVICE_INTERFACE);
+ if (device_proxy == NULL) {
+ continue;
+ }
+
+ res = dbus_g_proxy_call (device_proxy,
+ "GetPropertyInteger",
+ &error,
+ G_TYPE_STRING, key,
+ G_TYPE_INVALID,
+ G_TYPE_INT, &class_val,
+ G_TYPE_INVALID);
+ if (class_val == SEAT_PCI_DEVICE_CLASS) {
+ g_message ("Found device: %s", devices [i]);
+ seats = g_list_prepend (seats, devices [i]);
+ }
+
+ g_object_unref (device_proxy);
+ }
+
+ g_strfreev (devices);
}
static void
list_seats (GList *seats)
{
- GList *l;
- for (l = seats; l != NULL; l = l->next) {
- g_message ("Found device: %s", l->data);
- }
+ GList *l;
+ for (l = seats; l != NULL; l = l->next) {
+ g_message ("Found device: %s", l->data);
+ }
}
static gboolean
test_hal_seats (void)
{
- GError *error;
- DBusGConnection *bus;
+ GError *error;
+ DBusGConnection *bus;
DBusGProxy *proxy;
- GList *seats;
+ GList *seats;
- proxy = NULL;
+ proxy = NULL;
- error = NULL;
- bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (bus == NULL) {
- g_warning ("Couldn't connect to system bus: %s",
- error->message);
- g_error_free (error);
- goto out;
- }
+ error = NULL;
+ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (bus == NULL) {
+ g_warning ("Couldn't connect to system bus: %s",
+ error->message);
+ g_error_free (error);
+ goto out;
+ }
proxy = dbus_g_proxy_new_for_name (bus,
HAL_DBUS_NAME,
HAL_DBUS_MANAGER_PATH,
HAL_DBUS_MANAGER_INTERFACE);
- if (proxy == NULL) {
- g_warning ("Couldn't create proxy for HAL Manager");
- goto out;
- }
+ if (proxy == NULL) {
+ g_warning ("Couldn't create proxy for HAL Manager");
+ goto out;
+ }
- seats = NULL;
+ seats = NULL;
- get_pci_seats (bus, proxy, seats);
+ get_pci_seats (bus, proxy, seats);
- list_seats (seats);
+ list_seats (seats);
out:
- if (proxy != NULL) {
- g_object_unref (proxy);
- }
+ if (proxy != NULL) {
+ g_object_unref (proxy);
+ }
- return FALSE;
+ return FALSE;
}
int
main (int argc,
char *argv[])
{
- g_log_set_always_fatal (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+ g_log_set_always_fatal (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
- g_type_init ();
+ g_type_init ();
g_idle_add ((GSourceFunc)test_hal_seats, NULL);
- loop = g_main_loop_new (NULL, FALSE);
- g_main_loop_run (loop);
- g_main_loop_unref (loop);
+ loop = g_main_loop_new (NULL, FALSE);
+ g_main_loop_run (loop);
+ g_main_loop_unref (loop);
- return 0;
+ return 0;
}
diff --git a/daemon/test-session.c b/daemon/test-session.c
index dfc91acd..a15dda5e 100644
--- a/daemon/test-session.c
+++ b/daemon/test-session.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -34,238 +34,238 @@ static GMainLoop *loop;
static void
on_open (GdmSession *session,
- const char *username)
+ const char *username)
{
- GError *error;
- gboolean res;
-
- g_debug ("Got opened: begin auth for %s", username);
-
- error = NULL;
- res = gdm_session_begin_verification (session,
- username,
- &error);
- if (! res) {
- g_warning ("Unable to begin verification: %s", error->message);
- g_error_free (error);
- }
+ GError *error;
+ gboolean res;
+
+ g_debug ("Got opened: begin auth for %s", username);
+
+ error = NULL;
+ res = gdm_session_begin_verification (session,
+ username,
+ &error);
+ if (! res) {
+ g_warning ("Unable to begin verification: %s", error->message);
+ g_error_free (error);
+ }
}
static void
on_session_started (GdmSession *session,
GPid pid)
{
- g_print ("session started on pid %d\n", (int) pid);
+ g_print ("session started on pid %d\n", (int) pid);
}
static void
on_session_exited (GdmSession *session,
int exit_code)
{
- g_print ("session exited with code %d\n", exit_code);
- exit (0);
+ g_print ("session exited with code %d\n", exit_code);
+ exit (0);
}
static void
on_session_died (GdmSession *session,
int signal_number)
{
- g_print ("session died with signal %d, (%s)",
- signal_number,
- g_strsignal (signal_number));
- exit (1);
+ g_print ("session died with signal %d, (%s)",
+ signal_number,
+ g_strsignal (signal_number));
+ exit (1);
}
static void
on_user_verified (GdmSession *session)
{
- char *username;
- const char *command = "/usr/bin/gedit /tmp/foo.log";
+ char *username;
+ const char *command = "/usr/bin/gedit /tmp/foo.log";
- username = gdm_session_get_username (session);
+ username = gdm_session_get_username (session);
- g_print ("%s%ssuccessfully authenticated\n",
- username ? username : "", username ? " " : "");
- g_free (username);
+ g_print ("%s%ssuccessfully authenticated\n",
+ username ? username : "", username ? " " : "");
+ g_free (username);
- gdm_session_start_program (session, command);
+ gdm_session_start_program (session, command);
}
static void
on_user_verification_error (GdmSession *session,
GError *error)
{
- char *username;
+ char *username;
- username = gdm_session_get_username (session);
+ username = gdm_session_get_username (session);
- g_print ("%s%scould not be successfully authenticated: %s\n",
- username ? username : "", username ? " " : "",
- error->message);
+ g_print ("%s%scould not be successfully authenticated: %s\n",
+ username ? username : "", username ? " " : "",
+ error->message);
- g_free (username);
- exit (1);
+ g_free (username);
+ exit (1);
}
static void
on_info_query (GdmSession *session,
const char *query_text)
{
- char answer[1024];
+ char answer[1024];
- g_print ("%s ", query_text);
+ g_print ("%s ", query_text);
- fgets (answer, sizeof (answer), stdin);
- answer[strlen(answer) - 1] = '\0';
+ fgets (answer, sizeof (answer), stdin);
+ answer[strlen(answer) - 1] = '\0';
- if (answer[0] == '\0') {
- gdm_session_close (session);
- g_main_loop_quit (loop);
- } else {
- gdm_session_answer_query (session, answer);
- }
+ if (answer[0] == '\0') {
+ gdm_session_close (session);
+ g_main_loop_quit (loop);
+ } else {
+ gdm_session_answer_query (session, answer);
+ }
}
static void
on_info (GdmSession *session,
const char *info)
{
- g_print ("\n** NOTE: %s\n", info);
+ g_print ("\n** NOTE: %s\n", info);
}
static void
on_problem (GdmSession *session,
const char *problem)
{
- g_print ("\n** WARNING: %s\n", problem);
+ g_print ("\n** WARNING: %s\n", problem);
}
static void
on_secret_info_query (GdmSession *session,
const char *query_text)
{
- char answer[1024];
- struct termios ts0;
+ char answer[1024];
+ struct termios ts0;
struct termios ts1;
tcgetattr (fileno (stdin), &ts0);
ts1 = ts0;
ts1.c_lflag &= ~ECHO;
- g_print ("%s", query_text);
+ g_print ("%s", query_text);
if (tcsetattr (fileno (stdin), TCSAFLUSH, &ts1) != 0) {
fprintf (stderr, "Could not set terminal attributes\n");
exit (1);
}
- fgets (answer, sizeof (answer), stdin);
- answer[strlen (answer) - 1] = '\0';
+ fgets (answer, sizeof (answer), stdin);
+ answer[strlen (answer) - 1] = '\0';
tcsetattr (fileno (stdin), TCSANOW, &ts0);
- g_print ("\n");
+ g_print ("\n");
- gdm_session_answer_query (session, answer);
+ gdm_session_answer_query (session, answer);
}
static void
import_environment (GdmSession *session)
{
- if (g_getenv ("PATH") != NULL)
- gdm_session_set_environment_variable (session, "PATH",
- g_getenv ("PATH"));
+ if (g_getenv ("PATH") != NULL)
+ gdm_session_set_environment_variable (session, "PATH",
+ g_getenv ("PATH"));
- if (g_getenv ("DISPLAY") != NULL)
- gdm_session_set_environment_variable (session, "DISPLAY",
- g_getenv ("DISPLAY"));
+ if (g_getenv ("DISPLAY") != NULL)
+ gdm_session_set_environment_variable (session, "DISPLAY",
+ g_getenv ("DISPLAY"));
- if (g_getenv ("XAUTHORITY") != NULL)
- gdm_session_set_environment_variable (session, "XAUTHORITY",
- g_getenv ("XAUTHORITY"));
+ if (g_getenv ("XAUTHORITY") != NULL)
+ gdm_session_set_environment_variable (session, "XAUTHORITY",
+ g_getenv ("XAUTHORITY"));
}
int
main (int argc,
char *argv[])
{
- GdmSession *session;
- char *username;
- int exit_code;
+ GdmSession *session;
+ char *username;
+ int exit_code;
- exit_code = 0;
+ exit_code = 0;
- g_log_set_always_fatal (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+ g_log_set_always_fatal (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
- g_type_init ();
+ g_type_init ();
- do {
- g_message ("creating instance of 'user session' object...");
- session = gdm_session_new ();
- g_message ("'user session' object created successfully");
+ do {
+ g_message ("creating instance of 'user session' object...");
+ session = gdm_session_new ();
+ g_message ("'user session' object created successfully");
- if (argc <= 1) {
- username = NULL;
- } else {
- username = argv[1];
- }
+ if (argc <= 1) {
+ username = NULL;
+ } else {
+ username = argv[1];
+ }
- gdm_session_open (session,
- "gdm",
- "",
- ttyname (STDIN_FILENO),
- NULL);
+ gdm_session_open (session,
+ "gdm",
+ "",
+ ttyname (STDIN_FILENO),
+ NULL);
- g_signal_connect (session, "opened",
- G_CALLBACK (on_open),
- username);
+ g_signal_connect (session, "opened",
+ G_CALLBACK (on_open),
+ username);
- g_signal_connect (session, "info",
- G_CALLBACK (on_info),
- NULL);
+ g_signal_connect (session, "info",
+ G_CALLBACK (on_info),
+ NULL);
- g_signal_connect (session, "problem",
- G_CALLBACK (on_problem),
- NULL);
+ g_signal_connect (session, "problem",
+ G_CALLBACK (on_problem),
+ NULL);
- g_signal_connect (session, "info-query",
- G_CALLBACK (on_info_query),
- NULL);
+ g_signal_connect (session, "info-query",
+ G_CALLBACK (on_info_query),
+ NULL);
- g_signal_connect (session, "secret-info-query",
- G_CALLBACK (on_secret_info_query),
- NULL);
+ g_signal_connect (session, "secret-info-query",
+ G_CALLBACK (on_secret_info_query),
+ NULL);
- g_signal_connect (session, "user-verified",
- G_CALLBACK (on_user_verified),
- NULL);
+ g_signal_connect (session, "user-verified",
+ G_CALLBACK (on_user_verified),
+ NULL);
- g_signal_connect (session, "user-verification-error",
- G_CALLBACK (on_user_verification_error),
- NULL);
+ g_signal_connect (session, "user-verification-error",
+ G_CALLBACK (on_user_verification_error),
+ NULL);
- g_signal_connect (session, "session-started",
- G_CALLBACK (on_session_started),
- NULL);
+ g_signal_connect (session, "session-started",
+ G_CALLBACK (on_session_started),
+ NULL);
- g_signal_connect (session, "session-exited",
- G_CALLBACK (on_session_exited),
- NULL);
+ g_signal_connect (session, "session-exited",
+ G_CALLBACK (on_session_exited),
+ NULL);
- g_signal_connect (session, "session-died",
- G_CALLBACK (on_session_died),
- NULL);
+ g_signal_connect (session, "session-died",
+ G_CALLBACK (on_session_died),
+ NULL);
- import_environment (session);
+ import_environment (session);
- loop = g_main_loop_new (NULL, FALSE);
- g_main_loop_run (loop);
- g_main_loop_unref (loop);
+ loop = g_main_loop_new (NULL, FALSE);
+ g_main_loop_run (loop);
+ g_main_loop_unref (loop);
- g_message ("destroying previously created 'user session' object...");
- g_object_unref (session);
- g_message ("'user session' object destroyed successfully");
- } while (1);
+ g_message ("destroying previously created 'user session' object...");
+ g_object_unref (session);
+ g_message ("'user session' object destroyed successfully");
+ } while (1);
- return exit_code;
+ return exit_code;
}
diff --git a/gui/simple-greeter/gdm-simple-greeter.c b/gui/simple-greeter/gdm-simple-greeter.c
index 8f830669..c1c878db 100644
--- a/gui/simple-greeter/gdm-simple-greeter.c
+++ b/gui/simple-greeter/gdm-simple-greeter.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -64,44 +64,44 @@
#define GDM_SIMPLE_GREETER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_SIMPLE_GREETER, GdmSimpleGreeterPrivate))
enum {
- RESPONSE_RESTART,
- RESPONSE_REBOOT,
- RESPONSE_CLOSE
+ RESPONSE_RESTART,
+ RESPONSE_REBOOT,
+ RESPONSE_CLOSE
};
struct GdmSimpleGreeterPrivate
{
- GladeXML *xml;
+ GladeXML *xml;
};
enum {
- PROP_0,
+ PROP_0,
};
-static void gdm_simple_greeter_class_init (GdmSimpleGreeterClass *klass);
-static void gdm_simple_greeter_init (GdmSimpleGreeter *simple_greeter);
-static void gdm_simple_greeter_finalize (GObject *object);
+static void gdm_simple_greeter_class_init (GdmSimpleGreeterClass *klass);
+static void gdm_simple_greeter_init (GdmSimpleGreeter *simple_greeter);
+static void gdm_simple_greeter_finalize (GObject *object);
G_DEFINE_TYPE (GdmSimpleGreeter, gdm_simple_greeter, GDM_TYPE_GREETER)
static gboolean
gdm_simple_greeter_start (GdmGreeter *greeter)
{
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- GDM_GREETER_CLASS (gdm_simple_greeter_parent_class)->start (greeter);
+ GDM_GREETER_CLASS (gdm_simple_greeter_parent_class)->start (greeter);
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_simple_greeter_stop (GdmGreeter *greeter)
{
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- GDM_GREETER_CLASS (gdm_simple_greeter_parent_class)->stop (greeter);
+ GDM_GREETER_CLASS (gdm_simple_greeter_parent_class)->stop (greeter);
- return TRUE;
+ return TRUE;
}
static void
@@ -110,7 +110,7 @@ set_busy (GdmSimpleGreeter *greeter)
GdkCursor *cursor;
GtkWidget *top_level;
- top_level = glade_xml_get_widget (greeter->priv->xml, "auth-window");
+ top_level = glade_xml_get_widget (greeter->priv->xml, "auth-window");
cursor = gdk_cursor_new (GDK_WATCH);
gdk_window_set_cursor (top_level->window, cursor);
@@ -123,7 +123,7 @@ set_ready (GdmSimpleGreeter *greeter)
GdkCursor *cursor;
GtkWidget *top_level;
- top_level = glade_xml_get_widget (greeter->priv->xml, "auth-window");
+ top_level = glade_xml_get_widget (greeter->priv->xml, "auth-window");
cursor = gdk_cursor_new (GDK_LEFT_PTR);
gdk_window_set_cursor (top_level->window, cursor);
@@ -132,326 +132,326 @@ set_ready (GdmSimpleGreeter *greeter)
static void
set_sensitive (GdmSimpleGreeter *greeter,
- gboolean sensitive)
+ gboolean sensitive)
{
- GtkWidget *box;
+ GtkWidget *box;
- box = glade_xml_get_widget (greeter->priv->xml, "input-box");
+ box = glade_xml_get_widget (greeter->priv->xml, "input-box");
gtk_widget_set_sensitive (box, sensitive);
- box = glade_xml_get_widget (greeter->priv->xml, "button-box");
+ box = glade_xml_get_widget (greeter->priv->xml, "button-box");
gtk_widget_set_sensitive (box, sensitive);
}
static void
set_message (GdmSimpleGreeter *greeter,
- const char *text)
+ const char *text)
{
GtkWidget *label;
- label = glade_xml_get_widget (greeter->priv->xml, "message-label");
- gtk_label_set_text (GTK_LABEL (label), text);
+ label = glade_xml_get_widget (greeter->priv->xml, "message-label");
+ gtk_label_set_text (GTK_LABEL (label), text);
}
static void
do_cancel (GdmSimpleGreeter *greeter)
{
- set_busy (greeter);
- set_sensitive (greeter, FALSE);
+ set_busy (greeter);
+ set_sensitive (greeter, FALSE);
- gdm_greeter_emit_cancelled (GDM_GREETER (greeter));
+ gdm_greeter_emit_cancelled (GDM_GREETER (greeter));
}
static void
reset_dialog (GdmSimpleGreeter *greeter)
{
- GtkWidget *entry;
- GtkWidget *label;
+ GtkWidget *entry;
+ GtkWidget *label;
- g_debug ("Resetting dialog");
+ g_debug ("Resetting dialog");
- entry = glade_xml_get_widget (GDM_SIMPLE_GREETER (greeter)->priv->xml, "auth-entry");
- gtk_entry_set_text (GTK_ENTRY (entry), "");
- gtk_entry_set_visibility (GTK_ENTRY (entry), TRUE);
+ entry = glade_xml_get_widget (GDM_SIMPLE_GREETER (greeter)->priv->xml, "auth-entry");
+ gtk_entry_set_text (GTK_ENTRY (entry), "");
+ gtk_entry_set_visibility (GTK_ENTRY (entry), TRUE);
- label = glade_xml_get_widget (GDM_SIMPLE_GREETER (greeter)->priv->xml, "auth-label");
- gtk_label_set_text (GTK_LABEL (label), "");
+ label = glade_xml_get_widget (GDM_SIMPLE_GREETER (greeter)->priv->xml, "auth-label");
+ gtk_label_set_text (GTK_LABEL (label), "");
if (! GTK_WIDGET_HAS_FOCUS (entry)) {
gtk_widget_grab_focus (entry);
}
- set_message (greeter, "");
+ set_message (greeter, "");
- set_ready (greeter);
- set_sensitive (greeter, TRUE);
+ set_ready (greeter);
+ set_sensitive (greeter, TRUE);
}
static gboolean
gdm_simple_greeter_reset (GdmGreeter *greeter)
{
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- /*GDM_GREETER_CLASS (gdm_simple_greeter_parent_class)->reset (greeter);*/
+ /*GDM_GREETER_CLASS (gdm_simple_greeter_parent_class)->reset (greeter);*/
- reset_dialog (GDM_SIMPLE_GREETER (greeter));
- do_cancel (GDM_SIMPLE_GREETER (greeter));
+ reset_dialog (GDM_SIMPLE_GREETER (greeter));
+ do_cancel (GDM_SIMPLE_GREETER (greeter));
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_simple_greeter_info (GdmGreeter *greeter,
- const char *text)
+ const char *text)
{
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- GDM_GREETER_CLASS (gdm_simple_greeter_parent_class)->info (greeter, text);
+ GDM_GREETER_CLASS (gdm_simple_greeter_parent_class)->info (greeter, text);
- g_debug ("SIMPLE GREETER: info: %s", text);
+ g_debug ("SIMPLE GREETER: info: %s", text);
- set_message (GDM_SIMPLE_GREETER (greeter), text);
+ set_message (GDM_SIMPLE_GREETER (greeter), text);
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_simple_greeter_problem (GdmGreeter *greeter,
- const char *text)
+ const char *text)
{
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- GDM_GREETER_CLASS (gdm_simple_greeter_parent_class)->problem (greeter, text);
+ GDM_GREETER_CLASS (gdm_simple_greeter_parent_class)->problem (greeter, text);
- g_debug ("SIMPLE GREETER: problem: %s", text);
+ g_debug ("SIMPLE GREETER: problem: %s", text);
- set_message (GDM_SIMPLE_GREETER (greeter), text);
+ set_message (GDM_SIMPLE_GREETER (greeter), text);
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_simple_greeter_info_query (GdmGreeter *greeter,
- const char *text)
+ const char *text)
{
- GtkWidget *entry;
- GtkWidget *label;
+ GtkWidget *entry;
+ GtkWidget *label;
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- GDM_GREETER_CLASS (gdm_simple_greeter_parent_class)->info_query (greeter, text);
+ GDM_GREETER_CLASS (gdm_simple_greeter_parent_class)->info_query (greeter, text);
- g_debug ("SIMPLE GREETER: info query: %s", text);
+ g_debug ("SIMPLE GREETER: info query: %s", text);
- entry = glade_xml_get_widget (GDM_SIMPLE_GREETER (greeter)->priv->xml, "auth-entry");
- gtk_entry_set_text (GTK_ENTRY (entry), "");
- gtk_entry_set_visibility (GTK_ENTRY (entry), TRUE);
+ entry = glade_xml_get_widget (GDM_SIMPLE_GREETER (greeter)->priv->xml, "auth-entry");
+ gtk_entry_set_text (GTK_ENTRY (entry), "");
+ gtk_entry_set_visibility (GTK_ENTRY (entry), TRUE);
- label = glade_xml_get_widget (GDM_SIMPLE_GREETER (greeter)->priv->xml, "auth-label");
- gtk_label_set_text (GTK_LABEL (label), text);
+ label = glade_xml_get_widget (GDM_SIMPLE_GREETER (greeter)->priv->xml, "auth-label");
+ gtk_label_set_text (GTK_LABEL (label), text);
if (! GTK_WIDGET_HAS_FOCUS (entry)) {
gtk_widget_grab_focus (entry);
}
- set_ready (GDM_SIMPLE_GREETER (greeter));
- set_sensitive (GDM_SIMPLE_GREETER (greeter), TRUE);
+ set_ready (GDM_SIMPLE_GREETER (greeter));
+ set_sensitive (GDM_SIMPLE_GREETER (greeter), TRUE);
- return TRUE;
+ return TRUE;
}
static gboolean
gdm_simple_greeter_secret_info_query (GdmGreeter *greeter,
- const char *text)
+ const char *text)
{
- GtkWidget *entry;
- GtkWidget *label;
+ GtkWidget *entry;
+ GtkWidget *label;
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- GDM_GREETER_CLASS (gdm_simple_greeter_parent_class)->secret_info_query (greeter, text);
+ GDM_GREETER_CLASS (gdm_simple_greeter_parent_class)->secret_info_query (greeter, text);
- g_debug ("SIMPLE GREETER: secret info query: %s", text);
+ g_debug ("SIMPLE GREETER: secret info query: %s", text);
- entry = glade_xml_get_widget (GDM_SIMPLE_GREETER (greeter)->priv->xml, "auth-entry");
- gtk_entry_set_text (GTK_ENTRY (entry), "");
- gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE);
+ entry = glade_xml_get_widget (GDM_SIMPLE_GREETER (greeter)->priv->xml, "auth-entry");
+ gtk_entry_set_text (GTK_ENTRY (entry), "");
+ gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE);
- label = glade_xml_get_widget (GDM_SIMPLE_GREETER (greeter)->priv->xml, "auth-label");
- gtk_label_set_text (GTK_LABEL (label), text);
+ label = glade_xml_get_widget (GDM_SIMPLE_GREETER (greeter)->priv->xml, "auth-label");
+ gtk_label_set_text (GTK_LABEL (label), text);
if (! GTK_WIDGET_HAS_FOCUS (entry)) {
gtk_widget_grab_focus (entry);
}
- set_ready (GDM_SIMPLE_GREETER (greeter));
- set_sensitive (GDM_SIMPLE_GREETER (greeter), TRUE);
+ set_ready (GDM_SIMPLE_GREETER (greeter));
+ set_sensitive (GDM_SIMPLE_GREETER (greeter), TRUE);
- return TRUE;
+ return TRUE;
}
static void
gdm_simple_greeter_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GdmSimpleGreeter *self;
+ GdmSimpleGreeter *self;
- self = GDM_SIMPLE_GREETER (object);
+ self = GDM_SIMPLE_GREETER (object);
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gdm_simple_greeter_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GdmSimpleGreeter *self;
+ GdmSimpleGreeter *self;
- self = GDM_SIMPLE_GREETER (object);
+ self = GDM_SIMPLE_GREETER (object);
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
ok_button_clicked (GtkButton *button,
- GdmSimpleGreeter *greeter)
+ GdmSimpleGreeter *greeter)
{
- gboolean res;
- GtkWidget *entry;
- const char *text;
+ gboolean res;
+ GtkWidget *entry;
+ const char *text;
- set_busy (greeter);
- set_sensitive (greeter, FALSE);
+ set_busy (greeter);
+ set_sensitive (greeter, FALSE);
- entry = glade_xml_get_widget (greeter->priv->xml, "auth-entry");
- text = gtk_entry_get_text (GTK_ENTRY (entry));
- res = gdm_greeter_emit_answer_query (GDM_GREETER (greeter), text);
+ entry = glade_xml_get_widget (greeter->priv->xml, "auth-entry");
+ text = gtk_entry_get_text (GTK_ENTRY (entry));
+ res = gdm_greeter_emit_answer_query (GDM_GREETER (greeter), text);
}
static void
cancel_button_clicked (GtkButton *button,
- GdmSimpleGreeter *greeter)
+ GdmSimpleGreeter *greeter)
{
- do_cancel (greeter);
+ do_cancel (greeter);
}
static void
suspend_button_clicked (GtkButton *button,
- GdmSimpleGreeter *greeter)
+ GdmSimpleGreeter *greeter)
{
- gboolean res;
- GError *error;
- DBusGConnection *connection;
- DBusGProxy *proxy;
-
- g_debug ("Suspend button clicked");
-
- error = NULL;
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (error != NULL) {
- g_warning ("Couldn't suspend: %s", error->message);
- g_error_free (error);
- return;
- }
- proxy = dbus_g_proxy_new_for_name (connection,
- GPM_DBUS_NAME,
- GPM_DBUS_PATH,
- GPM_DBUS_INTERFACE);
- error = NULL;
- dbus_g_proxy_call (proxy,
+ gboolean res;
+ GError *error;
+ DBusGConnection *connection;
+ DBusGProxy *proxy;
+
+ g_debug ("Suspend button clicked");
+
+ error = NULL;
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (error != NULL) {
+ g_warning ("Couldn't suspend: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+ proxy = dbus_g_proxy_new_for_name (connection,
+ GPM_DBUS_NAME,
+ GPM_DBUS_PATH,
+ GPM_DBUS_INTERFACE);
+ error = NULL;
+ dbus_g_proxy_call (proxy,
"Suspend",
&error,
G_TYPE_INVALID,
G_TYPE_INVALID);
- if (error != NULL) {
- g_warning ("Couldn't suspend: %s", error->message);
- g_error_free (error);
- return;
- }
+ if (error != NULL) {
+ g_warning ("Couldn't suspend: %s", error->message);
+ g_error_free (error);
+ return;
+ }
- g_object_unref (proxy);
+ g_object_unref (proxy);
}
static void
create_greeter (GdmSimpleGreeter *greeter)
{
- GError *error;
- GtkWidget *dialog;
- GtkWidget *button;
+ GError *error;
+ GtkWidget *dialog;
+ GtkWidget *button;
#if 0
- error = NULL;
- g_spawn_command_line_async ("gtk-window-decorator", &error);
- if (error != NULL) {
- g_warning ("Error starting WM: %s", error->message);
- g_error_free (error);
- }
-
- error = NULL;
- g_spawn_command_line_async ("compiz", &error);
- if (error != NULL) {
- g_warning ("Error starting WM: %s", error->message);
- g_error_free (error);
- }
+ error = NULL;
+ g_spawn_command_line_async ("gtk-window-decorator", &error);
+ if (error != NULL) {
+ g_warning ("Error starting WM: %s", error->message);
+ g_error_free (error);
+ }
+
+ error = NULL;
+ g_spawn_command_line_async ("compiz", &error);
+ if (error != NULL) {
+ g_warning ("Error starting WM: %s", error->message);
+ g_error_free (error);
+ }
#else
- error = NULL;
- g_spawn_command_line_async ("metacity", &error);
- if (error != NULL) {
- g_warning ("Error starting WM: %s", error->message);
- g_error_free (error);
- }
+ error = NULL;
+ g_spawn_command_line_async ("metacity", &error);
+ if (error != NULL) {
+ g_warning ("Error starting WM: %s", error->message);
+ g_error_free (error);
+ }
#endif
greeter->priv->xml = glade_xml_new (GLADEDIR "/" GLADE_XML_FILE, NULL, PACKAGE);
- if (greeter->priv->xml == NULL) {
- /* FIXME: */
- }
-
- dialog = glade_xml_get_widget (greeter->priv->xml, "auth-window");
- if (dialog == NULL) {
- /* FIXME: */
- }
-
- button = glade_xml_get_widget (greeter->priv->xml, "ok-button");
- if (dialog != NULL) {
- gtk_widget_grab_default (button);
- g_signal_connect (button, "clicked", G_CALLBACK (ok_button_clicked), greeter);
- }
-
- button = glade_xml_get_widget (greeter->priv->xml, "cancel-button");
- if (dialog != NULL) {
- g_signal_connect (button, "clicked", G_CALLBACK (cancel_button_clicked), greeter);
- }
-
- button = glade_xml_get_widget (greeter->priv->xml, "suspend-button");
- if (dialog != NULL) {
- g_signal_connect (button, "clicked", G_CALLBACK (suspend_button_clicked), greeter);
- }
-
- gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ALWAYS);
- gtk_window_set_deletable (GTK_WINDOW (dialog), FALSE);
- gtk_window_set_decorated (GTK_WINDOW (dialog), FALSE);
- gtk_widget_show (dialog);
-
- set_busy (greeter);
+ if (greeter->priv->xml == NULL) {
+ /* FIXME: */
+ }
+
+ dialog = glade_xml_get_widget (greeter->priv->xml, "auth-window");
+ if (dialog == NULL) {
+ /* FIXME: */
+ }
+
+ button = glade_xml_get_widget (greeter->priv->xml, "ok-button");
+ if (dialog != NULL) {
+ gtk_widget_grab_default (button);
+ g_signal_connect (button, "clicked", G_CALLBACK (ok_button_clicked), greeter);
+ }
+
+ button = glade_xml_get_widget (greeter->priv->xml, "cancel-button");
+ if (dialog != NULL) {
+ g_signal_connect (button, "clicked", G_CALLBACK (cancel_button_clicked), greeter);
+ }
+
+ button = glade_xml_get_widget (greeter->priv->xml, "suspend-button");
+ if (dialog != NULL) {
+ g_signal_connect (button, "clicked", G_CALLBACK (suspend_button_clicked), greeter);
+ }
+
+ gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ALWAYS);
+ gtk_window_set_deletable (GTK_WINDOW (dialog), FALSE);
+ gtk_window_set_decorated (GTK_WINDOW (dialog), FALSE);
+ gtk_widget_show (dialog);
+
+ set_busy (greeter);
}
static GObject *
gdm_simple_greeter_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
{
GdmSimpleGreeter *greeter;
GdmSimpleGreeterClass *klass;
@@ -459,9 +459,9 @@ gdm_simple_greeter_constructor (GType type,
klass = GDM_SIMPLE_GREETER_CLASS (g_type_class_peek (GDM_TYPE_SIMPLE_GREETER));
greeter = GDM_SIMPLE_GREETER (G_OBJECT_CLASS (gdm_simple_greeter_parent_class)->constructor (type,
- n_construct_properties,
- construct_properties));
- create_greeter (greeter);
+ n_construct_properties,
+ construct_properties));
+ create_greeter (greeter);
return G_OBJECT (greeter);
}
@@ -469,55 +469,55 @@ gdm_simple_greeter_constructor (GType type,
static void
gdm_simple_greeter_class_init (GdmSimpleGreeterClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GdmGreeterClass *greeter_class = GDM_GREETER_CLASS (klass);
-
- object_class->get_property = gdm_simple_greeter_get_property;
- object_class->set_property = gdm_simple_greeter_set_property;
- object_class->constructor = gdm_simple_greeter_constructor;
- object_class->finalize = gdm_simple_greeter_finalize;
-
- greeter_class->start = gdm_simple_greeter_start;
- greeter_class->stop = gdm_simple_greeter_stop;
- greeter_class->reset = gdm_simple_greeter_reset;
- greeter_class->info = gdm_simple_greeter_info;
- greeter_class->problem = gdm_simple_greeter_problem;
- greeter_class->info_query = gdm_simple_greeter_info_query;
- greeter_class->secret_info_query = gdm_simple_greeter_secret_info_query;
-
- g_type_class_add_private (klass, sizeof (GdmSimpleGreeterPrivate));
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GdmGreeterClass *greeter_class = GDM_GREETER_CLASS (klass);
+
+ object_class->get_property = gdm_simple_greeter_get_property;
+ object_class->set_property = gdm_simple_greeter_set_property;
+ object_class->constructor = gdm_simple_greeter_constructor;
+ object_class->finalize = gdm_simple_greeter_finalize;
+
+ greeter_class->start = gdm_simple_greeter_start;
+ greeter_class->stop = gdm_simple_greeter_stop;
+ greeter_class->reset = gdm_simple_greeter_reset;
+ greeter_class->info = gdm_simple_greeter_info;
+ greeter_class->problem = gdm_simple_greeter_problem;
+ greeter_class->info_query = gdm_simple_greeter_info_query;
+ greeter_class->secret_info_query = gdm_simple_greeter_secret_info_query;
+
+ g_type_class_add_private (klass, sizeof (GdmSimpleGreeterPrivate));
}
static void
gdm_simple_greeter_init (GdmSimpleGreeter *simple_greeter)
{
- simple_greeter->priv = GDM_SIMPLE_GREETER_GET_PRIVATE (simple_greeter);
+ simple_greeter->priv = GDM_SIMPLE_GREETER_GET_PRIVATE (simple_greeter);
}
static void
gdm_simple_greeter_finalize (GObject *object)
{
- GdmSimpleGreeter *simple_greeter;
+ GdmSimpleGreeter *simple_greeter;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_SIMPLE_GREETER (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_SIMPLE_GREETER (object));
- simple_greeter = GDM_SIMPLE_GREETER (object);
+ simple_greeter = GDM_SIMPLE_GREETER (object);
- g_return_if_fail (simple_greeter->priv != NULL);
+ g_return_if_fail (simple_greeter->priv != NULL);
- G_OBJECT_CLASS (gdm_simple_greeter_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_simple_greeter_parent_class)->finalize (object);
}
GdmGreeter *
gdm_simple_greeter_new (void)
{
- GObject *object;
+ GObject *object;
- object = g_object_new (GDM_TYPE_SIMPLE_GREETER,
- NULL);
+ object = g_object_new (GDM_TYPE_SIMPLE_GREETER,
+ NULL);
- return GDM_GREETER (object);
+ return GDM_GREETER (object);
}
diff --git a/gui/simple-greeter/gdm-simple-greeter.h b/gui/simple-greeter/gdm-simple-greeter.h
index 7e78f0de..be1b8e98 100644
--- a/gui/simple-greeter/gdm-simple-greeter.h
+++ b/gui/simple-greeter/gdm-simple-greeter.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: h; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -39,18 +39,18 @@ typedef struct GdmSimpleGreeterPrivate GdmSimpleGreeterPrivate;
typedef struct
{
- GdmGreeter parent;
- GdmSimpleGreeterPrivate *priv;
+ GdmGreeter parent;
+ GdmSimpleGreeterPrivate *priv;
} GdmSimpleGreeter;
typedef struct
{
- GdmGreeterClass parent_class;
+ GdmGreeterClass parent_class;
} GdmSimpleGreeterClass;
-GType gdm_simple_greeter_get_type (void);
-GdmGreeter * gdm_simple_greeter_new (void);
+GType gdm_simple_greeter_get_type (void);
+GdmGreeter * gdm_simple_greeter_new (void);
G_END_DECLS
diff --git a/gui/simple-greeter/greeter-main.c b/gui/simple-greeter/greeter-main.c
index aa9e1143..f96eb226 100644
--- a/gui/simple-greeter/greeter-main.c
+++ b/gui/simple-greeter/greeter-main.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -55,270 +55,270 @@ static DBusGProxy *gpm_proxy = NULL;
static void
on_info (DBusGProxy *proxy,
- const char *text,
- gpointer data)
+ const char *text,
+ gpointer data)
{
- g_debug ("GREETER INFO: %s", text);
+ g_debug ("GREETER INFO: %s", text);
- gdm_greeter_info (GDM_GREETER (greeter), text);
+ gdm_greeter_info (GDM_GREETER (greeter), text);
}
static void
on_problem (DBusGProxy *proxy,
- const char *text,
- gpointer data)
+ const char *text,
+ gpointer data)
{
- g_debug ("GREETER PROBLEM: %s", text);
+ g_debug ("GREETER PROBLEM: %s", text);
- gdm_greeter_problem (GDM_GREETER (greeter), text);
+ gdm_greeter_problem (GDM_GREETER (greeter), text);
}
static void
on_reset (DBusGProxy *proxy,
- gpointer data)
+ gpointer data)
{
- g_debug ("GREETER RESET");
+ g_debug ("GREETER RESET");
- gdm_greeter_reset (GDM_GREETER (greeter));
+ gdm_greeter_reset (GDM_GREETER (greeter));
}
static void
on_info_query (DBusGProxy *proxy,
- const char *text,
- gpointer data)
+ const char *text,
+ gpointer data)
{
- g_debug ("GREETER Info query: %s", text);
+ g_debug ("GREETER Info query: %s", text);
- gdm_greeter_info_query (GDM_GREETER (greeter), text);
+ gdm_greeter_info_query (GDM_GREETER (greeter), text);
}
static void
on_secret_info_query (DBusGProxy *proxy,
- const char *text,
- gpointer data)
+ const char *text,
+ gpointer data)
{
- g_debug ("GREETER Secret info query: %s", text);
+ g_debug ("GREETER Secret info query: %s", text);
- gdm_greeter_secret_info_query (GDM_GREETER (greeter), text);
+ gdm_greeter_secret_info_query (GDM_GREETER (greeter), text);
}
static void
on_query_answer (GdmGreeter *greeter,
- const char *text,
- gpointer data)
+ const char *text,
+ gpointer data)
{
- gboolean res;
- GError *error;
-
- g_debug ("GREETER answer");
-
- error = NULL;
- res = dbus_g_proxy_call (server_proxy,
- "AnswerQuery",
- &error,
- G_TYPE_STRING, text,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to send AnswerQuery: %s", error->message);
- g_error_free (error);
- }
+ gboolean res;
+ GError *error;
+
+ g_debug ("GREETER answer");
+
+ error = NULL;
+ res = dbus_g_proxy_call (server_proxy,
+ "AnswerQuery",
+ &error,
+ G_TYPE_STRING, text,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Unable to send AnswerQuery: %s", error->message);
+ g_error_free (error);
+ }
}
static void
on_select_session (GdmGreeter *greeter,
- const char *text,
- gpointer data)
+ const char *text,
+ gpointer data)
{
- gboolean res;
- GError *error;
-
- g_debug ("GREETER session selected: %s", text);
-
- error = NULL;
- res = dbus_g_proxy_call (server_proxy,
- "SelectSession",
- &error,
- G_TYPE_STRING, text,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to send SelectSession: %s", error->message);
- g_error_free (error);
- }
+ gboolean res;
+ GError *error;
+
+ g_debug ("GREETER session selected: %s", text);
+
+ error = NULL;
+ res = dbus_g_proxy_call (server_proxy,
+ "SelectSession",
+ &error,
+ G_TYPE_STRING, text,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Unable to send SelectSession: %s", error->message);
+ g_error_free (error);
+ }
}
static void
on_select_language (GdmGreeter *greeter,
- const char *text,
- gpointer data)
+ const char *text,
+ gpointer data)
{
- gboolean res;
- GError *error;
-
- g_debug ("GREETER session selected: %s", text);
-
- error = NULL;
- res = dbus_g_proxy_call (server_proxy,
- "SelectLanguage",
- &error,
- G_TYPE_STRING, text,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to send SelectLanguage: %s", error->message);
- g_error_free (error);
- }
+ gboolean res;
+ GError *error;
+
+ g_debug ("GREETER session selected: %s", text);
+
+ error = NULL;
+ res = dbus_g_proxy_call (server_proxy,
+ "SelectLanguage",
+ &error,
+ G_TYPE_STRING, text,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Unable to send SelectLanguage: %s", error->message);
+ g_error_free (error);
+ }
}
static void
on_select_user (GdmGreeter *greeter,
- const char *text,
- gpointer data)
+ const char *text,
+ gpointer data)
{
- gboolean res;
- GError *error;
-
- g_debug ("GREETER user selected: %s", text);
-
- error = NULL;
- res = dbus_g_proxy_call (server_proxy,
- "SelectUser",
- &error,
- G_TYPE_STRING, text,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to send SelectUser: %s", error->message);
- g_error_free (error);
- }
+ gboolean res;
+ GError *error;
+
+ g_debug ("GREETER user selected: %s", text);
+
+ error = NULL;
+ res = dbus_g_proxy_call (server_proxy,
+ "SelectUser",
+ &error,
+ G_TYPE_STRING, text,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Unable to send SelectUser: %s", error->message);
+ g_error_free (error);
+ }
}
static void
on_cancelled (GdmGreeter *greeter,
- gpointer data)
+ gpointer data)
{
- gboolean res;
- GError *error;
-
- g_debug ("GREETER cancelled");
-
- error = NULL;
- res = dbus_g_proxy_call (server_proxy,
- "Cancel",
- &error,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Unable to send Cancelled: %s", error->message);
- g_error_free (error);
- }
+ gboolean res;
+ GError *error;
+
+ g_debug ("GREETER cancelled");
+
+ error = NULL;
+ res = dbus_g_proxy_call (server_proxy,
+ "Cancel",
+ &error,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Unable to send Cancelled: %s", error->message);
+ g_error_free (error);
+ }
}
static void
proxy_destroyed (GObject *object,
- gpointer data)
+ gpointer data)
{
- g_debug ("GREETER Proxy disconnected");
+ g_debug ("GREETER Proxy disconnected");
}
#if 1
static void
activate_power_manager (void)
{
- DBusGConnection *connection;
- GError *error;
- gboolean res;
- guint result;
-
- g_debug ("Activating power management");
-
- error = NULL;
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (error != NULL) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
-
- gpm_proxy = dbus_g_proxy_new_for_name (connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
- error = NULL;
- res = dbus_g_proxy_call (gpm_proxy,
- "StartServiceByName",
- &error,
- G_TYPE_STRING, GPM_DBUS_NAME,
- G_TYPE_UINT, 0,
- G_TYPE_INVALID,
- G_TYPE_UINT, &result,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("Could not start service: %s", error->message);
- g_error_free (error);
- } else {
- g_debug ("Result %u", result);
- }
+ DBusGConnection *connection;
+ GError *error;
+ gboolean res;
+ guint result;
+
+ g_debug ("Activating power management");
+
+ error = NULL;
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (error != NULL) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+
+ gpm_proxy = dbus_g_proxy_new_for_name (connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);
+ error = NULL;
+ res = dbus_g_proxy_call (gpm_proxy,
+ "StartServiceByName",
+ &error,
+ G_TYPE_STRING, GPM_DBUS_NAME,
+ G_TYPE_UINT, 0,
+ G_TYPE_INVALID,
+ G_TYPE_UINT, &result,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("Could not start service: %s", error->message);
+ g_error_free (error);
+ } else {
+ g_debug ("Result %u", result);
+ }
}
#else
static void
activate_power_manager (void)
{
- GError *error;
- gboolean res;
+ GError *error;
+ gboolean res;
- g_debug ("Activating power management");
+ g_debug ("Activating power management");
- error = NULL;
- res = g_spawn_command_line_async ("gnome-power-manager --no-daemon --verbose", &error);
- if (! res) {
- g_warning ("Unable to activate power management: %s", error->message);
- g_error_free (error);
- }
+ error = NULL;
+ res = g_spawn_command_line_async ("gnome-power-manager --no-daemon --verbose", &error);
+ if (! res) {
+ g_warning ("Unable to activate power management: %s", error->message);
+ g_error_free (error);
+ }
}
#endif
int
main (int argc, char *argv[])
{
- GError *error;
- const char *address;
+ GError *error;
+ const char *address;
- bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- textdomain (GETTEXT_PACKAGE);
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
- setlocale (LC_ALL, "");
+ setlocale (LC_ALL, "");
- g_type_init ();
+ g_type_init ();
if (! gdm_settings_client_init (GDMCONFDIR "/gdm.schemas", "/")) {
exit (1);
}
- g_debug ("Greeter for display %s xauthority:%s", g_getenv ("DISPLAY"), g_getenv ("XAUTHORITY"));
+ g_debug ("Greeter for display %s xauthority:%s", g_getenv ("DISPLAY"), g_getenv ("XAUTHORITY"));
- /*
- * gdm_common_atspi_launch () needs gdk initialized.
- * We cannot start gtk before the registry is running
- * because the atk-bridge will crash.
- */
- gdk_init (&argc, &argv);
- /*gdm_common_atspi_launch ();*/
- gtk_init (&argc, &argv);
+ /*
+ * gdm_common_atspi_launch () needs gdk initialized.
+ * We cannot start gtk before the registry is running
+ * because the atk-bridge will crash.
+ */
+ gdk_init (&argc, &argv);
+ /*gdm_common_atspi_launch ();*/
+ gtk_init (&argc, &argv);
- gdm_log_init ();
+ gdm_log_init ();
- /*gdm_common_log_set_debug (gdm_settings_client_get_bool (GDM_KEY_DEBUG));*/
- gdm_log_set_debug (TRUE);
+ /*gdm_common_log_set_debug (gdm_settings_client_get_bool (GDM_KEY_DEBUG));*/
+ gdm_log_set_debug (TRUE);
- address = g_getenv ("GDM_GREETER_DBUS_ADDRESS");
- if (address == NULL) {
- g_warning ("GDM_GREETER_DBUS_ADDRESS not set");
- exit (1);
- }
+ address = g_getenv ("GDM_GREETER_DBUS_ADDRESS");
+ if (address == NULL) {
+ g_warning ("GDM_GREETER_DBUS_ADDRESS not set");
+ exit (1);
+ }
- g_debug ("GREETER connecting to address: %s", address);
+ g_debug ("GREETER connecting to address: %s", address);
error = NULL;
connection = dbus_g_connection_open (address, &error);
@@ -327,84 +327,84 @@ main (int argc, char *argv[])
g_warning ("error opening connection: %s", error->message);
g_error_free (error);
} else {
- g_warning ("Unable to open connection");
- }
- exit (1);
+ g_warning ("Unable to open connection");
+ }
+ exit (1);
}
- g_debug ("GREETER creating proxy for peer: %s", SERVER_DBUS_PATH);
+ g_debug ("GREETER creating proxy for peer: %s", SERVER_DBUS_PATH);
server_proxy = dbus_g_proxy_new_for_peer (connection,
- SERVER_DBUS_PATH,
- SERVER_DBUS_INTERFACE);
- if (server_proxy == NULL) {
- g_warning ("Unable to create proxy for peer");
- exit (1);
- }
-
- g_signal_connect (server_proxy, "destroy", G_CALLBACK (proxy_destroyed), NULL);
-
- /* FIXME: not sure why introspection isn't working */
- dbus_g_proxy_add_signal (server_proxy, "InfoQuery", G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_add_signal (server_proxy, "SecretInfoQuery", G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_add_signal (server_proxy, "Info", G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_add_signal (server_proxy, "Problem", G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_add_signal (server_proxy, "Reset", G_TYPE_INVALID);
-
- dbus_g_proxy_connect_signal (server_proxy,
- "InfoQuery",
- G_CALLBACK (on_info_query),
- NULL,
- NULL);
- dbus_g_proxy_connect_signal (server_proxy,
- "SecretInfoQuery",
- G_CALLBACK (on_secret_info_query),
- NULL,
- NULL);
- dbus_g_proxy_connect_signal (server_proxy,
- "Info",
- G_CALLBACK (on_info),
- NULL,
- NULL);
- dbus_g_proxy_connect_signal (server_proxy,
- "Problem",
- G_CALLBACK (on_problem),
- NULL,
- NULL);
- dbus_g_proxy_connect_signal (server_proxy,
- "Reset",
- G_CALLBACK (on_reset),
- NULL,
- NULL);
-
- greeter = gdm_simple_greeter_new ();
- g_signal_connect (greeter,
- "query-answer",
- G_CALLBACK (on_query_answer),
- NULL);
- g_signal_connect (greeter,
- "session-selected",
- G_CALLBACK (on_select_session),
- NULL);
- g_signal_connect (greeter,
- "language-selected",
- G_CALLBACK (on_select_language),
- NULL);
- g_signal_connect (greeter,
- "user-selected",
- G_CALLBACK (on_select_user),
- NULL);
- g_signal_connect (greeter,
- "cancelled",
- G_CALLBACK (on_cancelled),
- NULL);
-
- activate_power_manager ();
-
- gtk_main ();
-
- if (greeter != NULL) {
- g_object_unref (greeter);
- }
-
- return 0;
+ SERVER_DBUS_PATH,
+ SERVER_DBUS_INTERFACE);
+ if (server_proxy == NULL) {
+ g_warning ("Unable to create proxy for peer");
+ exit (1);
+ }
+
+ g_signal_connect (server_proxy, "destroy", G_CALLBACK (proxy_destroyed), NULL);
+
+ /* FIXME: not sure why introspection isn't working */
+ dbus_g_proxy_add_signal (server_proxy, "InfoQuery", G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (server_proxy, "SecretInfoQuery", G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (server_proxy, "Info", G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (server_proxy, "Problem", G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (server_proxy, "Reset", G_TYPE_INVALID);
+
+ dbus_g_proxy_connect_signal (server_proxy,
+ "InfoQuery",
+ G_CALLBACK (on_info_query),
+ NULL,
+ NULL);
+ dbus_g_proxy_connect_signal (server_proxy,
+ "SecretInfoQuery",
+ G_CALLBACK (on_secret_info_query),
+ NULL,
+ NULL);
+ dbus_g_proxy_connect_signal (server_proxy,
+ "Info",
+ G_CALLBACK (on_info),
+ NULL,
+ NULL);
+ dbus_g_proxy_connect_signal (server_proxy,
+ "Problem",
+ G_CALLBACK (on_problem),
+ NULL,
+ NULL);
+ dbus_g_proxy_connect_signal (server_proxy,
+ "Reset",
+ G_CALLBACK (on_reset),
+ NULL,
+ NULL);
+
+ greeter = gdm_simple_greeter_new ();
+ g_signal_connect (greeter,
+ "query-answer",
+ G_CALLBACK (on_query_answer),
+ NULL);
+ g_signal_connect (greeter,
+ "session-selected",
+ G_CALLBACK (on_select_session),
+ NULL);
+ g_signal_connect (greeter,
+ "language-selected",
+ G_CALLBACK (on_select_language),
+ NULL);
+ g_signal_connect (greeter,
+ "user-selected",
+ G_CALLBACK (on_select_user),
+ NULL);
+ g_signal_connect (greeter,
+ "cancelled",
+ G_CALLBACK (on_cancelled),
+ NULL);
+
+ activate_power_manager ();
+
+ gtk_main ();
+
+ if (greeter != NULL) {
+ g_object_unref (greeter);
+ }
+
+ return 0;
}
diff --git a/libgreeter/gdm-greeter.c b/libgreeter/gdm-greeter.c
index 9cc60595..bd6f89ea 100644
--- a/libgreeter/gdm-greeter.c
+++ b/libgreeter/gdm-greeter.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -39,306 +39,306 @@
struct GdmGreeterPrivate
{
- gpointer dummy;
+ gpointer dummy;
};
enum {
- PROP_0,
+ PROP_0,
};
enum {
- QUERY_ANSWER,
- SESSION_SELECTED,
- LANGUAGE_SELECTED,
- USER_SELECTED,
- CANCELLED,
- LAST_SIGNAL
+ QUERY_ANSWER,
+ SESSION_SELECTED,
+ LANGUAGE_SELECTED,
+ USER_SELECTED,
+ CANCELLED,
+ LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0, };
-static void gdm_greeter_class_init (GdmGreeterClass *klass);
-static void gdm_greeter_init (GdmGreeter *greeter);
-static void gdm_greeter_finalize (GObject *object);
+static void gdm_greeter_class_init (GdmGreeterClass *klass);
+static void gdm_greeter_init (GdmGreeter *greeter);
+static void gdm_greeter_finalize (GObject *object);
G_DEFINE_ABSTRACT_TYPE (GdmGreeter, gdm_greeter, G_TYPE_OBJECT)
GQuark
gdm_greeter_error_quark (void)
{
- static GQuark ret = 0;
- if (ret == 0) {
- ret = g_quark_from_static_string ("gdm_greeter_error");
- }
+ static GQuark ret = 0;
+ if (ret == 0) {
+ ret = g_quark_from_static_string ("gdm_greeter_error");
+ }
- return ret;
+ return ret;
}
static gboolean
gdm_greeter_real_start (GdmGreeter *greeter)
{
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- return TRUE;
+ return TRUE;
}
gboolean
gdm_greeter_start (GdmGreeter *greeter)
{
- gboolean ret;
+ gboolean ret;
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- g_object_ref (greeter);
- ret = GDM_GREETER_GET_CLASS (greeter)->start (greeter);
- g_object_unref (greeter);
+ g_object_ref (greeter);
+ ret = GDM_GREETER_GET_CLASS (greeter)->start (greeter);
+ g_object_unref (greeter);
- return ret;
+ return ret;
}
static gboolean
gdm_greeter_real_stop (GdmGreeter *greeter)
{
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- return TRUE;
+ return TRUE;
}
gboolean
gdm_greeter_stop (GdmGreeter *greeter)
{
- gboolean ret;
+ gboolean ret;
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- g_object_ref (greeter);
- ret = GDM_GREETER_GET_CLASS (greeter)->stop (greeter);
- g_object_unref (greeter);
+ g_object_ref (greeter);
+ ret = GDM_GREETER_GET_CLASS (greeter)->stop (greeter);
+ g_object_unref (greeter);
- return ret;
+ return ret;
}
static gboolean
gdm_greeter_real_reset (GdmGreeter *greeter)
{
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- return TRUE;
+ return TRUE;
}
gboolean
gdm_greeter_reset (GdmGreeter *greeter)
{
- gboolean ret;
+ gboolean ret;
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- g_object_ref (greeter);
- ret = GDM_GREETER_GET_CLASS (greeter)->reset (greeter);
- g_object_unref (greeter);
+ g_object_ref (greeter);
+ ret = GDM_GREETER_GET_CLASS (greeter)->reset (greeter);
+ g_object_unref (greeter);
- return ret;
+ return ret;
}
static gboolean
gdm_greeter_real_info (GdmGreeter *greeter,
- const char *text)
+ const char *text)
{
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- return TRUE;
+ return TRUE;
}
gboolean
gdm_greeter_info (GdmGreeter *greeter,
- const char *text)
+ const char *text)
{
- gboolean ret;
+ gboolean ret;
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- g_object_ref (greeter);
- ret = GDM_GREETER_GET_CLASS (greeter)->info (greeter, text);
- g_object_unref (greeter);
+ g_object_ref (greeter);
+ ret = GDM_GREETER_GET_CLASS (greeter)->info (greeter, text);
+ g_object_unref (greeter);
- return ret;
+ return ret;
}
static gboolean
gdm_greeter_real_problem (GdmGreeter *greeter,
- const char *text)
+ const char *text)
{
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- return TRUE;
+ return TRUE;
}
gboolean
gdm_greeter_problem (GdmGreeter *greeter,
- const char *text)
+ const char *text)
{
- gboolean ret;
+ gboolean ret;
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- g_object_ref (greeter);
- ret = GDM_GREETER_GET_CLASS (greeter)->problem (greeter, text);
- g_object_unref (greeter);
+ g_object_ref (greeter);
+ ret = GDM_GREETER_GET_CLASS (greeter)->problem (greeter, text);
+ g_object_unref (greeter);
- return ret;
+ return ret;
}
static gboolean
gdm_greeter_real_info_query (GdmGreeter *greeter,
- const char *text)
+ const char *text)
{
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- return TRUE;
+ return TRUE;
}
gboolean
gdm_greeter_info_query (GdmGreeter *greeter,
- const char *text)
+ const char *text)
{
- gboolean ret;
+ gboolean ret;
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- g_object_ref (greeter);
- ret = GDM_GREETER_GET_CLASS (greeter)->info_query (greeter, text);
- g_object_unref (greeter);
+ g_object_ref (greeter);
+ ret = GDM_GREETER_GET_CLASS (greeter)->info_query (greeter, text);
+ g_object_unref (greeter);
- return ret;
+ return ret;
}
static gboolean
gdm_greeter_real_secret_info_query (GdmGreeter *greeter,
- const char *text)
+ const char *text)
{
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- return TRUE;
+ return TRUE;
}
gboolean
gdm_greeter_secret_info_query (GdmGreeter *greeter,
- const char *text)
+ const char *text)
{
- gboolean ret;
+ gboolean ret;
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- g_object_ref (greeter);
- ret = GDM_GREETER_GET_CLASS (greeter)->secret_info_query (greeter, text);
- g_object_unref (greeter);
+ g_object_ref (greeter);
+ ret = GDM_GREETER_GET_CLASS (greeter)->secret_info_query (greeter, text);
+ g_object_unref (greeter);
- return ret;
+ return ret;
}
gboolean
gdm_greeter_emit_answer_query (GdmGreeter *greeter,
- const char *text)
+ const char *text)
{
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- g_debug ("Answer query: %s", text);
+ g_debug ("Answer query: %s", text);
- g_signal_emit (greeter, signals[QUERY_ANSWER], 0, text);
+ g_signal_emit (greeter, signals[QUERY_ANSWER], 0, text);
- return TRUE;
+ return TRUE;
}
gboolean
gdm_greeter_emit_select_session (GdmGreeter *greeter,
- const char *text)
+ const char *text)
{
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- g_debug ("Select session: %s", text);
+ g_debug ("Select session: %s", text);
- g_signal_emit (greeter, signals[SESSION_SELECTED], 0, text);
+ g_signal_emit (greeter, signals[SESSION_SELECTED], 0, text);
- return TRUE;
+ return TRUE;
}
gboolean
gdm_greeter_emit_select_language (GdmGreeter *greeter,
- const char *text)
+ const char *text)
{
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- g_debug ("Select language: %s", text);
+ g_debug ("Select language: %s", text);
- g_signal_emit (greeter, signals[LANGUAGE_SELECTED], 0, text);
+ g_signal_emit (greeter, signals[LANGUAGE_SELECTED], 0, text);
- return TRUE;
+ return TRUE;
}
gboolean
gdm_greeter_emit_select_user (GdmGreeter *greeter,
- const char *text)
+ const char *text)
{
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- g_debug ("Select user: %s", text);
+ g_debug ("Select user: %s", text);
- g_signal_emit (greeter, signals[USER_SELECTED], 0, text);
+ g_signal_emit (greeter, signals[USER_SELECTED], 0, text);
- return TRUE;
+ return TRUE;
}
gboolean
gdm_greeter_emit_cancelled (GdmGreeter *greeter)
{
- g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
+ g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE);
- g_debug ("Cancelled");
+ g_debug ("Cancelled");
- g_signal_emit (greeter, signals[CANCELLED], 0);
+ g_signal_emit (greeter, signals[CANCELLED], 0);
- return TRUE;
+ return TRUE;
}
static void
-gdm_greeter_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gdm_greeter_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GdmGreeter *self;
+ GdmGreeter *self;
- self = GDM_GREETER (object);
+ self = GDM_GREETER (object);
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gdm_greeter_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gdm_greeter_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GdmGreeter *self;
+ GdmGreeter *self;
- self = GDM_GREETER (object);
+ self = GDM_GREETER (object);
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static GObject *
gdm_greeter_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
{
GdmGreeter *greeter;
GdmGreeterClass *klass;
@@ -346,8 +346,8 @@ gdm_greeter_constructor (GType type,
klass = GDM_GREETER_CLASS (g_type_class_peek (GDM_TYPE_GREETER));
greeter = GDM_GREETER (G_OBJECT_CLASS (gdm_greeter_parent_class)->constructor (type,
- n_construct_properties,
- construct_properties));
+ n_construct_properties,
+ construct_properties));
return G_OBJECT (greeter);
}
@@ -355,109 +355,109 @@ gdm_greeter_constructor (GType type,
static void
gdm_greeter_dispose (GObject *object)
{
- GdmGreeter *greeter;
+ GdmGreeter *greeter;
- greeter = GDM_GREETER (object);
+ greeter = GDM_GREETER (object);
- g_debug ("Disposing greeter");
- gdm_greeter_stop (greeter);
+ g_debug ("Disposing greeter");
+ gdm_greeter_stop (greeter);
- G_OBJECT_CLASS (gdm_greeter_parent_class)->dispose (object);
+ G_OBJECT_CLASS (gdm_greeter_parent_class)->dispose (object);
}
static void
gdm_greeter_class_init (GdmGreeterClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->get_property = gdm_greeter_get_property;
- object_class->set_property = gdm_greeter_set_property;
+ object_class->get_property = gdm_greeter_get_property;
+ object_class->set_property = gdm_greeter_set_property;
object_class->constructor = gdm_greeter_constructor;
- object_class->dispose = gdm_greeter_dispose;
- object_class->finalize = gdm_greeter_finalize;
-
- klass->start = gdm_greeter_real_start;
- klass->stop = gdm_greeter_real_stop;
- klass->reset = gdm_greeter_real_reset;
- klass->info = gdm_greeter_real_info;
- klass->problem = gdm_greeter_real_problem;
- klass->info_query = gdm_greeter_real_info_query;
- klass->secret_info_query = gdm_greeter_real_secret_info_query;
-
-
- signals [QUERY_ANSWER] =
- g_signal_new ("query-answer",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdmGreeterClass, query_answer),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1, G_TYPE_STRING);
- signals [LANGUAGE_SELECTED] =
- g_signal_new ("language-selected",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdmGreeterClass, language_selected),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1, G_TYPE_STRING);
- signals [USER_SELECTED] =
- g_signal_new ("user-selected",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdmGreeterClass, user_selected),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1, G_TYPE_STRING);
- signals [SESSION_SELECTED] =
- g_signal_new ("session-selected",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdmGreeterClass, session_selected),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1, G_TYPE_STRING);
- signals [CANCELLED] =
- g_signal_new ("cancelled",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdmGreeterClass, cancelled),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- g_type_class_add_private (klass, sizeof (GdmGreeterPrivate));
+ object_class->dispose = gdm_greeter_dispose;
+ object_class->finalize = gdm_greeter_finalize;
+
+ klass->start = gdm_greeter_real_start;
+ klass->stop = gdm_greeter_real_stop;
+ klass->reset = gdm_greeter_real_reset;
+ klass->info = gdm_greeter_real_info;
+ klass->problem = gdm_greeter_real_problem;
+ klass->info_query = gdm_greeter_real_info_query;
+ klass->secret_info_query = gdm_greeter_real_secret_info_query;
+
+
+ signals [QUERY_ANSWER] =
+ g_signal_new ("query-answer",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdmGreeterClass, query_answer),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1, G_TYPE_STRING);
+ signals [LANGUAGE_SELECTED] =
+ g_signal_new ("language-selected",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdmGreeterClass, language_selected),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1, G_TYPE_STRING);
+ signals [USER_SELECTED] =
+ g_signal_new ("user-selected",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdmGreeterClass, user_selected),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1, G_TYPE_STRING);
+ signals [SESSION_SELECTED] =
+ g_signal_new ("session-selected",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdmGreeterClass, session_selected),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1, G_TYPE_STRING);
+ signals [CANCELLED] =
+ g_signal_new ("cancelled",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdmGreeterClass, cancelled),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
+ g_type_class_add_private (klass, sizeof (GdmGreeterPrivate));
}
static void
gdm_greeter_init (GdmGreeter *greeter)
{
- greeter->priv = GDM_GREETER_GET_PRIVATE (greeter);
+ greeter->priv = GDM_GREETER_GET_PRIVATE (greeter);
}
static void
gdm_greeter_finalize (GObject *object)
{
- GdmGreeter *greeter;
+ GdmGreeter *greeter;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GDM_IS_GREETER (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_GREETER (object));
- greeter = GDM_GREETER (object);
+ greeter = GDM_GREETER (object);
- g_return_if_fail (greeter->priv != NULL);
+ g_return_if_fail (greeter->priv != NULL);
- G_OBJECT_CLASS (gdm_greeter_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdm_greeter_parent_class)->finalize (object);
}
diff --git a/libgreeter/gdm-greeter.h b/libgreeter/gdm-greeter.h
index 02804e83..ce1d5698 100644
--- a/libgreeter/gdm-greeter.h
+++ b/libgreeter/gdm-greeter.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: h; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
@@ -37,50 +37,50 @@ typedef struct GdmGreeterPrivate GdmGreeterPrivate;
typedef struct
{
- GObject parent;
- GdmGreeterPrivate *priv;
+ GObject parent;
+ GdmGreeterPrivate *priv;
} GdmGreeter;
typedef struct
{
- GObjectClass parent_class;
-
- /* signals */
- void (* query_answer) (GdmGreeter *greeter,
- const char *text);
- void (* session_selected) (GdmGreeter *greeter,
- const char *text);
- void (* language_selected) (GdmGreeter *greeter,
- const char *text);
- void (* user_selected) (GdmGreeter *greeter,
- const char *text);
- void (* cancelled) (GdmGreeter *greeter);
-
- /* methods */
- gboolean (*start) (GdmGreeter *greeter);
- gboolean (*stop) (GdmGreeter *greeter);
- gboolean (*reset) (GdmGreeter *greeter);
-
- gboolean (*info_query) (GdmGreeter *greeter,
- const char *text);
- gboolean (*secret_info_query) (GdmGreeter *greeter,
- const char *text);
- gboolean (*info) (GdmGreeter *greeter,
- const char *text);
- gboolean (*problem) (GdmGreeter *greeter,
- const char *text);
+ GObjectClass parent_class;
+
+ /* signals */
+ void (* query_answer) (GdmGreeter *greeter,
+ const char *text);
+ void (* session_selected) (GdmGreeter *greeter,
+ const char *text);
+ void (* language_selected) (GdmGreeter *greeter,
+ const char *text);
+ void (* user_selected) (GdmGreeter *greeter,
+ const char *text);
+ void (* cancelled) (GdmGreeter *greeter);
+
+ /* methods */
+ gboolean (*start) (GdmGreeter *greeter);
+ gboolean (*stop) (GdmGreeter *greeter);
+ gboolean (*reset) (GdmGreeter *greeter);
+
+ gboolean (*info_query) (GdmGreeter *greeter,
+ const char *text);
+ gboolean (*secret_info_query) (GdmGreeter *greeter,
+ const char *text);
+ gboolean (*info) (GdmGreeter *greeter,
+ const char *text);
+ gboolean (*problem) (GdmGreeter *greeter,
+ const char *text);
} GdmGreeterClass;
typedef enum
{
- GDM_GREETER_ERROR_GENERAL
+ GDM_GREETER_ERROR_GENERAL
} GdmGreeterError;
#define GDM_GREETER_ERROR gdm_greeter_error_quark ()
-GQuark gdm_greeter_error_quark (void);
-GType gdm_greeter_get_type (void);
+GQuark gdm_greeter_error_quark (void);
+GType gdm_greeter_get_type (void);
gboolean gdm_greeter_start (GdmGreeter *greeter);
gboolean gdm_greeter_stop (GdmGreeter *greeter);
@@ -88,24 +88,24 @@ gboolean gdm_greeter_reset (GdmGreeter *gree
/* emit signals */
gboolean gdm_greeter_emit_answer_query (GdmGreeter *greeter,
- const char *text);
+ const char *text);
gboolean gdm_greeter_emit_select_session (GdmGreeter *greeter,
- const char *text);
+ const char *text);
gboolean gdm_greeter_emit_select_language (GdmGreeter *greeter,
- const char *text);
+ const char *text);
gboolean gdm_greeter_emit_select_user (GdmGreeter *greeter,
- const char *text);
+ const char *text);
gboolean gdm_greeter_emit_cancelled (GdmGreeter *greeter);
/* actions */
gboolean gdm_greeter_info_query (GdmGreeter *greeter,
- const char *text);
+ const char *text);
gboolean gdm_greeter_secret_info_query (GdmGreeter *greeter,
- const char *text);
+ const char *text);
gboolean gdm_greeter_info (GdmGreeter *greeter,
- const char *text);
+ const char *text);
gboolean gdm_greeter_problem (GdmGreeter *greeter,
- const char *text);
+ const char *text);
G_END_DECLS
diff --git a/libgreeter/gdmlanguages.c b/libgreeter/gdmlanguages.c
index 66040ddb..b865bc54 100644
--- a/libgreeter/gdmlanguages.c
+++ b/libgreeter/gdmlanguages.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* GDM - The GNOME Display Manager
* Copyright (C) 1998, 1999, 2000 Martin K. Petersen <mkp@mkp.net>
@@ -46,13 +46,13 @@ static gboolean always_restart = FALSE;
typedef struct _Language Language;
struct _Language {
- char *name;
- char *code;
- char *untranslated;
- int found;
+ char *name;
+ char *code;
+ char *untranslated;
+ int found;
- /* extra fields */
- char *collate_key;
+ /* extra fields */
+ char *collate_key;
};
/* FIXME: We need to have a nicer selection of language and country,
@@ -65,245 +65,245 @@ struct _Language {
* languages, just their names and where they are placed in the menu.
* The available languages come from the supplied locale.alias */
static Language languages [] = {
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Afrikaans"), "af_ZA", NULL, 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Albanian"), "sq_AL", "Shqip", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Amharic"), "am_ET", NULL, 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Arabic (Egypt)"), "ar_EG", NULL, 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Arabic (Lebanon)"), "ar_LB", NULL, 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Arabic (Saudi Arabia)"), "ar_SA", NULL, 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Armenian"), "hy_AM", "Հայերեն", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Azerbaijani"), "az_AZ", "Azərbaycanca", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Basque"), "eu_ES", "Euskara", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Belarusian"), "be_BY", "Беларуская мова", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Bengali"), "bn_BD", "বাংলা", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Bengali (India)"), "bn_IN", "বাংলা", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Bulgarian"), "bg_BG", "Български", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Bosnian"), "bs_BA", "Bosanski", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Catalan"), "ca_ES", "Català", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Chinese (China Mainland)"), "zh_CN", "中文 (中国大陆)", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Chinese (Hong Kong)"), "zh_HK", "中文 (香港)", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Chinese (Singapore)"), "zh_SG", "中文 (新加坡)", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Chinese (Taiwan)"), "zh_TW", "中文 (台灣)", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Croatian"), "hr_HR", "Hrvatski", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Czech"), "cs_CZ", "čeština", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Danish"), "da_DK", "dansk", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Dutch"), "nl_NL", "Nederlands", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Dutch (Belgium)"), "nl_BE", "Nederlands (België)", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|English (USA)"), "en_US", "American English", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|English (Australia)"), "en_AU", "Australian English", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|English (UK)"), "en_GB", "British English", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|English (Canada)"), "en_CA", "Canadian English", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|English (Ireland)"), "en_IE", "Irish English", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|English (Denmark)"), "en_DK", "Danish English", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|English (South Africa)"), "en_ZA", "South African English", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|English (Malta)"), "en_MT", "Maltese English", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|English (New Zealand)"), "en_NZ", "New Zealand English", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Estonian"), "et_EE", "Eesti", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Finnish"), "fi_FI", "Suomi", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|French"), "fr_FR", "Français", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|French (Belgium)"), "fr_BE", "Français (Belgique)", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|French (Canada)"), "fr_CA", "Français (Canada)", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|French (Luxembourg)"), "fr_LU", "Français (Luxembourg)", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|French (Switzerland)"), "fr_CH", "Français (Suisse)", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Galician"), "gl_ES", "Galego", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|German"), "de_DE", "Deutsch", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|German (Austria)"), "de_AT", "Deutsch (Österreich)", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|German (Luxembourg)"), "de_LU", "Deutsch (Luxemburg)", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|German (Switzerland)"), "de_CH", "Deutsch (Schweiz)", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Greek"), "el_GR", "Ελληνικά", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Greek (Cyprus)"), "el_CY", "Ελληνικά (Κύπρος)", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Gujarati"), "gu_IN", "ગુજરાતી", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Hebrew"), "he_IL", "עברית", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Hebrew"), "iw_IL", "עברית", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Hindi"), "hi_IN", "हिंदी", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Hungarian"), "hu_HU", "Magyar", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Icelandic"), "is_IS", NULL, 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Indonesian"), "id_ID", "Bahasa Indonesia", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Interlingua"), "ia", NULL, 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Irish"), "ga_IE", "Gaeilge", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Italian"), "it_IT", "Italiano", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Japanese"), "ja_JP", "日本語", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Kannada"), "kn_IN", "ಕನ್ನಡ", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Kinyarwanda"), "rw_RW", "Kinyarwanda", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Korean"), "ko_KR", "한국어", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Latvian"), "lv_LV", "Latviešu", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Lithuanian"), "lt_LT", "Lietuvių", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Macedonian"), "mk_MK", NULL, 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Malay"), "ms_MY", "Bahasa Melayu", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Malayalam"), "ml_IN", "മലയാളം", 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Maltese"), "mt_MT", NULL, 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Marathi"), "mr_IN", NULL, 0 },
- /*Note translate the A-M to the A-M you used in the group label */
- { N_("A-M|Mongolian"), "mn_MN", "Монгол", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Northern Sotho"), "nso_ZA", "Sesotho sa Leboa", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Norwegian (bokmal)"), "no_NO", "Norsk (bokmål)", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Norwegian (nynorsk)"), "nn_NO", "Norsk (nynorsk)", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Oriya"), "or_IN", NULL, 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Punjabi"), "pa_IN", NULL, 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Persian"), "fa_IR", "فارسی", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Polish"), "pl_PL", "Polski", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Portuguese"), "pt_PT", "Português", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Portuguese (Brazilian)"), "pt_BR", "Português do Brasil", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Romanian"), "ro_RO", "Română", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Russian"), "ru_RU", "русский", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Serbian"), "sr_YU", "српски", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Serbian (Serbia & Montenegro)"), "sr_CS", "српски", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Serbian (Montenegro)"), "sr_ME", "српски", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Serbian (Serbia)"), "sr_RS", "српски", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Serbian (Latin)"), "sr_CS@Latn", "srpski (latinica)", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Serbian (Jekavian)"), "sr_CS@ije", "српски (ијекавски)", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Serbian (Bosnia)"), "sh_BA", "srpski (Bosna i Hercegovina)", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Slovak"), "sk_SK", "Slovenský", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Slovenian"), "sl_SI", "Slovenščina", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Spanish"), "es_ES", "Español", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Spanish (Argentina)"), "es_AR", "Español (Argentina)", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Spanish (Bolivia)"), "es_BO", "Español (Bolivia)", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Spanish (Chile)"), "es_CL", "Español (Chile)", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Spanish (Colombia)"), "es_CO", "Español (Colombia)", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Spanish (Costa Rica)"), "es_CR", "Español (Costa Rica)", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Spanish (Ecuador)"), "es_EC", "Español (Ecuador)", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Spanish (Guatemala)"), "es_GT", "Español (Guatemala)", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Spanish (Mexico)"), "es_MX", "Español (México)", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Spanish (Nicaragua)"), "es_NI", "Español (Nicaragua)", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Spanish (Panama)"), "es_PA", "Español (Panamá)", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Spanish (Peru)"), "es_PE", "Español (Perú)", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Spanish (Paraguay)"), "es_PY", "Español (Paraguay)", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Spanish (El Salvador)"), "es_SV", "Español (El Salvador)", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Spanish (Uruguay)"), "es_UY", "Español (Uruguay)", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Spanish (Venezuela)"), "es_VE", "Español (Venezuela)", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Swedish"), "sv_SE", "Svenska", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Swedish (Finland)"), "sv_FI", "Svenska (Finland)", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Tamil"), "ta_IN", NULL, 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Telugu"), "te_IN", NULL, 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Thai"), "th_TH", "ไทย", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Turkish"), "tr_TR", "Türkçe", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Ukrainian"), "uk_UA", "Українська", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Vietnamese"), "vi_VN", "Việt Nam", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Walloon"), "wa_BE", "Walon", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Welsh"), "cy_GB", "Cymraeg", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Xhosa"), "xh_ZA", "isiXhosa", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Yiddish"), "yi", "ייִדיש", 0 },
- /*Note translate the N-Z to the N-Z you used in the group label */
- { N_("N-Z|Zulu"), "zu_ZA", "isiZulu", 0 },
- /* This is the POSIX/C locale for english, should really be in Other */
- { N_("Other|POSIX/C English"), "C", "POSIX/C English", 0 },
- { NULL, NULL }
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Afrikaans"), "af_ZA", NULL, 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Albanian"), "sq_AL", "Shqip", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Amharic"), "am_ET", NULL, 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Arabic (Egypt)"), "ar_EG", NULL, 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Arabic (Lebanon)"), "ar_LB", NULL, 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Arabic (Saudi Arabia)"), "ar_SA", NULL, 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Armenian"), "hy_AM", "Հայերեն", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Azerbaijani"), "az_AZ", "Azərbaycanca", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Basque"), "eu_ES", "Euskara", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Belarusian"), "be_BY", "Беларуская мова", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Bengali"), "bn_BD", "বাংলা", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Bengali (India)"), "bn_IN", "বাংলা", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Bulgarian"), "bg_BG", "Български", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Bosnian"), "bs_BA", "Bosanski", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Catalan"), "ca_ES", "Català", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Chinese (China Mainland)"), "zh_CN", "中文 (中国大陆)", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Chinese (Hong Kong)"), "zh_HK", "中文 (香港)", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Chinese (Singapore)"), "zh_SG", "中文 (新加坡)", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Chinese (Taiwan)"), "zh_TW", "中文 (台灣)", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Croatian"), "hr_HR", "Hrvatski", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Czech"), "cs_CZ", "čeština", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Danish"), "da_DK", "dansk", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Dutch"), "nl_NL", "Nederlands", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Dutch (Belgium)"), "nl_BE", "Nederlands (België)", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|English (USA)"), "en_US", "American English", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|English (Australia)"), "en_AU", "Australian English", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|English (UK)"), "en_GB", "British English", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|English (Canada)"), "en_CA", "Canadian English", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|English (Ireland)"), "en_IE", "Irish English", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|English (Denmark)"), "en_DK", "Danish English", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|English (South Africa)"), "en_ZA", "South African English", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|English (Malta)"), "en_MT", "Maltese English", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|English (New Zealand)"), "en_NZ", "New Zealand English", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Estonian"), "et_EE", "Eesti", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Finnish"), "fi_FI", "Suomi", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|French"), "fr_FR", "Français", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|French (Belgium)"), "fr_BE", "Français (Belgique)", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|French (Canada)"), "fr_CA", "Français (Canada)", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|French (Luxembourg)"), "fr_LU", "Français (Luxembourg)", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|French (Switzerland)"), "fr_CH", "Français (Suisse)", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Galician"), "gl_ES", "Galego", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|German"), "de_DE", "Deutsch", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|German (Austria)"), "de_AT", "Deutsch (Österreich)", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|German (Luxembourg)"), "de_LU", "Deutsch (Luxemburg)", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|German (Switzerland)"), "de_CH", "Deutsch (Schweiz)", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Greek"), "el_GR", "Ελληνικά", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Greek (Cyprus)"), "el_CY", "Ελληνικά (Κύπρος)", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Gujarati"), "gu_IN", "ગુજરાતી", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Hebrew"), "he_IL", "עברית", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Hebrew"), "iw_IL", "עברית", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Hindi"), "hi_IN", "हिंदी", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Hungarian"), "hu_HU", "Magyar", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Icelandic"), "is_IS", NULL, 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Indonesian"), "id_ID", "Bahasa Indonesia", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Interlingua"), "ia", NULL, 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Irish"), "ga_IE", "Gaeilge", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Italian"), "it_IT", "Italiano", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Japanese"), "ja_JP", "日本語", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Kannada"), "kn_IN", "ಕನ್ನಡ", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Kinyarwanda"), "rw_RW", "Kinyarwanda", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Korean"), "ko_KR", "한국어", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Latvian"), "lv_LV", "Latviešu", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Lithuanian"), "lt_LT", "Lietuvių", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Macedonian"), "mk_MK", NULL, 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Malay"), "ms_MY", "Bahasa Melayu", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Malayalam"), "ml_IN", "മലയാളം", 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Maltese"), "mt_MT", NULL, 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Marathi"), "mr_IN", NULL, 0 },
+ /*Note translate the A-M to the A-M you used in the group label */
+ { N_("A-M|Mongolian"), "mn_MN", "Монгол", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Northern Sotho"), "nso_ZA", "Sesotho sa Leboa", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Norwegian (bokmal)"), "no_NO", "Norsk (bokmål)", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Norwegian (nynorsk)"), "nn_NO", "Norsk (nynorsk)", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Oriya"), "or_IN", NULL, 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Punjabi"), "pa_IN", NULL, 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Persian"), "fa_IR", "فارسی", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Polish"), "pl_PL", "Polski", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Portuguese"), "pt_PT", "Português", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Portuguese (Brazilian)"), "pt_BR", "Português do Brasil", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Romanian"), "ro_RO", "Română", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Russian"), "ru_RU", "русский", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Serbian"), "sr_YU", "српски", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Serbian (Serbia & Montenegro)"), "sr_CS", "српски", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Serbian (Montenegro)"), "sr_ME", "српски", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Serbian (Serbia)"), "sr_RS", "српски", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Serbian (Latin)"), "sr_CS@Latn", "srpski (latinica)", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Serbian (Jekavian)"), "sr_CS@ije", "српски (ијекавски)", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Serbian (Bosnia)"), "sh_BA", "srpski (Bosna i Hercegovina)", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Slovak"), "sk_SK", "Slovenský", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Slovenian"), "sl_SI", "Slovenščina", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Spanish"), "es_ES", "Español", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Spanish (Argentina)"), "es_AR", "Español (Argentina)", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Spanish (Bolivia)"), "es_BO", "Español (Bolivia)", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Spanish (Chile)"), "es_CL", "Español (Chile)", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Spanish (Colombia)"), "es_CO", "Español (Colombia)", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Spanish (Costa Rica)"), "es_CR", "Español (Costa Rica)", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Spanish (Ecuador)"), "es_EC", "Español (Ecuador)", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Spanish (Guatemala)"), "es_GT", "Español (Guatemala)", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Spanish (Mexico)"), "es_MX", "Español (México)", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Spanish (Nicaragua)"), "es_NI", "Español (Nicaragua)", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Spanish (Panama)"), "es_PA", "Español (Panamá)", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Spanish (Peru)"), "es_PE", "Español (Perú)", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Spanish (Paraguay)"), "es_PY", "Español (Paraguay)", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Spanish (El Salvador)"), "es_SV", "Español (El Salvador)", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Spanish (Uruguay)"), "es_UY", "Español (Uruguay)", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Spanish (Venezuela)"), "es_VE", "Español (Venezuela)", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Swedish"), "sv_SE", "Svenska", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Swedish (Finland)"), "sv_FI", "Svenska (Finland)", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Tamil"), "ta_IN", NULL, 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Telugu"), "te_IN", NULL, 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Thai"), "th_TH", "ไทย", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Turkish"), "tr_TR", "Türkçe", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Ukrainian"), "uk_UA", "Українська", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Vietnamese"), "vi_VN", "Việt Nam", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Walloon"), "wa_BE", "Walon", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Welsh"), "cy_GB", "Cymraeg", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Xhosa"), "xh_ZA", "isiXhosa", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Yiddish"), "yi", "ייִדיש", 0 },
+ /*Note translate the N-Z to the N-Z you used in the group label */
+ { N_("N-Z|Zulu"), "zu_ZA", "isiZulu", 0 },
+ /* This is the POSIX/C locale for english, should really be in Other */
+ { N_("Other|POSIX/C English"), "C", "POSIX/C English", 0 },
+ { NULL, NULL }
};
static GHashTable *lang_names = NULL;
@@ -311,347 +311,347 @@ static GHashTable *lang_names = NULL;
static void
gdm_lang_init (void)
{
- int i;
- if (lang_names != NULL)
- return;
+ int i;
+ if (lang_names != NULL)
+ return;
- lang_names = g_hash_table_new (g_str_hash, g_str_equal);
+ lang_names = g_hash_table_new (g_str_hash, g_str_equal);
- for (i = 0; languages[i].name != NULL; i++) {
- g_hash_table_insert (lang_names,
- languages[i].code,
- &languages[i]);
- }
+ for (i = 0; languages[i].name != NULL; i++) {
+ g_hash_table_insert (lang_names,
+ languages[i].code,
+ &languages[i]);
+ }
}
static Language *
find_lang (const char *language, gboolean *clean)
{
- char *name, *p;
- Language *lang;
-
- *clean = FALSE;
-
- lang = g_hash_table_lookup (lang_names, language);
- if (lang != NULL) {
- *clean = TRUE;
- return lang;
- }
-
- name = g_strdup (language);
-
- p = strrchr (name, '@');
- if (p != NULL) {
- char *mod = p+1;
- *p = '\0';
-
- /* attempt lookup without encoding but with the
- modifier first */
- p = strrchr (name, '.');
- if (p != NULL) {
- char *noenc;
- *p = '\0';
-
- noenc = g_strconcat (name, "@", mod, NULL);
- lang = g_hash_table_lookup (lang_names, noenc);
- if (lang != NULL) {
- g_free (name);
- g_free (noenc);
- return lang;
- }
- g_free (noenc);
-
- *p = '.';
- }
-
- lang = g_hash_table_lookup (lang_names, name);
- if (lang != NULL) {
- g_free (name);
- return lang;
- }
- }
-
- p = strrchr (name, '.');
- if (p != NULL) {
- *p = '\0';
- lang = g_hash_table_lookup (lang_names, name);
- if (lang != NULL) {
- g_free (name);
- return lang;
- }
- }
-
- p = strrchr (name, '_');
- if (p != NULL) {
- *p = '\0';
- lang = g_hash_table_lookup (lang_names, name);
- if (lang != NULL) {
- g_free (name);
- return lang;
- }
- }
-
- g_free (name);
- return NULL;
+ char *name, *p;
+ Language *lang;
+
+ *clean = FALSE;
+
+ lang = g_hash_table_lookup (lang_names, language);
+ if (lang != NULL) {
+ *clean = TRUE;
+ return lang;
+ }
+
+ name = g_strdup (language);
+
+ p = strrchr (name, '@');
+ if (p != NULL) {
+ char *mod = p+1;
+ *p = '\0';
+
+ /* attempt lookup without encoding but with the
+ modifier first */
+ p = strrchr (name, '.');
+ if (p != NULL) {
+ char *noenc;
+ *p = '\0';
+
+ noenc = g_strconcat (name, "@", mod, NULL);
+ lang = g_hash_table_lookup (lang_names, noenc);
+ if (lang != NULL) {
+ g_free (name);
+ g_free (noenc);
+ return lang;
+ }
+ g_free (noenc);
+
+ *p = '.';
+ }
+
+ lang = g_hash_table_lookup (lang_names, name);
+ if (lang != NULL) {
+ g_free (name);
+ return lang;
+ }
+ }
+
+ p = strrchr (name, '.');
+ if (p != NULL) {
+ *p = '\0';
+ lang = g_hash_table_lookup (lang_names, name);
+ if (lang != NULL) {
+ g_free (name);
+ return lang;
+ }
+ }
+
+ p = strrchr (name, '_');
+ if (p != NULL) {
+ *p = '\0';
+ lang = g_hash_table_lookup (lang_names, name);
+ if (lang != NULL) {
+ g_free (name);
+ return lang;
+ }
+ }
+
+ g_free (name);
+ return NULL;
}
gboolean
gdm_lang_name_translated (const char *language)
{
- Language *lang;
- gboolean clean;
+ Language *lang;
+ gboolean clean;
- gdm_lang_init ();
+ gdm_lang_init ();
- lang = find_lang (language, &clean);
- if (lang == NULL)
- return FALSE;
+ lang = find_lang (language, &clean);
+ if (lang == NULL)
+ return FALSE;
- if (strcmp (lang->name, _(lang->name)) == 0)
- return FALSE;
+ if (strcmp (lang->name, _(lang->name)) == 0)
+ return FALSE;
- return TRUE;
+ return TRUE;
}
char *
gdm_lang_name (const char *language,
- gboolean never_encoding,
- gboolean no_group,
- gboolean untranslated,
- gboolean markup)
+ gboolean never_encoding,
+ gboolean no_group,
+ gboolean untranslated,
+ gboolean markup)
{
- Language *lang;
- char *name;
- gboolean clean;
- const char *encoding;
-
- gdm_lang_init ();
-
- lang = find_lang (language, &clean);
- if (lang == NULL)
- return g_strdup (language);
-
- encoding = strchr (language, '.');
- if (encoding == NULL)
- encoding = strchr (language, '@'); /* treat a modifier without a codeset as an encoding */
- if (encoding != NULL)
- encoding++;
-
- /* if more then one language in the language file with this
- * locale, then hell, include the encoding to differentiate them */
- if (lang->found > 1 &&
- encoding != NULL &&
- ! never_encoding)
- name = g_strdup_printf ("%s (%s)", _(lang->name), encoding);
- else
- name = g_strdup (_(lang->name));
-
- if (lang->untranslated != NULL && untranslated) {
- char *full;
- full = g_strdup_printf ("%s (%s)",
- name, lang->untranslated);
- g_free (name);
- name = full;
- }
-
- if (no_group) {
- char *p = strchr (name, '|');
- if (p != NULL) {
- p = g_strdup (p + 1);
- g_free (name);
- name = p;
- }
- }
-
- return name;
+ Language *lang;
+ char *name;
+ gboolean clean;
+ const char *encoding;
+
+ gdm_lang_init ();
+
+ lang = find_lang (language, &clean);
+ if (lang == NULL)
+ return g_strdup (language);
+
+ encoding = strchr (language, '.');
+ if (encoding == NULL)
+ encoding = strchr (language, '@'); /* treat a modifier without a codeset as an encoding */
+ if (encoding != NULL)
+ encoding++;
+
+ /* if more then one language in the language file with this
+ * locale, then hell, include the encoding to differentiate them */
+ if (lang->found > 1 &&
+ encoding != NULL &&
+ ! never_encoding)
+ name = g_strdup_printf ("%s (%s)", _(lang->name), encoding);
+ else
+ name = g_strdup (_(lang->name));
+
+ if (lang->untranslated != NULL && untranslated) {
+ char *full;
+ full = g_strdup_printf ("%s (%s)",
+ name, lang->untranslated);
+ g_free (name);
+ name = full;
+ }
+
+ if (no_group) {
+ char *p = strchr (name, '|');
+ if (p != NULL) {
+ p = g_strdup (p + 1);
+ g_free (name);
+ name = p;
+ }
+ }
+
+ return name;
}
/* NULL if not found */
char *
gdm_lang_untranslated_name (const char *language,
- gboolean markup)
+ gboolean markup)
{
- Language *lang;
- gboolean clean;
+ Language *lang;
+ gboolean clean;
- gdm_lang_init ();
+ gdm_lang_init ();
- lang = find_lang (language, &clean);
- if (lang == NULL)
- return NULL;
+ lang = find_lang (language, &clean);
+ if (lang == NULL)
+ return NULL;
- return g_strdup (lang->untranslated);
+ return g_strdup (lang->untranslated);
}
const char *
gdm_lang_group1 (void)
{
- /* This should be the same as in the front of the language strings
- * else the languages will appear in the "Other" submenu */
- return _("A-M");
+ /* This should be the same as in the front of the language strings
+ * else the languages will appear in the "Other" submenu */
+ return _("A-M");
}
const char *
gdm_lang_group2 (void)
{
- /* This should be the same as in the front of the language strings
- * else the languages will appear in the "Other" submenu */
- return _("N-Z");
+ /* This should be the same as in the front of the language strings
+ * else the languages will appear in the "Other" submenu */
+ return _("N-Z");
}
static int
lang_collate (gconstpointer a, gconstpointer b)
{
- gboolean clean;
- Language *l1 = find_lang ((const char *)a, &clean);
- Language *l2 = find_lang ((const char *)b, &clean);
-
- /* paranoia */
- if (l1 == NULL || l2 == NULL)
- return 0;
-
- if (l1->collate_key == NULL) {
- const char *name;
- name = strchr (_(l1->name), '|');
- if (name != NULL)
- name++;
- else
- name = _(l1->name);
- l1->collate_key = g_utf8_collate_key (name, -1);
- }
-
- if (l2->collate_key == NULL) {
- const char *name;
- name = strchr (_(l2->name), '|');
- if (name != NULL)
- name++;
- else
- name = _(l2->name);
- l2->collate_key = g_utf8_collate_key (name, -1);
- }
-
- return strcmp (l1->collate_key, l2->collate_key);
+ gboolean clean;
+ Language *l1 = find_lang ((const char *)a, &clean);
+ Language *l2 = find_lang ((const char *)b, &clean);
+
+ /* paranoia */
+ if (l1 == NULL || l2 == NULL)
+ return 0;
+
+ if (l1->collate_key == NULL) {
+ const char *name;
+ name = strchr (_(l1->name), '|');
+ if (name != NULL)
+ name++;
+ else
+ name = _(l1->name);
+ l1->collate_key = g_utf8_collate_key (name, -1);
+ }
+
+ if (l2->collate_key == NULL) {
+ const char *name;
+ name = strchr (_(l2->name), '|');
+ if (name != NULL)
+ name++;
+ else
+ name = _(l2->name);
+ l2->collate_key = g_utf8_collate_key (name, -1);
+ }
+
+ return strcmp (l1->collate_key, l2->collate_key);
}
GList *
gdm_lang_read_locale_file (const char *locale_file)
{
- FILE *langlist;
- char curline[256];
- GList *langs = NULL;
- GHashTable *dupcheck;
- gboolean got_english = FALSE;
- Language *language;
- gboolean clean;
- char *getsret;
- char *p;
-
- if (locale_file == NULL)
- return NULL;
-
- VE_IGNORE_EINTR (langlist = fopen (locale_file, "r"));
-
- if (langlist == NULL)
- return NULL;
-
- gdm_lang_init ();
-
- dupcheck = g_hash_table_new (g_str_hash, g_str_equal);
-
- for (;;) {
- char *name;
- char *lang;
- char **lang_list;
- int i;
-
- VE_IGNORE_EINTR (getsret = fgets (curline, sizeof (curline), langlist));
- if (getsret == NULL)
- break;
-
- if (curline[0] <= ' ' ||
- curline[0] == '#')
- continue;
-
- name = strtok (curline, " \t\r\n");
- if (name == NULL)
- continue;
-
- lang = strtok (NULL, " \t\r\n");
- if (lang == NULL)
- continue;
-
- lang_list = g_strsplit (lang, ",", -1);
- if (lang_list == NULL)
- continue;
-
- lang = NULL;
- for (i = 0; lang_list[i] != NULL; i++) {
- if (ve_locale_exists (lang_list[i])) {
- lang = lang_list[i];
- break;
- }
- }
- if (lang == NULL ||
- g_hash_table_lookup (dupcheck, lang) != NULL) {
- g_strfreev (lang_list);
- continue;
- }
- language = find_lang (lang, &clean);
-
- if (language != NULL) {
- language->found++;
- } else {
- language = g_new0 (Language, 1);
- language->found = 1;
- /* add a space before an open bracket to match
- the style used in the internal list.
- e.g. change "English(India)" to "English (India)" */
- p = strchr (name, '(');
- if (p != NULL && p > name && *(p-1) != ' ') {
- *p = 0;
- language->name= g_strconcat (name, " (", p+1, NULL);
- } else
- language->name = g_strdup (name);
- /* only store the "lang_country" part of the locale code, so that we notice
- * if there is more than one encoding of this language. See bug 132629. */
- p = strchr (lang, '.');
- if (p == NULL)
- p = strchr (lang, '@');
- if (p != NULL)
- language->code = g_strndup (lang, (p - lang));
- else
- language->code = g_strdup (lang);
- language->untranslated = NULL;
- g_hash_table_insert (lang_names,
- language->code,
- language);
- }
-
- langs = g_list_prepend (langs, g_strdup (lang));
- g_hash_table_insert (dupcheck, g_strdup (lang),
- GINT_TO_POINTER (1));
-
- /* if we have an english locale */
- if (strncmp (lang, "en_", 3) == 0 ||
- strcmp (lang, "C") == 0)
- got_english = TRUE;
-
- g_strfreev (lang_list);
- }
-
- g_hash_table_foreach (dupcheck, (GHFunc) g_free, NULL);
- g_hash_table_destroy (dupcheck);
-
- /* If we haven't found any english locale, add american
- * english as that's as much of a fallback as we can get */
- if ( ! got_english)
- langs = g_list_prepend (langs, g_strdup ("en_US"));
-
- langs = g_list_sort (langs, lang_collate);
-
- VE_IGNORE_EINTR (fclose (langlist));
-
- return langs;
+ FILE *langlist;
+ char curline[256];
+ GList *langs = NULL;
+ GHashTable *dupcheck;
+ gboolean got_english = FALSE;
+ Language *language;
+ gboolean clean;
+ char *getsret;
+ char *p;
+
+ if (locale_file == NULL)
+ return NULL;
+
+ VE_IGNORE_EINTR (langlist = fopen (locale_file, "r"));
+
+ if (langlist == NULL)
+ return NULL;
+
+ gdm_lang_init ();
+
+ dupcheck = g_hash_table_new (g_str_hash, g_str_equal);
+
+ for (;;) {
+ char *name;
+ char *lang;
+ char **lang_list;
+ int i;
+
+ VE_IGNORE_EINTR (getsret = fgets (curline, sizeof (curline), langlist));
+ if (getsret == NULL)
+ break;
+
+ if (curline[0] <= ' ' ||
+ curline[0] == '#')
+ continue;
+
+ name = strtok (curline, " \t\r\n");
+ if (name == NULL)
+ continue;
+
+ lang = strtok (NULL, " \t\r\n");
+ if (lang == NULL)
+ continue;
+
+ lang_list = g_strsplit (lang, ",", -1);
+ if (lang_list == NULL)
+ continue;
+
+ lang = NULL;
+ for (i = 0; lang_list[i] != NULL; i++) {
+ if (ve_locale_exists (lang_list[i])) {
+ lang = lang_list[i];
+ break;
+ }
+ }
+ if (lang == NULL ||
+ g_hash_table_lookup (dupcheck, lang) != NULL) {
+ g_strfreev (lang_list);
+ continue;
+ }
+ language = find_lang (lang, &clean);
+
+ if (language != NULL) {
+ language->found++;
+ } else {
+ language = g_new0 (Language, 1);
+ language->found = 1;
+ /* add a space before an open bracket to match
+ the style used in the internal list.
+ e.g. change "English(India)" to "English (India)" */
+ p = strchr (name, '(');
+ if (p != NULL && p > name && *(p-1) != ' ') {
+ *p = 0;
+ language->name= g_strconcat (name, " (", p+1, NULL);
+ } else
+ language->name = g_strdup (name);
+ /* only store the "lang_country" part of the locale code, so that we notice
+ * if there is more than one encoding of this language. See bug 132629. */
+ p = strchr (lang, '.');
+ if (p == NULL)
+ p = strchr (lang, '@');
+ if (p != NULL)
+ language->code = g_strndup (lang, (p - lang));
+ else
+ language->code = g_strdup (lang);
+ language->untranslated = NULL;
+ g_hash_table_insert (lang_names,
+ language->code,
+ language);
+ }
+
+ langs = g_list_prepend (langs, g_strdup (lang));
+ g_hash_table_insert (dupcheck, g_strdup (lang),
+ GINT_TO_POINTER (1));
+
+ /* if we have an english locale */
+ if (strncmp (lang, "en_", 3) == 0 ||
+ strcmp (lang, "C") == 0)
+ got_english = TRUE;
+
+ g_strfreev (lang_list);
+ }
+
+ g_hash_table_foreach (dupcheck, (GHFunc) g_free, NULL);
+ g_hash_table_destroy (dupcheck);
+
+ /* If we haven't found any english locale, add american
+ * english as that's as much of a fallback as we can get */
+ if ( ! got_english)
+ langs = g_list_prepend (langs, g_strdup ("en_US"));
+
+ langs = g_list_sort (langs, lang_collate);
+
+ VE_IGNORE_EINTR (fclose (langlist));
+
+ return langs;
}
GtkListStore *
@@ -669,23 +669,23 @@ gdm_lang_initialize_model (gchar * locale_file)
list = gdm_lang_read_locale_file (locale_file);
lang_model = gtk_list_store_new (NUM_COLUMNS,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING);
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
gtk_list_store_append (lang_model, &iter);
gtk_list_store_set (lang_model, &iter,
- TRANSLATED_NAME_COLUMN, _("Last language"),
- UNTRANSLATED_NAME_COLUMN, NULL,
- LOCALE_COLUMN, LAST_LANGUAGE,
- -1);
+ TRANSLATED_NAME_COLUMN, _("Last language"),
+ UNTRANSLATED_NAME_COLUMN, NULL,
+ LOCALE_COLUMN, LAST_LANGUAGE,
+ -1);
gtk_list_store_append (lang_model, &iter);
gtk_list_store_set (lang_model, &iter,
- TRANSLATED_NAME_COLUMN, _("System Default"),
- UNTRANSLATED_NAME_COLUMN, NULL,
- LOCALE_COLUMN, DEFAULT_LANGUAGE,
- -1);
+ TRANSLATED_NAME_COLUMN, _("System Default"),
+ UNTRANSLATED_NAME_COLUMN, NULL,
+ LOCALE_COLUMN, DEFAULT_LANGUAGE,
+ -1);
for (li = list; li != NULL; li = li->next)
{
@@ -703,20 +703,20 @@ gdm_lang_initialize_model (gchar * locale_file)
#endif
name = gdm_lang_name (lang,
- FALSE /* never_encoding */,
- TRUE /* no_group */,
- FALSE /* untranslated */,
- FALSE /* markup */);
+ FALSE /* never_encoding */,
+ TRUE /* no_group */,
+ FALSE /* untranslated */,
+ FALSE /* markup */);
untranslated = gdm_lang_untranslated_name (lang,
- TRUE /* markup */);
+ TRUE /* markup */);
gtk_list_store_append (lang_model, &iter);
gtk_list_store_set (lang_model, &iter,
- TRANSLATED_NAME_COLUMN, name,
- UNTRANSLATED_NAME_COLUMN, untranslated,
- LOCALE_COLUMN, lang,
- -1);
+ TRANSLATED_NAME_COLUMN, name,
+ UNTRANSLATED_NAME_COLUMN, untranslated,
+ LOCALE_COLUMN, lang,
+ -1);
g_free (name);
g_free (untranslated);
@@ -746,46 +746,46 @@ gdm_lang_check_language (const char *old_language)
if (current_language != NULL && strcmp (current_language, LAST_LANGUAGE) != 0)
{
if (strcmp (current_language, DEFAULT_LANGUAGE) == 0)
- retval = g_strdup ("");
+ retval = g_strdup ("");
else
retval = g_strdup (current_language);
/* User's saved language is not the chosen one */
if (strcmp (old_language, retval) != 0)
- {
- gchar *primary_message;
- gchar *secondary_message;
- char *current_name, *saved_name;
-
- if (strcmp (current_language, DEFAULT_LANGUAGE) == 0)
- current_name = g_strdup (_("System Default"));
- else
- current_name = gdm_lang_name (current_language,
- FALSE /* never_encoding */,
- TRUE /* no_group */,
- TRUE /* untranslated */,
- TRUE /* markup */);
- if (strcmp (old_language, "") == 0)
- saved_name = g_strdup (_("System Default"));
- else
- saved_name = gdm_lang_name (old_language,
- FALSE /* never_encoding */,
- TRUE /* no_group */,
- TRUE /* untranslated */,
- TRUE /* markup */);
-
- primary_message = g_strdup_printf (_("Do you wish to make %s the default for future sessions?"),
- current_name);
- secondary_message = g_strdup_printf (_("You have chosen %s for this session, but your default setting is "
- "%s."), current_name, saved_name);
- g_free (current_name);
- g_free (saved_name);
-
- savelang = gdm_wm_query_dialog (primary_message, secondary_message,
- _("Make _Default"), _("Just For _This Session"), TRUE);
- g_free (primary_message);
- g_free (secondary_message);
- }
+ {
+ gchar *primary_message;
+ gchar *secondary_message;
+ char *current_name, *saved_name;
+
+ if (strcmp (current_language, DEFAULT_LANGUAGE) == 0)
+ current_name = g_strdup (_("System Default"));
+ else
+ current_name = gdm_lang_name (current_language,
+ FALSE /* never_encoding */,
+ TRUE /* no_group */,
+ TRUE /* untranslated */,
+ TRUE /* markup */);
+ if (strcmp (old_language, "") == 0)
+ saved_name = g_strdup (_("System Default"));
+ else
+ saved_name = gdm_lang_name (old_language,
+ FALSE /* never_encoding */,
+ TRUE /* no_group */,
+ TRUE /* untranslated */,
+ TRUE /* markup */);
+
+ primary_message = g_strdup_printf (_("Do you wish to make %s the default for future sessions?"),
+ current_name);
+ secondary_message = g_strdup_printf (_("You have chosen %s for this session, but your default setting is "
+ "%s."), current_name, saved_name);
+ g_free (current_name);
+ g_free (saved_name);
+
+ savelang = gdm_wm_query_dialog (primary_message, secondary_message,
+ _("Make _Default"), _("Just For _This Session"), TRUE);
+ g_free (primary_message);
+ g_free (secondary_message);
+ }
}
else
{
@@ -797,7 +797,7 @@ gdm_lang_check_language (const char *old_language)
static void
selection_changed (GtkTreeSelection *selection,
- gpointer data)
+ gpointer data)
{
GtkTreeIter iter;
@@ -819,8 +819,8 @@ tree_row_activated (GtkTreeView *view,
{
g_free (dialog_selected_language);
gtk_tree_model_get (GTK_TREE_MODEL (lang_model), &iter,
- LOCALE_COLUMN, &dialog_selected_language,
- -1);
+ LOCALE_COLUMN, &dialog_selected_language,
+ -1);
gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
}
}
@@ -839,20 +839,20 @@ gdm_lang_setup_treeview (void)
dialog = gtk_dialog_new_with_buttons (_("Select a Language"),
#ifdef TODO
- GTK_WINDOW (parent_window),
+ GTK_WINDOW (parent_window),
#endif
- NULL,
- 0,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL,
- NULL);
-
+ NULL,
+ 0,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ NULL);
+
button = gtk_button_new_with_mnemonic (_("Change _Language"));
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_widget_show (button);
gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button,
GTK_RESPONSE_OK);
-
+
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
@@ -863,7 +863,7 @@ gdm_lang_setup_treeview (void)
main_vbox, TRUE, TRUE, 0);
gtk_dialog_set_default_response (GTK_DIALOG (dialog),
- GTK_RESPONSE_OK);
+ GTK_RESPONSE_OK);
/* evil gcc warnings */
tmp_p = &dialog;
g_object_add_weak_pointer (G_OBJECT (dialog), (gpointer *)tmp_p);
@@ -873,7 +873,7 @@ gdm_lang_setup_treeview (void)
g_free (s);
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
gtk_box_pack_start (GTK_BOX (main_vbox),
- label, FALSE, FALSE, 0);
+ label, FALSE, FALSE, 0);
tv = gtk_tree_view_new ();
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tv), TRUE);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), tv);
@@ -882,66 +882,66 @@ gdm_lang_setup_treeview (void)
gtk_widget_set_direction (tv, GTK_TEXT_DIR_LTR);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tv), FALSE);
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tv),
- GTK_DIALOG_MODAL,
- NULL,
- gtk_cell_renderer_text_new (),
- "text", TRANSLATED_NAME_COLUMN,
- NULL);
+ GTK_DIALOG_MODAL,
+ NULL,
+ gtk_cell_renderer_text_new (),
+ "text", TRANSLATED_NAME_COLUMN,
+ NULL);
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tv),
- GTK_DIALOG_MODAL,
- NULL,
- gtk_cell_renderer_text_new (),
- "markup",
- UNTRANSLATED_NAME_COLUMN,
- NULL);
+ GTK_DIALOG_MODAL,
+ NULL,
+ gtk_cell_renderer_text_new (),
+ "markup",
+ UNTRANSLATED_NAME_COLUMN,
+ NULL);
swindow = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swindow), GTK_SHADOW_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (swindow), tv);
gtk_box_pack_start (GTK_BOX (main_vbox),
- swindow, TRUE, TRUE, 0);
+ swindow, TRUE, TRUE, 0);
gtk_window_set_default_size (GTK_WINDOW (dialog),
- MIN (400, gdm_wm_screen.width),
- MIN (600, gdm_wm_screen.height));
+ MIN (400, gdm_wm_screen.width),
+ MIN (600, gdm_wm_screen.height));
g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (tv))),
- "changed",
- (GCallback) selection_changed,
- NULL);
+ "changed",
+ (GCallback) selection_changed,
+ NULL);
g_signal_connect (G_OBJECT (tv),
"row_activated",
(GCallback) tree_row_activated,
NULL);
gtk_tree_view_set_model (GTK_TREE_VIEW (tv),
- GTK_TREE_MODEL (lang_model));
+ GTK_TREE_MODEL (lang_model));
}
}
gint
gdm_lang_ask_restart (gchar *language)
{
- gchar *firstmsg;
- gchar *secondmsg;
- gchar *login;
- gint response = GTK_RESPONSE_NO;
+ gchar *firstmsg;
+ gchar *secondmsg;
+ gchar *login;
+ gint response = GTK_RESPONSE_NO;
- if (always_restart)
- return GTK_RESPONSE_YES;
+ if (always_restart)
+ return GTK_RESPONSE_YES;
- login = _("the login screen");
- firstmsg = g_strdup_printf (_("Do you wish to restart %s with the chosen language?"),
- login);
- secondmsg = g_strdup_printf (_("You will restart %s with the %s locale."),
- login,
- language);
+ login = _("the login screen");
+ firstmsg = g_strdup_printf (_("Do you wish to restart %s with the chosen language?"),
+ login);
+ secondmsg = g_strdup_printf (_("You will restart %s with the %s locale."),
+ login,
+ language);
- response = gdm_wm_query_dialog (firstmsg, secondmsg, _("_Yes"), _("_No"), FALSE);
+ response = gdm_wm_query_dialog (firstmsg, secondmsg, _("_Yes"), _("_No"), FALSE);
- g_free (firstmsg);
- g_free (secondmsg);
+ g_free (firstmsg);
+ g_free (secondmsg);
- return response;
+ return response;
}
static gboolean
@@ -1059,11 +1059,11 @@ gdm_lang_handler (gpointer user_data)
if (tv != NULL)
{
GtkTreeSelection *selection;
-
+
gtk_widget_show_now (dialog);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tv));
if (selection == NULL)
- gtk_tree_selection_select_path (selection, gtk_tree_path_new_first ());
+ gtk_tree_selection_select_path (selection, gtk_tree_path_new_first ());
else
{
GtkTreeIter iter;
diff --git a/libgreeter/gdmlanguages.h b/libgreeter/gdmlanguages.h
index de75d2d5..e46a53e4 100644
--- a/libgreeter/gdmlanguages.h
+++ b/libgreeter/gdmlanguages.h
@@ -38,33 +38,33 @@ enum {
/* This is the interface for translating languages. Language translations
* are now hardocded in, but that may change */
-const char * gdm_lang_group1 (void);
-const char * gdm_lang_group2 (void);
+const char * gdm_lang_group1 (void);
+const char * gdm_lang_group2 (void);
-char * gdm_lang_name (const char *language,
- gboolean never_encoding,
- gboolean no_group,
- gboolean untranslated,
- gboolean markup);
-gboolean gdm_lang_name_translated (const char *language);
+char * gdm_lang_name (const char *language,
+ gboolean never_encoding,
+ gboolean no_group,
+ gboolean untranslated,
+ gboolean markup);
+gboolean gdm_lang_name_translated (const char *language);
/* NULL if not found */
-char * gdm_lang_untranslated_name (const char *language,
- gboolean markup);
+char * gdm_lang_untranslated_name (const char *language,
+ gboolean markup);
-GList * gdm_lang_read_locale_file (const char *file);
+GList * gdm_lang_read_locale_file (const char *file);
-GtkListStore * gdm_lang_get_model (void);
-void gdm_lang_initialize_model (gchar *locale_file);
-gchar * gdm_lang_check_language (const char *old_language);
-void gdm_lang_set (char *language);
+GtkListStore * gdm_lang_get_model (void);
+void gdm_lang_initialize_model (gchar *locale_file);
+gchar * gdm_lang_check_language (const char *old_language);
+void gdm_lang_set (char *language);
void gdm_lang_set_restart_dialog (char *language);
-gint gdm_lang_get_savelang_setting (void);
-void gdm_lang_handler (gpointer user_data);
-void gdm_lang_op_lang (const gchar *args);
-void gdm_lang_op_slang (const gchar *args);
-void gdm_lang_op_setlang (const gchar *args);
-void gdm_lang_op_always_restart (const gchar *args);
+gint gdm_lang_get_savelang_setting (void);
+void gdm_lang_handler (gpointer user_data);
+void gdm_lang_op_lang (const gchar *args);
+void gdm_lang_op_slang (const gchar *args);
+void gdm_lang_op_setlang (const gchar *args);
+void gdm_lang_op_always_restart (const gchar *args);
gint gdm_lang_ask_restart (gchar *language);
#endif /* GDM_LANGUAGES_H */
diff --git a/libgreeter/gdmsession.c b/libgreeter/gdmsession.c
index f96db737..a7f58f66 100644
--- a/libgreeter/gdmsession.c
+++ b/libgreeter/gdmsession.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* GDM - The GNOME Display Manager
* Copyright (C) 1999, 2000 Martin K. Petersen <mkp@mkp.net>
@@ -50,73 +50,73 @@ gboolean session_dir_whacked_out = FALSE;
int
gdm_session_sort_func (const char *a, const char *b)
{
- int ret;
- char *default_session;
+ int ret;
+ char *default_session;
/* Put default and GNOME sessions at the top */
- default_session = NULL;
- if (! gdm_settings_client_get_string (GDM_KEY_DEFAULT_SESSION, &default_session)) {
- default_session = g_strdup ("default.desktop");
- }
+ default_session = NULL;
+ if (! gdm_settings_client_get_string (GDM_KEY_DEFAULT_SESSION, &default_session)) {
+ default_session = g_strdup ("default.desktop");
+ }
if (strcmp (a, default_session) == 0) {
- ret = -1;
- goto out;
- }
+ ret = -1;
+ goto out;
+ }
- if (strcmp (b, default_session) == 0) {
+ if (strcmp (b, default_session) == 0) {
ret = 1;
- goto out;
- }
+ goto out;
+ }
if (strcmp (a, "default.desktop") == 0) {
ret = -1;
- goto out;
- }
+ goto out;
+ }
if (strcmp (b, "default.desktop") == 0) {
ret = 1;
- goto out;
- }
+ goto out;
+ }
if (strcmp (a, "gnome.desktop") == 0) {
ret = -1;
- goto out;
- }
+ goto out;
+ }
if (strcmp (b, "gnome.desktop") == 0) {
ret = 1;
- goto out;
- }
+ goto out;
+ }
/* put failsafe sessions on the bottom */
- if (strcmp (b, GDM_SESSION_FAILSAFE_XTERM) == 0) {
+ if (strcmp (b, GDM_SESSION_FAILSAFE_XTERM) == 0) {
ret = -1;
- goto out;
- }
+ goto out;
+ }
if (strcmp (a, GDM_SESSION_FAILSAFE_XTERM) == 0) {
ret = 1;
- goto out;
- }
+ goto out;
+ }
if (strcmp (b, GDM_SESSION_FAILSAFE_GNOME) == 0) {
ret = -1;
- goto out;
- }
+ goto out;
+ }
if (strcmp (a, GDM_SESSION_FAILSAFE_GNOME) == 0) {
ret = 1;
- goto out;
- }
+ goto out;
+ }
/* put everything else in the middle in alphabetical order */
- ret = strcmp (a, b);
+ ret = strcmp (a, b);
out:
- g_free (default_session);
+ g_free (default_session);
- return ret;
+ return ret;
}
const char *
@@ -132,13 +132,13 @@ gdm_session_name (const char *name)
if (session != NULL && !ve_string_empty (session->name))
return session->name;
else
- return name;
+ return name;
}
void
gdm_session_list_from_hash_table_func (const char *key,
- const char *value,
- GList **sessions)
+ const char *value,
+ GList **sessions)
{
*sessions = g_list_prepend (*sessions, g_strdup (key));
}
@@ -148,371 +148,371 @@ gdm_session_list_from_hash_table_func (const char *key,
void
gdm_session_list_init ()
{
- _gdm_session_list_init (&sessnames,
- &sessions,
- &default_session,
- &current_session);
+ _gdm_session_list_init (&sessnames,
+ &sessions,
+ &default_session,
+ &current_session);
}
/* The real gdm_session_list_init */
void
_gdm_session_list_init (GHashTable **sessnames,
- GList **sessions,
- gchar **default_session,
- const gchar **current_session)
+ GList **sessions,
+ gchar **default_session,
+ const gchar **current_session)
{
- GdmSession *session = NULL;
- gboolean some_dir_exists = FALSE;
- gboolean searching_for_default = TRUE;
- struct dirent *dent;
- char **vec;
- char *name;
- DIR *sessdir;
- gboolean show_failsafe;
- char *desktop_dir;
- int i;
-
- *sessnames = g_hash_table_new (g_str_hash, g_str_equal);
-
- show_failsafe = FALSE;
- gdm_settings_client_get_boolean (GDM_KEY_SHOW_GNOME_FAILSAFE, &show_failsafe);
-
- if (show_failsafe) {
- session = g_new0 (GdmSession, 1);
- session->name = g_strdup (_("Failsafe _GNOME"));
- session->clearname = g_strdup (_("Failsafe GNOME"));
- session->comment = g_strdup (_("This is a failsafe session that will log you "
- "into GNOME. No startup scripts will be read "
- "and it is only to be used when you can't log "
- "in otherwise. GNOME will use the 'Default' "
- "session."));
- g_hash_table_insert (*sessnames, g_strdup (GDM_SESSION_FAILSAFE_GNOME), session);
- }
-
- show_failsafe = FALSE;
- gdm_settings_client_get_boolean (GDM_KEY_SHOW_XTERM_FAILSAFE, &show_failsafe);
-
- if (show_failsafe) {
- /* Valgrind complains that the below is leaked */
- session = g_new0 (GdmSession, 1);
- session->name = g_strdup (_("Failsafe _Terminal"));
- session->clearname = g_strdup (_("Failsafe Terminal"));
- session->comment = g_strdup (_("This is a failsafe session that will log you "
- "into a terminal. No startup scripts will be read "
- "and it is only to be used when you can't log "
- "in otherwise. To exit the terminal, "
- "type 'exit'."));
- g_hash_table_insert (*sessnames, g_strdup (GDM_SESSION_FAILSAFE_XTERM),
- session);
- }
-
- gdm_settings_client_get_string (GDM_KEY_SESSION_DESKTOP_DIR, &desktop_dir);
- vec = g_strsplit (desktop_dir, ":", -1);
-
- for (i = 0; vec != NULL && vec[i] != NULL; i++) {
- const char *dir = vec[i];
-
- /* Check that session dir is readable */
- if G_UNLIKELY (dir == NULL || access (dir, R_OK|X_OK) != 0)
- continue;
-
- some_dir_exists = TRUE;
-
- /* Read directory entries in session dir */
- sessdir = opendir (dir);
-
- if G_LIKELY (sessdir != NULL)
- dent = readdir (sessdir);
- else
- dent = NULL;
-
- while (dent != NULL) {
- GKeyFile *cfg;
- char *exec;
- char *comment;
- char *s;
- char *tryexec;
- char *ext;
- gboolean hidden;
-
- /* ignore everything but the .desktop files */
- ext = strstr (dent->d_name, ".desktop");
- if (ext == NULL ||
- strcmp (ext, ".desktop") != 0) {
- dent = readdir (sessdir);
- continue;
- }
-
- /* already found this session, ignore */
- if (g_hash_table_lookup (*sessnames, dent->d_name) != NULL) {
- dent = readdir (sessdir);
- continue;
- }
-
- s = g_strconcat (dir, "/", dent->d_name, NULL);
- cfg = g_key_file_new ();
- g_key_file_load_from_file (cfg, s, 0, NULL);
- g_free (s);
-
- hidden = g_key_file_get_boolean (cfg, "Desktop Entry", "Hidden", NULL);
- if (hidden) {
- session = g_new0 (GdmSession, 1);
- session->name = g_strdup (dent->d_name);
- session->clearname = NULL;
- g_hash_table_insert (*sessnames, g_strdup (dent->d_name), session);
- g_key_file_free (cfg);
- dent = readdir (sessdir);
- continue;
- }
-
- tryexec = g_key_file_get_string (cfg, "Desktop Entry", "TryExec", NULL);
- if ( ! ve_string_empty (tryexec)) {
- char **tryexecvec = g_strsplit (tryexec, " ", -1);
- char *full = NULL;
-
- /* Do not pass any arguments to g_find_program_in_path */
- if (tryexecvec != NULL)
- full = g_find_program_in_path (tryexecvec[0]);
-
- if (full == NULL) {
- session = g_new0 (GdmSession, 1);
- session->name = g_strdup (dent->d_name);
- session->clearname = NULL;
- g_hash_table_insert (*sessnames, g_strdup (dent->d_name),
- session);
- g_free (tryexec);
- g_key_file_free (cfg);
- dent = readdir (sessdir);
- continue;
- }
- g_strfreev (tryexecvec);
- g_free (full);
- }
- g_free (tryexec);
-
- exec = g_key_file_get_string (cfg, "Desktop Entry", "Exec", NULL);
- name = g_key_file_get_locale_string (cfg, "Desktop Entry", "Name", NULL, NULL);
- comment = g_key_file_get_locale_string (cfg, "Desktop Entry", "Comment", NULL, NULL);
- g_key_file_free (cfg);
-
- if G_UNLIKELY (ve_string_empty (exec) || ve_string_empty (name)) {
- session = g_new0 (GdmSession, 1);
- session->name = g_strdup (dent->d_name);
- session->clearname = NULL;
- g_hash_table_insert (*sessnames, g_strdup (dent->d_name), session);
- g_free (exec);
- g_free (name);
- g_free (comment);
- dent = readdir (sessdir);
- continue;
- }
-
- /* if we found the default session */
- if (default_session != NULL) {
- char *def;
-
- def = NULL;
- gdm_settings_client_get_string (GDM_KEY_DEFAULT_SESSION, &def);
- if ( ! ve_string_empty (def) && strcmp (dent->d_name, def) == 0) {
- g_free (*default_session);
- *default_session = g_strdup (dent->d_name);
- searching_for_default = FALSE;
- }
- g_free (def);
-
- /* if there is a session called Default */
- if (searching_for_default &&
- g_ascii_strcasecmp (dent->d_name, "default.desktop") == 0) {
- g_free (*default_session);
- *default_session = g_strdup (dent->d_name);
- }
-
- if (searching_for_default &&
- g_ascii_strcasecmp (dent->d_name, "gnome.desktop") == 0) {
- /* Just in case there is no default session and
- * no default link, make gnome the default */
- if (*default_session == NULL)
- *default_session = g_strdup (dent->d_name);
-
- }
- }
-
- session = g_new0 (GdmSession, 1);
- session->name = g_strdup (name);
- session->clearname = NULL;
- session->comment = g_strdup (comment);
- g_hash_table_insert (*sessnames, g_strdup (dent->d_name), session);
- g_free (exec);
- g_free (comment);
- dent = readdir (sessdir);
- }
-
- if G_LIKELY (sessdir != NULL)
- closedir (sessdir);
- }
-
- g_strfreev (vec);
-
- /* Check that session dir is readable */
- if G_UNLIKELY ( ! some_dir_exists) {
- g_warning ("%s: Session directory <%s> not found!",
- "gdm_session_list_init",
- desktop_dir);
- session_dir_whacked_out = TRUE;
- }
-
- if G_UNLIKELY (g_hash_table_size (*sessnames) == 0) {
- g_warning ("Error, no sessions found in the session directory <%s>.",
- desktop_dir);
-
- session_dir_whacked_out = TRUE;
- if (default_session != NULL)
- *default_session = g_strdup (GDM_SESSION_FAILSAFE_GNOME);
- }
-
- g_free (desktop_dir);
-
- /* Convert to list (which is unsorted) */
- g_hash_table_foreach (*sessnames,
- (GHFunc) gdm_session_list_from_hash_table_func, sessions);
-
- /* Prioritize and sort the list */
- *sessions = g_list_sort (*sessions, (GCompareFunc) gdm_session_sort_func);
-
- if (default_session != NULL)
- if G_UNLIKELY (*default_session == NULL) {
- *default_session = g_strdup (GDM_SESSION_FAILSAFE_GNOME);
- g_warning ("No default session link found. Using Failsafe GNOME.");
- }
-
- if (current_session != NULL &&
- default_session != NULL) {
- if (*current_session == NULL)
- *current_session = *default_session;
- }
+ GdmSession *session = NULL;
+ gboolean some_dir_exists = FALSE;
+ gboolean searching_for_default = TRUE;
+ struct dirent *dent;
+ char **vec;
+ char *name;
+ DIR *sessdir;
+ gboolean show_failsafe;
+ char *desktop_dir;
+ int i;
+
+ *sessnames = g_hash_table_new (g_str_hash, g_str_equal);
+
+ show_failsafe = FALSE;
+ gdm_settings_client_get_boolean (GDM_KEY_SHOW_GNOME_FAILSAFE, &show_failsafe);
+
+ if (show_failsafe) {
+ session = g_new0 (GdmSession, 1);
+ session->name = g_strdup (_("Failsafe _GNOME"));
+ session->clearname = g_strdup (_("Failsafe GNOME"));
+ session->comment = g_strdup (_("This is a failsafe session that will log you "
+ "into GNOME. No startup scripts will be read "
+ "and it is only to be used when you can't log "
+ "in otherwise. GNOME will use the 'Default' "
+ "session."));
+ g_hash_table_insert (*sessnames, g_strdup (GDM_SESSION_FAILSAFE_GNOME), session);
+ }
+
+ show_failsafe = FALSE;
+ gdm_settings_client_get_boolean (GDM_KEY_SHOW_XTERM_FAILSAFE, &show_failsafe);
+
+ if (show_failsafe) {
+ /* Valgrind complains that the below is leaked */
+ session = g_new0 (GdmSession, 1);
+ session->name = g_strdup (_("Failsafe _Terminal"));
+ session->clearname = g_strdup (_("Failsafe Terminal"));
+ session->comment = g_strdup (_("This is a failsafe session that will log you "
+ "into a terminal. No startup scripts will be read "
+ "and it is only to be used when you can't log "
+ "in otherwise. To exit the terminal, "
+ "type 'exit'."));
+ g_hash_table_insert (*sessnames, g_strdup (GDM_SESSION_FAILSAFE_XTERM),
+ session);
+ }
+
+ gdm_settings_client_get_string (GDM_KEY_SESSION_DESKTOP_DIR, &desktop_dir);
+ vec = g_strsplit (desktop_dir, ":", -1);
+
+ for (i = 0; vec != NULL && vec[i] != NULL; i++) {
+ const char *dir = vec[i];
+
+ /* Check that session dir is readable */
+ if G_UNLIKELY (dir == NULL || access (dir, R_OK|X_OK) != 0)
+ continue;
+
+ some_dir_exists = TRUE;
+
+ /* Read directory entries in session dir */
+ sessdir = opendir (dir);
+
+ if G_LIKELY (sessdir != NULL)
+ dent = readdir (sessdir);
+ else
+ dent = NULL;
+
+ while (dent != NULL) {
+ GKeyFile *cfg;
+ char *exec;
+ char *comment;
+ char *s;
+ char *tryexec;
+ char *ext;
+ gboolean hidden;
+
+ /* ignore everything but the .desktop files */
+ ext = strstr (dent->d_name, ".desktop");
+ if (ext == NULL ||
+ strcmp (ext, ".desktop") != 0) {
+ dent = readdir (sessdir);
+ continue;
+ }
+
+ /* already found this session, ignore */
+ if (g_hash_table_lookup (*sessnames, dent->d_name) != NULL) {
+ dent = readdir (sessdir);
+ continue;
+ }
+
+ s = g_strconcat (dir, "/", dent->d_name, NULL);
+ cfg = g_key_file_new ();
+ g_key_file_load_from_file (cfg, s, 0, NULL);
+ g_free (s);
+
+ hidden = g_key_file_get_boolean (cfg, "Desktop Entry", "Hidden", NULL);
+ if (hidden) {
+ session = g_new0 (GdmSession, 1);
+ session->name = g_strdup (dent->d_name);
+ session->clearname = NULL;
+ g_hash_table_insert (*sessnames, g_strdup (dent->d_name), session);
+ g_key_file_free (cfg);
+ dent = readdir (sessdir);
+ continue;
+ }
+
+ tryexec = g_key_file_get_string (cfg, "Desktop Entry", "TryExec", NULL);
+ if ( ! ve_string_empty (tryexec)) {
+ char **tryexecvec = g_strsplit (tryexec, " ", -1);
+ char *full = NULL;
+
+ /* Do not pass any arguments to g_find_program_in_path */
+ if (tryexecvec != NULL)
+ full = g_find_program_in_path (tryexecvec[0]);
+
+ if (full == NULL) {
+ session = g_new0 (GdmSession, 1);
+ session->name = g_strdup (dent->d_name);
+ session->clearname = NULL;
+ g_hash_table_insert (*sessnames, g_strdup (dent->d_name),
+ session);
+ g_free (tryexec);
+ g_key_file_free (cfg);
+ dent = readdir (sessdir);
+ continue;
+ }
+ g_strfreev (tryexecvec);
+ g_free (full);
+ }
+ g_free (tryexec);
+
+ exec = g_key_file_get_string (cfg, "Desktop Entry", "Exec", NULL);
+ name = g_key_file_get_locale_string (cfg, "Desktop Entry", "Name", NULL, NULL);
+ comment = g_key_file_get_locale_string (cfg, "Desktop Entry", "Comment", NULL, NULL);
+ g_key_file_free (cfg);
+
+ if G_UNLIKELY (ve_string_empty (exec) || ve_string_empty (name)) {
+ session = g_new0 (GdmSession, 1);
+ session->name = g_strdup (dent->d_name);
+ session->clearname = NULL;
+ g_hash_table_insert (*sessnames, g_strdup (dent->d_name), session);
+ g_free (exec);
+ g_free (name);
+ g_free (comment);
+ dent = readdir (sessdir);
+ continue;
+ }
+
+ /* if we found the default session */
+ if (default_session != NULL) {
+ char *def;
+
+ def = NULL;
+ gdm_settings_client_get_string (GDM_KEY_DEFAULT_SESSION, &def);
+ if ( ! ve_string_empty (def) && strcmp (dent->d_name, def) == 0) {
+ g_free (*default_session);
+ *default_session = g_strdup (dent->d_name);
+ searching_for_default = FALSE;
+ }
+ g_free (def);
+
+ /* if there is a session called Default */
+ if (searching_for_default &&
+ g_ascii_strcasecmp (dent->d_name, "default.desktop") == 0) {
+ g_free (*default_session);
+ *default_session = g_strdup (dent->d_name);
+ }
+
+ if (searching_for_default &&
+ g_ascii_strcasecmp (dent->d_name, "gnome.desktop") == 0) {
+ /* Just in case there is no default session and
+ * no default link, make gnome the default */
+ if (*default_session == NULL)
+ *default_session = g_strdup (dent->d_name);
+
+ }
+ }
+
+ session = g_new0 (GdmSession, 1);
+ session->name = g_strdup (name);
+ session->clearname = NULL;
+ session->comment = g_strdup (comment);
+ g_hash_table_insert (*sessnames, g_strdup (dent->d_name), session);
+ g_free (exec);
+ g_free (comment);
+ dent = readdir (sessdir);
+ }
+
+ if G_LIKELY (sessdir != NULL)
+ closedir (sessdir);
+ }
+
+ g_strfreev (vec);
+
+ /* Check that session dir is readable */
+ if G_UNLIKELY ( ! some_dir_exists) {
+ g_warning ("%s: Session directory <%s> not found!",
+ "gdm_session_list_init",
+ desktop_dir);
+ session_dir_whacked_out = TRUE;
+ }
+
+ if G_UNLIKELY (g_hash_table_size (*sessnames) == 0) {
+ g_warning ("Error, no sessions found in the session directory <%s>.",
+ desktop_dir);
+
+ session_dir_whacked_out = TRUE;
+ if (default_session != NULL)
+ *default_session = g_strdup (GDM_SESSION_FAILSAFE_GNOME);
+ }
+
+ g_free (desktop_dir);
+
+ /* Convert to list (which is unsorted) */
+ g_hash_table_foreach (*sessnames,
+ (GHFunc) gdm_session_list_from_hash_table_func, sessions);
+
+ /* Prioritize and sort the list */
+ *sessions = g_list_sort (*sessions, (GCompareFunc) gdm_session_sort_func);
+
+ if (default_session != NULL)
+ if G_UNLIKELY (*default_session == NULL) {
+ *default_session = g_strdup (GDM_SESSION_FAILSAFE_GNOME);
+ g_warning ("No default session link found. Using Failsafe GNOME.");
+ }
+
+ if (current_session != NULL &&
+ default_session != NULL) {
+ if (*current_session == NULL)
+ *current_session = *default_session;
+ }
}
static gboolean
gdm_login_list_lookup (GList *l,
- const gchar *data)
+ const gchar *data)
{
- GList *list = l;
+ GList *list = l;
- if (list == NULL || data == NULL)
- return FALSE;
+ if (list == NULL || data == NULL)
+ return FALSE;
- /* FIXME: Hack, will support these builtin types later */
- if (strcmp (data, GDM_SESSION_DEFAULT ".desktop") == 0 ||
- strcmp (data, GDM_SESSION_CUSTOM ".desktop") == 0 ||
- strcmp (data, GDM_SESSION_FAILSAFE ".desktop") == 0) {
- return TRUE;
- }
+ /* FIXME: Hack, will support these builtin types later */
+ if (strcmp (data, GDM_SESSION_DEFAULT ".desktop") == 0 ||
+ strcmp (data, GDM_SESSION_CUSTOM ".desktop") == 0 ||
+ strcmp (data, GDM_SESSION_FAILSAFE ".desktop") == 0) {
+ return TRUE;
+ }
- while (list) {
+ while (list) {
- if (strcmp (list->data, data) == 0)
- return TRUE;
+ if (strcmp (list->data, data) == 0)
+ return TRUE;
- list = list->next;
- }
+ list = list->next;
+ }
- return FALSE;
+ return FALSE;
}
char *
gdm_session_lookup (const char *saved_session,
- gint *lookup_status)
+ gint *lookup_status)
{
- gchar *session = NULL;
-
- /* Assume that the lookup will go well */
- *lookup_status = SESSION_LOOKUP_SUCCESS;
-
- /* Don't save session unless told otherwise */
- save_session = GTK_RESPONSE_NO;
-
- /* Previously saved session not found in ~/.dmrc */
- if ( ! (saved_session != NULL &&
- strcmp ("(null)", saved_session) != 0 &&
- saved_session[0] != '\0')) {
- /* If "Last" is chosen run default,
- * else run user's current selection */
- if (current_session == NULL || strcmp (current_session, LAST_SESSION) == 0)
- session = g_strdup (default_session);
- else
- session = g_strdup (current_session);
-
- save_session = GTK_RESPONSE_YES;
- return session;
- }
-
- /* If "Last" session is selected */
- if (current_session == NULL || strcmp (current_session, LAST_SESSION) == 0) {
- session = g_strdup (saved_session);
-
- /* Check if user's saved session exists on this box */
- if (!gdm_login_list_lookup (sessions, session)) {
- g_free (session);
- session = g_strdup (default_session);
- *lookup_status = SESSION_LOOKUP_PREFERRED_MISSING;
- }
- } else {
- /* One of the other available session types is selected */
- session = g_strdup (current_session);
-
- /* User's saved session is not the chosen one */
- if (strcmp (session, GDM_SESSION_FAILSAFE_GNOME) == 0 ||
- strcmp (session, GDM_SESSION_FAILSAFE_XTERM) == 0 ||
- g_ascii_strcasecmp (session, GDM_SESSION_FAILSAFE ".desktop") == 0 ||
- g_ascii_strcasecmp (session, GDM_SESSION_FAILSAFE) == 0) {
- /*
- * Never save failsafe sessions as the default session.
- * These are intended to be used for debugging or temporary
- * purposes.
- */
- save_session = GTK_RESPONSE_NO;
- } else if (strcmp (saved_session, session) != 0) {
- gboolean show_last;
-
- show_last = FALSE;
- gdm_settings_client_get_boolean (GDM_KEY_SHOW_LAST_SESSION, &show_last);
-
- if (show_last) {
- *lookup_status = SESSION_LOOKUP_DEFAULT_MISMATCH;
- } else if (strcmp (session, default_session) != 0 &&
- strcmp (session, saved_session) != 0 &&
- strcmp (session, LAST_SESSION) != 0) {
- /*
- * If (! GDM_KEY_SHOW_LAST_SESSION) then our saved session is
- * irrelevant, we are in "switchdesk mode" and the relevant
- * thing is the saved session in .Xclients
- */
- if (g_access ("/usr/bin/switchdesk", F_OK) == 0) {
- *lookup_status = SESSION_LOOKUP_USE_SWITCHDESK;
- }
- save_session = GTK_RESPONSE_NO;
- }
- }
- }
-
- return session;
+ gchar *session = NULL;
+
+ /* Assume that the lookup will go well */
+ *lookup_status = SESSION_LOOKUP_SUCCESS;
+
+ /* Don't save session unless told otherwise */
+ save_session = GTK_RESPONSE_NO;
+
+ /* Previously saved session not found in ~/.dmrc */
+ if ( ! (saved_session != NULL &&
+ strcmp ("(null)", saved_session) != 0 &&
+ saved_session[0] != '\0')) {
+ /* If "Last" is chosen run default,
+ * else run user's current selection */
+ if (current_session == NULL || strcmp (current_session, LAST_SESSION) == 0)
+ session = g_strdup (default_session);
+ else
+ session = g_strdup (current_session);
+
+ save_session = GTK_RESPONSE_YES;
+ return session;
+ }
+
+ /* If "Last" session is selected */
+ if (current_session == NULL || strcmp (current_session, LAST_SESSION) == 0) {
+ session = g_strdup (saved_session);
+
+ /* Check if user's saved session exists on this box */
+ if (!gdm_login_list_lookup (sessions, session)) {
+ g_free (session);
+ session = g_strdup (default_session);
+ *lookup_status = SESSION_LOOKUP_PREFERRED_MISSING;
+ }
+ } else {
+ /* One of the other available session types is selected */
+ session = g_strdup (current_session);
+
+ /* User's saved session is not the chosen one */
+ if (strcmp (session, GDM_SESSION_FAILSAFE_GNOME) == 0 ||
+ strcmp (session, GDM_SESSION_FAILSAFE_XTERM) == 0 ||
+ g_ascii_strcasecmp (session, GDM_SESSION_FAILSAFE ".desktop") == 0 ||
+ g_ascii_strcasecmp (session, GDM_SESSION_FAILSAFE) == 0) {
+ /*
+ * Never save failsafe sessions as the default session.
+ * These are intended to be used for debugging or temporary
+ * purposes.
+ */
+ save_session = GTK_RESPONSE_NO;
+ } else if (strcmp (saved_session, session) != 0) {
+ gboolean show_last;
+
+ show_last = FALSE;
+ gdm_settings_client_get_boolean (GDM_KEY_SHOW_LAST_SESSION, &show_last);
+
+ if (show_last) {
+ *lookup_status = SESSION_LOOKUP_DEFAULT_MISMATCH;
+ } else if (strcmp (session, default_session) != 0 &&
+ strcmp (session, saved_session) != 0 &&
+ strcmp (session, LAST_SESSION) != 0) {
+ /*
+ * If (! GDM_KEY_SHOW_LAST_SESSION) then our saved session is
+ * irrelevant, we are in "switchdesk mode" and the relevant
+ * thing is the saved session in .Xclients
+ */
+ if (g_access ("/usr/bin/switchdesk", F_OK) == 0) {
+ *lookup_status = SESSION_LOOKUP_USE_SWITCHDESK;
+ }
+ save_session = GTK_RESPONSE_NO;
+ }
+ }
+ }
+
+ return session;
}
gint
gdm_get_save_session (void)
{
- return save_session;
+ return save_session;
}
void
gdm_set_save_session (const gint session)
{
- save_session = session;
+ save_session = session;
}
const char*
gdm_get_default_session (void)
{
- return default_session;
+ return default_session;
}
diff --git a/libgreeter/gdmsession.h b/libgreeter/gdmsession.h
index e4079b9f..a3998f9c 100644
--- a/libgreeter/gdmsession.h
+++ b/libgreeter/gdmsession.h
@@ -34,10 +34,10 @@ typedef struct {
} GdmSession;
enum {
- SESSION_LOOKUP_SUCCESS,
- SESSION_LOOKUP_PREFERRED_MISSING,
- SESSION_LOOKUP_DEFAULT_MISMATCH,
- SESSION_LOOKUP_USE_SWITCHDESK
+ SESSION_LOOKUP_SUCCESS,
+ SESSION_LOOKUP_PREFERRED_MISSING,
+ SESSION_LOOKUP_DEFAULT_MISMATCH,
+ SESSION_LOOKUP_USE_SWITCHDESK
};
#define GDM_SESSION_FAILSAFE_GNOME "GDM_Failsafe.GNOME"
@@ -49,23 +49,23 @@ enum {
#define GDM_SESSION_FAILSAFE "failsafe"
-void gdm_session_list_init (void);
-void _gdm_session_list_init (GHashTable **sessnames,
- GList **sessions,
- gchar **default_session,
- const gchar **current_session);
-gint gdm_session_sort_func (const char *a, const char *b);
-const char * gdm_session_name (const char *name);
-void gdm_session_list_from_hash_table_func (const char *key,
- const char *value,
- GList **sessions);
-gint gdm_session_sort_func (const char *a,
- const char *b);
-char * gdm_session_lookup (const char *saved_session, gint *lookup_status);
+void gdm_session_list_init (void);
+void _gdm_session_list_init (GHashTable **sessnames,
+ GList **sessions,
+ gchar **default_session,
+ const gchar **current_session);
+gint gdm_session_sort_func (const char *a, const char *b);
+const char * gdm_session_name (const char *name);
+void gdm_session_list_from_hash_table_func (const char *key,
+ const char *value,
+ GList **sessions);
+gint gdm_session_sort_func (const char *a,
+ const char *b);
+char * gdm_session_lookup (const char *saved_session, gint *lookup_status);
-gint gdm_get_save_session (void);
+gint gdm_get_save_session (void);
-void gdm_set_save_session (const gint session);
+void gdm_set_save_session (const gint session);
const char * gdm_get_default_session (void);
diff --git a/libgreeter/gdmwm.c b/libgreeter/gdmwm.c
index 2daed1da..44ab5100 100644
--- a/libgreeter/gdmwm.c
+++ b/libgreeter/gdmwm.c
@@ -38,19 +38,19 @@
typedef struct _GdmWindow GdmWindow;
struct _GdmWindow {
- int x, y;
- Window win;
- Window deco;
- Window shadow;
- gboolean ignore_size_hints; /* for gdm windows */
- gboolean center; /* do centering */
- gboolean recenter; /* do re-centering */
+ int x, y;
+ Window win;
+ Window deco;
+ Window shadow;
+ gboolean ignore_size_hints; /* for gdm windows */
+ gboolean center; /* do centering */
+ gboolean recenter; /* do re-centering */
gboolean takefocus; /* permit take focus */
- /* hack, when we reparent, we will get an unmap and then
- * an map, and we want to ignore those */
- int ignore_next_map;
- int ignore_next_unmap;
+ /* hack, when we reparent, we will get an unmap and then
+ * an map, and we want to ignore those */
+ int ignore_next_map;
+ int ignore_next_unmap;
};
static GList *windows = NULL;
@@ -79,155 +79,155 @@ static guint save_struts[4] = {0, 0, 0, 0};
void
gdm_wm_screen_init (int cur_screen_num)
{
- if (g_getenv ("FAKE_XINERAMA_GDM") != NULL) {
- /* for testing Xinerama support on non-xinerama setups */
- gdm_wm_screen.x = 100;
- gdm_wm_screen.y = 100;
- gdm_wm_screen.width = gdk_screen_width () / 2 - 100;
- gdm_wm_screen.height = gdk_screen_height () / 2 - 100;
-
- gdm_wm_allscreens = g_new0 (GdkRectangle, 2);
- gdm_wm_allscreens[0] = gdm_wm_screen;
- gdm_wm_allscreens[1].x = gdk_screen_width () / 2;
- gdm_wm_allscreens[1].y = gdk_screen_height () / 2;
- gdm_wm_allscreens[1].width = gdk_screen_width () / 2;
- gdm_wm_allscreens[1].height = gdk_screen_height () / 2;
- gdm_wm_screens = 2;
- return;
- }
-
- {
+ if (g_getenv ("FAKE_XINERAMA_GDM") != NULL) {
+ /* for testing Xinerama support on non-xinerama setups */
+ gdm_wm_screen.x = 100;
+ gdm_wm_screen.y = 100;
+ gdm_wm_screen.width = gdk_screen_width () / 2 - 100;
+ gdm_wm_screen.height = gdk_screen_height () / 2 - 100;
+
+ gdm_wm_allscreens = g_new0 (GdkRectangle, 2);
+ gdm_wm_allscreens[0] = gdm_wm_screen;
+ gdm_wm_allscreens[1].x = gdk_screen_width () / 2;
+ gdm_wm_allscreens[1].y = gdk_screen_height () / 2;
+ gdm_wm_allscreens[1].width = gdk_screen_width () / 2;
+ gdm_wm_allscreens[1].height = gdk_screen_height () / 2;
+ gdm_wm_screens = 2;
+ return;
+ }
+
+ {
#ifdef HAVE_XFREE_XINERAMA
- gboolean have_xinerama = FALSE;
-
- gdk_flush ();
- gdk_error_trap_push ();
- have_xinerama = XineramaIsActive (GDK_DISPLAY ());
- gdk_flush ();
- if (gdk_error_trap_pop () != 0)
- have_xinerama = FALSE;
-
- if (have_xinerama) {
- int screen_num, i;
- XineramaScreenInfo *xscreens =
- XineramaQueryScreens (GDK_DISPLAY (),
- &screen_num);
-
-
- if (screen_num <= 0) {
- /* should NEVER EVER happen */
- g_warning ("Xinerama active, but <= 0 screens?");
- gdm_wm_screen.x = 0;
- gdm_wm_screen.y = 0;
- gdm_wm_screen.width = gdk_screen_width ();
- gdm_wm_screen.height = gdk_screen_height ();
-
- gdm_wm_allscreens = g_new0 (GdkRectangle, 1);
- gdm_wm_allscreens[0] = gdm_wm_screen;
- gdm_wm_screens = 1;
- return;
- }
-
- if (screen_num <= cur_screen_num)
- cur_screen_num = 0;
-
- gdm_wm_allscreens = g_new0 (GdkRectangle, screen_num);
- gdm_wm_screens = screen_num;
-
- for (i = 0; i < screen_num; i++) {
- gdm_wm_allscreens[i].x = xscreens[i].x_org;
- gdm_wm_allscreens[i].y = xscreens[i].y_org;
- gdm_wm_allscreens[i].width = xscreens[i].width;
- gdm_wm_allscreens[i].height = xscreens[i].height;
-
- if (cur_screen_num == i)
- gdm_wm_screen = gdm_wm_allscreens[i];
- }
-
- XFree (xscreens);
- } else
+ gboolean have_xinerama = FALSE;
+
+ gdk_flush ();
+ gdk_error_trap_push ();
+ have_xinerama = XineramaIsActive (GDK_DISPLAY ());
+ gdk_flush ();
+ if (gdk_error_trap_pop () != 0)
+ have_xinerama = FALSE;
+
+ if (have_xinerama) {
+ int screen_num, i;
+ XineramaScreenInfo *xscreens =
+ XineramaQueryScreens (GDK_DISPLAY (),
+ &screen_num);
+
+
+ if (screen_num <= 0) {
+ /* should NEVER EVER happen */
+ g_warning ("Xinerama active, but <= 0 screens?");
+ gdm_wm_screen.x = 0;
+ gdm_wm_screen.y = 0;
+ gdm_wm_screen.width = gdk_screen_width ();
+ gdm_wm_screen.height = gdk_screen_height ();
+
+ gdm_wm_allscreens = g_new0 (GdkRectangle, 1);
+ gdm_wm_allscreens[0] = gdm_wm_screen;
+ gdm_wm_screens = 1;
+ return;
+ }
+
+ if (screen_num <= cur_screen_num)
+ cur_screen_num = 0;
+
+ gdm_wm_allscreens = g_new0 (GdkRectangle, screen_num);
+ gdm_wm_screens = screen_num;
+
+ for (i = 0; i < screen_num; i++) {
+ gdm_wm_allscreens[i].x = xscreens[i].x_org;
+ gdm_wm_allscreens[i].y = xscreens[i].y_org;
+ gdm_wm_allscreens[i].width = xscreens[i].width;
+ gdm_wm_allscreens[i].height = xscreens[i].height;
+
+ if (cur_screen_num == i)
+ gdm_wm_screen = gdm_wm_allscreens[i];
+ }
+
+ XFree (xscreens);
+ } else
#elif HAVE_SOLARIS_XINERAMA
- gboolean have_xinerama = FALSE;
- /* This code from GDK, Copyright (C) 2002 Sun Microsystems */
- int opcode;
- int firstevent;
- int firsterror;
- int n_monitors = 0;
-
- gdk_flush ();
- gdk_error_trap_push ();
- have_xinerama = XQueryExtension (GDK_DISPLAY (),
- "XINERAMA",
- &opcode,
- &firstevent,
- &firsterror);
- gdk_flush ();
- if (gdk_error_trap_pop () != 0)
- have_xinerama = FALSE;
-
- if (have_xinerama) {
- int i;
- int result;
- XRectangle monitors[MAXFRAMEBUFFERS];
- unsigned char hints[16];
-
- result = XineramaGetInfo (GDK_DISPLAY (), 0, monitors, hints, &n_monitors);
- /* Yes I know it should be Success but the current implementation
- * returns the num of monitor
- */
-
- if (result <= 0) {
- /* should NEVER EVER happen */
- g_warning ("Xinerama active, but <= 0 screens?");
- gdm_wm_screen.x = 0;
- gdm_wm_screen.y = 0;
- gdm_wm_screen.width = gdk_screen_width ();
- gdm_wm_screen.height = gdk_screen_height ();
-
- gdm_wm_allscreens = g_new0 (GdkRectangle, 1);
- gdm_wm_allscreens[0] = gdm_wm_screen;
- gdm_wm_screens = 1;
- return;
- }
-
- if (n_monitors <= cur_screen_num)
- cur_screen_num = 0;
-
- gdm_wm_allscreens = g_new0 (GdkRectangle, n_monitors);
- gdm_wm_screens = n_monitors;
-
- for (i = 0; i < n_monitors; i++) {
- gdm_wm_allscreens[i].x = monitors[i].x;
- gdm_wm_allscreens[i].y = monitors[i].y;
- gdm_wm_allscreens[i].width = monitors[i].width;
- gdm_wm_allscreens[i].height = monitors[i].height;
-
- if (cur_screen_num == i)
- gdm_wm_screen = gdm_wm_allscreens[i];
- }
-
- } else
+ gboolean have_xinerama = FALSE;
+ /* This code from GDK, Copyright (C) 2002 Sun Microsystems */
+ int opcode;
+ int firstevent;
+ int firsterror;
+ int n_monitors = 0;
+
+ gdk_flush ();
+ gdk_error_trap_push ();
+ have_xinerama = XQueryExtension (GDK_DISPLAY (),
+ "XINERAMA",
+ &opcode,
+ &firstevent,
+ &firsterror);
+ gdk_flush ();
+ if (gdk_error_trap_pop () != 0)
+ have_xinerama = FALSE;
+
+ if (have_xinerama) {
+ int i;
+ int result;
+ XRectangle monitors[MAXFRAMEBUFFERS];
+ unsigned char hints[16];
+
+ result = XineramaGetInfo (GDK_DISPLAY (), 0, monitors, hints, &n_monitors);
+ /* Yes I know it should be Success but the current implementation
+ * returns the num of monitor
+ */
+
+ if (result <= 0) {
+ /* should NEVER EVER happen */
+ g_warning ("Xinerama active, but <= 0 screens?");
+ gdm_wm_screen.x = 0;
+ gdm_wm_screen.y = 0;
+ gdm_wm_screen.width = gdk_screen_width ();
+ gdm_wm_screen.height = gdk_screen_height ();
+
+ gdm_wm_allscreens = g_new0 (GdkRectangle, 1);
+ gdm_wm_allscreens[0] = gdm_wm_screen;
+ gdm_wm_screens = 1;
+ return;
+ }
+
+ if (n_monitors <= cur_screen_num)
+ cur_screen_num = 0;
+
+ gdm_wm_allscreens = g_new0 (GdkRectangle, n_monitors);
+ gdm_wm_screens = n_monitors;
+
+ for (i = 0; i < n_monitors; i++) {
+ gdm_wm_allscreens[i].x = monitors[i].x;
+ gdm_wm_allscreens[i].y = monitors[i].y;
+ gdm_wm_allscreens[i].width = monitors[i].width;
+ gdm_wm_allscreens[i].height = monitors[i].height;
+
+ if (cur_screen_num == i)
+ gdm_wm_screen = gdm_wm_allscreens[i];
+ }
+
+ } else
#endif
- {
- gdm_wm_screen.x = 0;
- gdm_wm_screen.y = 0;
- gdm_wm_screen.width = gdk_screen_width ();
- gdm_wm_screen.height = gdk_screen_height ();
-
- gdm_wm_allscreens = g_new0 (GdkRectangle, 1);
- gdm_wm_allscreens[0] = gdm_wm_screen;
- gdm_wm_screens = 1;
- }
- }
+ {
+ gdm_wm_screen.x = 0;
+ gdm_wm_screen.y = 0;
+ gdm_wm_screen.width = gdk_screen_width ();
+ gdm_wm_screen.height = gdk_screen_height ();
+
+ gdm_wm_allscreens = g_new0 (GdkRectangle, 1);
+ gdm_wm_allscreens[0] = gdm_wm_screen;
+ gdm_wm_screens = 1;
+ }
+ }
}
void
gdm_wm_set_screen (int cur_screen_num)
{
- if (cur_screen_num >= gdm_wm_screens || cur_screen_num < 0)
- cur_screen_num = 0;
+ if (cur_screen_num >= gdm_wm_screens || cur_screen_num < 0)
+ cur_screen_num = 0;
- gdm_wm_screen = gdm_wm_allscreens[cur_screen_num];
+ gdm_wm_screen = gdm_wm_allscreens[cur_screen_num];
}
/* Not really a WM function, center a gtk window by setting uposition */
@@ -237,51 +237,51 @@ gdm_wm_center_window (GtkWindow *cw)
gint x, y;
gint w, h;
- gtk_window_get_size (cw, &w, &h);
+ gtk_window_get_size (cw, &w, &h);
- x = gdm_wm_screen.x + (gdm_wm_screen.width - w)/2;
- y = gdm_wm_screen.y + (gdm_wm_screen.height - h)/2;
+ x = gdm_wm_screen.x + (gdm_wm_screen.width - w)/2;
+ y = gdm_wm_screen.y + (gdm_wm_screen.height - h)/2;
- if (x < gdm_wm_screen.x)
- x = gdm_wm_screen.x;
- if (y < gdm_wm_screen.y)
- y = gdm_wm_screen.y;
+ if (x < gdm_wm_screen.x)
+ x = gdm_wm_screen.x;
+ if (y < gdm_wm_screen.y)
+ y = gdm_wm_screen.y;
- gtk_window_move (GTK_WINDOW (cw), x, y);
+ gtk_window_move (GTK_WINDOW (cw), x, y);
}
void
gdm_wm_center_cursor (void)
{
XWarpPointer (wm_disp, None, wm_root, 0, 0, 0, 0,
- gdm_wm_screen.x + gdm_wm_screen.width / 2,
- gdm_wm_screen.y + gdm_wm_screen.height / 2);
+ gdm_wm_screen.x + gdm_wm_screen.width / 2,
+ gdm_wm_screen.y + gdm_wm_screen.height / 2);
}
static void
trap_push (void)
{
- trap_depth++;
- gdk_error_trap_push ();
+ trap_depth++;
+ gdk_error_trap_push ();
}
static int
trap_pop (void)
{
- trap_depth --;
- if (trap_depth <= 0)
- XSync (wm_disp, False);
- return gdk_error_trap_pop ();
+ trap_depth --;
+ if (trap_depth <= 0)
+ XSync (wm_disp, False);
+ return gdk_error_trap_pop ();
}
/* stolen from gwmh */
static gpointer
get_typed_property_data (Display *xdisplay,
- Window xwindow,
- Atom property,
- Atom requested_type,
- gint *size_p,
- guint expected_format)
+ Window xwindow,
+ Atom property,
+ Atom requested_type,
+ gint *size_p,
+ guint expected_format)
{
static const guint prop_buffer_lengh = 1024 * 1024;
unsigned char *prop_data = NULL;
@@ -297,15 +297,15 @@ get_typed_property_data (Display *xdisplay,
gdk_error_trap_push ();
abort = XGetWindowProperty (xdisplay,
- xwindow,
- property,
- 0, prop_buffer_lengh,
- False,
- requested_type,
- &type_returned, &format_returned,
- &nitems_return,
- &bytes_after_return,
- &prop_data) != Success;
+ xwindow,
+ property,
+ 0, prop_buffer_lengh,
+ False,
+ requested_type,
+ &type_returned, &format_returned,
+ &nitems_return,
+ &bytes_after_return,
+ &prop_data) != Success;
if (gdk_error_trap_pop () ||
type_returned == None)
abort++;
@@ -319,69 +319,69 @@ get_typed_property_data (Display *xdisplay,
if (!abort && bytes_after_return)
{
g_warning (G_GNUC_PRETTY_FUNCTION "(): Eeek, property has more than %u bytes, stored on harddisk?",
- prop_buffer_lengh);
+ prop_buffer_lengh);
abort++;
}
if (!abort && expected_format && expected_format != format_returned)
{
g_warning (G_GNUC_PRETTY_FUNCTION "(): Expected format (%u) unmatched (%d)",
- expected_format, format_returned);
+ expected_format, format_returned);
abort++;
}
if (!abort && prop_data && nitems_return && format_returned)
{
switch (format_returned)
- {
- case 32:
- *size_p = nitems_return * 4;
- if (sizeof (gulong) == 8)
- {
- guint32 i, *mem = g_malloc0 (*size_p + 1);
- gulong *prop_longs = (gulong*) prop_data;
-
- for (i = 0; i < *size_p / 4; i++)
- mem[i] = prop_longs[i];
- data = mem;
- }
- break;
- case 16:
- *size_p = nitems_return * 2;
- break;
- case 8:
- *size_p = nitems_return;
- break;
- default:
- g_warning ("Unknown property data format with %d bits (extraterrestrial?)",
- format_returned);
- break;
- }
+ {
+ case 32:
+ *size_p = nitems_return * 4;
+ if (sizeof (gulong) == 8)
+ {
+ guint32 i, *mem = g_malloc0 (*size_p + 1);
+ gulong *prop_longs = (gulong*) prop_data;
+
+ for (i = 0; i < *size_p / 4; i++)
+ mem[i] = prop_longs[i];
+ data = mem;
+ }
+ break;
+ case 16:
+ *size_p = nitems_return * 2;
+ break;
+ case 8:
+ *size_p = nitems_return;
+ break;
+ default:
+ g_warning ("Unknown property data format with %d bits (extraterrestrial?)",
+ format_returned);
+ break;
+ }
if (!data && *size_p)
- {
- guint8 *mem = NULL;
-
- if (format_returned == 8 && type_returned == XA_COMPOUND_TEXT)
- {
- gchar **tlist = NULL;
- gint count = gdk_text_property_to_text_list
- (gdk_x11_xatom_to_atom (type_returned), 8, prop_data,
- nitems_return, &tlist);
-
- if (count && tlist && tlist[0])
- {
- mem = (guint8 *)g_strdup (tlist[0]);
- *size_p = strlen ((char *)mem);
- }
- if (tlist)
- gdk_free_text_list (tlist);
- }
- if (!mem)
- {
- mem = g_malloc (*size_p + 1);
- memcpy (mem, prop_data, *size_p);
- mem[*size_p] = 0;
- }
- data = mem;
- }
+ {
+ guint8 *mem = NULL;
+
+ if (format_returned == 8 && type_returned == XA_COMPOUND_TEXT)
+ {
+ gchar **tlist = NULL;
+ gint count = gdk_text_property_to_text_list
+ (gdk_x11_xatom_to_atom (type_returned), 8, prop_data,
+ nitems_return, &tlist);
+
+ if (count && tlist && tlist[0])
+ {
+ mem = (guint8 *)g_strdup (tlist[0]);
+ *size_p = strlen ((char *)mem);
+ }
+ if (tlist)
+ gdk_free_text_list (tlist);
+ }
+ if (!mem)
+ {
+ mem = g_malloc (*size_p + 1);
+ memcpy (mem, prop_data, *size_p);
+ mem[*size_p] = 0;
+ }
+ data = mem;
+ }
}
if (prop_data)
@@ -398,30 +398,30 @@ get_typed_property_data (Display *xdisplay,
static void
gdm_wm_update_struts (Display *xdisplay, Window xwindow)
{
- gint size = 0;
- guint32 *struts = get_typed_property_data (xdisplay, xwindow, XA_NET_WM_STRUT,
- XA_CARDINAL, &size, 32);
- if (size == 16)
- {
- gint i;
- for (i = 0; i < 4; ++i)
- {
- /* strut owners are the only windows whose 'zero' struts are reflected */
- if (struts[i] != 0 || (strut_owners[i] == xwindow))
- {
- /* if any window re-specifies a strut, it becomes the new owner */
- strut_owners[i] = xwindow;
- save_struts[i] = struts[i];
- }
- }
- }
- g_free (struts);
+ gint size = 0;
+ guint32 *struts = get_typed_property_data (xdisplay, xwindow, XA_NET_WM_STRUT,
+ XA_CARDINAL, &size, 32);
+ if (size == 16)
+ {
+ gint i;
+ for (i = 0; i < 4; ++i)
+ {
+ /* strut owners are the only windows whose 'zero' struts are reflected */
+ if (struts[i] != 0 || (strut_owners[i] == xwindow))
+ {
+ /* if any window re-specifies a strut, it becomes the new owner */
+ strut_owners[i] = xwindow;
+ save_struts[i] = struts[i];
+ }
+ }
+ }
+ g_free (struts);
}
/* stolen from gwmh */
static gboolean
wm_protocol_check_support (Window xwin,
- Atom check_atom)
+ Atom check_atom)
{
Atom *pdata = NULL;
guint32 *gdata = NULL;
@@ -432,17 +432,17 @@ wm_protocol_check_support (Window xwin,
trap_push ();
if (!XGetWMProtocols (wm_disp,
- xwin,
- &pdata,
- &n_pids))
+ xwin,
+ &pdata,
+ &n_pids))
{
gint size = 0;
gdata = get_typed_property_data (wm_disp,
- xwin,
- XA_WM_PROTOCOLS,
- XA_WM_PROTOCOLS,
- &size, 32);
+ xwin,
+ XA_WM_PROTOCOLS,
+ XA_WM_PROTOCOLS,
+ &size, 32);
n_gids = size / 4;
}
@@ -451,8 +451,8 @@ wm_protocol_check_support (Window xwin,
for (i = 0; i < n_pids; i++)
if (pdata[i] == check_atom)
{
- is_supported = TRUE;
- break;
+ is_supported = TRUE;
+ break;
}
if (pdata)
XFree (pdata);
@@ -460,8 +460,8 @@ wm_protocol_check_support (Window xwin,
for (i = 0; i < n_gids; i++)
if (gdata[i] == check_atom)
{
- is_supported = TRUE;
- break;
+ is_supported = TRUE;
+ break;
}
g_free (gdata);
@@ -471,216 +471,216 @@ wm_protocol_check_support (Window xwin,
static GList *
find_window_list (Window w, gboolean deco_ok)
{
- GList *li;
+ GList *li;
- for (li = windows; li != NULL; li = li->next) {
- GdmWindow *gw = li->data;
+ for (li = windows; li != NULL; li = li->next) {
+ GdmWindow *gw = li->data;
- if (gw->win == w)
- return li;
- if (deco_ok &&
- (gw->deco == w ||
- gw->shadow == w))
- return li;
- }
+ if (gw->win == w)
+ return li;
+ if (deco_ok &&
+ (gw->deco == w ||
+ gw->shadow == w))
+ return li;
+ }
- return NULL;
+ return NULL;
}
static GdmWindow *
find_window (Window w, gboolean deco_ok)
{
- GList *li = find_window_list (w, deco_ok);
- if (li == NULL)
- return NULL;
- else
- return li->data;
+ GList *li = find_window_list (w, deco_ok);
+ if (li == NULL)
+ return NULL;
+ else
+ return li->data;
}
void
gdm_wm_focus_window (Window window)
{
- XWindowAttributes attribs = {0};
- GdmWindow *win;
-
- if (no_focus_login > 0 &&
- window == wm_login_window)
- return;
-
- win = find_window (window, TRUE);
- if (win != NULL &&
- ! win->takefocus)
- return;
-
- trap_push ();
-
- XGetWindowAttributes (wm_disp, window, &attribs);
- if (attribs.map_state == IsUnmapped) {
- trap_pop ();
- return;
- }
-
- if (wm_protocol_check_support (window, XA_WM_TAKE_FOCUS)) {
- XEvent xevent = { 0, };
-
- xevent.type = ClientMessage;
- xevent.xclient.window = window;
- xevent.xclient.message_type = XA_WM_PROTOCOLS;
- xevent.xclient.format = 32;
- xevent.xclient.data.l[0] = XA_WM_TAKE_FOCUS;
- xevent.xclient.data.l[1] = CurrentTime;
-
- XSendEvent (wm_disp, window, False, 0, &xevent);
- XSync (wm_disp, False);
- }
-
- XSetInputFocus (wm_disp,
- window,
- RevertToPointerRoot,
- CurrentTime);
- trap_pop ();
-
- wm_focus_window = window;
+ XWindowAttributes attribs = {0};
+ GdmWindow *win;
+
+ if (no_focus_login > 0 &&
+ window == wm_login_window)
+ return;
+
+ win = find_window (window, TRUE);
+ if (win != NULL &&
+ ! win->takefocus)
+ return;
+
+ trap_push ();
+
+ XGetWindowAttributes (wm_disp, window, &attribs);
+ if (attribs.map_state == IsUnmapped) {
+ trap_pop ();
+ return;
+ }
+
+ if (wm_protocol_check_support (window, XA_WM_TAKE_FOCUS)) {
+ XEvent xevent = { 0, };
+
+ xevent.type = ClientMessage;
+ xevent.xclient.window = window;
+ xevent.xclient.message_type = XA_WM_PROTOCOLS;
+ xevent.xclient.format = 32;
+ xevent.xclient.data.l[0] = XA_WM_TAKE_FOCUS;
+ xevent.xclient.data.l[1] = CurrentTime;
+
+ XSendEvent (wm_disp, window, False, 0, &xevent);
+ XSync (wm_disp, False);
+ }
+
+ XSetInputFocus (wm_disp,
+ window,
+ RevertToPointerRoot,
+ CurrentTime);
+ trap_pop ();
+
+ wm_focus_window = window;
}
static void
constrain_window (GdmWindow *gw)
{
/* constrain window to lie within screen geometry, with struts reserved */
- int x, y, screen_x = 0, screen_y = 0;
- Window root;
- unsigned int width, height, border, depth;
- unsigned int screen_width = gdk_screen_width (), screen_height = gdk_screen_height ();
-
- /* exclude any strut areas not owned by this window */
- if (strut_owners[0] != gw->win)
- {
- screen_x = save_struts[0];
- screen_width -= save_struts[0];
- }
- if (strut_owners[2] != gw->win)
- {
- screen_y = save_struts[2];
- screen_height -= save_struts[2];
- }
- if (strut_owners[1] != gw->win)
- screen_width -= save_struts[1];
- if (strut_owners[3] != gw->win)
- screen_height -= save_struts[3];
-
- if (gw->deco == None)
- return;
-
- trap_push ();
-
- XGetGeometry (wm_disp, gw->deco,
- &root, &x, &y, &width, &height, &border, &depth);
-
- if (width > screen_width)
- width = screen_width;
- if (height > screen_height)
- height = screen_height;
-
- if (x < screen_x)
- x = screen_x;
- if (y < screen_y)
- y = screen_y;
- if ((x - screen_x + width) > screen_width)
- x = screen_width - width;
- if ((y - screen_y + height) > screen_height)
- y = screen_height - height;
-
- XMoveResizeWindow (wm_disp, gw->deco, x, y, width, height);
-
- trap_pop ();
+ int x, y, screen_x = 0, screen_y = 0;
+ Window root;
+ unsigned int width, height, border, depth;
+ unsigned int screen_width = gdk_screen_width (), screen_height = gdk_screen_height ();
+
+ /* exclude any strut areas not owned by this window */
+ if (strut_owners[0] != gw->win)
+ {
+ screen_x = save_struts[0];
+ screen_width -= save_struts[0];
+ }
+ if (strut_owners[2] != gw->win)
+ {
+ screen_y = save_struts[2];
+ screen_height -= save_struts[2];
+ }
+ if (strut_owners[1] != gw->win)
+ screen_width -= save_struts[1];
+ if (strut_owners[3] != gw->win)
+ screen_height -= save_struts[3];
+
+ if (gw->deco == None)
+ return;
+
+ trap_push ();
+
+ XGetGeometry (wm_disp, gw->deco,
+ &root, &x, &y, &width, &height, &border, &depth);
+
+ if (width > screen_width)
+ width = screen_width;
+ if (height > screen_height)
+ height = screen_height;
+
+ if (x < screen_x)
+ x = screen_x;
+ if (y < screen_y)
+ y = screen_y;
+ if ((x - screen_x + width) > screen_width)
+ x = screen_width - width;
+ if ((y - screen_y + height) > screen_height)
+ y = screen_height - height;
+
+ XMoveResizeWindow (wm_disp, gw->deco, x, y, width, height);
+
+ trap_pop ();
}
static void
constrain_all_windows (void)
{
- GList *winlist = windows;
-
- while (winlist)
- {
- GdmWindow *gw = winlist->data;
- constrain_window (gw);
- winlist = winlist->next;
- }
+ GList *winlist = windows;
+
+ while (winlist)
+ {
+ GdmWindow *gw = winlist->data;
+ constrain_window (gw);
+ winlist = winlist->next;
+ }
}
static void
center_x_window (GdmWindow *gw, Window w, Window hintwin)
{
- XSizeHints hints;
- Status status;
- long ret;
- int x, y;
- Window root;
- unsigned int width, height, border, depth;
- gboolean can_resize, can_reposition;
-
- trap_push ();
-
- status = XGetWMNormalHints (wm_disp,
- hintwin,
- &hints,
- &ret);
-
- if ( ! status) {
- trap_pop ();
- return;
- }
-
- /* allow resizing when PSize is given, just don't allow centering when
- * PPosition is goven */
- can_resize = ! (hints.flags & USSize);
- can_reposition = ! (hints.flags & USPosition ||
- hints.flags & PPosition);
-
- if (can_reposition && ! gw->center)
- can_reposition = FALSE;
-
- if (gw->ignore_size_hints) {
- can_resize = TRUE;
- can_reposition = TRUE;
- }
-
- if ( ! can_resize &&
- ! can_reposition) {
- trap_pop ();
- return;
- }
-
- XGetGeometry (wm_disp, w,
- &root, &x, &y, &width, &height, &border, &depth);
-
- /* we replace the x,y and width,height with some new values */
-
- if (can_resize) {
- if (width > gdm_wm_screen.width)
- width = gdm_wm_screen.width;
- if (height > gdm_wm_screen.height)
- height = gdm_wm_screen.height;
- }
-
- if (can_reposition) {
- /* we wipe the X with some new values */
- x = gdm_wm_screen.x + (gdm_wm_screen.width - width)/2;
- y = gdm_wm_screen.y + (gdm_wm_screen.height - height)/2;
-
- if (x < gdm_wm_screen.x)
- x = gdm_wm_screen.x;
- if (y < gdm_wm_screen.y)
- y = gdm_wm_screen.y;
- }
-
- XMoveResizeWindow (wm_disp, w, x, y, width, height);
-
- if (gw->center && ! gw->recenter) {
- gw->center = FALSE;
- }
-
- trap_pop ();
+ XSizeHints hints;
+ Status status;
+ long ret;
+ int x, y;
+ Window root;
+ unsigned int width, height, border, depth;
+ gboolean can_resize, can_reposition;
+
+ trap_push ();
+
+ status = XGetWMNormalHints (wm_disp,
+ hintwin,
+ &hints,
+ &ret);
+
+ if ( ! status) {
+ trap_pop ();
+ return;
+ }
+
+ /* allow resizing when PSize is given, just don't allow centering when
+ * PPosition is goven */
+ can_resize = ! (hints.flags & USSize);
+ can_reposition = ! (hints.flags & USPosition ||
+ hints.flags & PPosition);
+
+ if (can_reposition && ! gw->center)
+ can_reposition = FALSE;
+
+ if (gw->ignore_size_hints) {
+ can_resize = TRUE;
+ can_reposition = TRUE;
+ }
+
+ if ( ! can_resize &&
+ ! can_reposition) {
+ trap_pop ();
+ return;
+ }
+
+ XGetGeometry (wm_disp, w,
+ &root, &x, &y, &width, &height, &border, &depth);
+
+ /* we replace the x,y and width,height with some new values */
+
+ if (can_resize) {
+ if (width > gdm_wm_screen.width)
+ width = gdm_wm_screen.width;
+ if (height > gdm_wm_screen.height)
+ height = gdm_wm_screen.height;
+ }
+
+ if (can_reposition) {
+ /* we wipe the X with some new values */
+ x = gdm_wm_screen.x + (gdm_wm_screen.width - width)/2;
+ y = gdm_wm_screen.y + (gdm_wm_screen.height - height)/2;
+
+ if (x < gdm_wm_screen.x)
+ x = gdm_wm_screen.x;
+ if (y < gdm_wm_screen.y)
+ y = gdm_wm_screen.y;
+ }
+
+ XMoveResizeWindow (wm_disp, w, x, y, width, height);
+
+ if (gw->center && ! gw->recenter) {
+ gw->center = FALSE;
+ }
+
+ trap_pop ();
}
#ifndef MWMUTIL_H_INCLUDED
@@ -702,503 +702,503 @@ typedef struct {
static gboolean
has_deco (Window win)
{
- static Atom hints_atom = None;
- unsigned char *foo;
- MotifWmHints *hints;
- Atom type;
- gint format;
- gulong nitems;
- gulong bytes_after;
- gboolean border = TRUE;
-
- trap_push ();
-
- if (hints_atom == None)
- hints_atom = XInternAtom (wm_disp, "_MOTIF_WM_HINTS", False);
-
- hints = NULL;
-
- XGetWindowProperty (wm_disp, win,
- hints_atom, 0,
- sizeof (MotifWmHints) / sizeof (long),
- False, AnyPropertyType, &type, &format, &nitems,
- &bytes_after, &foo);
- hints = (MotifWmHints *)foo;
-
- if (type != None &&
- hints != NULL &&
- hints->flags & MWM_HINTS_DECORATIONS &&
- ! (hints->decorations & MWM_DECOR_BORDER)) {
- border = FALSE;
- }
-
- if (hints != NULL)
- XFree (hints);
-
- trap_pop ();
-
- return border;
+ static Atom hints_atom = None;
+ unsigned char *foo;
+ MotifWmHints *hints;
+ Atom type;
+ gint format;
+ gulong nitems;
+ gulong bytes_after;
+ gboolean border = TRUE;
+
+ trap_push ();
+
+ if (hints_atom == None)
+ hints_atom = XInternAtom (wm_disp, "_MOTIF_WM_HINTS", False);
+
+ hints = NULL;
+
+ XGetWindowProperty (wm_disp, win,
+ hints_atom, 0,
+ sizeof (MotifWmHints) / sizeof (long),
+ False, AnyPropertyType, &type, &format, &nitems,
+ &bytes_after, &foo);
+ hints = (MotifWmHints *)foo;
+
+ if (type != None &&
+ hints != NULL &&
+ hints->flags & MWM_HINTS_DECORATIONS &&
+ ! (hints->decorations & MWM_DECOR_BORDER)) {
+ border = FALSE;
+ }
+
+ if (hints != NULL)
+ XFree (hints);
+
+ trap_pop ();
+
+ return border;
}
static void
add_deco (GdmWindow *w, gboolean is_mapped)
{
- int x, y;
- Window root;
- unsigned int width, height, border, depth;
- XWindowAttributes attribs = { 0, };
- int black;
-
- trap_push ();
-
- XGetWindowAttributes (wm_disp, w->win, &attribs);
- XSelectInput (wm_disp, w->win,
- attribs.your_event_mask |
- PropertyChangeMask);
-
- if ( ! has_deco (w->win)) {
- trap_pop ();
- return;
- }
-
- XGetGeometry (wm_disp, w->win,
- &root, &x, &y, &width, &height, &border, &depth);
-
- black = BlackPixel (wm_disp, DefaultScreen (wm_disp));
-
- /* all but the login window has shadows */
- if (w->win != wm_login_window) {
- w->shadow = XCreateSimpleWindow (wm_disp,
- wm_root,
- x + 4, y + 4,
- width + 2 + 2 * border,
- height + 2 + 2 * border,
- 0,
- black, black);
-
- XMapWindow (wm_disp, w->shadow);
- }
-
- w->deco = XCreateSimpleWindow (wm_disp,
- wm_root,
- x - 1, y - 1,
- width + 2 + 2 * border,
- height + 2 + 2 * border,
- 0,
- black, black);
-
- XGetWindowAttributes (wm_disp, w->deco, &attribs);
- XSelectInput (wm_disp, w->deco,
- attribs.your_event_mask |
- EnterWindowMask |
- PropertyChangeMask |
- SubstructureNotifyMask |
- SubstructureRedirectMask);
-
- XMapWindow (wm_disp, w->deco);
-
- XSync (wm_disp, False);
- trap_pop ();
-
- trap_push ();
- XReparentWindow (wm_disp, w->win, w->deco, 1, 1);
- XSync (wm_disp, False);
- if (trap_pop () == 0) {
- if (is_mapped) {
- /* Ignore the next unmap/map, but only
- * if reparent window really succeeded */
- w->ignore_next_map++;
- w->ignore_next_unmap++;
- }
- }
+ int x, y;
+ Window root;
+ unsigned int width, height, border, depth;
+ XWindowAttributes attribs = { 0, };
+ int black;
+
+ trap_push ();
+
+ XGetWindowAttributes (wm_disp, w->win, &attribs);
+ XSelectInput (wm_disp, w->win,
+ attribs.your_event_mask |
+ PropertyChangeMask);
+
+ if ( ! has_deco (w->win)) {
+ trap_pop ();
+ return;
+ }
+
+ XGetGeometry (wm_disp, w->win,
+ &root, &x, &y, &width, &height, &border, &depth);
+
+ black = BlackPixel (wm_disp, DefaultScreen (wm_disp));
+
+ /* all but the login window has shadows */
+ if (w->win != wm_login_window) {
+ w->shadow = XCreateSimpleWindow (wm_disp,
+ wm_root,
+ x + 4, y + 4,
+ width + 2 + 2 * border,
+ height + 2 + 2 * border,
+ 0,
+ black, black);
+
+ XMapWindow (wm_disp, w->shadow);
+ }
+
+ w->deco = XCreateSimpleWindow (wm_disp,
+ wm_root,
+ x - 1, y - 1,
+ width + 2 + 2 * border,
+ height + 2 + 2 * border,
+ 0,
+ black, black);
+
+ XGetWindowAttributes (wm_disp, w->deco, &attribs);
+ XSelectInput (wm_disp, w->deco,
+ attribs.your_event_mask |
+ EnterWindowMask |
+ PropertyChangeMask |
+ SubstructureNotifyMask |
+ SubstructureRedirectMask);
+
+ XMapWindow (wm_disp, w->deco);
+
+ XSync (wm_disp, False);
+ trap_pop ();
+
+ trap_push ();
+ XReparentWindow (wm_disp, w->win, w->deco, 1, 1);
+ XSync (wm_disp, False);
+ if (trap_pop () == 0) {
+ if (is_mapped) {
+ /* Ignore the next unmap/map, but only
+ * if reparent window really succeeded */
+ w->ignore_next_map++;
+ w->ignore_next_unmap++;
+ }
+ }
}
static gboolean
is_wm_class (XClassHint *hint, const char *string, int len)
{
- if (len > 0) {
- return ((hint->res_name != NULL &&
- strncmp (hint->res_name, string, len) == 0) ||
- (hint->res_class != NULL &&
- strncmp (hint->res_class, string, len) == 0));
- } else {
- return ((hint->res_name != NULL &&
- strcmp (hint->res_name, string) == 0) ||
- (hint->res_class != NULL &&
- strcmp (hint->res_class, string) == 0));
- }
+ if (len > 0) {
+ return ((hint->res_name != NULL &&
+ strncmp (hint->res_name, string, len) == 0) ||
+ (hint->res_class != NULL &&
+ strncmp (hint->res_class, string, len) == 0));
+ } else {
+ return ((hint->res_name != NULL &&
+ strcmp (hint->res_name, string) == 0) ||
+ (hint->res_class != NULL &&
+ strcmp (hint->res_class, string) == 0));
+ }
}
static GdmWindow *
add_window (Window w, gboolean center, gboolean is_mapped)
{
- GdmWindow *gw;
-
- gw = find_window (w, FALSE);
- if (gw == NULL) {
- XClassHint hint = { NULL, NULL };
- XWMHints *wmhints;
- int x, y;
- Window root;
- unsigned int width, height, border, depth;
-
- gw = g_new0 (GdmWindow, 1);
- gw->win = w;
- windows = g_list_prepend (windows, gw);
-
- trap_push ();
-
- /* add "centering" */
- gw->ignore_size_hints = FALSE;
- gw->center = center;
- gw->recenter = FALSE;
- gw->takefocus = TRUE;
-
- gw->ignore_next_map = 0;
- gw->ignore_next_unmap = 0;
-
- wmhints = XGetWMHints (wm_disp, w);
- if (wmhints != NULL) {
- /* NoInput windows */
- if ((wmhints->flags & InputHint) &&
- ! wmhints->input) {
- gw->takefocus = FALSE;
- }
- XFree (wmhints);
- }
-
- /* hack, set USpos/size on login window */
- if (w == wm_login_window) {
- long ret;
- XSizeHints hints;
- XGetWMNormalHints (wm_disp, w, &hints, &ret);
- hints.flags |= USPosition | USSize;
- XSetWMNormalHints (wm_disp, w, &hints);
- gw->center = FALSE;
- gw->recenter = FALSE;
- } else if (XGetClassHint (wm_disp, w, &hint)) {
- if (is_wm_class (&hint, "gdm", 3)) {
- gw->ignore_size_hints = TRUE;
- gw->center = TRUE;
- gw->recenter = TRUE;
- } else if (is_wm_class (&hint, "gkrellm", 0)) {
- /* hack, gkrell is stupid and doesn't set
- * right hints, such as USPosition and other
- * such stuff */
- gw->center = FALSE;
- gw->recenter = FALSE;
- } else if (is_wm_class (&hint, "xscribble", 0)) {
- /* hack, xscribble mustn't take focus */
- gw->takefocus = FALSE;
- }
- if (hint.res_name != NULL)
- XFree (hint.res_name);
- if (hint.res_class != NULL)
- XFree (hint.res_class);
- }
-
- XGetGeometry (wm_disp, w,
- &root, &x, &y, &width, &height, &border, &depth);
-
- gw->x = x;
- gw->y = x;
-
- center_x_window (gw, w, w);
- add_deco (gw, is_mapped);
-
- XAddToSaveSet (wm_disp, w);
-
- trap_pop ();
- }
- return gw;
+ GdmWindow *gw;
+
+ gw = find_window (w, FALSE);
+ if (gw == NULL) {
+ XClassHint hint = { NULL, NULL };
+ XWMHints *wmhints;
+ int x, y;
+ Window root;
+ unsigned int width, height, border, depth;
+
+ gw = g_new0 (GdmWindow, 1);
+ gw->win = w;
+ windows = g_list_prepend (windows, gw);
+
+ trap_push ();
+
+ /* add "centering" */
+ gw->ignore_size_hints = FALSE;
+ gw->center = center;
+ gw->recenter = FALSE;
+ gw->takefocus = TRUE;
+
+ gw->ignore_next_map = 0;
+ gw->ignore_next_unmap = 0;
+
+ wmhints = XGetWMHints (wm_disp, w);
+ if (wmhints != NULL) {
+ /* NoInput windows */
+ if ((wmhints->flags & InputHint) &&
+ ! wmhints->input) {
+ gw->takefocus = FALSE;
+ }
+ XFree (wmhints);
+ }
+
+ /* hack, set USpos/size on login window */
+ if (w == wm_login_window) {
+ long ret;
+ XSizeHints hints;
+ XGetWMNormalHints (wm_disp, w, &hints, &ret);
+ hints.flags |= USPosition | USSize;
+ XSetWMNormalHints (wm_disp, w, &hints);
+ gw->center = FALSE;
+ gw->recenter = FALSE;
+ } else if (XGetClassHint (wm_disp, w, &hint)) {
+ if (is_wm_class (&hint, "gdm", 3)) {
+ gw->ignore_size_hints = TRUE;
+ gw->center = TRUE;
+ gw->recenter = TRUE;
+ } else if (is_wm_class (&hint, "gkrellm", 0)) {
+ /* hack, gkrell is stupid and doesn't set
+ * right hints, such as USPosition and other
+ * such stuff */
+ gw->center = FALSE;
+ gw->recenter = FALSE;
+ } else if (is_wm_class (&hint, "xscribble", 0)) {
+ /* hack, xscribble mustn't take focus */
+ gw->takefocus = FALSE;
+ }
+ if (hint.res_name != NULL)
+ XFree (hint.res_name);
+ if (hint.res_class != NULL)
+ XFree (hint.res_class);
+ }
+
+ XGetGeometry (wm_disp, w,
+ &root, &x, &y, &width, &height, &border, &depth);
+
+ gw->x = x;
+ gw->y = x;
+
+ center_x_window (gw, w, w);
+ add_deco (gw, is_mapped);
+
+ XAddToSaveSet (wm_disp, w);
+
+ trap_pop ();
+ }
+ return gw;
}
static void
remove_window (Window w)
{
- GList *li = find_window_list (w, FALSE);
+ GList *li = find_window_list (w, FALSE);
- if (w == wm_focus_window)
- wm_focus_window = None;
+ if (w == wm_focus_window)
+ wm_focus_window = None;
- if (li != NULL) {
- GdmWindow *gw = li->data;
+ if (li != NULL) {
+ GdmWindow *gw = li->data;
- li->data = NULL;
+ li->data = NULL;
- trap_push ();
+ trap_push ();
- XRemoveFromSaveSet (wm_disp, w);
+ XRemoveFromSaveSet (wm_disp, w);
- gw->win = None;
+ gw->win = None;
- if (gw->deco != None) {
- XDestroyWindow (wm_disp, gw->deco);
- gw->deco = None;
- }
- if (gw->shadow != None) {
- XDestroyWindow (wm_disp, gw->shadow);
- gw->shadow = None;
- }
- trap_pop ();
+ if (gw->deco != None) {
+ XDestroyWindow (wm_disp, gw->deco);
+ gw->deco = None;
+ }
+ if (gw->shadow != None) {
+ XDestroyWindow (wm_disp, gw->shadow);
+ gw->shadow = None;
+ }
+ trap_pop ();
- windows = g_list_remove_link (windows, li);
- g_list_free_1 (li);
+ windows = g_list_remove_link (windows, li);
+ g_list_free_1 (li);
- g_free (gw);
- }
+ g_free (gw);
+ }
}
static void
revert_focus_to_login (void)
{
- if (wm_login_window != None) {
- gdm_wm_focus_window (wm_login_window);
- }
+ if (wm_login_window != None) {
+ gdm_wm_focus_window (wm_login_window);
+ }
}
static void
add_all_current_windows (void)
{
- Window *children = NULL;
- Window xparent, xroot;
- guint size = 0;
-
- gdk_flush ();
- XSync (wm_disp, False);
- trap_push ();
-
- XGrabServer (wm_disp);
-
- if (XQueryTree (wm_disp,
- wm_root,
- &xroot,
- &xparent,
- &children,
- &size)) {
- int i;
-
- for (i = 0; i < size; i++) {
- XWindowAttributes attribs = {0};
-
- XGetWindowAttributes (wm_disp,
- children[i],
- &attribs);
-
- if ( ! attribs.override_redirect &&
- attribs.map_state != IsUnmapped) {
- add_window (children[i],
- FALSE /*center*/,
- TRUE /* is_mapped */);
- }
- }
-
- if (children != NULL)
- XFree (children);
- }
-
- XUngrabServer (wm_disp);
-
- trap_pop ();
+ Window *children = NULL;
+ Window xparent, xroot;
+ guint size = 0;
+
+ gdk_flush ();
+ XSync (wm_disp, False);
+ trap_push ();
+
+ XGrabServer (wm_disp);
+
+ if (XQueryTree (wm_disp,
+ wm_root,
+ &xroot,
+ &xparent,
+ &children,
+ &size)) {
+ int i;
+
+ for (i = 0; i < size; i++) {
+ XWindowAttributes attribs = {0};
+
+ XGetWindowAttributes (wm_disp,
+ children[i],
+ &attribs);
+
+ if ( ! attribs.override_redirect &&
+ attribs.map_state != IsUnmapped) {
+ add_window (children[i],
+ FALSE /*center*/,
+ TRUE /* is_mapped */);
+ }
+ }
+
+ if (children != NULL)
+ XFree (children);
+ }
+
+ XUngrabServer (wm_disp);
+
+ trap_pop ();
}
static void
reparent_to_root (GdmWindow *gw)
{
- /* only if reparented */
- if (gw->deco != None) {
- trap_push ();
+ /* only if reparented */
+ if (gw->deco != None) {
+ trap_push ();
- XReparentWindow (wm_disp, gw->win, wm_root, gw->x, gw->y);
- XSync (wm_disp, False);
+ XReparentWindow (wm_disp, gw->win, wm_root, gw->x, gw->y);
+ XSync (wm_disp, False);
- trap_pop ();
- }
+ trap_pop ();
+ }
}
static void
shadow_follow (GdmWindow *gw)
{
- int x, y;
- Window root;
- unsigned int width, height, border, depth;
+ int x, y;
+ Window root;
+ unsigned int width, height, border, depth;
- if (gw->shadow == None)
- return;
+ if (gw->shadow == None)
+ return;
- trap_push ();
+ trap_push ();
- XGetGeometry (wm_disp, gw->deco,
- &root, &x, &y, &width, &height, &border, &depth);
+ XGetGeometry (wm_disp, gw->deco,
+ &root, &x, &y, &width, &height, &border, &depth);
- x += 5;
- y += 5;
+ x += 5;
+ y += 5;
- XMoveResizeWindow (wm_disp, gw->shadow, x, y, width, height);
+ XMoveResizeWindow (wm_disp, gw->shadow, x, y, width, height);
- trap_pop ();
+ trap_pop ();
}
static void
event_process (XEvent *ev)
{
- GdmWindow *gw;
- Window w;
- XWindowChanges wchanges;
-
- trap_push ();
-
- switch (ev->type) {
- case MapRequest:
- w = ev->xmaprequest.window;
- gw = find_window (w, FALSE);
- if (gw == NULL) {
- if (ev->xmaprequest.parent == wm_root) {
- XGrabServer (wm_disp);
- gw = add_window (w,
- TRUE /* center */,
- FALSE /* is_mapped */);
- XUngrabServer (wm_disp);
- }
- }
- XMapWindow (wm_disp, w);
- break;
- case ConfigureRequest:
- XGrabServer (wm_disp);
- w = ev->xconfigurerequest.window;
- gw = find_window (w, FALSE);
- wchanges.border_width = ev->xconfigurerequest.border_width;
- wchanges.sibling = ev->xconfigurerequest.above;
- wchanges.stack_mode = ev->xconfigurerequest.detail;
- if (gw == NULL ||
- gw->deco == None) {
- wchanges.x = ev->xconfigurerequest.x;
- wchanges.y = ev->xconfigurerequest.y;
- } else {
- wchanges.x = 1;
- wchanges.y = 1;
- }
- wchanges.width = ev->xconfigurerequest.width;
- wchanges.height = ev->xconfigurerequest.height;
- XConfigureWindow (wm_disp,
- w,
- ev->xconfigurerequest.value_mask,
- &wchanges);
- if (gw != NULL) {
- gw->x = ev->xconfigurerequest.x;
- gw->y = ev->xconfigurerequest.y;
- if (gw->deco != None) {
- wchanges.x = ev->xconfigurerequest.x - 1;
- wchanges.y = ev->xconfigurerequest.y - 1;
- wchanges.width = ev->xconfigurerequest.width + 2
- + 2*ev->xconfigurerequest.border_width;;
- wchanges.height = ev->xconfigurerequest.height + 2
- + 2*ev->xconfigurerequest.border_width;;
- wchanges.border_width = 0;
- XConfigureWindow (wm_disp,
- gw->deco,
- ev->xconfigurerequest.value_mask,
- &wchanges);
- center_x_window (gw, gw->deco, gw->win);
- } else {
- center_x_window (gw, gw->win, gw->win);
- }
- shadow_follow (gw);
- }
- XUngrabServer (wm_disp);
- break;
- case CirculateRequest:
- w = ev->xcirculaterequest.window;
- gw = find_window (w, FALSE);
- if (gw == NULL) {
- if (ev->xcirculaterequest.place == PlaceOnTop)
- XRaiseWindow (wm_disp, w);
- else
- XLowerWindow (wm_disp, w);
- } else {
- if (ev->xcirculaterequest.place == PlaceOnTop) {
- if (gw->shadow != None)
- XRaiseWindow (wm_disp, gw->shadow);
- if (gw->deco != None)
- XRaiseWindow (wm_disp, gw->deco);
- else
- XRaiseWindow (wm_disp, gw->win);
- } else {
- if (gw->deco != None)
- XLowerWindow (wm_disp, gw->deco);
- else
- XLowerWindow (wm_disp, gw->win);
- if (gw->shadow != None)
- XLowerWindow (wm_disp, gw->shadow);
- }
- }
- break;
- case MapNotify:
- w = ev->xmap.window;
- gw = find_window (w, FALSE);
- if (gw != NULL) {
- if (gw->ignore_next_map > 0) {
- gw->ignore_next_map --;
- break;
- }
- if ( ! ev->xmap.override_redirect &&
- focus_new_windows) {
- gdm_wm_focus_window (w);
- }
- }
- break;
- case UnmapNotify:
- w = ev->xunmap.window;
- gw = find_window (w, FALSE);
- if (gw != NULL) {
- if (gw->ignore_next_unmap > 0) {
- gw->ignore_next_unmap --;
- break;
- }
- XGrabServer (wm_disp);
- if (gw->deco != None)
- XUnmapWindow (wm_disp, gw->deco);
- if (gw->shadow != None)
- XUnmapWindow (wm_disp, gw->shadow);
- reparent_to_root (gw);
- remove_window (w);
- XDeleteProperty (wm_disp, w, XA_WM_STATE);
- if (w != wm_login_window)
- revert_focus_to_login ();
- XUngrabServer (wm_disp);
- }
- break;
- case DestroyNotify:
- w = ev->xdestroywindow.window;
- gw = find_window (w, FALSE);
- if (gw != NULL) {
- XGrabServer (wm_disp);
- remove_window (w);
- if (w != wm_login_window)
- revert_focus_to_login ();
- XUngrabServer (wm_disp);
- }
- break;
- case EnterNotify:
- w = ev->xcrossing.window;
- gw = find_window (w, TRUE);
- if (gw != NULL)
- gdm_wm_focus_window (gw->win);
- break;
- case PropertyNotify:
- if (ev->xproperty.atom == XA_NET_WM_STRUT)
- {
- gdm_wm_update_struts (ev->xproperty.display,
- ev->xproperty.window);
- constrain_all_windows ();
- }
- break;
- default:
- break;
- }
-
- trap_pop ();
+ GdmWindow *gw;
+ Window w;
+ XWindowChanges wchanges;
+
+ trap_push ();
+
+ switch (ev->type) {
+ case MapRequest:
+ w = ev->xmaprequest.window;
+ gw = find_window (w, FALSE);
+ if (gw == NULL) {
+ if (ev->xmaprequest.parent == wm_root) {
+ XGrabServer (wm_disp);
+ gw = add_window (w,
+ TRUE /* center */,
+ FALSE /* is_mapped */);
+ XUngrabServer (wm_disp);
+ }
+ }
+ XMapWindow (wm_disp, w);
+ break;
+ case ConfigureRequest:
+ XGrabServer (wm_disp);
+ w = ev->xconfigurerequest.window;
+ gw = find_window (w, FALSE);
+ wchanges.border_width = ev->xconfigurerequest.border_width;
+ wchanges.sibling = ev->xconfigurerequest.above;
+ wchanges.stack_mode = ev->xconfigurerequest.detail;
+ if (gw == NULL ||
+ gw->deco == None) {
+ wchanges.x = ev->xconfigurerequest.x;
+ wchanges.y = ev->xconfigurerequest.y;
+ } else {
+ wchanges.x = 1;
+ wchanges.y = 1;
+ }
+ wchanges.width = ev->xconfigurerequest.width;
+ wchanges.height = ev->xconfigurerequest.height;
+ XConfigureWindow (wm_disp,
+ w,
+ ev->xconfigurerequest.value_mask,
+ &wchanges);
+ if (gw != NULL) {
+ gw->x = ev->xconfigurerequest.x;
+ gw->y = ev->xconfigurerequest.y;
+ if (gw->deco != None) {
+ wchanges.x = ev->xconfigurerequest.x - 1;
+ wchanges.y = ev->xconfigurerequest.y - 1;
+ wchanges.width = ev->xconfigurerequest.width + 2
+ + 2*ev->xconfigurerequest.border_width;;
+ wchanges.height = ev->xconfigurerequest.height + 2
+ + 2*ev->xconfigurerequest.border_width;;
+ wchanges.border_width = 0;
+ XConfigureWindow (wm_disp,
+ gw->deco,
+ ev->xconfigurerequest.value_mask,
+ &wchanges);
+ center_x_window (gw, gw->deco, gw->win);
+ } else {
+ center_x_window (gw, gw->win, gw->win);
+ }
+ shadow_follow (gw);
+ }
+ XUngrabServer (wm_disp);
+ break;
+ case CirculateRequest:
+ w = ev->xcirculaterequest.window;
+ gw = find_window (w, FALSE);
+ if (gw == NULL) {
+ if (ev->xcirculaterequest.place == PlaceOnTop)
+ XRaiseWindow (wm_disp, w);
+ else
+ XLowerWindow (wm_disp, w);
+ } else {
+ if (ev->xcirculaterequest.place == PlaceOnTop) {
+ if (gw->shadow != None)
+ XRaiseWindow (wm_disp, gw->shadow);
+ if (gw->deco != None)
+ XRaiseWindow (wm_disp, gw->deco);
+ else
+ XRaiseWindow (wm_disp, gw->win);
+ } else {
+ if (gw->deco != None)
+ XLowerWindow (wm_disp, gw->deco);
+ else
+ XLowerWindow (wm_disp, gw->win);
+ if (gw->shadow != None)
+ XLowerWindow (wm_disp, gw->shadow);
+ }
+ }
+ break;
+ case MapNotify:
+ w = ev->xmap.window;
+ gw = find_window (w, FALSE);
+ if (gw != NULL) {
+ if (gw->ignore_next_map > 0) {
+ gw->ignore_next_map --;
+ break;
+ }
+ if ( ! ev->xmap.override_redirect &&
+ focus_new_windows) {
+ gdm_wm_focus_window (w);
+ }
+ }
+ break;
+ case UnmapNotify:
+ w = ev->xunmap.window;
+ gw = find_window (w, FALSE);
+ if (gw != NULL) {
+ if (gw->ignore_next_unmap > 0) {
+ gw->ignore_next_unmap --;
+ break;
+ }
+ XGrabServer (wm_disp);
+ if (gw->deco != None)
+ XUnmapWindow (wm_disp, gw->deco);
+ if (gw->shadow != None)
+ XUnmapWindow (wm_disp, gw->shadow);
+ reparent_to_root (gw);
+ remove_window (w);
+ XDeleteProperty (wm_disp, w, XA_WM_STATE);
+ if (w != wm_login_window)
+ revert_focus_to_login ();
+ XUngrabServer (wm_disp);
+ }
+ break;
+ case DestroyNotify:
+ w = ev->xdestroywindow.window;
+ gw = find_window (w, FALSE);
+ if (gw != NULL) {
+ XGrabServer (wm_disp);
+ remove_window (w);
+ if (w != wm_login_window)
+ revert_focus_to_login ();
+ XUngrabServer (wm_disp);
+ }
+ break;
+ case EnterNotify:
+ w = ev->xcrossing.window;
+ gw = find_window (w, TRUE);
+ if (gw != NULL)
+ gdm_wm_focus_window (gw->win);
+ break;
+ case PropertyNotify:
+ if (ev->xproperty.atom == XA_NET_WM_STRUT)
+ {
+ gdm_wm_update_struts (ev->xproperty.display,
+ ev->xproperty.window);
+ constrain_all_windows ();
+ }
+ break;
+ default:
+ break;
+ }
+
+ trap_pop ();
}
/* following partly stolen from gdk */
@@ -1206,491 +1206,491 @@ static GPollFD event_poll_fd;
static gboolean
event_prepare (GSource *source,
- gint *timeout)
+ gint *timeout)
{
- *timeout = -1;
- return XPending (wm_disp) > 0;
+ *timeout = -1;
+ return XPending (wm_disp) > 0;
}
static gboolean
event_check (GSource *source)
{
- if (event_poll_fd.revents & G_IO_IN) {
- return XPending (wm_disp) > 0;
- } else {
- return FALSE;
- }
+ if (event_poll_fd.revents & G_IO_IN) {
+ return XPending (wm_disp) > 0;
+ } else {
+ return FALSE;
+ }
}
static void
process_events (void)
{
- while (XPending (wm_disp) > 0) {
- XEvent ev;
- XNextEvent (wm_disp, &ev);
- event_process (&ev);
- }
+ while (XPending (wm_disp) > 0) {
+ XEvent ev;
+ XNextEvent (wm_disp, &ev);
+ event_process (&ev);
+ }
}
static gboolean
event_dispatch (GSource *source,
- GSourceFunc callback,
- gpointer user_data)
+ GSourceFunc callback,
+ gpointer user_data)
{
- process_events ();
+ process_events ();
- return TRUE;
+ return TRUE;
}
static GSourceFuncs event_funcs = {
- event_prepare,
- event_check,
- event_dispatch
+ event_prepare,
+ event_check,
+ event_dispatch
};
void
gdm_wm_init (Window login_window)
{
- XWindowAttributes attribs = { 0, };
- GSource *source;
+ XWindowAttributes attribs = { 0, };
+ GSource *source;
- wm_login_window = login_window;
+ wm_login_window = login_window;
- if (wm_disp != NULL) {
- return;
- }
+ if (wm_disp != NULL) {
+ return;
+ }
- wm_disp = XOpenDisplay (gdk_get_display ());
- if (wm_disp == NULL) {
- /* EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEK! */
- wm_disp = GDK_DISPLAY ();
- return;
- }
+ wm_disp = XOpenDisplay (gdk_get_display ());
+ if (wm_disp == NULL) {
+ /* EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEK! */
+ wm_disp = GDK_DISPLAY ();
+ return;
+ }
- trap_push ();
+ trap_push ();
- XA_WM_PROTOCOLS = XInternAtom (wm_disp, "WM_PROTOCOLS", False);
- XA_WM_STATE = XInternAtom (wm_disp, "WM_STATE", False);
- XA_WM_TAKE_FOCUS = XInternAtom (wm_disp, "WM_TAKE_FOCUS", False);
+ XA_WM_PROTOCOLS = XInternAtom (wm_disp, "WM_PROTOCOLS", False);
+ XA_WM_STATE = XInternAtom (wm_disp, "WM_STATE", False);
+ XA_WM_TAKE_FOCUS = XInternAtom (wm_disp, "WM_TAKE_FOCUS", False);
- XA_COMPOUND_TEXT = XInternAtom (wm_disp, "COMPOUND_TEXT", False);
- XA_NET_WM_STRUT = XInternAtom (wm_disp, "_NET_WM_STRUT", False);
+ XA_COMPOUND_TEXT = XInternAtom (wm_disp, "COMPOUND_TEXT", False);
+ XA_NET_WM_STRUT = XInternAtom (wm_disp, "_NET_WM_STRUT", False);
- wm_root = DefaultRootWindow (wm_disp);
+ wm_root = DefaultRootWindow (wm_disp);
- /* set event mask for events on root window */
- XGetWindowAttributes (wm_disp, wm_root, &attribs);
- XSelectInput (wm_disp, wm_root,
- attribs.your_event_mask |
- SubstructureNotifyMask |
- SubstructureRedirectMask);
+ /* set event mask for events on root window */
+ XGetWindowAttributes (wm_disp, wm_root, &attribs);
+ XSelectInput (wm_disp, wm_root,
+ attribs.your_event_mask |
+ SubstructureNotifyMask |
+ SubstructureRedirectMask);
- if (trap_pop () != 0)
- return;
+ if (trap_pop () != 0)
+ return;
- trap_push ();
+ trap_push ();
- add_all_current_windows ();
+ add_all_current_windows ();
- source = g_source_new (&event_funcs, sizeof (GSource));
+ source = g_source_new (&event_funcs, sizeof (GSource));
- event_poll_fd.fd = ConnectionNumber (wm_disp);
- event_poll_fd.events = G_IO_IN;
+ event_poll_fd.fd = ConnectionNumber (wm_disp);
+ event_poll_fd.events = G_IO_IN;
- g_source_add_poll (source, &event_poll_fd);
- g_source_set_priority (source, GDK_PRIORITY_EVENTS);
- g_source_set_can_recurse (source, FALSE);
- g_source_attach (source, NULL);
+ g_source_add_poll (source, &event_poll_fd);
+ g_source_set_priority (source, GDK_PRIORITY_EVENTS);
+ g_source_set_can_recurse (source, FALSE);
+ g_source_attach (source, NULL);
- trap_pop ();
+ trap_pop ();
}
void
gdm_wm_focus_new_windows (gboolean focus)
{
- focus_new_windows = focus;
+ focus_new_windows = focus;
}
void
gdm_wm_no_login_focus_push (void)
{
- /* it makes not sense for this to be false then */
- focus_new_windows = TRUE;
- no_focus_login++;
+ /* it makes not sense for this to be false then */
+ focus_new_windows = TRUE;
+ no_focus_login++;
}
void
gdm_wm_no_login_focus_pop (void)
{
- no_focus_login --;
+ no_focus_login --;
- if (no_focus_login == 0 &&
- wm_focus_window == None &&
- wm_login_window != None)
- gdm_wm_focus_window (wm_login_window);
+ if (no_focus_login == 0 &&
+ wm_focus_window == None &&
+ wm_login_window != None)
+ gdm_wm_focus_window (wm_login_window);
}
void
gdm_wm_get_window_pos (Window window, int *xp, int *yp)
{
- int x, y;
- Window root;
- unsigned int width, height, border, depth;
- GdmWindow *gw;
+ int x, y;
+ Window root;
+ unsigned int width, height, border, depth;
+ GdmWindow *gw;
- trap_push ();
+ trap_push ();
- gw = find_window (window, TRUE);
+ gw = find_window (window, TRUE);
- if (gw == NULL) {
- XGetGeometry (wm_disp, window,
- &root, &x, &y, &width, &height, &border, &depth);
+ if (gw == NULL) {
+ XGetGeometry (wm_disp, window,
+ &root, &x, &y, &width, &height, &border, &depth);
- *xp = x;
- *yp = y;
+ *xp = x;
+ *yp = y;
- trap_pop ();
+ trap_pop ();
- return;
- }
+ return;
+ }
- if (gw->deco != None) {
- XGetGeometry (wm_disp, gw->deco,
- &root, &x, &y, &width, &height, &border, &depth);
- *xp = x + 1;
- *yp = y + 1;
- } else {
- XGetGeometry (wm_disp, gw->win,
- &root, &x, &y, &width, &height, &border, &depth);
- *xp = x;
- *yp = y;
- }
+ if (gw->deco != None) {
+ XGetGeometry (wm_disp, gw->deco,
+ &root, &x, &y, &width, &height, &border, &depth);
+ *xp = x + 1;
+ *yp = y + 1;
+ } else {
+ XGetGeometry (wm_disp, gw->win,
+ &root, &x, &y, &width, &height, &border, &depth);
+ *xp = x;
+ *yp = y;
+ }
- trap_pop ();
+ trap_pop ();
}
void
gdm_wm_move_window_now (Window window, int x, int y)
{
- GdmWindow *gw;
+ GdmWindow *gw;
- trap_push ();
+ trap_push ();
- gw = find_window (window, TRUE);
+ gw = find_window (window, TRUE);
- if (gw == NULL) {
- XMoveWindow (wm_disp, window, x, y);
+ if (gw == NULL) {
+ XMoveWindow (wm_disp, window, x, y);
- XSync (wm_disp, False);
- trap_pop ();
- return;
- }
+ XSync (wm_disp, False);
+ trap_pop ();
+ return;
+ }
- if (gw->deco != None)
- XMoveWindow (wm_disp, gw->deco, x - 1, y - 1);
- else
- XMoveWindow (wm_disp, gw->win, x, y);
- if (gw->shadow != None)
- XMoveWindow (wm_disp, gw->deco, x + 4, y + 4);
+ if (gw->deco != None)
+ XMoveWindow (wm_disp, gw->deco, x - 1, y - 1);
+ else
+ XMoveWindow (wm_disp, gw->win, x, y);
+ if (gw->shadow != None)
+ XMoveWindow (wm_disp, gw->deco, x + 4, y + 4);
- XSync (wm_disp, False);
- trap_pop ();
+ XSync (wm_disp, False);
+ trap_pop ();
}
void
gdm_wm_save_wm_order (void)
{
- Window *children = NULL;
- Window xparent, xroot;
- guint size = 0;
- int dlen = 0;
- unsigned long *data;
-
- gdk_flush ();
- XSync (wm_disp, False);
- trap_push ();
-
- XGrabServer (wm_disp);
-
- if (XQueryTree (wm_disp,
- wm_root,
- &xroot,
- &xparent,
- &children,
- &size)) {
- int i;
- Atom atom;
- data = g_new0 (unsigned long, size);
-
- for (i = 0; i < size; i++) {
- GdmWindow *gw = find_window (children[i], TRUE);
-
- /* Ignore unknowns and shadows */
- if (gw == NULL ||
- gw->shadow == children[i])
- continue;
-
- if (gw->win == wm_login_window) {
- /* Empty spot in the list signifies the
- * login window */
- data [dlen++] = None;
- } else {
- data [dlen++] = gw->win;
- }
- }
-
- atom = XInternAtom (wm_disp, "GDMWM_WINDOW_ORDER", False);
-
- XChangeProperty (wm_disp, wm_root,
- atom,
- XA_CARDINAL,
- 32,
- PropModeReplace,
- (unsigned char *)data,
- dlen);
-
- if (children != NULL)
- XFree (children);
- g_free (data);
- }
-
- XUngrabServer (wm_disp);
-
- trap_pop ();
+ Window *children = NULL;
+ Window xparent, xroot;
+ guint size = 0;
+ int dlen = 0;
+ unsigned long *data;
+
+ gdk_flush ();
+ XSync (wm_disp, False);
+ trap_push ();
+
+ XGrabServer (wm_disp);
+
+ if (XQueryTree (wm_disp,
+ wm_root,
+ &xroot,
+ &xparent,
+ &children,
+ &size)) {
+ int i;
+ Atom atom;
+ data = g_new0 (unsigned long, size);
+
+ for (i = 0; i < size; i++) {
+ GdmWindow *gw = find_window (children[i], TRUE);
+
+ /* Ignore unknowns and shadows */
+ if (gw == NULL ||
+ gw->shadow == children[i])
+ continue;
+
+ if (gw->win == wm_login_window) {
+ /* Empty spot in the list signifies the
+ * login window */
+ data [dlen++] = None;
+ } else {
+ data [dlen++] = gw->win;
+ }
+ }
+
+ atom = XInternAtom (wm_disp, "GDMWM_WINDOW_ORDER", False);
+
+ XChangeProperty (wm_disp, wm_root,
+ atom,
+ XA_CARDINAL,
+ 32,
+ PropModeReplace,
+ (unsigned char *)data,
+ dlen);
+
+ if (children != NULL)
+ XFree (children);
+ g_free (data);
+ }
+
+ XUngrabServer (wm_disp);
+
+ trap_pop ();
}
static gboolean
focus_win (gpointer data)
{
- Window focus = (Window)data;
- focus_new_windows = TRUE;
- gdm_wm_focus_window (focus);
- return FALSE;
+ Window focus = (Window)data;
+ focus_new_windows = TRUE;
+ gdm_wm_focus_window (focus);
+ return FALSE;
}
void
gdm_wm_restore_wm_order (void)
{
- guint32 *data;
- Window focus = None;
- int size;
- int i;
- Atom atom;
-
- gdk_flush ();
- XSync (wm_disp, False);
-
- process_events ();
-
- gdk_flush ();
- XSync (wm_disp, False);
- trap_push ();
-
- XGrabServer (wm_disp);
-
- atom = XInternAtom (wm_disp, "GDMWM_WINDOW_ORDER", False);
-
- data = get_typed_property_data (wm_disp, wm_root,
- atom, XA_CARDINAL,
- &size, 32);
-
- if (data != NULL) {
- for (i = 0; i < size/4; i++) {
- GdmWindow *gw;
- if (data[i] == None)
- gw = find_window (wm_login_window, TRUE);
- else
- gw = find_window (data[i], TRUE);
-
- if (gw != NULL) {
- focus = gw->win;
- if (gw->shadow != None)
- XRaiseWindow (wm_disp, gw->shadow);
- if (gw->deco != None)
- XRaiseWindow (wm_disp, gw->deco);
- else
- XRaiseWindow (wm_disp, gw->win);
- }
- }
-
- g_free (data);
- }
+ guint32 *data;
+ Window focus = None;
+ int size;
+ int i;
+ Atom atom;
+
+ gdk_flush ();
+ XSync (wm_disp, False);
+
+ process_events ();
+
+ gdk_flush ();
+ XSync (wm_disp, False);
+ trap_push ();
+
+ XGrabServer (wm_disp);
+
+ atom = XInternAtom (wm_disp, "GDMWM_WINDOW_ORDER", False);
+
+ data = get_typed_property_data (wm_disp, wm_root,
+ atom, XA_CARDINAL,
+ &size, 32);
+
+ if (data != NULL) {
+ for (i = 0; i < size/4; i++) {
+ GdmWindow *gw;
+ if (data[i] == None)
+ gw = find_window (wm_login_window, TRUE);
+ else
+ gw = find_window (data[i], TRUE);
+
+ if (gw != NULL) {
+ focus = gw->win;
+ if (gw->shadow != None)
+ XRaiseWindow (wm_disp, gw->shadow);
+ if (gw->deco != None)
+ XRaiseWindow (wm_disp, gw->deco);
+ else
+ XRaiseWindow (wm_disp, gw->win);
+ }
+ }
+
+ g_free (data);
+ }
- XUngrabServer (wm_disp);
+ XUngrabServer (wm_disp);
- trap_pop ();
+ trap_pop ();
- process_events ();
+ process_events ();
- if (focus != None) {
- /* let us hit the main loop first */
- g_idle_add (focus_win, (gpointer)focus);
- }
+ if (focus != None) {
+ /* let us hit the main loop first */
+ g_idle_add (focus_win, (gpointer)focus);
+ }
}
static void
setup_cursor (GdkCursorType type)
{
- GdkCursor *cursor = gdk_cursor_new (type);
- gdk_window_set_cursor (gdk_get_default_root_window (), cursor);
- gdk_cursor_unref (cursor);
+ GdkCursor *cursor = gdk_cursor_new (type);
+ gdk_window_set_cursor (gdk_get_default_root_window (), cursor);
+ gdk_cursor_unref (cursor);
}
void
gdm_wm_show_info_msg_dialog (const gchar *msg_file,
- const gchar *msg_font)
+ const gchar *msg_font)
{
- GtkWidget *dialog, *label;
- gchar *InfoMsg;
- gsize InfoMsgLength;
-
- if ((msg_file == NULL || msg_file[0] == '\0') ||
- ! g_file_test (msg_file, G_FILE_TEST_EXISTS) ||
- ! g_file_get_contents (msg_file, &InfoMsg, &InfoMsgLength, NULL))
- return;
-
- if (InfoMsgLength <= 0) {
- g_free (InfoMsg);
- return;
- }
-
- gdm_wm_focus_new_windows (TRUE);
- dialog = gtk_dialog_new_with_buttons (NULL /* Message */,
- NULL /* parent */, GTK_DIALOG_MODAL |
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- NULL);
- label = gtk_label_new (InfoMsg);
-
- if (msg_font && strlen (msg_font) > 0) {
- PangoFontDescription *GdmInfoMsgFontDesc = pango_font_description_from_string (msg_font);
- if (GdmInfoMsgFontDesc) {
- gtk_widget_modify_font (label, GdmInfoMsgFontDesc);
- pango_font_description_free (GdmInfoMsgFontDesc);
- }
- }
-
- gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), label);
- gtk_widget_show_all (dialog);
- gdm_wm_center_window (GTK_WINDOW (dialog));
-
- setup_cursor (GDK_LEFT_PTR);
-
- gdm_wm_no_login_focus_push ();
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- gdm_wm_no_login_focus_pop ();
-
- g_free (InfoMsg);
+ GtkWidget *dialog, *label;
+ gchar *InfoMsg;
+ gsize InfoMsgLength;
+
+ if ((msg_file == NULL || msg_file[0] == '\0') ||
+ ! g_file_test (msg_file, G_FILE_TEST_EXISTS) ||
+ ! g_file_get_contents (msg_file, &InfoMsg, &InfoMsgLength, NULL))
+ return;
+
+ if (InfoMsgLength <= 0) {
+ g_free (InfoMsg);
+ return;
+ }
+
+ gdm_wm_focus_new_windows (TRUE);
+ dialog = gtk_dialog_new_with_buttons (NULL /* Message */,
+ NULL /* parent */, GTK_DIALOG_MODAL |
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_OK, GTK_RESPONSE_OK,
+ NULL);
+ label = gtk_label_new (InfoMsg);
+
+ if (msg_font && strlen (msg_font) > 0) {
+ PangoFontDescription *GdmInfoMsgFontDesc = pango_font_description_from_string (msg_font);
+ if (GdmInfoMsgFontDesc) {
+ gtk_widget_modify_font (label, GdmInfoMsgFontDesc);
+ pango_font_description_free (GdmInfoMsgFontDesc);
+ }
+ }
+
+ gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), label);
+ gtk_widget_show_all (dialog);
+ gdm_wm_center_window (GTK_WINDOW (dialog));
+
+ setup_cursor (GDK_LEFT_PTR);
+
+ gdm_wm_no_login_focus_push ();
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ gdm_wm_no_login_focus_pop ();
+
+ g_free (InfoMsg);
}
static GtkWidget *
hig_dialog_new (GtkWindow *parent,
- GtkDialogFlags flags,
- GtkMessageType type,
- GtkButtonsType buttons,
- const gchar *primary_message,
- const gchar *secondary_message)
+ GtkDialogFlags flags,
+ GtkMessageType type,
+ GtkButtonsType buttons,
+ const gchar *primary_message,
+ const gchar *secondary_message)
{
- GtkWidget *dialog;
+ GtkWidget *dialog;
- dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- type,
- buttons,
- "%s", primary_message);
+ dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ type,
+ buttons,
+ "%s", primary_message);
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- "%s", secondary_message);
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s", secondary_message);
- gtk_window_set_title (GTK_WINDOW (dialog), "");
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 14);
+ gtk_window_set_title (GTK_WINDOW (dialog), "");
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 14);
- return dialog;
+ return dialog;
}
void
gdm_wm_message_dialog (const gchar *primary_message,
- const gchar *secondary_message)
+ const gchar *secondary_message)
{
- GtkWidget *req = NULL;
+ GtkWidget *req = NULL;
- /* we should be now fine for focusing new windows */
- gdm_wm_focus_new_windows (TRUE);
+ /* we should be now fine for focusing new windows */
+ gdm_wm_focus_new_windows (TRUE);
- req = hig_dialog_new (NULL /* parent */,
+ req = hig_dialog_new (NULL /* parent */,
GTK_DIALOG_MODAL /* flags */,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
primary_message,
secondary_message);
- gdm_wm_center_window (GTK_WINDOW (req));
+ gdm_wm_center_window (GTK_WINDOW (req));
- gdm_wm_no_login_focus_push ();
- gtk_dialog_run (GTK_DIALOG (req));
- gtk_widget_destroy (req);
- gdm_wm_no_login_focus_pop ();
+ gdm_wm_no_login_focus_push ();
+ gtk_dialog_run (GTK_DIALOG (req));
+ gtk_widget_destroy (req);
+ gdm_wm_no_login_focus_pop ();
}
gint
gdm_wm_query_dialog (const gchar *primary_message,
- const gchar *secondary_message,
- const char *posbutton,
- const char *negbutton,
- gboolean has_cancel)
+ const gchar *secondary_message,
+ const char *posbutton,
+ const char *negbutton,
+ gboolean has_cancel)
{
- int ret;
- GtkWidget *req;
- GtkWidget *button;
+ int ret;
+ GtkWidget *req;
+ GtkWidget *button;
- /* we should be now fine for focusing new windows */
- gdm_wm_focus_new_windows (TRUE);
+ /* we should be now fine for focusing new windows */
+ gdm_wm_focus_new_windows (TRUE);
- req = hig_dialog_new (NULL /* parent */,
+ req = hig_dialog_new (NULL /* parent */,
GTK_DIALOG_MODAL /* flags */,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
primary_message,
secondary_message);
- if (negbutton != NULL) {
- button = gtk_button_new_from_stock (negbutton);
- gtk_dialog_add_action_widget (GTK_DIALOG (req), button, GTK_RESPONSE_NO);
- GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
- gtk_widget_show (button);
- }
-
- if (has_cancel == TRUE) {
- button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
- gtk_dialog_add_action_widget (GTK_DIALOG (req), button, GTK_RESPONSE_CANCEL);
- GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
- gtk_widget_show (button);
- }
-
- if (posbutton != NULL) {
- button = gtk_button_new_from_stock (posbutton);
- gtk_dialog_add_action_widget (GTK_DIALOG (req), button, GTK_RESPONSE_YES);
- GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
- gtk_widget_show (button);
- }
-
- if (posbutton != NULL)
- gtk_dialog_set_default_response (GTK_DIALOG (req), GTK_RESPONSE_YES);
- else if (negbutton != NULL)
- gtk_dialog_set_default_response (GTK_DIALOG (req), GTK_RESPONSE_NO);
- else if (has_cancel)
- gtk_dialog_set_default_response (GTK_DIALOG (req), GTK_RESPONSE_CANCEL);
-
- gdm_wm_center_window (GTK_WINDOW (req));
-
- gdm_wm_no_login_focus_push ();
- ret = gtk_dialog_run (GTK_DIALOG (req));
- gdm_wm_no_login_focus_pop ();
- gtk_widget_destroy (req);
-
- return ret;
+ if (negbutton != NULL) {
+ button = gtk_button_new_from_stock (negbutton);
+ gtk_dialog_add_action_widget (GTK_DIALOG (req), button, GTK_RESPONSE_NO);
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ gtk_widget_show (button);
+ }
+
+ if (has_cancel == TRUE) {
+ button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
+ gtk_dialog_add_action_widget (GTK_DIALOG (req), button, GTK_RESPONSE_CANCEL);
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ gtk_widget_show (button);
+ }
+
+ if (posbutton != NULL) {
+ button = gtk_button_new_from_stock (posbutton);
+ gtk_dialog_add_action_widget (GTK_DIALOG (req), button, GTK_RESPONSE_YES);
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ gtk_widget_show (button);
+ }
+
+ if (posbutton != NULL)
+ gtk_dialog_set_default_response (GTK_DIALOG (req), GTK_RESPONSE_YES);
+ else if (negbutton != NULL)
+ gtk_dialog_set_default_response (GTK_DIALOG (req), GTK_RESPONSE_NO);
+ else if (has_cancel)
+ gtk_dialog_set_default_response (GTK_DIALOG (req), GTK_RESPONSE_CANCEL);
+
+ gdm_wm_center_window (GTK_WINDOW (req));
+
+ gdm_wm_no_login_focus_push ();
+ ret = gtk_dialog_run (GTK_DIALOG (req));
+ gdm_wm_no_login_focus_pop ();
+ gtk_widget_destroy (req);
+
+ return ret;
}
gint
@@ -1700,56 +1700,56 @@ gdm_wm_warn_dialog (const gchar *primary_message,
const char *negbutton,
gboolean has_cancel)
{
- int ret;
- GtkWidget *req;
- GtkWidget *button;
+ int ret;
+ GtkWidget *req;
+ GtkWidget *button;
- /* we should be now fine for focusing new windows */
- gdm_wm_focus_new_windows (TRUE);
+ /* we should be now fine for focusing new windows */
+ gdm_wm_focus_new_windows (TRUE);
- req = hig_dialog_new (NULL /* parent */,
+ req = hig_dialog_new (NULL /* parent */,
GTK_DIALOG_MODAL /* flags */,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_NONE,
primary_message,
secondary_message);
- if (negbutton != NULL) {
- button = gtk_button_new_from_stock (negbutton);
- gtk_dialog_add_action_widget (GTK_DIALOG (req), button, GTK_RESPONSE_NO);
- GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
- gtk_widget_show (button);
- }
-
- if (has_cancel == TRUE) {
- button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
- gtk_dialog_add_action_widget (GTK_DIALOG (req), button, GTK_RESPONSE_CANCEL);
- GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
- gtk_widget_show (button);
- }
-
- if (posbutton != NULL) {
- button = gtk_button_new_from_stock (posbutton);
- gtk_dialog_add_action_widget (GTK_DIALOG (req), button, GTK_RESPONSE_YES);
- GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
- gtk_widget_show (button);
- }
-
- if (posbutton != NULL)
- gtk_dialog_set_default_response (GTK_DIALOG (req), GTK_RESPONSE_YES);
- else if (negbutton != NULL)
- gtk_dialog_set_default_response (GTK_DIALOG (req), GTK_RESPONSE_NO);
- else if (has_cancel)
- gtk_dialog_set_default_response (GTK_DIALOG (req), GTK_RESPONSE_CANCEL);
-
- gdm_wm_center_window (GTK_WINDOW (req));
-
- gdm_wm_no_login_focus_push ();
- ret = gtk_dialog_run (GTK_DIALOG (req));
- gdm_wm_no_login_focus_pop ();
- gtk_widget_destroy (req);
-
- return ret;
+ if (negbutton != NULL) {
+ button = gtk_button_new_from_stock (negbutton);
+ gtk_dialog_add_action_widget (GTK_DIALOG (req), button, GTK_RESPONSE_NO);
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ gtk_widget_show (button);
+ }
+
+ if (has_cancel == TRUE) {
+ button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
+ gtk_dialog_add_action_widget (GTK_DIALOG (req), button, GTK_RESPONSE_CANCEL);
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ gtk_widget_show (button);
+ }
+
+ if (posbutton != NULL) {
+ button = gtk_button_new_from_stock (posbutton);
+ gtk_dialog_add_action_widget (GTK_DIALOG (req), button, GTK_RESPONSE_YES);
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ gtk_widget_show (button);
+ }
+
+ if (posbutton != NULL)
+ gtk_dialog_set_default_response (GTK_DIALOG (req), GTK_RESPONSE_YES);
+ else if (negbutton != NULL)
+ gtk_dialog_set_default_response (GTK_DIALOG (req), GTK_RESPONSE_NO);
+ else if (has_cancel)
+ gtk_dialog_set_default_response (GTK_DIALOG (req), GTK_RESPONSE_CANCEL);
+
+ gdm_wm_center_window (GTK_WINDOW (req));
+
+ gdm_wm_no_login_focus_push ();
+ ret = gtk_dialog_run (GTK_DIALOG (req));
+ gdm_wm_no_login_focus_pop ();
+ gtk_widget_destroy (req);
+
+ return ret;
}
/* EOF */
diff --git a/libgreeter/gdmwm.h b/libgreeter/gdmwm.h
index 14390f8b..6a3e7a08 100644
--- a/libgreeter/gdmwm.h
+++ b/libgreeter/gdmwm.h
@@ -30,39 +30,39 @@
* Login window will be given focus every time a window
* is killed
*/
-void gdm_wm_init (Window login_window);
+void gdm_wm_init (Window login_window);
/*
* By default new windows aren't given focus, you have to
* call this function with a TRUE
*/
-void gdm_wm_focus_new_windows (gboolean focus);
+void gdm_wm_focus_new_windows (gboolean focus);
-void gdm_wm_focus_window (Window window);
+void gdm_wm_focus_window (Window window);
/* Movement for the impatient */
-void gdm_wm_move_window_now (Window window,
- int x,
- int y);
-void gdm_wm_get_window_pos (Window window,
- int *xp,
- int *yp);
+void gdm_wm_move_window_now (Window window,
+ int x,
+ int y);
+void gdm_wm_get_window_pos (Window window,
+ int *xp,
+ int *yp);
/* Refuse to focus the login window, poor mans modal dialogs */
-void gdm_wm_no_login_focus_push (void);
-void gdm_wm_no_login_focus_pop (void);
+void gdm_wm_no_login_focus_push (void);
+void gdm_wm_no_login_focus_pop (void);
/*
* Xinerama support stuff
*/
-void gdm_wm_screen_init (int cur_screen_num);
-void gdm_wm_set_screen (int cur_screen_num);
+void gdm_wm_screen_init (int cur_screen_num);
+void gdm_wm_set_screen (int cur_screen_num);
/*
* Not really a WM function, center a gtk window on current screen
* by setting uposition
*/
-void gdm_wm_center_window (GtkWindow *cw);
+void gdm_wm_center_window (GtkWindow *cw);
/* Center mouse pointer
*/
@@ -72,8 +72,8 @@ void gdm_wm_center_cursor (void);
* Save and restore stacking order, useful for restarting
* the greeter
*/
-void gdm_wm_save_wm_order (void);
-void gdm_wm_restore_wm_order (void);
+void gdm_wm_save_wm_order (void);
+void gdm_wm_restore_wm_order (void);
/* Dialogs */
gint gdm_wm_query_dialog (const gchar *primary_message,