diff options
author | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-08 13:24:39 +0200 |
---|---|---|
committer | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-08 13:24:39 +0200 |
commit | 973ae30e7c4f7a1afb385dd3d8eeea178f981445 (patch) | |
tree | 1a5d8be5b3ff273a141b6144bf3031b1bc3deb2d | |
parent | 66404f0bfbd78e635ff6381ca30b25157e0e1a09 (diff) |
fix deprecated prototypes
111 files changed, 1037 insertions, 1003 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b010b19 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.cache/ +compile_commands.json diff --git a/src/columnt.c b/src/columnt.c index d02b7ed..fc76c1a 100644 --- a/src/columnt.c +++ b/src/columnt.c @@ -14,15 +14,17 @@ char outbuf[BSIZE]; buffer bo = BUFFER_INIT(write, 1, outbuf, sizeof(outbuf)); -void nomem() +static void nomem() { logmsg(WHO, 111, FATAL, "out of memory"); } -void die_read() + +static void die_read() { logmsg(WHO, 110, ERROR, "unable to read input: "); } -void die_write() + +static void die_write() { logmsg(WHO, 110, ERROR, "unable to write output: "); } @@ -31,24 +33,24 @@ stralloc file = {0}; int *width; int maxfield = 0; -void nothing() {} +static void nothing() {} -void printline() +static void printline() { if (buffer_put(&bo, "\n", 1) == -1) die_write(); } -void maxfield_check(int fieldnum, char *buf, int len) +static void maxfield_check(int fieldnum, char *buf, int len) { if (fieldnum > maxfield) maxfield = fieldnum; } -void width_check(int fieldnum, char *buf, int len) +static void width_check(int fieldnum, char *buf, int len) { if (len > width[fieldnum]) width[fieldnum] = len; } -void width_init() +static void width_init() { int i; @@ -57,7 +59,7 @@ void width_init() for (i = 0; i <= maxfield; ++i) width[i] = 0; } -void printfield(int fieldnum, char *buf, int len) +static void printfield(int fieldnum, char *buf, int len) { int i; @@ -71,7 +73,7 @@ void printfield(int fieldnum, char *buf, int len) if (buffer_put(&bo, " ", 2) == -1) die_write(); } -void split(void (*dofield)(), void (*doline)()) +static void split(void (*dofield)(int, char *, int), void (*doline)(void)) { int i; int j; diff --git a/src/condredirect.c b/src/condredirect.c index 534dac7..2868ee6 100644 --- a/src/condredirect.c +++ b/src/condredirect.c @@ -15,7 +15,7 @@ struct qmail qqt; -ssize_t mywrite(int fd, char *buf, int len) +static ssize_t mywrite(int fd, char *buf, int len) { qmail_put(&qqt, buf, len); return len; diff --git a/src/control.c b/src/control.c index d3d12ad..2bc7b57 100644 --- a/src/control.c +++ b/src/control.c @@ -2,11 +2,10 @@ #include <unistd.h> -#include "alloc.h" +#include <errno.h> + #include "buffer.h" -#include "error.h" #include "getln.h" -#include "logmsg.h" #include "open.h" #include "scan.h" #include "stralloc.h" @@ -7,14 +7,7 @@ #include <sys/socket.h> #include <sys/types.h> -#include <string.h> - #include "alloc.h" -#include "buffer.h" -#include "case.h" -#include "dnsresolv.h" -#include "exit.h" -#include "fmt.h" #include "ip.h" #include "str.h" #include "stralloc.h" @@ -80,8 +73,9 @@ static int dns_ipplus(ipalloc *ia, stralloc *sa, int pref) } error = 0; } - } else + } else { error = 1; + } /* Case 4: sa is fqdn and looking for IPv4 */ @@ -97,13 +91,14 @@ static int dns_ipplus(ipalloc *ia, stralloc *sa, int pref) } error = 0; } - } else + } else { error += 2; + } return error; } -int dns_ipalloc(ipalloc *ia, stralloc *sa) +static int dns_ipalloc(ipalloc *ia, stralloc *sa) { if (!ipalloc_readyplus(ia, 0)) return DNS_MEM; ia->len = 0; diff --git a/src/dns_tlsa.c b/src/dns_tlsa.c index 612c6b3..66226a0 100644 --- a/src/dns_tlsa.c +++ b/src/dns_tlsa.c @@ -1,4 +1,5 @@ #include "byte.h" +#include "dnsresolv.h" #include "logmsg.h" #include "stralloc.h" #include "uint_t.h" @@ -7,7 +8,7 @@ static char *q = 0; -int dns_tlsa_packet(stralloc *out, const char *buf, unsigned int len) +static int dns_tlsa_packet(stralloc *out, const char *buf, unsigned int len) { unsigned int pos; char header[12]; diff --git a/src/dnsmxip.c b/src/dnsmxip.c index 9148bdc..e11d83e 100644 --- a/src/dnsmxip.c +++ b/src/dnsmxip.c @@ -12,7 +12,6 @@ #include "stralloc.h" #include "dns.h" -#include "now.h" #define WHO "dnsmxip" @@ -21,7 +20,7 @@ static stralloc ia = {0}; static stralloc out = {0}; static stralloc ipaddr = {0}; -int dns_ia(stralloc *ip, char *s) +static int dns_ia(stralloc *ip, char *s) { int i; int j = 0; diff --git a/src/fastforward.c b/src/fastforward.c index 731ada8..9d35d16 100644 --- a/src/fastforward.c +++ b/src/fastforward.c @@ -55,7 +55,7 @@ struct qmail qq; char qp[FMT_ULONG]; char qqbuf[1]; -ssize_t qqwrite(int fd, char *buf, int len) +static ssize_t qqwrite(int fd, char *buf, int len) { qmail_put(&qq, buf, len); return len; @@ -79,7 +79,7 @@ stralloc todo = {0}; stralloc mailinglist = {0}; -void dofile(char *fn) +static void dofile(char *fn) { int fd; struct stat st; @@ -116,12 +116,12 @@ uint32 dlen; stralloc data = {0}; struct cdb cdb; -void cdbreaderror() +static void cdbreaderror() { logmsg(WHO, 111, FATAL, B("unable to read: ", fncdb)); } -int findtarget(int flagwild, char *prepend, char *addr) +static int findtarget(int flagwild, char *prepend, char *addr) { int r; int at; @@ -157,7 +157,7 @@ int findtarget(int flagwild, char *prepend, char *addr) return 0; } -int gettarget(int flagwild, char *prepend, char *addr) +static int gettarget(int flagwild, char *prepend, char *addr) { if (!findtarget(flagwild, prepend, addr)) return 0; dlen = cdb_datalen(&cdb); @@ -168,7 +168,7 @@ int gettarget(int flagwild, char *prepend, char *addr) return 1; } -void doprogram(char *arg) +static void doprogram(char *arg) { char *args[5]; int child; @@ -222,7 +222,7 @@ void doprogram(char *arg) if (seek_begin(0) == -1) logmsg(WHO, 111, FATAL, "unable to rewind input: "); } -void dodata() +static void dodata() { int i; int j; @@ -244,7 +244,7 @@ void dodata() } } -void dorecip(char *addr) +static void dorecip(char *addr) { if (!findtarget(0, "?", addr)) { @@ -257,7 +257,7 @@ void dorecip(char *addr) if (!stralloc_0(&forward)) nomem(); } -void doorigrecip(char *addr) +static void doorigrecip(char *addr) { if (sender.len) if ((sender.len != 4) || byte_diff(sender.s, 4, "#@[]")) diff --git a/src/forward.c b/src/forward.c index e8c7eb0..83372d7 100644 --- a/src/forward.c +++ b/src/forward.c @@ -2,7 +2,6 @@ #include "buffer.h" #include "env.h" -#include "exit.h" #include "fmt.h" #include "logmsg.h" #include "sig.h" @@ -11,14 +10,14 @@ #define WHO "forward" -void die_nomem() +static void die_nomem() { logmsg(WHO, 111, FATAL, "out of memory"); } struct qmail qqt; -ssize_t mywrite(int fd, char *buf, int len) +static ssize_t mywrite(int fd, char *buf, int len) { qmail_put(&qqt, buf, len); return len; diff --git a/src/headerbody.c b/src/headerbody.c index 58458cf..460b1a0 100644 --- a/src/headerbody.c +++ b/src/headerbody.c @@ -1,8 +1,6 @@ #include "headerbody.h" -#include "buffer.h" #include "getln.h" -#include "stralloc.h" #include "hfield.h" @@ -20,11 +18,7 @@ static int getsa(buffer *b, stralloc *sa, int *match) static stralloc line = {0}; static stralloc nextline = {0}; -int headerbody(b, dohf, hdone, dobl) -buffer *b; -void (*dohf)(); -void (*hdone)(); -void (*dobl)(); +int headerbody(buffer *b, void (*dohf)(stralloc *), void (*hdone)(void), void (*dobl)(stralloc *)) { int match; int flaglineok; diff --git a/src/hfield.c b/src/hfield.c index 3043327..357386f 100644 --- a/src/hfield.c +++ b/src/hfield.c @@ -1,6 +1,6 @@ #include "hfield.h" -static char *(hname[]) = { +static const char *hname[] = { "unknown-header", "sender", "from", @@ -32,7 +32,7 @@ static char *(hname[]) = { "mail-followup-to", 0}; -static int hmatch(char *s, int len, char *t) +static int hmatch(char *s, int len, const char *t) { int i; char ch; @@ -56,7 +56,7 @@ static int hmatch(char *s, int len, char *t) int hfield_known(char *s, int len) { int i; - char *t; + const char *t; for (i = 1; (t = hname[i]); ++i) if (hmatch(s, len, t)) return i; @@ -1,9 +1,7 @@ #include "hier.h" -#include "fifo.h" #include "fmt.h" -#include "ipalloc.h" #include "tcpto.h" #ifdef USE_CONFIG @@ -16,7 +14,7 @@ char buf[100 + FMT_ULONG]; -void dsplit(char *base, int uid, int mode) /* base must be under 100 bytes */ +static void dsplit(char *base, int uid, int mode) /* base must be under 100 bytes */ { char *x; unsigned long i; diff --git a/src/hmac_md5.c b/src/hmac_md5.c index 5c46653..6b0fd0d 100644 --- a/src/hmac_md5.c +++ b/src/hmac_md5.c @@ -1,5 +1,6 @@ +#include "hmac_md5.h" + #include "byte.h" -#include "str.h" #include "global.h" #include "md5.h" @@ -11,7 +12,7 @@ int text_len : length of challenge unsigned char *key : pointer to password int key_len : length of password - output: unsigned char *digest: pointer to calculated digest + output: unsigned char *digest: pointer to calculated digest */ void hmac_md5(unsigned char *text, int text_len, unsigned char *key, int key_len, unsigned char *digest) diff --git a/src/include/commands.h b/src/include/commands.h index fed35e7..ea15add 100644 --- a/src/include/commands.h +++ b/src/include/commands.h @@ -1,12 +1,14 @@ #ifndef COMMANDS_H #define COMMANDS_H +#include "buffer.h" + struct commands { char *text; - void (*fun)(); - void (*flush)(); + void (*fun)(char *); + void (*flush)(void); }; -int commands(); +extern int commands(buffer *, struct commands *); #endif diff --git a/src/include/constmap.h b/src/include/constmap.h index 0a43e98..4e33dd1 100644 --- a/src/include/constmap.h +++ b/src/include/constmap.h @@ -13,9 +13,9 @@ struct constmap { int *inputlen; }; -int constmap_init(struct constmap *, char *, int, int); -int constmap_init_char(struct constmap *, char *, int, int, char); -void constmap_free(); -char *constmap(); +extern int constmap_init(struct constmap *, char *, int, int); +extern int constmap_init_char(struct constmap *, char *, int, int, char); +extern void constmap_free(struct constmap *cm); +extern char *constmap(struct constmap *cm, char *s, int len); #endif diff --git a/src/include/datetime.h b/src/include/datetime.h index eb8abc6..0f71755 100644 --- a/src/include/datetime.h +++ b/src/include/datetime.h @@ -14,7 +14,7 @@ struct datetime { typedef long datetime_sec; -void datetime_tai(); -datetime_sec datetime_untai(); +extern void datetime_tai(struct datetime *dt, datetime_sec t); +extern datetime_sec datetime_untai(struct datetime *dt); #endif diff --git a/src/include/headerbody.h b/src/include/headerbody.h index a074981..eec505f 100644 --- a/src/include/headerbody.h +++ b/src/include/headerbody.h @@ -1,6 +1,9 @@ #ifndef HEADERBODY_H #define HEADERBODY_H -int headerbody(); +#include "buffer.h" +#include "stralloc.h" + +extern int headerbody(buffer *b, void (*dohf)(stralloc *), void (*hdone)(void), void (*dobl)(stralloc *)); #endif diff --git a/src/include/hfield.h b/src/include/hfield.h index f2110b5..1415683 100644 --- a/src/include/hfield.h +++ b/src/include/hfield.h @@ -1,10 +1,6 @@ #ifndef HFIELD_H #define HFIELD_H -unsigned int hfield_skipname(); -int hfield_known(); -int hfield_valid(); - #define H_SENDER 1 #define H_FROM 2 #define H_REPLYTO 3 @@ -35,4 +31,8 @@ int hfield_valid(); #define H_MAILFOLLOWUPTO 28 #define H_NUM 29 +extern unsigned int hfield_skipname(char *s, int len); +extern int hfield_known(char *s, int len); +extern int hfield_valid(char *s, int len); + #endif diff --git a/src/include/hier.h b/src/include/hier.h index 21413cc..0c04c4b 100644 --- a/src/include/hier.h +++ b/src/include/hier.h @@ -1,10 +1,12 @@ #ifndef HIER_H #define HIER_H -void c(char *, char *, char *, int, int, int); -void h(char *, int, int, int); -void d(char *, char *, int, int, int); -void p(char *, char *, int, int, int); -void z(char *, char *, int, int, int, int); +extern void c(const char *, char *, char *, int, int, int); +extern void h(const char *, int, int, int); +extern void d(const char *, char *, int, int, int); +extern void p(const char *, char *, int, int, int); +extern void z(const char *, char *, int, int, int, int); + +extern void hier(void); #endif diff --git a/src/include/ipalloc.h b/src/include/ipalloc.h index cec29a9..8100c11 100644 --- a/src/include/ipalloc.h +++ b/src/include/ipalloc.h @@ -3,6 +3,7 @@ #include "genalloc.h" #include "ip.h" + #define NAME_LEN 256 struct ip_mx { @@ -16,7 +17,7 @@ struct ip_mx { }; GEN_ALLOC_typedef(ipalloc, struct ip_mx, ix, len, a); -int ipalloc_readyplus(); -int ipalloc_append(); +GEN_ALLOC_readyplus(ipalloc, struct ip_mx, ix, len, a, i, n, x, 22, ipalloc_readyplus); +GEN_ALLOC_append(ipalloc, struct ip_mx, ix, len, a, i, n, x, 22, ipalloc_readyplus, ipalloc_append); #endif diff --git a/src/include/ipme.h b/src/include/ipme.h index f9dff4e..d559dd8 100644 --- a/src/include/ipme.h +++ b/src/include/ipme.h @@ -7,9 +7,9 @@ extern ipalloc ipme; -int ipme_init(); -int ipme_is4(); -int ipme_is6(); -int ipme_is(); +extern int ipme_init(void); +extern int ipme_is4(struct ip4_address *); +extern int ipme_is6(struct ip6_address *); +extern int ipme_is(struct ip_mx *); #endif diff --git a/src/include/meson.build b/src/include/meson.build index 3677692..ca8c752 100644 --- a/src/include/meson.build +++ b/src/include/meson.build @@ -1,3 +1,58 @@ +config = configuration_data() +cc = meson.get_compiler('c') + +if cc.has_member('struct sockaddr', 'sa_len', prefix : '#include <sys/socket.h>') + config.set('HASSALEN', true) +endif + +if cc.has_function('getspnam', prefix : '#include <shadow.h>') + config.set('HASGETSPNAM', true) +elif cc.has_function('getuserpw', prefix : '#include <userpw.h>') + config.set('HASGETUSERPW', true) +endif + +if cc.has_function('mkfifo', prefix : '#include <sys/stat.h>') + config.set('HASMKFIFO', true) +endif + +if cc.has_header('utmp.h') + config.set('HASUTMP', true) +endif + +if idn2_dep.found() + config.set('IDN2', true) +endif + +auto_qmail = run_command('head', '-n1', + meson.project_source_root() / 'conf-home', check : true).stdout().strip() +config.set('auto_qmail', auto_qmail) + +config.set('auto_usera', 'alias') + +config.set('auto_split', get_option('split')) +config.set('auto_patrn', get_option('patrn')) +config.set('auto_spawn', get_option('spawn')) + +user_groups = [ + 'alias', 'qmaild', 'qmaill', 'qmailp', 'qmailq', 'qmailr', 'qmails', + 'sqmail', 'nofiles', +] + +foreach id : user_groups + config.set(id, get_option(id)) +endforeach + +sqmail_hdrs_subdir = 'sqmail' + +configure_file( + configuration : config, + input : 'fehsqm-config.h.in', + output : 'fehsqm-config.h', + install_dir : get_option('includedir') / sqmail_hdrs_subdir, + install_tag : 'devel') + +add_project_arguments('-DUSE_CONFIG', language : 'c') + sqmail_hdrs = [ 'base64.h', 'commands.h', @@ -42,6 +97,7 @@ sqmail_hdrs = [ 'sha1.h', 'sha256.h', 'smtpdlog.h', + 'spawn.h', 'spf.h', 'srs2.h', 'strset.h', @@ -52,10 +108,9 @@ sqmail_hdrs = [ 'tls_timeoutio.h', 'token822.h', 'trigger.h', - 'triggerpull.h', 'wildmat.h', ] -sqmail_hdrs_subdir = 'sqmail' - install_headers(sqmail_hdrs, subdir : sqmail_hdrs_subdir) + +inc = include_directories('.') diff --git a/src/include/newfield.h b/src/include/newfield.h index 049fb5e..8cfed4c 100644 --- a/src/include/newfield.h +++ b/src/include/newfield.h @@ -3,10 +3,12 @@ #include "stralloc.h" +#include "datetime.h" + extern stralloc newfield_date; -int newfield_datemake(); +extern int newfield_datemake(datetime_sec when); extern stralloc newfield_msgid; -int newfield_msgidmake(); +extern int newfield_msgidmake(char *idhost, int idhostlen, datetime_sec when); #endif diff --git a/src/include/now.h b/src/include/now.h index 1379d76..06b2f38 100644 --- a/src/include/now.h +++ b/src/include/now.h @@ -3,6 +3,6 @@ #include "datetime.h" -datetime_sec now(); +extern datetime_sec now(void); #endif diff --git a/src/include/prioq.h b/src/include/prioq.h index 31c99ac..db61b59 100644 --- a/src/include/prioq.h +++ b/src/include/prioq.h @@ -12,8 +12,8 @@ struct prioq_elt { GEN_ALLOC_typedef(prioq, struct prioq_elt, p, len, a); -int prioq_insert(); -int prioq_min(); -void prioq_delmin(); +extern int prioq_insert(prioq *pq, struct prioq_elt *pe); +extern int prioq_min(prioq *pq, struct prioq_elt *pe); +extern void prioq_delmin(prioq *pq); #endif diff --git a/src/include/prot.h b/src/include/prot.h index 08203da..7dd0503 100644 --- a/src/include/prot.h +++ b/src/include/prot.h @@ -1,7 +1,7 @@ #ifndef PROT_H #define PROT_H -int prot_gid(); -int prot_uid(); +extern int prot_gid(int); +extern int prot_uid(int); #endif diff --git a/src/include/qsutil.h b/src/include/qsutil.h index 7ef8ec1..0d5eca1 100644 --- a/src/include/qsutil.h +++ b/src/include/qsutil.h @@ -9,7 +9,6 @@ void log3s(char *, char *, char *); void log4s(char *, char *, char *, char *); void log5s(char *, char *, char *, char *, char *); void logsa(stralloc *); -void nomem(); void pausedir(char *); void logsafe(char *); int issafe(char); diff --git a/src/include/rcpthosts.h b/src/include/rcpthosts.h index 0c58797..791df47 100644 --- a/src/include/rcpthosts.h +++ b/src/include/rcpthosts.h @@ -1,7 +1,7 @@ #ifndef RCPTHOSTS_H #define RCPTHOSTS_H -int rcpthosts_init(); -int rcpthosts(); +extern int rcpthosts_init(void); +extern int rcpthosts(char *, int); #endif diff --git a/src/include/readsubdir.h b/src/include/readsubdir.h index 3910693..fc816f4 100644 --- a/src/include/readsubdir.h +++ b/src/include/readsubdir.h @@ -1,17 +1,17 @@ #ifndef READSUBDIR_H #define READSUBDIR_H -#include "direntry.h" +#include <dirent.h> typedef struct readsubdir { DIR *dir; int pos; char *name; - void (*pause)(); + void (*pause)(char *); } readsubdir; -void readsubdir_init(); -int readsubdir_next(); +extern void readsubdir_init(readsubdir *rs, char *name, void (*pause)(char *)); +extern int readsubdir_next(readsubdir *rs, unsigned long *id); #define READSUBDIR_NAMELEN 10 diff --git a/src/include/recipients.h b/src/include/recipients.h index 34542d5..2fabd26 100644 --- a/src/include/recipients.h +++ b/src/include/recipients.h @@ -3,8 +3,8 @@ #include <sys/types.h> -int recipients_init(void); -int recipients(char *, int); -ssize_t safewrite(); +extern int recipients_init(void); +extern int recipients(char *, int); +extern ssize_t safewrite(int, char *, int); #endif diff --git a/src/include/smtpdlog.h b/src/include/smtpdlog.h index 9b305c5..d0ec06a 100644 --- a/src/include/smtpdlog.h +++ b/src/include/smtpdlog.h @@ -1,9 +1,10 @@ #ifndef SMTPDLOG_H #define SMTPDLOG_H -#define FDLOG 2 -void flush(); -void out(); +// #define FDLOG 2 + +void flush(void); +void out(char *); void smtpdlog_init(void); void smtp_loga(char *, char *, char *, char *, char *, char *, char *, char *, char *); diff --git a/src/include/spawn.h b/src/include/spawn.h new file mode 100644 index 0000000..93b6e69 --- /dev/null +++ b/src/include/spawn.h @@ -0,0 +1,12 @@ +#ifndef SPAWN_H_INCLUDE +#define SPAWN_H_INCLUDE + +#include "buffer.h" + +extern int truncreport; + +extern int spawn(int fdmess, int fdout, const char *s, char *r, const int at); +extern void report(buffer *log, int wstat, char *s, int len); +extern void initialize(int argc, char **argv); + +#endif diff --git a/src/include/srs2.h b/src/include/srs2.h index 9856636..928573a 100644 --- a/src/include/srs2.h +++ b/src/include/srs2.h @@ -95,7 +95,7 @@ typedef struct _srs_t { /* Interface */ int srs_set_malloc(srs_malloc_t m, srs_realloc_t r, srs_free_t f); -srs_t *srs_new(); +srs_t *srs_new(void); void srs_init(srs_t *); void srs_free(srs_t *); int srs_forward(srs_t *, char *, int, const char *, const char *); diff --git a/src/include/tcpto.h b/src/include/tcpto.h index 678d12a..010dd1b 100644 --- a/src/include/tcpto.h +++ b/src/include/tcpto.h @@ -1,25 +1,27 @@ #ifndef TCPTO_H #define TCPTO_H +#include "ipalloc.h" + #define TCPTO_BUFSIZ 1024 -/* persistency structure: record -struct tcpto { +/* persistency structure: record +struct tcpto { unsigned char af; -- 1 byte -- IPv4: x'2' / IPv6: x'a' (10) unsigned char nul[3]; -- 3 byte unsigned char errorcount -- 1 byte -- if err_timeout || err_conrefused || err_proto (TLS) unsigned char nul[3]; -- 3 byte - unsigned long when; -- 8 byte + unsigned long when; -- 8 byte union { struct ip_address ip; struct ip6_address ip6; unsigned char nul[16]; -- 16 byte -- IPv4: filled up with '.' = x'2e' - } addr; + } addr; }; total: 32 byte */ -int tcpto(); -void tcpto_err(); -void tcpto_clean(); +int tcpto(struct ip_mx *); +void tcpto_err(struct ip_mx *ix, int flagerr); +void tcpto_clean(void); #endif diff --git a/src/include/tls_errors.h b/src/include/tls_errors.h index a61e8fd..31f105c 100644 --- a/src/include/tls_errors.h +++ b/src/include/tls_errors.h @@ -3,10 +3,10 @@ #include "stralloc.h" -extern void temp_tlscon(); -extern void temp_tlspeercert(); -extern void temp_tlspeervalid(); -extern void temp_tlspeerverify(); +extern void temp_tlscon(void); +extern void temp_tlspeercert(void); +extern void temp_tlspeervalid(void); +extern void temp_tlspeerverify(void); extern stralloc host; extern stralloc remotehost; diff --git a/src/include/tls_timeoutio.h b/src/include/tls_timeoutio.h index 175757e..fe3cd86 100644 --- a/src/include/tls_timeoutio.h +++ b/src/include/tls_timeoutio.h @@ -3,13 +3,14 @@ #include <openssl/ssl.h> -int tls_timeoutconn(int t, int rfd, int wfd, SSL *tls); -int tls_timeoutaccept(int t, int rfd, int wfd, SSL *tls); -int tsl_timeoutrehandshake(int t, int rfd, int wfd, SSL *tls); +extern int tls_timeoutconn(int t, int rfd, int wfd, SSL *tls); +extern int tls_timeoutaccept(int t, int rfd, int wfd, SSL *tls); +extern int tls_timeoutrehandshake(int t, int rfd, int wfd, SSL *tls); -int tls_timeoutread(int t, int rfd, int wfd, SSL *tls, char *buf, int len); -int tls_timeoutwrite(int t, int rfd, int wfd, SSL *tls, char *buf, int len); +extern int tls_timeoutread(int t, int rfd, int wfd, SSL *tls, char *buf, int len); +extern int tls_timeoutwrite(int t, int rfd, int wfd, SSL *tls, char *buf, int len); -int tls_timeoutio(int (*fun)(), int t, int rfd, int wfd, SSL *tls, char *buf, int len); +extern int tls_timeoutio( + int (*fun)(SSL *, void *, int), int t, int rfd, int wfd, SSL *tls, char *buf, int len); #endif diff --git a/src/include/token822.h b/src/include/token822.h index 73ef0be..565cf5b 100644 --- a/src/include/token822.h +++ b/src/include/token822.h @@ -2,24 +2,7 @@ #define TOKEN822_H #include "genalloc.h" - -struct token822 { - int type; - char *s; - int slen; -}; - -GEN_ALLOC_typedef(token822_alloc, struct token822, t, len, a); - -int token822_parse(); -int token822_addrlist(); -int token822_unquote(); -int token822_unparse(); -void token822_free(); -void token822_reverse(); -int token822_ready(); -int token822_readyplus(); -int token822_append(); +#include "stralloc.h" #define TOKEN822_ATOM 1 #define TOKEN822_QUOTE 2 @@ -33,4 +16,24 @@ int token822_append(); #define TOKEN822_COLON 10 #define TOKEN822_DOT 11 +struct token822 { + int type; + char *s; + int slen; +}; + +GEN_ALLOC_typedef(token822_alloc, struct token822, t, len, a); +GEN_ALLOC_ready(token822_alloc, struct token822, t, len, a, i, n, x, 30, token822_ready); +GEN_ALLOC_readyplus(token822_alloc, struct token822, t, len, a, i, n, x, 30, token822_readyplus); +GEN_ALLOC_append( + token822_alloc, struct token822, t, len, a, i, n, x, 30, token822_readyplus, token822_append); + +int token822_parse(token822_alloc *, stralloc *, stralloc *); +int token822_addrlist( + token822_alloc *taout, token822_alloc *taaddr, token822_alloc *ta, int (*callback)()); +int token822_unquote(stralloc *, token822_alloc *); +int token822_unparse(stralloc *, token822_alloc *, unsigned int); +void token822_free(); +void token822_reverse(token822_alloc *); + #endif diff --git a/src/include/trigger.h b/src/include/trigger.h index d0f4a3e..01bd4c4 100644 --- a/src/include/trigger.h +++ b/src/include/trigger.h @@ -1,9 +1,11 @@ #ifndef TRIGGER_H #define TRIGGER_H -extern void trigger_set(); -extern void trigger_selprep(); -extern int trigger_pulled(); -extern void triggerpull(); +#include "select.h" + +extern void trigger_set(void); +extern void trigger_selprep(int *nfds, fd_set *rfds); +extern int trigger_pulled(fd_set *rfds); +extern void triggerpull(void); #endif diff --git a/src/include/triggerpull.h b/src/include/triggerpull.h deleted file mode 100644 index 188f4f2..0000000 --- a/src/include/triggerpull.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef TRIGGERPULL_H -#define TRIGGERPULL_H - -void triggerpull(void); - -#endif diff --git a/src/install.c b/src/install.c index e6f95a9..7ca734d 100644 --- a/src/install.c +++ b/src/install.c @@ -7,13 +7,15 @@ #include "logmsg.h" #include "open.h" +#include "hier.h" + extern void hier(); #define WHO "install" int fdsourcedir = -1; -void h(char *home, int uid, int gid, int mode) +void h(const char *home, int uid, int gid, int mode) { if (mkdir(home, 0700) == -1) if (errno != EEXIST) logmsg(WHO, 111, FATAL, B("unable to mkdir: ", home)); @@ -21,7 +23,7 @@ void h(char *home, int uid, int gid, int mode) if (chmod(home, mode) == -1) logmsg(WHO, 111, FATAL, B("unable to chmod: ", home)); } -void d(char *home, char *subdir, int uid, int gid, int mode) +void d(const char *home, char *subdir, int uid, int gid, int mode) { if (chdir(home) == -1) logmsg(WHO, 110, FATAL, B("unable to switch to: ", home)); if (mkdir(subdir, 0700) == -1) @@ -30,7 +32,7 @@ void d(char *home, char *subdir, int uid, int gid, int mode) if (chmod(subdir, mode) == -1) logmsg(WHO, 111, FATAL, B("unable to chmod: ", home, "/", subdir)); } -void p(char *home, char *fifo, int uid, int gid, int mode) +void p(const char *home, char *fifo, int uid, int gid, int mode) { if (chdir(home) == -1) logmsg(WHO, 110, FATAL, B("unable to switch to: ", home)); if (fifo_make(fifo, 0700) == -1) @@ -44,7 +46,7 @@ buffer bi; char outbuf[BUFFER_OUTSIZE]; buffer bo; -void c(char *home, char *subdir, char *file, int uid, int gid, int mode) +void c(const char *home, char *subdir, char *file, int uid, int gid, int mode) { int fdin; int fdout; @@ -77,7 +79,7 @@ void c(char *home, char *subdir, char *file, int uid, int gid, int mode) if (chmod(file, mode) == -1) logmsg(WHO, 111, FATAL, B("unable to chmod .../", subdir, "/", file)); } -void z(char *home, char *file, int len, int uid, int gid, int mode) +void z(const char *home, char *file, int len, int uid, int gid, int mode) { int fdout; diff --git a/src/instcheck.c b/src/instcheck.c index 126ad11..c42eebf 100644 --- a/src/instcheck.c +++ b/src/instcheck.c @@ -7,11 +7,10 @@ #include "hier.h" -extern void hier(); - #define WHO "instcheck" -void perm(char *prefix1, char *prefix2, char *prefix3, char *file, int type, int uid, int gid, int mode) +static void perm( + char *prefix1, char *prefix2, char *prefix3, char *file, int type, int uid, int gid, int mode) { struct stat st; @@ -33,31 +32,31 @@ void perm(char *prefix1, char *prefix2, char *prefix3, char *file, int type, int logmsg(WHO, 0, WARN, B("file has wrong type: ", prefix1, prefix2, prefix3, file)); } -void h(char *home, int uid, int gid, int mode) +void h(const char *home, int uid, int gid, int mode) { perm("", "", "", home, S_IFDIR, uid, gid, mode); } -void d(char *home, char *subdir, int uid, int gid, int mode) +void d(const char *home, char *subdir, int uid, int gid, int mode) { if (chdir(home) == -1) logmsg(WHO, 111, FATAL, B("unable to switch to: ", home)); perm("", home, "/", subdir, S_IFDIR, uid, gid, mode); } -void p(char *home, char *fifo, int uid, int gid, int mode) +void p(const char *home, char *fifo, int uid, int gid, int mode) { if (chdir(home) == -1) logmsg(WHO, 111, FATAL, B("unable to switch to: ", home)); perm("", home, "/", fifo, S_IFIFO, uid, gid, mode); } -void c(char *home, char *subdir, char *file, int uid, int gid, int mode) +void c(const char *home, char *subdir, char *file, int uid, int gid, int mode) { if (chdir(home) == -1) logmsg(WHO, 111, FATAL, B("unable to switch to: ", home)); if (chdir(subdir) == -1) logmsg(WHO, 111, FATAL, B("unable to switch to: ", home, "/", subdir)); perm(".../", subdir, "/", file, S_IFREG, uid, gid, mode); } -void z(char *home, char *file, int len, int uid, int gid, int mode) +void z(const char *home, char *file, int len, int uid, int gid, int mode) { if (chdir(home) == -1) logmsg(WHO, 111, FATAL, B("unable to switch to: ", home)); perm("", home, "/", file, S_IFREG, uid, gid, mode); diff --git a/src/ipalloc.c b/src/ipalloc.c deleted file mode 100644 index 3cb363e..0000000 --- a/src/ipalloc.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "ipalloc.h" - -#include "alloc.h" -#include "genalloc.h" -#include "ip.h" - -GEN_ALLOC_readyplus(ipalloc, struct ip_mx, ix, len, a, i, n, x, 22, ipalloc_readyplus); -GEN_ALLOC_append(ipalloc, struct ip_mx, ix, len, a, i, n, x, 22, ipalloc_readyplus, ipalloc_append); @@ -12,7 +12,6 @@ #include "byte.h" #include "ip.h" -#include "stralloc.h" #include "ipalloc.h" @@ -20,15 +19,10 @@ #include <sys/sockio.h> #endif -#ifdef USE_CONFIG - #include "fehsqm-config.h" -#else - #include "hassalen.h" -#endif - -/** @file ipme.c - @brief ipme_is4, ipme_is6, ipme_is46, ipme_init - */ +/** + @file ipme.c + @brief ipme_is4, ipme_is6, ipme_is46, ipme_init +*/ static int ipmeok = 0; ipalloc ipme = {0}; diff --git a/src/maildir2mbox.c b/src/maildir2mbox.c index 7678969..0d62df3 100644 --- a/src/maildir2mbox.c +++ b/src/maildir2mbox.c @@ -6,12 +6,10 @@ #include "buffer.h" #include "env.h" #include "exit.h" -#include "genalloc.h" #include "getln.h" #include "lock.h" #include "logmsg.h" #include "open.h" -#include "str.h" #include "stralloc.h" #include "gfrom.h" @@ -35,7 +33,7 @@ char outbuf[BUFFER_OUTSIZE]; #define WHO "maildir2mbox" -void die_nomem() +static void die_nomem() { logmsg(WHO, 111, FATAL, "out of memory"); } diff --git a/src/maildirwatch.c b/src/maildirwatch.c index 0fe479f..7e67d88 100644 --- a/src/maildirwatch.c +++ b/src/maildirwatch.c @@ -1,11 +1,8 @@ #include <unistd.h> #include "buffer.h" -#include "exit.h" -#include "getln.h" #include "logmsg.h" #include "open.h" -#include "str.h" #include "stralloc.h" #include "headerbody.h" @@ -15,7 +12,7 @@ #define WHO "maildirwatch" -void die_nomem() +static void die_nomem() { logmsg(WHO, 111, FATAL, "out of memory"); } @@ -25,18 +22,18 @@ stralloc sender = {0}; stralloc fromline = {0}; stralloc text = {0}; -void addtext(char *s, int n) +static void addtext(char *s, int n) { if (!stralloc_catb(&text, s, n)) die_nomem(); if (text.len > 158) text.len = 158; } -void dobody(stralloc *h) +static void dobody(stralloc *h) { addtext(h->s, h->len); } -void doheader(stralloc *h) +static void doheader(stralloc *h) { int i; switch (hfield_known(h->s, h->len)) { @@ -59,7 +56,8 @@ void doheader(stralloc *h) break; } } -void finishheader() {} + +static void finishheader() {} stralloc filenames = {0}; prioq pq = {0}; diff --git a/src/matchup.c b/src/matchup.c index 5a01aac..fc318e8 100644 --- a/src/matchup.c +++ b/src/matchup.c @@ -1,6 +1,5 @@ #include <unistd.h> -#include "alloc.h" #include "buffer.h" #include "case.h" #include "exit.h" @@ -14,32 +13,32 @@ #define WHO "matchup" -void nomem() +static void nomem() { logmsg(WHO, 111, FATAL, "out of memory"); } -void die_read() +static void die_read() { logmsg(WHO, 110, ERROR, "unable to read input: "); } -void die_write() +static void die_write() { logmsg(WHO, 110, ERROR, "unable to write output: "); } -void die_write5() +static void die_write5() { logmsg(WHO, 111, FATAL, "unable to write fd 5: "); } -void out(char *buf, int len) +static void out(char *buf, int len) { if (buffer_put(buffer_1, buf, len) == -1) die_write(); } -void outs(char *buf) +static void outs(char *buf) { if (buffer_puts(buffer_1, buf) == -1) die_write(); } @@ -47,12 +46,12 @@ void outs(char *buf) char buf5[512]; buffer bo5 = BUFFER_INIT(write, 5, buf5, sizeof(buf5)); -void out5(char *buf, int len) +static void out5(char *buf, int len) { if (buffer_put(&bo5, buf, len) == -1) die_write5(); } -void outs5(char *buf) +static void outs5(char *buf) { if (buffer_puts(&bo5, buf) == -1) die_write5(); } @@ -77,7 +76,7 @@ ulongalloc numz = {0}; ulongalloc sender = {0}; ulongalloc birth = {0}; -int msg_find(unsigned long m) +static int msg_find(unsigned long m) { int i; for (i = 0; i < nummsg; ++i) @@ -85,7 +84,7 @@ int msg_find(unsigned long m) return -1; } -int msg_add(unsigned long m) +static int msg_add(unsigned long m) { int i; for (i = 0; i < nummsg; ++i) @@ -104,7 +103,7 @@ int msg_add(unsigned long m) return i; } -void msg_kill(int i) +static void msg_kill(int i) { poolbytes -= str_len(pool.s + sender.u[i]) + 1; poolbytes -= str_len(pool.s + birth.u[i]) + 1; @@ -128,7 +127,7 @@ ulongalloc dchan = {0}; ulongalloc drecip = {0}; ulongalloc dstart = {0}; -int del_find(unsigned long d) +static int del_find(unsigned long d) { int i; for (i = 0; i < numdel; ++i) @@ -136,7 +135,7 @@ int del_find(unsigned long d) return -1; } -int del_add(unsigned long d) +static int del_add(unsigned long d) { int i; for (i = 0; i < numdel; ++i) @@ -151,7 +150,7 @@ int del_add(unsigned long d) return i; } -void del_kill(int i) +static void del_kill(int i) { poolbytes -= str_len(pool.s + dchan.u[i]) + 1; poolbytes -= str_len(pool.s + drecip.u[i]) + 1; @@ -166,7 +165,7 @@ void del_kill(int i) stralloc pool2 = {0}; -void garbage() +static void garbage() { int i; char *x; @@ -212,13 +211,13 @@ int match; #define FIELDS 20 int field[FIELDS]; -void clear() +static void clear() { while (numdel > 0) del_kill(0); garbage(); } -void starting() +static void starting() { unsigned long d; unsigned long m; @@ -247,7 +246,7 @@ void starting() poolbytes += pool.len - dstart.u[dpos]; } -void delivery() +static void delivery() { unsigned long d; unsigned long m; @@ -324,7 +323,7 @@ void delivery() garbage(); } -void newmsg() +static void newmsg() { unsigned long m; int mpos; @@ -336,7 +335,7 @@ void newmsg() garbage(); } -void endmsg() +static void endmsg() { unsigned long m; int mpos; @@ -369,7 +368,7 @@ void endmsg() garbage(); } -void info() +static void info() { unsigned long m; int mpos; @@ -397,7 +396,7 @@ void info() poolbytes += pool.len - birth.u[mpos]; } -void extra() +static void extra() { unsigned long m; int mpos; @@ -411,7 +410,7 @@ void extra() scan_ulong(line.s + field[5], &numd.u[mpos]); } -void pending() +static void pending() { int i; @@ -92,7 +92,7 @@ static unsigned char PADDING[64] = {0x80, 0}; } /* MD5 initialization. Begins an MD5 operation, writing a new context. */ -void MD5Init(context) MD5_CTX *context; /* context */ +void MD5Init(MD5_CTX *context) /* context */ { context->count[0] = context->count[1] = 0; @@ -108,9 +108,7 @@ void MD5Init(context) MD5_CTX *context; /* context */ operation, processing another message block, and updating the context. */ -void MD5Update(context, input, inputLen) MD5_CTX *context; /* context */ -unsigned char *input; /* input block */ -unsigned int inputLen; /* length of input block */ +void MD5Update(MD5_CTX *context, unsigned char *input, unsigned int inputLen) { unsigned int i, index, partLen; @@ -141,8 +139,7 @@ unsigned int inputLen; /* length of input bl /* MD5 finalization. Ends an MD5 message-digest operation, writing the the message digest and zeroizing the context. */ -void MD5Final(digest, context) unsigned char digest[16]; /* message digest */ -MD5_CTX *context; /* context */ +void MD5Final(unsigned char digest[16], MD5_CTX *context) { unsigned char bits[8]; unsigned int index, padLen; @@ -167,8 +164,7 @@ MD5_CTX *context; /* context */ /* MD5 basic transformation. Transforms state based on block. */ -static void MD5Transform(state, block) UINT4 state[4]; -unsigned char block[64]; +static void MD5Transform(UINT4 state[4], unsigned char block[64]) { UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; @@ -258,9 +254,7 @@ unsigned char block[64]; /* Encodes input (UINT4) into output (unsigned char). Assumes len is a multiple of 4. */ -static void Encode(output, input, len) unsigned char *output; -UINT4 *input; -unsigned int len; +static void Encode(unsigned char *output, UINT4 *input, unsigned int len) { unsigned int i, j; @@ -275,9 +269,7 @@ unsigned int len; /* Decodes input (unsigned char) into output (UINT4). Assumes len is a multiple of 4. */ -static void Decode(output, input, len) UINT4 *output; -unsigned char *input; -unsigned int len; +static void Decode(UINT4 *output, unsigned char *input, unsigned int len) { unsigned int i, j; @@ -288,9 +280,7 @@ unsigned int len; /* Note: Replace "for loop" with standard memcpy if possible. */ -static void MD5_memcpy(output, input, len) POINTER output; -POINTER input; -unsigned int len; +static void MD5_memcpy(POINTER output, POINTER input, unsigned int len) { unsigned int i; @@ -299,9 +289,7 @@ unsigned int len; /* Note: Replace "for loop" with standard memset if possible. */ -static void MD5_memset(output, value, len) POINTER output; -int value; -unsigned int len; +static void MD5_memset(POINTER output, int value, unsigned int len) { unsigned int i; diff --git a/src/meson.build b/src/meson.build index 8f9af12..6244403 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,64 +1,11 @@ -inc = 'include' - -subdir(inc) - -config = configuration_data() -cc = meson.get_compiler('c') - -if cc.has_member('struct sockaddr', 'sa_len', prefix : '#include <sys/socket.h>') - config.set('HASSALEN', true) -endif - -if cc.has_function('getspnam', prefix : '#include <shadow.h>') - config.set('HASGETSPNAM', true) -elif cc.has_function('getuserpw', prefix : '#include <userpw.h>') - config.set('HASGETUSERPW', true) -endif - -if cc.has_function('mkfifo', prefix : '#include <sys/stat.h>') - config.set('HASMKFIFO', true) -endif - -if cc.has_header('utmp.h') - config.set('HASUTMP', true) -endif - -if idn2_dep.found() - config.set('IDN2', true) -endif - -auto_qmail = run_command('head', '-n1', '../conf-home', check : true).stdout().strip() -config.set('auto_qmail', auto_qmail) - -config.set('auto_usera', 'alias') - -config.set('auto_split', get_option('split')) -config.set('auto_patrn', get_option('patrn')) -config.set('auto_spawn', get_option('spawn')) - -user_groups = [ - 'alias', 'qmaild', 'qmaill', 'qmailp', 'qmailq', 'qmailr', 'qmails', - 'sqmail', 'nofiles', -] - -foreach id : user_groups - config.set(id, get_option(id)) -endforeach - -configure_file( - configuration : config, - input : inc / 'fehsqm-config.h.in', - output : 'fehsqm-config.h', - install_dir : get_option('includedir') / sqmail_hdrs_subdir, - install_tag : 'devel') - -add_project_arguments('-DUSE_CONFIG', language : 'c') +subdir('include') auto_break = get_option('break') assert(auto_break[0] == auto_break) assert(auto_break not in ['"', '\\']) -auto_break_c = custom_target(output : 'auto_break.c', - command : ['echo', 'char', 'auto_break', '[]', '=', f'"@auto_break@"', ';'], +auto_break_c = custom_target( + output : 'auto_break.c', + command : ['echo', f'char auto_break[] = "@auto_break@";'], capture : true) @@ -98,14 +45,20 @@ if get_option('build-user') install : true, dependencies : qlibs_dep) - executable('qmail-newu', 'qmail-newu.c', dependencies : qlibs_dep, install : true) + executable('qmail-newu', 'qmail-newu.c', + include_directories : inc, + dependencies : qlibs_dep, + install : true) executable('qmail-pw2u', 'qmail-pw2u.c', 'constmap.c', 'control.c', auto_break_c, include_directories : inc, install : true, dependencies : qlibs_dep) - executable('qmail-newmrh', 'qmail-newmrh.c', dependencies : qlibs_dep, install : true) + executable('qmail-newmrh', 'qmail-newmrh.c', + include_directories : inc, + dependencies : qlibs_dep, + install : true) endif @@ -128,7 +81,7 @@ if get_option('build-server') dependencies : qlibs_dep) executable('qmail-smtpd', - 'qmail-smtpd.c', 'rcpthosts.c', 'commands.c', 'ipme.c', 'ipalloc.c', + 'qmail-smtpd.c', 'rcpthosts.c', 'commands.c', 'ipme.c', 'constmap.c', 'control.c', 'received.c', 'recipients.c', 'mfrules.c', 'tls_start.c', 'smtpdlog.c', 'dns.c', 'date822fmt.c', 'now.c', 'qmail.c', 'wildmat.c', 'spf.c', 'spfdnsip.c', 'base64.c', auto_break_c, @@ -155,7 +108,10 @@ if get_option('build-queue') link_with : datetime_slib, dependencies : qlibs_dep) - executable('qmail-tcpok', 'qmail-tcpok.c', dependencies : qlibs_dep, install : true) + executable('qmail-tcpok', 'qmail-tcpok.c', + include_directories : inc, + dependencies : qlibs_dep, + install : true) endif @@ -170,7 +126,7 @@ if get_option('build-pam') dependencies : [qlibs_dep, crypt_dep]) executable('qmail-smtpam', - 'qmail-smtpam.c', 'control.c', 'now.c', 'dns.c', 'constmap.c', 'ipalloc.c', + 'qmail-smtpam.c', 'control.c', 'now.c', 'dns.c', 'constmap.c', 'ipme.c', 'quote.c', 'tcpto.c', 'tls_timeoutio.c', 'tls_errors.c', 'tls_remote.c', 'dns_tlsa.c', include_directories : inc, @@ -202,16 +158,24 @@ endif if get_option('build-control') executable('qmail-badmimetypes', 'qmail-badmimetypes.c', + include_directories : inc, install : true, dependencies : qlibs_dep) executable('qmail-badloadertypes', 'qmail-badloadertypes.c', + include_directories : inc, install : true, dependencies : qlibs_dep) - executable('qmail-mfrules', 'qmail-mfrules.c', dependencies : qlibs_dep, install : true) + executable('qmail-mfrules', 'qmail-mfrules.c', + include_directories : inc, + dependencies : qlibs_dep, + install : true) - executable('qmail-recipients', 'qmail-recipients.c', dependencies : qlibs_dep, install : true) + executable('qmail-recipients', 'qmail-recipients.c', + include_directories : inc, + dependencies : qlibs_dep, + install : true) executable('qmail-showctl', 'qmail-showctl.c', 'control.c', auto_break_c, include_directories : inc, @@ -290,50 +254,50 @@ endif if get_option('build-dns') - executable('dnscname', 'dnscname.c', 'dns.c', 'ipalloc.c', + executable('dnscname', 'dnscname.c', 'dns.c', include_directories : inc, install : true, dependencies : [qlibs_dep, dnsresolv_dep]) - executable('dnsptr', 'dnsptr.c', 'dns.c', 'ipalloc.c', + executable('dnsptr', 'dnsptr.c', 'dns.c', include_directories : inc, install : true, dependencies : [qlibs_dep, dnsresolv_dep]) - executable('dnsip', 'dnsip.c', 'dns.c', 'ipalloc.c', + executable('dnsip', 'dnsip.c', 'dns.c', include_directories : inc, install : true, dependencies : [qlibs_dep, dnsresolv_dep]) - executable('dnsmxip', 'dnsmxip.c', 'ipalloc.c', 'dns.c', + executable('dnsmxip', 'dnsmxip.c', 'dns.c', include_directories : inc, install : true, dependencies : [qlibs_dep, dnsresolv_dep]) - executable('dnsfq', 'dnsfq.c', 'dns.c', 'ipalloc.c', + executable('dnsfq', 'dnsfq.c', 'dns.c', include_directories : inc, install : true, dependencies : [qlibs_dep, dnsresolv_dep]) - executable('dnstlsa', 'dnstlsa.c', 'dns_tlsa.c', 'ipalloc.c', 'dns.c', + executable('dnstlsa', 'dnstlsa.c', 'dns_tlsa.c', 'dns.c', include_directories : inc, install : true, dependencies : [qlibs_dep, dnsresolv_dep]) - executable('dnstxt', 'dnstxt.c', 'ipalloc.c', 'dns.c', + executable('dnstxt', 'dnstxt.c', 'dns.c', include_directories : inc, install : true, dependencies : [qlibs_dep, dnsresolv_dep]) executable('hostname', 'hostname.c', dependencies : [qlibs_dep, dnsresolv_dep], install : true) - executable('ipmeprint', 'ipmeprint.c', 'ipme.c', 'ipalloc.c', + executable('ipmeprint', 'ipmeprint.c', 'ipme.c', include_directories : inc, install : true, dependencies : [qlibs_dep, dnsresolv_dep]) executable('spfquery', - 'spfquery.c', 'spf.c', 'ipme.c', 'ipalloc.c', 'now.c', 'dns.c', 'spfdnsip.c', + 'spfquery.c', 'spf.c', 'ipme.c', 'now.c', 'dns.c', 'spfdnsip.c', include_directories : inc, install : true, link_with : datetime_slib, @@ -369,7 +333,7 @@ endif if get_option('build-clients') executable('qmail-remote', - 'qmail-remote.c', 'control.c', 'tcpto.c', 'now.c', 'dns.c', 'ipalloc.c', + 'qmail-remote.c', 'control.c', 'tcpto.c', 'now.c', 'dns.c', 'ipme.c', 'quote.c', 'tls_timeoutio.c', 'tls_errors.c', 'tls_remote.c', 'dns_tlsa.c', 'base64.c', 'constmap.c', 'md5c.c', 'hmac_md5.c', include_directories : inc, @@ -381,7 +345,10 @@ if get_option('build-clients') install : true, dependencies : qlibs_dep) - executable('sendmail', 'sendmail.c', dependencies : qlibs_dep, install : true) + executable('sendmail', 'sendmail.c', + include_directories : inc, + dependencies : qlibs_dep, + install : true) endif @@ -476,10 +443,13 @@ if get_option('build-base') install : true, dependencies : qlibs_dep) - executable('qmail-start', 'qmail-start.c', dependencies : qlibs_dep, install : true) + executable('qmail-start', 'qmail-start.c', + include_directories : inc, + dependencies : qlibs_dep, + install : true) executable('qmail-queue', - 'qmail-queue.c', 'triggerpull.c', 'fmtqfn.c', 'now.c', 'date822fmt.c', + 'qmail-queue.c', 'trigger.c', 'fmtqfn.c', 'now.c', 'date822fmt.c', include_directories : inc, install : true, link_with : datetime_slib, diff --git a/src/mfrules.c b/src/mfrules.c index be32422..2f39fd0 100644 --- a/src/mfrules.c +++ b/src/mfrules.c @@ -5,7 +5,6 @@ #include "case.h" #include "cdbread.h" #include "close.h" -#include "open.h" #include "str.h" #include "stralloc.h" @@ -65,7 +64,7 @@ static int mffind(char *mf) return -1; } -int mfsearch(char *ip, char *host, char *info, char *mf) +static int mfsearch(char *ip, char *host, char *info, char *mf) { int r; diff --git a/src/myctime.c b/src/myctime.c index ebb01ba..69d7004 100644 --- a/src/myctime.c +++ b/src/myctime.c @@ -4,8 +4,8 @@ #include "datetime.h" -static char *daytab[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; -static char *montab[12] = { +static const char *daytab[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; +static const char *montab[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; static char result[30]; diff --git a/src/newaliases.c b/src/newaliases.c index 2275f63..9248636 100644 --- a/src/newaliases.c +++ b/src/newaliases.c @@ -5,7 +5,6 @@ #include "byte.h" #include "case.h" #include "cdbmake.h" -#include "genalloc.h" #include "getln.h" #include "logmsg.h" #include "open.h" @@ -24,32 +23,32 @@ int rename(const char *, const char *); // stdio.h -void nomem() +static void nomem() { logmsg(WHO, 111, FATAL, "out of memory"); } -void nulbyte() +static void nulbyte() { logmsg(WHO, 100, FATAL, "NUL bytes are not permitted"); } -void longaddress() +static void longaddress() { logmsg(WHO, 100, FATAL, "addresses over 800 bytes are not permitted"); } -void writeerr() +static void writeerr() { logmsg(WHO, 111, FATAL, "unable to write to /etc/aliases.tmp"); } -void readerr() +static void readerr() { logmsg(WHO, 111, FATAL, "unable to read /etc/aliases"); } -void die_control() +static void die_control() { logmsg(WHO, 111, FATAL, "unable to read controls"); } @@ -59,7 +58,7 @@ stralloc defaulthost = {0}; stralloc defaultdomain = {0}; stralloc plusdomain = {0}; -void readcontrols() +static void readcontrols() { int r; int fddir; @@ -97,7 +96,7 @@ token822_alloc toks = {0}; token822_alloc tokaddr = {0}; stralloc address = {0}; -void gotincl() +static void gotincl() { token822_reverse(&tokaddr); if (token822_unquote(&address, &tokaddr) != 1) nomem(); @@ -114,7 +113,7 @@ void gotincl() if (!stralloc_0(&instr)) nomem(); } -void gotaddr() +static void gotaddr() { int i; int j; @@ -186,13 +185,13 @@ stralloc line = {0}; stralloc newline = {0}; int match; -void parseerr() +static void parseerr() { if (!stralloc_0(&line)) nomem(); logmsg(WHO, 111, FATAL, B("unable to parse this line: ", line.s)); } -void parseline() +static void parseline() { int wordok; struct token822 *t; @@ -265,7 +264,7 @@ buffer bi; struct cdb_make cdb; stralloc key = {0}; -void doit() +static void doit() { if (!instr.len) { if (target.len) parseerr(); diff --git a/src/newinclude.c b/src/newinclude.c index ae01482..4bc9f81 100644 --- a/src/newinclude.c +++ b/src/newinclude.c @@ -6,7 +6,6 @@ #include "buffer.h" #include "byte.h" #include "env.h" -#include "genalloc.h" #include "getln.h" #include "logmsg.h" #include "open.h" @@ -23,12 +22,12 @@ #define WHO "newinclude" -void nomem() +static void nomem() { logmsg(WHO, 111, FATAL, "out of memory"); } -void usage() +static void usage() { logmsg(WHO, 100, USAGE, "newinclude list"); } @@ -45,12 +44,12 @@ char tmpbuf[1024]; buffer bt; -void readerr() +static void readerr() { logmsg(WHO, 111, FATAL, B("unable to read: ", fnlist)); } -void writeerr() +static void writeerr() { logmsg(WHO, 111, FATAL, B("unable to write to ", fntmp)); } @@ -60,8 +59,7 @@ static void out(char *s, int len) if (buffer_put(&bt, s, len) == -1) writeerr(); } -void doincl(buf, len) char *buf; -int len; +static void doincl(char *buf, int len) { if (!len) logmsg(WHO, 111, FATAL, "empty :include: filenames not permitted"); if (byte_chr(buf, len, '\n') != len) @@ -73,8 +71,7 @@ int len; out("", 1); } -void dorecip(buf, len) char *buf; -int len; +static void dorecip(char *buf, int len) { if (!len) logmsg(WHO, 111, FATAL, "empty recipient addresses not permitted"); if (byte_chr(buf, len, '\n') != len) @@ -90,7 +87,7 @@ int len; } -void die_control() +static void die_control() { logmsg(WHO, 111, FATAL, "unable to read controls"); } @@ -100,7 +97,7 @@ stralloc defaulthost = {0}; stralloc defaultdomain = {0}; stralloc plusdomain = {0}; -void readcontrols() +static void readcontrols() { int r; int fddir; @@ -148,7 +145,7 @@ token822_alloc toks = {0}; token822_alloc tokaddr = {0}; stralloc address = {0}; -void gotincl() +static void gotincl() { token822_reverse(&tokaddr); if (token822_unquote(&address, &tokaddr) != 1) nomem(); @@ -156,7 +153,7 @@ void gotincl() doincl(address.s, address.len); } -void gotaddr() +static void gotaddr() { int i; int j; @@ -209,13 +206,13 @@ void gotaddr() stralloc line = {0}; int match; -void parseerr() +static void parseerr() { if (!stralloc_0(&line)) nomem(); logmsg(WHO, 111, FATAL, B("unable to parse this line: ", line.s)); } -void parseline() +static void parseline() { int wordok; struct token822 *t; diff --git a/src/preline.c b/src/preline.c index 2a0b8c4..b80142e 100644 --- a/src/preline.c +++ b/src/preline.c @@ -11,7 +11,7 @@ #define WHO "preline" -void die_usage() +static void die_usage() { logmsg(WHO, 100, USAGE, "preline cmd [ arg ... ]"); } diff --git a/src/printforward.c b/src/printforward.c index ae5d26c..130bb03 100644 --- a/src/printforward.c +++ b/src/printforward.c @@ -7,17 +7,17 @@ #define WHO "printmaillist" -void badformat() +static void badformat() { logmsg(WHO, 100, FATAL, "bad database format"); } -void nomem() +static void nomem() { logmsg(WHO, 111, FATAL, "out of memory"); } -void getch(char *ch) +static void getch(char *ch) { int r; r = buffer_get(buffer_0small, ch, 1); @@ -25,17 +25,17 @@ void getch(char *ch) if (r == 0) badformat(); } -void out(char *ch) +static void out(char *ch) { if (buffer_put(buffer_1small, ch, 1) == -1) logmsg(WHO, 111, FATAL, "unable to write output"); } -void printbuf(char *buf) +static void printbuf(char *buf) { while (*buf) out(buf++); } -void printsafe(char *buf, int len) +static void printsafe(char *buf, int len) { char ch; diff --git a/src/printmaillist.c b/src/printmaillist.c index 8de8b69..3bd109c 100644 --- a/src/printmaillist.c +++ b/src/printmaillist.c @@ -8,7 +8,7 @@ #define WHO "printmaillist" -void badformat() +static void badformat() { logmsg(WHO, 100, FATAL, "bad mailing list format"); } @@ -1,6 +1,13 @@ #include "prot.h" -#include "hasshsgr.h" +#include <grp.h> +#include <unistd.h> + +#ifdef USE_CONFIG + #include "fehsqm-config.h" +#else + #include "hasshsgr.h" +#endif /* XXX: there are more portability problems here waiting to leap out at me */ diff --git a/src/qbiff.c b/src/qbiff.c index 25d1ae5..36dce84 100644 --- a/src/qbiff.c +++ b/src/qbiff.c @@ -52,18 +52,18 @@ stralloc woof = {0}; stralloc tofrom = {0}; stralloc text = {0}; -void doit(char *s, int n) +static void doit(char *s, int n) { if (!stralloc_catb(&text, s, n)) _exit(0); if (text.len > 78) text.len = 78; } -void dobody(stralloc *h) +static void dobody(stralloc *h) { doit(h->s, h->len); } -void doheader(stralloc *h) +static void doheader(stralloc *h) { int i; @@ -73,7 +73,7 @@ void doheader(stralloc *h) } } -void finishheader() {} +static void finishheader() {} int main() { diff --git a/src/qmail-authuser.c b/src/qmail-authuser.c index ce18a19..1f31df6 100644 --- a/src/qmail-authuser.c +++ b/src/qmail-authuser.c @@ -1,7 +1,7 @@ #include <pwd.h> #include <unistd.h> -#include <stdio.h> +#include <errno.h> #include <crypt.h> @@ -9,13 +9,9 @@ #include "byte.h" #include "case.h" #include "constmap.h" -#include "error.h" #include "fd.h" -#include "fmt.h" -#include "open.h" #include "pathexec.h" #include "prot.h" -#include "scan.h" #include "sig.h" #include "str.h" #include "stralloc.h" @@ -86,7 +82,7 @@ stralloc shell = {0}; cram-md5/apop: (1,5) */ -void exit(int fail) +static void exit(int fail) { int i; @@ -94,7 +90,7 @@ void exit(int fail) _exit(fail); } -int dig_ascii(char *digascii, const char *digest, const int len) +static int dig_ascii(char *digascii, const char *digest, const int len) { static const char hextab[] = "0123456789abcdef"; int j; @@ -108,7 +104,7 @@ int dig_ascii(char *digascii, const char *digest, const int len) return (2 * j); // 2*len } -int auth_sha1(char *pwdhash, char *response) +static int auth_sha1(char *pwdhash, char *response) { unsigned char digest[20]; unsigned char digascii[41]; @@ -119,7 +115,7 @@ int auth_sha1(char *pwdhash, char *response) return str_diffn(digascii, pwdhash, 40); } -int auth_sha256(char *pwdhash, char *response) +static int auth_sha256(char *pwdhash, char *response) { unsigned char digest[32]; unsigned char digascii[65]; @@ -130,7 +126,7 @@ int auth_sha256(char *pwdhash, char *response) return str_diffn(digascii, pwdhash, 64); } -int auth_md5(char *pwdhash, char *response) +static int auth_md5(char *pwdhash, char *response) { MD5_CTX ctx; unsigned char digest[16]; @@ -144,7 +140,7 @@ int auth_md5(char *pwdhash, char *response) return str_diffn(digascii, pwdhash, 32); } -int auth_hash(char *password, char *response) +static int auth_hash(char *password, char *response) { switch (str_len(password)) { case 32: return auth_md5(password, response); @@ -154,7 +150,7 @@ int auth_hash(char *password, char *response) } } -int auth_unix(char *user, char *response) +static int auth_unix(char *user, char *response) { char *encrypted = 0; char *stored = 0; @@ -199,7 +195,7 @@ int auth_unix(char *user, char *response) return r; } -int auth_apop(unsigned char *password, unsigned char *response, unsigned char *challenge) +static int auth_apop(unsigned char *password, unsigned char *response, unsigned char *challenge) { MD5_CTX context; unsigned char digest[16]; @@ -214,7 +210,7 @@ int auth_apop(unsigned char *password, unsigned char *response, unsigned char *c return (str_diff(digascii, response)); } -int auth_cram(unsigned char *password, unsigned char *response, unsigned char *challenge) +static int auth_cram(unsigned char *password, unsigned char *response, unsigned char *challenge) { unsigned char digest[16]; unsigned char digascii[33]; @@ -225,7 +221,7 @@ int auth_cram(unsigned char *password, unsigned char *response, unsigned char *c return (str_diff(digascii, response) && str_diff(password, response)); } -int auth_dovecot(char *user, char *response, char *socket, char *service) +static int auth_dovecot(char *user, char *response, char *socket, char *service) { int wstat; int child; @@ -261,7 +257,7 @@ int auth_dovecot(char *user, char *response, char *socket, char *service) return wait_exitcode(wstat); } -int auth_wrapper(char *pam, char *arg1, char *arg2, char *auth, int len) +static int auth_wrapper(char *pam, char *arg1, char *arg2, char *auth, int len) { int wstat; int child; diff --git a/src/qmail-badloadertypes.c b/src/qmail-badloadertypes.c index b8feba7..84e5b51 100644 --- a/src/qmail-badloadertypes.c +++ b/src/qmail-badloadertypes.c @@ -21,12 +21,12 @@ #define WHO "qmail-badloadertypes" #define LOADER_LEN 5 -void die_read() +static void die_read() { logmsg(WHO, 111, FATAL, "unable to read control/badloadertypes"); } -void die_write() +static void die_write() { logmsg(WHO, 111, FATAL, "unable to write to control/badloadertypes.tmp"); } diff --git a/src/qmail-badmimetypes.c b/src/qmail-badmimetypes.c index c2298e8..c32218e 100644 --- a/src/qmail-badmimetypes.c +++ b/src/qmail-badmimetypes.c @@ -20,12 +20,12 @@ #define WHO "qmail-badmimetypes" #define MIMETYPE_LEN 9 -void die_read() +static void die_read() { logmsg(WHO, 111, FATAL, "unable to read control/badmimetypes"); } -void die_write() +static void die_write() { logmsg(WHO, 111, FATAL, "unable to write to control/badmimetypes.tmp"); } diff --git a/src/qmail-clean.c b/src/qmail-clean.c index 3e4d74e..041a90f 100644 --- a/src/qmail-clean.c +++ b/src/qmail-clean.c @@ -27,7 +27,7 @@ stralloc line = {0}; -void cleanuppid() +static void cleanuppid() { DIR *dir; direntry *d; @@ -53,7 +53,7 @@ void cleanuppid() char fnbuf[FMTQFN]; -void respond(char *s) +static void respond(char *s) { if (buffer_putflush(buffer_1small, s, 1) == -1) _exit(100); } diff --git a/src/qmail-dksign.c b/src/qmail-dksign.c index 50d1394..e94a561 100644 --- a/src/qmail-dksign.c +++ b/src/qmail-dksign.c @@ -65,33 +65,33 @@ buffer bi = BUFFER_INIT(read, 0, bufin, sizeof(bufin)); char bufout[1000]; buffer bo = BUFFER_INIT(write, 1, bufout, sizeof(bufout)); -void die(int e) +static void die(int e) { _exit(e); } -void die_write(char *fn) +static void die_write(char *fn) { unlink(fn); die(53); } -void die_read() +static void die_read() { die(54); } -void out(char *s) +static void out(char *s) { if (buffer_puts(&bo, s) == -1) _exit(111); } -void zero() +static void zero() { if (buffer_put(&bo, "\0", 1) == -1) _exit(111); } -void zerodie() +static void zerodie() { zero(); buffer_flush(&bo); @@ -111,19 +111,19 @@ stralloc ecckey = {0}; stralloc rsakey = {0}; char *dkimparams = 0; -void temp_nomem() +static void temp_nomem() { out("ZOut of memory. (#4.3.0)\n"); zerodie(); } -void temp_chdir() +static void temp_chdir() { out("ZUnable to switch to target directory. (#4.3.0)\n"); zerodie(); } -void temp_create() +static void temp_create() { out("ZUnable to create DKIM stage file: "); out(error_str(errno)); @@ -132,31 +132,31 @@ void temp_create() zerodie(); } -void temp_unlink() +static void temp_unlink() { out("ZUnable to unlink DKIM stage file. (#4.3.0)\n"); zerodie(); } -void temp_control() +static void temp_control() { out("ZUnable to read DKIM control files. (#4.3.0)\n"); zerodie(); } -void perm_usage() +static void perm_usage() { out("Zqmail-dksign was invoked improperly. (#5.3.5)\n"); zerodie(); } -void temp_read() +static void temp_read() { out("DUnable to read message for DKIM signing. (#4.3.0)\n"); zerodie(); } -void temp_nosignkey() +static void temp_nosignkey() { out("DCan't read sign key: "); out(rsakey.s); @@ -166,7 +166,7 @@ void temp_nosignkey() zerodie(); } -int get_controls() +static int get_controls() { int i; stralloc domname = {0}; @@ -225,14 +225,14 @@ int get_controls() return 0; } -void fnmake_dkim(unsigned long id) +static void fnmake_dkim(unsigned long id) { fndkin.len = fmtqfn(fndkin.s, "queue/dkim/", id, 1); id += id; fndkout.len = fmtqfn(fndkout.s, "queue/dkim/", id, 1); } -void dkim_unlink() +static void dkim_unlink() { if (unlink(fndkin.s) == -1) if (errno != ENOENT) temp_unlink(); @@ -240,7 +240,7 @@ void dkim_unlink() if (errno != ENOENT) temp_unlink(); } -void dkim_stage() +static void dkim_stage() { int r; int fd; @@ -307,7 +307,7 @@ stralloc length = {0}; // -l -z<hash> - set signature type (1=sha1, 2=sha256, 3=both, 4=ed25519, 5=hybrid) */ -int dkim_sign(const char *rsakeyfile, const char *ecckeyfile, const char *fnin, const char *fnout) +static int dkim_sign(const char *rsakeyfile, const char *ecckeyfile, const char *fnin, const char *fnout) { int child; int wstat; @@ -379,7 +379,7 @@ int dkim_sign(const char *rsakeyfile, const char *ecckeyfile, const char *fnin, } } -int qmail_remote(char **qargs, int fd) +static int qmail_remote(char **qargs, int fd) { int child; int wstat; @@ -410,7 +410,7 @@ int qmail_remote(char **qargs, int fd) } } -void dkim_setup() +static void dkim_setup() { int c, i, j, k, l; char *opt, *pos; diff --git a/src/qmail-dkverify.c b/src/qmail-dkverify.c index 0438f58..cb123db 100644 --- a/src/qmail-dkverify.c +++ b/src/qmail-dkverify.c @@ -52,82 +52,82 @@ buffer bi = BUFFER_INIT(read, 0, bufin, sizeof(bufin)); // read buffer char bufout[1024]; buffer bo = BUFFER_INIT(write, 1, bufout, sizeof(bufout)); // output message -void die(int e) +static void die(int e) { _exit(e); } -void die_pipe(char *fn) +static void die_pipe(char *fn) { unlink(fn); die(53); } -void die_write(char *fn) +static void die_write(char *fn) { unlink(fn); die(53); } -void die_read() +static void die_read() { die(54); } -void out(char *s) +static void out(char *s) { if (buffer_puts(&bo, s) == -1) _exit(111); } -void zero() +static void zero() { if (buffer_put(&bo, "\0", 1) == -1) _exit(111); } -void zerodie() +static void zerodie() { zero(); buffer_flush(&bo); _exit(111); } -void temp_nomem() +static void temp_nomem() { out("ZOut of memory. (#4.3.0)\n"); zerodie(); } -void temp_chdir() +static void temp_chdir() { out("ZUnable to switch to target directory. (#4.3.0)\n"); zerodie(); } -void temp_create() +static void temp_create() { out("ZUnable to create DKIM stage file. (#4.3.0)\n"); zerodie(); } -void temp_unlink() +static void temp_unlink() { out("ZUnable to unlink DKIM stage file. (#4.3.0)\n"); zerodie(); } -void temp_read() +static void temp_read() { out("ZUnable to read message. (#4.3.0)\n"); zerodie(); } -void temp_socket() +static void temp_socket() { out("ZUnable to crate socket pair. (#4.3.0)\n"); zerodie(); } -void temp_control() +static void temp_control() { out("ZUnable to read control files. (#4.3.0)\n"); zerodie(); @@ -140,14 +140,14 @@ static stralloc fndkin = {0}; static stralloc fndkout = {0}; static stralloc result = {0}; -void fnmake_dkim(unsigned long id) +static void fnmake_dkim(unsigned long id) { fndkin.len = fmtqfn(fndkin.s, "queue/dkim/", id, 1); id += id; fndkout.len = fmtqfn(fndkout.s, "queue/dkim/", id, 1); } -void dkim_stage() +static void dkim_stage() { int r; int fd; @@ -184,7 +184,7 @@ void dkim_stage() if (close(fd) == -1) die_write(fndkin.s); } -int mess_dkim() +static int mess_dkim() { stralloc line = {0}; int match; @@ -240,7 +240,7 @@ int mess_dkim() return r; } -int dkim_verify() +static int dkim_verify() { int child; int wstat; @@ -269,7 +269,7 @@ int dkim_verify() } } -int dkim_result(const char *me) +static int dkim_result(const char *me) { int max = 64; int fd; @@ -314,7 +314,7 @@ int dkim_result(const char *me) return r; } -int qmail_queue() +static int qmail_queue() { int fd; int r; @@ -373,7 +373,7 @@ int qmail_queue() return 0; } -void dkim_unlink() +static void dkim_unlink() { if (unlink(fndkin.s) == -1) if (errno != ENOENT) temp_unlink(); diff --git a/src/qmail-getpw.c b/src/qmail-getpw.c index 70fe776..e5d03c5 100644 --- a/src/qmail-getpw.c +++ b/src/qmail-getpw.c @@ -27,7 +27,7 @@ struct passwd *pw; char *dash; char *extension; -int userext() +static int userext() { char username[GETPW_USERLEN]; struct stat st; diff --git a/src/qmail-inject.c b/src/qmail-inject.c index 9b7cca7..bded8dc 100644 --- a/src/qmail-inject.c +++ b/src/qmail-inject.c @@ -59,7 +59,7 @@ int flagrh; int flagqueue; struct qmail qqt; -void out(char *s, int len) +static void out(char *s, int len) { if (flagqueue) qmail_put(&qqt, s, len); @@ -67,54 +67,54 @@ void out(char *s, int len) buffer_putflush(buffer_1, s, len); } -void outs(char *s) +static void outs(char *s) { out(s, str_len(s)); } -void perm() +static void perm() { _exit(100); } -void temp() +static void temp() { _exit(111); } -void die_nomem() +static void die_nomem() { buffer_putsflush(buffer_2, "qmail-inject: fatal: out of memory\n"); temp(); } -void die_invalid(stralloc *sa) +static void die_invalid(stralloc *sa) { buffer_putsflush(buffer_2, "qmail-inject: fatal: invalid header field: "); buffer_putflush(buffer_2, sa->s, sa->len); perm(); } -void die_qqt() +static void die_qqt() { buffer_putsflush(buffer_2, "qmail-inject: fatal: unable to run qmail-queue\n"); temp(); } -void die_chdir() +static void die_chdir() { buffer_putsflush(buffer_2, "qmail-inject: fatal: internal bug\n"); temp(); } -void die_read() +static void die_read() { if (errno == ENOMEM) die_nomem(); buffer_putsflush(buffer_2, "qmail-inject: fatal: read error\n"); temp(); } -void doordie(stralloc *sa, int r) +static void doordie(stralloc *sa, int r) { if (r == 1) return; if (r == -1) die_nomem(); @@ -135,7 +135,7 @@ saa hrrlist = {0}; saa reciplist = {0}; int flagresent; -void exitnicely() +static void exitnicely() { char *qqx; @@ -186,7 +186,7 @@ void exitnicely() _exit(0); } -void savedh_append(stralloc *h) +static void savedh_append(stralloc *h) { if (!saa_readyplus(&savedh, 1)) die_nomem(); savedh.sa[savedh.len] = sauninit; @@ -194,7 +194,7 @@ void savedh_append(stralloc *h) ++savedh.len; } -void savedh_print() +static void savedh_print() { int i; @@ -208,14 +208,14 @@ token822_alloc defaulthost = {0}; stralloc plusdomainbuf = {0}; token822_alloc plusdomain = {0}; -void rwroute(token822_alloc *addr) +static void rwroute(token822_alloc *addr) { if (addr->t[addr->len - 1].type == TOKEN822_AT) while (addr->len) if (addr->t[--addr->len].type == TOKEN822_COLON) return; } -void rwextraat(token822_alloc *addr) +static void rwextraat(token822_alloc *addr) { int i; @@ -225,7 +225,7 @@ void rwextraat(token822_alloc *addr) } } -void rwextradot(token822_alloc *addr) +static void rwextradot(token822_alloc *addr) { int i; @@ -235,7 +235,7 @@ void rwextradot(token822_alloc *addr) } } -void rwnoat(token822_alloc *addr) +static void rwnoat(token822_alloc *addr) { int i; int shift; @@ -251,7 +251,7 @@ void rwnoat(token822_alloc *addr) for (i = 0; i < shift; ++i) addr->t[i] = defaulthost.t[shift - 1 - i]; } -void rwnodot(token822_alloc *addr) +static void rwnodot(token822_alloc *addr) { int i; int shift; @@ -274,7 +274,7 @@ void rwnodot(token822_alloc *addr) for (i = 0; i < shift; ++i) addr->t[i] = defaultdomain.t[shift - 1 - i]; } -void rwplus(token822_alloc *addr) +static void rwplus(token822_alloc *addr) { int i; int shift; @@ -295,7 +295,7 @@ void rwplus(token822_alloc *addr) for (i = 0; i < shift; ++i) addr->t[i] = plusdomain.t[shift - 1 - i]; } -void rwgeneric(token822_alloc *addr) +static void rwgeneric(token822_alloc *addr) { if (!addr->len) return; /* don't rewrite <> */ if (addr->len >= 2) @@ -315,7 +315,7 @@ void rwgeneric(token822_alloc *addr) rwnodot(addr); } -int setreturn(token822_alloc *addr) +static int setreturn(token822_alloc *addr) { if (!sender.s) { token822_reverse(addr); @@ -327,20 +327,20 @@ int setreturn(token822_alloc *addr) return 1; } -int rwreturn(token822_alloc *addr) +static int rwreturn(token822_alloc *addr) { rwgeneric(addr); setreturn(addr); return 1; } -int rwsender(token822_alloc *addr) +static int rwsender(token822_alloc *addr) { rwgeneric(addr); return 1; } -void rwappend(token822_alloc *addr, saa *xl) +static void rwappend(token822_alloc *addr, saa *xl) { token822_reverse(addr); if (!saa_readyplus(xl, 1)) die_nomem(); @@ -350,21 +350,21 @@ void rwappend(token822_alloc *addr, saa *xl) token822_reverse(addr); } -int rwhrr(token822_alloc *addr) +static int rwhrr(token822_alloc *addr) { rwgeneric(addr); rwappend(addr, &hrrlist); return 1; } -int rwhr(token822_alloc *addr) +static int rwhr(token822_alloc *addr) { rwgeneric(addr); rwappend(addr, &hrlist); return 1; } -int rwtocc(token822_alloc *addr) +static int rwtocc(token822_alloc *addr) { rwgeneric(addr); rwappend(addr, &hrlist); @@ -378,7 +378,7 @@ token822_alloc hfin = {0}; token822_alloc hfrewrite = {0}; token822_alloc hfaddr = {0}; -void doheaderfield(stralloc *h) +static void doheaderfield(stralloc *h) { int htype; int (*rw)() = 0; @@ -428,7 +428,7 @@ void doheaderfield(stralloc *h) savedh_append(h); } -void dobody(stralloc *h) +static void dobody(stralloc *h) { out(h->s, h->len); } @@ -436,7 +436,7 @@ void dobody(stralloc *h) stralloc torecip = {0}; token822_alloc tr = {0}; -void dorecip(char *s) +static void dorecip(char *s) { if (!quote2(&torecip, s)) die_nomem(); @@ -456,7 +456,7 @@ void dorecip(char *s) stralloc defaultfrom = {0}; token822_alloc df = {0}; -void defaultfrommake() +static void defaultfrommake() { char *fullname; fullname = env_get("QMAILNAME"); @@ -518,7 +518,7 @@ token822_alloc drp = {0}; stralloc hackedruser = {0}; char strnum[FMT_ULONG]; -void dodefaultreturnpath() +static void dodefaultreturnpath() { if (!stralloc_copys(&hackedruser, mailruser)) die_nomem(); @@ -564,7 +564,7 @@ int flagmft = 0; stralloc mft = {0}; struct constmap mapmft; -void mft_init() +static void mft_init() { char *x; int r; @@ -580,7 +580,7 @@ void mft_init() flagmft = 1; } -void finishmft() +static void finishmft() { int i; static stralloc sa = {0}; @@ -606,7 +606,7 @@ void finishmft() outs("\n"); } -void finishheader() +static void finishheader() { flagresent = htypeseen[H_R_SENDER] || htypeseen[H_R_FROM] || htypeseen[H_R_REPLYTO] || htypeseen[H_R_TO] @@ -668,7 +668,7 @@ void finishheader() savedh_print(); } -void getcontrols() +static void getcontrols() { static stralloc sa = {0}; char *x; diff --git a/src/qmail-local.c b/src/qmail-local.c index bbef6f3..ec22fa2 100644 --- a/src/qmail-local.c +++ b/src/qmail-local.c @@ -45,42 +45,42 @@ #define WHO "qmail-local" -void usage() +static void usage() { logmsg(WHO, 100, USAGE, "qmail-local [ -nN ] user homedir local dash ext domain sender aliasempty"); } -void temp_nomem() +static void temp_nomem() { logmsg(WHO, 111, FATAL, "Out of memory. (#4.3.0)"); } -void temp_rewind() +static void temp_rewind() { logmsg(WHO, 111, FATAL, "Unable to rewind message. (#4.3.0)"); } -void temp_childcrashed() +static void temp_childcrashed() { logmsg(WHO, 111, FATAL, "Aack, child crashed. (#4.3.0)"); } -void temp_fork() +static void temp_fork() { logmsg(WHO, 111, FATAL, B("Unable to fork: ", error_str(errno), ". (#4.3.0)")); } -void temp_read() +static void temp_read() { logmsg(WHO, 111, ERROR, B("Unable to read message: ", error_str(errno), ". (#4.3.0)")); } -void temp_slowlock() +static void temp_slowlock() { logmsg(WHO, 111, ERROR, "File has been locked for 30 seconds straight. (#4.3.0)"); } -void temp_qmail(fn) char *fn; +static void temp_qmail(char *fn) { logmsg(WHO, 111, FATAL, B("Unable to open: ", fn, " ", error_str(errno), ". (#4.3.0)")); } @@ -117,18 +117,18 @@ char bufout[1024]; char fntmptph[80 + FMT_ULONG * 2]; char fnnewtph[80 + FMT_ULONG * 2]; -void tryunlinktmp() +static void tryunlinktmp() { unlink(fntmptph); } -void sigalrm() +static void sigalrm() { tryunlinktmp(); _exit(3); } -void maildir_child(char *dir) +static void maildir_child(char *dir) { unsigned long pid; struct timeval time; @@ -236,7 +236,7 @@ FAIL: /* end child process */ -void maildir(char *fn) +static void maildir(char *fn) { int child; int wstat; @@ -260,7 +260,7 @@ void maildir(char *fn) } } -void mailfile(char *fn) +static void mailfile(char *fn) { int fd; buffer bi; @@ -319,7 +319,7 @@ WRITERRS: _exit(111); } -void mailprogram(char *prog) +static void mailprogram(char *prog) { int child; char *(args[4]); @@ -359,7 +359,7 @@ void mailprogram(char *prog) unsigned long mailforward_qp = 0; -void mailforward(char **recips) +static void mailforward(char **recips) { struct qmail qqt; char *qqx; @@ -388,7 +388,7 @@ void mailforward(char **recips) logmsg(WHO, *qqx == 'D' ? 100 : 111, ERROR, B("Unable to forward message: ", qqx + 1, ".")); } -void bouncexf() +static void bouncexf() { int match; buffer bi; @@ -407,7 +407,7 @@ void bouncexf() } } -void checkhome() +static void checkhome() { struct stat st; @@ -422,7 +422,7 @@ void checkhome() } } -int qmeox(char *dashowner) +static int qmeox(char *dashowner) { struct stat st; @@ -439,7 +439,7 @@ int qmeox(char *dashowner) return 0; } -int qmeexists(int *fd, int *cutable) +static int qmeexists(int *fd, int *cutable) { struct stat st; @@ -471,7 +471,7 @@ int qmeexists(int *fd, int *cutable) /* "-/" "a-b-": "-/a-b-" "-/a-b-default" "-/a-default" "-/default" */ /* "-/" "a-b-c": "-/a-b-c" "-/a-b-default" "-/a-default" "-/default" */ -void qmesearch(int *fd, int *cutable) +static void qmesearch(int *fd, int *cutable) { int i; @@ -512,7 +512,7 @@ char count_buf[FMT_ULONG]; char buflog[256]; buffer bl = BUFFER_INIT(write, 1, buflog, sizeof(buflog)); -void count_print() +static void count_print() { buffer_puts(&bl, "did "); buffer_put(&bl, count_buf, fmt_ulong(count_buf, count_file)); @@ -530,7 +530,7 @@ void count_print() buffer_flush(&bl); } -void sayit(char *type, char *cmd, int len) +static void sayit(char *type, char *cmd, int len) { buffer_puts(&bl, type); buffer_put(&bl, cmd, len); diff --git a/src/qmail-lspawn.c b/src/qmail-lspawn.c index 57fba4b..cbf402e 100644 --- a/src/qmail-lspawn.c +++ b/src/qmail-lspawn.c @@ -15,6 +15,7 @@ #include "wait.h" #include "qlx.h" +#include "spawn.h" #ifdef USE_CONFIG #include "fehsqm-config.h" @@ -75,7 +76,7 @@ stralloc wildchars = {0}; static struct cdb c; -void nughde_get(char *local) +static void nughde_get(char *local) { char *(args[3]); int pi[2]; diff --git a/src/qmail-mfrules.c b/src/qmail-mfrules.c index 7ef097c..1e3c367 100644 --- a/src/qmail-mfrules.c +++ b/src/qmail-mfrules.c @@ -37,23 +37,23 @@ int match = 1; struct cdb_make cdb; -void die_nomem() +static void die_nomem() { logmsg(WHO, 112, FATAL, "out of memory"); } -void die_parse() +static void die_parse() { if (!stralloc_0(&line)) die_nomem(); logmsg(WHO, 100, ERROR, B("unable to parse this line: ", line.s)); } -void die_read() +static void die_read() { logmsg(WHO, 111, ERROR, "unable to read control/mailfromrules"); } -void die_write() +static void die_write() { logmsg(WHO, 111, ERROR, "unable to write to control/mailfromrules.tmp"); } @@ -61,14 +61,14 @@ void die_write() char strnum[FMT_ULONG]; stralloc sanum = {0}; -void getnum(char *buf, int len, unsigned long *u) +static void getnum(char *buf, int len, unsigned long *u) { if (!stralloc_copyb(&sanum, buf, len)) die_nomem(); if (!stralloc_0(&sanum)) die_nomem(); if (sanum.s[scan_ulong(sanum.s, u)]) die_parse(); } -void doaddressdata() +static void doaddressdata() { int i; int left; diff --git a/src/qmail-mrtg.c b/src/qmail-mrtg.c index bcf4d01..96407d9 100644 --- a/src/qmail-mrtg.c +++ b/src/qmail-mrtg.c @@ -98,7 +98,7 @@ static void out(int i) char bufspace[1024]; buffer bi = BUFFER_INIT(read, 0, bufspace, sizeof(bufspace)); -void mrtg_results(char flag) +static void mrtg_results(char flag) { switch (flag) { case '1': @@ -188,7 +188,7 @@ void mrtg_results(char flag) } } -void mrtg_sendlog(char *in, char flag) +static void mrtg_sendlog(char *in, char flag) { int i, j, k = 0; @@ -240,7 +240,7 @@ void mrtg_sendlog(char *in, char flag) } } -void mrtg_smtplog(char *in, char flag) +static void mrtg_smtplog(char *in, char flag) { int i, j, k = 0; @@ -310,7 +310,7 @@ void mrtg_smtplog(char *in, char flag) } } -void mrtg_pop3log(char *in, char flag) +static void mrtg_pop3log(char *in, char flag) { int i, j = 0; diff --git a/src/qmail-newmrh.c b/src/qmail-newmrh.c index b437818..671d50b 100644 --- a/src/qmail-newmrh.c +++ b/src/qmail-newmrh.c @@ -20,12 +20,12 @@ #define WHO "qmail-newmrh" -void die_read() +static void die_read() { logmsg(WHO, 111, ERROR, "unable to read control/morercpthosts"); } -void die_write() +static void die_write() { logmsg(WHO, 111, ERROR, "unable to write to control/morercpthosts.tmp"); } diff --git a/src/qmail-newu.c b/src/qmail-newu.c index 953f243..ed68742 100644 --- a/src/qmail-newu.c +++ b/src/qmail-newu.c @@ -21,42 +21,42 @@ #define WHO "qmail-newu" -void die_chdir() +static void die_chdir() { logmsg(WHO, 110, ERROR, "unable to chdir"); } -void die_nomem() +static void die_nomem() { logmsg(WHO, 111, FATAL, "fatal: out of memory"); } -void die_opena() +static void die_opena() { logmsg(WHO, 112, ERROR, "unable to open users/assign"); } -void die_reada() +static void die_reada() { logmsg(WHO, 110, ERROR, "unable to read users/assign"); } -void die_format() +static void die_format() { logmsg(WHO, 112, ERROR, "bad format in users/assign"); } -void die_opent() +static void die_opent() { logmsg(WHO, 112, ERROR, "unable to open users/assign.cdb.tmp"); } -void die_writet() +static void die_writet() { logmsg(WHO, 112, ERROR, "unable to write users/assign.cdb.tmp"); } -void die_rename() +static void die_rename() { logmsg(WHO, 112, ERROR, "unable to move users/cdb.tmp to users/assign.cdb"); } diff --git a/src/qmail-pop3d.c b/src/qmail-pop3d.c index 795bedc..7fef483 100644 --- a/src/qmail-pop3d.c +++ b/src/qmail-pop3d.c @@ -23,12 +23,12 @@ #define FDIN 0 #define FDOUT 1 -void die() +static void die() { _exit(0); } -ssize_t saferead(int fd, char *buf, int len) +static ssize_t saferead(int fd, char *buf, int len) { int r; r = timeoutread(1200, fd, buf, len); @@ -36,7 +36,7 @@ ssize_t saferead(int fd, char *buf, int len) return r; } -ssize_t safewrite(int fd, char *buf, int len) +static ssize_t safewrite(int fd, char *buf, int len) { int r; r = timeoutwrite(1200, fd, buf, len); @@ -50,22 +50,22 @@ buffer bo = BUFFER_INIT(safewrite, FDOUT, outbuf, sizeof(outbuf)); char inbuf[128]; buffer bi = BUFFER_INIT(saferead, FDIN, inbuf, sizeof(inbuf)); -void out(char *buf, int len) +static void out(char *buf, int len) { buffer_put(&bo, buf, len); } -void outs(char *s) +static void outs(char *s) { buffer_puts(&bo, s); } -void flush() +static void flush() { buffer_flush(&bo); } -void err(char *s) +static void err(char *s) { outs("-ERR "); outs(s); @@ -73,66 +73,66 @@ void err(char *s) flush(); } -void die_nomem() +static void die_nomem() { err("out of memory"); die(); } -void die_nomaildir() +static void die_nomaildir() { err("this user has no $HOME/Maildir"); die(); } -void die_scan() +static void die_scan() { err("unable to scan $HOME/Maildir"); die(); } -void err_syntax() +static void err_syntax() { err("syntax error"); } -void err_unimpl() +static void err_unimpl() { err("unimplemented"); } -void err_deleted() +static void err_deleted() { err("already deleted"); } -void err_nozero() +static void err_nozero() { err("messages are counted from 1"); } -void err_toobig() +static void err_toobig() { err("not that many messages"); } -void err_nosuch() +static void err_nosuch() { err("unable to open that message"); } -void err_nounlink() +static void err_nounlink() { err("unable to unlink all deleted messages"); } -void okay() +static void okay() { outs("+OK \r\n"); flush(); } -void printfn(char *fn) +static void printfn(char *fn) { fn += 4; out(fn, str_chr(fn, ':')); @@ -141,7 +141,7 @@ void printfn(char *fn) char strnum[FMT_ULONG]; stralloc line = {0}; -void blast(buffer *bf, unsigned long limit) +static void blast(buffer *bf, unsigned long limit) { int match; int inheaders = 1; @@ -178,7 +178,7 @@ struct message { int numm; int last = 0; -void getlist() +static void getlist() { struct prioq_elt pe; struct stat st; @@ -206,7 +206,7 @@ void getlist() } } -void pop3_stat() +static void pop3_stat() { int i; unsigned long total; @@ -223,7 +223,7 @@ void pop3_stat() flush(); } -void pop3_rset() +static void pop3_rset() { int i; @@ -232,7 +232,7 @@ void pop3_rset() okay(); } -void pop3_last() +static void pop3_last() { outs("+OK "); out(strnum, fmt_uint(strnum, last)); @@ -240,7 +240,7 @@ void pop3_last() flush(); } -void pop3_quit() +static void pop3_quit() { int i; @@ -261,7 +261,7 @@ void pop3_quit() die(); } -int msgno(char *arg) +static int msgno(char *arg) { unsigned long u; @@ -285,7 +285,7 @@ int msgno(char *arg) return u; } -void pop3_dele(char *arg) +static void pop3_dele(char *arg) { int i; @@ -296,7 +296,7 @@ void pop3_dele(char *arg) okay(); } -void list(int i, int flaguidl) +static void list(int i, int flaguidl) { out(strnum, fmt_uint(strnum, i + 1)); outs(" "); @@ -307,7 +307,7 @@ void list(int i, int flaguidl) outs("\r\n"); } -void dolisting(char *arg, int flaguidl) +static void dolisting(char *arg, int flaguidl) { unsigned int i; @@ -326,12 +326,12 @@ void dolisting(char *arg, int flaguidl) flush(); } -void pop3_uidl(char *arg) +static void pop3_uidl(char *arg) { dolisting(arg, 1); } -void pop3_list(char *arg) +static void pop3_list(char *arg) { dolisting(arg, 0); } @@ -339,7 +339,7 @@ void pop3_list(char *arg) char msgbuf[1024]; buffer bm; -void pop3_top(char *arg) +static void pop3_top(char *arg) { int i; unsigned long limit; diff --git a/src/qmail-popup.c b/src/qmail-popup.c index e94e9a7..c8ee5a4 100644 --- a/src/qmail-popup.c +++ b/src/qmail-popup.c @@ -26,12 +26,12 @@ #define FDAUTH 3 #define FDLOG 5 -void die() +static void die() { _exit(1); } -ssize_t saferead(int fd, char *buf, int len) +static ssize_t saferead(int fd, char *buf, int len) { int r; r = timeoutread(1200, fd, buf, len); @@ -39,7 +39,7 @@ ssize_t saferead(int fd, char *buf, int len) return r; } -ssize_t safewrite(int fd, char *buf, int len) +static ssize_t safewrite(int fd, char *buf, int len) { int r; r = timeoutwrite(1200, fd, buf, len); @@ -53,17 +53,17 @@ buffer bo = BUFFER_INIT(safewrite, FDOUT, outbuf, sizeof(outbuf)); char inbuf[128]; buffer bi = BUFFER_INIT(saferead, FDIN, inbuf, sizeof(inbuf)); -void outs(char *s) +static void outs(char *s) { buffer_puts(&bo, s); } -void flush() +static void flush() { buffer_flush(&bo); } -void err(char *s) +static void err(char *s) { outs("-ERR "); outs(s); @@ -83,18 +83,18 @@ char strnum[FMT_ULONG]; char logbuf[512]; buffer bl = BUFFER_INIT(safewrite, FDLOG, logbuf, sizeof(logbuf)); -void logs(char *s) +static void logs(char *s) { if (buffer_puts(&bl, s) == -1) _exit(1); } -void logp(char *s) +static void logp(char *s) { logs(" P:"); logs(s); } -void logh(char *s1, char *s2) +static void logh(char *s1, char *s2) { logs(" S:"); logs(s1); @@ -102,20 +102,20 @@ void logh(char *s1, char *s2) logs(s2); } -void logu(char *s) +static void logu(char *s) { logs(" ?~ '"); logs(s); logs("'"); } -void logn(char *s) +static void logn(char *s) { if (buffer_puts(&bl, s) == -1) _exit(1); if (buffer_flush(&bl) == -1) _exit(1); } -void logpid() +static void logpid() { strnum[fmt_ulong(strnum, getpid())] = 0; logs("qmail-popup: pid "); @@ -123,7 +123,7 @@ void logpid() logs(" "); } -void log_pop(char *s1, char *s2, char *s3, char *s4, char *s5, char *s6) +static void log_pop(char *s1, char *s2, char *s3, char *s4, char *s5, char *s6) { logpid(); logs(s1); @@ -132,87 +132,87 @@ void log_pop(char *s1, char *s2, char *s3, char *s4, char *s5, char *s6) logh(s4, s5), logu(s6), logn("\n"); } -void die_usage() +static void die_usage() { err("usage: popup hostname subprogram"); die(); } -void die_nomem() +static void die_nomem() { err("out of memory"); die(); } -void die_pipe() +static void die_pipe() { err("unable to open pipe"); die(); } -void die_write() +static void die_write() { err("unable to write pipe"); die(); } -void die_fork() +static void die_fork() { err("unable to fork"); die(); } -void die_childcrashed() +static void die_childcrashed() { err("aack, child crashed"); } -void die_badauth() +static void die_badauth() { err("authorization failed"); } -void die_tls() +static void die_tls() { err("TLS startup failed"); die(); } -void die_notls() +static void die_notls() { err("TLS required but not negotiated"); log_pop("Reject::STLS::", "Any", "POP3", remoteip, remotehost, "unknown"); die(); } -void err_syntax() +static void err_syntax() { err("syntax error"); } -void err_wantuser() +static void err_wantuser() { err("USER first"); } -void err_authoriz() +static void err_authoriz() { err("authorization first"); } -void okay() +static void okay() { outs("+OK \r\n"); flush(); } -void pop3_quit() +static void pop3_quit() { okay(); die(); } -void poplog_init() +static void poplog_init() { if (!stralloc_copys(&protocol, "POP3")) die_nomem(); localport = env_get("TCP6LOCALPORT"); @@ -240,7 +240,7 @@ int stls = 0; int seenstls = 0; int apop = 0; -void doanddie(char *user, unsigned int userlen, char *pass) /* userlen: including 0 byte */ +static void doanddie(char *user, unsigned int userlen, char *pass) /* userlen: including 0 byte */ { int child; int wstat; @@ -283,7 +283,7 @@ void doanddie(char *user, unsigned int userlen, char *pass) /* userlen: includin die(); } -void pop3_greet() +static void pop3_greet() { char *s; s = unique; @@ -304,7 +304,7 @@ void pop3_greet() flush(); } -void pop3_user(char *arg) +static void pop3_user(char *arg) { if (stls == 2 && !seenstls) die_notls(); if (!*arg) { @@ -317,7 +317,7 @@ void pop3_user(char *arg) if (!stralloc_0(&username)) die_nomem(); } -void pop3_pass(char *arg) +static void pop3_pass(char *arg) { if (!seenuser) { err_wantuser(); @@ -331,7 +331,7 @@ void pop3_pass(char *arg) doanddie(username.s, username.len, arg); } -void pop3_apop(char *arg) +static void pop3_apop(char *arg) { char *space; @@ -346,7 +346,7 @@ void pop3_apop(char *arg) doanddie(arg, space - arg, space); } -void pop3_capa(char *arg) +static void pop3_capa(char *arg) { outs("+OK capability list follows\r\n"); outs("TOP\r\n"); @@ -358,7 +358,7 @@ void pop3_capa(char *arg) flush(); } -void pop3_stls(char *arg) +static void pop3_stls(char *arg) { if (stls == 0 || seenstls == 1) return err("STLS not available"); outs("+OK starting TLS negotiation\r\n"); diff --git a/src/qmail-pw2u.c b/src/qmail-pw2u.c index 1ed7568..948270c 100644 --- a/src/qmail-pw2u.c +++ b/src/qmail-pw2u.c @@ -27,37 +27,37 @@ #define WHO "qmail-pw2u" -void die_chdir() +static void die_chdir() { buffer_putsflush(buffer_2, "qmail-pw2u: fatal: unable to chdir\n"); _exit(111); } -void die_nomem() +static void die_nomem() { buffer_putsflush(buffer_2, "qmail-pw2u: fatal: out of memory\n"); _exit(111); } -void die_read() +static void die_read() { buffer_putsflush(buffer_2, "qmail-pw2u: fatal: unable to read input\n"); _exit(111); } -void die_write() +static void die_write() { buffer_putsflush(buffer_2, "qmail-pw2u: fatal: unable to write output\n"); _exit(111); } -void die_control() +static void die_control() { buffer_putsflush(buffer_2, "qmail-pw2u: fatal: unable to read controls\n"); _exit(111); } -void die_alias() +static void die_alias() { buffer_puts(buffer_2, "qmail-pw2u: fatal: unable to find "); buffer_puts(buffer_2, auto_usera); @@ -66,7 +66,7 @@ void die_alias() _exit(111); } -void die_home(char *fn) +static void die_home(char *fn) { buffer_puts(buffer_2, "qmail-pw2u: fatal: unable to stat "); buffer_puts(buffer_2, fn); @@ -75,7 +75,7 @@ void die_home(char *fn) _exit(111); } -void die_user(char *s, unsigned int len) +static void die_user(char *s, unsigned int len) { buffer_puts(buffer_2, "qmail-pw2u: fatal: unable to find "); buffer_put(buffer_2, s, len); @@ -114,7 +114,7 @@ unsigned long uid; stralloc line = {0}; -void doaccount() +static void doaccount() { struct stat st; int i; @@ -234,7 +234,7 @@ void doaccount() stralloc sub = {0}; -void dosubuser() +static void dosubuser() { int i; char *x; diff --git a/src/qmail-qmaint.c b/src/qmail-qmaint.c index c0dac40..2c6e23a 100644 --- a/src/qmail-qmaint.c +++ b/src/qmail-qmaint.c @@ -57,22 +57,22 @@ int qmailr_uid; int qmail_gid; int split_num; -void die_make(char *name) +static void die_make(char *name) { logmsg(WHO, 111, ERROR, B("Failed to make: ", name)); } -void die_user(char *user) +static void die_user(char *user) { logmsg(WHO, 111, ERROR, B("Failed to determine uid of: ", user)); } -void die_group(char *group) +static void die_group(char *group) { logmsg(WHO, 111, ERROR, B("Failed to determine gid of: ", group)); } -void die_check() +static void die_check() { logmsg( WHO, @@ -82,7 +82,7 @@ void die_check() "permission to access it."); } -void die_recon() +static void die_recon() { logmsg( WHO, @@ -91,14 +91,14 @@ void die_recon() "Failed to reconstruct queue. \nEnsure the queue exists and you have permission to modify it."); } -void die_nomem() +static void die_nomem() { logmsg(WHO, 110, ERROR, "Out of memory."); } /*returns 1==yes, 0==no*/ -int confirm() +static int confirm() { int match; @@ -122,7 +122,7 @@ int confirm() logmsg(WHO, 0, WARN, B("It looks like ownerships are wrong for ", name, " should I fix them? (Y/n)")) #define COWNER logmsg(WHO, 0, WARN, B("Changing ownership: ", name, " => ", unum, "/", gnum)) -int check_item(char *name, int uid, int gid, int perm, char type, int size) +static int check_item(char *name, int uid, int gid, int perm, char type, int size) { struct stat st; int fd; @@ -290,7 +290,7 @@ int check_item(char *name, int uid, int gid, int perm, char type, int size) return 0; } -int check_files(char *directory, int uid, int gid, int perm) +static int check_files(char *directory, int uid, int gid, int perm) { DIR *dir; direntry *d; @@ -313,7 +313,7 @@ int check_files(char *directory, int uid, int gid, int perm) return 0; } -void warn_files(char *directory) +static void warn_files(char *directory) { DIR *dir; direntry *d; @@ -340,7 +340,8 @@ void warn_files(char *directory) " that shouldn't be there. I will not remove them. You should consider checking it out.")); } -int check_splits(char *directory, int dir_uid, int dir_gid, int dir_perm, int file_gid, int file_perm) +static int check_splits( + char *directory, int dir_uid, int dir_gid, int dir_perm, int file_gid, int file_perm) { DIR *dir; direntry *d; @@ -376,7 +377,7 @@ int check_splits(char *directory, int dir_uid, int dir_gid, int dir_perm, int fi return 0; } -int rename_mess(char *dir, char *part, char *new_part, char *old_filename, char *new_filename) +static int rename_mess(char *dir, char *part, char *new_part, char *old_filename, char *new_filename) { if (flag_interactive && !flag_namefix) { @@ -409,7 +410,7 @@ int rename_mess(char *dir, char *part, char *new_part, char *old_filename, char return 0; } -int fix_part(char *part) +static int fix_part(char *part) { DIR *dir; direntry *d; @@ -486,7 +487,7 @@ int fix_part(char *part) return 0; } -int fix_names() +static int fix_names() { int i; @@ -502,7 +503,7 @@ int fix_names() return 0; } -int check_dirs() +static int check_dirs() { /*check root existence*/ if (!stralloc_copy(&check_dir, &queue_dir)) die_nomem(); @@ -594,61 +595,61 @@ int check_dirs() stralloc fn = {0}; -void fnmake_init() +static void fnmake_init() { while (!stralloc_ready(&fn, FMTQFN)) die_nomem(); } -void fnmake_local(unsigned long id) +static void fnmake_local(unsigned long id) { fn.len = fmtqfn(fn.s, "local/", id, 1); } -void fnmake_remote(unsigned long id) +static void fnmake_remote(unsigned long id) { fn.len = fmtqfn(fn.s, "remote/", id, 1); } -void fnmake_mess(unsigned long id) +static void fnmake_mess(unsigned long id) { fn.len = fmtqfn(fn.s, "mess/", id, 1); } -void fnmake_dkim(unsigned long id) +static void fnmake_dkim(unsigned long id) { fn.len = fmtqfn(fn.s, "dkim/", id, 1); } -void fnmake_info(unsigned long id) +static void fnmake_info(unsigned long id) { fn.len = fmtqfn(fn.s, "info/", id, 1); } -void fnmake_bounce(unsigned long id) +static void fnmake_bounce(unsigned long id) { fn.len = fmtqfn(fn.s, "bounce/", id, 0); } -void warn_unlink(unsigned long id) +static void warn_unlink(unsigned long id) { char foo[FMT_ULONG]; foo[fmt_ulong(foo, id)] = 0; logmsg(WHO, 99, WARN, B("no such file to unlink #", foo)); } -void err_unlink(unsigned long id) +static void err_unlink(unsigned long id) { char foo[FMT_ULONG]; foo[fmt_ulong(foo, id)] = 0; logmsg(WHO, 100, ERROR, B("trouble with unlinking #", foo)); } -void err_chdir() +static void err_chdir() { logmsg(WHO, 110, FATAL, "unable to chdir"); } -int delete_msg(unsigned long id) +static int delete_msg(unsigned long id) { struct stat st; int bounce = 1; diff --git a/src/qmail-qmqpc.c b/src/qmail-qmqpc.c index 7ee80d7..ad14ce3 100644 --- a/src/qmail-qmqpc.c +++ b/src/qmail-qmqpc.c @@ -29,53 +29,53 @@ #define PORT_QMQP 628 -void die_success() +static void die_success() { _exit(0); } -void die_perm() +static void die_perm() { _exit(31); } -void nomem() +static void nomem() { _exit(51); } -void die_read() +static void die_read() { if (errno == ENOMEM) nomem(); _exit(54); } -void die_control() +static void die_control() { _exit(55); } -void die_socket() +static void die_socket() { _exit(56); } -void die_home() +static void die_home() { _exit(61); } -void die_temp() +static void die_temp() { _exit(71); } -void die_conn() +static void die_conn() { _exit(74); } -void die_format() +static void die_format() { _exit(91); } @@ -83,7 +83,7 @@ void die_format() int lasterror = 55; int qmqpfd; -ssize_t saferead(int fd, char *buf, int len) +static ssize_t saferead(int fd, char *buf, int len) { int r; r = timeoutread(60, qmqpfd, buf, len); @@ -91,7 +91,7 @@ ssize_t saferead(int fd, char *buf, int len) return r; } -ssize_t safewrite(int fd, char *buf, int len) +static ssize_t safewrite(int fd, char *buf, int len) { int r; r = timeoutwrite(60, qmqpfd, buf, len); @@ -112,7 +112,7 @@ stralloc aftermessage = {0}; char strnum[FMT_ULONG]; stralloc line = {0}; -void getmess() +static void getmess() { int match; @@ -148,7 +148,7 @@ void getmess() } } -void doit(char *server) +static void doit(char *server) { struct ip4_address ip4s; struct ip6_address ip6s; diff --git a/src/qmail-qmqpd.c b/src/qmail-qmqpd.c index 7aa5e73..9a81fb1 100644 --- a/src/qmail-qmqpd.c +++ b/src/qmail-qmqpd.c @@ -22,12 +22,12 @@ #define PORT_QMQP "628" -void resources() +static void resources() { _exit(111); } -ssize_t safewrite(int fd, char *buf, int len) +static ssize_t safewrite(int fd, char *buf, int len) { int r; r = write(fd, buf, len); @@ -35,7 +35,7 @@ ssize_t safewrite(int fd, char *buf, int len) return r; } -ssize_t saferead(int fd, char *buf, int len) +static ssize_t saferead(int fd, char *buf, int len) { int r; r = read(fd, buf, len); @@ -50,13 +50,13 @@ buffer bo = BUFFER_INIT(safewrite, 1, outbuf, sizeof(outbuf)); unsigned long bytesleft = 100; -void getbyte(char *ch) +static void getbyte(char *ch) { if (!bytesleft--) _exit(100); buffer_get(&bi, ch, 1); } -unsigned long getlen() +static unsigned long getlen() { unsigned long len = 0; char ch; @@ -69,7 +69,7 @@ unsigned long getlen() } } -void getcomma() +static void getcomma() { char ch; getbyte(&ch); @@ -78,7 +78,7 @@ void getcomma() struct qmail qq; -void identify() +static void identify() { char *remotehost; char *remoteinfo; @@ -110,7 +110,7 @@ void identify() char buf[1000]; char strnum[FMT_ULONG]; -int getbuf() +static int getbuf() { unsigned long len; int i; diff --git a/src/qmail-qmtpd.c b/src/qmail-qmtpd.c index bb08fcc..4d93f1a 100644 --- a/src/qmail-qmtpd.c +++ b/src/qmail-qmtpd.c @@ -30,17 +30,17 @@ /** @file qmail-qmtpd.c -- QMTP/QMTPS server @brief requires sslserver */ -void badproto() +static void badproto() { _exit(100); } -void resources() +static void resources() { _exit(111); } -ssize_t safewrite(int fd, char *buf, int len) +static ssize_t safewrite(int fd, char *buf, int len) { int r; r = write(fd, buf, len); @@ -51,7 +51,7 @@ ssize_t safewrite(int fd, char *buf, int len) char outbuf[256]; buffer bo = BUFFER_INIT(safewrite, 1, outbuf, sizeof(outbuf)); -ssize_t saferead(int fd, char *buf, int len) +static ssize_t saferead(int fd, char *buf, int len) { int r; buffer_flush(&bo); @@ -63,7 +63,7 @@ ssize_t saferead(int fd, char *buf, int len) char inbuf[512]; buffer bi = BUFFER_INIT(saferead, 0, inbuf, sizeof(inbuf)); -unsigned long getlen() +static unsigned long getlen() { unsigned long len = 0; char ch; @@ -76,7 +76,7 @@ unsigned long getlen() } } -void getcomma() +static void getcomma() { char ch; buffer_get(&bi, &ch, 1); @@ -114,7 +114,7 @@ char *dnemail; int seentls = 0; -int modssl_info() +static int modssl_info() { tlsversion = env_get("SSL_PROTOCOL"); if (!tlsversion) return 0; diff --git a/src/qmail-qread.c b/src/qmail-qread.c index a0925ad..5b2b6e7 100644 --- a/src/qmail-qread.c +++ b/src/qmail-qread.c @@ -23,13 +23,13 @@ readsubdir rs; -void die(int n) +static void die(int n) { buffer_flush(buffer_1); _exit(n); } -void warn(char *s1, char *s2) +static void warn(char *s1, char *s2) { char *x; x = error_str(errno); @@ -40,25 +40,25 @@ void warn(char *s1, char *s2) buffer_puts(buffer_1, "\n"); } -void die_nomem() +static void die_nomem() { buffer_puts(buffer_1, "fatal: out of memory\n"); die(111); } -void die_chdir() +static void die_chdir() { warn("fatal: unable to chdir", ""); die(110); } -void die_opendir(fn) char *fn; +static void die_opendir(char *fn) { warn("fatal: unable to opendir ", fn); die(110); } -void err(unsigned long id) +static void err(unsigned long id) { char foo[FMT_ULONG]; foo[fmt_ulong(foo, id)] = 0; @@ -79,7 +79,7 @@ datetime_sec qtime; int flagbounce; unsigned long size; -unsigned int fmtstats(char *s) +static unsigned int fmtstats(char *s) { struct datetime dt; unsigned int len; @@ -122,7 +122,7 @@ unsigned int fmtstats(char *s) stralloc stats = {0}; -void out(char *s, unsigned int n) +static void out(char *s, unsigned int n) { while (n > 0) { buffer_put(buffer_1, ((*s >= 32) && (*s <= 126)) ? s : "_", 1); @@ -131,17 +131,17 @@ void out(char *s, unsigned int n) } } -void outs(char *s) +static void outs(char *s) { out(s, str_len(s)); } -void outok(char *s) +static void outok(char *s) { buffer_puts(buffer_1, s); } -void putstats() +static void putstats() { if (!stralloc_ready(&stats, fmtstats(FMT_LEN))) die_nomem(); stats.len = fmtstats(stats.s); diff --git a/src/qmail-queue.c b/src/qmail-queue.c index fe75ffa..9bb0ab1 100644 --- a/src/qmail-queue.c +++ b/src/qmail-queue.c @@ -19,7 +19,7 @@ #include "extra.h" #include "fmtqfn.h" #include "now.h" -#include "triggerpull.h" +#include "trigger.h" #ifdef USE_CONFIG #include "fehsqm-config.h" @@ -51,7 +51,7 @@ int intdfd; int flagmademess = 0; int flagmadeintd = 0; -void cleanup() +static void cleanup() { if (flagmadeintd) { seek_trunc(intdfd, 0); @@ -63,35 +63,35 @@ void cleanup() } } -void die(int e) +static void die(int e) { _exit(e); } -void die_qhpsi() +static void die_qhpsi() { cleanup(); die(71); } -void die_write() +static void die_write() { cleanup(); die(53); } -void die_read() +static void die_read() { cleanup(); die(54); } -void sigalrm() +static void sigalrm() { /* thou shalt not clean up here */ die(52); } -void sigbug() +static void sigbug() { die(81); } @@ -144,7 +144,7 @@ static unsigned int receivedfmt(char *s) return len; } -void received_setup() +static void received_setup() { receivedlen = receivedfmt((char *)0); received = alloc(receivedlen + 1); @@ -152,7 +152,7 @@ void received_setup() receivedfmt(received); } -unsigned int pidfmt(char *s, unsigned long seq) +static unsigned int pidfmt(char *s, unsigned long seq) { unsigned int i; unsigned int len; @@ -182,7 +182,7 @@ unsigned int pidfmt(char *s, unsigned long seq) return len; } -char *fnnum(char *dirslash, int flagsplit) +static char *fnnum(char *dirslash, int flagsplit) { char *s; @@ -192,7 +192,7 @@ char *fnnum(char *dirslash, int flagsplit) return s; } -void pidopen(void) +static void pidopen(void) { unsigned int len; unsigned long seq; @@ -214,7 +214,7 @@ void pidopen(void) char *qhpsi; -void qhpsiprog(char *arg) +static void qhpsiprog(char *arg) { int wstat; int child; diff --git a/src/qmail-recipients.c b/src/qmail-recipients.c index 2b5b88e..899948f 100644 --- a/src/qmail-recipients.c +++ b/src/qmail-recipients.c @@ -20,12 +20,12 @@ #define WHO "qmail-recipients" -void die_read() +static void die_read() { logmsg(WHO, 111, ERROR, "unable to read users/recipients"); } -void die_write() +static void die_write() { logmsg(WHO, 111, ERROR, "unable to write to users/recipients.tmp"); } diff --git a/src/qmail-remote.c b/src/qmail-remote.c index 1227b81..c086d14 100644 --- a/src/qmail-remote.c +++ b/src/qmail-remote.c @@ -121,7 +121,7 @@ void out(char *s) if (buffer_puts(&bs, s) == -1) _exit(0); } -void zero() +static void zero() { if (buffer_put(&bs, "\0", 1) == -1) _exit(0); } @@ -147,7 +147,7 @@ void outsafe(stralloc *sa) } } -void temp_noip() +static void temp_noip() { out("ZInvalid ipaddr in control/domainips (#4.3.0)\n"); zerodie(); @@ -159,13 +159,13 @@ void temp_nomem() zerodie(); } -void temp_oserr() +static void temp_oserr() { out("ZSystem resources temporarily unavailable. (#4.3.0)\n"); zerodie(); } -void temp_osip() +static void temp_osip() { out("ZCan't bind to local ip address: "); outsafe(&sendip); @@ -173,7 +173,7 @@ void temp_osip() zerodie(); } -void temp_noconn() +static void temp_noconn() { out("ZSorry, I wasn't able to establish an SMTP connection: "); outsafe(&canonhost); @@ -181,7 +181,7 @@ void temp_noconn() zerodie(); } -void temp_qmtpnoc() +static void temp_qmtpnoc() { out("ZSorry, I wasn't able to establish an QMTP connection: "); outsafe(&canonhost); @@ -189,13 +189,13 @@ void temp_qmtpnoc() zerodie(); } -void temp_read() +static void temp_read() { out("ZUnable to read message. (#4.3.0)\n"); zerodie(); } -void temp_dnscanon() +static void temp_dnscanon() { out("ZCNAME lookup failed temporarily for: "); outsafe(&canonhost); @@ -203,7 +203,7 @@ void temp_dnscanon() zerodie(); } -void temp_dns() +static void temp_dns() { out("ZSorry, I couldn't find any host named: "); outsafe(&host); @@ -211,7 +211,7 @@ void temp_dns() zerodie(); } -void temp_nomx() +static void temp_nomx() { out("ZSorry, I couldn't find a mail exchanger or IP address for: "); outsafe(&host); @@ -219,37 +219,37 @@ void temp_nomx() zerodie(); } -void temp_chdir() +static void temp_chdir() { out("ZUnable to switch to home directory. (#4.3.0)\n"); zerodie(); } -void temp_control() +static void temp_control() { out("ZUnable to read control files. (#4.3.0)\n"); zerodie(); } -void perm_partialline() +static void perm_partialline() { out("DSMTP cannot transfer messages with partial final lines. (#5.6.2)\n"); zerodie(); } -void temp_proto() +static void temp_proto() { out("ZRecipient did not talk proper QMTP (#4.3.0)\n"); zerodie(); } -void perm_usage() +static void perm_usage() { out("Dqmail-remote was invoked improperly. (#5.3.5)\n"); zerodie(); } -void perm_dns() +static void perm_dns() { out("DSorry, I couldn't find any host named: "); outsafe(&host); @@ -257,7 +257,7 @@ void perm_dns() zerodie(); } -void perm_nomx() +static void perm_nomx() { out("DSorry, I couldn't find a mail exchanger or IP address for: "); outsafe(&host); @@ -265,19 +265,19 @@ void perm_nomx() zerodie(); } -void perm_ambigmx() +static void perm_ambigmx() { out("DSorry. Although I'm listed as a best-preference MX or A for that host,\n" "it isn't in my control/locals file, so I don't treat it as local. (#5.4.6)\n"); zerodie(); } -void err_authprot() +static void err_authprot() { out("KNo supported AUTH method found, continuing without authentication.\n"); } -void outhost() +static void outhost() { char ipaddr[IPFMT]; int len; @@ -291,7 +291,7 @@ void outhost() int flagcritical = 0; -void dropped() +static void dropped() { out("ZConnected to "); outhost(); @@ -305,7 +305,7 @@ long timeoutconnect = 60; int smtpfd; long timeout = 1200; -ssize_t saferead(int fd, char *buf, int len) +static ssize_t saferead(int fd, char *buf, int len) { int r; if (ssl) { @@ -318,7 +318,7 @@ ssize_t saferead(int fd, char *buf, int len) return r; } -ssize_t safewrite(int fd, char *buf, int len) +static ssize_t safewrite(int fd, char *buf, int len) { int r; if (ssl) { @@ -341,7 +341,7 @@ buffer bf = BUFFER_INIT(saferead, -1, frombuf, sizeof(frombuf)); static stralloc smtptext = {0}; static stralloc header = {0}; -void get(char *ch) +static void get(char *ch) { buffer_get(&bf, ch, 1); if (*ch != '\r') @@ -349,7 +349,7 @@ void get(char *ch) if (!stralloc_append(&smtptext, ch)) temp_nomem(); } -unsigned long smtpcode() +static unsigned long smtpcode() { unsigned char ch; unsigned long code; @@ -375,7 +375,7 @@ unsigned long smtpcode() return code; } -void outsmtptext() +static void outsmtptext() { int i; if (smtptext.s) @@ -388,7 +388,7 @@ void outsmtptext() } } -void quit(char *prepend, char *append) +static void quit(char *prepend, char *append) { buffer_putsflush(&bo, "QUIT\r\n"); /* waiting for remote side is just too ridiculous */ @@ -400,7 +400,7 @@ void quit(char *prepend, char *append) zerodie(); } -void blast() +static void blast() { int r; char ch; @@ -443,7 +443,7 @@ stralloc tlsdestinations = {0}; struct constmap maptlsdestinations; unsigned long verifydepth = VERIFYDEPTH; -void tls_init() +static void tls_init() { ctx = ssl_client(); ssl_errstr(); @@ -483,7 +483,7 @@ void tls_init() if (tls_timeoutconn(timeout, smtpfd, smtpfd, ssl) <= 0) temp_tlserr(); } -int starttls_peer() +static int starttls_peer() { int i = 0; @@ -494,7 +494,7 @@ int starttls_peer() return 0; } -void tls_peercheck() +static void tls_peercheck() { X509 *cert; STACK_OF(X509) * certs; @@ -573,7 +573,7 @@ int utf8string(unsigned char *ch, int len) return 0; } -int utf8received() +static int utf8received() { int r; int i; @@ -616,7 +616,7 @@ int utf8received() unsigned long code; int flagsize = 0; -int smtp_size() +static int smtp_size() { int i; if (smtptext.len > 10) { @@ -627,7 +627,7 @@ int smtp_size() return 0; } -void smtp_greeting() +static void smtp_greeting() { buffer_puts(&bo, "EHLO "); buffer_put(&bo, helohost.s, helohost.len); @@ -648,7 +648,7 @@ void smtp_greeting() flagsize = smtp_size(); } -void smtp_starttls() +static void smtp_starttls() { buffer_puts(&bo, "STARTTLS\r\n"); buffer_flush(&bo); @@ -663,7 +663,7 @@ void smtp_starttls() } } -void mailfrom() +static void mailfrom() { buffer_puts(&bo, "MAIL FROM:<"); buffer_put(&bo, sender.s, sender.len); @@ -692,7 +692,7 @@ stralloc xuser = {0}; static const char hextab[] = "0123456789abcdef"; -int xtext(stralloc *sa, char *s, int len) +static int xtext(stralloc *sa, char *s, int len) { int i; unsigned char c; @@ -713,7 +713,7 @@ int xtext(stralloc *sa, char *s, int len) return sa->len; } -void mailfrom_xtext() +static void mailfrom_xtext() { if (!xtext(&xuser, user.s, user.len)) temp_nomem(); buffer_puts(&bo, "MAIL FROM:<"); @@ -729,7 +729,7 @@ void mailfrom_xtext() buffer_flush(&bo); } -int mailfrom_plain() +static int mailfrom_plain() { buffer_puts(&bo, "AUTH PLAIN\r\n"); buffer_flush(&bo); @@ -755,7 +755,7 @@ int mailfrom_plain() return 0; } -int mailfrom_login() +static int mailfrom_login() { buffer_puts(&bo, "AUTH LOGIN\r\n"); buffer_flush(&bo); @@ -785,7 +785,7 @@ int mailfrom_login() return 0; } -int mailfrom_cram() +static int mailfrom_cram() { int j; unsigned char digest[16]; @@ -831,7 +831,7 @@ int mailfrom_cram() return 0; } -void smtp_auth() +static void smtp_auth() { int i; @@ -851,7 +851,7 @@ void smtp_auth() /* this file is too long ------------------------------------------- GO ON */ -void smtp() +static void smtp() { int flagbother; int i; @@ -962,7 +962,7 @@ void smtp() int qmtpsend = 0; -void qmtp() +static void qmtp() { unsigned long len; char *x; @@ -1076,7 +1076,7 @@ void qmtp() /* host has to be canonical [A/AAAA record], box has to be quoted */ -void addrmangle(stralloc *saout, char *address, int *flagalias, int flagcname) +static void addrmangle(stralloc *saout, char *address, int *flagalias, int flagcname) { int at; int r = 0; @@ -1110,7 +1110,7 @@ void addrmangle(stralloc *saout, char *address, int *flagalias, int flagcname) if (!stralloc_cat(saout, &canonhost)) temp_nomem(); } -void getcontrols() +static void getcontrols() { if (control_init() == -1) temp_control(); if (control_readint(&timeout, "control/timeoutremote") == -1) temp_control(); diff --git a/src/qmail-rspawn.c b/src/qmail-rspawn.c index c4155bb..719a7db 100644 --- a/src/qmail-rspawn.c +++ b/src/qmail-rspawn.c @@ -10,6 +10,7 @@ #include "wait.h" #include "ipalloc.h" +#include "spawn.h" #include "tcpto.h" #ifdef USE_CONFIG diff --git a/src/qmail-send.c b/src/qmail-send.c index 6b7a737..2c5e514 100644 --- a/src/qmail-send.c +++ b/src/qmail-send.c @@ -72,24 +72,24 @@ int chanfdin[CHANNELS] = {2, 4}; int chanskip[CHANNELS] = {10, 20}; int flagexitasap = 0; -void sigterm() +static void sigterm() { flagexitasap = 1; } int flagrunasap = 0; -void sigalrm() +static void sigalrm() { flagrunasap = 1; } int flagreadasap = 0; -void sighup() +static void sighup() { flagreadasap = 1; } -void cleandied() +static void cleandied() { log1s("alert: lost connection to qmail-clean ... exiting\n"); flagexitasap = 1; @@ -97,7 +97,7 @@ void cleandied() int flagspawnalive[CHANNELS]; -void spawndied(int c) +static void spawndied(int c) { log1s("alert: oh no! lost spawn connection! dying...\n"); flagspawnalive[c] = 0; @@ -115,43 +115,49 @@ stralloc fn = {0}; stralloc fn2 = {0}; char fnmake_strnum[FMT_ULONG]; -void fnmake_init() +static void nomem() +{ + log1s("alert: out of memory, sleeping...\n"); + sleep(10); +} + +static void fnmake_init() { while (!stralloc_ready(&fn, FMTQFN)) nomem(); while (!stralloc_ready(&fn2, FMTQFN)) nomem(); } -void fnmake_info(unsigned long id) +static void fnmake_info(unsigned long id) { fn.len = fmtqfn(fn.s, "info/", id, 1); } -void fnmake_todo(unsigned long id) +static void fnmake_todo(unsigned long id) { fn.len = fmtqfn(fn.s, "todo/", id, 1); } -void fnmake_mess(unsigned long id) +static void fnmake_mess(unsigned long id) { fn.len = fmtqfn(fn.s, "mess/", id, 1); } -void fnmake_foop(unsigned long id) +static void fnmake_foop(unsigned long id) { fn.len = fmtqfn(fn.s, "foop/", id, 0); } -void fnmake_split(unsigned long id) +static void fnmake_split(unsigned long id) { fn.len = fmtqfn(fn.s, "", id, 1); } -void fnmake2_bounce(unsigned long id) +static void fnmake2_bounce(unsigned long id) { fn2.len = fmtqfn(fn2.s, "bounce/", id, 0); } -void fnmake_chanaddr(unsigned long id, int c) +static void fnmake_chanaddr(unsigned long id, int c) { fn.len = fmtqfn(fn.s, chanaddr[c], id, 1); } @@ -159,7 +165,7 @@ void fnmake_chanaddr(unsigned long id, int c) /* this file is too long ----------------------------------------- REWRITING */ -void senderadd(stralloc *sa, char *sender, char *recip) +static void senderadd(stralloc *sa, char *sender, char *recip) { int i; int j; @@ -188,7 +194,7 @@ void senderadd(stralloc *sa, char *sender, char *recip) /* this file is too long ---------------------------------------------- INFO */ -int getinfo(stralloc *sa, datetime_sec *dt, unsigned long id) +static int getinfo(stralloc *sa, datetime_sec *dt, unsigned long id) { int fdnumber; struct stat st; @@ -229,7 +235,7 @@ char fromqcbuf[1024]; stralloc comm_buf[CHANNELS] = {{0}, {0}}; int comm_pos[CHANNELS]; -void comm_init() +static void comm_init() { int c; @@ -241,14 +247,14 @@ void comm_init() spawndied(c); /* drastic, but better than risking deadlock */ } -int comm_canwrite(int c) +static int comm_canwrite(int c) { /* XXX: could allow a bigger buffer; say 10 recipients */ if (comm_buf[c].s && comm_buf[c].len) return 0; return 1; } -void comm_write(int c, int delnum, unsigned long id, char *sender, char *recip) +static void comm_write(int c, int delnum, unsigned long id, char *sender, char *recip) { char ch; @@ -266,7 +272,7 @@ void comm_write(int c, int delnum, unsigned long id, char *sender, char *recip) comm_pos[c] = 0; } -void comm_selprep(int *nfds, fd_set *wfds) +static void comm_selprep(int *nfds, fd_set *wfds) { int c; @@ -280,7 +286,7 @@ void comm_selprep(int *nfds, fd_set *wfds) } } -void comm_do(fd_set *wfds) +static void comm_do(fd_set *wfds) { int c; @@ -315,19 +321,19 @@ int flagcleanup; /* if 1, cleanupdir is initialized and ready */ readsubdir cleanupdir; datetime_sec cleanuptime; -void cleanup_init() +static void cleanup_init() { flagcleanup = 0; cleanuptime = now(); } -void cleanup_selprep(datetime_sec *wakeup) +static void cleanup_selprep(datetime_sec *wakeup) { if (flagcleanup) *wakeup = 0; if (*wakeup > cleanuptime) *wakeup = cleanuptime; } -void cleanup_do() +static void cleanup_do() { char ch; struct stat st; @@ -378,7 +384,7 @@ prioq pqchan[CHANNELS] = {{0}, {0}}; /* pqchan 1: -todo +info ?local +remote */ prioq pqfail = {0}; /* stat() failure; has to be pqadded again */ -void pqadd(unsigned long id) +static void pqadd(unsigned long id) { struct prioq_elt pe; struct prioq_elt pechan[CHANNELS]; @@ -433,7 +439,7 @@ FAIL: while (!prioq_insert(&pqfail, &pe)) nomem(); } -void pqstart() +static void pqstart() { readsubdir rs; int x; @@ -445,7 +451,7 @@ void pqstart() if (x > 0) pqadd(id); } -void pqfinish() +static void pqfinish() { int c; struct prioq_elt pe; @@ -463,7 +469,7 @@ void pqfinish() } } -void pqrun() +static void pqrun() { int c; int i; @@ -491,7 +497,7 @@ struct job { int numjobs; struct job *jo; -void job_init() +static void job_init() { int j; @@ -502,7 +508,7 @@ void job_init() } } -int job_avail() +static int job_avail() { int j; @@ -511,7 +517,7 @@ int job_avail() return 0; } -int job_open(unsigned long id, int channel) +static int job_open(unsigned long id, int channel) { int j; @@ -526,7 +532,7 @@ int job_open(unsigned long id, int channel) return j; } -void job_close(int j) +static void job_close(int j) { struct prioq_elt pe; struct stat st; @@ -564,7 +570,7 @@ void job_close(int j) /* this file is too long ------------------------------------------- BOUNCES */ -char *stripvdomprepend(char *recip) +static char *stripvdomprepend(char *recip) { int i; char *domain; @@ -593,7 +599,7 @@ char *stripvdomprepend(char *recip) stralloc bouncetext = {0}; -void addbounce(unsigned long id, char *recip, char *report) +static void addbounce(unsigned long id, char *recip, char *report) { int fd; int pos; @@ -640,7 +646,7 @@ void addbounce(unsigned long id, char *recip, char *report) close(fd); } -int injectbounce(unsigned long id) +static int injectbounce(unsigned long id) { struct qmail qqt; struct stat st; @@ -808,7 +814,7 @@ struct del *d[CHANNELS]; stralloc dline[CHANNELS]; char delbuf[2048]; -void del_status() +static void del_status() { int c; @@ -823,7 +829,7 @@ void del_status() log1s("\n"); } -void del_init() +static void del_init() { int c; int i; @@ -842,7 +848,7 @@ void del_init() del_status(); } -int del_canexit() +static int del_canexit() { int c; @@ -852,12 +858,12 @@ int del_canexit() return 1; } -int del_avail(int c) +static int del_avail(int c) { return flagspawnalive[c] && comm_canwrite(c) && (concurrencyused[c] < concurrency[c]); } -void del_start(int j, seek_pos mpos, char *recip) +static void del_start(int j, seek_pos mpos, char *recip) { int i; int c; @@ -896,7 +902,7 @@ void del_start(int j, seek_pos mpos, char *recip) del_status(); } -void markdone(int c, unsigned long id, seek_pos pos) +static void markdone(int c, unsigned long id, seek_pos pos) { struct stat st; int fd; @@ -925,7 +931,7 @@ void markdone(int c, unsigned long id, seek_pos pos) log3s("warning: trouble marking ", fn.s, "; message will be delivered twice!\n"); } -void del_dochan(int c) +static void del_dochan(int c) { int r; char ch; @@ -997,7 +1003,7 @@ void del_dochan(int c) } } -void del_selprep(int *nfds, fd_set *rfds) +static void del_selprep(int *nfds, fd_set *rfds) { int c; @@ -1008,7 +1014,7 @@ void del_selprep(int *nfds, fd_set *rfds) } } -void del_do(fd_set *rfds) +static void del_do(fd_set *rfds) { int c; @@ -1029,14 +1035,14 @@ struct { char buf[128]; } pass[CHANNELS]; -void pass_init() +static void pass_init() { int c; for (c = 0; c < CHANNELS; ++c) pass[c].id = 0; } -void pass_selprep(datetime_sec *wakeup) +static void pass_selprep(datetime_sec *wakeup) { int c; struct prioq_elt pe; @@ -1081,7 +1087,7 @@ static datetime_sec squareroot(datetime_sec x) /* result^2 <= x < (result + 1)^2 return y; } -datetime_sec nextretry(datetime_sec birth, int c) +static datetime_sec nextretry(datetime_sec birth, int c) { int n; @@ -1094,7 +1100,7 @@ datetime_sec nextretry(datetime_sec birth, int c) return birth + n * n; } -void pass_dochan(int c) +static void pass_dochan(int c) { datetime_sec birth; struct prioq_elt pe; @@ -1168,7 +1174,7 @@ trouble: while (!prioq_insert(&pqchan[c], &pe)) nomem(); } -void messdone(unsigned long id) +static void messdone(unsigned long id) { char ch; int c; @@ -1231,7 +1237,7 @@ FAIL: while (!prioq_insert(&pqdone, &pe)) nomem(); } -void pass_do() +static void pass_do() { int c; struct prioq_elt pe; @@ -1260,14 +1266,14 @@ int todofdin; int todofdout; int flagtodoalive; -void tododied() +static void tododied() { log1s("alert: lost connection to qmail-todo ... exiting\n"); flagexitasap = 1; flagtodoalive = 0; } -void todo_init() +static void todo_init() { todofdout = 7; todofdin = 8; @@ -1278,7 +1284,7 @@ void todo_init() return; } -void todo_selprep(int *nfds, fd_set *rfds, datetime_sec *wakeup) +static void todo_selprep(int *nfds, fd_set *rfds, datetime_sec *wakeup) { if (flagexitasap) { if (flagtodoalive) { @@ -1291,7 +1297,7 @@ void todo_selprep(int *nfds, fd_set *rfds, datetime_sec *wakeup) } } -void todo_del(char *s) +static void todo_del(char *s) { int flagchan[CHANNELS]; struct prioq_elt pe; @@ -1333,7 +1339,7 @@ void todo_del(char *s) return; } -void todo_do(fd_set *rfds) +static void todo_do(fd_set *rfds) { int r; char ch; @@ -1379,7 +1385,7 @@ void todo_do(fd_set *rfds) /* this file is too long ---------------------------------------------- MAIN */ -int getcontrols() +static int getcontrols() { if (control_init() == -1) return 0; if (control_readint(&lifetime, "control/queuelifetime") == -1) return 0; @@ -1420,7 +1426,7 @@ int getcontrols() stralloc newlocals = {0}; stralloc newvdoms = {0}; -void regetcontrols() +static void regetcontrols() { int r; @@ -1460,7 +1466,7 @@ void regetcontrols() while (!constmap_init(&mapvdoms, "", 0, 1)) nomem(); } -void reread() +static void reread() { if (chdir(auto_qmail) == -1) { log1s("alert: unable to reread controls: unable to switch to home directory\n"); diff --git a/src/qmail-showctl.c b/src/qmail-showctl.c index dd15845..96b4d7e 100644 --- a/src/qmail-showctl.c +++ b/src/qmail-showctl.c @@ -30,7 +30,7 @@ int meok; stralloc line = {0}; char num[FMT_ULONG]; -void safeput(char *buf, unsigned int len) +static void safeput(char *buf, unsigned int len) { char ch; @@ -43,7 +43,7 @@ void safeput(char *buf, unsigned int len) } } -void do_int(char *fn, char *def, char *pre, char *post) +static void do_int(char *fn, char *def, char *pre, char *post) { long i; buffer_puts(buffer_1, "\n"); @@ -68,7 +68,7 @@ void do_int(char *fn, char *def, char *pre, char *post) } } -void do_str(char *fn, int flagme, char *def, char *pre) +static void do_str(char *fn, int flagme, char *def, char *pre) { buffer_puts(buffer_1, "\n"); buffer_puts(buffer_1, fn); @@ -95,7 +95,7 @@ void do_str(char *fn, int flagme, char *def, char *pre) } } -int do_lst(char *fn, char *def, char *pre, char *post) +static int do_lst(char *fn, char *def, char *pre, char *post) { int i; int j; diff --git a/src/qmail-smtpam.c b/src/qmail-smtpam.c index 46f47a0..9ef1238 100644 --- a/src/qmail-smtpam.c +++ b/src/qmail-smtpam.c @@ -96,7 +96,7 @@ void out(char *s) if (buffer_puts(buffer_1small, s) == -1) _exit(111); } -void zero() +static void zero() { if (buffer_put(buffer_1small, "\0", 1) == -1) _exit(111); } @@ -120,7 +120,7 @@ void outsafe(stralloc *sa) } } -void temp_noip() +static void temp_noip() { out("Zinvalid ipaddr in control/domainips (#4.3.0)\n"); zerodie(); @@ -132,13 +132,13 @@ void temp_nomem() zerodie(); } -void temp_oserr() +static void temp_oserr() { out("ZSystem resources temporarily unavailable. (#4.3.0)\n"); zerodie(); } -void temp_osip() +static void temp_osip() { out("ZCan't bind to local ip address: "); outsafe(&sendip); @@ -146,13 +146,13 @@ void temp_osip() zerodie(); } -void temp_noconn() +static void temp_noconn() { out("ZSorry, I wasn't able to establish an SMTP connection. (#4.4.1)\n"); zerodie(); } -void temp_dnscanon() +static void temp_dnscanon() { out("ZCNAME lookup failed temporarily for: "); outsafe(&canonhost); @@ -160,7 +160,7 @@ void temp_dnscanon() zerodie(); } -void temp_dns() +static void temp_dns() { out("ZSorry, I couldn't find any host named: "); outsafe(&host); @@ -168,25 +168,25 @@ void temp_dns() zerodie(); } -void temp_chdir() +static void temp_chdir() { out("ZUnable to switch to home directory. (#4.3.0)\n"); zerodie(); } -void temp_control() +static void temp_control() { out("ZUnable to read control files. (#4.3.0)\n"); zerodie(); } -void perm_usage() +static void perm_usage() { out("Dqmail-smtpam was invoked improperly. (#5.3.5)\n"); zerodie(); } -void perm_dns() +static void perm_dns() { out("DSorry, I couldn't find any host named: "); outsafe(&host); @@ -194,7 +194,7 @@ void perm_dns() zerodie(); } -void outhost() +static void outhost() { char ipaddr[IPFMT]; int len; @@ -208,7 +208,7 @@ void outhost() int flagcritical = 0; -void dropped() +static void dropped() { out("ZConnected to "); outhost(); @@ -222,7 +222,7 @@ long timeoutconnect = 60; int smtpfd; long timeout = 1200; -ssize_t saferead(int fd, char *buf, int len) +static ssize_t saferead(int fd, char *buf, int len) { int r; r = timeoutread(timeout, smtpfd, buf, len); @@ -230,7 +230,7 @@ ssize_t saferead(int fd, char *buf, int len) return r; } -ssize_t safewrite(int fd, char *buf, int len) +static ssize_t safewrite(int fd, char *buf, int len) { int r; r = timeoutwrite(timeout, smtpfd, buf, len); @@ -245,7 +245,7 @@ buffer bi = BUFFER_INIT(saferead, -1, frombuf, sizeof(frombuf)); stralloc smtptext = {0}; -void get(char *ch) +static void get(char *ch) { buffer_get(&bi, ch, 1); if (*ch != '\r') @@ -253,7 +253,7 @@ void get(char *ch) if (!stralloc_append(&smtptext, ch)) temp_nomem(); } -unsigned long smtpcode() +static unsigned long smtpcode() { unsigned char ch; unsigned long code; @@ -279,7 +279,7 @@ unsigned long smtpcode() return code; } -void outsmtptext() +static void outsmtptext() { int i; if (smtptext.s) { @@ -293,7 +293,7 @@ void outsmtptext() } } -void quit(char *prepend, char *append) +static void quit(char *prepend, char *append) { buffer_putsflush(&bo, "QUIT\r\n"); /* waiting for remote side is just too ridiculous */ @@ -326,7 +326,7 @@ stralloc tlsdestinations = {0}; struct constmap maptlsdestinations; unsigned long verifydepth = VERIFYDEPTH; -void tls_init() +static void tls_init() { /* Client CTX */ @@ -357,7 +357,7 @@ void tls_init() if (tls_timeoutconn(timeout, smtpfd, smtpfd, ssl) <= 0) temp_tlserr(); } -int starttls_peer() +static int starttls_peer() { int i = 0; @@ -368,7 +368,7 @@ int starttls_peer() return 0; } -void tls_peercheck() +static void tls_peercheck() { X509 *cert; @@ -404,7 +404,7 @@ void tls_peercheck() return; } -int utf8flag(unsigned char *ch, int len) +static int utf8flag(unsigned char *ch, int len) { int i = 0; while (i < len) @@ -416,7 +416,7 @@ int utf8flag(unsigned char *ch, int len) unsigned long code; -void smtp_greeting() +static void smtp_greeting() { buffer_puts(&bo, "EHLO "); buffer_put(&bo, helohost.s, helohost.len); @@ -434,7 +434,7 @@ void smtp_greeting() } } -void smtp_starttls() +static void smtp_starttls() { buffer_puts(&bo, "STARTTLS\r\n"); buffer_flush(&bo); @@ -448,7 +448,7 @@ void smtp_starttls() } } -void smtp() +static void smtp() { if (flagtls > 10 && flagtls < 20) { /* SMTPS */ @@ -490,7 +490,7 @@ void smtp() _exit(1); } -void getcontrols() +static void getcontrols() { if (control_init() == -1) temp_control(); if (control_readint(&timeout, "control/timeoutremote") == -1) temp_control(); diff --git a/src/qmail-smtpd.c b/src/qmail-smtpd.c index 5e1497a..557649e 100644 --- a/src/qmail-smtpd.c +++ b/src/qmail-smtpd.c @@ -8,6 +8,7 @@ #include "cdbread.h" #include "close.h" #include "constmap.h" +#include "dnsresolv.h" #include "env.h" #include "exit.h" #include "fd.h" @@ -44,8 +45,10 @@ #include "auto_qmail.h" #endif -/** @file qmail-smtpd.c -- authenticating ESMTP/ESMTPS server - @brief requires sslserver or tcpserver */ +/** + * @file qmail-smtpd.c -- authenticating ESMTP/ESMTPS server + * @brief requires sslserver or tcpserver + */ #define PAM111421 #define AUTHSLEEP 5 @@ -64,7 +67,7 @@ unsigned long databytes = 0; long timeout = 1200; -int modssl_info(); +static int modssl_info(void); ssize_t safewrite(int fd, char *buf, int len) { @@ -74,7 +77,15 @@ ssize_t safewrite(int fd, char *buf, int len) return r; } -ssize_t saferead(int fd, char *buf, int len) +char outbuf[BUFFER_SIZE / 2]; +buffer bo = BUFFER_INIT(safewrite, FDOUT, outbuf, sizeof(outbuf)); + +void flush() +{ + buffer_flush(&bo); +} // this triggers writing to STDIO + +static ssize_t saferead(int fd, char *buf, int len) { int r; flush(); @@ -88,17 +99,9 @@ ssize_t saferead(int fd, char *buf, int len) char inbuf[BUFFER_SIZE]; buffer bi = BUFFER_INIT(saferead, FDIN, inbuf, sizeof(inbuf)); -char outbuf[BUFFER_SIZE / 2]; -buffer bo = BUFFER_INIT(safewrite, FDOUT, outbuf, sizeof(outbuf)); - char logbuf[256]; buffer bl = BUFFER_INIT(write, FDLOG, logbuf, sizeof(logbuf)); -void flush() -{ - buffer_flush(&bo); -} // this triggers writing to STDIO - void out(char *s) { buffer_puts(&bo, s); @@ -111,7 +114,7 @@ int bhelocheck(void); /* this file is too long -------------------------------------- DNS helper */ -int dnsq(char *arg, char type) +static int dnsq(char *arg, char type) { unsigned int random; int at; @@ -152,18 +155,18 @@ int dnsq(char *arg, char type) static stralloc greeting = {0}; -void smtp_greet(char *code) +static void smtp_greet(char *code) { buffer_puts(&bo, code); buffer_put(&bo, greeting.s, greeting.len); } -void smtp_help() +static void smtp_help() { out("214 s/qmail home page: https://www.fehcom.de/sqmail.html\r\n"); } -void smtp_quit() +static void smtp_quit() { smtp_greet("221 "); out("\r\n"); @@ -192,7 +195,7 @@ int seenhelo = 0; char *badmailcond; char *badhelocond; -void dohelo(char *helo) +static void dohelo(char *helo) { if (!stralloc_copys(&helohost, helo)) die_nomem(); if (!stralloc_0(&helohost)) die_nomem(); @@ -339,7 +342,7 @@ char *rblsmtpd; int flagspf = 0; static stralloc spfbounce = {0}; -void setup() +static void setup() { char *x; unsigned long u; @@ -547,7 +550,7 @@ void setup() fakehelo = 0; } -void auth_info(char *method) +static void auth_info(char *method) { if (!env_put("AUTHPROTOCOL", method)) die_nomem(); if (!env_put("AUTHUSER", remoteinfo)) die_nomem(); @@ -559,7 +562,7 @@ void auth_info(char *method) if (!stralloc_append(&protocol, "A")) die_nomem(); } -int modssl_info() +static int modssl_info() { tlsversion = env_get("SSL_PROTOCOL"); if (!tlsversion) return 0; @@ -623,7 +626,7 @@ int flagdnsmf = 0; int flagsize; int rcptcount = 0; -int addrparse(char *arg) +static int addrparse(char *arg) { int i; char ch; @@ -648,7 +651,7 @@ int addrparse(char *arg) if (!stralloc_copys(&addr, "")) die_nomem(); flagesc = 0; flagquoted = 0; - for (i = 0; ch = arg[i]; ++i) { /* copy arg to addr, stripping quotes */ + for (i = 0; (ch = arg[i]); ++i) { /* copy arg to addr, stripping quotes */ if (flagesc) { if (!stralloc_append(&addr, &ch)) die_nomem(); flagesc = 0; @@ -718,7 +721,7 @@ int bhelocheck() return 0; } -int bmfcheck() +static int bmfcheck() { int i = 0; int j = 0; @@ -808,7 +811,7 @@ int bmfcheck() return 0; } -int brtcheck() +static int brtcheck() { int i; int j = 0; @@ -846,7 +849,7 @@ int brtcheck() return 0; } -int addrallowed(char *arg) +static int addrallowed(char *arg) { int r; r = rcpthosts(arg, str_len(arg)); @@ -854,7 +857,7 @@ int addrallowed(char *arg) return r; } -int rcptallowed() +static int rcptallowed() { int r; r = recipients(addr.s, str_len(addr.s)); @@ -867,7 +870,7 @@ int rcptallowed() return r; } -int localaddr(char *mf) +static int localaddr(char *mf) { int at; int mflen; @@ -896,7 +899,7 @@ int localaddr(char *mf) } } -int spf_check(int flag6) +static int spf_check(int flag6) { int r; @@ -961,7 +964,7 @@ int spf_check(int flag6) /* this file is too long --------------------------------- MF parser */ -int mailfrom_size(char *arg) +static int mailfrom_size(char *arg) { unsigned long r; unsigned long sizebytes = 0; @@ -973,7 +976,7 @@ int mailfrom_size(char *arg) return 0; } -void mailfrom_auth(char *arg, int len) +static void mailfrom_auth(char *arg, int len) { if (!stralloc_copys(&fuser, "")) die_nomem(); if (case_starts(arg, "<>")) { @@ -1009,7 +1012,7 @@ void mailfrom_auth(char *arg, int len) } } -void mailfrom_parms(char *arg) +static void mailfrom_parms(char *arg) { int len; @@ -1037,7 +1040,7 @@ void mailfrom_parms(char *arg) /* this file is too long --------------------------------- SMTP dialog */ -void smtp_helo(char *arg) +static void smtp_helo(char *arg) { smtp_greet("250 "); out("\r\n"); @@ -1048,7 +1051,7 @@ void smtp_helo(char *arg) dohelo(arg); } -void smtp_ehlo(char *arg) +static void smtp_ehlo(char *arg) { char size[FMT_ULONG]; @@ -1078,8 +1081,10 @@ void smtp_ehlo(char *arg) dohelo(arg); } -void smtp_rset(void) +static void smtp_rset(char *x) { + (void)x; + seenmail = 0; rcptcount = 0; /* RFC 5321: seenauth + seentls stay */ @@ -1088,7 +1093,7 @@ void smtp_rset(void) out("250 flushed\r\n"); } -void smtp_starttls() +static void smtp_starttls() { if (starttls == 0) err_starttls(); @@ -1114,7 +1119,7 @@ void smtp_starttls() if (seenauth == 1) seenauth = 0; /* Otherwise Auth by client Cert */ } -void smtp_mail(char *arg) +static void smtp_mail(char *arg) { if (flagutf8) if (!stralloc_cats(&protocol, "UTF8")) die_nomem(); @@ -1156,7 +1161,7 @@ void smtp_mail(char *arg) /* this file is too long --------------------------------- Greylisting */ -int postgrey_scanner() +static int postgrey_scanner() { int child; int wstat; @@ -1178,7 +1183,7 @@ int postgrey_scanner() } } -void smtp_rcpt(char *arg) +static void smtp_rcpt(char *arg) { char *rcptok = 0; if (!seenmail) { @@ -1535,7 +1540,7 @@ static void queue_put(char *ch) qmail_put(&qqt, ch, 1); } -void blast(int *hops) +static void blast(int *hops) { char ch; int state; @@ -1640,7 +1645,7 @@ void blast(int *hops) char accept_buf[FMT_ULONG]; -void acceptmessage(unsigned long qp) +static void acceptmessage(unsigned long qp) { datetime_sec when; when = now(); @@ -1653,7 +1658,7 @@ void acceptmessage(unsigned long qp) out("\r\n"); } -void smtp_data() +static void smtp_data() { int hops; unsigned long qp; @@ -1822,7 +1827,7 @@ char **childargs; char authbuf[512]; buffer ba = BUFFER_INIT(safewrite, FDAUTH, authbuf, sizeof(authbuf)); -int authgetl(void) +static int authgetl() { int i; @@ -1843,7 +1848,7 @@ int authgetl(void) return authin.len; } -int authenticate(void) +static int authenticate() { int child; int wstat; @@ -1882,11 +1887,11 @@ int authenticate(void) if (wait_exitcode(wstat)) { sleep(AUTHSLEEP); return 1; - } /* no */ + } /* no */ return 0; /* yes */ } -int auth_login(char *arg) +static int auth_login(char *arg) { int r; if (smtpauth == 2 || smtpauth == 12) return 1; /* only login/plain */ @@ -1912,7 +1917,7 @@ int auth_login(char *arg) return authenticate(); } -int auth_plain(char *arg) +static int auth_plain(char *arg) { int r, id = 0; if (smtpauth == 2 || smtpauth == 12) return 1; /* only login/plain */ @@ -1937,7 +1942,7 @@ int auth_plain(char *arg) return authenticate(); } -int auth_cram() +static int auth_cram() { int i, r; char *s; @@ -1976,17 +1981,23 @@ int auth_cram() return authenticate(); } +static int err_noauth_handler(char *s) +{ + (void)s; + return err_noauth(); +} + struct authcmd { char *text; - int (*fun)(); + int (*fun)(char *); } authcmds[] = { - { "login", auth_login}, - { "plain", auth_plain}, - {"cram-md5", auth_cram}, - { 0, err_noauth} + { "login", auth_login}, + { "plain", auth_plain}, + {"cram-md5", auth_cram}, + { 0, err_noauth_handler} }; -void smtp_auth(char *arg) +static void smtp_auth(char *arg) { int i; char *cmd = arg; @@ -2067,20 +2078,38 @@ void smtp_auth(char *arg) /* this file is too long --------------------------------- GO ON */ +static void err_noop_handler(char *s) +{ + (void)s; + err_noop(); +} + +static void err_vrfy_handler(char *s) +{ + (void)s; + err_vrfy(); +} + +static void err_unimpl_handler(char *s) +{ + (void)s; + err_unimpl(); +} + struct commands smtpcommands[] = { - { "rcpt", smtp_rcpt, 0}, - { "mail", smtp_mail, 0}, - { "data", smtp_data, flush}, - { "auth", smtp_auth, flush}, - { "quit", smtp_quit, flush}, - { "helo", smtp_helo, flush}, - { "ehlo", smtp_ehlo, flush}, - { "rset", smtp_rset, flush}, - { "help", smtp_help, flush}, - { "noop", err_noop, flush}, - { "vrfy", err_vrfy, flush}, - {"starttls", smtp_starttls, flush}, - { 0, err_unimpl, flush} + { "rcpt", smtp_rcpt, 0}, + { "mail", smtp_mail, 0}, + { "data", smtp_data, flush}, + { "auth", smtp_auth, flush}, + { "quit", smtp_quit, flush}, + { "helo", smtp_helo, flush}, + { "ehlo", smtp_ehlo, flush}, + { "rset", smtp_rset, flush}, + { "help", smtp_help, flush}, + { "noop", err_noop_handler, flush}, + { "vrfy", err_vrfy_handler, flush}, + {"starttls", smtp_starttls, flush}, + { 0, err_unimpl_handler, flush} }; int main(int argc, char **argv) @@ -2094,7 +2123,7 @@ int main(int argc, char **argv) smtp_greet("220 "); out(" ESMTP\r\n"); flush(); - if (commands(&bi, &smtpcommands) == 0) die_read(); + if (commands(&bi, smtpcommands) == 0) die_read(); die_nomem(); return 0; diff --git a/src/qmail-start.c b/src/qmail-start.c index d6a90a8..c80761b 100644 --- a/src/qmail-start.c +++ b/src/qmail-start.c @@ -17,7 +17,7 @@ char *(qlargs[]) = {"qmail-lspawn", "./Mailbox", 0}; char *(qrargs[]) = {"qmail-rspawn", 0}; char *(qtargs[]) = {"qmail-todo", 0}; -void die() +static void die() { _exit(111); } @@ -34,7 +34,7 @@ int pi8[2]; int pi9[2]; int pi10[2]; -void closefds() +static void closefds() { close(2); close(3); @@ -45,7 +45,7 @@ void closefds() close(8); } -void closepipes() +static void closepipes() { close(pi1[0]); close(pi1[1]); diff --git a/src/qmail-tcpto.c b/src/qmail-tcpto.c index 632a5cd..26a9b88 100644 --- a/src/qmail-tcpto.c +++ b/src/qmail-tcpto.c @@ -24,13 +24,13 @@ #define WHO "qmail-tcpto" -void die(n) int n; +static void die(int n) { buffer_flush(buffer_1); _exit(n); } -void warn(s) char *s; +static void warn(char *s) { char *x; x = error_str(errno); @@ -40,22 +40,22 @@ void warn(s) char *s; buffer_puts(buffer_1, "\n"); } -void die_chdir() +static void die_chdir() { logmsg(WHO, 110, FATAL, "unable to chdir"); } -void die_open() +static void die_open() { logmsg(WHO, 112, FATAL, "unable to open tcpto"); } -void die_lock() +static void die_lock() { logmsg(WHO, 112, FATAL, "unable to lock tcpto"); } -void die_read() +static void die_read() { logmsg(WHO, 112, FATAL, "unable to read tcpto"); } diff --git a/src/qmail-todo.c b/src/qmail-todo.c index a26365d..d2f29d5 100644 --- a/src/qmail-todo.c +++ b/src/qmail-todo.c @@ -53,25 +53,25 @@ int flagquitasap = 0; void sendlog1(char *x); void sendlog3(char *x, char *y, char *z); -void sigterm(void) +static void sigterm() { if (flagquitasap == 0) sendlog1("status: qmail-todo stop processing asap\n"); flagquitasap = 1; } int flagreadasap = 0; -void sighup(void) +static void sighup() { flagreadasap = 1; } int flagsendalive = 1; -void senddied(void) +static void senddied() { flagsendalive = 0; } -void cleandied() +static void cleandied() { sendlog1("alert: qmail-todo lost connection to qmail-clean ... exiting\n"); flagquitasap = 1; @@ -82,27 +82,33 @@ void cleandied() stralloc fn = {0}; -void fnmake_init(void) +static void nomem() +{ + log1s("alert: out of memory, sleeping...\n"); + sleep(10); +} + +static void fnmake_init() { while (!stralloc_ready(&fn, FMTQFN)) nomem(); } -void fnmake_info(unsigned long id) +static void fnmake_info(unsigned long id) { fn.len = fmtqfn(fn.s, "info/", id, 1); } -void fnmake_todo(unsigned long id) +static void fnmake_todo(unsigned long id) { fn.len = fmtqfn(fn.s, "todo/", id, 1); } -void fnmake_mess(unsigned long id) +static void fnmake_mess(unsigned long id) { fn.len = fmtqfn(fn.s, "mess/", id, 1); } -void fnmake_chanaddr(unsigned long id, int c) +static void fnmake_chanaddr(unsigned long id, int c) { fn.len = fmtqfn(fn.s, chanaddr[c], id, 1); } @@ -115,7 +121,7 @@ stralloc rwline = {0}; /* 1 if by land, 2 if by sea, 0 if out of memory. not allowed to barf. */ /* may trash recip. must set up rwline, between a T and a \0. */ -int rewrite(char *recip) +static int rewrite(char *recip) { int i; int j; @@ -209,7 +215,7 @@ FAIL: comm_buf.len = pos; } -void comm_init(void) +static void comm_init(void) { buffer_init(&toqc, write, 2, toqcbuf, sizeof(toqcbuf)); buffer_init(&fromqc, read, 3, fromqcbuf, sizeof(fromqcbuf)); @@ -222,7 +228,7 @@ void comm_init(void) while (!stralloc_ready(&comm_buf, 1024)) nomem(); } -int comm_canwrite(void) +static int comm_canwrite(void) { /* XXX: could allow a bigger buffer; say 10 recipients */ /* XXX: returns true if there is something in the buffer */ @@ -231,7 +237,7 @@ int comm_canwrite(void) return 0; } -void comm_write(unsigned long id, int local, int remote) +static void comm_write(unsigned long id, int local, int remote) { int pos; char *s; @@ -258,7 +264,8 @@ FAIL: comm_buf.len = pos; } -void comm_info(unsigned long id, unsigned long size, char *from, unsigned long pid, unsigned long uid) +static void comm_info( + unsigned long id, unsigned long size, char *from, unsigned long pid, unsigned long uid) { int pos; int i; @@ -296,14 +303,14 @@ FAIL: comm_buf.len = pos; } -void comm_exit(void) +static void comm_exit(void) { /* if it FAILs exit, we have already stoped */ if (!stralloc_cats(&comm_buf, "X")) _exit(1); if (!stralloc_0(&comm_buf)) _exit(1); } -void comm_selprep(int *nfds, fd_set *wfds, fd_set *rfds) +static void comm_selprep(int *nfds, fd_set *wfds, fd_set *rfds) { if (flagsendalive) { if (flagquitasap && comm_canwrite() == 0) comm_exit(); @@ -316,7 +323,7 @@ void comm_selprep(int *nfds, fd_set *wfds, fd_set *rfds) } } -void comm_do(fd_set *wfds, fd_set *rfds) +static void comm_do(fd_set *wfds, fd_set *rfds) { /* first write then read */ if (flagsendalive) { @@ -367,14 +374,14 @@ char todobuf[BUFFER_INSIZE]; char todobufinfo[512]; char todobufchan[CHANNELS][1024]; -void todo_init(void) +static void todo_init(void) { flagtododir = 0; nexttodorun = now(); trigger_set(); } -void todo_selprep(int *nfds, fd_set *rfds, datetime_sec *wakeup) +static void todo_selprep(int *nfds, fd_set *rfds, datetime_sec *wakeup) { if (flagquitasap) return; trigger_selprep(nfds, rfds); @@ -382,7 +389,7 @@ void todo_selprep(int *nfds, fd_set *rfds, datetime_sec *wakeup) if (*wakeup > nexttodorun) *wakeup = nexttodorun; } -void todo_do(fd_set *rfds) +static void todo_do(fd_set *rfds) { struct stat st; buffer bi; @@ -578,7 +585,7 @@ FAIL: /* this file is too long ---------------------------------------------- MAIN */ -int getcontrols(void) +static int getcontrols(void) { if (control_init() == -1) return 0; if (control_rldef(&envnoathost, "control/envnoathost", 1, "envnoathost") != 1) return 0; @@ -608,7 +615,7 @@ int getcontrols(void) stralloc newlocals = {0}; stralloc newvdoms = {0}; -void regetcontrols(void) +static void regetcontrols(void) { int r; @@ -636,7 +643,7 @@ void regetcontrols(void) } } -void reread(void) +static void reread(void) { if (chdir(auto_qmail) == -1) { sendlog1("alert: qmail-todo: unable to reread controls: unable to switch to home directory\n"); @@ -682,7 +689,7 @@ int main() do { r = read(fdin, &c, 1); if ((r == -1) && (errno != EINTR)) _exit(100); /* read failed probably qmail-send died */ - } while ((r = !1)); /* we assume it is a 'S' */ + } while ((r = !1)); /* we assume it is a 'S' */ for (;;) { recent = now(); diff --git a/src/qmail-vmailuser.c b/src/qmail-vmailuser.c index eeca889..ebf13ce 100644 --- a/src/qmail-vmailuser.c +++ b/src/qmail-vmailuser.c @@ -42,7 +42,7 @@ stralloc vdomdir = {0}; stralloc vuser = {0}; stralloc vuserdir = {0}; -void pam_exit(int fail) +static void pam_exit(int fail) { int i; diff --git a/src/qreceipt.c b/src/qreceipt.c index ee9fc52..9cdfb46 100644 --- a/src/qreceipt.c +++ b/src/qreceipt.c @@ -19,60 +19,59 @@ #define WHO "qreceipt" -void die_noreceipt() +static void die_noreceipt() { _exit(0); } -void die() +static void die() { _exit(100); } -void die_temp() +static void die_temp() { _exit(111); } -void die_nomem() +static void die_nomem() { buffer_putsflush(buffer_2, "qreceipt: fatal: out of memory\n"); die_temp(); } -void die_fork() +static void die_fork() { buffer_putsflush(buffer_2, "qreceipt: fatal: unable to fork\n"); die_temp(); } -void die_qqperm() +static void die_qqperm() { buffer_putsflush(buffer_2, "qreceipt: fatal: permanent qmail-queue error\n"); die(); } -void die_qqtemp() +static void die_qqtemp() { buffer_putsflush(buffer_2, "qreceipt: fatal: temporary qmail-queue error\n"); die_temp(); } -void die_usage() +static void die_usage() { buffer_putsflush(buffer_2, "qreceipt: usage: qreceipt deliveryaddress\n"); die(); } -void die_read() +static void die_read() { if (errno == ENOMEM) die_nomem(); buffer_putsflush(buffer_2, "qreceipt: fatal: read error\n"); die_temp(); } -void doordie(sa, r) stralloc *sa; -int r; +static void doordie(stralloc *sa, int r) { if (r == 1) return; if (r == -1) die_nomem(); @@ -89,7 +88,7 @@ char *returnpath; stralloc messageid = {0}; stralloc sanotice = {0}; -int rwnotice(token822_alloc *addr) +static int rwnotice(token822_alloc *addr) { token822_reverse(addr); if (token822_unquote(&sanotice, addr) != 1) die_nomem(); @@ -103,7 +102,7 @@ struct qmail qqt; stralloc quoted = {0}; -void finishheader() +static void finishheader() { char *qqx; @@ -150,7 +149,7 @@ token822_alloc hfin = {0}; token822_alloc hfrewrite = {0}; token822_alloc hfaddr = {0}; -void doheaderfield(stralloc *h) +static void doheaderfield(stralloc *h) { switch (hfield_known(h->s, h->len)) { case H_MESSAGEID: @@ -163,7 +162,7 @@ void doheaderfield(stralloc *h) } } -void dobody(stralloc *h) {} +static void dobody(stralloc *h) {} int main(int argc, char **argv) { diff --git a/src/qsutil.c b/src/qsutil.c index fc4129b..4076dc1 100644 --- a/src/qsutil.c +++ b/src/qsutil.c @@ -51,7 +51,7 @@ void log5s(char *s1, char *s2, char *s3, char *s4, char *s5) buffer_putsflush(&be, s5); } -void nomem() +static void nomem() { log1s("alert: out of memory, sleeping...\n"); sleep(10); diff --git a/src/readsubdir.c b/src/readsubdir.c index 8a57735..497b585 100644 --- a/src/readsubdir.c +++ b/src/readsubdir.c @@ -1,5 +1,6 @@ #include "readsubdir.h" +#include "direntry.h" #include "fmt.h" #include "scan.h" #include "str.h" diff --git a/src/received.c b/src/received.c index b564fd4..acb00c8 100644 --- a/src/received.c +++ b/src/received.c @@ -27,7 +27,7 @@ static int issafe(char ch) return 0; } -void safeput(struct qmail *qqt, char *s) +static void safeput(struct qmail *qqt, char *s) { char ch; while ((ch = *s++)) { diff --git a/src/recipients.c b/src/recipients.c index 3d883e2..58a0f7b 100644 --- a/src/recipients.c +++ b/src/recipients.c @@ -59,7 +59,7 @@ int recipients_init() char rcptbuf[512]; buffer br = BUFFER_INIT(safewrite, FDAUTH, rcptbuf, sizeof(rcptbuf)); -int callapam(char *pam, char *addr) +static int callapam(char *pam, char *addr) { int i; int j = 0; @@ -143,7 +143,7 @@ int callapam(char *pam, char *addr) return wait_exitcode(wstat); } -int recipients_parse( +static int recipients_parse( char *rhost, int rlen, char *addr, diff --git a/src/sendmail.c b/src/sendmail.c index 84385d9..1a9e858 100644 --- a/src/sendmail.c +++ b/src/sendmail.c @@ -16,19 +16,19 @@ #define WHO "sendmail" -void nomem() +static void nomem() { logmsg(WHO, 111, FATAL, "out of memory\n"); } -void die_usage() +static void die_usage() { logmsg(WHO, 100, USAGE, "sendmail [ -t ] [ -fsender ] [ -Fname ] [ -bp ] [ -bs ] [ arg ... ]\n"); } char *smtpdarg[] = {"bin/qmail-smtpd", 0}; -void smtpd() +static void smtpd() { if (!env_get("PROTO")) { if (!env_puts("RELAYCLIENT=")) nomem(); @@ -48,13 +48,13 @@ void smtpd() char *qreadarg[] = {"bin/qmail-qread", 0}; -void mailq() +static void mailq() { execv(*qreadarg, qreadarg); logmsg(WHO, 111, FATAL, "unable to run qmail-qread\n"); } -void do_sender(const char *s) +static void do_sender(const char *s) { char *x; int n; diff --git a/src/setforward.c b/src/setforward.c index ec282ba..22f3d75 100644 --- a/src/setforward.c +++ b/src/setforward.c @@ -12,37 +12,37 @@ #define WHO "setforward" -void usage() +static void usage() { logmsg(WHO, 100, USAGE, "setforward data.cdb data.tmp"); } -void nomem() +static void nomem() { logmsg(WHO, 111, FATAL, "out of memory"); } -void missingsemicolon() +static void missingsemicolon() { logmsg(WHO, 100, FATAL, "final instruction must end with semicolon"); } -void extracolon() +static void extracolon() { logmsg(WHO, 100, FATAL, "double colons are not permitted"); } -void extracomma() +static void extracomma() { logmsg(WHO, 100, FATAL, "commas are not permitted before colons"); } -void nulbyte() +static void nulbyte() { logmsg(WHO, 100, FATAL, "NUL bytes are not permitted"); } -void longaddress() +static void longaddress() { logmsg(WHO, 100, FATAL, "addresses over 800 bytes are not permitted"); } @@ -61,14 +61,12 @@ int flagtarget = 0; /* 0: reading target; command is empty; instr is empty */ /* 1: target is complete; instr still has to be written; reading command */ -void writeerr() +static void writeerr() { logmsg(WHO, 111, FATAL, B("unable to write to: ", fntmp)); } -void doit(prepend, data, datalen) char *prepend; -char *data; -int datalen; +static void doit(char *prepend, char *data, int datalen) { if (!stralloc_copys(&key, prepend)) nomem(); if (!stralloc_cat(&key, &target)) nomem(); @@ -76,8 +74,7 @@ int datalen; if (cdb_make_add(&cdb, key.s, key.len, data, datalen) == -1) writeerr(); } -int getch(ch) -char *ch; +static int getch(char *ch) { int r; diff --git a/src/setmaillist.c b/src/setmaillist.c index e06e336..1f12596 100644 --- a/src/setmaillist.c +++ b/src/setmaillist.c @@ -12,7 +12,7 @@ #define WHO "setmaillist" -void usage() +static void usage() { logmsg(WHO, 100, USAGE, "setmaillist list.bin list.tmp"); } @@ -26,7 +26,7 @@ int fd; char buf[1024]; buffer bo; -void writeerr() +static void writeerr() { logmsg(WHO, 111, FATAL, B("unable to write to: ", fntmp)); } diff --git a/src/spawn.c b/src/spawn.c index 2ad7d13..59ed63e 100644 --- a/src/spawn.c +++ b/src/spawn.c @@ -1,3 +1,5 @@ +#include "spawn.h" + #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> @@ -23,11 +25,6 @@ #include "auto_uids.h" #endif -extern int truncreport; -extern int spawn(); -extern void report(); -extern void initialize(); - struct delivery { int used; int fdin; /* pipe input */ @@ -39,7 +36,7 @@ struct delivery { struct delivery *d; -void sigchld() +static void sigchld() { int wstat; int pid; @@ -58,7 +55,7 @@ void sigchld() int flagwriting = 1; -ssize_t okwrite(int fd, char *buf, int n) +static ssize_t okwrite(int fd, char *buf, int n) { int w; if (!flagwriting) return n; @@ -81,7 +78,7 @@ stralloc messid = {0}; stralloc sender = {0}; stralloc recip = {0}; -void err(char *s) +static void err(char *s) { char ch; @@ -91,7 +88,7 @@ void err(char *s) buffer_putflush(&bo, "", 1); } -void docmd() +static void docmd() { int f; int i; @@ -205,7 +202,7 @@ void docmd() char cmdbuf[1024]; -void getcmd() +static void getcmd() { int i; int r; @@ -73,7 +73,7 @@ int spf_query( break; case 0: if (!ip4_scan(remoteip, ip4remote)) return SPF_SYNTAX; - if (ipme_is4(ip4remote) == 1) { + if (ipme_is4((struct ip4_address *)ip4remote) == 1) { if (!spf_info("MLocal=", remoteip)) return SPF_NOMEM; if (!spf_info("R:", "+")) return SPF_NOMEM; return SPF_ME; @@ -81,7 +81,7 @@ int spf_query( break; case 1: if (!ip6_scan(remoteip, ip6remote)) return SPF_SYNTAX; - if (ipme_is6(ip6remote) == 1) { + if (ipme_is6((struct ip6_address *)ip6remote) == 1) { if (!spf_info("MLocal=", remoteip)) return SPF_NOMEM; if (!spf_info("R:", "+")) return SPF_NOMEM; return SPF_ME; diff --git a/src/spfquery.c b/src/spfquery.c index 8eb0697..a9bdf70 100644 --- a/src/spfquery.c +++ b/src/spfquery.c @@ -15,13 +15,13 @@ #define WHO "spfquery" -void die(int e, char *s) +static void die(int e, char *s) { buffer_putsflush(buffer_2, s); _exit(e); } -void die_nomem() +static void die_nomem() { die(111, "fatal: out of memory\n"); } diff --git a/src/splogger.c b/src/splogger.c index 55fc94a..33fa568 100644 --- a/src/splogger.c +++ b/src/splogger.c @@ -16,7 +16,7 @@ int flagcont = 0; int priority; /* defined if flagcont */ char stamp[FMT_ULONG + FMT_ULONG + 3]; /* defined if flagcont */ -void stamp_make() +static void stamp_make() { struct timeval tv; char *s; @@ -28,7 +28,7 @@ void stamp_make() *s = 0; } -void flush() +static void flush() { if (bufpos) { buf[bufpos] = 0; @@ -285,7 +285,7 @@ static void srs_hash_create_v(srs_t *srs, int idx, char *buf, int nargs, va_list buf[srs->hashlen] = '\0'; } -int srs_hash_create(srs_t *srs, char *buf, int nargs, ...) +static int srs_hash_create(srs_t *srs, char *buf, int nargs, ...) { va_list ap; @@ -300,7 +300,7 @@ int srs_hash_create(srs_t *srs, char *buf, int nargs, ...) return SRS_SUCCESS; } -int srs_hash_check(srs_t *srs, char *hash, int nargs, ...) +static int srs_hash_check(srs_t *srs, char *hash, int nargs, ...) { va_list ap; char *srshash; @@ -329,7 +329,7 @@ int srs_hash_check(srs_t *srs, char *hash, int nargs, ...) return SRS_EHASHINVALID; } -int srs_compile_shortcut( +static int srs_compile_shortcut( srs_t *srs, char *buf, int buflen, char *sendhost, char *senduser, const char *aliashost) { char *srshash; @@ -371,7 +371,7 @@ int srs_compile_shortcut( return SRS_SUCCESS; } -int srs_compile_guarded( +static int srs_compile_guarded( srs_t *srs, char *buf, int buflen, char *sendhost, char *senduser, const char *aliashost) { char *srshost; @@ -434,7 +434,7 @@ int srs_compile_guarded( return SRS_SUCCESS; } -int srs_parse_shortcut(srs_t *srs, char *buf, int buflen, char *senduser) +static int srs_parse_shortcut(srs_t *srs, char *buf, int buflen, char *senduser) { char *srshash; char *srsstamp; @@ -465,7 +465,7 @@ int srs_parse_shortcut(srs_t *srs, char *buf, int buflen, char *senduser) return SRS_ENOTSRSADDRESS; } -int srs_parse_guarded(srs_t *srs, char *buf, int buflen, char *senduser) +static int srs_parse_guarded(srs_t *srs, char *buf, int buflen, char *senduser) { char *srshash; char *srshost; diff --git a/src/srsforward.c b/src/srsforward.c index f15a8ad..967a015 100644 --- a/src/srsforward.c +++ b/src/srsforward.c @@ -23,12 +23,12 @@ #define WHO "srsforward" -void die_nomem() +static void die_nomem() { logmsg(WHO, 111, FATAL, "out of memory"); } -void die_control() +static void die_control() { logmsg(WHO, 110, FATAL, "Unable to read control files"); } @@ -56,7 +56,7 @@ static int srserror_str(int code) return -3; } -ssize_t mywrite(int fd, char *buf, int len) +static ssize_t mywrite(int fd, char *buf, int len) { qmail_put(&qqt, buf, len); return len; diff --git a/src/srsreverse.c b/src/srsreverse.c index bee168a..1f28098 100644 --- a/src/srsreverse.c +++ b/src/srsreverse.c @@ -25,12 +25,12 @@ #define WHO "srsreverse" -void die_nomem() +static void die_nomem() { logmsg(WHO, 111, FATAL, "out of memory"); } -void die_control() +static void die_control() { logmsg(WHO, 110, FATAL, "Unable to read control files"); } @@ -61,7 +61,7 @@ static int srserror_str(int code) return -3; } -ssize_t mywrite(int fd, char *buf, int len) +static ssize_t mywrite(int fd, char *buf, int len) { qmail_put(&qqt, buf, len); return len; diff --git a/src/tls_remote.c b/src/tls_remote.c index dde4dff..3ae1a94 100644 --- a/src/tls_remote.c +++ b/src/tls_remote.c @@ -129,7 +129,7 @@ int tls_checkcrl(SSL *ssl) // not implemented yet return 0; } -int dig_ascii(char *digascii, const char *digest, const int len) +static int dig_ascii(char *digascii, const char *digest, const int len) { static const char hextab[] = "0123456789abcdef"; int j; @@ -149,7 +149,7 @@ int dig_ascii(char *digascii, const char *digest, const int len) Subjects keys are restricted to 2048 byte in size. Return codes: 1: sucess, 0: failed. */ -int X509_pkey_digest(const X509 *cert, const EVP_MD *type, unsigned char *md, unsigned int *dlen) +static int X509_pkey_digest(const X509 *cert, const EVP_MD *type, unsigned char *md, unsigned int *dlen) { unsigned int len = 0; unsigned int size = 2048; diff --git a/src/tls_start.c b/src/tls_start.c index 434591f..72f012b 100644 --- a/src/tls_start.c +++ b/src/tls_start.c @@ -1,9 +1,10 @@ +#include "tls_start.h" + #include <unistd.h> #include "env.h" #include "fd.h" #include "logmsg.h" -#include "open.h" #include "scan.h" #include "stralloc.h" @@ -21,7 +22,7 @@ static void die_tlsenv() logmsg(WHO, 111, FATAL, "no UCSPITLS environment to read"); } -int starttls_init(void) +int starttls_init() { unsigned long fd; char *fdstr; @@ -41,7 +42,7 @@ int starttls_init(void) return 1; } -int starttls_info(void) +int starttls_info() { unsigned long fd; char *fdstr; diff --git a/src/tls_timeoutio.c b/src/tls_timeoutio.c index e97c858..c8c2138 100644 --- a/src/tls_timeoutio.c +++ b/src/tls_timeoutio.c @@ -2,14 +2,20 @@ #include "tls_timeoutio.h" #include "error.h" -#include "logmsg.h" #include "ndelay.h" #include "select.h" #include "now.h" -#include "ucspissl.h" -int tls_timeoutio(int (*fun)(), int t, int rfd, int wfd, SSL *ssl, char *buf, int len) +#define CALLBACK_ADAPTER(func) \ + static int func##_adapter(SSL *ssl, void *buf, int len) \ + { \ + (void)buf; \ + (void)len; \ + return func(ssl); \ + } + +int tls_timeoutio(int (*fun)(SSL *, void *, int), int t, int rfd, int wfd, SSL *ssl, char *buf, int len) { int n; const datetime_sec end = (datetime_sec)t + now(); @@ -18,7 +24,7 @@ int tls_timeoutio(int (*fun)(), int t, int rfd, int wfd, SSL *ssl, char *buf, in fd_set fds; struct timeval tv; - const int r = buf ? fun(ssl, buf, len) : fun(ssl); + const int r = fun(ssl, buf, len); if (r > 0) return r; t = end - now(); @@ -46,13 +52,15 @@ int tls_timeoutio(int (*fun)(), int t, int rfd, int wfd, SSL *ssl, char *buf, in return -1; } +CALLBACK_ADAPTER(SSL_accept); + int tls_timeoutaccept(int t, int rfd, int wfd, SSL *ssl) { int r; /* if connection is established, keep NDELAY */ if (ndelay_on(rfd) == -1 || ndelay_on(wfd) == -1) return -1; - r = tls_timeoutio(SSL_accept, t, rfd, wfd, ssl, NULL, 0); + r = tls_timeoutio(SSL_accept_adapter, t, rfd, wfd, ssl, NULL, 0); if (r <= 0) { ndelay_off(rfd); @@ -64,13 +72,15 @@ int tls_timeoutaccept(int t, int rfd, int wfd, SSL *ssl) return r; } +CALLBACK_ADAPTER(SSL_connect); + int tls_timeoutconn(int t, int rfd, int wfd, SSL *ssl) { int r; /* if connection is established, keep NDELAY */ if (ndelay_on(rfd) == -1 || ndelay_on(wfd) == -1) return -1; - r = tls_timeoutio(SSL_connect, t, rfd, wfd, ssl, NULL, 0); + r = tls_timeoutio(SSL_connect_adapter, t, rfd, wfd, ssl, NULL, 0); if (r <= 0) { ndelay_off(rfd); @@ -82,19 +92,21 @@ int tls_timeoutconn(int t, int rfd, int wfd, SSL *ssl) return r; } +CALLBACK_ADAPTER(SSL_do_handshake); + int tls_timeoutrehandshake(int t, int rfd, int wfd, SSL *ssl) { int r; SSL_renegotiate(ssl); - r = tls_timeoutio(SSL_do_handshake, t, rfd, wfd, ssl, NULL, 0); + r = tls_timeoutio(SSL_do_handshake_adapter, t, rfd, wfd, ssl, NULL, 0); if (r <= 0) return r; if (SSL_get_state(ssl) & SSL_ST_CONNECT) return -2; /* now a macro in ssl.h */ /* this is for the client only */ SSL_set_connect_state(ssl); - return tls_timeoutio(SSL_do_handshake, t, rfd, wfd, ssl, NULL, 0); + return tls_timeoutio(SSL_do_handshake_adapter, t, rfd, wfd, ssl, NULL, 0); } int tls_timeoutread(int t, int rfd, int wfd, SSL *ssl, char *buf, int len) @@ -107,5 +119,5 @@ int tls_timeoutread(int t, int rfd, int wfd, SSL *ssl, char *buf, int len) int tls_timeoutwrite(int t, int rfd, int wfd, SSL *ssl, char *buf, int len) { if (!buf) return 0; - return tls_timeoutio(SSL_write, t, rfd, wfd, ssl, buf, len); + return tls_timeoutio((int (*)(SSL *, void *, int))SSL_write, t, rfd, wfd, ssl, buf, len); } diff --git a/src/token822.c b/src/token822.c index 34d8c24..b4913ab 100644 --- a/src/token822.c +++ b/src/token822.c @@ -9,23 +9,16 @@ static struct token822 comma = {TOKEN822_COMMA}; void token822_reverse(token822_alloc *ta) { - int i; - int n; + int n = ta->len - 1; struct token822 temp; - n = ta->len - 1; - for (i = 0; i + i < n; ++i) { + for (int i = 0; i + i < n; ++i) { temp = ta->t[i]; ta->t[i] = ta->t[n - i]; ta->t[n - i] = temp; } } -GEN_ALLOC_ready(token822_alloc, struct token822, t, len, a, i, n, x, 30, token822_ready); -GEN_ALLOC_readyplus(token822_alloc, struct token822, t, len, a, i, n, x, 30, token822_readyplus); -GEN_ALLOC_append( - token822_alloc, struct token822, t, len, a, i, n, x, 30, token822_readyplus, token822_append); - static int needspace(int t1, int t2) { if (!t1) return 0; @@ -449,7 +442,7 @@ int token822_parse(token822_alloc *ta, stralloc *sa, stralloc *buf) return 1; } -static int gotaddr(token822_alloc *taout, token822_alloc *taaddr, int (*callback)()) +static int gotaddr(token822_alloc *taout, token822_alloc *taaddr, int (*callback)(token822_alloc *)) { int i; diff --git a/src/triggerpull.c b/src/triggerpull.c deleted file mode 100644 index a55797f..0000000 --- a/src/triggerpull.c +++ /dev/null @@ -1,18 +0,0 @@ -#include "triggerpull.h" - -#include <unistd.h> - -#include "ndelay.h" -#include "open.h" - -void triggerpull(void) -{ - int fd; - - fd = open_write("lock/trigger"); - if (fd >= 0) { - ndelay_on(fd); - write(fd, "", 1); /* if it fails, bummer */ - close(fd); - } -} |