diff options
author | George Lebl <jirka@5z.com> | 2001-10-09 04:05:18 +0000 |
---|---|---|
committer | George Lebl <jirka@src.gnome.org> | 2001-10-09 04:05:18 +0000 |
commit | 6c35f4f1f1c9625b8d20d8d92ccddb171f765e14 (patch) | |
tree | bd70e8956f969caf46fde5e54d90e5d8a68a86cc | |
parent | d8c5975e154b4a22295ec75044130df6edff8094 (diff) | |
download | gdm-6c35f4f1f1c9625b8d20d8d92ccddb171f765e14.tar.gz |
Fix small leak
Mon Oct 08 20:54:33 2001 George Lebl <jirka@5z.com>
* daemon/auth.c: Fix small leak
* daemon/server.[ch], daemon/slave.c: wipe cookies better and safer
* daemon/server.c: server killing right after launch race fixed,
probably was harmless though, also reset the vt number on linux
before starting a new server.
* daemon/slave.c: increase the loop of death time for logouts, and
always redo parsed automatic/timed login vars after each display
start as the display number / hostname might have changed. When
we can't open a display, it's XFAILED rather then REMANAGE so
that we go into the "your X sucks" dialog. We need better
error reporting though.
-rw-r--r-- | ChangeLog | 17 | ||||
-rw-r--r-- | daemon/auth.c | 10 | ||||
-rw-r--r-- | daemon/server.c | 39 | ||||
-rw-r--r-- | daemon/server.h | 3 | ||||
-rw-r--r-- | daemon/slave.c | 37 |
5 files changed, 74 insertions, 32 deletions
@@ -1,3 +1,20 @@ +Mon Oct 08 20:54:33 2001 George Lebl <jirka@5z.com> + + * daemon/auth.c: Fix small leak + + * daemon/server.[ch], daemon/slave.c: wipe cookies better and safer + + * daemon/server.c: server killing right after launch race fixed, + probably was harmless though, also reset the vt number on linux + before starting a new server. + + * daemon/slave.c: increase the loop of death time for logouts, and + always redo parsed automatic/timed login vars after each display + start as the display number / hostname might have changed. When + we can't open a display, it's XFAILED rather then REMANAGE so + that we go into the "your X sucks" dialog. We need better + error reporting though. + Sun Oct 07 16:55:24 2001 Fatih Demir <kabalak@gtranslator.org> * configure.in: Added "ta" to the languages list. diff --git a/daemon/auth.c b/daemon/auth.c index 9ca10096..86daa110 100644 --- a/daemon/auth.c +++ b/daemon/auth.c @@ -411,7 +411,8 @@ void gdm_auth_user_remove (GdmDisplay *d, uid_t user) { FILE *af; - gchar *authfile, *authdir; + const gchar *authfile; + gchar *authdir; if (!d || !d->userauth) return; @@ -436,9 +437,10 @@ gdm_auth_user_remove (GdmDisplay *d, uid_t user) if (! gdm_file_check ("gdm_auth_user_remove", user, authdir, authfile, TRUE, GdmUserMaxFile, GdmRelaxPerms)) { - gdm_error (_("gdm_auth_user_remove: Ignoring suspiciously looking cookie file %s"), d->userauth); + g_free (authdir); + gdm_error (_("gdm_auth_user_remove: Ignoring suspiciously looking cookie file %s"), d->userauth); - return; + return; } g_free (authdir); @@ -464,8 +466,6 @@ gdm_auth_user_remove (GdmDisplay *d, uid_t user) g_free (d->userauth); d->userauth = NULL; - - return; } diff --git a/daemon/server.c b/daemon/server.c index 92641e72..63461b00 100644 --- a/daemon/server.c +++ b/daemon/server.c @@ -67,6 +67,20 @@ extern pid_t extra_process; /* Global vars */ static GdmDisplay *d = NULL; +/* Wipe cookie files */ +void +gdm_server_wipe_cookies (GdmDisplay *disp) +{ + if ( ! ve_string_empty (disp->authfile)) + unlink (disp->authfile); + g_free (disp->authfile); + disp->authfile = NULL; + if ( ! ve_string_empty (disp->authfile_gdm)) + unlink (disp->authfile_gdm); + g_free (disp->authfile_gdm); + disp->authfile_gdm = NULL; +} + /** * gdm_server_reinit: * @disp: Pointer to a GdmDisplay structure @@ -122,14 +136,16 @@ gdm_server_stop (GdmDisplay *disp) disp->servstat = SERVER_DEAD; if (disp->servpid != 0) { - if (kill (disp->servpid, SIGTERM) == 0) - waitpid (disp->servpid, 0, 0); + pid_t servpid = disp->servpid; + + /* avoid SIGCHLD race */ disp->servpid = 0; + + if (kill (servpid, SIGTERM) == 0) + waitpid (servpid, 0, 0); } - unlink (disp->authfile); - if (disp->authfile_gdm != NULL) - unlink (disp->authfile_gdm); + gdm_server_wipe_cookies (disp); } static gboolean @@ -279,6 +295,15 @@ gdm_server_start (GdmDisplay *disp, gboolean treat_as_flexi, /* if an X server exists, wipe it */ gdm_server_stop (d); + /* On linux first clear the VT number */ +#ifdef __linux__ + if (d->type == TYPE_LOCAL || + d->type == TYPE_FLEXI) { + d->vt = -1; + gdm_slave_send_num (GDM_SOP_VT_NUM, -1); + } +#endif + if (SERVER_IS_FLEXI (d) || treat_as_flexi) { flexi_disp = gdm_get_free_display @@ -437,9 +462,7 @@ gdm_server_start (GdmDisplay *disp, gboolean treat_as_flexi, } /* We will rebake cookies anyway, so wipe these */ - unlink (disp->authfile); - if (disp->authfile_gdm != NULL) - unlink (disp->authfile_gdm); + gdm_server_wipe_cookies (disp); sigprocmask (SIG_SETMASK, &oldmask, NULL); diff --git a/daemon/server.h b/daemon/server.h index 823606da..743711c9 100644 --- a/daemon/server.h +++ b/daemon/server.h @@ -21,6 +21,9 @@ #include "gdm.h" +/* Wipe cookie files */ +void gdm_server_wipe_cookies (GdmDisplay *disp); + gboolean gdm_server_start (GdmDisplay *d, gboolean treat_as_flexi, int min_flexi_disp, diff --git a/daemon/slave.c b/daemon/slave.c index 28f39dc1..1dbe3469 100644 --- a/daemon/slave.c +++ b/daemon/slave.c @@ -230,7 +230,7 @@ gdm_slave_start (GdmDisplay *display) death_count ++; if ((the_time - first_time) <= 0 || - (the_time - first_time) > 40) { + (the_time - first_time) > 60) { first_time = the_time; death_count = 0; } else if (death_count > 6) { @@ -334,18 +334,6 @@ gdm_slave_run (GdmDisplay *display) d = display; - if ( ! ve_string_empty (GdmAutomaticLogin) && - ParsedAutomaticLogin == NULL) { - ParsedAutomaticLogin = gdm_parse_enriched_login (GdmAutomaticLogin, - display); - } - - if ( ! ve_string_empty (GdmTimedLogin) && - ParsedTimedLogin == NULL) { - ParsedTimedLogin = gdm_parse_enriched_login (GdmTimedLogin, - display); - } - if (d->sleep_before_run > 0) { gdm_debug ("gdm_slave_run: Sleeping %d seconds before server start", d->sleep_before_run); sleep (d->sleep_before_run); @@ -369,6 +357,20 @@ gdm_slave_run (GdmDisplay *display) ve_setenv ("XAUTHORITY", d->authfile, TRUE); ve_setenv ("DISPLAY", d->name, TRUE); + + /* Now the display name and hostname is final */ + if ( ! ve_string_empty (GdmAutomaticLogin)) { + g_free (ParsedAutomaticLogin); + ParsedAutomaticLogin = gdm_parse_enriched_login (GdmAutomaticLogin, + display); + } + + if ( ! ve_string_empty (GdmTimedLogin)) { + g_free (ParsedTimedLogin); + ParsedTimedLogin = gdm_parse_enriched_login (GdmTimedLogin, + display); + } + /* X error handlers to avoid the default one (i.e. exit (1)) */ XSetErrorHandler (gdm_slave_xerror_handler); @@ -398,12 +400,12 @@ gdm_slave_run (GdmDisplay *display) } } - /* something may have gone wrong, try remanaging, if local (non-flexi), + /* something may have gone wrong, try xfailed, if local (non-flexi), * the toplevel loop of death will handle us */ if (d->dsp == NULL) { gdm_server_stop (d); if (d->type == TYPE_LOCAL) - _exit (DISPLAY_REMANAGE); + _exit (DISPLAY_XFAILED); else _exit (DISPLAY_ABORT); } @@ -2344,10 +2346,7 @@ gdm_slave_child_handler (int sig) } else if (pid != 0 && pid == d->servpid) { d->servstat = SERVER_DEAD; d->servpid = 0; - if ( ! ve_string_empty (d->authfile)) - unlink (d->authfile); - if ( ! ve_string_empty (d->authfile_gdm)) - unlink (d->authfile_gdm); + gdm_server_wipe_cookies (d); } else if (pid == extra_process) { /* an extra process died, yay! */ extra_process = -1; |