diff options
author | George Lebl <jirka@5z.com> | 2002-04-22 05:45:33 +0000 |
---|---|---|
committer | George Lebl <jirka@src.gnome.org> | 2002-04-22 05:45:33 +0000 |
commit | d44c8b75cd69ff7479985c2734088635d6f633ca (patch) | |
tree | e2efbae0c42d2ec580477872e87111d68ffbf688 /daemon | |
parent | 2fc1cf08f13efda94f1fecfafec882116995c961 (diff) | |
download | gdm-d44c8b75cd69ff7479985c2734088635d6f633ca.tar.gz |
add a printf style function
Sun Apr 21 22:50:49 2002 George Lebl <jirka@5z.com>
* daemon/gdm-net.[ch]: add a printf style function
* daemon/gdm.[ch], daemon/xdmcp.c: add functionality for 1) getting
a list of greeter pids for use with the setup proggie 2) implement
auto updating of most of the xdmcp stuff
* gui/gdmchooser.(c|glade), gui/Makefile.am: minor fixes, use a glade2
instead of converting.
* gui/gdmlogin.c: doh kind of warning fixes
* gui/gdmsetup.c, gui/Makefile.am: add a beginning of a setup
proggie, doesn't yet doo much, but it's a start
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/gdm-net.c | 18 | ||||
-rw-r--r-- | daemon/gdm-net.h | 3 | ||||
-rw-r--r-- | daemon/gdm.c | 67 | ||||
-rw-r--r-- | daemon/gdm.h | 20 | ||||
-rw-r--r-- | daemon/misc.c | 16 | ||||
-rw-r--r-- | daemon/xdmcp.c | 20 |
6 files changed, 117 insertions, 27 deletions
diff --git a/daemon/gdm-net.c b/daemon/gdm-net.c index ab2845af..d74e0252 100644 --- a/daemon/gdm-net.c +++ b/daemon/gdm-net.c @@ -475,4 +475,22 @@ gdm_connection_set_close_notify (GdmConnection *conn, conn->close_notify = close_notify; } +gboolean +gdm_connection_printf (GdmConnection *conn, const gchar *format, ...) +{ + va_list args; + gboolean ret; + gchar *s; + + va_start (args, format); + s = g_strdup_vprintf (format, args); + va_end (args); + + ret = gdm_connection_write (conn, s); + + g_free (s); + + return ret; +} + /* EOF */ diff --git a/daemon/gdm-net.h b/daemon/gdm-net.h index 41d610d8..d1577d41 100644 --- a/daemon/gdm-net.h +++ b/daemon/gdm-net.h @@ -34,6 +34,9 @@ typedef void (* GdmConnectionHandler) (GdmConnection *conn, gboolean gdm_connection_is_writable (GdmConnection *conn); gboolean gdm_connection_write (GdmConnection *conn, const char *str); +gboolean gdm_connection_printf (GdmConnection *conn, + const gchar *format, ...) + G_GNUC_PRINTF (2, 3); GdmConnection * gdm_connection_open_unix (const char *sockname, mode_t mode); diff --git a/daemon/gdm.c b/daemon/gdm.c index d8c1f20c..0b81da97 100644 --- a/daemon/gdm.c +++ b/daemon/gdm.c @@ -2255,6 +2255,40 @@ update_config (const char *key) notify_displays_string (GDM_NOTIFY_REMOTEGREETER, val); goto update_config_ok; + } else if (is_key (key, GDM_KEY_XDMCP)) { + gboolean val = gnome_config_get_bool (GDM_KEY_XDMCP); + if (ve_bool_equal (val, GdmXdmcp)) + goto update_config_ok; + GdmXdmcp = val; + + if (GdmXdmcp) { + if (gdm_xdmcp_init ()) + gdm_xdmcp_run (); + } else { + gdm_xdmcp_close (); + } + + goto update_config_ok; + } else if (is_key (key, "xdmcp/PARAMETERS")) { + GdmDispPerHost = gnome_config_get_int (GDM_KEY_DISPERHOST); + GdmMaxPending = gnome_config_get_int (GDM_KEY_MAXPEND); + GdmMaxManageWait = gnome_config_get_int (GDM_KEY_MAXWAIT); + GdmMaxSessions = gnome_config_get_int (GDM_KEY_MAXSESS); + GdmIndirect = gnome_config_get_bool (GDM_KEY_INDIRECT); + GdmMaxIndirect = gnome_config_get_int (GDM_KEY_MAXINDIR); + GdmMaxIndirectWait = gnome_config_get_int (GDM_KEY_MAXINDWAIT); + GdmPingInterval = gnome_config_get_int (GDM_KEY_PINGINTERVAL); + } else if (is_key (key, GDM_KEY_UDPPORT)) { + int val = gnome_config_get_int (GDM_KEY_UDPPORT); + if (GdmPort == val) + goto update_config_ok; + GdmPort = val; + + if (GdmXdmcp) { + gdm_xdmcp_close (); + if (gdm_xdmcp_init ()) + gdm_xdmcp_run (); + } } gnome_config_pop_prefix (); @@ -2395,31 +2429,38 @@ gdm_handle_user_message (GdmConnection *conn, const char *msg, gpointer data) GdmDisplay *disp = li->data; if ( ! disp->console) continue; - gdm_connection_write (conn, sep); + gdm_connection_printf (conn, + "%s%s,%s,", + sep, + ve_sure_string (disp->name), + ve_sure_string (disp->login)); sep = ";"; - gdm_connection_write (conn, - ve_sure_string (disp->name)); - gdm_connection_write (conn, ","); - gdm_connection_write (conn, - ve_sure_string (disp->login)); - gdm_connection_write (conn, ","); if (disp->type == TYPE_FLEXI_XNEST) { gdm_connection_write (conn, ve_sure_string (disp->xnest_disp)); } else { - char *vt = g_strdup_printf ("%d", + gdm_connection_printf (conn, "%d", #ifdef __linux__ - disp->vt + disp->vt #else - -1 + -1 #endif - ); - gdm_connection_write (conn, vt); - g_free (vt); + ); } } gdm_connection_write (conn, "\n"); + } else if (strcmp (msg, GDM_SUP_GREETERPIDS) == 0) { + GSList *li; + const char *sep = " "; + gdm_connection_write (conn, "OK"); + for (li = displays; li != NULL; li = li->next) { + GdmDisplay *disp = li->data; + gdm_connection_printf (conn, "%s%ld", + sep, (long)disp->greetpid); + sep = ";"; + } + gdm_connection_write (conn, "\n"); } else if (strncmp (msg, GDM_SUP_UPDATE_CONFIG " ", strlen (GDM_SUP_UPDATE_CONFIG " ")) == 0) { const char *key = diff --git a/daemon/gdm.h b/daemon/gdm.h index 9d508aa1..89c554dc 100644 --- a/daemon/gdm.h +++ b/daemon/gdm.h @@ -535,6 +535,18 @@ GdmXServer * gdm_find_x_server (const char *id); * security/AllowRemoteAutoLogin (2.3.90.2) * security/RetryDelay (2.3.90.2) * daemon/Greeter (2.3.90.2) + * daemon/RemoteGreeter (2.3.90.2) + * xdmcp/Enable (2.3.90.2) + * xdmcp/Port (2.3.90.2) + * xdmcp/PARAMETERS (2.3.90.2) (pseudokey, all the parameters) + * xdmcp/MaxPending + * xdmcp/MaxSessions + * xdmcp/MaxWait + * xdmcp/DisplaysPerHost + * xdmcp/HonorIndirect + * xdmcp/MaxPendingIndirect + * xdmcp/MaxWaitIndirect + * xdmcp/PingInterval (only affects new connections) * Supported since: 2.3.90.2 * Arguments: <key> * <key> is just the base part of the key such as "security/AllowRemoteRoot" @@ -545,6 +557,14 @@ GdmXServer * gdm_find_x_server (const char *id); * 50 = Unsupported key * 999 = Unknown error */ +#define GDM_SUP_GREETERPIDS "GREETERPIDS" /* None */ +/* GREETERPIDS: List all greeter pids so that one can send HUP to them + * for config rereading. Of course one must be root to do that. + * Supported since: 2.3.90.2 + * Arguments: None + * Answers: + * OK <pid>;<pid>;... + */ #define GDM_SUP_CLOSE "CLOSE" /* no arguments */ /* CLOSE Answers: None * Supported since: 2.2.4.0 diff --git a/daemon/misc.c b/daemon/misc.c index 5df76f2e..88abce31 100644 --- a/daemon/misc.c +++ b/daemon/misc.c @@ -167,16 +167,16 @@ gdm_debug (const gchar *format, ...) void gdm_fdprintf (int fd, const gchar *format, ...) { - va_list args; - gchar *s; + va_list args; + gchar *s; - 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); - write (fd, s, strlen (s)); - - g_free (s); + write (fd, s, strlen (s)); + + g_free (s); } /* clear environment, but keep the i18n ones, diff --git a/daemon/xdmcp.c b/daemon/xdmcp.c index bf2886cd..aca5e262 100644 --- a/daemon/xdmcp.c +++ b/daemon/xdmcp.c @@ -111,6 +111,7 @@ static gint globsessid; static gchar *sysid; static ARRAY8 servhost; static XdmcpBuffer buf; +static gboolean initted = FALSE; extern GSList *displays; extern gint sessions; @@ -231,6 +232,9 @@ gdm_xdmcp_init (void) struct sockaddr_in serv_sa = {0}; gchar hostbuf[256]; struct utsname name; + + if ( ! GdmXdmcp) + return TRUE; globsessid = time (NULL); @@ -240,14 +244,18 @@ gdm_xdmcp_init (void) GdmXdmcp = FALSE; return FALSE; } - - uname (&name); - sysid = g_strconcat (name.sysname, " ", name.release, NULL); - servhost.data = g_strdup (hostbuf); - servhost.length = strlen (servhost.data); + if ( ! initted) { + uname (&name); + sysid = g_strconcat (name.sysname, " ", name.release, NULL); + + servhost.data = g_strdup (hostbuf); + servhost.length = strlen (servhost.data); + + initted = TRUE; + } - gdm_debug ("Start up on host %s, port %d", hostbuf, GdmPort); + gdm_debug ("XDMCP: Start up on host %s, port %d", hostbuf, GdmPort); /* Open socket for communications */ gdm_xdmcpfd = socket (AF_INET, SOCK_DGRAM, 0); /* UDP */ |