17a18,20 > // Modified Andrew Daviel, TRIUMF, May 2007 > // Get per-user threshold from ~/.spamassassin/reject_thrsh > // and use custom reject message with URL 101a105,106 > #include > 421a427,428 > char rejmsg[255] ; > 429a437 > float score ; float required ; 434c442,457 < int score, rv; --- > int rv; > char thrs_file[80] ; > strncpy(thrs_file, assassin->local_user().c_str(),50) ; thrs_file[50] = '\0' ; > FILE *thrsf ; > struct passwd *userpw ; > userpw = getpwnam(thrs_file) ; > strncpy(thrs_file,userpw->pw_dir,50) ; thrs_file[50] = '\0' ; > strcat(thrs_file,"/.spamassassin/reject_thrsh") ; > thrsf = fopen(thrs_file,"r") ; > if (thrsf) { > rv = fscanf(thrsf,"%f",&required) ; > debug(D_ALWAYS, "%s: %.2f\n",thrs_file,required) ; > } else { > required = reject_score ; > debug(D_ALWAYS, "Using default threshold %.2f\n",required) ; > } 437c460 < rv = sscanf(spam_status,"%*s score=%d", &score); --- > rv = sscanf(spam_status,"%*s score=%f", &score); 441c464 < rv = sscanf(spam_status,"%*s hits=%d", &score); --- > rv = sscanf(spam_status,"%*s hits=%f", &score); 447,448c470,471 < debug(D_MISC, "SA score: %d", score); < if (score >= reject_score) --- > debug(D_MISC, "SA score: %.2f", score); > if (score >= required) 455,456c478,480 < smfi_setreply(ctx, "550", "5.7.1", "Blocked by SpamAssassin"); < --- > // smfi_setreply(ctx, "550", "5.7.1", "Blocked by SpamAssassin"); > snprintf(rejmsg,255,"Rejected; see http://example.com/cgi-bin/SA?%.2f+%.2f",score,required) ; > smfi_setreply(ctx, "550", "5.7.1", rejmsg);