summaryrefslogtreecommitdiff
path: root/tools/hi-q.c
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-07-21 05:18:31 (GMT)
committerJohn Denker <jsd@av8n.com>2012-07-21 05:18:31 (GMT)
commit7c1ce87457e0eb69f7b9989c8538a169b6744d23 (patch)
tree92bc230551433de150caf51ef9245c16e2613f34 /tools/hi-q.c
parente6056a8ac7a8e843549e163a29d5545f6c97b8f7 (diff)
implement penaltybox return-code (exit status)
also make sure DNS checking doesn't interfere with more basic duties such as keeping the greylist database updated
Diffstat (limited to 'tools/hi-q.c')
-rw-r--r--tools/hi-q.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/tools/hi-q.c b/tools/hi-q.c
index 26e67a7..6aaf302 100644
--- a/tools/hi-q.c
+++ b/tools/hi-q.c
@@ -30,6 +30,7 @@ using namespace std;
#define bar \
foo(good, 0) ;\
foo(spam, 21) ;\
+foo(penaltybox, 22) ;\
foo(permerr, 31) ;\
foo(greylisting, 70) ;\
foo(syserr, 71) ;\
@@ -188,6 +189,7 @@ void exeunt(const int sts) {
// FIXME: stop other children
//xxxx cerr << "hi-q: exeunt called with " << sts << endl;
if (sts == ex_spam) fork_and_wait(post);
+ if (sts == ex_penaltybox) exit(ex_spam);
exit(sts);
}
@@ -274,15 +276,18 @@ int xclose(int arg){
extern char** environ;
+string basename(const string path){
+ size_t where = path.rfind("/");
+ if (where != string::npos) return path.substr(1+where);
+ return path;
+}
+
int main(int argc, char** argv) {
{
progname = *argv;
mypid = getpid();
- string shortname = progname;
- size_t where = shortname.rfind("/");
- if (where != string::npos) shortname = shortname.substr(1+where);
stringstream binder;
- binder << shortname << "[" << mypid << "]";
+ binder << basename(progname) << "[" << mypid << "]";
progid = binder.str();
}
@@ -658,7 +663,7 @@ bar
}
cerr << progid
<< " concludes: kid[" << kidno << "]"
- << " i.e. " << filter[kidno].cmd[0]
+ << " i.e. " << basename(filter[kidno].cmd[0])
<< "[" << argbest_blame << "]"
<< " reports " << exword << endl;
exeunt(excode);
@@ -666,7 +671,7 @@ bar
int sig = WTERMSIG(best_blame);
cerr << progid
<< " concludes: kid[" << kidno << "]"
- << " i.e. " << filter[kidno].cmd[0]
+ << " i.e. " << basename(filter[kidno].cmd[0])
<< "[" << argbest_blame << "]"
<< " was killed by signal " << sig
<< endl;
@@ -690,7 +695,7 @@ bar
int sts = WEXITSTATUS(kidstatus);
cerr << progid
<< " says: qq program"
- << " i.e. " << filter[nkids-1].cmd[0]
+ << " i.e. " << basename(filter[nkids-1].cmd[0])
<< "[" << kidpid[nkids-1] << "]"
<< " returned status " << sts
<< endl;
@@ -698,7 +703,7 @@ bar
} else if (WIFSIGNALED(kidstatus)) {
cerr << progid
<< " says: qq program"
- << " i.e. " << filter[nkids-1].cmd[0]
+ << " i.e. " << basename(filter[nkids-1].cmd[0])
<< "[" << kidpid[nkids-1] << "]"
<< " was killed by signal " << WTERMSIG(kidstatus)
<< endl;