The message sent by mail.local ends in a newline so we need to trim
it before calling strtonum(). Also adds some debugging syslogs
that were useful along the way (disabled by default).
- todd
Index: libexec/comsat/comsat.c
===================================================================
RCS file: /cvs/src/libexec/comsat/comsat.c,v
retrieving revision 1.39
diff -u -p -u -r1.39 comsat.c
--- libexec/comsat/comsat.c 18 Apr 2015 18:28:37 -0000 1.39
+++ libexec/comsat/comsat.c 6 Jul 2015 14:56:23 -0000
@@ -191,6 +191,7 @@ doreadutmp(void)
}
(void)lseek(uf, 0, SEEK_SET);
nutmp = read(uf, utmp, statbf.st_size)/sizeof(struct utmp);
+ dsyslog(LOG_DEBUG, "read %d utmp entries", nutmp);
}
(void)alarm(15);
}
@@ -204,15 +205,22 @@ mailfor(char *name)
char *cp;
off_t offset;
+ dsyslog(LOG_DEBUG, "mail for '%s'", name);
+ cp = name + strlen(name) - 1;
+ while (cp > name && isspace((unsigned char)*cp))
+ *cp-- = '\0';
if (!(cp = strchr(name, '@')))
return;
*cp = '\0';
offset = strtonum(cp + 1, 0, LLONG_MAX, &errstr);
- if (errstr)
+ if (errstr) {
+ syslog(LOG_ERR, "'%s' is %s", cp + 1, errstr);
return;
+ }
while (--utp >= utmp) {
memcpy(utname, utp->ut_name, UT_NAMESIZE);
utname[UT_NAMESIZE] = '\0';
+ dsyslog(LOG_DEBUG, "check %s against %s", name, utname);
if (!strncmp(utname, name, UT_NAMESIZE))
notify(utp, offset);
}