Patch for simple login strings on imap servers
Robert Minsk <[email protected]> Mon, 27 Aug 2012 19:19:41 -0700
| Newsgroups | gmane.mail.perdition.user |
|---|---|
| Message-ID | <69BF9462AB658F458FD6FD072E7F800A0143B83A4B@VA3DIAXVS5D1.RED001.local> |
imap4 supports a simpler version of the login string than perdition uses. Some older imap servers do not understand the newer login string that perdition uses. The disadvantage of the simple login is that user names can not contain spaces or other special characters. The patch adds a flag to have perdition use the simpler login method. It also corrects a spelling error with DEFAULT being typed as DEFAILT. This e-mail and any attachments are intended only for use by the addressee(s) named herein and may contain confidential information. If you are not the intended recipient of this e-mail, you are hereby notified any dissemination, distribution or copying of this email and any attachments is strictly prohibited. If you receive this email in error, please immediately notify the sender by return email and permanently delete the original, any copy and any printout thereof. The integrity and security of e-mail cannot be guaranteed. ______________________________________________ Perdition-users mailing list [email protected] http://lists.vergenet.net/listinfo/perdition-users
simple_login.patch
(text/x-patch, 8.9 KB)
diff -rupN perdition-1.18.orig/etc/perdition/perdition.conf perdition-1.18/etc/perdition/perdition.conf
--- perdition-1.18.orig/etc/perdition/perdition.conf 2009-09-28 19:17:18.000000000 -0700
+++ perdition-1.18/etc/perdition/perdition.conf 2012-08-27 19:03:47.000000000 -0700
@@ -287,6 +287,9 @@
#query_key \\I
#query_key \\u\\da_domain,\\da_domain
+# simple_login
+# Use simple login method on outgoing imap server.
+#simple_login
######################################################################
# Options below relate to SSL/TLS support.
diff -rupN perdition-1.18.orig/perdition/imap4_out.c perdition-1.18/perdition/imap4_out.c
--- perdition-1.18.orig/perdition/imap4_out.c 2009-11-25 21:05:32.000000000 -0800
+++ perdition-1.18/perdition/imap4_out.c 2012-08-27 19:01:08.000000000 -0700
@@ -345,33 +345,42 @@ int imap4_out_authenticate(
goto leave;
}
- if(imap4_write(rs_io, NULL_FLAG, tag, IMAP4_CMD_LOGIN, 1, "{%d}",
- strlen(pw->pw_name))<0){
- VANESSA_LOGGER_DEBUG("imap4_write login");
- status=-1;
- goto leave;
- }
- if(n) { new_n = *n; }
- if((status=imap4_out_response(rs_io, eu_io, cont, ok, &q,
- (unsigned char *)buf, &new_n))<0){
- VANESSA_LOGGER_DEBUG("imap4_out_response login");
- }
+ if(opt.simple_login) {
+ if(imap4_write(rs_io, NULL_FLAG, tag, IMAP4_CMD_LOGIN, 2, "%s %s",
+ pw->pw_name, pw->pw_passwd)<0){
+ VANESSA_LOGGER_DEBUG("imap4_write login passwd");
+ status=-1;
+ goto leave;
+ }
+ } else {
+ if(imap4_write(rs_io, NULL_FLAG, tag, IMAP4_CMD_LOGIN, 1, "{%d}",
+ strlen(pw->pw_name))<0){
+ VANESSA_LOGGER_DEBUG("imap4_write login");
+ status=-1;
+ goto leave;
+ }
+ if(n) { new_n = *n; }
+ if((status=imap4_out_response(rs_io, eu_io, cont, ok, &q,
+ (unsigned char *)buf, &new_n))<0){
+ VANESSA_LOGGER_DEBUG("imap4_out_response login");
+ }
- if(imap4_write(rs_io, NULL_FLAG, NULL, NULL, 2, "%s {%d}",
- pw->pw_name, strlen(pw->pw_passwd))<0){
- VANESSA_LOGGER_DEBUG("imap4_write name");
- status=-1;
- goto leave;
- }
- if(n) { new_n = *n; }
- if((status=imap4_out_response(rs_io, eu_io, cont, ok, &q, buf, &new_n))<0){
- VANESSA_LOGGER_DEBUG("imap4_out_response name");
- }
+ if(imap4_write(rs_io, NULL_FLAG, NULL, NULL, 2, "%s {%d}",
+ pw->pw_name, strlen(pw->pw_passwd))<0){
+ VANESSA_LOGGER_DEBUG("imap4_write name");
+ status=-1;
+ goto leave;
+ }
+ if(n) { new_n = *n; }
+ if((status=imap4_out_response(rs_io, eu_io, cont, ok, &q, buf, &new_n))<0){
+ VANESSA_LOGGER_DEBUG("imap4_out_response name");
+ }
- if(imap4_write(rs_io, NULL_FLAG, NULL, NULL, 1, "%s", pw->pw_passwd)<0){
- VANESSA_LOGGER_DEBUG("str_write passwd");
- status=-1;
- goto leave;
+ if(imap4_write(rs_io, NULL_FLAG, NULL, NULL, 1, "%s", pw->pw_passwd)<0){
+ VANESSA_LOGGER_DEBUG("str_write passwd");
+ status=-1;
+ goto leave;
+ }
}
if(n) { new_n = *n; }
if((status=imap4_out_response(rs_io, eu_io, tag, ok, &q, buf, &new_n))<0){
diff -rupN perdition-1.18.orig/perdition/options.c perdition-1.18/perdition/options.c
--- perdition-1.18.orig/perdition/options.c 2009-11-26 16:05:18.000000000 -0800
+++ perdition-1.18/perdition/options.c 2012-08-27 18:51:42.000000000 -0700
@@ -402,6 +402,8 @@ int options(int argc, char **argv, flag_
TAG_PID_FILE},
{"no_daemon", '\0', POPT_ARG_NONE, NULL,
TAG_NO_DAEMON},
+ {"simple_login", '\0', POPT_ARG_NONE, NULL,
+ TAG_SIMPLE_LOGIN},
{"ssl_mode", '\0', POPT_ARG_STRING, NULL,
TAG_SSL_MODE },
{"ssl_ca_chain_file", '\0', POPT_ARG_STRING, NULL,
@@ -477,6 +479,7 @@ int options(int argc, char **argv, flag_
opt_i(&(opt.protocol), DEFAULT_PROTOCOL, &i, 0, OPT_NOT_SET);
}
opt_i(&(opt.no_daemon), DEFAULT_NO_DAEMON, &i, 0, OPT_NOT_SET);
+ opt_i(&(opt.simple_login), DEFAULT_SIMPLE_LOGIN, &i, 0, OPT_NOT_SET);
opt_i(&(opt.no_lookup), DEFAULT_NO_LOOKUP, &i, 0, OPT_NOT_SET);
opt_i(&(opt.login_disabled), DEFAULT_LOGIN_DISABLED, &i, 0, OPT_NOT_SET);
opt_i(&(opt.lower_case), DEFAULT_LOWER_CASE, &i, 0, OPT_NOT_SET);
@@ -502,7 +505,7 @@ int options(int argc, char **argv, flag_
opt_p(&(opt.explicit_domain), NULL, &i, 0, OPT_NOT_SET);
opt_p(&(opt.group), DEFAULT_GROUP, &i, 0, OPT_NOT_SET);
opt_p(&(opt.listen_port), PERDITION_PROTOCOL_DEPENDANT, &i, 0, OPT_NOT_SET);
- opt_i(&(opt.log_passwd), DEFAILT_LOG_PASSWD, &i, 0, OPT_NOT_SET);
+ opt_i(&(opt.log_passwd), DEFAULT_LOG_PASSWD, &i, 0, OPT_NOT_SET);
opt_p(&(opt.map_library), DEFAULT_MAP_LIB, &i, 0, OPT_NOT_SET);
opt_p(&(opt.map_library_opt), DEFAULT_MAP_LIB_OPT, &i, 0, OPT_NOT_SET);
opt_p(&(opt.outgoing_port), PERDITION_PROTOCOL_DEPENDANT,
@@ -740,6 +743,9 @@ int options(int argc, char **argv, flag_
case TAG_NO_DAEMON:
opt_i(&(opt.no_daemon), 1, &(opt.mask), MASK_NO_DAEMON, f);
break;
+ case TAG_SIMPLE_LOGIN:
+ opt_i(&(opt.simple_login), 1, &(opt.mask2), MASK2_SIMPLE_LOGIN, f);
+ break;
case TAG_LOGIN_DISABLED:
opt_i(&(opt.login_disabled), 1, &(opt.mask), MASK_LOGIN_DISABLED, f);
break;
@@ -1134,6 +1140,7 @@ int log_options_str(char *str, size_t n)
"pid_file=\"%s\", "
"protocol=\"%s\", "
"server_resp_line=%s, "
+ "simple_login=%s, "
"strip_domain=\"%s\", "
"timeout=%d, "
"username=\"%s\", "
@@ -1192,6 +1199,7 @@ int log_options_str(char *str, size_t n)
OPT_STR(opt.pid_file),
protocol,
BIN_OPT_STR(opt.server_resp_line),
+ BIN_OPT_STR(opt.simple_login),
strip_domain,
opt.timeout,
OPT_STR(opt.username),
@@ -1386,6 +1394,8 @@ void usage(int exit_status){
" Default real-server port. (default \"%s\")\n"
" -s|--outgoing_server SERVER[,SERVER...]:\n"
" Default server(s). (default \"%s\")\n"
+ " --simple_login:\n"
+ " Use simple imap login format on outgoing server.\n"
" --pid_file FILENAME\n"
" Path for pidfile. Must be a full path starting with a '/'.\n"
" Empty for no pid file. Not used in inetd mode.\n"
@@ -1476,7 +1486,7 @@ void usage(int exit_status){
OPT_STR(PERDITION_PROTOCOL_DEPENDANT),
DEFAULT_CONNECTION_LIMIT,
OPT_STR(PERDITION_PROTOCOL_DEPENDANT),
- OPT_STR(log_passwd_to_str(DEFAILT_LOG_PASSWD)),
+ OPT_STR(log_passwd_to_str(DEFAULT_LOG_PASSWD)),
OPT_STR(DEFAULT_MAP_LIB),
OPT_STR(DEFAULT_MAP_LIB_OPT),
OPT_STR(DEFAULT_OK_LINE),
diff -rupN perdition-1.18.orig/perdition/options.h perdition-1.18/perdition/options.h
--- perdition-1.18.orig/perdition/options.h 2009-11-26 16:05:18.000000000 -0800
+++ perdition-1.18/perdition/options.h 2012-08-27 18:52:55.000000000 -0700
@@ -148,7 +148,8 @@
#define DEFAULT_USERNAME_FROM_DATABASE 0
#define DEFAULT_QUERY_KEY NULL
#define DEFAULT_QUIET 0
-#define DEFAILT_LOG_PASSWD LOG_PASSWD_NEVER
+#define DEFAULT_LOG_PASSWD LOG_PASSWD_NEVER
+#define DEFAULT_SIMPLE_LOGIN 0
#ifdef WITH_SSL_SUPPORT
#define DEFAULT_SSL_CA_CHAIN_FILE NULL
#define RECOMMENDED_SSL_CA_CHAIN_FILE PERDITION_SYSCONFDIR \
@@ -214,6 +215,7 @@ typedef struct {
int protocol;
int quiet;
int server_resp_line;
+ int simple_login;
int strip_domain;
int timeout;
char *username;
@@ -280,6 +282,7 @@ typedef struct {
#define MASK2_EXPLICIT_DOMAIN (flag_t) 0x00000004
#define MASK2_LOG_PASSWD (flag_t) 0x00000008
#define MASK2_AUTHENTICATE_TIMEOUT (flag_t) 0x00000010
+#define MASK2_SIMPLE_LOGIN (flag_t) 0x00000020
#ifdef WITH_SSL_SUPPORT
/* options_t.ssl_mask entries */
@@ -329,6 +332,7 @@ typedef struct {
#define TAG_SSL_NO_CERT_VERIFY (int) 148
#define TAG_SSL_NO_CN_VERIFY (int) 149
#define TAG_AUTHENTICATE_TIMEOUT (int) 150
+#define TAG_SIMPLE_LOGIN (int) 151
/*Flag values for options()*/
diff -rupN perdition-1.18.orig/perdition/perdition.8 perdition-1.18/perdition/perdition.8
--- perdition-1.18.orig/perdition/perdition.8 2009-11-26 16:05:10.000000000 -0800
+++ perdition-1.18/perdition/perdition.8 2012-08-27 19:08:07.000000000 -0700
@@ -336,6 +336,11 @@ delimited by a ','. If multiple servers
used in a round robin fashion.
.br
(default "")
+.B \-\-simple_login:
+Use a simple one-line format to login to the outgoing imap server.
+Some imap servers do not support the more complex multi-line format. The
+simple login can not handle user names with special characters or spaces.
+.TP
.TP
.B \-\-pid_file FILENAME:
Path for pidfile. Must be a full path starting with a '/'.