DIR *queuedir;
struct dirent *dp;
char *mailname, *fromname, *toname, *reptoname, *from, *to, *repto;
- char *discardedname = NULL;
+ char *discardedname = NULL, *ch;
char *dirname = concatstr(2, listdir, "/queue/");
FILE *ffrom, *fto, *f;
pid_t pid;
}
while((dp = readdir(queuedir)) != NULL) {
- if(strchr(dp->d_name, '.'))
- continue;
-
if(stat(dp->d_name, &st) < 0) {
log_error(LOG_ARGS, "Could not stat(%s)",dp->d_name);
continue;
if(!S_ISREG(st.st_mode))
continue;
+ if(strchr(dp->d_name, '.')) {
+ mailname = strdup(dp->d_name);
+ ch = strchr(mailname, '.');
+ *ch = '\0';
+ if(stat(mailname, &st) < 0)
+ if(errno == ENOENT)
+ unlink(dp->d_name);
+ free(mailname);
+ continue;
+ }
+
mailname = concatstr(3, listdir, "/queue/", dp->d_name);
fromname = concatstr(2, mailname, ".mailfrom");
mlmmjsend = concatstr(2, bindir, "/mlmmj-send");
free(bindir);
- if(daemon(1,0) < 0) {
+ if(daemonize && daemon(1,0) < 0) {
log_error(LOG_ARGS, "Could not daemonize. Only one "
"maintenance run will be done.");
daemonize = 0;