17#define WHO "newaliases"
19int rename(
const char *,
const char *);
23 logmsg(
WHO,111,FATAL,
"out of memory");
29static void longaddress()
31 logmsg(
WHO,100,FATAL,
"addresses over 800 bytes are not permitted");
35 logmsg(
WHO,111,FATAL,
"unable to write to /etc/aliases.tmp");
39 logmsg(
WHO,111,FATAL,
"unable to read /etc/aliases");
43 logmsg(
WHO,111,FATAL,
"unable to read controls");
56 fddir = open_read(
".");
58 logmsg(
WHO,111,FATAL,
"unable to open current directory");
79 if (fchdir(fddir) == -1)
80 logmsg(
WHO,111,FATAL,
"unable to set current directory");
99 logmsg(
WHO,111,FATAL,
"empty :include: filenames not permitted");
101 logmsg(
WHO,111,FATAL,
"NUL not permitted in :include: filenames");
120 logmsg(
WHO,111,FATAL,
"empty recipient addresses not permitted");
123 for (i = 0; i <
tokaddr.len; ++i)
134 logmsg(
WHO,111,FATAL,B(
"file delivery for ",
address.s,
" not supported"));
139 logmsg(
WHO,111,FATAL,
"NUL not permitted in program names");
176 logmsg(
WHO,111,FATAL,
"NUL not permitted in recipient addresses");
183static void parseerr()
186 logmsg(
WHO,111,FATAL,B(
"unable to parse this line: ",
line.s));
189static void parseline()
207 while (t > beginning)
208 switch ((--t)->
type) {
212 if (t >= beginning + 2)
216 if (!byte_diff(t[-1].
s,7,
"include")) {
226 if (t <= beginning) parseerr();
233 if (!wordok)
if (
tokaddr.len) gotaddr();
260 if (
target.len) parseerr();
264 if (!
target.len) parseerr();
266 if (stralloc_starts(&
target,
"owner-")) {
269 case_lowerb(
key.s,
key.len);
275 case_lowerb(
key.s,
key.len);
286 fd = open_read(
"/etc/aliases");
287 if (
fd == -1) readerr();
290 fd = open_trunc(
"/etc/aliases.tmp");
291 if (
fd == -1) logmsg(
WHO,111,FATAL,
"unable to create /etc/aliases.tmp");
292 if (cdb_make_start(&
cdb,
fd) == -1) writeerr();
307 if (
line.s[0] !=
'#') {
319 if (cdb_make_finish(&
cdb) == -1) writeerr();
320 if (fsync(
fd) == -1) writeerr();
321 if (close(
fd) == -1) writeerr();
323 if (
rename(
"/etc/aliases.tmp",
"/etc/aliases.cdb") == -1)
324 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)
int token822_append(token822_alloc *, struct token822 *)
int token822_unquote(stralloc *, token822_alloc *)
void token822_reverse(token822_alloc *)
int token822_readyplus(token822_alloc *, unsigned int)