Commit 2cfd51d2 authored by Brian Cameron's avatar Brian Cameron Committed by Brian Cameron

After two months, the redesign of GDM's internal configuration is finally

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

        After two months, the redesign of GDM's internal configuration is
        finally reaching a close.  Now GDM users are instructed to not modify
        the gdm.conf file directly and instead put any cutomizations in a
        separate file called gdm.conf-custom (read the comments in both files).
        gdmsetup now modifies the gdm.conf-custom file.  The GDM daemon will
        now use values in gdm.conf-custom first and the default values in
        gdm.conf if no value is defined in gdm.conf-custom.  Benefits:

        1) Now GDM truly supports system-wide and machine-specific config.
           System wide configuration is when the sysadmin wants to share the
           main gdm.conf file across multiple systems on a shared file system
           (possible by building GDM with the --with-configdir option or by
           running GDM with the --config option).  Specific systems can
           override defaults by modifying the gdm.conf-custom file.
        2) Distros can stomp the main gdm.conf file on upgrade knowing that any
           user changes are stored in a separate file.  For best backwards
           compatibility, distros will need to move the gdm.conf file to
           gdm.conf-custom if the gdm.conf file exists on the system but the
           gdm.conf-custom file does not.
        3) Making this work required a lot of cleanup in the way GDM manages
           its configuration files.  For example, now config options are
           managed via access functions, and do not depend on non-static
           globals being shared across files.  The GET_CONFIG and UPDATE_CONFIG
           commands work better and do not require special tweaking when adding
           new config options.  Vicious-extensions is now only included in a
           few files that need to know how to access the config files directly.

        This makes GDM support a popular feature in CDE which works similarly.
        (config files in /etc/dt/config take precidence over the ones in
        /usr/dt/config).

        * daemon/gdmconfig.[ch]: Now supports reading configuration values
          (including "servers" and "server-foo" sections from gdm.conf-custom
          and then from gdm.conf if not found in the custom file.  Now store
          translated strings in a separate hash since this improves
          performance.  Fix GET_SERVER_DETAILS so it works better and
          update config can now update server-foo sections via the
          "xservers/PARMAETERS" key.
        * gui/gdmsetup.c: Now only writes to the gdm.conf-custom file and isa
          smart enough to just delete the key if the value will be the same as
          in the gdm.conf file.  Fixed some core dumping issues caused by my
          change to make gdmsetup use the new gdmconfig functions for getting
          configuration data from the server.  This work cleaned up the code
          quite a bit.  Removed the "--config" option from gdmsetup since this
          change makes it edit the configuration of the running GDM daemon
          instead of a program that edits a particular configuration file.
        * daemon/gdm.h, doc/C/gdm.xml: Updated docs with info about how
          configuration works nwo.  Now sockets protocol info is the same
          in both documents.
        * daemon/gdm.c: Fix GET_SERVER_DETAILS to support "ID" and some
          cleanup.
        * gui/Makefile.am, daemon/Makefile.am: Support --with-configdir option
          which got broken.
        * config/gdm.conf.in: Updated comments to mention that this file is not
          to be edited. Cleaned up the file so it is more readible.
        * config/Makefile.am: Install gdm.conf-custom and move gdm.conf to
          gdm.conf-custom if it is modified and gdm.conf-custom is not already
          installed.  If it is changed and gdm.conf-custom already exists, move
          it to gdm.conf.org.
        * gui/gdmchooser.c, gui/gdmflexiserver.c: Remove unused getting of the
          configuration file.
        * gui/gdmconfig.[ch]: Add function to tell config to never_cache, which
          is needed by gdmsetup.
        * config/gdm.conf-custom: Added template file.
parent 2ec3b31c
......@@ -13,7 +13,7 @@ postdir = $(sysconfdir)/gdm/PostSession
predir = $(sysconfdir)/gdm/PreSession
postlogindir = $(sysconfdir)/gdm/PostLogin
noinst_DATA = gdm.conf
noinst_DATA = gdm.conf gdm.conf-custom
DESKTOP_FILES = default.desktop CDE.desktop gnome.desktop
......@@ -51,6 +51,7 @@ uninstall-hook:
$(DESTDIR)$(instsessdir)/default.desktop \
$(DESTDIR)$(instsessdir)/CDE.desktop \
$(DESTDIR)$(gdmconfdir)/gdm.conf \
$(DESTDIR)$(gdmconfdir)/gdm.conf-custom \
$(DESTDIR)$(gdmconfdir)/factory-gdm.conf \
$(DESTDIR)$(confdir)/XKeepsCrashing \
$(DESTDIR)$(confdir)/Xsession \
......@@ -73,13 +74,20 @@ install-data-hook: gdm.conf Xsession gnome.desktop default.desktop CDE.desktop I
$(mkinstalldirs) $(DESTDIR)$(gdmconfdir); \
chmod 755 $(DESTDIR)$(gdmconfdir); \
fi
-if cmp -s $(DESTDIR)$(gdmconfdir)/gdm.conf $(DESTDIR)$(gdmconfdir)/factory-gdm.conf > /dev/null 2>&1 ; then \
cp -f $(DESTDIR)$(gdmconfdir)/gdm.conf $(DESTDIR)$(gdmconfdir)/gdm.conf.orig; \
-if ! cmp -s $(DESTDIR)$(gdmconfdir)/gdm.conf $(DESTDIR)$(gdmconfdir)/factory-gdm.conf > /dev/null 2>&1 ; then \
if test '!' -f $(DESTDIR)$(gdmconfdir)/gdm.conf-custom; then \
cp -f $(DESTDIR)$(gdmconfdir)/gdm.conf $(DESTDIR)$(gdmconfdir)/gdm.conf-custom; \
else \
cp -f $(DESTDIR)$(gdmconfdir)/gdm.conf $(DESTDIR)$(gdmconfdir)/gdm.conf.org; \
fi; \
$(INSTALL_DATA) gdm.conf $(DESTDIR)$(gdmconfdir)/gdm.conf; \
fi
if test '!' -f $(DESTDIR)$(gdmconfdir)/gdm.conf; then \
$(INSTALL_DATA) gdm.conf $(DESTDIR)$(gdmconfdir)/gdm.conf; \
fi
if test '!' -f $(DESTDIR)$(gdmconfdir)/gdm.conf-custom; then \
$(INSTALL_DATA) gdm.conf-custom $(DESTDIR)$(gdmconfdir)/gdm.conf-custom; \
fi
$(INSTALL_DATA) gdm.conf $(DESTDIR)$(gdmconfdir)/factory-gdm.conf
$(INSTALL_SCRIPT) $(srcdir)/XKeepsCrashing $(DESTDIR)$(confdir)/XKeepsCrashing
......
# GDM Configuration Customization file.
#
# This file is the appropriate place for specifying your customizations to the
# GDM configuration. If you run gdmsetup, it will automatically edit this
# file for you and will cause the daemon and any running GDM GUI programs to
# automatically update with the new configuration. Not all configuration
# options are supported by gdmsetup, so to modify some values it may be
# necessary to modify this file directly by hand.
#
# To hand-edit this file, simply add or modify the key=value combination in
# the appropriate section in the template below. Refer to the comments in the
# gdm.conf file for information about each option. Also refer to the reference
# documentation.
#
# If you hand edit a GDM configuration file, you should run the following
# command to get the GDM daemon to notice the change. Any running GDM GUI
# programs will also be notified to update with the new configuration.
#
# gdmflexiserver --command="UPDATE_CONFIG <configuration key>"
#
# For example, the "Enable" key in the "[debug]" section would be specified by
# "debug/Enable".
#
# You can also run gdm-restart or gdm-safe-restart to cause GDM to restart and
# re-read the new configuration settings. You can also restart GDM by sending
# a HUP or USR1 signal to the daemon. HUP behaves like gdm-restart and causes
# any user session started by GDM to exit immediately while USR1 behaves like
# gdm-safe-restart and will wait until all users log out before restarting GDM.
#
# For full reference documentation see the gnome help browser under
# GNOME|System category. You can also find the docs in HTML form on
# http://www.gnome.org/projects/gdm/
#
# NOTE: Lines that begin with "#" are considered comments.
#
# Have fun!
[daemon]
[security]
[xdmcp]
[gui]
[greeter]
[chooser]
[debug]
[servers]
This diff is collapsed.
## Process this file with automake to produce makefile.in
DEFS = @DEFS@ -DGDM_SYSCONFDIR_CONFIG_FILE=\"@sysconfdir@/gdm/gdm.conf\" -DGDM_INSTALL_CONFIG_FILE=\"$(GDM_CONFIGDIR)/gdm.conf\"
DEFS = @DEFS@ -DGDM_SYSCONFDIR_CONFIG_FILE=\"$(GDM_CONFIGDIR)/gdm.conf\"
# Note that we have cflags for just about everything even if
# we don't link to everything
......
......@@ -2889,7 +2889,7 @@ gdm_handle_user_message (GdmConnection *conn, const char *msg, gpointer data)
name = g_strdup (GDM_STANDARD);
}
svr = gdm_find_x_server (name);
svr = gdm_find_xserver (name);
if G_UNLIKELY (svr == NULL) {
/* Don't print the name to syslog as it might be
* long and dangerous */
......@@ -3006,7 +3006,7 @@ gdm_handle_user_message (GdmConnection *conn, const char *msg, gpointer data)
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 ();
gchar *retval = gdm_get_xservers ();
if (retval != NULL) {
gdm_connection_printf (conn, "OK %s\n", retval);
......@@ -3019,10 +3019,12 @@ gdm_handle_user_message (GdmConnection *conn, const char *msg, gpointer data)
strlen (GDM_SUP_GET_SERVER_DETAILS " ")) == 0) {
const char *server = &msg[strlen (GDM_SUP_GET_SERVER_DETAILS " ")];
gchar **splitstr = g_strsplit (server, " ", 2);
GdmXserver *svr = gdm_find_x_server ((char *)splitstr[0]);
GdmXserver *svr = gdm_find_xserver ((char *)splitstr[0]);
if (svr != NULL) {
if (g_strncasecmp (splitstr[1], "NAME", 4) == 0)
if (g_strncasecmp (splitstr[1], "ID", 4) == 0)
gdm_connection_printf (conn, "OK %s\n", svr->id);
else 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);
......@@ -3031,25 +3033,25 @@ gdm_handle_user_message (GdmConnection *conn, const char *msg, gpointer data)
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");
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");
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");
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");
gdm_connection_printf (conn, "OK false\n");
else
gdm_connection_printf (conn, "ERROR 2 Key not valid\n");
......
This diff is collapsed.
This diff is collapsed.
......@@ -37,8 +37,8 @@ gboolean gdm_config_to_string (gchar *key,
gboolean gdm_update_config (gchar *key);
void gdm_config_init (void);
void gdm_config_parse (void);
GdmXserver* gdm_find_x_server (const gchar *id);
gchar* gdm_get_x_servers (void);
GdmXserver* gdm_find_xserver (const gchar *id);
gchar* gdm_get_xservers (void);
int gdm_compare_displays (gconstpointer a,
gconstpointer b);
uid_t gdm_get_gdmuid (void);
......
......@@ -951,7 +951,7 @@ gdm_server_resolve (GdmDisplay *disp)
bin = ve_first_word (disp->command);
if (bin != NULL && bin[0] != '/') {
svr = gdm_find_x_server (bin);
svr = gdm_find_xserver (bin);
}
g_free (bin);
return svr;
......@@ -975,7 +975,7 @@ gdm_server_resolve_command_line (GdmDisplay *disp,
gdm_error (_("Invalid server command '%s'"), disp->command);
argv = ve_split (gdm_get_value_string (GDM_KEY_STANDARD_XSERVER));
} else if (bin[0] != '/') {
GdmXserver *svr = gdm_find_x_server (bin);
GdmXserver *svr = gdm_find_xserver (bin);
if (svr == NULL) {
gdm_error (_("Server name '%s' not found; "
"using standard server"), bin);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -6,8 +6,8 @@ DEFS = @DEFS@ \
-DSYSCONFDIR=\"@sysconfdir@\" \
-DDATADIR=\"@datadir@\" \
-DLIBDIR=\"@libdir@\" \
-DGDM_CONFIG_FILE=\"@sysconfdir@/gdm/gdm.conf\" \
-DGDM_FACTORY_CONFIG_FILE=\"@sysconfdir@/gdm/factory-gdm.conf\" \
-DGDM_FACTORY_CONFIG_FILE=\"$(GDM_CONFIGDIR)/factory-gdm.conf\" \
-DGDM_SYSCONFDIR_CONFIG_FILE=\"$(GDM_CONFIGDIR)/gdm.conf\" \
-DGDM_GLADE_DIR=\"@datadir@/gdm\"
INCLUDES = \
......
......@@ -58,8 +58,6 @@
#include "viciousui.h"
static gchar *config_file;
static gboolean RUNNING_UNDER_GDM = FALSE;
enum {
......@@ -1940,12 +1938,6 @@ main (int argc, char *argv[])
glade_init ();
config_file = gdm_common_get_config_file ();
if (config_file == NULL) {
g_print (_("Could not access GDM configuration file.\n"));
exit (EXIT_FAILURE);
}
/* if broadcasting, then append BROADCAST to hosts */
if (gdm_config_get_bool (GDM_KEY_BROADCAST)) {
gchar *hosts = gdm_config_get_string (GDM_KEY_HOSTS);
......
......@@ -36,6 +36,7 @@
static GHashTable *int_hash = NULL;
static GHashTable *bool_hash = NULL;
static GHashTable *string_hash = NULL;
static gboolean gdm_never_cache = FALSE;
/*
* Hack to keep track if config functions should be printing error messages
......@@ -50,6 +51,24 @@ gdm_openlog (const char *ident, int logopt, int facility)
using_syslog = TRUE;
}
/**
* gdm_config_never_cache
*
* Most programs want config data to be cached to avoid constantly
* grabbing the information over the wire and are happy calling
* gdm_update_config to update a key value. However, gdmsetup
* really does want the latest value each time it accesses a
* config option. To avoid needing to call update_config
* for each key to be retrieved, just calling this function will
* let the config system know to always get the value via the
* sockets connection.
*/
void
gdm_config_never_cache (gboolean never_cache)
{
gdm_never_cache = never_cache;
}
/**
* gdm_config_hash_lookup
*
......@@ -203,8 +222,8 @@ gdm_config_get_xservers (gboolean flexible)
while (*sec != NULL) {
GdmXserver *svr = g_new0 (GdmXserver, 1);
svr->id = gdm_config_get_xserver_details (*sec, "ID");
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");
......@@ -285,7 +304,7 @@ _gdm_config_get_string (gchar *key, gboolean reload, gboolean *changed, gboolean
g_free (result);
if (hashretval == NULL) {
gchar** charval = g_new0 (gchar *, 1);
gchar **charval = g_new0 (gchar *, 1);
*charval = temp;
gdm_config_add_hash (string_hash, key, charval);
......@@ -309,7 +328,10 @@ _gdm_config_get_string (gchar *key, gboolean reload, gboolean *changed, gboolean
gchar *
gdm_config_get_string (gchar *key)
{
return _gdm_config_get_string (key, FALSE, NULL, TRUE);
if (gdm_never_cache == TRUE)
return _gdm_config_get_string (key, TRUE, NULL, TRUE);
else
return _gdm_config_get_string (key, FALSE, NULL, TRUE);
}
/**
......@@ -359,7 +381,10 @@ _gdm_config_get_translated_string (gchar *key, gboolean reload, gboolean *change
gchar *
gdm_config_get_translated_string (gchar *key)
{
return _gdm_config_get_translated_string (key, FALSE, NULL);
if (gdm_never_cache == TRUE)
return _gdm_config_get_translated_string (key, TRUE, NULL);
else
return _gdm_config_get_translated_string (key, FALSE, NULL);
}
/**
......@@ -427,7 +452,10 @@ _gdm_config_get_int (gchar *key, gboolean reload, gboolean *changed)
gint
gdm_config_get_int (gchar *key)
{
return _gdm_config_get_int (key, FALSE, NULL);
if (gdm_never_cache == TRUE)
return _gdm_config_get_int (key, TRUE, NULL);
else
return _gdm_config_get_int (key, FALSE, NULL);
}
/**
......@@ -498,7 +526,10 @@ _gdm_config_get_bool (gchar *key, gboolean reload, gboolean *changed)
gboolean
gdm_config_get_bool (gchar *key)
{
return _gdm_config_get_bool (key, FALSE, NULL);
if (gdm_never_cache == TRUE)
return _gdm_config_get_bool (key, TRUE, NULL);
else
return _gdm_config_get_bool (key, FALSE, NULL);
}
/**
......
......@@ -30,6 +30,7 @@ void gdm_openlog (const char *ident,
int logopt,
int facility);
void gdm_config_never_cache (gboolean never_cache);
gchar * gdm_config_get_string (gchar *key);
gchar * gdm_config_get_translated_string (gchar *key);
gint gdm_config_get_int (gchar *key);
......
......@@ -530,7 +530,7 @@ check_for_users (void)
}
static void
read_servers (gchar *config_file)
read_servers (void)
{
GSList *li;
......@@ -701,7 +701,6 @@ int
main (int argc, char *argv[])
{
GtkWidget *dialog;
gchar *config_file;
char *command;
char *version;
char *ret;
......@@ -733,12 +732,6 @@ main (int argc, char *argv[])
return 1;
}
config_file = gdm_common_get_config_file ();
if (config_file == NULL) {
g_print (_("Could not access GDM configuration file.\n"));
exit (0);
}
if (send_command != NULL) {
if (authenticate)
auth_cookie = gdmcomm_get_auth_cookie ();
......@@ -771,7 +764,6 @@ main (int argc, char *argv[])
if (ret != NULL) {
g_print ("%s\n", ret);
g_free (config_file);
return 0;
} else {
dialog = ve_hig_dialog_new
......@@ -786,7 +778,6 @@ main (int argc, char *argv[])
gtk_widget_show_all (dialog);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
g_free (config_file);
return 1;
}
}
......@@ -815,7 +806,6 @@ main (int argc, char *argv[])
gtk_widget_show_all (dialog);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
g_free (config_file);
return 1;
}
command = g_strdup_printf (GDM_SUP_FLEXI_XNEST " %s %d %s %s",
......@@ -842,11 +832,10 @@ main (int argc, char *argv[])
gtk_widget_show_all (dialog);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
g_free (config_file);
return 1;
}
read_servers (config_file);
read_servers ();
server = choose_server ();
if (server == NULL)
command = g_strdup (GDM_SUP_FLEXI_XSERVER);
......@@ -856,8 +845,6 @@ main (int argc, char *argv[])
version = "2.2.4.0";
}
g_free (config_file);
ret = gdmcomm_call_gdm (command, auth_cookie, version, 5);
g_free (command);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment