2011-12-30 15:52:59 +01:00
|
|
|
/*
|
|
|
|
* pilerimport.c, SJ
|
|
|
|
*/
|
|
|
|
|
2012-08-09 10:13:57 +02:00
|
|
|
#define _FILE_OFFSET_BITS 64
|
|
|
|
|
2011-12-30 15:52:59 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2012-05-26 15:18:22 +02:00
|
|
|
#include <sys/socket.h>
|
2013-04-01 16:15:43 +02:00
|
|
|
#include <netdb.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <netinet/in.h>
|
2012-05-23 16:42:58 +02:00
|
|
|
#include <fcntl.h>
|
2012-01-03 00:19:43 +01:00
|
|
|
#include <dirent.h>
|
2011-12-30 15:52:59 +01:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <locale.h>
|
2012-08-21 21:57:39 +02:00
|
|
|
#include <getopt.h>
|
2011-12-30 15:52:59 +01:00
|
|
|
#include <syslog.h>
|
|
|
|
#include <piler.h>
|
|
|
|
|
|
|
|
|
2013-01-10 22:30:30 +01:00
|
|
|
#define SKIPLIST "junk,trash,spam,draft,"
|
2012-08-19 23:20:33 +02:00
|
|
|
#define MBOX_ARGS 1024
|
|
|
|
|
2012-01-03 00:19:43 +01:00
|
|
|
extern char *optarg;
|
|
|
|
extern int optind;
|
|
|
|
|
2013-08-23 13:02:51 +02:00
|
|
|
int dryrun=0;
|
|
|
|
int import_from_gui=0;
|
2014-05-04 10:34:00 +02:00
|
|
|
char *folder_imap=NULL;
|
2012-08-08 23:53:07 +02:00
|
|
|
|
2013-04-01 16:15:43 +02:00
|
|
|
int connect_to_imap_server(int sd, int *seq, char *username, char *password, int port, struct __data *data, int use_ssl);
|
2013-09-04 22:42:06 +02:00
|
|
|
int list_folders(int sd, int *seq, int use_ssl, struct __data *data);
|
2013-08-23 13:02:51 +02:00
|
|
|
int process_imap_folder(int sd, int *seq, char *folder, struct session_data *sdata, struct __data *data, int use_ssl, int dryrun, struct __config *cfg);
|
2013-04-01 16:15:43 +02:00
|
|
|
int connect_to_pop3_server(int sd, char *username, char *password, int port, struct __data *data, int use_ssl);
|
2013-08-23 13:02:51 +02:00
|
|
|
int process_pop3_emails(int sd, struct session_data *sdata, struct __data *data, int use_ssl, int dryrun, struct __config *cfg);
|
2013-09-25 22:08:38 +02:00
|
|
|
void send_imap_close(int sd, int *seq, struct __data *data, int use_ssl);
|
2012-11-24 23:02:08 +01:00
|
|
|
void close_connection(int sd, struct __data *data, int use_ssl);
|
2012-01-03 00:19:43 +01:00
|
|
|
|
2013-08-23 13:46:27 +02:00
|
|
|
void update_import_job_stat(struct session_data *sdata, struct __data *data);
|
2013-08-23 13:02:51 +02:00
|
|
|
|
2012-01-03 00:19:43 +01:00
|
|
|
|
|
|
|
int import_from_mailbox(char *mailbox, struct session_data *sdata, struct __data *data, struct __config *cfg){
|
|
|
|
FILE *F, *f=NULL;
|
2012-07-09 15:18:21 +02:00
|
|
|
int rc=ERR, tot_msgs=0, ret=OK;
|
2012-01-03 00:19:43 +01:00
|
|
|
char buf[MAXBUFSIZE], fname[SMALLBUFSIZE];
|
|
|
|
time_t t;
|
|
|
|
|
|
|
|
|
|
|
|
F = fopen(mailbox, "r");
|
|
|
|
if(!F){
|
|
|
|
printf("cannot open mailbox: %s\n", mailbox);
|
|
|
|
return rc;
|
2011-12-30 15:52:59 +01:00
|
|
|
}
|
|
|
|
|
2012-01-03 00:19:43 +01:00
|
|
|
t = time(NULL);
|
2011-12-30 15:52:59 +01:00
|
|
|
|
2012-01-03 00:19:43 +01:00
|
|
|
while(fgets(buf, sizeof(buf)-1, F)){
|
2011-12-30 15:52:59 +01:00
|
|
|
|
2012-01-03 00:19:43 +01:00
|
|
|
if(buf[0] == 'F' && buf[1] == 'r' && buf[2] == 'o' && buf[3] == 'm' && buf[4] == ' '){
|
|
|
|
tot_msgs++;
|
|
|
|
if(f){
|
|
|
|
fclose(f);
|
2012-12-03 13:27:14 +01:00
|
|
|
f = NULL;
|
2012-01-03 00:19:43 +01:00
|
|
|
rc = import_message(fname, sdata, data, cfg);
|
2013-01-24 09:54:20 +01:00
|
|
|
if(rc == ERR){
|
|
|
|
printf("error importing: '%s'\n", fname);
|
|
|
|
ret = ERR;
|
|
|
|
}
|
|
|
|
else unlink(fname);
|
2012-08-08 23:53:07 +02:00
|
|
|
|
2013-09-27 14:33:15 +02:00
|
|
|
if(data->quiet == 0) printf("processed: %7d\r", tot_msgs); fflush(stdout);
|
2012-01-03 00:19:43 +01:00
|
|
|
}
|
2011-12-30 15:52:59 +01:00
|
|
|
|
2012-01-03 00:19:43 +01:00
|
|
|
snprintf(fname, sizeof(fname)-1, "%ld-%d", t, tot_msgs);
|
|
|
|
f = fopen(fname, "w+");
|
|
|
|
continue;
|
|
|
|
}
|
2011-12-30 15:52:59 +01:00
|
|
|
|
2012-01-03 00:19:43 +01:00
|
|
|
if(f) fprintf(f, "%s", buf);
|
|
|
|
}
|
2011-12-30 15:52:59 +01:00
|
|
|
|
2012-01-03 00:19:43 +01:00
|
|
|
if(f){
|
|
|
|
fclose(f);
|
|
|
|
rc = import_message(fname, sdata, data, cfg);
|
2013-01-24 09:54:20 +01:00
|
|
|
if(rc == ERR){
|
|
|
|
printf("error importing: '%s'\n", fname);
|
|
|
|
ret = ERR;
|
|
|
|
}
|
|
|
|
else unlink(fname);
|
2012-08-08 23:53:07 +02:00
|
|
|
|
2013-09-27 14:33:15 +02:00
|
|
|
if(data->quiet == 0) printf("processed: %7d\r", tot_msgs); fflush(stdout);
|
2012-01-03 00:19:43 +01:00
|
|
|
}
|
2011-12-30 15:52:59 +01:00
|
|
|
|
2012-01-03 00:19:43 +01:00
|
|
|
fclose(F);
|
|
|
|
|
2012-08-21 21:57:39 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int import_mbox_from_dir(char *directory, struct session_data *sdata, struct __data *data, int *tot_msgs, struct __config *cfg){
|
|
|
|
DIR *dir;
|
|
|
|
struct dirent *de;
|
2012-09-03 17:12:02 +02:00
|
|
|
int rc=ERR, ret=OK, i=0;
|
2013-06-29 15:22:07 +02:00
|
|
|
int folder;
|
2012-08-21 21:57:39 +02:00
|
|
|
char fname[SMALLBUFSIZE];
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
dir = opendir(directory);
|
|
|
|
if(!dir){
|
|
|
|
printf("cannot open directory: %s\n", directory);
|
|
|
|
return ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
while((de = readdir(dir))){
|
|
|
|
if(strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) continue;
|
|
|
|
|
|
|
|
snprintf(fname, sizeof(fname)-1, "%s/%s", directory, de->d_name);
|
|
|
|
|
|
|
|
if(stat(fname, &st) == 0){
|
|
|
|
if(S_ISDIR(st.st_mode)){
|
2012-09-03 17:12:02 +02:00
|
|
|
folder = data->folder;
|
2012-08-21 21:57:39 +02:00
|
|
|
rc = import_mbox_from_dir(fname, sdata, data, tot_msgs, cfg);
|
2012-09-03 17:12:02 +02:00
|
|
|
data->folder = folder;
|
2012-08-21 21:57:39 +02:00
|
|
|
if(rc == ERR) ret = ERR;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
if(S_ISREG(st.st_mode)){
|
2012-09-03 17:12:02 +02:00
|
|
|
if(i == 0 && data->recursive_folder_names == 1){
|
2015-07-24 14:28:31 +02:00
|
|
|
folder = get_folder_id(sdata, data, fname, data->folder, cfg);
|
2013-06-29 15:22:07 +02:00
|
|
|
if(folder == ERR_FOLDER){
|
2015-07-24 14:28:31 +02:00
|
|
|
folder = add_new_folder(sdata, data, fname, data->folder, cfg);
|
2012-09-03 17:12:02 +02:00
|
|
|
|
2013-06-29 15:22:07 +02:00
|
|
|
if(folder == ERR_FOLDER){
|
2012-09-03 17:12:02 +02:00
|
|
|
printf("error: cannot get/add folder '%s' to parent id: %d\n", fname, data->folder);
|
|
|
|
return ERR;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
data->folder = folder;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-08-21 21:57:39 +02:00
|
|
|
rc = import_from_mailbox(fname, sdata, data, cfg);
|
|
|
|
if(rc == OK) (*tot_msgs)++;
|
|
|
|
else ret = ERR;
|
|
|
|
|
2012-09-03 17:12:02 +02:00
|
|
|
i++;
|
2012-08-21 21:57:39 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("%s is not a file\n", fname);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("cannot stat() %s\n", fname);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
closedir(dir);
|
2012-01-03 00:19:43 +01:00
|
|
|
|
2012-07-09 15:18:21 +02:00
|
|
|
return ret;
|
2012-01-03 00:19:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-08 23:53:07 +02:00
|
|
|
int import_from_maildir(char *directory, struct session_data *sdata, struct __data *data, int *tot_msgs, struct __config *cfg){
|
2012-01-03 00:19:43 +01:00
|
|
|
DIR *dir;
|
|
|
|
struct dirent *de;
|
2012-09-03 17:12:02 +02:00
|
|
|
int rc=ERR, ret=OK, i=0;
|
2013-06-29 15:22:07 +02:00
|
|
|
int folder;
|
2012-09-03 17:12:02 +02:00
|
|
|
char *p, fname[SMALLBUFSIZE];
|
2012-05-26 15:18:22 +02:00
|
|
|
struct stat st;
|
2012-01-03 00:19:43 +01:00
|
|
|
|
|
|
|
dir = opendir(directory);
|
|
|
|
if(!dir){
|
|
|
|
printf("cannot open directory: %s\n", directory);
|
2012-07-09 15:18:21 +02:00
|
|
|
return ERR;
|
2012-01-03 00:19:43 +01:00
|
|
|
}
|
|
|
|
|
2012-05-26 15:18:22 +02:00
|
|
|
|
2012-01-03 00:19:43 +01:00
|
|
|
while((de = readdir(dir))){
|
|
|
|
if(strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) continue;
|
|
|
|
|
|
|
|
snprintf(fname, sizeof(fname)-1, "%s/%s", directory, de->d_name);
|
|
|
|
|
2012-05-26 15:18:22 +02:00
|
|
|
if(stat(fname, &st) == 0){
|
|
|
|
if(S_ISDIR(st.st_mode)){
|
2012-09-03 17:12:02 +02:00
|
|
|
folder = data->folder;
|
2012-08-08 23:53:07 +02:00
|
|
|
rc = import_from_maildir(fname, sdata, data, tot_msgs, cfg);
|
2012-09-03 17:12:02 +02:00
|
|
|
data->folder = folder;
|
2012-07-09 15:18:21 +02:00
|
|
|
if(rc == ERR) ret = ERR;
|
2012-05-26 15:18:22 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-01-03 00:19:43 +01:00
|
|
|
|
2012-05-26 15:18:22 +02:00
|
|
|
if(S_ISREG(st.st_mode)){
|
2012-09-03 17:12:02 +02:00
|
|
|
if(i == 0 && data->recursive_folder_names == 1){
|
|
|
|
p = strrchr(directory, '/');
|
|
|
|
if(p) p++;
|
|
|
|
else {
|
|
|
|
printf("invalid directory name: '%s'\n", directory);
|
|
|
|
return ERR;
|
|
|
|
}
|
|
|
|
|
2015-07-24 14:28:31 +02:00
|
|
|
folder = get_folder_id(sdata, data, p, data->folder, cfg);
|
2013-06-29 15:22:07 +02:00
|
|
|
if(folder == ERR_FOLDER){
|
2015-07-24 14:28:31 +02:00
|
|
|
folder = add_new_folder(sdata, data, p, data->folder, cfg);
|
2012-09-03 17:12:02 +02:00
|
|
|
|
2013-06-29 15:22:07 +02:00
|
|
|
if(folder == ERR_FOLDER){
|
2012-09-03 17:12:02 +02:00
|
|
|
printf("error: cannot get/add folder '%s' to parent id: %d\n", p, data->folder);
|
|
|
|
return ERR;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
data->folder = folder;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-05-26 15:18:22 +02:00
|
|
|
rc = import_message(fname, sdata, data, cfg);
|
2012-08-08 23:53:07 +02:00
|
|
|
if(rc == OK) (*tot_msgs)++;
|
2013-01-24 09:54:20 +01:00
|
|
|
else {
|
|
|
|
printf("error importing: '%s'\n", fname);
|
|
|
|
ret = ERR;
|
|
|
|
}
|
|
|
|
|
2013-11-26 16:04:54 +01:00
|
|
|
if(data->import->remove_after_import == 1 && ret != ERR) unlink(fname);
|
2012-09-28 14:15:45 +02:00
|
|
|
|
2012-09-03 17:12:02 +02:00
|
|
|
i++;
|
|
|
|
|
2013-09-27 14:33:15 +02:00
|
|
|
if(data->quiet == 0) printf("processed: %7d\r", *tot_msgs); fflush(stdout);
|
2012-05-26 15:18:22 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("%s is not a file\n", fname);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("cannot stat() %s\n", fname);
|
|
|
|
}
|
2012-01-03 00:19:43 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
closedir(dir);
|
|
|
|
|
2012-07-09 15:18:21 +02:00
|
|
|
return ret;
|
2012-01-03 00:19:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-23 13:02:51 +02:00
|
|
|
int import_from_imap_server(char *server, char *username, char *password, int port, struct session_data *sdata, struct __data *data, char *skiplist, int dryrun, struct __config *cfg){
|
2013-09-04 22:42:06 +02:00
|
|
|
int i, rc=ERR, ret=OK, sd, seq=1, skipmatch, use_ssl=0;
|
2014-10-10 14:57:26 +02:00
|
|
|
char port_string[8], puf[SMALLBUFSIZE];
|
2013-04-01 16:15:43 +02:00
|
|
|
struct addrinfo hints, *res;
|
2013-09-04 22:42:06 +02:00
|
|
|
struct node *q;
|
|
|
|
|
2012-08-06 12:42:35 +02:00
|
|
|
|
2013-09-26 23:12:29 +02:00
|
|
|
inithash(data->imapfolders);
|
|
|
|
|
2013-04-01 16:15:43 +02:00
|
|
|
snprintf(port_string, sizeof(port_string)-1, "%d", port);
|
|
|
|
|
|
|
|
memset(&hints, 0, sizeof(hints));
|
|
|
|
hints.ai_family = AF_UNSPEC;
|
|
|
|
hints.ai_socktype = SOCK_STREAM;
|
|
|
|
|
|
|
|
if((rc = getaddrinfo(server, port_string, &hints, &res)) != 0){
|
|
|
|
printf("getaddrinfo for '%s': %s\n", server, gai_strerror(rc));
|
|
|
|
return ERR;
|
|
|
|
}
|
2012-10-27 14:40:25 +02:00
|
|
|
|
|
|
|
if(port == 993) use_ssl = 1;
|
|
|
|
|
|
|
|
|
2013-04-01 16:15:43 +02:00
|
|
|
if((sd = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) == -1){
|
2012-05-26 15:18:22 +02:00
|
|
|
printf("cannot create socket\n");
|
2013-04-01 16:15:43 +02:00
|
|
|
ret = ERR;
|
|
|
|
goto ENDE_IMAP;
|
2012-05-26 15:18:22 +02:00
|
|
|
}
|
|
|
|
|
2013-04-01 16:15:43 +02:00
|
|
|
if(connect(sd, res->ai_addr, res->ai_addrlen) == -1){
|
|
|
|
printf("connect()\n");
|
|
|
|
ret = ERR;
|
|
|
|
goto ENDE_IMAP;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(connect_to_imap_server(sd, &seq, username, password, port, data, use_ssl) == ERR){
|
2012-05-26 15:18:22 +02:00
|
|
|
close(sd);
|
2013-04-01 16:15:43 +02:00
|
|
|
ret = ERR;
|
|
|
|
goto ENDE_IMAP;
|
2012-05-26 15:18:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-15 09:36:09 +02:00
|
|
|
/*
|
|
|
|
* if the user gives -f <foldername>, then don't iterate through the folder list
|
|
|
|
* rather build the folderlist based on the <foldername> option, 2014.10.14, SJ
|
|
|
|
*/
|
|
|
|
|
|
|
|
if(folder_imap){
|
|
|
|
addnode(data->imapfolders, folder_imap);
|
|
|
|
} else {
|
|
|
|
rc = list_folders(sd, &seq, use_ssl, data);
|
|
|
|
if(rc == ERR) goto ENDE_IMAP;
|
|
|
|
}
|
2012-05-26 15:18:22 +02:00
|
|
|
|
|
|
|
|
2013-09-04 22:42:06 +02:00
|
|
|
for(i=0;i<MAXHASH;i++){
|
|
|
|
q = data->imapfolders[i];
|
|
|
|
while(q != NULL){
|
2012-08-06 12:42:35 +02:00
|
|
|
|
2013-09-04 22:42:06 +02:00
|
|
|
if(q && q->str && strlen(q->str) > 1){
|
2012-08-06 12:42:35 +02:00
|
|
|
|
2013-09-04 22:42:06 +02:00
|
|
|
skipmatch = 0;
|
2012-08-06 12:42:35 +02:00
|
|
|
|
2013-09-04 22:42:06 +02:00
|
|
|
if(skiplist && strlen(skiplist) > 0){
|
2014-05-06 22:29:27 +02:00
|
|
|
snprintf(puf, sizeof(puf)-1, "%s,", (char *)q->str);
|
|
|
|
if(strstr(skiplist, puf)) skipmatch = 1;
|
2013-09-04 22:42:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-04 10:34:00 +02:00
|
|
|
if(folder_imap && strstr(q->str, folder_imap) == NULL){
|
|
|
|
skipmatch = 1;
|
|
|
|
}
|
|
|
|
|
2013-09-04 22:42:06 +02:00
|
|
|
if(skipmatch == 1){
|
2013-09-27 14:33:15 +02:00
|
|
|
if(data->quiet == 0) printf("SKIPPING FOLDER: %s\n", (char *)q->str);
|
2013-09-04 22:42:06 +02:00
|
|
|
}
|
|
|
|
else {
|
2013-09-27 14:33:15 +02:00
|
|
|
if(data->quiet == 0) printf("processing folder: %s... ", (char *)q->str);
|
2012-08-06 12:42:35 +02:00
|
|
|
|
2013-09-04 22:42:06 +02:00
|
|
|
if(process_imap_folder(sd, &seq, q->str, sdata, data, use_ssl, dryrun, cfg) == ERR) ret = ERR;
|
|
|
|
}
|
2012-05-26 15:18:22 +02:00
|
|
|
|
2013-09-04 22:42:06 +02:00
|
|
|
}
|
2012-05-26 15:18:22 +02:00
|
|
|
|
2013-09-04 22:42:06 +02:00
|
|
|
q = q->r;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2012-05-26 15:18:22 +02:00
|
|
|
|
2013-09-25 22:08:38 +02:00
|
|
|
send_imap_close(sd, &seq, data, use_ssl);
|
2012-05-26 15:18:22 +02:00
|
|
|
|
2012-10-27 14:40:25 +02:00
|
|
|
close_connection(sd, data, use_ssl);
|
2012-05-26 15:18:22 +02:00
|
|
|
|
2013-04-01 16:15:43 +02:00
|
|
|
ENDE_IMAP:
|
|
|
|
freeaddrinfo(res);
|
|
|
|
|
2013-09-04 22:42:06 +02:00
|
|
|
clearhash(data->imapfolders);
|
|
|
|
|
2013-09-12 15:17:04 +02:00
|
|
|
data->import->status = 2;
|
|
|
|
|
2012-07-09 15:18:21 +02:00
|
|
|
return ret;
|
2012-05-26 15:18:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-23 13:02:51 +02:00
|
|
|
int import_from_pop3_server(char *server, char *username, char *password, int port, struct session_data *sdata, struct __data *data, int dryrun, struct __config *cfg){
|
2013-04-01 16:15:43 +02:00
|
|
|
int rc, ret=OK, sd, use_ssl=0;
|
2014-10-13 09:58:39 +02:00
|
|
|
char port_string[8];
|
2013-04-01 16:15:43 +02:00
|
|
|
struct addrinfo hints, *res;
|
|
|
|
|
|
|
|
snprintf(port_string, sizeof(port_string)-1, "%d", port);
|
|
|
|
|
|
|
|
memset(&hints, 0, sizeof(hints));
|
|
|
|
hints.ai_family = AF_UNSPEC;
|
|
|
|
hints.ai_socktype = SOCK_STREAM;
|
|
|
|
|
|
|
|
if((rc = getaddrinfo(server, port_string, &hints, &res)) != 0){
|
|
|
|
printf("getaddrinfo for '%s': %s\n", server, gai_strerror(rc));
|
|
|
|
return ERR;
|
|
|
|
}
|
2012-11-24 23:02:08 +01:00
|
|
|
|
|
|
|
if(port == 995) use_ssl = 1;
|
|
|
|
|
2013-04-01 16:15:43 +02:00
|
|
|
if((sd = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) == -1){
|
2012-11-24 23:02:08 +01:00
|
|
|
printf("cannot create socket\n");
|
2013-04-01 16:15:43 +02:00
|
|
|
ret = ERR;
|
|
|
|
goto ENDE_POP3;
|
2012-11-24 23:02:08 +01:00
|
|
|
}
|
|
|
|
|
2013-04-01 16:15:43 +02:00
|
|
|
if(connect(sd, res->ai_addr, res->ai_addrlen) == -1){
|
|
|
|
printf("connect()\n");
|
|
|
|
ret = ERR;
|
|
|
|
goto ENDE_POP3;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(connect_to_pop3_server(sd, username, password, port, data, use_ssl) == ERR){
|
2012-11-24 23:02:08 +01:00
|
|
|
close(sd);
|
2013-04-01 16:15:43 +02:00
|
|
|
ret = ERR;
|
|
|
|
goto ENDE_POP3;
|
2012-11-24 23:02:08 +01:00
|
|
|
}
|
|
|
|
|
2013-08-23 13:02:51 +02:00
|
|
|
if(process_pop3_emails(sd, sdata, data, use_ssl, dryrun, cfg) == ERR) ret = ERR;
|
2012-11-24 23:02:08 +01:00
|
|
|
|
|
|
|
close_connection(sd, data, use_ssl);
|
|
|
|
|
2013-04-01 16:15:43 +02:00
|
|
|
ENDE_POP3:
|
|
|
|
freeaddrinfo(res);
|
|
|
|
|
2012-11-24 23:02:08 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-04 23:42:07 +02:00
|
|
|
int read_gui_import_data(struct session_data *sdata, struct __data *data, char *skiplist, int dryrun, struct __config *cfg){
|
2013-08-23 13:02:51 +02:00
|
|
|
int rc=ERR;
|
|
|
|
char s_type[SMALLBUFSIZE], s_username[SMALLBUFSIZE], s_password[SMALLBUFSIZE], s_server[SMALLBUFSIZE];
|
|
|
|
|
|
|
|
memset(s_type, 0, sizeof(s_type));
|
|
|
|
memset(s_username, 0, sizeof(s_username));
|
|
|
|
memset(s_password, 0, sizeof(s_password));
|
|
|
|
memset(s_server, 0, sizeof(s_server));
|
|
|
|
|
2015-07-24 14:28:31 +02:00
|
|
|
if(prepare_sql_statement(sdata, &(data->stmt_generic), SQL_PREPARED_STMT_GET_GUI_IMPORT_JOBS, cfg) == ERR) return ERR;
|
2013-08-23 13:02:51 +02:00
|
|
|
|
|
|
|
p_bind_init(data);
|
|
|
|
|
|
|
|
if(p_exec_query(sdata, data->stmt_generic, data) == ERR) goto ENDE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
p_bind_init(data);
|
|
|
|
|
|
|
|
data->sql[data->pos] = (char *)&(data->import->import_job_id); data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++;
|
|
|
|
data->sql[data->pos] = &s_type[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s_type)-2; data->pos++;
|
|
|
|
data->sql[data->pos] = &s_username[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s_username)-2; data->pos++;
|
|
|
|
data->sql[data->pos] = &s_password[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s_password)-2; data->pos++;
|
|
|
|
data->sql[data->pos] = &s_server[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s_server)-2; data->pos++;
|
|
|
|
|
|
|
|
p_store_results(sdata, data->stmt_generic, data);
|
|
|
|
|
|
|
|
if(p_fetch_results(data->stmt_generic) == OK) rc = OK;
|
|
|
|
|
|
|
|
p_free_results(data->stmt_generic);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ENDE:
|
|
|
|
close_prepared_statement(data->stmt_generic);
|
|
|
|
|
2013-09-04 23:42:07 +02:00
|
|
|
data->import->processed_messages = 0;
|
|
|
|
data->import->total_messages = 0;
|
2013-08-23 13:02:51 +02:00
|
|
|
|
|
|
|
time(&(data->import->started));
|
|
|
|
data->import->status = 1;
|
2013-08-23 13:46:27 +02:00
|
|
|
update_import_job_stat(sdata, data);
|
2013-08-23 13:02:51 +02:00
|
|
|
|
|
|
|
if(strcmp(s_type, "pop3") == 0){
|
2013-08-23 13:46:27 +02:00
|
|
|
rc = import_from_pop3_server(s_server, s_username, s_password, 110, sdata, data, dryrun, cfg);
|
2013-09-04 23:42:07 +02:00
|
|
|
}
|
2013-08-23 13:46:27 +02:00
|
|
|
|
2013-09-04 23:42:07 +02:00
|
|
|
if(strcmp(s_type, "imap") == 0){
|
|
|
|
rc = import_from_imap_server(s_server, s_username, s_password, 143, sdata, data, skiplist, dryrun, cfg);
|
2013-08-23 13:02:51 +02:00
|
|
|
}
|
|
|
|
|
2013-09-26 13:11:36 +02:00
|
|
|
update_import_job_stat(sdata, data);
|
|
|
|
|
2013-09-09 15:02:30 +02:00
|
|
|
// don't set error in case of a problem, because it
|
|
|
|
// will scare users looking at the gui progressbar
|
|
|
|
/*if(rc == ERR){
|
2013-09-04 23:42:07 +02:00
|
|
|
data->import->status = 3;
|
|
|
|
update_import_job_stat(sdata, data);
|
2013-09-09 15:02:30 +02:00
|
|
|
}*/
|
2013-08-23 13:02:51 +02:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-03 00:19:43 +01:00
|
|
|
void usage(){
|
2015-11-04 08:50:41 +01:00
|
|
|
printf("\nusage: pilerimport\n\n");
|
|
|
|
printf(" [-c <config file>] Config file to use if not the default\n");
|
|
|
|
printf(" -e <eml file> EML file to import\n");
|
|
|
|
printf(" -m <mailbox file> Mbox file to import\n");
|
|
|
|
printf(" -d <dir> Directory with EML files to import\n");
|
|
|
|
printf(" -i <imap server> IMAP server to connect\n");
|
|
|
|
printf(" -K <pop3 server> POP3 server to connect\n");
|
|
|
|
printf(" -u <username> Username for imap/pop3 import\n");
|
|
|
|
printf(" -p <password> Password for imap/pop3 import\n");
|
|
|
|
printf(" -P <port> Port for imap/pop3 import (default: 143/110\n");
|
|
|
|
printf(" -t <timeout> Timeout in sec for imap/pop3 import\n");
|
|
|
|
printf(" -x <folder1,folder2,....folderN,> Comma separated list of imap folders to skip. Add the trailing comma!\n");
|
|
|
|
printf(" -f <imap folder> IMAP folder name to import\n");
|
2015-11-04 21:22:39 +01:00
|
|
|
printf(" -g <imap folder> Move email after import to this IMAP folder\n");
|
2015-11-04 08:50:41 +01:00
|
|
|
printf(" -F <folder> Piler folder name to assign to this import\n");
|
|
|
|
printf(" -b <batch limit> Import only this many emails\n");
|
|
|
|
printf(" -s <start position> Start importing POP3 emails from this position\n");
|
|
|
|
printf(" -D Dry-run, do not import anything\n");
|
|
|
|
printf(" -o Only download emails for POP3/IMAP import\n");
|
|
|
|
printf(" -R Recursive piler folder names\n");
|
|
|
|
printf(" -r Remove imported emails\n");
|
|
|
|
printf(" -q Quiet mode\n");
|
|
|
|
|
2012-01-03 00:19:43 +01:00
|
|
|
exit(0);
|
2011-12-30 15:52:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv){
|
2012-10-27 14:40:25 +02:00
|
|
|
int i, c, rc=0, n_mbox=0, tot_msgs=0, port=143;
|
2012-08-21 21:57:39 +02:00
|
|
|
char *configfile=CONFIG_FILE, *emlfile=NULL, *mboxdir=NULL, *mbox[MBOX_ARGS], *directory=NULL;
|
2012-11-24 23:02:08 +01:00
|
|
|
char *imapserver=NULL, *pop3server=NULL, *username=NULL, *password=NULL, *skiplist=SKIPLIST, *folder=NULL;
|
2011-12-30 15:52:59 +01:00
|
|
|
struct session_data sdata;
|
|
|
|
struct __config cfg;
|
|
|
|
struct __data data;
|
2013-08-23 13:02:51 +02:00
|
|
|
struct import import;
|
2011-12-30 15:52:59 +01:00
|
|
|
|
2012-08-19 23:20:33 +02:00
|
|
|
for(i=0; i<MBOX_ARGS; i++) mbox[i] = NULL;
|
2011-12-30 15:52:59 +01:00
|
|
|
|
2013-09-11 09:19:29 +02:00
|
|
|
srand(getpid());
|
|
|
|
|
2012-08-23 10:23:58 +02:00
|
|
|
data.folder = 0;
|
2012-09-03 17:12:02 +02:00
|
|
|
data.recursive_folder_names = 0;
|
2013-09-27 14:33:15 +02:00
|
|
|
data.quiet = 0;
|
2013-08-23 13:02:51 +02:00
|
|
|
|
2014-09-02 12:54:11 +02:00
|
|
|
|
|
|
|
import.import_job_id = import.total_messages = import.total_size = import.processed_messages = import.batch_processing_limit = 0;
|
2013-11-26 16:04:54 +01:00
|
|
|
import.started = import.updated = import.finished = import.remove_after_import = 0;
|
2015-11-04 21:22:39 +01:00
|
|
|
import.extra_recipient = import.move_folder = NULL;
|
2014-09-03 11:39:52 +02:00
|
|
|
import.start_position = 1;
|
2014-10-15 23:22:36 +02:00
|
|
|
import.download_only = 0;
|
2015-07-31 12:06:19 +02:00
|
|
|
import.timeout = 30;
|
2013-08-23 13:02:51 +02:00
|
|
|
|
|
|
|
data.import = &import;
|
|
|
|
|
2013-08-14 14:24:30 +02:00
|
|
|
inithash(data.mydomains);
|
|
|
|
initrules(data.archiving_rules);
|
|
|
|
initrules(data.retention_rules);
|
2015-08-28 22:50:28 +02:00
|
|
|
initrules(data.folder_rules);
|
2012-08-21 21:57:39 +02:00
|
|
|
|
|
|
|
while(1){
|
|
|
|
|
|
|
|
#ifdef _GNU_SOURCE
|
|
|
|
static struct option long_options[] =
|
|
|
|
{
|
|
|
|
{"config", required_argument, 0, 'c' },
|
|
|
|
{"eml", required_argument, 0, 'e' },
|
|
|
|
{"dir", required_argument, 0, 'd' },
|
|
|
|
{"mbox", required_argument, 0, 'm' },
|
|
|
|
{"mboxdir", required_argument, 0, 'M' },
|
|
|
|
{"imapserver", required_argument, 0, 'i' },
|
2012-11-24 23:02:08 +01:00
|
|
|
{"pop3server", required_argument, 0, 'K' },
|
2012-08-21 21:57:39 +02:00
|
|
|
{"username", required_argument, 0, 'u' },
|
|
|
|
{"password", required_argument, 0, 'p' },
|
2012-10-27 14:40:25 +02:00
|
|
|
{"port", required_argument, 0, 'P' },
|
2012-08-21 21:57:39 +02:00
|
|
|
{"skiplist", required_argument, 0, 'x' },
|
2012-08-23 10:23:58 +02:00
|
|
|
{"folder", required_argument, 0, 'F' },
|
2014-05-04 10:34:00 +02:00
|
|
|
{"folder_imap", required_argument, 0, 'f' },
|
2014-06-04 22:20:10 +02:00
|
|
|
{"add-recipient",required_argument, 0, 'a' },
|
2014-09-02 12:54:11 +02:00
|
|
|
{"batch-limit", required_argument, 0, 'b' },
|
2015-07-31 12:06:19 +02:00
|
|
|
{"timeout", required_argument, 0, 't' },
|
2014-09-03 11:39:52 +02:00
|
|
|
{"start-position",required_argument, 0, 's' },
|
2014-06-04 22:20:10 +02:00
|
|
|
{"quiet", no_argument, 0, 'q' },
|
2012-09-03 17:12:02 +02:00
|
|
|
{"recursive", required_argument, 0, 'R' },
|
2014-06-04 22:20:10 +02:00
|
|
|
{"remove-after-import",no_argument, 0, 'r' },
|
2015-11-04 21:22:39 +01:00
|
|
|
{"move-folder", required_argument, 0, 'g' },
|
2014-10-15 23:22:36 +02:00
|
|
|
{"only-download",no_argument, 0, 'o' },
|
2014-06-04 22:20:10 +02:00
|
|
|
{"gui-import", no_argument, 0, 'G' },
|
|
|
|
{"dry-run", no_argument, 0, 'D' },
|
2012-08-21 21:57:39 +02:00
|
|
|
{"help", no_argument, 0, 'h' },
|
|
|
|
{0,0,0,0}
|
|
|
|
};
|
|
|
|
|
|
|
|
int option_index = 0;
|
|
|
|
|
2015-11-04 21:22:39 +01:00
|
|
|
c = getopt_long(argc, argv, "c:m:M:e:d:i:K:u:p:P:x:F:f:a:b:t:s:g:GDRroqh?", long_options, &option_index);
|
2012-08-21 21:57:39 +02:00
|
|
|
#else
|
2015-11-04 21:22:39 +01:00
|
|
|
c = getopt(argc, argv, "c:m:M:e:d:i:K:u:p:P:x:F:f:a:b:t:s:g:GDRroqh?");
|
2012-08-21 21:57:39 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if(c == -1) break;
|
|
|
|
|
|
|
|
switch(c){
|
2012-01-03 00:19:43 +01:00
|
|
|
|
|
|
|
case 'c' :
|
|
|
|
configfile = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'e' :
|
|
|
|
emlfile = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'd' :
|
|
|
|
directory = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'm' :
|
2012-08-19 23:20:33 +02:00
|
|
|
if(n_mbox < MBOX_ARGS){
|
|
|
|
mbox[n_mbox++] = optarg;
|
|
|
|
} else {
|
|
|
|
printf("too many -m <mailbox> arguments: %s\n", optarg);
|
|
|
|
}
|
|
|
|
|
2012-01-03 00:19:43 +01:00
|
|
|
break;
|
|
|
|
|
2012-08-21 21:57:39 +02:00
|
|
|
case 'M' :
|
|
|
|
mboxdir = optarg;
|
|
|
|
break;
|
|
|
|
|
2012-05-26 15:18:22 +02:00
|
|
|
case 'i' :
|
|
|
|
imapserver = optarg;
|
|
|
|
break;
|
|
|
|
|
2012-11-24 23:02:08 +01:00
|
|
|
case 'K' :
|
|
|
|
pop3server = optarg;
|
|
|
|
if(port == 143) port = 110;
|
|
|
|
break;
|
|
|
|
|
2012-05-26 15:18:22 +02:00
|
|
|
case 'u' :
|
|
|
|
username = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'p' :
|
|
|
|
password = optarg;
|
|
|
|
break;
|
|
|
|
|
2012-10-27 14:40:25 +02:00
|
|
|
case 'P' :
|
|
|
|
port = atoi(optarg);
|
|
|
|
break;
|
|
|
|
|
2012-08-06 12:42:35 +02:00
|
|
|
case 'x' :
|
|
|
|
skiplist = optarg;
|
|
|
|
break;
|
|
|
|
|
2012-08-23 10:23:58 +02:00
|
|
|
case 'F' :
|
|
|
|
folder = optarg;
|
2012-08-21 21:57:39 +02:00
|
|
|
break;
|
|
|
|
|
2014-05-04 10:34:00 +02:00
|
|
|
case 'f' :
|
|
|
|
folder_imap = optarg;
|
|
|
|
break;
|
|
|
|
|
2012-09-03 17:12:02 +02:00
|
|
|
case 'R' :
|
|
|
|
data.recursive_folder_names = 1;
|
|
|
|
break;
|
|
|
|
|
2012-09-28 14:15:45 +02:00
|
|
|
case 'r' :
|
2013-11-26 16:04:54 +01:00
|
|
|
data.import->remove_after_import = 1;
|
2012-09-28 14:15:45 +02:00
|
|
|
break;
|
|
|
|
|
2015-11-04 21:22:39 +01:00
|
|
|
case 'g' :
|
|
|
|
data.import->move_folder = optarg;
|
|
|
|
break;
|
|
|
|
|
2014-10-15 23:22:36 +02:00
|
|
|
case 'o' :
|
|
|
|
data.import->download_only = 1;
|
|
|
|
dryrun = 1;
|
|
|
|
break;
|
|
|
|
|
2014-09-02 12:54:11 +02:00
|
|
|
case 'b' :
|
|
|
|
data.import->batch_processing_limit = atoi(optarg);
|
2015-07-31 12:06:19 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 't' :
|
|
|
|
data.import->timeout = atoi(optarg);
|
2014-09-02 12:54:11 +02:00
|
|
|
break;
|
|
|
|
|
2014-09-03 11:39:52 +02:00
|
|
|
case 's' :
|
|
|
|
if(atoi(optarg) < 1){
|
|
|
|
printf("invalid start position: %s\n", optarg);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
data.import->start_position = atoi(optarg);
|
|
|
|
break;
|
|
|
|
|
2014-06-04 22:20:10 +02:00
|
|
|
case 'a' :
|
|
|
|
data.import->extra_recipient = optarg;
|
|
|
|
break;
|
|
|
|
|
2013-08-23 13:02:51 +02:00
|
|
|
case 'G' :
|
|
|
|
import_from_gui = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'D' :
|
|
|
|
dryrun = 1;
|
|
|
|
break;
|
|
|
|
|
2012-09-28 14:15:45 +02:00
|
|
|
case 'q' :
|
2013-09-27 14:33:15 +02:00
|
|
|
data.quiet = 1;
|
2012-09-28 14:15:45 +02:00
|
|
|
break;
|
|
|
|
|
2012-01-03 00:19:43 +01:00
|
|
|
case 'h' :
|
|
|
|
case '?' :
|
|
|
|
usage();
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default :
|
|
|
|
break;
|
|
|
|
}
|
2011-12-30 15:52:59 +01:00
|
|
|
}
|
|
|
|
|
2012-01-03 00:19:43 +01:00
|
|
|
|
|
|
|
|
2013-08-23 13:02:51 +02:00
|
|
|
if(!mbox[0] && !mboxdir && !emlfile && !directory && !imapserver && !pop3server && import_from_gui == 0) usage();
|
2012-01-03 00:19:43 +01:00
|
|
|
|
2014-10-02 10:02:33 +02:00
|
|
|
if(!can_i_write_current_directory()) __fatal("cannot write current directory!");
|
|
|
|
|
2012-01-03 00:19:43 +01:00
|
|
|
cfg = read_config(configfile);
|
2011-12-30 15:52:59 +01:00
|
|
|
|
2014-02-24 10:07:20 +01:00
|
|
|
/* make sure we don't discard messages without a valid Message-Id when importing manually */
|
|
|
|
cfg.archive_emails_not_having_message_id = 1;
|
|
|
|
|
2011-12-30 15:52:59 +01:00
|
|
|
if(read_key(&cfg)){
|
|
|
|
printf("%s\n", ERR_READING_KEY);
|
2012-07-09 15:18:21 +02:00
|
|
|
return ERR;
|
2011-12-30 15:52:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-28 14:18:09 +02:00
|
|
|
if(open_database(&sdata, &cfg) == ERR) return 0;
|
|
|
|
|
2011-12-30 15:52:59 +01:00
|
|
|
|
|
|
|
setlocale(LC_CTYPE, cfg.locale);
|
|
|
|
|
2012-03-20 10:35:22 +01:00
|
|
|
(void) openlog("pilerimport", LOG_PID, LOG_MAIL);
|
|
|
|
|
2013-04-22 22:28:01 +02:00
|
|
|
#ifdef HAVE_MEMCACHED
|
|
|
|
memcached_init(&(data.memc), cfg.memcached_servers, 11211);
|
|
|
|
#endif
|
|
|
|
|
2012-08-23 10:23:58 +02:00
|
|
|
if(folder){
|
2015-07-24 14:28:31 +02:00
|
|
|
data.folder = get_folder_id(&sdata, &data, folder, 0, &cfg);
|
2012-08-23 10:23:58 +02:00
|
|
|
|
2013-06-29 15:22:07 +02:00
|
|
|
if(data.folder == ERR_FOLDER){
|
2015-07-24 14:28:31 +02:00
|
|
|
data.folder = add_new_folder(&sdata, &data, folder, 0, &cfg);
|
2012-08-23 10:23:58 +02:00
|
|
|
}
|
|
|
|
|
2013-06-29 15:22:07 +02:00
|
|
|
if(data.folder == ERR_FOLDER){
|
2012-08-23 10:23:58 +02:00
|
|
|
printf("error: cannot get/add folder '%s'\n", folder);
|
2013-04-28 14:18:09 +02:00
|
|
|
close_database(&sdata);
|
2012-08-23 10:23:58 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-07-24 14:28:31 +02:00
|
|
|
load_rules(&sdata, &data, data.archiving_rules, SQL_ARCHIVING_RULE_TABLE, &cfg);
|
|
|
|
load_rules(&sdata, &data, data.retention_rules, SQL_RETENTION_RULE_TABLE, &cfg);
|
2015-08-28 22:50:28 +02:00
|
|
|
load_rules(&sdata, &data, data.folder_rules, SQL_FOLDER_RULE_TABLE, &cfg);
|
2011-12-30 15:52:59 +01:00
|
|
|
|
2013-01-06 22:16:21 +01:00
|
|
|
load_mydomains(&sdata, &data, &cfg);
|
|
|
|
|
2012-01-03 00:19:43 +01:00
|
|
|
if(emlfile) rc = import_message(emlfile, &sdata, &data, &cfg);
|
2012-08-23 10:23:58 +02:00
|
|
|
|
2012-08-19 23:20:33 +02:00
|
|
|
if(mbox[0]){
|
|
|
|
for(i=0; i<n_mbox; i++){
|
|
|
|
rc = import_from_mailbox(mbox[i], &sdata, &data, &cfg);
|
|
|
|
}
|
|
|
|
}
|
2012-08-21 21:57:39 +02:00
|
|
|
if(mboxdir) rc = import_mbox_from_dir(mboxdir, &sdata, &data, &tot_msgs, &cfg);
|
2012-08-08 23:53:07 +02:00
|
|
|
if(directory) rc = import_from_maildir(directory, &sdata, &data, &tot_msgs, &cfg);
|
2013-08-23 13:02:51 +02:00
|
|
|
if(imapserver && username && password) rc = import_from_imap_server(imapserver, username, password, port, &sdata, &data, skiplist, dryrun, &cfg);
|
|
|
|
if(pop3server && username && password) rc = import_from_pop3_server(pop3server, username, password, port, &sdata, &data, dryrun, &cfg);
|
2013-09-04 23:42:07 +02:00
|
|
|
if(import_from_gui == 1) rc = read_gui_import_data(&sdata, &data, skiplist, dryrun, &cfg);
|
2011-12-30 15:52:59 +01:00
|
|
|
|
2013-08-14 14:24:30 +02:00
|
|
|
clearrules(data.archiving_rules);
|
|
|
|
clearrules(data.retention_rules);
|
2015-08-28 22:50:28 +02:00
|
|
|
clearrules(data.folder_rules);
|
2011-12-30 15:52:59 +01:00
|
|
|
|
2013-08-14 14:24:30 +02:00
|
|
|
clearhash(data.mydomains);
|
2013-07-12 22:54:45 +02:00
|
|
|
|
2013-04-28 14:18:09 +02:00
|
|
|
close_database(&sdata);
|
2011-12-30 15:52:59 +01:00
|
|
|
|
2013-09-27 14:33:15 +02:00
|
|
|
if(data.quiet == 0) printf("\n");
|
2012-08-21 21:57:39 +02:00
|
|
|
|
2012-07-09 15:18:21 +02:00
|
|
|
return rc;
|
2011-12-30 15:52:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|