comparison src/local.c @ 15:f671821d8222

code beautifying; 0 -> \0 if appropriate
author meillo@marmaro.de
date Thu, 06 Nov 2008 09:18:38 +0100
parents 26e34ae9a3e3
children a80ebfa16cd5
comparison
equal deleted inserted replaced
14:a8f3424347dc 15:f671821d8222
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software 15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */ 17 */
18 18
19 #include <sys/wait.h>
20
19 #include "masqmail.h" 21 #include "masqmail.h"
20 #include "peopen.h" 22 #include "peopen.h"
21 #include <sys/wait.h>
22 23
23 static void 24 static void
24 message_stream(FILE * out, message * msg, GList * hdr_list, guint flags) 25 message_stream(FILE * out, message * msg, GList * hdr_list, guint flags)
25 { 26 {
26 time_t now = time(NULL); 27 time_t now = time(NULL);
90 lock.l_whence = SEEK_END; 91 lock.l_whence = SEEK_END;
91 lock.l_start = lock.l_len = 0; 92 lock.l_start = lock.l_len = 0;
92 if (fcntl(fileno(out), F_SETLK, &lock) != -1) { 93 if (fcntl(fileno(out), F_SETLK, &lock) != -1) {
93 #endif 94 #endif
94 fchmod(fileno(out), 0600); 95 fchmod(fileno(out), 0600);
95
96 message_stream(out, msg, hdr_list, MSGSTR_FROMLINE | MSGSTR_FROMHACK); 96 message_stream(out, msg, hdr_list, MSGSTR_FROMLINE | MSGSTR_FROMHACK);
97
98 ok = TRUE; 97 ok = TRUE;
99 98
100 /* close when still user */ 99 /* close when still user */
101 fclose(out); 100 fclose(out);
102 #ifdef USE_LIBLOCKFILE 101 #ifdef USE_LIBLOCKFILE
209 g_free(path1); 208 g_free(path1);
210 } 209 }
211 if (i == 3) { 210 if (i == 3) {
212 FILE *out; 211 FILE *out;
213 mode_t saved_mode = umask(066); 212 mode_t saved_mode = umask(066);
214 /* the qmail style unique works only if delivering 213 /* the qmail style unique works only if delivering with different process.
215 with different process. We do not fork for each delivery, 214 We do not fork for each delivery, so our uid is more unique.
216 so our uid is more unique. Hope it is compatible with all 215 Hope it is compatible with all MUAs.
217 MUAs.
218 */ 216 */
219 gchar *filename = g_strdup_printf("%s/tmp/%s.%s", path, msg->uid, conf.host_name); 217 gchar *filename = g_strdup_printf("%s/tmp/%s.%s", path, msg->uid, conf.host_name);
220 218
221 DEBUG(5) debugf("filename = %s\n", filename); 219 DEBUG(5) debugf("filename = %s\n", filename);
222 220
225 message_stream(out, msg, hdr_list, flags); 223 message_stream(out, msg, hdr_list, flags);
226 ok = TRUE; 224 ok = TRUE;
227 if (fflush(out) == EOF) 225 if (fflush(out) == EOF)
228 ok = FALSE; 226 ok = FALSE;
229 else if (fdatasync(fileno(out)) != 0) { 227 else if (fdatasync(fileno(out)) != 0) {
230 if (errno != EINVAL) /* some fs do not support this.. I hope this also means that it is not necessary */ 228 if (errno != EINVAL)
229 /* some fs do not support this.. I hope this also means that it is not necessary */
231 ok = FALSE; 230 ok = FALSE;
232 } 231 }
233 fclose(out); 232 fclose(out);
234 if (rename(filename, newname) != 0) { 233 if (rename(filename, newname) != 0) {
235 ok = FALSE; 234 ok = FALSE;