From 6937c3f2bd8cf40ce8d2f0d3fea37f076e4ce709 Mon Sep 17 00:00:00 2001 From: Bjørn Mork Date: Sat, 4 Mar 2017 20:59:09 +0100 Subject: ripe-atlas-fw: imported version 4740 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bjørn Mork --- eperd/evtdig.c | 27 +++++++++++++++++++++++++-- eperd/httpget.c | 25 +++++++++++++++++++++++-- eperd/ntp.c | 20 ++++++++++++++++++-- eperd/ping.c | 24 +++++++++++++++++++++--- eperd/sslgetcert.c | 26 +++++++++++++++++++++++--- eperd/traceroute.c | 20 ++++++++++++++++++-- 6 files changed, 128 insertions(+), 14 deletions(-) (limited to 'eperd') diff --git a/eperd/evtdig.c b/eperd/evtdig.c index 0303cfd..df223ff 100644 --- a/eperd/evtdig.c +++ b/eperd/evtdig.c @@ -289,6 +289,7 @@ struct query_state { int resolv_i; char * str_Atlas; + char * str_bundle; u_int16_t qtype; u_int16_t qclass; @@ -1428,11 +1429,11 @@ static void *tdig_init(int argc, char *argv[], void (*done)(void *state)) qry->opt_v4_only = 0; qry->opt_v6_only = 0; qry->str_Atlas = NULL; + qry->str_bundle = NULL; qry->out_filename = NULL; qry->opt_proto = 17; qry->udp_fd = -1; qry->server_name = NULL; - qry->str_Atlas = NULL; qry->infname = NULL; tdig_base->activeqry++; qry->qst = STATUS_FREE; @@ -1478,7 +1479,7 @@ static void *tdig_init(int argc, char *argv[], void (*done)(void *state)) evtimer_assign(&qry->done_qry_timer, tdig_base->event_base, done_qry_cb, qry); optind = 0; - while (c= getopt_long(argc, argv, "46adD:e:tbhinqO:Rrs:A:I:?", longopts, NULL), c != -1) { + while (c= getopt_long(argc, argv, "46adD:e:tbhinqO:Rrs:A:B:I:?", longopts, NULL), c != -1) { switch(c) { case '4': qry->opt_v4_only = 1; @@ -1504,6 +1505,18 @@ static void *tdig_init(int argc, char *argv[], void (*done)(void *state)) } qry->str_Atlas = strdup(optarg); break; + + case 'B': + if (!validate_atlas_id(optarg)) + { + crondlog(LVL8 "bad bundle ID '%s'", + optarg); + tdig_delete(qry); + return NULL; + } + qry->str_bundle= strdup(optarg); + break; + case 'I': free(qry->infname); qry->infname= strdup(optarg); @@ -2320,6 +2333,11 @@ static int tdig_delete(void *state) free( qry->str_Atlas); qry->str_Atlas = NULL; } + if( qry->str_bundle) + { + free( qry->str_bundle); + qry->str_bundle = NULL; + } if(qry->server_name) { free(qry->server_name); @@ -2366,6 +2384,8 @@ void printErrorQuick (struct query_state *qry) { fprintf(fh, ",{"); fprintf(fh, "\"id\" : \"%s\"", qry->str_Atlas); + if (qry->str_bundle) + fprintf(fh, ",\"bundle\" : %s", qry->str_bundle); fprintf(fh, ",\"start time\" : %ld", qry->xmit_time); if(qry->retry) { fprintf(fh, ",\"retry\": %d", qry->retry); @@ -2409,6 +2429,9 @@ void printReply(struct query_state *qry, int wire_size, unsigned char *result) if(qry->str_Atlas) { JS(id, qry->str_Atlas); + if (qry->str_bundle) { + JS1(bundle, %s, qry->str_bundle); + } } JD(fw, fw); diff --git a/eperd/httpget.c b/eperd/httpget.c index aed596e..a7d6b8a 100644 --- a/eperd/httpget.c +++ b/eperd/httpget.c @@ -74,6 +74,7 @@ struct hgstate /* Parameters */ char *output_file; char *atlas; + char *bundle; char do_all; char do_combine; char only_v4; @@ -384,7 +385,7 @@ static void *httpget_init(int __attribute((unused)) argc, char *argv[], unsigned timeout; char *url, *check; char *post_file, *output_file, *post_footer, *post_header, - *A_arg, *store_headers, *store_body, *read_limit_str, + *A_arg, *b_arg, *store_headers, *store_body, *read_limit_str, *timeout_str, *infname, *response_in, *response_out; const char *user_agent; char *host, *port, *hostport, *path; @@ -407,6 +408,7 @@ static void *httpget_init(int __attribute((unused)) argc, char *argv[], read_limit_str= NULL; timeout_str= NULL; A_arg= NULL; + b_arg= NULL; infname= NULL; response_in= NULL; response_out= NULL; @@ -426,7 +428,7 @@ static void *httpget_init(int __attribute((unused)) argc, char *argv[], /* Allow us to be called directly by another program in busybox */ optind= 0; - while (c= getopt_long(argc, argv, "01aA:cI:O:R:W:46", longopts, NULL), + while (c= getopt_long(argc, argv, "01ab:A:cI:O:R:W:46", longopts, NULL), c != -1) { switch(c) @@ -457,6 +459,9 @@ static void *httpget_init(int __attribute((unused)) argc, char *argv[], case 'a': /* --all */ do_all= 1; break; + case 'b': + b_arg= optarg; + break; case 'B': /* --store-body */ store_body= optarg; break; @@ -566,6 +571,14 @@ static void *httpget_init(int __attribute((unused)) argc, char *argv[], return NULL; } } + if (b_arg) + { + if (!validate_atlas_id(b_arg)) + { + crondlog(LVL8 "bad bundle ID '%s'", b_arg); + return NULL; + } + } if (post_header && !validate_filename(post_header, SAFE_PREFIX_IN)) { @@ -650,6 +663,7 @@ static void *httpget_init(int __attribute((unused)) argc, char *argv[], state= xzalloc(sizeof(*state)); state->base= hg_base; state->atlas= A_arg ? strdup(A_arg) : NULL; + state->bundle= b_arg ? strdup(b_arg) : NULL; state->output_file= output_file ? strdup(output_file) : NULL; state->response_in= response_in ? strdup(response_in) : NULL; state->response_out= response_out ? strdup(response_out) : NULL; @@ -756,6 +770,11 @@ static void report(struct hgstate *state) state->atlas, get_atlas_fw_version(), get_timesync(), state->gstart); + if (state->bundle) + { + fprintf(fh, DBQ(bundle) ":%s, ", + state->bundle); + } } fprintf(fh, DBQ(result) ":[ "); } @@ -2058,6 +2077,8 @@ static int httpget_delete(void *state) free(hgstate->atlas); hgstate->atlas= NULL; + free(hgstate->bundle); + hgstate->bundle= NULL; free(hgstate->output_file); hgstate->output_file= NULL; free(hgstate->infname); diff --git a/eperd/ntp.c b/eperd/ntp.c index 0289f35..fb788c2 100644 --- a/eperd/ntp.c +++ b/eperd/ntp.c @@ -31,7 +31,7 @@ #define NTP_PORT 123 -#define NTP_OPT_STRING ("!46c:i:w:A:O:R:W:") +#define NTP_OPT_STRING ("!46c:i:w:A:B:O:R:W:") #define OPT_4 (1 << 0) #define OPT_6 (1 << 1) @@ -71,6 +71,7 @@ struct ntpstate { /* Parameters */ char *atlas; + char *bundle; char *hostname; char *destportstr; char *out_filename; @@ -354,6 +355,8 @@ static void report(struct ntpstate *state) state->atlas, get_atlas_fw_version(), get_timesync(), state->starttime); + if (state->bundle) + fprintf(fh, DBQ(bundle) ":%s, ", state->bundle); } fprintf(fh, DBQ(dst_name) ":" DBQ(%s), @@ -1682,6 +1685,7 @@ static void *ntp_init(int __attribute((unused)) argc, char *argv[], /* must be int-sized */ size_t newsiz; char *str_Atlas; + char *str_bundle; const char *hostname; char *out_filename; const char *destportstr; @@ -1702,13 +1706,14 @@ static void *ntp_init(int __attribute((unused)) argc, char *argv[], interface= NULL; timeout= 1000; str_Atlas= NULL; + str_bundle= NULL; out_filename= NULL; response_in= NULL; response_out= NULL; opt_complementary = "=1:4--6:i--u:c+:w+:"; opt = getopt32(argv, NTP_OPT_STRING, &count, - &interface, &timeout, &str_Atlas, &out_filename, + &interface, &timeout, &str_Atlas, &str_bundle, &out_filename, &response_in, &response_out); hostname = argv[optind]; @@ -1762,6 +1767,14 @@ static void *ntp_init(int __attribute((unused)) argc, char *argv[], return NULL; } } + if (str_bundle) + { + if (!validate_atlas_id(str_bundle)) + { + crondlog(LVL8 "bad bundle ID '%s'", str_bundle); + return NULL; + } + } destportstr= "123"; @@ -1771,6 +1784,7 @@ static void *ntp_init(int __attribute((unused)) argc, char *argv[], state->destportstr= strdup(destportstr); state->timeout= timeout*1000; state->atlas= str_Atlas ? strdup(str_Atlas) : NULL; + state->bundle= str_bundle ? strdup(str_bundle) : NULL; state->hostname= strdup(hostname); state->do_v6= do_v6; state->out_filename= out_filename ? strdup(out_filename) : NULL; @@ -2100,6 +2114,8 @@ static int ntp_delete(void *state) free(ntpstate->atlas); ntpstate->atlas= NULL; + free(ntpstate->bundle); + ntpstate->bundle= NULL; free(ntpstate->hostname); ntpstate->hostname= NULL; free(ntpstate->destportstr); diff --git a/eperd/ping.c b/eperd/ping.c index 3f03bf8..583d512 100644 --- a/eperd/ping.c +++ b/eperd/ping.c @@ -26,7 +26,7 @@ #define DBQ(str) "\"" #str "\"" -#define PING_OPT_STRING ("!46rc:s:A:O:i:I:R:W:") +#define PING_OPT_STRING ("!46rc:s:A:B:O:i:I:R:W:") enum { @@ -94,6 +94,7 @@ struct pingstate { /* Parameters */ char *atlas; + char *bundle_id; char *hostname; char *interface; int pingcount; @@ -222,6 +223,8 @@ static void report(struct pingstate *state) ", " DBQ(time) ":%ld, ", state->atlas, get_atlas_fw_version(), get_timesync(), (long)time(NULL)); + if (state->bundle_id) + fprintf(fh, DBQ(bundle) ":%s, ", state->bundle_id); } fprintf(fh, DBQ(dst_name) ":" DBQ(%s), @@ -1097,6 +1100,7 @@ static void *ping_init(int __attribute((unused)) argc, char *argv[], sa_family_t af; const char *hostname; char *str_Atlas; + char *str_bundle; char *out_filename; char *interface; char *response_in, *response_out; @@ -1143,6 +1147,7 @@ static void *ping_init(int __attribute((unused)) argc, char *argv[], pingcount= 3; size= 0; str_Atlas= NULL; + str_bundle= NULL; out_filename= NULL; interval= DEFAULT_PING_INTERVAL; interface= NULL; @@ -1151,7 +1156,7 @@ static void *ping_init(int __attribute((unused)) argc, char *argv[], /* exactly one argument needed; -c NUM */ opt_complementary = "=1:c+:s+:i+"; opt = getopt32(argv, PING_OPT_STRING, &pingcount, &size, - &str_Atlas, &out_filename, &interval, &interface, + &str_Atlas, &str_bundle, &out_filename, &interval, &interface, &response_in, &response_out); hostname = argv[optind]; @@ -1209,6 +1214,14 @@ static void *ping_init(int __attribute((unused)) argc, char *argv[], return NULL; } } + if (str_bundle) + { + if (!validate_atlas_id(str_bundle)) + { + crondlog(LVL8 "bad bundle ID '%s'", str_bundle); + return NULL; + } + } if (opt & opt_4) af= AF_INET; @@ -1254,7 +1267,7 @@ static void *ping_init(int __attribute((unused)) argc, char *argv[], state->af= af; state->delay_name_res= delay_name_res; state->interval= interval; - state->interface= interface; + state->interface= interface ? strdup(interface) : NULL; state->socket= -1; state->response_in= response_in ? strdup(response_in) : NULL; state->response_out= response_out ? strdup(response_out) : NULL; @@ -1293,6 +1306,7 @@ static void *ping_init(int __attribute((unused)) argc, char *argv[], state->pingcount= pingcount; state->atlas= str_Atlas ? strdup(str_Atlas) : NULL; + state->bundle_id= str_bundle ? strdup(str_bundle) : NULL; state->hostname= strdup(hostname); state->out_filename= out_filename ? strdup(out_filename) : NULL; @@ -1599,6 +1613,10 @@ static int ping_delete(void *state) free(pingstate->atlas); pingstate->atlas= NULL; + free(pingstate->bundle_id); + pingstate->bundle_id= NULL; + free(pingstate->interface); + pingstate->interface= NULL; free(pingstate->hostname); pingstate->hostname= NULL; free(pingstate->out_filename); diff --git a/eperd/sslgetcert.c b/eperd/sslgetcert.c index e457106..6660b40 100644 --- a/eperd/sslgetcert.c +++ b/eperd/sslgetcert.c @@ -73,6 +73,7 @@ struct state /* Parameters */ char *output_file; char *atlas; + char *bundle; char *infname; char *response_in; /* Fuzzing */ char *response_out; @@ -634,7 +635,7 @@ static void *sslgetcert_init(int __attribute((unused)) argc, char *argv[], int c, i, only_v4, only_v6, major, minor; size_t newsiz; char *hostname, *str_port, *infname, *version_str; - char *output_file, *A_arg; + char *output_file, *A_arg, *B_arg; char *response_in, *response_out; struct state *state; FILE *fh; @@ -643,6 +644,7 @@ static void *sslgetcert_init(int __attribute((unused)) argc, char *argv[], output_file= NULL; version_str= NULL; A_arg= NULL; + B_arg= NULL; infname= NULL; str_port= NULL; response_in= NULL; @@ -660,13 +662,16 @@ static void *sslgetcert_init(int __attribute((unused)) argc, char *argv[], /* Allow us to be called directly by another program in busybox */ optind= 0; - while (c= getopt_long(argc, argv, "A:O:R:V:W:i:p:46", longopts, NULL), c != -1) + while (c= getopt_long(argc, argv, "A:B:O:R:V:W:i:p:46", longopts, NULL), c != -1) { switch(c) { case 'A': A_arg= optarg; break; + case 'B': + B_arg= optarg; + break; case 'O': output_file= optarg; break; @@ -748,6 +753,14 @@ static void *sslgetcert_init(int __attribute((unused)) argc, char *argv[], return NULL; } } + if (B_arg) + { + if (!validate_atlas_id(B_arg)) + { + crondlog(LVL8 "bad bundle ID '%s'", B_arg); + return NULL; + } + } if (version_str == NULL || strcasecmp(version_str, "TLS1.2") == 0) { @@ -778,6 +791,7 @@ static void *sslgetcert_init(int __attribute((unused)) argc, char *argv[], state= xzalloc(sizeof(*state)); state->base= hg_base; state->atlas= A_arg ? strdup(A_arg) : NULL; + state->bundle= B_arg ? strdup(B_arg) : NULL; state->output_file= output_file ? strdup(output_file) : NULL; state->response_in= response_in ? strdup(response_in) : NULL; state->response_out= response_out ? strdup(response_out) : NULL; @@ -848,6 +862,8 @@ static void report(struct state *state) DBQ(time) ":%ld, ", state->atlas, get_atlas_fw_version(), get_timesync(), state->gstart); + if (state->bundle) + fprintf(fh, DBQ(bundle) ":%s, ", state->bundle); } fprintf(fh, DBQ(dst_name) ":" DBQ(%s) ", " @@ -1000,6 +1016,8 @@ static FILE *report_head(struct state *state) ", " DBQ(lts) ":%d", state->atlas, get_atlas_fw_version(), get_timesync()); + if (state->bundle) + fprintf(fh, DBQ(bundle) ":%s, ", state->bundle); } fprintf(fh, "%s" DBQ(time) ":%ld", @@ -1107,7 +1125,7 @@ static int eat_alert(struct state *state) return -1; fprintf(fh, ", " DBQ(alert) ": { " DBQ(level) ": %d, " - DBQ(decription) ": %d }", + DBQ(description) ": %d }", level, descr); msgbuf->buffer.offset += 2; @@ -1625,6 +1643,8 @@ static int sslgetcert_delete(void *vstate) free(state->atlas); state->atlas= NULL; + free(state->bundle); + state->bundle= NULL; free(state->output_file); state->output_file= NULL; free(state->hostname); diff --git a/eperd/traceroute.c b/eperd/traceroute.c index c446d8e..441aebd 100644 --- a/eperd/traceroute.c +++ b/eperd/traceroute.c @@ -28,7 +28,7 @@ #define uh_sum check #endif -#define TRACEROUTE_OPT_STRING ("!46IUFrTa:b:c:f:g:i:m:p:w:z:A:O:S:H:D:R:W:") +#define TRACEROUTE_OPT_STRING ("!46IUFrTa:b:c:f:g:i:m:p:w:z:A:B:O:S:H:D:R:W:") #define OPT_4 (1 << 0) #define OPT_6 (1 << 1) @@ -81,6 +81,7 @@ struct trtstate { /* Parameters */ char *atlas; + char *bundle_id; char *hostname; char *destportstr; char *out_filename; @@ -404,6 +405,8 @@ static void report(struct trtstate *state) get_timesync(), state->starttime, (long)time(NULL)); + if (state->bundle_id) + fprintf(fh, DBQ(bundle) ":%s, ", state->bundle_id); } fprintf(fh, DBQ(dst_name) ":" DBQ(%s), @@ -3816,6 +3819,7 @@ static void *traceroute_init(int __attribute((unused)) argc, char *argv[], /* must be int-sized */ size_t newsiz; char *str_Atlas; + char *str_bundle; const char *hostname; char *out_filename; const char *destportstr; @@ -3849,6 +3853,7 @@ static void *traceroute_init(int __attribute((unused)) argc, char *argv[], hbhoptsize= 0; destoptsize= 0; str_Atlas= NULL; + str_bundle= NULL; out_filename= NULL; response_in= NULL; response_out= NULL; @@ -3861,7 +3866,7 @@ for (i= 0; argv[i] != NULL; i++) &count, &firsthop, &gaplimit, &interface, &maxhops, &destportstr, &timeout, - &duptimeout, &str_Atlas, &out_filename, &maxpacksize, + &duptimeout, &str_Atlas, &str_bundle, &out_filename, &maxpacksize, &hbhoptsize, &destoptsize, &response_in, &response_out); hostname = argv[optind]; @@ -3925,6 +3930,14 @@ for (i= 0; argv[i] != NULL; i++) return NULL; } } + if (str_bundle) + { + if (!validate_atlas_id(str_bundle)) + { + crondlog(LVL8 "bad bundle ID '%s'", str_bundle); + return NULL; + } + } if (!delay_name_res) { @@ -3969,6 +3982,7 @@ for (i= 0; argv[i] != NULL; i++) state->duptimeout= duptimeout*1000; state->timeout= timeout*1000; state->atlas= str_Atlas ? strdup(str_Atlas) : NULL; + state->bundle_id= str_bundle ? strdup(str_bundle) : NULL; state->hostname= strdup(hostname); state->do_icmp= do_icmp; state->do_tcp= do_tcp; @@ -4479,6 +4493,8 @@ static int traceroute_delete(void *state) free(trtstate->atlas); trtstate->atlas= NULL; + free(trtstate->bundle_id); + trtstate->bundle_id= NULL; free(trtstate->hostname); trtstate->hostname= NULL; free(trtstate->destportstr); -- cgit v1.2.3