masqmail-0.2
changeset 15:f671821d8222
code beautifying; 0 -> \0 if appropriate
author | meillo@marmaro.de |
---|---|
date | Thu, 06 Nov 2008 09:18:38 +0100 |
parents | a8f3424347dc |
children | 163aa299bedb |
files | src/deliver.c src/expand.c src/fail_msg.c src/get.c src/header.c src/listen.c src/local.c src/log.c src/lookup.c src/online.c src/parse.c src/peopen.c src/permissions.c src/pop3_in.c src/queue.c src/readsock.c src/rewrite.c src/route.c src/smtp_in.c src/smtp_out.c src/spool.c src/tables.c src/timeival.c |
diffstat | 23 files changed, 136 insertions(+), 179 deletions(-) [+] |
line diff
1.1 --- a/src/deliver.c Wed Oct 29 21:21:26 2008 +0100 1.2 +++ b/src/deliver.c Thu Nov 06 09:18:38 2008 +0100 1.3 @@ -16,15 +16,15 @@ 1.4 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 1.5 */ 1.6 1.7 -#include "masqmail.h" 1.8 -#include "smtp_out.h" 1.9 #include <fnmatch.h> 1.10 #include <sysexits.h> 1.11 #include <netdb.h> 1.12 1.13 +#include "masqmail.h" 1.14 +#include "smtp_out.h" 1.15 + 1.16 /* collect failed/defered rcpts for failure/warning messages */ 1.17 -/* returns TRUE if either there are no failures or a 1.18 - failure message has been successfully sent */ 1.19 +/* returns TRUE if either there are no failures or a failure message has been successfully sent */ 1.20 gboolean 1.21 delivery_failures(message * msg, GList * rcpt_list, gchar * err_fmt, ...) 1.22 { 1.23 @@ -92,11 +92,8 @@ 1.24 address *ret_path = msg->return_path; 1.25 header *retpath_hdr, *envto_hdr; 1.26 1.27 - /* we need a private copy of the hdr list because we add headers here 1.28 - that belong to the rcpt only. 1.29 - g_list_copy copies only the nodes, so it is safe to 1.30 - g_list_free it 1.31 - */ 1.32 + /* we need a private copy of the hdr list because we add headers here that belong to the rcpt only. 1.33 + g_list_copy copies only the nodes, so it is safe to g_list_free it */ 1.34 hdr_list = g_list_copy(msg->hdr_list); 1.35 retpath_hdr = create_header(HEAD_ENVELOPE_TO, "Envelope-to: %s\n", addr_string(env_addr)); 1.36 envto_hdr = create_header(HEAD_RETURN_PATH, "Return-path: %s\n", addr_string(ret_path)); 1.37 @@ -109,7 +106,8 @@ 1.38 if (pipe_out(msg, hdr_list, rcpt, &(rcpt->local_part[1]), 1.39 (conf.pipe_fromline ? MSGSTR_FROMLINE : 0) 1.40 | (conf.pipe_fromhack ? MSGSTR_FROMHACK : 0))) { 1.41 - logwrite(LOG_NOTICE, "%s => %s <%s@%s> with pipe\n", msg->uid, rcpt->local_part, env_addr->local_part, env_addr->domain); 1.42 + logwrite(LOG_NOTICE, "%s => %s <%s@%s> with pipe\n", 1.43 + msg->uid, rcpt->local_part, env_addr->local_part, env_addr->domain); 1.44 addr_mark_delivered(rcpt); 1.45 ok = TRUE; 1.46 } else { 1.47 @@ -216,9 +214,7 @@ 1.48 return ok; 1.49 } 1.50 1.51 -/* make a list of rcpt's of a message that are local 1.52 - return a new copy of the list 1.53 -*/ 1.54 +/* make a list of rcpt's of a message that are local return a new copy of the list */ 1.55 void 1.56 msg_rcptlist_local(GList * rcpt_list, GList ** p_local_list, GList ** p_nonlocal_list) 1.57 { 1.58 @@ -315,11 +311,9 @@ 1.59 return ok; 1.60 } 1.61 1.62 -/* deliver list of messages to one host 1.63 - and finishes them if the message was delivered to at least one rcpt. 1.64 +/* deliver list of messages to one host and finishes them if the message was delivered to at least one rcpt. 1.65 Returns TRUE if at least one msg was delivered to at least one rcpt. 1.66 */ 1.67 - 1.68 gboolean 1.69 deliver_msglist_host_smtp(connect_route * route, GList * msgout_list, gchar * host, GList * res_list) 1.70 { 1.71 @@ -368,8 +362,7 @@ 1.72 gboolean flag, ok_msg = FALSE, ok_fail = FALSE; 1.73 message *msg = msgout->msg; 1.74 1.75 - /* we may have to read the data at this point 1.76 - and remember if we did */ 1.77 + /* we may have to read the data at this point and remember if we did */ 1.78 flag = (msg->data_list == NULL); 1.79 if (flag) { 1.80 if (!spool_read_data(msg)) { 1.81 @@ -380,7 +373,8 @@ 1.82 1.83 smtp_out_msg(psb, msg, msgout->return_path, msgout->rcpt_list, msgout->hdr_list); 1.84 1.85 - ok_fail = delivery_failures(msg, msgout->rcpt_list, "while connected with %s, the server replied\n\t%s", host, psb->buffer); 1.86 + ok_fail = delivery_failures(msg, msgout->rcpt_list, 1.87 + "while connected with %s, the server replied\n\t%s", host, psb->buffer); 1.88 1.89 if ((psb->error == smtp_eof) 1.90 || (psb->error == smtp_timeout)) { 1.91 @@ -437,11 +431,9 @@ 1.92 addr_mark_defered(rcpt); 1.93 } 1.94 if (route->wrapper 1.95 - ? delivery_failures(msgout->msg, msgout->rcpt_list, 1.96 - "could not open wrapper:\n\t%s", 1.97 + ? delivery_failures(msgout->msg, msgout->rcpt_list, "could not open wrapper:\n\t%s", 1.98 strerror(errno)) 1.99 - : delivery_failures(msgout->msg, msgout->rcpt_list, 1.100 - "could not open connection to %s:%d :\n\t%s", 1.101 + : delivery_failures(msgout->msg, msgout->rcpt_list, "could not open connection to %s:%d :\n\t%s", 1.102 host, port, h_errno != 0 ? hstrerror(h_errno) : strerror(errno))) 1.103 deliver_finish(msgout); 1.104 } 1.105 @@ -470,8 +462,7 @@ 1.106 { 1.107 gboolean ok = FALSE; 1.108 1.109 - DEBUG(5) 1.110 - debugf("deliver_route_msgout_list entered, route->name = %s\n", route->name); 1.111 + DEBUG(5) debugf("deliver_route_msgout_list entered, route->name = %s\n", route->name); 1.112 1.113 if (route->mail_host != NULL) { 1.114 /* this is easy... */ 1.115 @@ -506,8 +497,7 @@ 1.116 1.117 /* 1.118 calls route_prepare_msg() 1.119 - delivers messages in msg_list using route 1.120 - by calling deliver_route_msgout_list() 1.121 + delivers messages in msg_list using route by calling deliver_route_msgout_list() 1.122 */ 1.123 gboolean 1.124 deliver_route_msg_list(connect_route * route, GList * msgout_list) 1.125 @@ -524,12 +514,10 @@ 1.126 GList *rcpt_list_non_delivered = NULL; 1.127 GList *rcpt_node; 1.128 1.129 - /* we have to delete already delivered rcpt's 1.130 - because a previous route may have delivered to it */ 1.131 + /* we have to delete already delivered rcpt's because a previous route may have delivered to it */ 1.132 foreach(msgout_cloned->rcpt_list, rcpt_node) { 1.133 address *rcpt = (address *) (rcpt_node->data); 1.134 - /* failed addresses already have been bounced 1.135 - - there should be a better way to handle those. */ 1.136 + /* failed addresses already have been bounced - there should be a better way to handle those. */ 1.137 if (!addr_is_delivered(rcpt) && !addr_is_failed(rcpt) 1.138 && !(rcpt->flags & ADDR_FLAG_LAST_ROUTE)) 1.139 rcpt_list_non_delivered = g_list_append(rcpt_list_non_delivered, rcpt); 1.140 @@ -591,10 +579,9 @@ 1.141 } 1.142 } 1.143 1.144 -/* after delivery attempts, we check if there are any 1.145 - rcpt addresses left in the message. 1.146 - If all addresses have been completed, the spool files will 1.147 - be deleted, otherwise the header spool will be written back. 1.148 +/* after delivery attempts, we check if there are any rcpt addresses left in the message. 1.149 + If all addresses have been completed, the spool files will be deleted, 1.150 + otherwise the header spool will be written back. 1.151 We never changed the data spool, so there is no need to write that back. 1.152 1.153 returns TRUE if all went well. 1.154 @@ -616,10 +603,8 @@ 1.155 if (!addr_is_finished_children(rcpt)) 1.156 finished = FALSE; 1.157 else { 1.158 - /* if ALL children have been delivered, 1.159 - mark parent as delivered. 1.160 - if there is one or more not delivered, 1.161 - it must have failed, we mark the parent as failed as well. 1.162 + /* if ALL children have been delivered, mark parent as delivered. 1.163 + if there is one or more not delivered, it must have failed, we mark the parent as failed as well. 1.164 */ 1.165 if (addr_is_delivered_children(rcpt)) { 1.166 addr_mark_delivered(rcpt);
2.1 --- a/src/expand.c Wed Oct 29 21:21:26 2008 +0100 2.2 +++ b/src/expand.c Thu Nov 06 09:18:38 2008 +0100 2.3 @@ -96,7 +96,7 @@ 2.4 j++; 2.5 } 2.6 } 2.7 - *vq = 0; 2.8 + *vq = '\0'; 2.9 2.10 if (j < MAX_VAR) { 2.11 /* search var */ 2.12 @@ -120,7 +120,7 @@ 2.13 p++; 2.14 } 2.15 } 2.16 - *q = 0; 2.17 + *q = '\0'; 2.18 2.19 if (i >= (result_len - 1)) 2.20 return -3;
3.1 --- a/src/fail_msg.c Wed Oct 29 21:21:26 2008 +0100 3.2 +++ b/src/fail_msg.c Thu Nov 06 09:18:38 2008 +0100 3.3 @@ -29,7 +29,7 @@ 3.4 address *ret_path = NULL; 3.5 3.6 /* do not bounce bounces, send to postmaster instead */ 3.7 - if (msg->return_path->local_part[0] == 0) { 3.8 + if (msg->return_path->local_part[0] == '\0') { 3.9 GList *node; 3.10 3.11 ret_path = create_address_qualified("postmaster", TRUE, conf.host_name); 3.12 @@ -79,8 +79,7 @@ 3.13 fputs(hdr->header, out); 3.14 } 3.15 } else if (strncmp(fmt, "@msg_body", 9) == 0) { 3.16 - /* we may have to read the data at this point 3.17 - and remember if we did */ 3.18 + /* we may have to read the data at this point and remember if we did */ 3.19 gboolean flag = (msg->data_list == NULL); 3.20 if (flag) { 3.21 if (!spool_read_data(msg)) {
4.1 --- a/src/get.c Wed Oct 29 21:21:26 2008 +0100 4.2 +++ b/src/get.c Thu Nov 06 09:18:38 2008 +0100 4.3 @@ -62,8 +62,10 @@ 4.4 and the server name, to prevent more than one connection at the same time 4.5 to the same server and the same user. This way concurrent connections 4.6 are possible to different servers or different users */ 4.7 - hitch_name = g_strdup_printf("%s/masqmail-get-%s@%s-%d.lock", conf.lock_dir, gc->login_user, gc->server_name, getpid()); 4.8 - lock_name = g_strdup_printf("%s/masqmail-get-%s@%s.lock", conf.lock_dir, gc->login_user, gc->server_name); 4.9 + hitch_name = g_strdup_printf("%s/masqmail-get-%s@%s-%d.lock", 4.10 + conf.lock_dir, gc->login_user, gc->server_name, getpid()); 4.11 + lock_name = g_strdup_printf("%s/masqmail-get-%s@%s.lock", 4.12 + conf.lock_dir, gc->login_user, gc->server_name); 4.13 4.14 ok = dot_lock(lock_name, hitch_name); 4.15 if (!ok) 4.16 @@ -98,7 +100,8 @@ 4.17 static gboolean 4.18 get_unlock(get_conf * gc) 4.19 { 4.20 - gchar *lock_name lock_name = g_strdup_printf("%s/masqmail-get-%s@%s.lock", conf.lock_dir, gc->login_user, gc->server_name); 4.21 + gchar *lock_name lock_name = g_strdup_printf("%s/masqmail-get-%s@%s.lock", 4.22 + conf.lock_dir, gc->login_user, gc->server_name); 4.23 4.24 dot_unlock(lock_name); 4.25 g_free(lock_name); 4.26 @@ -109,7 +112,8 @@ 4.27 static void 4.28 get_unlock(get_conf * gc, int fd) 4.29 { 4.30 - gchar *lock_name = g_strdup_printf("%s/masqmail-get-%s@%s.lock", conf.lock_dir, gc->login_user, gc->server_name); 4.31 + gchar *lock_name = g_strdup_printf("%s/masqmail-get-%s@%s.lock", 4.32 + conf.lock_dir, gc->login_user, gc->server_name); 4.33 4.34 flock(fd, LOCK_UN); 4.35 close(fd); 4.36 @@ -351,8 +355,7 @@ 4.37 } 4.38 } 4.39 } else { 4.40 - /* If select returns 0, the interval time has elapsed. 4.41 - We start a new get process */ 4.42 + /* If select returns 0, the interval time has elapsed. We start a new get process */ 4.43 int pid; 4.44 signal(SIGCHLD, sigchld_handler); 4.45 if ((pid = fork()) == 0) { 4.46 @@ -384,7 +387,8 @@ 4.47 ok = pop3_login(gc->server_name, gc->server_port, resolve_list, gc->login_user, gc->login_pass, flags); 4.48 } else if (strcmp(gc->protocol, "apop") == 0) { 4.49 DEBUG(3) debugf ("attempting to login for user %s, host = %s with apop\n", gc->login_user, gc->server_name); 4.50 - ok = pop3_login(gc->server_name, gc->server_port, resolve_list, gc->login_user, gc->login_pass, flags | POP3_FLAG_APOP); 4.51 + ok = pop3_login(gc->server_name, gc->server_port, resolve_list, gc->login_user, 4.52 + gc->login_pass, flags | POP3_FLAG_APOP); 4.53 } else { 4.54 logwrite(LOG_ALERT, "get protocol %s unknown\n", gc->protocol); 4.55 }
5.1 --- a/src/header.c Wed Oct 29 21:21:26 2008 +0100 5.2 +++ b/src/header.c Thu Nov 06 09:18:38 2008 +0100 5.3 @@ -18,30 +18,18 @@ 5.4 #include "masqmail.h" 5.5 5.6 header_name header_names[] = { 5.7 - {"From", HEAD_FROM,} 5.8 - , 5.9 - {"Sender", HEAD_SENDER,} 5.10 - , 5.11 - {"To", HEAD_TO,} 5.12 - , 5.13 - {"Cc", HEAD_CC,} 5.14 - , 5.15 - {"Bcc", HEAD_BCC,} 5.16 - , 5.17 - {"Date", HEAD_DATE,} 5.18 - , 5.19 - {"Message-Id", HEAD_MESSAGE_ID,} 5.20 - , 5.21 - {"Reply-To", HEAD_REPLY_TO,} 5.22 - , 5.23 - {"Subject", HEAD_SUBJECT,} 5.24 - , 5.25 - {"Return-Path", HEAD_RETURN_PATH,} 5.26 - , 5.27 - {"Envelope-To", HEAD_ENVELOPE_TO,} 5.28 - , 5.29 - {"Received", HEAD_RECEIVED} 5.30 - , 5.31 + {"From", HEAD_FROM,}, 5.32 + {"Sender", HEAD_SENDER,}, 5.33 + {"To", HEAD_TO,}, 5.34 + {"Cc", HEAD_CC,}, 5.35 + {"Bcc", HEAD_BCC,}, 5.36 + {"Date", HEAD_DATE,}, 5.37 + {"Message-Id", HEAD_MESSAGE_ID,}, 5.38 + {"Reply-To", HEAD_REPLY_TO,}, 5.39 + {"Subject", HEAD_SUBJECT,}, 5.40 + {"Return-Path", HEAD_RETURN_PATH,}, 5.41 + {"Envelope-To", HEAD_ENVELOPE_TO,}, 5.42 + {"Received", HEAD_RECEIVED}, 5.43 }; 5.44 5.45 /* this was borrowed from exim and slightly changed */ 5.46 @@ -100,7 +88,7 @@ 5.47 5.48 while (*p != ':' && q < buf + 63 && *p) 5.49 *(q++) = *(p++); 5.50 - *q = 0; 5.51 + *q = '\0'; 5.52 5.53 if (strcasecmp(buf, hdr_str) == 0) 5.54 found_list = g_list_append(found_list, hdr); 5.55 @@ -149,7 +137,7 @@ 5.56 q = tmp_hdr; 5.57 5.58 if (p[len - 1] == '\n') 5.59 - p[len - 1] = 0; 5.60 + p[len - 1] = '\0'; 5.61 5.62 while (*p) { 5.63 gint i, l; 5.64 @@ -184,7 +172,7 @@ 5.65 i++; 5.66 } 5.67 *(q++) = '\n'; 5.68 - *(q++) = *(p++); /* this is either space, tab or 0 */ 5.69 + *(q++) = *(p++); /* this is either space, tab or 0 */ 5.70 } 5.71 { 5.72 gchar *new_hdr; 5.73 @@ -257,7 +245,7 @@ 5.74 5.75 while (*p && (*p != ':') && (q < buf + 63)) 5.76 *(q++) = *(p++); 5.77 - *q = 0; 5.78 + *q = '\0'; 5.79 5.80 if (*p != ':') 5.81 return NULL;
6.1 --- a/src/listen.c Wed Oct 29 21:21:26 2008 +0100 6.2 +++ b/src/listen.c Thu Nov 06 09:18:38 2008 +0100 6.3 @@ -16,10 +16,11 @@ 6.4 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 6.5 */ 6.6 6.7 -#include "masqmail.h" 6.8 #include <sys/wait.h> 6.9 #include <sys/types.h> 6.10 6.11 +#include "masqmail.h" 6.12 + 6.13 static int volatile sighup_seen = 0; 6.14 6.15 static void 6.16 @@ -132,8 +133,7 @@ 6.17 signal(SIGHUP, sighup_handler); 6.18 signal(SIGCHLD, sigchld_handler); 6.19 6.20 - /* now that we have our socket(s), 6.21 - we can give up root privileges */ 6.22 + /* now that we have our socket(s), we can give up root privileges */ 6.23 if (!conf.run_as_user) { 6.24 if (setegid(conf.mail_gid) != 0) { 6.25 logwrite(LOG_ALERT, "could not change gid to %d: %s\n", conf.mail_gid, strerror(errno)); 6.26 @@ -172,8 +172,7 @@ 6.27 } 6.28 } 6.29 /* Block until input arrives on one or more active sockets, 6.30 - or signal arrives, 6.31 - or queuing interval time elapsed (if qival > 0) */ 6.32 + or signal arrives, or queuing interval time elapsed (if qival > 0) */ 6.33 read_fd_set = active_fd_set; 6.34 if ((sel_ret = select(FD_SETSIZE, &read_fd_set, NULL, NULL, qival > 0 ? &tm : NULL)) < 0) { 6.35 if (errno != EINTR) {
7.1 --- a/src/local.c Wed Oct 29 21:21:26 2008 +0100 7.2 +++ b/src/local.c Thu Nov 06 09:18:38 2008 +0100 7.3 @@ -16,9 +16,10 @@ 7.4 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 7.5 */ 7.6 7.7 +#include <sys/wait.h> 7.8 + 7.9 #include "masqmail.h" 7.10 #include "peopen.h" 7.11 -#include <sys/wait.h> 7.12 7.13 static void 7.14 message_stream(FILE * out, message * msg, GList * hdr_list, guint flags) 7.15 @@ -92,9 +93,7 @@ 7.16 if (fcntl(fileno(out), F_SETLK, &lock) != -1) { 7.17 #endif 7.18 fchmod(fileno(out), 0600); 7.19 - 7.20 message_stream(out, msg, hdr_list, MSGSTR_FROMLINE | MSGSTR_FROMHACK); 7.21 - 7.22 ok = TRUE; 7.23 7.24 /* close when still user */ 7.25 @@ -211,10 +210,9 @@ 7.26 if (i == 3) { 7.27 FILE *out; 7.28 mode_t saved_mode = umask(066); 7.29 - /* the qmail style unique works only if delivering 7.30 - with different process. We do not fork for each delivery, 7.31 - so our uid is more unique. Hope it is compatible with all 7.32 - MUAs. 7.33 + /* the qmail style unique works only if delivering with different process. 7.34 + We do not fork for each delivery, so our uid is more unique. 7.35 + Hope it is compatible with all MUAs. 7.36 */ 7.37 gchar *filename = g_strdup_printf("%s/tmp/%s.%s", path, msg->uid, conf.host_name); 7.38 7.39 @@ -227,7 +225,8 @@ 7.40 if (fflush(out) == EOF) 7.41 ok = FALSE; 7.42 else if (fdatasync(fileno(out)) != 0) { 7.43 - if (errno != EINVAL) /* some fs do not support this.. I hope this also means that it is not necessary */ 7.44 + if (errno != EINVAL) 7.45 + /* some fs do not support this.. I hope this also means that it is not necessary */ 7.46 ok = FALSE; 7.47 } 7.48 fclose(out);
8.1 --- a/src/log.c Wed Oct 29 21:21:26 2008 +0100 8.2 +++ b/src/log.c Thu Nov 06 09:18:38 2008 +0100 8.3 @@ -16,10 +16,10 @@ 8.4 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 8.5 */ 8.6 8.7 +#include <sysexits.h> 8.8 + 8.9 #include "masqmail.h" 8.10 8.11 -#include "sysexits.h" 8.12 - 8.13 static char *_sysexit_strings[] = { 8.14 "command line usage error", 8.15 "data format error", 8.16 @@ -109,8 +109,7 @@ 8.17 void 8.18 vlogwrite(int pri, const char *fmt, va_list args) 8.19 { 8.20 - if ((conf.do_verbose && (pri & LOG_VERBOSE)) || (pri == LOG_ALERT) 8.21 - || (pri == LOG_WARNING)) { 8.22 + if ((conf.do_verbose && (pri & LOG_VERBOSE)) || (pri == LOG_ALERT) || (pri == LOG_WARNING)) { 8.23 va_list args_copy; 8.24 va_copy(args_copy, args); 8.25 vfprintf(stdout, fmt, args_copy); 8.26 @@ -120,7 +119,6 @@ 8.27 8.28 pri &= ~LOG_VERBOSE; 8.29 if (pri) { 8.30 - 8.31 if (conf.use_syslog) 8.32 vsyslog(pri, fmt, args); 8.33 else { 8.34 @@ -159,7 +157,6 @@ 8.35 8.36 if (debugfile) { 8.37 fprintf(debugfile, "%s [%d] ", buf, getpid()); 8.38 - 8.39 vfprintf(debugfile, fmt, args); 8.40 fflush(debugfile); 8.41 } else {
9.1 --- a/src/lookup.c Wed Oct 29 21:21:26 2008 +0100 9.2 +++ b/src/lookup.c Thu Nov 06 09:18:38 2008 +0100 9.3 @@ -23,10 +23,8 @@ 9.4 #include "masqmail.h" 9.5 9.6 #ifdef RESOLV_TEST 9.7 - 9.8 #undef DEBUG 9.9 #define DEBUG(x) if(x > 0) 9.10 - 9.11 #define debugf g_print 9.12 #endif 9.13 9.14 @@ -343,26 +341,20 @@ 9.15 GList *addr_list = NULL, *node; 9.16 9.17 g_print("starting res_init()\n"); 9.18 - 9.19 g_print("retrans = %d, retry = %d\n", _res.retrans, _res.retry); 9.20 - 9.21 if (res_init() == 0) { 9.22 - 9.23 addr_list = resolve_dns_a(NULL, argv[1]); 9.24 g_print("A:\n"); 9.25 - 9.26 foreach(addr_list, node) { 9.27 mxip_addr *p_mxip = (mxip_addr *) (node->data); 9.28 - 9.29 printf("name = %s\n IP = %s\n", p_mxip->name, inet_ntoa(*(struct in_addr *) &(p_mxip->ip))); 9.30 } 9.31 addr_list = resolve_dns_mx(NULL, argv[1]); 9.32 g_print("MX:\n"); 9.33 - 9.34 foreach(addr_list, node) { 9.35 mxip_addr *p_mxip = (mxip_addr *) (node->data); 9.36 - 9.37 - printf("name = %s\n IP = %s pref = %d\n", p_mxip->name, inet_ntoa(*(struct in_addr *) &(p_mxip->ip)), p_mxip->pref); 9.38 + printf("name = %s\n IP = %s pref = %d\n", p_mxip->name, 9.39 + inet_ntoa(*(struct in_addr *) &(p_mxip->ip)), p_mxip->pref); 9.40 } 9.41 { 9.42 guint32 ip; 9.43 @@ -371,6 +363,5 @@ 9.44 } 9.45 } else 9.46 printf("res_init() failed.\n"); 9.47 - 9.48 } 9.49 #endif
10.1 --- a/src/online.c Wed Oct 29 21:21:26 2008 +0100 10.2 +++ b/src/online.c Thu Nov 06 09:18:38 2008 +0100 10.3 @@ -18,6 +18,7 @@ 10.4 10.5 #include <sys/stat.h> 10.6 #include <sys/wait.h> 10.7 + 10.8 #include "masqmail.h" 10.9 #include "mserver.h" 10.10 #include "peopen.h"
11.1 --- a/src/parse.c Wed Oct 29 21:21:26 2008 +0100 11.2 +++ b/src/parse.c Thu Nov 06 09:18:38 2008 +0100 11.3 @@ -125,7 +125,8 @@ 11.4 } 11.5 11.6 gboolean 11.7 -parse_address_rfc822(gchar* string, gchar** local_begin, gchar** local_end, gchar** domain_begin, gchar** domain_end, gchar** address_end) 11.8 +parse_address_rfc822(gchar* string, gchar** local_begin, gchar** local_end, gchar** domain_begin, 11.9 + gchar** domain_end, gchar** address_end) 11.10 { 11.11 gint angle_brackets = 0; 11.12 11.13 @@ -262,7 +263,8 @@ 11.14 } 11.15 11.16 gboolean 11.17 -parse_address_rfc821(gchar* string, gchar** local_begin, gchar** local_end, gchar** domain_begin, gchar** domain_end, gchar** address_end) 11.18 +parse_address_rfc821(gchar* string, gchar** local_begin, gchar** local_end, gchar** domain_begin, 11.19 + gchar** domain_end, gchar** address_end) 11.20 { 11.21 gint angle_brackets = 0; 11.22 11.23 @@ -352,7 +354,6 @@ 11.24 11.25 parses both rfc 821 and rfc 822 addresses, depending on flag is_rfc821 11.26 */ 11.27 - 11.28 address* 11.29 _create_address(gchar * string, gchar ** end, gboolean is_rfc821) 11.30 { 11.31 @@ -364,7 +365,8 @@ 11.32 address *addr = g_malloc(sizeof(address)); 11.33 addr->address = g_strdup(""); 11.34 addr->local_part = g_strdup(""); 11.35 - addr->domain = g_strdup(""); /* 'NULL' address (failure notice), "" makes sure it will not be qualified with a hostname */ 11.36 + addr->domain = g_strdup(""); /* 'NULL' address (failure notice), 11.37 + "" makes sure it will not be qualified with a hostname */ 11.38 return addr; 11.39 } 11.40 11.41 @@ -375,7 +377,6 @@ 11.42 address *addr = g_malloc(sizeof(address)); 11.43 gchar *p = addr_end; 11.44 11.45 - 11.46 memset(addr, 0, sizeof(address)); 11.47 11.48 if (loc_beg[0] == '|') { 11.49 @@ -397,7 +398,8 @@ 11.50 addr->domain = g_strndup(dom_beg, dom_end - dom_beg); 11.51 } else { 11.52 if (addr->local_part[0] == 0) 11.53 - addr->domain = g_strdup(""); /* 'NULL' address (failure notice), "" makes sure it will not be qualified with a hostname */ 11.54 + addr->domain = g_strdup(""); /* 'NULL' address (failure notice), 11.55 + "" makes sure it will not be qualified with a hostname */ 11.56 else 11.57 addr->domain = NULL; 11.58 }
12.1 --- a/src/peopen.c Wed Oct 29 21:21:26 2008 +0100 12.2 +++ b/src/peopen.c Thu Nov 06 09:18:38 2008 +0100 12.3 @@ -7,10 +7,9 @@ 12.4 #include <unistd.h> 12.5 #include <string.h> 12.6 #include <sys/types.h> 12.7 +#include <sysexits.h> 12.8 12.9 #include "peopen.h" 12.10 -#include "sysexits.h" 12.11 - 12.12 #include "masqmail.h" 12.13 12.14 static void 12.15 @@ -35,6 +34,7 @@ 12.16 int i = 0; 12.17 12.18 arr = (char **) malloc(sizeof(char *) * count); 12.19 + /* FIXME: check return value of malloc() */ 12.20 12.21 p = cmd; 12.22 while (*p && i < (count - 1)) { 12.23 @@ -43,7 +43,7 @@ 12.24 q = buf; 12.25 while (*p && !isspace(*p)) 12.26 *q++ = *p++; 12.27 - *q = 0; 12.28 + *q = '\0'; 12.29 arr[i++] = strdup(buf); 12.30 while (*p && isspace(*p)) 12.31 p++;
13.1 --- a/src/permissions.c Wed Oct 29 21:21:26 2008 +0100 13.2 +++ b/src/permissions.c Thu Nov 06 09:18:38 2008 +0100 13.3 @@ -16,10 +16,11 @@ 13.4 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 13.5 */ 13.6 13.7 -#include "masqmail.h" 13.8 #include <pwd.h> 13.9 #include <grp.h> 13.10 13.11 +#include "masqmail.h" 13.12 + 13.13 /* is there really no function in libc for this? */ 13.14 gboolean 13.15 is_ingroup(uid_t uid, gid_t gid)
14.1 --- a/src/pop3_in.c Wed Oct 29 21:21:26 2008 +0100 14.2 +++ b/src/pop3_in.c Thu Nov 06 09:18:38 2008 +0100 14.3 @@ -17,13 +17,13 @@ 14.4 14.5 /* see RFC 1725 */ 14.6 14.7 +#include <sys/wait.h> 14.8 +#include <sys/stat.h> 14.9 + 14.10 #include "masqmail.h" 14.11 #include "pop3_in.h" 14.12 #include "readsock.h" 14.13 14.14 -#include <sys/wait.h> 14.15 -#include <sys/stat.h> 14.16 - 14.17 #ifdef USE_LIB_CRYPTO 14.18 #include <openssl/md5.h> 14.19 #else 14.20 @@ -376,7 +376,7 @@ 14.21 while (*p && (*p != '>') && (i < 254)) 14.22 buf[i++] = *(p++); 14.23 buf[i++] = '>'; 14.24 - buf[i] = 0; 14.25 + buf[i] = '\0'; 14.26 14.27 popb->timestamp = g_strdup(buf); 14.28 14.29 @@ -448,14 +448,10 @@ 14.30 gint sock; 14.31 14.32 DEBUG(5) debugf("pop3_in_open_child entered, cmd = %s\n", cmd); 14.33 - 14.34 sock = child(cmd); 14.35 - 14.36 if (sock > 0) { 14.37 - 14.38 popb = create_pop3base(sock, flags); 14.39 popb->remote_host = NULL; 14.40 - 14.41 return popb; 14.42 } 14.43 logwrite(LOG_ALERT, "child failed (sock = %d): %s\n", sock, strerror(errno)); 14.44 @@ -566,7 +562,7 @@ 14.45 msg->rcpt_list = g_list_append(NULL, copy_address(rcpt)); 14.46 14.47 if ((err = accept_message(popb->in, msg, ACC_MAIL_FROM_HEAD 14.48 - | (conf.do_save_envelope_to ? ACC_SAVE_ENVELOPE_TO : 0))) 14.49 + | (conf.do_save_envelope_to ? ACC_SAVE_ENVELOPE_TO : 0))) 14.50 == AERR_OK) 14.51 return msg; 14.52 14.53 @@ -591,11 +587,8 @@ 14.54 pop3_in_quit(pop3_base * popb) 14.55 { 14.56 pop3_printf(popb->out, "QUIT\r\n"); 14.57 - 14.58 DEBUG(4) debugf("QUIT\n"); 14.59 - 14.60 signal(SIGALRM, SIG_DFL); 14.61 - 14.62 return TRUE; 14.63 } 14.64 14.65 @@ -620,7 +613,8 @@ 14.66 } 14.67 14.68 gboolean 14.69 -pop3_get(pop3_base * popb, gchar * user, gchar * pass, address * rcpt, address * return_path, gint max_count, gint max_size, gboolean max_size_delete) 14.70 +pop3_get(pop3_base * popb, gchar * user, gchar * pass, address * rcpt, address * return_path, 14.71 + gint max_count, gint max_size, gboolean max_size_delete) 14.72 { 14.73 gboolean ok = FALSE; 14.74 gint num_children = 0; 14.75 @@ -634,7 +628,8 @@ 14.76 if (pop3_in_stat(popb)) { 14.77 if (popb->msg_cnt > 0) { 14.78 14.79 - logwrite(LOG_NOTICE | LOG_VERBOSE, "%d message(s) for user %s at %s\n", popb->msg_cnt, user, popb->remote_host); 14.80 + logwrite(LOG_NOTICE | LOG_VERBOSE, "%d message(s) for user %s at %s\n", 14.81 + popb->msg_cnt, user, popb->remote_host); 14.82 14.83 if (pop3_in_list(popb)) { 14.84 gboolean do_get = !(popb->flags & POP3_FLAG_UIDL);
15.1 --- a/src/queue.c Wed Oct 29 21:21:26 2008 +0100 15.2 +++ b/src/queue.c Thu Nov 06 09:18:38 2008 +0100 15.3 @@ -16,11 +16,11 @@ 15.4 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 15.5 */ 15.6 15.7 -#include "masqmail.h" 15.8 - 15.9 #include <sys/stat.h> 15.10 #include <glob.h> 15.11 15.12 +#include "masqmail.h" 15.13 + 15.14 static void 15.15 mix_arr(int *buf, int len) 15.16 {
16.1 --- a/src/readsock.c Wed Oct 29 21:21:26 2008 +0100 16.2 +++ b/src/readsock.c Thu Nov 06 09:18:38 2008 +0100 16.3 @@ -16,14 +16,15 @@ 16.4 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16.5 */ 16.6 16.7 -/*#include "masqmail.h"*/ 16.8 #include <signal.h> 16.9 #include <stdio.h> 16.10 #include <stdlib.h> 16.11 #include <setjmp.h> 16.12 #include <unistd.h> 16.13 #include <ctype.h> 16.14 + 16.15 #include "readsock.h" 16.16 +/*#include "masqmail.h"*/ 16.17 16.18 jmp_buf jmp_timeout; 16.19 16.20 @@ -80,7 +81,7 @@ 16.21 c = fgetc(in); 16.22 } 16.23 16.24 - buf[p] = 0; 16.25 + buf[p] = '\0'; 16.26 16.27 if (c == EOF) 16.28 return -1; 16.29 @@ -90,7 +91,7 @@ 16.30 } 16.31 16.32 buf[p++] = c; /* \n */ 16.33 - buf[p] = 0; 16.34 + buf[p] = '\0'; 16.35 16.36 return p; 16.37 } 16.38 @@ -177,7 +178,7 @@ 16.39 if (flags & READSOCKL_CVT_CRLF) { 16.40 if ((buf[p - 2] == '\r') && (buf[p - 1] == '\n')) { 16.41 buf[p - 2] = '\n'; 16.42 - buf[p - 1] = 0; 16.43 + buf[p - 1] = '\0'; 16.44 p--; 16.45 } 16.46 }
17.1 --- a/src/rewrite.c Wed Oct 29 21:21:26 2008 +0100 17.2 +++ b/src/rewrite.c Thu Nov 06 09:18:38 2008 +0100 17.3 @@ -54,7 +54,7 @@ 17.4 if (*p == ',') 17.5 p++; 17.6 17.7 - new_hdr = g_strconcat(new_hdr, rewr_string, *p != 0 ? "," : NULL, NULL); 17.8 + new_hdr = g_strconcat(new_hdr, rewr_string, *p != '\0' ? "," : NULL, NULL); 17.9 17.10 } else 17.11 return FALSE;
18.1 --- a/src/route.c Wed Oct 29 21:21:26 2008 +0100 18.2 +++ b/src/route.c Thu Nov 06 09:18:38 2008 +0100 18.3 @@ -16,8 +16,9 @@ 18.4 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18.5 */ 18.6 18.7 +#include <fnmatch.h> 18.8 + 18.9 #include "masqmail.h" 18.10 -#include <fnmatch.h> 18.11 18.12 msgout_perhost* 18.13 create_msgout_perhost(gchar * host) 18.14 @@ -85,7 +86,8 @@ 18.15 DEBUG(6) debugf("header = %s\n", new_hdr->header); 18.16 msgout->xtra_hdr_list = g_list_append(msgout->xtra_hdr_list, new_hdr); 18.17 } else { 18.18 - logwrite(LOG_ALERT, "error in set_address_header_domain(%s, %s)\n", new_hdr->value, route->set_h_from_domain); 18.19 + logwrite(LOG_ALERT, "error in set_address_header_domain(%s, %s)\n", 18.20 + new_hdr->value, route->set_h_from_domain); 18.21 } 18.22 } 18.23 } 18.24 @@ -170,7 +172,8 @@ 18.25 if (hdr->id == HEAD_SENDER) { 18.26 header *new_hdr; 18.27 18.28 - new_hdr = create_header(HEAD_SENDER, "Sender: %s@%s\n", msgout->return_path->local_part, msgout->return_path->domain); 18.29 + new_hdr = create_header(HEAD_SENDER, "Sender: %s@%s\n", 18.30 + msgout->return_path->local_part, msgout->return_path->domain); 18.31 hdr_node->data = new_hdr; 18.32 /* we need this list only to carefully free the extra headers: */ 18.33 msgout->xtra_hdr_list = g_list_append(msgout->xtra_hdr_list, new_hdr); 18.34 @@ -322,8 +325,7 @@ 18.35 } 18.36 } 18.37 18.38 - /* rewrite return path 18.39 - if there is a table, use that 18.40 + /* rewrite return path if there is a table, use that 18.41 if an address is found and if it has a domain, use that 18.42 */ 18.43 if (route->map_return_path_addresses) { 18.44 @@ -382,9 +384,8 @@ 18.45 /* there is already a rcpt for this host */ 18.46 msg_out *msgout_last = (msg_out *) ((g_list_last(mo_ph->msgout_list))->data); 18.47 if (msgout_last->msg == msgout->msg) { 18.48 - /* if it is also the same message, it must be the last one 18.49 - appended to mo_ph->msgout_list (since outer loop goes through 18.50 - msgout_list) */ 18.51 + /* if it is also the same message, it must be the last one appended 18.52 + to mo_ph->msgout_list (since outer loop goes through msgout_list) */ 18.53 msgout_last->rcpt_list = g_list_append(msgout_last->rcpt_list, rcpt); 18.54 } else { 18.55 /* if not, we append a new msgout */
19.1 --- a/src/smtp_in.c Wed Oct 29 21:21:26 2008 +0100 19.2 +++ b/src/smtp_in.c Thu Nov 06 09:18:38 2008 +0100 19.3 @@ -31,24 +31,15 @@ 19.4 #ifdef ENABLE_SMTP_SERVER 19.5 19.6 smtp_cmd smtp_cmds[] = { 19.7 - {SMTP_HELO, "HELO",} 19.8 - , 19.9 - {SMTP_EHLO, "EHLO",} 19.10 - , 19.11 - {SMTP_MAIL_FROM, "MAIL FROM:",} 19.12 - , 19.13 - {SMTP_RCPT_TO, "RCPT TO:",} 19.14 - , 19.15 - {SMTP_DATA, "DATA",} 19.16 - , 19.17 - {SMTP_QUIT, "QUIT",} 19.18 - , 19.19 - {SMTP_RSET, "RSET",} 19.20 - , 19.21 - {SMTP_NOOP, "NOOP",} 19.22 - , 19.23 - {SMTP_HELP, "HELP"} 19.24 - , 19.25 + {SMTP_HELO, "HELO",}, 19.26 + {SMTP_EHLO, "EHLO",}, 19.27 + {SMTP_MAIL_FROM, "MAIL FROM:",}, 19.28 + {SMTP_RCPT_TO, "RCPT TO:",}, 19.29 + {SMTP_DATA, "DATA",}, 19.30 + {SMTP_QUIT, "QUIT",}, 19.31 + {SMTP_RSET, "RSET",}, 19.32 + {SMTP_NOOP, "NOOP",}, 19.33 + {SMTP_HELP, "HELP"}, 19.34 }; 19.35 19.36 static smtp_cmd_id 19.37 @@ -65,7 +56,6 @@ 19.38 /* this is a quick hack: we expect the address to be syntactically correct 19.39 and containing the mailbox only: 19.40 */ 19.41 - 19.42 static gboolean 19.43 get_address(gchar * line, gchar * addr) 19.44 {
20.1 --- a/src/smtp_out.c Wed Oct 29 21:21:26 2008 +0100 20.2 +++ b/src/smtp_out.c Thu Nov 06 09:18:38 2008 +0100 20.3 @@ -168,7 +168,7 @@ 20.4 } 20.5 for (i = 0; i < 4; i++) 20.6 code[i] = psb->buffer[buf_pos + i]; 20.7 - code[i] = 0; 20.8 + code[i] = '\0'; 20.9 psb->last_code = atoi(code); 20.10 20.11 buf_pos += len; 20.12 @@ -223,7 +223,7 @@ 20.13 if (*p && (*p != '\n')) { 20.14 while (*p && (*p != '\n') && (*p != '\r') && (q < buf + SMTP_BUF_LEN - 1)) 20.15 *(q++) = *(p++); 20.16 - *q = 0; 20.17 + *q = '\0'; 20.18 return g_strdup(buf); 20.19 } 20.20 return NULL; 20.21 @@ -356,7 +356,8 @@ 20.22 beginning with a dot is prepended with another dot. 20.23 */ 20.24 gchar *ptr; 20.25 - gboolean new_line = TRUE; /* previous versions assumed that each item was exactly one line. This is no longer the case */ 20.26 + gboolean new_line = TRUE; /* previous versions assumed that each item was exactly one line. 20.27 + This is no longer the case */ 20.28 20.29 ptr = data; 20.30 while (*ptr) { 20.31 @@ -567,7 +568,7 @@ 20.32 20.33 for (i = 0; i < 16; i++) 20.34 sprintf(&(digest_string[i + i]), "%02x", (unsigned int) (digest[i])); 20.35 - digest_string[32] = 0; 20.36 + digest_string[32] = '\0'; 20.37 20.38 DEBUG(5) debugf("digest = %s\n", digest_string); 20.39 20.40 @@ -746,7 +747,8 @@ 20.41 ok = FALSE; 20.42 break; 20.43 } else { 20.44 - logwrite(LOG_NOTICE, "%s == %s host=%s failed: %s", msg->uid, addr_string(rcpt), psb->remote_host, psb->buffer); 20.45 + logwrite(LOG_NOTICE, "%s == %s host=%s failed: %s", 20.46 + msg->uid, addr_string(rcpt), psb->remote_host, psb->buffer); 20.47 if (psb->error == smtp_trylater) { 20.48 addr_mark_defered(rcpt); 20.49 } else {
21.1 --- a/src/spool.c Wed Oct 29 21:21:26 2008 +0100 21.2 +++ b/src/spool.c Thu Nov 06 09:18:38 2008 +0100 21.3 @@ -16,8 +16,9 @@ 21.4 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21.5 */ 21.6 21.7 +#include <sys/stat.h> 21.8 + 21.9 #include "masqmail.h" 21.10 -#include <sys/stat.h> 21.11 #include "dotlock.h" 21.12 21.13 static gint 21.14 @@ -39,7 +40,7 @@ 21.15 if ((p > 0) && (buf[p - 1] == '\r')) 21.16 p--; 21.17 buf[p++] = '\n'; 21.18 - buf[p] = 0; 21.19 + buf[p] = '\0'; 21.20 21.21 return p; 21.22 } 21.23 @@ -68,7 +69,7 @@ 21.24 { 21.25 address *rcpt = NULL; 21.26 21.27 - if (line[3] != 0) { 21.28 + if (line[3] != '\0') { 21.29 if (line[4] != '|') { 21.30 rcpt = create_address(&(line[4]), TRUE); 21.31 } else {
22.1 --- a/src/tables.c Wed Oct 29 21:21:26 2008 +0100 22.2 +++ b/src/tables.c Thu Nov 06 09:18:38 2008 +0100 22.3 @@ -16,8 +16,9 @@ 22.4 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 22.5 */ 22.6 22.7 +#include <fnmatch.h> 22.8 + 22.9 #include "masqmail.h" 22.10 -#include <fnmatch.h> 22.11 22.12 table_pair* 22.13 create_pair(gchar * key, gpointer value) 22.14 @@ -52,9 +53,9 @@ 22.15 22.16 p = line; 22.17 q = buf; 22.18 - while ((*p != 0) && (*p != delim) && q < buf + 255) 22.19 + while ((*p != '\0') && (*p != delim) && q < buf + 255) 22.20 *(q++) = *(p++); 22.21 - *q = 0; 22.22 + *q = '\0'; 22.23 22.24 pair = g_malloc(sizeof(table_pair)); 22.25 pair->key = g_strdup(g_strstrip(buf));