Commit 50ae5e21 authored by Jiri (George) Lebl's avatar Jiri (George) Lebl Committed by George Lebl

handle fails on user auth writing by going to the fallback file to handle

Tue Jul 09 09:08:25 2002  George Lebl <jirka@5z.com>

	* daemon/auth.c: handle fails on user auth writing by going to the
	  fallback file to handle things in a saner way.  Fixed
	  locking/unlocking to be done properly and fixed leaks in the purge
	  function.
parent f24d49df
Tue Jul 09 09:08:25 2002 George Lebl <jirka@5z.com>
* daemon/auth.c: handle fails on user auth writing by going to the
fallback file to handle things in a saner way. Fixed
locking/unlocking to be done properly and fixed leaks in the purge
function.
Tue Jul 09 08:44:04 2002 George Lebl <jirka@5z.com>
* daemon/slave.c: Fix a bug with finding the parent process
......
......@@ -2,8 +2,6 @@ Postfreeze things:
- handle kills of server not working correctly to be more robust
we must leave killing to the main daemon since that can more likely kill
the server.
- DisplayInit in setup_automatic_session should probably be run
before the user setup, probably does no harm but anyway.
- in the slave child handler check that restart greeter is done with euid
and all that set correctly
- in slave child handler check that the server dead stuff can actually wipe
......
......@@ -387,24 +387,34 @@ gdm_auth_user_add (GdmDisplay *d, uid_t user, const char *homedir)
FILE *af;
GSList *auths = NULL;
gboolean ret = TRUE;
gboolean automatic_tmp_dir = FALSE;
gboolean locked;
if (!d)
return FALSE;
gdm_debug ("gdm_auth_user_add: Adding cookie for %d", user);
try_user_add_again:
locked = FALSE;
/* Determine whether UserAuthDir is specified. Otherwise ~user is used */
if (*GdmUserAuthDir)
if ( ! ve_string_empty (GdmUserAuthDir))
authdir = GdmUserAuthDir;
else
authdir = homedir;
umask (077);
d->userauth = g_strconcat (authdir, "/", GdmUserAuthFile, NULL);
if (authdir == NULL)
d->userauth = NULL;
else
d->userauth = g_strconcat (authdir, "/", GdmUserAuthFile, NULL);
/* Find out if the Xauthority file passes the paranoia check */
if (authdir == NULL ||
if (automatic_tmp_dir ||
authdir == NULL ||
! gdm_file_check ("gdm_auth_user_add", user, authdir, GdmUserAuthFile,
TRUE, GdmUserMaxFile, GdmRelaxPerms) ||
! try_open_append (d->userauth)) {
......@@ -438,21 +448,30 @@ gdm_auth_user_add (GdmDisplay *d, uid_t user, const char *homedir)
umask (022);
return FALSE;
automatic_tmp_dir = TRUE;
goto try_user_add_again;
}
locked = TRUE;
af = fopen (d->userauth, "a+");
}
if (!af) {
/* Really no need to clean up here - this process is a goner anyway */
gdm_error (_("gdm_auth_user_add: Could not open cookie file %s"), d->userauth);
XauUnlockAuth (d->userauth);
if (locked)
XauUnlockAuth (d->userauth);
g_free (d->userauth);
d->userauth = NULL;
umask (022);
if ( ! d->authfb) {
automatic_tmp_dir = TRUE;
goto try_user_add_again;
}
return FALSE;
}
......@@ -469,6 +488,17 @@ gdm_auth_user_add (GdmDisplay *d, uid_t user, const char *homedir)
if ( ! XauWriteAuth (af, auths->data)) {
gdm_error (_("%s: Could not write cookie"),
"gdm_auth_user_add");
if ( ! d->authfb) {
fclose (af);
if (locked)
XauUnlockAuth (d->userauth);
g_free (d->userauth);
d->userauth = NULL;
automatic_tmp_dir = TRUE;
goto try_user_add_again;
}
ret = FALSE;
break;
}
......@@ -477,7 +507,8 @@ gdm_auth_user_add (GdmDisplay *d, uid_t user, const char *homedir)
}
fclose (af);
XauUnlockAuth (d->userauth);
if (locked)
XauUnlockAuth (d->userauth);
gdm_debug ("gdm_auth_user_add: Done");
......@@ -537,14 +568,20 @@ gdm_auth_user_remove (GdmDisplay *d, uid_t user)
g_free (authfile);
/* Lock user's cookie jar and open it for writing */
if (XauLockAuth (d->userauth, 3, 3, 0) != LOCK_SUCCESS)
if (XauLockAuth (d->userauth, 3, 3, 0) != LOCK_SUCCESS) {
g_free (d->userauth);
d->userauth = NULL;
return;
}
af = fopen (d->userauth, "a+");
if (!af) {
XauUnlockAuth (d->userauth);
g_free (d->userauth);
d->userauth = NULL;
return;
}
......@@ -572,7 +609,7 @@ static void
gdm_auth_purge (GdmDisplay *d, FILE *af)
{
Xauth *xa;
GSList *keep = NULL;
GSList *keep = NULL, *li;
if (!d || !af)
return;
......@@ -585,7 +622,7 @@ gdm_auth_purge (GdmDisplay *d, FILE *af)
* temporary file issues. Then remove any instance of this display
* in the cookie jar... */
while ( (xa = XauReadAuth (af)) ) {
while ( (xa = XauReadAuth (af)) != NULL ) {
gboolean match = FALSE;
GSList *alist = d->auths;
......@@ -608,17 +645,14 @@ gdm_auth_purge (GdmDisplay *d, FILE *af)
/* Rewind the file */
af = freopen (d->userauth, "w", af);
if (!af) {
XauUnlockAuth (d->userauth);
return;
}
/* Write out remaining entries */
while (keep) {
XauWriteAuth (af, keep->data);
XauDisposeAuth (keep->data);
keep = keep->next;
for (li = keep; li != NULL; li = li->next) {
/* FIXME: is this correct, if we can't open
* this is quite crap isn't it ... */
if (af != NULL)
XauWriteAuth (af, li->data);
XauDisposeAuth (li->data);
li->data = NULL;
}
g_slist_free (keep);
......
......@@ -317,15 +317,17 @@ setup_automatic_session (GdmDisplay *display, const char *name)
greet = FALSE;
gdm_debug ("setup_automatic_session: Automatic login: %s", login);
if ( ! gdm_verify_setup_user (display, login, display->name))
return FALSE;
/* Run the init script. gdmslave suspends until script
* has terminated */
gdm_slave_exec_script (display, GdmDisplayInit, NULL, NULL);
gdm_debug ("setup_automatic_session: DisplayInit script finished");
if ( ! gdm_verify_setup_user (display, login, display->name))
return FALSE;
gdm_debug ("setup_automatic_session: Automatic login successful");
return TRUE;
}
......
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