16#define WHO "newaliases"
18int rename(
const char *,
const char *);
22 logmsg(
WHO,111,FATAL,
"out of memory");
26 logmsg(
WHO,100,FATAL,
"NUL bytes are not permitted");
30 logmsg(
WHO,100,FATAL,
"addresses over 800 bytes are not permitted");
34 logmsg(
WHO,111,FATAL,
"unable to write to /etc/aliases.tmp");
38 logmsg(
WHO,111,FATAL,
"unable to read /etc/aliases");
42 logmsg(
WHO,111,FATAL,
"unable to read controls");
55 fddir = open_read(
".");
57 logmsg(
WHO,111,FATAL,
"unable to open current directory");
78 if (fchdir(fddir) == -1)
79 logmsg(
WHO,111,FATAL,
"unable to set current directory");
98 logmsg(
WHO,111,FATAL,
"empty :include: filenames not permitted");
100 logmsg(
WHO,111,FATAL,
"NUL not permitted in :include: filenames");
119 logmsg(
WHO,111,FATAL,
"empty recipient addresses not permitted");
122 for (i = 0; i <
tokaddr.len; ++i)
133 logmsg(
WHO,111,FATAL,B(
"file delivery for ",
address.s,
" not supported"));
138 logmsg(
WHO,111,FATAL,
"NUL not permitted in program names");
175 logmsg(
WHO,111,FATAL,
"NUL not permitted in recipient addresses");
185 logmsg(
WHO,111,FATAL,B(
"unable to parse this line: ",
line.s));
206 while (t > beginning)
207 switch ((--t)->
type) {
211 if (t >= beginning + 2)
215 if (!byte_diff(t[-1].
s,7,
"include")) {
265 if (stralloc_starts(&
target,
"owner-")) {
268 case_lowerb(
key.s,
key.len);
274 case_lowerb(
key.s,
key.len);
285 fd = open_read(
"/etc/aliases");
289 fd = open_trunc(
"/etc/aliases.tmp");
290 if (
fd == -1) logmsg(
WHO,111,FATAL,
"unable to create /etc/aliases.tmp");
306 if (
line.s[0] !=
'#') {
322 if (
rename(
"/etc/aliases.tmp",
"/etc/aliases.cdb") == -1)
323 logmsg(
WHO,111,FATAL,
"unable to move /etc/aliases.tmp to /etc/aliases.cdb");
int control_readline(stralloc *sa, char *fn)
int stralloc_copys(stralloc *, char const *)
int rename(const char *, const char *)
int token822_parse(token822_alloc *ta, stralloc *sa, stralloc *buf)