@@ -135,6 +135,9 @@ struct arcf_config
135
135
size_t conf_keylen ; /* key length */
136
136
int conf_maxhdrsz ; /* max. header size */
137
137
int conf_minkeysz ; /* min. key size */
138
+ int conf_ret_disabled ; /* configured not to process */
139
+ int conf_ret_unable ; /* internal error */
140
+ int conf_ret_unwilling ; /* badly formed message */
138
141
struct config * conf_data ; /* configuration data */
139
142
ARC_LIB * conf_libopenarc ; /* shared library instance */
140
143
struct conflist conf_peers ; /* peers hosts */
@@ -221,6 +224,14 @@ struct nametable arcf_chainstates[] = {
221
224
{NULL , -1 }
222
225
};
223
226
227
+ struct nametable arcf_responses [] = {
228
+ {"accept" , SMFIS_ACCEPT },
229
+ {"discard" , SMFIS_DISCARD },
230
+ {"reject" , SMFIS_REJECT },
231
+ {"tempfail" , SMFIS_TEMPFAIL },
232
+ {NULL , -1 }
233
+ };
234
+
224
235
/* PROTOTYPES */
225
236
sfsistat mlfi_abort (SMFICTX * );
226
237
sfsistat mlfi_close (SMFICTX * );
@@ -1156,6 +1167,10 @@ arcf_config_new(void)
1156
1167
new -> conf_safekeys = true;
1157
1168
new -> conf_authresip = true;
1158
1169
1170
+ new -> conf_ret_disabled = SMFIS_ACCEPT ;
1171
+ new -> conf_ret_unable = SMFIS_TEMPFAIL ;
1172
+ new -> conf_ret_unwilling = SMFIS_REJECT ;
1173
+
1159
1174
LIST_INIT (& new -> conf_peers );
1160
1175
LIST_INIT (& new -> conf_internal );
1161
1176
@@ -1543,6 +1558,52 @@ arcf_config_load(struct config *data,
1543
1558
conf -> conf_fixedtime = strtoul (str , & end , 10 );
1544
1559
}
1545
1560
1561
+ str = NULL ;
1562
+ config_get (data , "ResponseDisabled" , & str , sizeof str );
1563
+ if (str )
1564
+ {
1565
+ int resp = arc_name_to_code (arcf_responses , str );
1566
+ if (resp == -1 )
1567
+ {
1568
+ snprintf (err , errlen , "%s: invalid response value" , str );
1569
+ }
1570
+ else
1571
+ {
1572
+ conf -> conf_ret_disabled = arc_name_to_code (arcf_responses , str );
1573
+ }
1574
+ }
1575
+
1576
+ str = NULL ;
1577
+ config_get (data , "ResponseUnable" , & str , sizeof str );
1578
+ if (str )
1579
+ {
1580
+ int resp = arc_name_to_code (arcf_responses , str );
1581
+ if (resp == -1 )
1582
+ {
1583
+ snprintf (err , errlen , "%s: invalid response value" , str );
1584
+ }
1585
+ else
1586
+ {
1587
+ conf -> conf_ret_unable = arc_name_to_code (arcf_responses , str );
1588
+ }
1589
+ }
1590
+
1591
+ str = NULL ;
1592
+ config_get (data , "ResponseUnwilling" , & str , sizeof str );
1593
+ if (str )
1594
+ {
1595
+ int resp = arc_name_to_code (arcf_responses , str );
1596
+ if (resp == -1 )
1597
+ {
1598
+ snprintf (err , errlen , "%s: invalid response value" , str );
1599
+ }
1600
+ else
1601
+ {
1602
+ conf -> conf_ret_unwilling = arc_name_to_code (arcf_responses ,
1603
+ str );
1604
+ }
1605
+ }
1606
+
1546
1607
(void ) config_get (data , "TestKeys" , & conf -> conf_testkeys ,
1547
1608
sizeof conf -> conf_testkeys );
1548
1609
@@ -2785,10 +2846,10 @@ mlfi_connect(SMFICTX *ctx, char *host, _SOCK_ADDR *ip)
2785
2846
syslog (LOG_ERR , "%s malloc(): %s" , host , strerror (errno ));
2786
2847
}
2787
2848
2849
+ int retval = curconf -> conf_ret_unable ;
2788
2850
pthread_mutex_unlock (& conf_lock );
2789
2851
2790
- /* XXX -- result should be selectable */
2791
- return SMFIS_TEMPFAIL ;
2852
+ return retval ;
2792
2853
}
2793
2854
2794
2855
pthread_mutex_lock (& conf_lock );
@@ -2836,9 +2897,11 @@ mlfi_connect(SMFICTX *ctx, char *host, _SOCK_ADDR *ip)
2836
2897
{
2837
2898
if (curconf -> conf_dolog )
2838
2899
{
2839
- syslog (LOG_INFO , "ignoring connection from %s" , host );
2900
+ syslog (
2901
+ LOG_INFO , "peer connection from %s, returning %s" , host ,
2902
+ arc_code_to_name (arcf_responses , curconf -> conf_ret_disabled ));
2840
2903
}
2841
- return SMFIS_ACCEPT ;
2904
+ return curconf -> conf_ret_disabled ;
2842
2905
}
2843
2906
2844
2907
/* infer operating mode if not explicitly set */
@@ -2991,15 +3054,13 @@ mlfi_header(SMFICTX *ctx, char *headerf, char *headerv)
2991
3054
afc -> mctx_hdrbytes + strlen (headerf ) + strlen (headerv ) + 2 >
2992
3055
conf -> conf_maxhdrsz )
2993
3056
{
2994
- /* FIXME: this should be configurable, and it might be better to
2995
- * default to rejecting the message.
2996
- */
2997
3057
if (conf -> conf_dolog )
2998
3058
{
2999
- syslog (LOG_NOTICE , "too much header data; accepting" );
3059
+ syslog (LOG_NOTICE , "too much header data, returning %s" ,
3060
+ arc_code_to_name (arcf_responses , conf -> conf_ret_unwilling ));
3000
3061
}
3001
3062
3002
- return SMFIS_ACCEPT ;
3063
+ return conf -> conf_ret_unwilling ;
3003
3064
}
3004
3065
3005
3066
/*
@@ -3026,7 +3087,7 @@ mlfi_header(SMFICTX *ctx, char *headerf, char *headerv)
3026
3087
}
3027
3088
3028
3089
arcf_cleanup (ctx );
3029
- return SMFIS_TEMPFAIL ;
3090
+ return conf -> conf_ret_unable ;
3030
3091
}
3031
3092
3032
3093
newhdr -> hdr_hdr = ARC_STRDUP (headerf );
@@ -3046,7 +3107,7 @@ mlfi_header(SMFICTX *ctx, char *headerf, char *headerv)
3046
3107
3047
3108
arcf_cleanup (ctx );
3048
3109
3049
- return SMFIS_TEMPFAIL ;
3110
+ return conf -> conf_ret_unable ;
3050
3111
}
3051
3112
}
3052
3113
else
@@ -3111,7 +3172,7 @@ mlfi_header(SMFICTX *ctx, char *headerf, char *headerv)
3111
3172
ARC_FREE (newhdr -> hdr_val );
3112
3173
ARC_FREE (newhdr );
3113
3174
arcf_cleanup (ctx );
3114
- return SMFIS_TEMPFAIL ;
3175
+ return conf -> conf_ret_unable ;
3115
3176
}
3116
3177
3117
3178
afc -> mctx_hdrbytes += strlen (newhdr -> hdr_hdr ) + 1 ;
@@ -3359,7 +3420,7 @@ mlfi_eoh(SMFICTX *ctx)
3359
3420
afc -> mctx_jobid );
3360
3421
}
3361
3422
3362
- return SMFIS_ACCEPT ;
3423
+ return conf -> conf_ret_disabled ;
3363
3424
}
3364
3425
}
3365
3426
#endif /* USE_JANSSON */
@@ -3381,7 +3442,7 @@ mlfi_eoh(SMFICTX *ctx)
3381
3442
afc -> mctx_jobid , err );
3382
3443
}
3383
3444
3384
- return SMFIS_TEMPFAIL ;
3445
+ return conf -> conf_ret_unable ;
3385
3446
}
3386
3447
3387
3448
for (hdr = afc -> mctx_hqhead ; hdr != NULL ; hdr = hdr -> hdr_next )
@@ -3397,7 +3458,7 @@ mlfi_eoh(SMFICTX *ctx)
3397
3458
afc -> mctx_jobid );
3398
3459
}
3399
3460
3400
- return SMFIS_TEMPFAIL ;
3461
+ return conf -> conf_ret_unable ;
3401
3462
}
3402
3463
}
3403
3464
else
@@ -3438,7 +3499,11 @@ mlfi_eoh(SMFICTX *ctx)
3438
3499
afc -> mctx_jobid , hdr -> hdr_hdr );
3439
3500
}
3440
3501
3441
- return SMFIS_TEMPFAIL ;
3502
+ if (status == ARC_STAT_SYNTAX )
3503
+ {
3504
+ return conf -> conf_ret_unwilling ;
3505
+ }
3506
+ return conf -> conf_ret_unable ;
3442
3507
}
3443
3508
}
3444
3509
@@ -3512,7 +3577,7 @@ mlfi_body(SMFICTX *ctx, unsigned char *bodyp, size_t bodylen)
3512
3577
afc -> mctx_jobid );
3513
3578
}
3514
3579
3515
- return SMFIS_TEMPFAIL ;
3580
+ return conf -> conf_ret_unable ;
3516
3581
}
3517
3582
}
3518
3583
@@ -3657,7 +3722,7 @@ mlfi_eom(SMFICTX *ctx)
3657
3722
syslog (LOG_ERR , "arc_dstring_new() failed" );
3658
3723
}
3659
3724
3660
- return SMFIS_TEMPFAIL ;
3725
+ return conf -> conf_ret_unable ;
3661
3726
}
3662
3727
}
3663
3728
@@ -3693,7 +3758,7 @@ mlfi_eom(SMFICTX *ctx)
3693
3758
afc -> mctx_jobid );
3694
3759
}
3695
3760
3696
- return SMFIS_TEMPFAIL ;
3761
+ return conf -> conf_ret_unable ;
3697
3762
}
3698
3763
3699
3764
if (BITSET (ARC_MODE_SIGN , cc -> cctx_mode ))
@@ -3806,7 +3871,7 @@ mlfi_eom(SMFICTX *ctx)
3806
3871
afc -> mctx_jobid );
3807
3872
}
3808
3873
3809
- return SMFIS_TEMPFAIL ;
3874
+ return conf -> conf_ret_unable ;
3810
3875
}
3811
3876
3812
3877
for (sealhdr = seal ; sealhdr != NULL ; sealhdr = arc_hdr_next (sealhdr ))
@@ -3858,7 +3923,7 @@ mlfi_eom(SMFICTX *ctx)
3858
3923
afc -> mctx_jobid , "" );
3859
3924
}
3860
3925
3861
- return SMFIS_TEMPFAIL ;
3926
+ return conf -> conf_ret_unable ;
3862
3927
}
3863
3928
3864
3929
arc_dstring_blank (afc -> mctx_tmpstr );
0 commit comments