commit 41c219615c738917321ccf9c000fc2e1eb5a197a
parent 7171e2ab9565100e89086fc9c1fab58650e1db15
Author: Michael Rasmussen <mir@datanom.net>
Date: Sun, 14 Aug 2011 19:40:31 +0000
2011-08-14 [mir] 3.7.9cvs47
* src/news.c
* src/etpan/nntp-thread.c
Fix bug 2418. Patch provided by Sébastien Bigaret with
some minor contribution by me.
Diffstat:
5 files changed, 57 insertions(+), 23 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,10 @@
+2011-08-14 [mir] 3.7.9cvs47
+
+ * src/news.c
+ * src/etpan/nntp-thread.c
+ Fix bug 2418. Patch provided by Sébastien Bigaret with
+ some minor contribution by me.
+
2011-08-13 [mir] 3.7.9cvs46
* src/etpan/nntp-thread.c
diff --git a/PATCHSETS b/PATCHSETS
@@ -4198,3 +4198,4 @@
( cvs diff -u -r 1.1.2.102 -r 1.1.2.103 src/gtk/quicksearch.c; ) > 3.7.9cvs44.patchset
( cvs diff -u -r 1.83.2.169 -r 1.83.2.170 src/mimeview.c; ) > 3.7.9cvs45.patchset
( cvs diff -u -r 1.1.2.14 -r 1.1.2.15 src/etpan/nntp-thread.c; ) > 3.7.9cvs46.patchset
+( cvs diff -u -r 1.101.2.66 -r 1.101.2.67 src/news.c; cvs diff -u -r 1.1.2.15 -r 1.1.2.16 src/etpan/nntp-thread.c; ) > 3.7.9cvs47.patchset
diff --git a/configure.ac b/configure.ac
@@ -12,7 +12,7 @@ MINOR_VERSION=7
MICRO_VERSION=9
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=46
+EXTRA_VERSION=47
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
diff --git a/src/etpan/nntp-thread.c b/src/etpan/nntp-thread.c
@@ -592,15 +592,11 @@ static void login_run(struct etpan_thread_op * op)
mailstream_debug = 0;
#endif
- r = newsnntp_mode_reader(param->nntp);
- if (r == NEWSNNTP_NO_ERROR ||
- r == NEWSNNTP_WARNING_REQUEST_AUTHORIZATION_USERNAME ||
- r == NEWSNNTP_WARNING_REQUEST_AUTHORIZATION_PASSWORD) {
- r = newsnntp_authinfo_username(param->nntp, param->login);
- if (r == NEWSNNTP_NO_ERROR ||
- r == NEWSNNTP_WARNING_REQUEST_AUTHORIZATION_PASSWORD) {
- r = newsnntp_authinfo_password(param->nntp, param->password);
- }
+ r = newsnntp_authinfo_username(param->nntp, param->login);
+ /* libetpan returning NO_ERROR means it received resp.code 281:
+ in this case auth. is already successful, no password is needed. */
+ if (r == NEWSNNTP_WARNING_REQUEST_AUTHORIZATION_PASSWORD) {
+ r = newsnntp_authinfo_password(param->nntp, param->password);
}
diff --git a/src/news.c b/src/news.c
@@ -328,6 +328,7 @@ static Session *news_session_new_for_folder(Folder *folder)
const gchar *userid = NULL;
gchar *passwd = NULL;
gushort port;
+ int r;
cm_return_val_if_fail(folder != NULL, NULL);
cm_return_val_if_fail(folder->account != NULL, NULL);
@@ -366,6 +367,48 @@ static Session *news_session_new_for_folder(Folder *folder)
session = news_session_new(folder, ac->nntp_server, port, userid, passwd);
#endif
+ r = nntp_threaded_mode_reader(folder);
+ if (r != NEWSNNTP_NO_ERROR) {
+ if (r == NEWSNNTP_WARNING_REQUEST_AUTHORIZATION_USERNAME) {
+ /*
+ FIX ME when libetpan implements 480 to indicate authorization
+ is required to use this capability. Libetpan treats a 480 as a
+ 381 which is clearly wrong.
+ RFC 4643 section 2.
+ Response code 480
+ Generic response
+ Meaning: command unavailable until the client
+ has authenticated itself.
+ */
+ /* if the server does not advertise the capability MODE-READER,
+ we normally should not send MODE READER. However this can't
+ hurt: a transit-only server returns 502 and closes the cnx.
+ Ref.: http://tools.ietf.org/html/rfc3977#section-5.3
+ */
+ log_error(LOG_PROTOCOL, _("Libetpan does not support return code 480 "
+ "so for now we choose to continue\n"));
+ }
+ else if (r == NEWSNNTP_ERROR_UNEXPECTED_RESPONSE) {
+ /* if the server does not advertise the capability MODE-READER,
+ we normally should not send MODE READER. However this can't
+ hurt: a transit-only server returns 502 and closes the cnx.
+ Ref.: http://tools.ietf.org/html/rfc3977#section-5.3
+ */
+ log_error(LOG_PROTOCOL, _("Mode reader failed, continuing nevertheless\n"));
+ }
+ else {
+ /* An error state bail out */
+ log_error(LOG_PROTOCOL, _("Error creating session with %s:%d\n"), ac->nntp_server, port);
+ session_destroy(SESSION(session));
+ g_free(passwd);
+ if (ac->session_passwd) {
+ g_free(ac->session_passwd);
+ ac->session_passwd = NULL;
+ }
+ return NULL;
+ }
+ }
+
if ((session != NULL) && ac->use_nntp_auth) { /* FIXME: && ac->use_nntp_auth_onconnect */
if (nntp_threaded_login(folder, userid, passwd) !=
NEWSNNTP_NO_ERROR) {
@@ -701,11 +744,6 @@ gint news_post(Folder *folder, const gchar *file)
ok = nntp_threaded_post(folder, contents, strlen(contents));
- if (ok != NEWSNNTP_NO_ERROR && ok != NEWSNNTP_ERROR_STREAM) {
- ok = nntp_threaded_mode_reader(folder);
- if (ok == NEWSNNTP_NO_ERROR)
- ok = nntp_threaded_post(folder, contents, strlen(contents));
- }
g_free(contents);
if (ok == NEWSNNTP_ERROR_STREAM) {
@@ -769,14 +807,6 @@ static gint news_select_group(Folder *folder, const gchar *group,
ok = nntp_threaded_group(folder, group, &info);
- if (ok != NEWSNNTP_NO_ERROR &&
- ok != NEWSNNTP_ERROR_STREAM &&
- ok != NEWSNNTP_WARNING_REQUEST_AUTHORIZATION_USERNAME) {
- ok = nntp_threaded_mode_reader(folder);
- if (ok == NEWSNNTP_NO_ERROR)
- ok = nntp_threaded_group(folder, group, &info);
- }
-
if (ok == NEWSNNTP_NO_ERROR && info) {
session->group = g_strdup(group);
*num = info->grp_first;