mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-08 10:51:58 +01:00
pilerimport fixes
This commit is contained in:
parent
3aa0ebe4a6
commit
eb2aa4df8f
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#define VERSION "1.1.1-pre"
|
#define VERSION "1.1.1-pre"
|
||||||
|
|
||||||
#define BUILD 894
|
#define BUILD 895
|
||||||
|
|
||||||
#define HOSTID "mailarchiver"
|
#define HOSTID "mailarchiver"
|
||||||
|
|
||||||
|
@ -273,6 +273,7 @@ struct import {
|
|||||||
int start_position;
|
int start_position;
|
||||||
int import_job_id;
|
int import_job_id;
|
||||||
int remove_after_import;
|
int remove_after_import;
|
||||||
|
int download_only;
|
||||||
int keep_eml;
|
int keep_eml;
|
||||||
long total_size;
|
long total_size;
|
||||||
time_t started, updated, finished;
|
time_t started, updated, finished;
|
||||||
|
@ -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);
|
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_library_init();
|
||||||
SSL_load_error_strings();
|
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");
|
CHK_NULL(data->ctx, "internal SSL error");
|
||||||
|
|
||||||
data->ssl = SSL_new(data->ctx);
|
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);
|
n = SSL_connect(data->ssl);
|
||||||
CHK_SSL(n, "internal ssl error");
|
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);
|
server_cert = SSL_get_peer_certificate(data->ssl);
|
||||||
CHK_NULL(server_cert, "server cert error");
|
CHK_NULL(server_cert, "server cert error");
|
||||||
|
@ -472,7 +472,7 @@ ENDE:
|
|||||||
|
|
||||||
void usage(){
|
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("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);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,6 +499,7 @@ int main(int argc, char **argv){
|
|||||||
import.started = import.updated = import.finished = import.remove_after_import = 0;
|
import.started = import.updated = import.finished = import.remove_after_import = 0;
|
||||||
import.extra_recipient = NULL;
|
import.extra_recipient = NULL;
|
||||||
import.start_position = 1;
|
import.start_position = 1;
|
||||||
|
import.download_only = 0;
|
||||||
|
|
||||||
data.import = &import;
|
data.import = &import;
|
||||||
|
|
||||||
@ -530,6 +531,7 @@ int main(int argc, char **argv){
|
|||||||
{"quiet", no_argument, 0, 'q' },
|
{"quiet", no_argument, 0, 'q' },
|
||||||
{"recursive", required_argument, 0, 'R' },
|
{"recursive", required_argument, 0, 'R' },
|
||||||
{"remove-after-import",no_argument, 0, 'r' },
|
{"remove-after-import",no_argument, 0, 'r' },
|
||||||
|
{"only-download",no_argument, 0, 'o' },
|
||||||
{"gui-import", no_argument, 0, 'G' },
|
{"gui-import", no_argument, 0, 'G' },
|
||||||
{"dry-run", no_argument, 0, 'D' },
|
{"dry-run", no_argument, 0, 'D' },
|
||||||
{"help", no_argument, 0, 'h' },
|
{"help", no_argument, 0, 'h' },
|
||||||
@ -538,9 +540,9 @@ int main(int argc, char **argv){
|
|||||||
|
|
||||||
int option_index = 0;
|
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
|
#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
|
#endif
|
||||||
|
|
||||||
if(c == -1) break;
|
if(c == -1) break;
|
||||||
@ -613,6 +615,11 @@ int main(int argc, char **argv){
|
|||||||
data.import->remove_after_import = 1;
|
data.import->remove_after_import = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'o' :
|
||||||
|
data.import->download_only = 1;
|
||||||
|
dryrun = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'b' :
|
case 'b' :
|
||||||
data.import->batch_processing_limit = atoi(optarg);
|
data.import->batch_processing_limit = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
@ -48,7 +48,7 @@ int connect_to_pop3_server(int sd, char *username, char *password, int port, str
|
|||||||
SSL_library_init();
|
SSL_library_init();
|
||||||
SSL_load_error_strings();
|
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");
|
CHK_NULL(data->ctx, "internal SSL error");
|
||||||
|
|
||||||
data->ssl = SSL_new(data->ctx);
|
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);
|
n = SSL_connect(data->ssl);
|
||||||
CHK_SSL(n, "internal ssl error");
|
CHK_SSL(n, "internal ssl error");
|
||||||
|
|
||||||
|
printf("Cipher: %s\n", SSL_get_cipher(data->ssl));
|
||||||
|
|
||||||
server_cert = SSL_get_peer_certificate(data->ssl);
|
server_cert = SSL_get_peer_certificate(data->ssl);
|
||||||
CHK_NULL(server_cert, "server cert error");
|
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(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);
|
unlink(filename);
|
||||||
|
|
||||||
fd = open(filename, O_CREAT|O_EXCL|O_RDWR|O_TRUNC, S_IRUSR|S_IWUSR);
|
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);
|
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 */
|
/* whether to quit after processing a batch of messages */
|
||||||
|
Loading…
Reference in New Issue
Block a user