![]() |
In addition to the expected fax functionality and usual trace log files, I want to use HylaFAX to generate a separate log file containing *only* Caller ID information. The kicker is that I want that log file to contain Caller ID information from *all* incoming calls, regardless of whether they are answered by HylaFAX or not.
#!/bin/sh echo "$1 $2 $3 $4" >> /tmp/call-log if [ "$2" = "8005551212" ]; then exit 1 # reject this call fi exit 0 # all other calls are okay
diff -Nru hylafax.orig/faxd/faxGettyApp.c++ hylafax/faxd/faxGettyApp.c++ --- hylafax.orig/faxd/faxGettyApp.c++ 2006-03-13 08:23:53.995944728 -0800 +++ hylafax/faxd/faxGettyApp.c++ 2006-03-13 11:21:25.205714720 -0800 @@ -330,7 +330,7 @@ bool callResolved; bool advanceRotary = true; fxStr emsg; - if (!isCIDOk(callid.size() > CallID::NUMBER ? callid.id(CallID::NUMBER) : "")) { // check Caller ID if present + if (!isCIDOk(callid)) { // check Caller ID if present /* * Call was rejected based on Caller ID information. */ @@ -743,8 +743,33 @@ } bool -faxGettyApp::isCIDOk(const fxStr& cid) +faxGettyApp::isCIDOk(const CallID& callid) { + if (qualifyCIDex.length()) { + const char* argv[callid.size()+3]; + argv[0] = (const char*) qualifyCIDex; + argv[1] = (const char*) getModemDevice(); + for (u_int i = 0; i < callid.size(); i++) + argv[i+2] = (const char*) callid.id(i); + argv[callid.size()+2] = NULL; + pid_t pid = fork(); + switch (pid) { + case 0: + Sys::execv((const char*) qualifyCIDex, (char* const*) argv); + sleep(1); // XXX give parent time + _exit(-1); + case -1: + traceProtocol("Couldn't fork to run QualifyCID-Ex: %s", (const char*) qualifyCIDex); + break; + default: + int estat = -1; + Sys::waitpid(pid, estat); + if (estat != 0) + return (false); // qualifyCIDex rejects call + break; + } + } + const fxStr cid = callid.size() > CallID::NUMBER ? callid.id(CallID::NUMBER) : ""; updatePatterns(qualifyCID, cidPats, acceptCID, lastCIDModTime); return (qualifyCID == "" ? true : checkACL(cid, cidPats, *acceptCID)); } @@ -987,6 +1012,7 @@ faxGettyApp::stringtag faxGettyApp::strings[] = { { "qualifycid", &faxGettyApp::qualifyCID }, +{ "qualifycid-ex", &faxGettyApp::qualifyCIDex }, { "gettyargs", &faxGettyApp::gettyArgs }, { "vgettyargs", &faxGettyApp::vgettyArgs }, { "egettyargs", &faxGettyApp::egettyArgs }, diff -Nru hylafax.orig/faxd/faxGettyApp.h hylafax/faxd/faxGettyApp.h --- hylafax.orig/faxd/faxGettyApp.h 2006-03-13 08:23:50.432486456 -0800 +++ hylafax/faxd/faxGettyApp.h 2006-03-13 09:15:24.997041136 -0800 @@ -68,6 +68,7 @@ u_short ringsBeforeAnswer; // # rings to wait u_short ringsHeard; // # rings received fxStr qualifyCID; // if set, no answer w/o acceptable cid + fxStr qualifyCIDex; // if set, executable to run to check cid time_t lastCIDModTime; // last mod time of CID patterns file REArray* cidPats; // recv cid patterns fxBoolArray* acceptCID; // accept/reject matched cid @@ -109,7 +110,7 @@ bool setupModem(bool isSend); void discardModem(bool dropDTR); // inbound call handling - bool isCIDOk(const fxStr& cid); + bool isCIDOk(const CallID& callid); bool processCall(CallType ctype, fxStr& emsg, const CallID& callid); CallType runGetty(const char* what, Getty* (*newgetty)(const fxStr&, const fxStr&), diff -Nru hylafax.orig/man/hylafax-config.4f hylafax/man/hylafax-config.4f --- hylafax.orig/man/hylafax-config.4f 2006-03-13 08:23:49.137683296 -0800 +++ hylafax/man/hylafax-config.4f 2006-03-13 09:24:19.340808536 -0800 @@ -188,6 +188,7 @@ PriorityScheduling boolean \s-1\fIsee below\fP\s+1 use available priority job scheduling mechanism PS2FaxCmd\(S1 string \s-1bin/ps2fax\s+1 \*(Ps \s-1RIP\s+1 command script QualifyCID string \- file of Caller-ID or DNIS patterns for checking inbound calls +QualifyCID-Ex string \- executable file for inbound CallID checking QualifyPWD string \- file of \s-1PWD\s+1 patterns for qualifying senders QualifyTSI string \- file of \s-1TSI\s+1 patterns for qualifying senders RecvDataFormat string \s-1adaptive\s+1 format for received facsimile data @@ -1219,6 +1220,18 @@ parameters must also be setup to reflect the manner in which the modem returns call identification information to the host. .TP +.B QualifyCID-Ex +A string that specifies an executable file to run with the arguments of +device name first followed by all +.B CallIDPattern +matches for each incoming call. +.B QualifyCID-Ex +is run just before checking against +.B QualifyCID, +and if +.B QualifyCID-Ex +exits with a non-zero value, then the call will be rejected. +.TP .B QualifyPWD A string that specifies whether or not the identity of calling facsimile machines should be checked against an access