summaryrefslogtreecommitdiff
path: root/gui/gdmchooser.c
diff options
context:
space:
mode:
authorGeorge Lebl <jirka@5z.com>2003-07-24 22:01:21 +0000
committerGeorge Lebl <jirka@src.gnome.org>2003-07-24 22:01:21 +0000
commit405013a3120c612b629072c16a4baaa542bb02d0 (patch)
treea8e8f3a113d6eaf9a8cf518e916161c60979b088 /gui/gdmchooser.c
parent38ad2d1c9bceb5507411daff7868abaaf9045d27 (diff)
downloadgdm-405013a3120c612b629072c16a4baaa542bb02d0.tar.gz
change some g_strconcat's to g_build_filename's to address #118040. still
Thu Jul 24 14:58:23 2003 George Lebl <jirka@5z.com> * daemon/gdm.c, daemon/slave.c, daemon/auth.c: change some g_strconcat's to g_build_filename's to address #118040. still more need to be converted * gdm.spec.in, daemon/gdm.h, config/gdm.conf.in, config/Makefile.am, configure.in: By default use logdir of /var/log/gdm just like redhat does it * daemon/gdm.c: check logdir to exist and if not set it to ServAuthDir * gdm.spec.in, daemon/gdm.c, config/Makefile.am: Make the ServAuthDir permissions to be 1770 with owenership root.gdm. That makes it impossible for the gdm user to run DoS attacks against the gdm daemon (though without any process limits set it can still somewhat do that) * daemon/slave.c, daemon/display.c, daemon/gdm.c, daemon/misc.c, daemon/server.c: Hunt more races and hangs. Make sure we really don't do anything bad in signal handlers by making a setjmp at the beginning of the slave_start function and returning there from signal handlers to do final cleanup kind of stuff. Also when we are receiving TERM signals while waiting on stuff to die, be very un-nice to things and SIGKILL them. Also stop using sleep if we might be using alarm at the same time. * daemon/display.c: whack non-useful signal block push on unmanage, and if we get a TERM signal while waiting on the slave, then send a TERM signal to the slave again. * daemon/errorgui.c: set USER, USERNAME and LOGNAME to "gdm" so that they don't end up root by some mistake * daemon/slave.c: Use home of root rather then /root for the home directory of gdmsetup. Also if we can't change to the home directory chdir to / instead of leaving it at servauthdir. Be anal about COOKIEs in the logfile. Also when things go just a bit wrong and not completely whacko, don't ABORT but just REMANAGE, the toplevel loop of death will handle things for us correctly. And setsid a very close to the start of the session to avoid a race ABORTing a display by mistake. * daemon/slave.c: make the PostLogin behave just like PostSession with respect to the return value * daemon/verify-pam.c: avoid races on termination with the verify_cleanup and handle some cases where crashes may (but should not) occur. * daemon/gdm.c: whack unneeded signal blockers (the main daemon is all async with a nice mainloop) * gui/gdmchooser.c: handle HUP gracefully, when one of the config options we care about changes just restart self instead of * gui/gdmlogin.c, gui/greeter/greeter_item_ulist.c: make the username bold * docs/C/gdm.xml: update the PostLogin behaviour and the permissions on the ServAuthDir
Diffstat (limited to 'gui/gdmchooser.c')
-rw-r--r--gui/gdmchooser.c117
1 files changed, 110 insertions, 7 deletions
diff --git a/gui/gdmchooser.c b/gui/gdmchooser.c
index 6681c297..aa71495b 100644
--- a/gui/gdmchooser.c
+++ b/gui/gdmchooser.c
@@ -83,6 +83,7 @@ static gint connection_type = 0;
static void gdm_chooser_abort (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
static void gdm_chooser_warn (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
+static void set_background (void);
/* Exported for glade */
void gdm_chooser_cancel (void);
@@ -112,6 +113,10 @@ static guint scan_time_handler = 0;
static int ping_tries = PING_TRIES;
static guint ping_try_handler = 0;
+/* set in the main function */
+static char **stored_argv = NULL;
+static int stored_argc = 0;
+
/* Fixetyfix */
int XdmcpReallocARRAY8 (ARRAY8Ptr array, int length);
@@ -142,6 +147,7 @@ static gchar *GdmHostIconDir;
static gchar *GdmHostDefaultIcon;
static gchar *GdmGtkRC;
static gchar *GdmHosts;
+static gchar *GdmHostsOrig;
static gboolean GdmBroadcast;
static gboolean GdmAllowAdd;
static gchar *GdmBackgroundColor;
@@ -1055,6 +1061,7 @@ gdm_chooser_parse_config (void)
/* note that command line arguments will prevail over these */
GdmHosts = ve_config_get_string (cfg, GDM_KEY_HOSTS);
+ GdmHostsOrig = g_strdup (GdmHosts);
GdmBroadcast = ve_config_get_bool (cfg, GDM_KEY_BROADCAST);
/* if broadcasting, then append BROADCAST to hosts */
if (GdmBroadcast) {
@@ -1250,24 +1257,111 @@ gdm_chooser_gui_init (void)
}
}
+static gboolean
+string_same (VeConfig *config, const char *cur, const char *key)
+{
+ char *val = ve_config_get_string (config, key);
+ if (strcmp (ve_sure_string (cur), ve_sure_string (val)) == 0) {
+ g_free (val);
+ return TRUE;
+ } else {
+ g_free (val);
+ return FALSE;
+ }
+}
+
+static gboolean
+bool_same (VeConfig *config, gboolean cur, const char *key)
+{
+ gboolean val = ve_config_get_bool (config, key);
+ if (ve_bool_equal (cur, val)) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+static gboolean
+int_same (VeConfig *config, int cur, const char *key)
+{
+ int val = ve_config_get_int (config, key);
+ if (cur == val) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+
+static gboolean
+gdm_reread_config (int sig, gpointer data)
+{
+ VeConfig *config;
+ /* reparse config stuff here. At least ones we care about */
+
+ config = ve_config_get (GDM_CONFIG_FILE);
+
+ /* FIXME: The following is evil, we should update on the fly rather
+ * then just restarting */
+ /* Also we may not need to check ALL those keys but just a few */
+ if ( ! string_same (config, GdmHostsOrig, GDM_KEY_HOSTS) ||
+ ! string_same (config, GdmGtkRC, GDM_KEY_GTKRC) ||
+ ! string_same (config, GdmHostDefaultIcon, GDM_KEY_HOST) ||
+ ! string_same (config, GdmHostIconDir, GDM_KEY_HOSTDIR) ||
+ ! int_same (config,
+ GdmXineramaScreen, GDM_KEY_XINERAMASCREEN) ||
+ ! int_same (config, GdmIconMaxWidth, GDM_KEY_ICONWIDTH) ||
+ ! int_same (config, GdmIconMaxHeight, GDM_KEY_ICONHEIGHT) ||
+ ! int_same (config, GdmScanTime, GDM_KEY_SCAN) ||
+ ! bool_same (config, GdmDebug, GDM_KEY_DEBUG)) {
+ if (RUNNING_UNDER_GDM) {
+ /* Set busy cursor */
+ setup_cursor (GDK_WATCH);
+
+ gdm_wm_save_wm_order ();
+ }
+
+ /* we don't need to tell the slave that we're restarting
+ it doesn't care about our state. Unlike with the greeter */
+ execvp (stored_argv[0], stored_argv);
+ _exit (DISPLAY_REMANAGE);
+ }
+
+ /* we only use the color and do it for all types except NONE */
+ if ( ! string_same (config, GdmBackgroundColor, GDM_KEY_BACKGROUNDCOLOR) ||
+ ! int_same (config, GdmBackgroundType, GDM_KEY_BACKGROUNDTYPE)) {
+ set_background ();
+ }
+
+ return TRUE;
+}
+
static void
gdm_chooser_signals_init (void)
{
struct sigaction hup;
+ struct sigaction term;
sigset_t mask;
- hup.sa_handler = (void *) gdm_chooser_cancel;
+ ve_signal_add (SIGHUP, gdm_reread_config, NULL);
+
+ hup.sa_handler = ve_signal_notify;
hup.sa_flags = 0;
- sigemptyset (&hup.sa_mask);
+ sigemptyset(&hup.sa_mask);
+ sigaddset (&hup.sa_mask, SIGCHLD);
+
+ term.sa_handler = (void *) gdm_chooser_cancel;
+ term.sa_flags = 0;
+ sigemptyset (&term.sa_mask);
if (sigaction (SIGHUP, &hup, NULL) < 0)
gdm_chooser_abort (_("gdm_signals_init: Error setting up HUP signal handler"));
- if (sigaction (SIGINT, &hup, NULL) < 0)
+ if (sigaction (SIGINT, &term, NULL) < 0)
gdm_chooser_abort (_("gdm_signals_init: Error setting up INT signal handler"));
- if (sigaction (SIGTERM, &hup, NULL) < 0)
+ if (sigaction (SIGTERM, &term, NULL) < 0)
gdm_chooser_abort (_("gdm_signals_init: Error setting up TERM signal handler"));
sigfillset (&mask);
@@ -1358,6 +1452,13 @@ main (int argc, char *argv[])
poptContext ctx;
int nextopt;
const char *gdm_version;
+ 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;
if (g_getenv ("RUNNING_UNDER_GDM") != NULL)
RUNNING_UNDER_GDM = TRUE;
@@ -1472,14 +1573,16 @@ main (int argc, char *argv[])
gdm_wm_focus_window (GDK_WINDOW_XWINDOW (chooser->window));
}
- if (RUNNING_UNDER_GDM)
- setup_cursor (GDK_LEFT_PTR);
-
if (GdmAllowAdd)
gtk_widget_grab_focus (add_entry);
gdm_chooser_add_entry_changed ();
+ if (RUNNING_UNDER_GDM) {
+ gdm_wm_restore_wm_order ();
+ setup_cursor (GDK_LEFT_PTR);
+ }
+
gtk_main();
exit (EXIT_SUCCESS);