Commit 864af89d authored by Brian Cameron's avatar Brian Cameron Committed by Brian Cameron

Add GET_SERVER_LIST and GET_SERVER_DETAILS sockets functions so that

2005-12-12  Brian Cameron  <brian.cameron@sun.com>

        * daemon/gdm.[ch], daemongdmconfig.[ch]: Add
          GET_SERVER_LIST and GET_SERVER_DETAILS
          sockets functions so that gdmflexiserver and
          gdmconfig do not need to access the config
          file for these, instead using the sockets
          protocol.
        * docs/C/gdm.xml: Add docs for new sockets
          commands.
        * configure.ac, gui/Makefile.am: Remove some
          libgnome/libgnomeui dependencies.
        * gui/gdmcomm.c: Now close sockets connection
          after 20 messages since the daemon gets mad
          if you send more.
        * gui/gdmconfig.[ch]: New client functions for
          getting server information via sockets.
        * gui/gdmflexiserver.c: Remove libgnome
          dependencies and now use new config
          mechanism for getting server info.
        * gui/gdmsetup.c: Now use new config
          mechanism for reading from config file and
          remove libgnome dependencies.  Cleaned up
          the code a bit.  Now we don't call
          ve_config_get all over the place, which
          seems to speed up the start time.
parent bfc60f6c
2005-12-12 Brian Cameron <brian.cameron@sun.com>
* daemon/gdm.[ch], daemongdmconfig.[ch]: Add
GET_SERVER_LIST and GET_SERVER_DETAILS
sockets functions so that gdmflexiserver and
gdmconfig do not need to access the config
file for these, instead using the sockets
protocol.
* docs/C/gdm.xml: Add docs for new sockets
commands.
* configure.ac, gui/Makefile.am: Remove some
libgnome/libgnomeui dependencies.
* gui/gdmcomm.c: Now close sockets connection
after 20 messages since the daemon gets mad
if you send more.
* gui/gdmconfig.[ch]: New client functions for
getting server information via sockets.
* gui/gdmflexiserver.c: Remove libgnome
dependencies and now use new config
mechanism for getting server info.
* gui/gdmsetup.c: Now use new config
mechanism for reading from config file and
remove libgnome dependencies. Cleaned up
the code a bit. Now we don't call
ve_config_get all over the place, which
seems to speed up the start time.
2005-12-12 Brian Cameron <brian.cameron@sun.com>
* Release 2.13.0.3:
......
......@@ -148,7 +148,7 @@ PKG_CHECK_MODULES(DAEMON, gtk+-2.0 >= $GTK_REQUIRED)
AC_SUBST(DAEMON_CFLAGS)
AC_SUBST(DAEMON_LIBS)
PKG_CHECK_MODULES(GUI, gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED libglade-2.0 >= $LIBGLADE_REQUIRED)
PKG_CHECK_MODULES(GUI, gtk+-2.0 >= $GTK_REQUIRED libglade-2.0 >= $LIBGLADE_REQUIRED)
AC_SUBST(GUI_CFLAGS)
AC_SUBST(GUI_LIBS)
......@@ -164,7 +164,7 @@ PKG_CHECK_MODULES(GREETER, gtk+-2.0 >= $GTK_REQUIRED libgnomecanvas-2.0 >= $LIBG
AC_SUBST(GREETER_CFLAGS)
AC_SUBST(GREETER_LIBS)
PKG_CHECK_MODULES(UTILS, gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED libglade-2.0 >= $LIBGLADE_REQUIRED)
PKG_CHECK_MODULES(UTILS, gtk+-2.0 >= $GTK_REQUIRED libglade-2.0 >= $LIBGLADE_REQUIRED)
AC_SUBST(UTILS_CFLAGS)
AC_SUBST(UTILS_LIBS)
......
......@@ -2802,7 +2802,7 @@ gdm_handle_user_message (GdmConnection *conn, const char *msg, gpointer data)
{
gdm_debug ("Handling user message: '%s'", msg);
if (gdm_connection_get_message_count (conn) > 20) {
if (gdm_connection_get_message_count (conn) > GDM_SUP_MAX_CONNECTIONS) {
gdm_connection_write (conn, "ERROR 200 Too many messages\n");
gdm_connection_close (conn);
return;
......@@ -3005,7 +3005,6 @@ gdm_handle_user_message (GdmConnection *conn, const char *msg, gpointer data)
g_string_append (msg, "\n");
gdm_connection_write (conn, msg->str);
g_string_free (msg, TRUE);
/*
} else if (strcmp (msg, GDM_SUP_GET_SERVER_LIST) == 0) {
gchar *retval = gdm_get_x_servers ();
......@@ -3019,15 +3018,46 @@ gdm_handle_user_message (GdmConnection *conn, const char *msg, gpointer data)
} else if (strncmp (msg, GDM_SUP_GET_SERVER_DETAILS " ",
strlen (GDM_SUP_GET_SERVER_DETAILS " ")) == 0) {
const char *server = &msg[strlen (GDM_SUP_GET_SERVER_DETAILS " ")];
gchar *retval = gdm_get_x_server_details (server);
if (retval != NULL) {
gdm_connection_printf (conn, "OK %s\n", retval);
g_free (retval);
gchar **splitstr = g_strsplit (server, " ", 2);
GdmXserver *svr = gdm_find_x_server ((char *)splitstr[0]);
if (svr != NULL) {
if (g_strncasecmp (splitstr[1], "NAME", 4) == 0)
gdm_connection_printf (conn, "OK %s\n", svr->name);
else if (g_strncasecmp (splitstr[1], "COMMAND", 7) == 0)
gdm_connection_printf (conn, "OK %s\n", svr->command);
else if (g_strncasecmp (splitstr[1], "FLEXIBLE", 8) == 0 &&
svr->flexible)
gdm_connection_printf (conn, "OK true\n");
else if (g_strncasecmp (splitstr[1], "FLEXIBLE", 8) == 0 &&
!svr->flexible)
gdm_connection_printf (conn, "OK FALSE\n");
else if (g_strncasecmp (splitstr[1], "CHOOSABLE", 9) == 0 &&
svr->choosable)
gdm_connection_printf (conn, "OK true\n");
else if (g_strncasecmp (splitstr[1], "CHOOSABLE", 9) == 0 &&
!svr->choosable)
gdm_connection_printf (conn, "OK FALSE\n");
else if (g_strncasecmp (splitstr[1], "HANDLED", 7) == 0 &&
svr->handled)
gdm_connection_printf (conn, "OK true\n");
else if (g_strncasecmp (splitstr[1], "HANDLED", 7) == 0 &&
!svr->handled)
gdm_connection_printf (conn, "OK FALSE\n");
else if (g_strncasecmp (splitstr[1], "CHOOSER", 7) == 0 &&
svr->chooser)
gdm_connection_printf (conn, "OK true\n");
else if (g_strncasecmp (splitstr[1], "CHOOSER", 7) == 0 &&
!svr->chooser)
gdm_connection_printf (conn, "OK FALSE\n");
else
gdm_connection_printf (conn, "ERROR 2 Key not valid\n");
g_strfreev (splitstr);
} else {
gdm_connection_printf (conn, "ERROR 1 Server not found\n");
}
*/
} else if (strcmp (msg, GDM_SUP_GREETERPIDS) == 0) {
GString *msg;
GSList *li;
......@@ -3278,39 +3308,33 @@ gdm_handle_user_message (GdmConnection *conn, const char *msg, gpointer data)
#else
gdm_connection_write (conn, "ERROR 8 Virtual terminals not supported\n");
#endif
} else if (strncmp (msg, GDM_SUP_ADD_DYNAMIC_DISPLAY " ",
strlen (GDM_SUP_ADD_DYNAMIC_DISPLAY " ")) == 0) {
char *key;
key = g_strdup (&msg[strlen (GDM_SUP_ADD_DYNAMIC_DISPLAY " ")]);
g_strstrip (key);
handle_dynamic_server (conn, DYNAMIC_ADD, key);
g_free (key);
} else if (strncmp (msg, GDM_SUP_ADD_DYNAMIC_DISPLAY " ",
strlen (GDM_SUP_ADD_DYNAMIC_DISPLAY " ")) == 0) {
char *key;
} else if (strncmp (msg, GDM_SUP_REMOVE_DYNAMIC_DISPLAY " ",
strlen (GDM_SUP_REMOVE_DYNAMIC_DISPLAY " ")) == 0) {
char *key;
key = g_strdup (&msg[strlen (GDM_SUP_REMOVE_DYNAMIC_DISPLAY " ")]);
g_strstrip (key);
handle_dynamic_server (conn, DYNAMIC_REMOVE, key);
g_free (key);
key = g_strdup (&msg[strlen (GDM_SUP_ADD_DYNAMIC_DISPLAY " ")]);
g_strstrip (key);
handle_dynamic_server (conn, DYNAMIC_ADD, key);
g_free (key);
} else if (strncmp (msg, GDM_SUP_RELEASE_DYNAMIC_DISPLAYS " ",
strlen (GDM_SUP_RELEASE_DYNAMIC_DISPLAYS " ")) == 0) {
} else if (strncmp (msg, GDM_SUP_REMOVE_DYNAMIC_DISPLAY " ",
strlen (GDM_SUP_REMOVE_DYNAMIC_DISPLAY " ")) == 0) {
char *key;
char *key;
key = g_strdup (&msg[strlen (GDM_SUP_REMOVE_DYNAMIC_DISPLAY " ")]);
g_strstrip (key);
handle_dynamic_server (conn, DYNAMIC_REMOVE, key);
g_free (key);
key = g_strdup (&msg[strlen (GDM_SUP_RELEASE_DYNAMIC_DISPLAYS " ")]);
g_strstrip (key);
} else if (strncmp (msg, GDM_SUP_RELEASE_DYNAMIC_DISPLAYS " ",
strlen (GDM_SUP_RELEASE_DYNAMIC_DISPLAYS " ")) == 0) {
handle_dynamic_server (conn, DYNAMIC_RELEASE, key);
char *key;
g_free (key);
key = g_strdup (&msg[strlen (GDM_SUP_RELEASE_DYNAMIC_DISPLAYS " ")]);
g_strstrip (key);
handle_dynamic_server (conn, DYNAMIC_RELEASE, key);
g_free (key);
} else if (strcmp (msg, GDM_SUP_VERSION) == 0) {
gdm_connection_write (conn, "GDM " VERSION "\n");
......
......@@ -712,6 +712,11 @@ void gdm_final_cleanup (void);
/* notify a command */
#define GDM_SLAVE_NOTIFY_COMMAND '#'
/*
* Maximum number of connections allowed at once. Might be useful to
* try and tune this. GDM would be faster if the value is larger.
*/
#define GDM_SUP_MAX_CONNECTIONS 20
#define GDM_SUP_SOCKET "/tmp/.gdm_socket"
/*
......@@ -839,7 +844,7 @@ void gdm_final_cleanup (void);
* 999 = Unknown error
*/
#define GDM_SUP_ALL_SERVERS "ALL_SERVERS" /* None */
/* ALL_SERVERS: List all servers, including attached, remote, xnest. This
/* ALL_SERVERS: List all displays, including attached, remote, xnest. This
* Can for example be useful to figure out if the server you are on is managed
* by the gdm daemon, by seeing if it is in the list. It is also somewhat
* like the 'w' command but for graphical sessions.
......@@ -857,6 +862,41 @@ void gdm_final_cleanup (void);
* 200 = Too many messages
* 999 = Unknown error
*/
#define GDM_SUP_GET_SERVER_LIST "GET_SERVER_LIST" /* None */
/* GET_SERVER_LIST: Get a list of the server sections from
* the configuration file.
* Supported since: 2.13.0.4
* Arguments: None
* Answers:
* OK <value>;<value>;...
* ERROR <err number> <english error description>
* 0 = Not implemented
* 1 = No servers found
* 50 = Unsupported key
* 200 = Too many messages
* 999 = Unknown error
*/
#define GDM_SUP_GET_SERVER_DETAILS "GET_SERVER_DETAILS" /* <server> <key> */
/* GET_SERVER_DETAILS: Get detail information for a specific
* server. Key values include:
* NAME - Returns the server name
* COMMAND - Returns the server command
* FLEXIBLE - Returns "true" if flexible, "false" otherwise
* CHOOSABLE - Returns "true" if choosable, "false" otherwise
* HANDLED - Returns "true" if handled, "false" otherwise
* CHOOSER - Returns "true" if chooser, "false" otherwise
* Supported since: 2.13.0.4
* Arguments: <server> <key>
* Answers:
* OK <value>
* ERROR <err number> <english error description>
* 0 = Not implemented
* 1 = Server not found
* 2 = Key not valid
* 50 = Unsupported key
* 200 = Too many messages
* 999 = Unknown error
*/
#define GDM_SUP_GET_CONFIG "GET_CONFIG" /* <key> */
/* GET_CONFIG: Get configuration value for key. Useful so
* that other programs can request configuration information
......
......@@ -1321,41 +1321,6 @@ gdm_get_x_servers (void)
return retval;
}
gchar *
gdm_get_x_server_details (gchar *id)
{
GdmXserver *svr = gdm_find_x_server (id);
gchar *retval;
if (svr == NULL)
return NULL;
retval = g_strdup (svr->name);
retval = g_strconcat (retval, ";", svr->command, NULL);
if (svr->flexible)
retval = g_strconcat (retval, ";true", NULL);
else
retval = g_strconcat (retval, ";false", NULL);
if (svr->choosable)
retval = g_strconcat (retval, ";true", NULL);
else
retval = g_strconcat (retval, ";false", NULL);
if (svr->handled)
retval = g_strconcat (retval, ";true", NULL);
else
retval = g_strconcat (retval, ";false", NULL);
if (svr->chooser)
retval = g_strconcat (retval, ";true", NULL);
else
retval = g_strconcat (retval, ";false", NULL);
return retval;
}
/**
* gdm_load_config_option
*
......
......@@ -39,7 +39,6 @@ void gdm_config_init (void);
void gdm_config_parse (void);
GdmXserver* gdm_find_x_server (const gchar *id);
gchar* gdm_get_x_servers (void);
gchar* gdm_get_x_server_details (gchar *id);
int gdm_compare_displays (gconstpointer a,
gconstpointer b);
uid_t gdm_get_gdmuid (void);
......
......@@ -3603,6 +3603,8 @@ FLEXI_XSERVER
FLEXI_XNEST
ATTACHED_SERVERS
ALL_SERVERS
GET_SERVER_LIST
GET_SERVER_DETAILS
GET_CONFIG
GET_CONFIG_FILE
UPDATE_CONFIG
......@@ -3814,7 +3816,7 @@ Answers:
<sect3 id="allservers">
<title>ALL_SERVERS</title>
<screen>
ALL_SERVERS: List all servers, including console, remote, xnest.
ALL_SERVERS: List all displays, including console, remote, xnest.
This can, for example, be useful to figure out if
the server you are on is managed by the gdm daemon,
by seeing if it is in the list. It is also somewhat
......@@ -3835,6 +3837,49 @@ Answers:
</screen>
</sect3>
<sect3 id="getserverlist">
<title>GET_SERVER_LIST</title>
<screen>
GET_SERVER_LIST: Get a list of the server sections from
the configuration file.
Supported since: 2.13.0.4
Arguments: None
Answers:
OK &lt;value&gt;;&lt;value&gt;;...
ERROR &lt;err number&gt; &lt;english error description&gt;
0 = Not implemented
1 = No servers found
50 = Unsupported key
200 = Too many messages
999 = Unknown error
</screen>
</sect3>
<sect3 id="getserverdetails">
<title>GET_SERVER_DETAILS</title>
<screen>
GET_SERVER_DETAILS: Get detail information for a specific
server. Key values include:
NAME - Returns the server name
COMMAND - Returns the server command
FLEXIBLE - Returns "true" if flexible, "false" otherwise
CHOOSABLE - Returns "true" if choosable, "false" otherwise
HANDLED - Returns "true" if handled, "false" otherwise
CHOOSER - Returns "true" if chooser, "false" otherwise
Supported since: 2.13.0.4
Arguments: &lt;server&gt; &lt;key&gt;
Answers:
OK &lt;value&gt;
ERROR &lt;err number&gt; &lt;english error description&gt;
0 = Not implemented
1 = Server not found
2 = Key not valid
50 = Unsupported key
200 = Too many messages
999 = Unknown error
</screen>
</sect3>
<sect3 id="getconfig">
<title>GET_CONFIG</title>
<screen>
......
This diff is collapsed.
......@@ -1765,6 +1765,8 @@ FLEXI_XSERVER
FLEXI_XNEST
ATTACHED_SERVERS
ALL_SERVERS
GET_SERVER_LIST
GET_SERVER_DETAILS
GET_CONFIG
GET_CONFIG_FILE
UPDATE_CONFIG
......@@ -1973,7 +1975,7 @@ Answers:
<sect3 id="allservers">
<title>ALL_SERVERS</title>
<screen>
ALL_SERVERS: List all servers, including console, remote, xnest.
ALL_SERVERS: List all displays, including console, remote, xnest.
This can, for example, be useful to figure out if
the server you are on is managed by the gdm daemon,
by seeing if it is in the list. It is also somewhat
......@@ -1994,6 +1996,49 @@ Answers:
</screen>
</sect3>
<sect3 id="getserverlist">
<title>GET_SERVER_LIST</title>
<screen>
GET_SERVER_LIST: Get a list of the server sections from
the configuration file.
Supported since: 2.13.0.4
Arguments: None
Answers:
OK &lt;value&gt;;&lt;value&gt;;...
ERROR &lt;err number&gt; &lt;english error description&gt;
0 = Not implemented
1 = No servers found
50 = Unsupported key
200 = Too many messages
999 = Unknown error
</screen>
</sect3>
<sect3 id="getserverdetails">
<title>GET_SERVER_DETAILS</title>
<screen>
GET_SERVER_DETAILS: Get detail information for a specific
server. Key values include:
NAME - Returns the server name
COMMAND - Returns the server command
FLEXIBLE - Returns "true" if flexible, "false" otherwise
CHOOSABLE - Returns "true" if choosable, "false" otherwise
HANDLED - Returns "true" if handled, "false" otherwise
CHOOSER - Returns "true" if chooser, "false" otherwise
Supported since: 2.13.0.4
Arguments: &lt;server&gt; &lt;key&gt;
Answers:
OK &lt;value&gt;
ERROR &lt;err number&gt; &lt;english error description&gt;
0 = Not implemented
1 = Server not found
2 = Key not valid
50 = Unsupported key
200 = Too many messages
999 = Unknown error
</screen>
</sect3>
<sect3 id="getconfig">
<title>GET_CONFIG</title>
<screen>
......
......@@ -85,6 +85,11 @@ gdmlogin_SOURCES = \
gdmsetup_SOURCES = \
gdmsetup.c
# Many GUI programs still require LIBGNOME because they need
# gnome_program_locate_file which is in the ve_find_file ()
# interface in vicious-extensions/ve-gnome.c. Fixing this
# function should remove libgnome as a GDM dependency.
#
gdmchooser_LDFLAGS = -export-dynamic
gdmchooser_LDADD = \
$(EXTRA_CHOOSER_LIBS) \
......@@ -119,10 +124,13 @@ gdmlogin_LDADD = \
$(GDK_LIBS) \
$(PANGO_LIBS) \
$(GDKPIXBUF_LIBS) \
$(LIBGNOME_LIBS) \
$(LIBGNOMEUI_LIBS) \
$(top_builddir)/vicious-extensions/libviciousui-minimal.a
# LIBGNOMEUI should be removed from gdmsetup at some point.
# It is needed because it uses gnome_help_display_uri(), which
# should be replaced at some point.
#
gdmsetup_CFLAGS = $(LIBGNOMEUI_CFLAGS)
gdmsetup_LDFLAGS = -export-dynamic
gdmsetup_LDADD = \
libgdmcommon.a \
......@@ -135,9 +143,8 @@ gdmsetup_LDADD = \
$(PANGO_LIBS) \
$(GDK_LIBS) \
$(GDKPIXBUF_LIBS) \
$(LIBGNOME_LIBS) \
$(LIBGNOMEUI_LIBS) \
$(EXTRA_SETUP_LIBS) \
$(LIBGNOMEUI_LIBS) \
$(top_builddir)/vicious-extensions/libviciousui-gnome.a
gdmphotosetup_LDADD = \
......@@ -148,9 +155,8 @@ gdmphotosetup_LDADD = \
$(GOBJECT_LIBS) \
$(GDK_LIBS) \
$(GDKPIXBUF_LIBS) \
$(LIBGNOME_LIBS) \
$(LIBGNOMEUI_LIBS) \
$(INTLLIBS) \
$(LIBGNOME_LIBS) \
$(top_builddir)/vicious-extensions/libviciousui-gnome.a
gdmXnestchooser_LDADD = \
......@@ -158,26 +164,26 @@ gdmXnestchooser_LDADD = \
$(GUI_LIBS) \
-lXau \
-lX11 \
-lpopt \
$(INTLLIBS) \
$(GLIB_LIBS) \
$(GOBJECT_LIBS) \
$(GDK_LIBS) \
$(LIBGNOME_LIBS) \
$(LIBGNOMEUI_LIBS) \
$(EXTRA_XNEST_LIBS) \
$(LIBGNOME_LIBS) \
$(top_builddir)/vicious-extensions/libviciousui-gnome.a
gdmflexiserver_LDADD = \
libgdmcommon.a \
$(GUI_LIBS) \
-lXau \
-lpopt \
$(INTLLIBS) \
$(GLIB_LIBS) \
$(GOBJECT_LIBS) \
$(GDK_LIBS) \
$(LIBGNOME_LIBS) \
$(LIBGNOMEUI_LIBS) \
$(EXTRA_FLEXI_LIBS) \
$(LIBGNOME_LIBS) \
$(top_builddir)/vicious-extensions/libviciousui-gnome.a
gdmdynamic_LDADD = \
......@@ -188,9 +194,8 @@ gdmdynamic_LDADD = \
$(GLIB_LIBS) \
$(GOBJECT_LIBS) \
$(GDK_LIBS) \
$(LIBGNOME_LIBS) \
$(LIBGNOMEUI_LIBS) \
$(EXTRA_DYNAMIC_LIBS) \
$(LIBGNOME_LIBS) \
$(top_builddir)/vicious-extensions/libviciousui-gnome.a
Settingsdir = $(datadir)/applications
......
......@@ -112,8 +112,18 @@ char *
gdmcomm_call_gdm (const char *command, const char * auth_cookie, const char *min_version, int tries)
{
static int fd = 0;
static int num_cmds = 0;
char *ret;
if (num_cmds == (GDM_SUP_MAX_CONNECTIONS - 1)) {
do_command (fd, GDM_SUP_CLOSE, FALSE);
VE_IGNORE_EINTR (close (fd));
fd = 0;
num_cmds = 0;
}
num_cmds++;
if (tries <= 0)
return NULL;
......@@ -148,9 +158,6 @@ gdmcomm_call_gdm (const char *command, const char * auth_cookie, const char *min
}
if ( ! version_ok_p (&ret[4], min_version)) {
g_free (ret);
/*
do_command (fd, GDM_SUP_CLOSE, FALSE);
*/
VE_IGNORE_EINTR (close (fd));
fd = 0;
return NULL;
......@@ -172,10 +179,6 @@ gdmcomm_call_gdm (const char *command, const char * auth_cookie, const char *min
}
/* not auth'ed */
if (strcmp (ret, "OK") != 0) {
/*
do_command (fd, GDM_SUP_CLOSE,
FALSE);
*/
VE_IGNORE_EINTR (close (fd));
fd = 0;
/* returns the error */
......@@ -191,10 +194,6 @@ gdmcomm_call_gdm (const char *command, const char * auth_cookie, const char *min
return gdmcomm_call_gdm (command, auth_cookie, min_version, tries - 1);
}
/*
do_command (fd, GDM_SUP_CLOSE, FALSE);
*/
return ret;
}
......
......@@ -116,10 +116,131 @@ gdm_config_get_result (gchar *key)
result = gdmcomm_call_gdm (command, NULL /* auth cookie */,
"2.13.0.1", 5);
g_free (command);
g_free (newkey);
return result;
}
/**
* gdm_config_get_xserver_details
*
* Calls daemon to get details for an xserver config.
*/
static gchar *
gdm_config_get_xserver_details (gchar *xserver, gchar *key)
{
gchar *command = NULL;
gchar *result = NULL;
gchar *temp;
command = g_strdup_printf ("GET_SERVER_DETAILS %s %s", xserver, key);
result = gdmcomm_call_gdm (command, NULL /* auth cookie */,
"2.13.0.1", 5);
g_free (command);
if (! result || ve_string_empty (result) ||
strncmp (result, "OK ", 3) != 0) {
if (using_syslog)
syslog (LOG_ERR, "Could not access xserver configuration");
else
printf ("Could not access xserver configuration");
if (result)
g_free (result);
return NULL;
}
/* skip the "OK " */
temp = g_strdup (result + 3);
g_free (result);
return temp;
}
/**
* gdm_config_get_xservers
*
* Calls daemon to get xserver config.
*/
GSList *
gdm_config_get_xservers (gboolean flexible)
{
GSList *xservers = NULL;
gchar *p;
gchar **splitstr, **sec;
gchar *command = NULL;
gchar *result = NULL;
gchar *temp;
gboolean tempbool;
command = g_strdup_printf ("GET_SERVER_LIST");
result = gdmcomm_call_gdm (command, NULL /* auth cookie */,
"2.13.0.1", 5);
g_free (command);
if (! result || ve_string_empty (result) ||
strncmp (result, "OK ", 3) != 0) {
if (using_syslog)
syslog (LOG_ERR, "Could not access xserver configuration");
else
printf ("Could not access xserver configuration");
if (result)
g_free (result);
return NULL;
}
/* skip the "OK " */
splitstr = g_strsplit (result + 3, ";", 0);
sec = splitstr;
g_free (result);
while (*sec != NULL) {
GdmXserver *svr = g_new0 (GdmXserver, 1);
svr->name = gdm_config_get_xserver_details (*sec, "NAME");
svr->id = g_strdup_printf ("server-%s", *sec);
svr->command = gdm_config_get_xserver_details (*sec, "COMMAND");
temp = gdm_config_get_xserver_details (*sec, "FLEXIBLE");
if (g_strncasecmp (temp, "true", 4) == 0)
svr->flexible = TRUE;
else
svr->flexible = FALSE;
temp = gdm_config_get_xserver_details (*sec, "CHOOSABLE");
if (g_strncasecmp (temp, "true", 4) == 0)
svr->choosable = TRUE;
else
svr->choosable = FALSE;
temp = gdm_config_get_xserver_details (*sec, "HANDLED");
if (g_strncasecmp (temp, "true", 4) == 0)
svr->handled = TRUE;
else
svr->handled = FALSE;
temp = gdm_config_get_xserver_details (*sec, "CHOOSER");
if (g_strncasecmp (temp, "true", 4) == 0)
svr->chooser = TRUE;
else
svr->chooser = FALSE;
sec++;
/* If only flexible was requested, then skip if not flexible */
if (flexible && !svr->flexible)
continue;
xservers = g_slist_append (xservers, svr);
}
g_strfreev (splitstr);
return xservers;
}
/**
* gdm_config_get_string
*
......
......@@ -43,5 +43,6 @@ void gdm_set_servauth (gchar *file,
gchar *id);
char * gdm_get_theme_greeter (gchar *file,
const char *fallback);
GSList * gdm_config_get_xservers (gboolean flexible);
#endif /* GDMCONFIG_H */
......@@ -25,6 +25,7 @@
#include <stdio.h>
#include <unistd.h>
#include <stdio.h>
#include <popt.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/socket.h>
......@@ -36,8 +37,6 @@
#include <glib/gi18n.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <libgnome/libgnome.h> /* for gnome_config */
#include <libgnomeui/libgnomeui.h> /* for gnome_program */
#include "gdm.h"
#include "gdmcomm.h"
......@@ -533,60 +532,19 @@ check_for_users (void)
static void
read_servers (gchar *config_file)
{
gpointer iter;
gchar *config_sections;
char *k;
/* Find server definitions */
config_sections = g_strdup_printf ("=%s=/", config_file);
iter = gnome_config_init_iterator_sections (config_sections);
iter = gnome_config_iterator_next (iter, &k, NULL);
while (iter) {
if (strncmp (k, "server-", strlen ("server-")) == 0) {
char *section;
GdmXserver *svr;
section = g_strdup_printf ("=%s=/%s/", config_file, k);
gnome_config_push_prefix (section);
if ( ! gnome_config_get_bool
(GDM_KEY_SERVER_FLEXIBLE)) {
gnome_config_pop_prefix ();
g_free (section);
g_free (k);
iter = gnome_config_iterator_next (iter,
&k, NULL);
continue;
}