pilerimport fixes

This commit is contained in:
SJ 2014-10-15 23:22:36 +02:00
parent 3aa0ebe4a6
commit eb2aa4df8f
5 changed files with 20 additions and 10 deletions

View File

@ -14,7 +14,7 @@
#define VERSION "1.1.1-pre"
#define BUILD 894
#define BUILD 895
#define HOSTID "mailarchiver"

View File

@ -273,6 +273,7 @@ struct import {
int start_position;
int import_job_id;
int remove_after_import;
int download_only;
int keep_eml;
long total_size;
time_t started, updated, finished;

View File

@ -259,7 +259,7 @@ int process_imap_folder(int sd, int *seq, char *folder, struct session_data *sda
read_response(sd, buf, sizeof(buf), seq, data, use_ssl);
}
unlink(filename);
if(data->import->download_only == 0) unlink(filename);
}
@ -290,7 +290,7 @@ int connect_to_imap_server(int sd, int *seq, char *username, char *password, int
SSL_library_init();
SSL_load_error_strings();
data->ctx = SSL_CTX_new(SSLv3_client_method());
data->ctx = SSL_CTX_new(TLSv1_client_method());
CHK_NULL(data->ctx, "internal SSL error");
data->ssl = SSL_new(data->ctx);
@ -300,7 +300,7 @@ int connect_to_imap_server(int sd, int *seq, char *username, char *password, int
n = SSL_connect(data->ssl);
CHK_SSL(n, "internal ssl error");
//printf("Cipher: %s\n", SSL_get_cipher(data->ssl));
printf("Cipher: %s\n", SSL_get_cipher(data->ssl));
server_cert = SSL_get_peer_certificate(data->ssl);
CHK_NULL(server_cert, "server cert error");

View File

@ -472,7 +472,7 @@ ENDE:
void usage(){
printf("usage: pilerimport [-c <config file>] -e <eml file> | -m <mailbox file> | -d <directory> | -i <imap server> | -K <pop3 server> | -u <imap username> -p <imap password> -P <imap port>\n");
printf(" [-x <folder1,folder2,....,folderN,>] [-f <imap foldername>] [-F <foldername>] [-b <batchlimit>] [-s <start positiion>] [-D] [-R] [-r] [-q]\n");
printf(" [-x <folder1,folder2,....,folderN,>] [-f <imap foldername>] [-F <foldername>] [-b <batchlimit>] [-s <start positiion>] [-D] [-o] [-R] [-r] [-q]\n");
exit(0);
}
@ -499,6 +499,7 @@ int main(int argc, char **argv){
import.started = import.updated = import.finished = import.remove_after_import = 0;
import.extra_recipient = NULL;
import.start_position = 1;
import.download_only = 0;
data.import = &import;
@ -530,6 +531,7 @@ int main(int argc, char **argv){
{"quiet", no_argument, 0, 'q' },
{"recursive", required_argument, 0, 'R' },
{"remove-after-import",no_argument, 0, 'r' },
{"only-download",no_argument, 0, 'o' },
{"gui-import", no_argument, 0, 'G' },
{"dry-run", no_argument, 0, 'D' },
{"help", no_argument, 0, 'h' },
@ -538,9 +540,9 @@ int main(int argc, char **argv){
int option_index = 0;
c = getopt_long(argc, argv, "c:m:M:e:d:i:K:u:p:P:x:F:f:a:b:s:GDRrqh?", long_options, &option_index);
c = getopt_long(argc, argv, "c:m:M:e:d:i:K:u:p:P:x:F:f:a:b:s:GDRroqh?", long_options, &option_index);
#else
c = getopt(argc, argv, "c:m:M:e:d:i:K:u:p:P:x:F:f:a:b:s:GDRrqh?");
c = getopt(argc, argv, "c:m:M:e:d:i:K:u:p:P:x:F:f:a:b:s:GDRroqh?");
#endif
if(c == -1) break;
@ -613,6 +615,11 @@ int main(int argc, char **argv){
data.import->remove_after_import = 1;
break;
case 'o' :
data.import->download_only = 1;
dryrun = 1;
break;
case 'b' :
data.import->batch_processing_limit = atoi(optarg);
break;

View File

@ -48,7 +48,7 @@ int connect_to_pop3_server(int sd, char *username, char *password, int port, str
SSL_library_init();
SSL_load_error_strings();
data->ctx = SSL_CTX_new(SSLv3_client_method());
data->ctx = SSL_CTX_new(TLSv1_client_method());
CHK_NULL(data->ctx, "internal SSL error");
data->ssl = SSL_new(data->ctx);
@ -58,6 +58,8 @@ int connect_to_pop3_server(int sd, char *username, char *password, int port, str
n = SSL_connect(data->ssl);
CHK_SSL(n, "internal ssl error");
printf("Cipher: %s\n", SSL_get_cipher(data->ssl));
server_cert = SSL_get_peer_certificate(data->ssl);
CHK_NULL(server_cert, "server cert error");
@ -129,7 +131,7 @@ int process_pop3_emails(int sd, struct session_data *sdata, struct __data *data,
snprintf(buf, sizeof(buf)-1, "RETR %d\r\n", i);
snprintf(filename, sizeof(filename)-1, "pop3-tmp-%d.txt", i);
snprintf(filename, sizeof(filename)-1, "pop3-tmp-%d-%d.txt", getpid(), i);
unlink(filename);
fd = open(filename, O_CREAT|O_EXCL|O_RDWR|O_TRUNC, S_IRUSR|S_IWUSR);
@ -210,7 +212,7 @@ int process_pop3_emails(int sd, struct session_data *sdata, struct __data *data,
update_import_job_stat(sdata, data);
}
unlink(filename);
if(data->import->download_only == 0) unlink(filename);
/* whether to quit after processing a batch of messages */