Mercurial > masqmail
comparison src/spool.c @ 422:bdbedce60247
Remove `input' dir in spool dir. Spooled files are in spool dir directly now.
There's no more need to have any sub directories in the spool dir at all.
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Wed, 30 May 2012 10:27:10 +0200 |
parents | 0430194f7ef8 |
children |
comparison
equal
deleted
inserted
replaced
421:f37384470855 | 422:bdbedce60247 |
---|---|
94 { | 94 { |
95 FILE *in; | 95 FILE *in; |
96 gchar *spool_file; | 96 gchar *spool_file; |
97 | 97 |
98 DEBUG(5) debugf("spool_read_data entered\n"); | 98 DEBUG(5) debugf("spool_read_data entered\n"); |
99 spool_file = g_strdup_printf("%s/input/%s-D", conf.spool_dir, msg->uid); | 99 spool_file = g_strdup_printf("%s/%s-D", conf.spool_dir, msg->uid); |
100 DEBUG(5) debugf("reading data spool file '%s'\n", spool_file); | 100 DEBUG(5) debugf("reading data spool file '%s'\n", spool_file); |
101 in = fopen(spool_file, "r"); | 101 in = fopen(spool_file, "r"); |
102 if (!in) { | 102 if (!in) { |
103 logwrite(LOG_ALERT, "could not open spool data file %s: %s\n", spool_file, strerror(errno)); | 103 logwrite(LOG_ALERT, "could not open spool data file %s: %s\n", spool_file, strerror(errno)); |
104 return FALSE; | 104 return FALSE; |
125 { | 125 { |
126 FILE *in; | 126 FILE *in; |
127 gchar *spool_file; | 127 gchar *spool_file; |
128 | 128 |
129 /* header spool: */ | 129 /* header spool: */ |
130 spool_file = g_strdup_printf("%s/input/%s-H", conf.spool_dir, msg->uid); | 130 spool_file = g_strdup_printf("%s/%s-H", conf.spool_dir, msg->uid); |
131 in = fopen(spool_file, "r"); | 131 in = fopen(spool_file, "r"); |
132 if (!in) { | 132 if (!in) { |
133 logwrite(LOG_ALERT, "could not open spool header file %s: %s\n", | 133 logwrite(LOG_ALERT, "could not open spool header file %s: %s\n", |
134 spool_file, strerror(errno)); | 134 spool_file, strerror(errno)); |
135 return FALSE; | 135 return FALSE; |
230 gchar *spool_file, *tmp_file; | 230 gchar *spool_file, *tmp_file; |
231 FILE *out; | 231 FILE *out; |
232 gboolean ok = TRUE; | 232 gboolean ok = TRUE; |
233 | 233 |
234 /* header spool: */ | 234 /* header spool: */ |
235 tmp_file = g_strdup_printf("%s/input/%d-H.tmp", conf.spool_dir, getpid()); | 235 tmp_file = g_strdup_printf("%s/%d-H.tmp", conf.spool_dir, getpid()); |
236 DEBUG(4) debugf("tmp_file = %s\n", tmp_file); | 236 DEBUG(4) debugf("tmp_file = %s\n", tmp_file); |
237 | 237 |
238 if ((out = fopen(tmp_file, "w"))) { | 238 if ((out = fopen(tmp_file, "w"))) { |
239 DEBUG(6) debugf("opened tmp_file %s\n", tmp_file); | 239 DEBUG(6) debugf("opened tmp_file %s\n", tmp_file); |
240 | 240 |
280 if (errno != EINVAL) /* some fs do not support this.. I hope this also means that it is not necessary */ | 280 if (errno != EINVAL) /* some fs do not support this.. I hope this also means that it is not necessary */ |
281 ok = FALSE; | 281 ok = FALSE; |
282 } | 282 } |
283 fclose(out); | 283 fclose(out); |
284 if (ok) { | 284 if (ok) { |
285 spool_file = g_strdup_printf("%s/input/%s-H", conf.spool_dir, msg->uid); | 285 spool_file = g_strdup_printf("%s/%s-H", conf.spool_dir, msg->uid); |
286 DEBUG(4) debugf("spool_file = %s\n", spool_file); | 286 DEBUG(4) debugf("spool_file = %s\n", spool_file); |
287 ok = (rename(tmp_file, spool_file) != -1); | 287 ok = (rename(tmp_file, spool_file) != -1); |
288 g_free(spool_file); | 288 g_free(spool_file); |
289 } | 289 } |
290 } else { | 290 } else { |
317 /* header spool: */ | 317 /* header spool: */ |
318 ok = spool_write_header(msg); | 318 ok = spool_write_header(msg); |
319 | 319 |
320 if (ok && do_write_data) { | 320 if (ok && do_write_data) { |
321 /* data spool: */ | 321 /* data spool: */ |
322 tmp_file = g_strdup_printf("%s/input/%d-D.tmp", conf.spool_dir, getpid()); | 322 tmp_file = g_strdup_printf("%s/%d-D.tmp", conf.spool_dir, getpid()); |
323 DEBUG(4) debugf("tmp_file = %s\n", tmp_file); | 323 DEBUG(4) debugf("tmp_file = %s\n", tmp_file); |
324 | 324 |
325 if ((out = fopen(tmp_file, "w"))) { | 325 if ((out = fopen(tmp_file, "w"))) { |
326 fprintf(out, "%s\n", msg->uid); | 326 fprintf(out, "%s\n", msg->uid); |
327 for (list = g_list_first(msg->data_list); list != NULL; list = g_list_next(list)) { | 327 for (list = g_list_first(msg->data_list); list != NULL; list = g_list_next(list)) { |
336 ok = FALSE; | 336 ok = FALSE; |
337 } | 337 } |
338 } | 338 } |
339 fclose(out); | 339 fclose(out); |
340 if (ok) { | 340 if (ok) { |
341 spool_file = g_strdup_printf("%s/input/%s-D", conf.spool_dir, msg->uid); | 341 spool_file = g_strdup_printf("%s/%s-D", conf.spool_dir, msg->uid); |
342 DEBUG(4) debugf("spool_file = %s\n", spool_file); | 342 DEBUG(4) debugf("spool_file = %s\n", spool_file); |
343 ok = (rename(tmp_file, spool_file) != -1); | 343 ok = (rename(tmp_file, spool_file) != -1); |
344 g_free(spool_file); | 344 g_free(spool_file); |
345 } | 345 } |
346 } else { | 346 } else { |
426 if (!conf.run_as_user) { | 426 if (!conf.run_as_user) { |
427 set_euidgid(conf.mail_uid, conf.mail_gid, &saved_uid, &saved_gid); | 427 set_euidgid(conf.mail_uid, conf.mail_gid, &saved_uid, &saved_gid); |
428 } | 428 } |
429 | 429 |
430 /* header spool: */ | 430 /* header spool: */ |
431 spool_file = g_strdup_printf("%s/input/%s-H", conf.spool_dir, msg->uid); | 431 spool_file = g_strdup_printf("%s/%s-H", conf.spool_dir, msg->uid); |
432 if (unlink(spool_file) != 0) { | 432 if (unlink(spool_file) != 0) { |
433 logwrite(LOG_ALERT, "could not delete spool file %s: %s\n", spool_file, strerror(errno)); | 433 logwrite(LOG_ALERT, "could not delete spool file %s: %s\n", spool_file, strerror(errno)); |
434 } | 434 } |
435 g_free(spool_file); | 435 g_free(spool_file); |
436 | 436 |
437 /* data spool: */ | 437 /* data spool: */ |
438 spool_file = g_strdup_printf("%s/input/%s-D", conf.spool_dir, msg->uid); | 438 spool_file = g_strdup_printf("%s/%s-D", conf.spool_dir, msg->uid); |
439 if (unlink(spool_file) != 0) { | 439 if (unlink(spool_file) != 0) { |
440 logwrite(LOG_ALERT, "could not delete spool file %s: %s\n", spool_file, strerror(errno)); | 440 logwrite(LOG_ALERT, "could not delete spool file %s: %s\n", spool_file, strerror(errno)); |
441 } | 441 } |
442 g_free(spool_file); | 442 g_free(spool_file); |
443 | 443 |