Changing the user while preparing the password



After adding the non-indented line in TnyGnomeAccountStore, you'll see
this during authentication (it's possible to change the user while
preparing the password in the get-password function).

So although I know you told me it's not working on IRC, Murray, this
more or less proofs that it does.

Note that there are a few properties of the account that you can't
change while preparing the password question. That's because the
password question is asked during authentication. For example:

Changing the hostname while preparing the password will cause a forceful
disconnect. Although that by itself will cause a new password question,
the old password question that you entered might not have set the right
values and some values (like the authentication mech) might have been
reset. Especially if the new hostname doesn't support that
authentication mech.

This is much more caused by limitations of what actually can be done
during authentication, than that this is a Tinymail limitation, of
course.

Although, indeed, setting the user during authentication is an exception
that has now been made to work.

Note that when testing, use -DDEBUG in your CFLAGS. That way we can see
the LOGIN IMAP command happening (like you can see below).

If you don't compile Tinymail with this CFLAG, it's obviously much
harder to test things.


a) A change in ~ tny-gnome-account-store.c:72 (the tny_account_set_user line is added)

static gchar* 
per_account_get_pass_func (TnyAccount *account, const gchar *prompt, gboolean *cancel)
{
	TnyPlatformFactory *platfact = tny_gnome_platform_factory_get_instance ();
	TnyPasswordGetter *pwdgetter;
	gchar *retval;

	pwdgetter = tny_platform_factory_new_password_getter (platfact);
	retval = (gchar*) tny_password_getter_get_password (pwdgetter, 
		tny_account_get_id (account), prompt, cancel);
	g_object_unref (G_OBJECT (pwdgetter));

tny_account_set_user (account, "TEST");

	return retval;
}


b) In GDB I've put a break on "imap_auth_loop" in camel-imap-store.c:1523


Breakpoint 2, imap_auth_loop (service=0x80dc638, ex=0xb5f8c2c8)
    at camel-imap-store.c:1523
1523            CamelImapStore *store = CAMEL_IMAP_STORE (service);
(gdb) next
1524            CamelSession *session = camel_service_get_session (service);
(gdb) 
1525            CamelServiceAuthType *authtype = NULL;
(gdb) 
1527            char *errbuf = NULL;
(gdb) 
1528            gboolean authenticated = FALSE;
(gdb) 
1532            if (store->capabilities & IMAP_CAPABILITY_LOGINDISABLED)
(gdb) 
1535            auth_domain = camel_url_get_param (service->url, "auth-domain");
(gdb) 
1537            if (store->preauthed) 
(gdb) print service->url->user
$1 = 0x82333f8 "tnytest"
(gdb) next
1545            if (service->url->authmech) 
(gdb) 
1572            while (!authenticated) 
(gdb) 
1574                    if (errbuf) 
(gdb) 
1582                    if (!service->url->passwd) 
(gdb) 
1586                            prompt = g_strdup_printf (_("%sPlease enter the IMAP " ...
(gdb) 
1591                            service->url->passwd = camel_session_get_password (session, service, auth_domain,
					prompt, "password", CAMEL_SESSION_PASSWORD_SECRET, ex);
(gdb) 
1594                            g_free (prompt);
(gdb) print service->url->user
$2 = 0x82333f8 "TEST"
(gdb) next
1595                            g_free (errbuf);
(gdb) 
1596                            errbuf = NULL;
(gdb) 
1598                            if (!service->url->passwd) {
(gdb) next
1605                    if (!store->connected) 
(gdb) 
1613                    if (authtype)
(gdb) 
1617                            if (!service->url->passwd)
(gdb) 
1624                            response = camel_imap_command (store, NULL, ex, ...
(gdb) 
(27, 27) -> B00001 LOGIN TEST tnytest

(.., ..) <- B00001 NO Login failed: authentication failure
1628                            if (response) {
(gdb) 

You can clearly see that the account first had "tnytest" as its user
(the $1 print) and that at the time of actual authentication it had
"TEST" as user (the $2 print). Which was the user that I had set in ~
tny-gnome-account-store.c:84 (note that this line does not exist in the
repository, this is a line that I added for testing, you can see the
line above in this E-mail).


-- 
Philip Van Hoof, software developer
home: me at pvanhoof dot be 
gnome: pvanhoof at gnome dot org 
http://www.pvanhoof.be/blog







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]