Project

General

Profile

Bug #7145 » patch-dhcp6c__script.c

Added Reason params - Martin Wasley, 01/30/2017 06:48 AM

 
1
--- dhcp6c_script.c.orig	2016-12-19 08:16:42 UTC
2
+++ dhcp6c_script.c
3
@@ -71,6 +71,8 @@ static char nispserver_str[] = "new_nisp
4
 static char nispname_str[] = "new_nisp_name";
5
 static char bcmcsserver_str[] = "new_bcmcs_servers";
6
 static char bcmcsname_str[] = "new_bcmcs_name";
7
+static char reason[32];
8
+
9
 
10
 int
11
 client6_script(scriptpath, state, optinfo)
12
@@ -78,20 +80,44 @@ client6_script(scriptpath, state, optinf
13
 	int state;
14
 	struct dhcp6_optinfo *optinfo;
15
 {
16
-	int i, dnsservers, ntpservers, dnsnamelen, envc, elen, ret = 0;
17
+	int i,z, dnsservers, ntpservers, dnsnamelen, envc, elen, ret = 0;
18
 	int sipservers, sipnamelen;
19
 	int nisservers, nisnamelen;
20
 	int nispservers, nispnamelen;
21
 	int bcmcsservers, bcmcsnamelen;
22
 	char **envp, *s;
23
-	char reason[] = "REASON=NBI";
24
 	struct dhcp6_listval *v;
25
 	pid_t pid, wpid;
26
-
27
+	
28
+	switch(state) {
29
+	  case DHCP6S_INFOREQ:
30
+	    sprintf(reason,"REASON=INFO");
31
+	    break;
32
+	  case DHCP6S_REQUEST:
33
+	    sprintf(reason,"REASON=REPLY");
34
+	    break;
35
+	 case DHCP6S_RENEW:
36
+	    sprintf(reason,"REASON=RENEW");
37
+	    break;
38
+	case DHCP6S_REBIND:
39
+	    sprintf(reason,"REASON=REBIND");
40
+	    break;
41
+	case DHCP6S_RELEASE:
42
+	    sprintf(reason,"REASON=RELEASE");
43
+	    break;
44
+	case DHCP6S_EXIT:
45
+	    sprintf(reason,"REASON=EXIT");
46
+	    break;  
47
+	default:
48
+	    sprintf(reason,"REASON=OTHER");
49
+	}
50
+	
51
 	/* if a script is not specified, do nothing */
52
 	if (scriptpath == NULL || strlen(scriptpath) == 0)
53
 		return -1;
54
 
55
+	
56
+
57
 	/* initialize counters */
58
 	dnsservers = 0;
59
 	ntpservers = 0;
60
@@ -106,54 +132,56 @@ client6_script(scriptpath, state, optinf
61
 	bcmcsnamelen = 0;
62
 	envc = 2;     /* we at least include the reason and the terminator */
63
 
64
-	/* count the number of variables */
65
-	for (v = TAILQ_FIRST(&optinfo->dns_list); v; v = TAILQ_NEXT(v, link))
66
-		dnsservers++;
67
-	envc += dnsservers ? 1 : 0;
68
-	for (v = TAILQ_FIRST(&optinfo->dnsname_list); v;
69
-	    v = TAILQ_NEXT(v, link)) {
70
-		dnsnamelen += v->val_vbuf.dv_len;
71
-	}
72
-	envc += dnsnamelen ? 1 : 0;
73
-	for (v = TAILQ_FIRST(&optinfo->ntp_list); v; v = TAILQ_NEXT(v, link))
74
-		ntpservers++;
75
-	envc += ntpservers ? 1 : 0;
76
-	for (v = TAILQ_FIRST(&optinfo->sip_list); v; v = TAILQ_NEXT(v, link))
77
-		sipservers++;
78
-	envc += sipservers ? 1 : 0;
79
-	for (v = TAILQ_FIRST(&optinfo->sipname_list); v;
80
-	    v = TAILQ_NEXT(v, link)) {
81
-		sipnamelen += v->val_vbuf.dv_len;
82
-	}
83
-	envc += sipnamelen ? 1 : 0;
84
+	/* count the number of variables */  
85
+	if(state != DHCP6S_EXIT)
86
+	{
87
+		for (v = TAILQ_FIRST(&optinfo->dns_list); v; v = TAILQ_NEXT(v, link))
88
+			dnsservers++;
89
+		envc += dnsservers ? 1 : 0;
90
+		for (v = TAILQ_FIRST(&optinfo->dnsname_list); v;
91
+		    v = TAILQ_NEXT(v, link)) {
92
+			dnsnamelen += v->val_vbuf.dv_len;
93
+		}
94
+		envc += dnsnamelen ? 1 : 0;
95
+		for (v = TAILQ_FIRST(&optinfo->ntp_list); v; v = TAILQ_NEXT(v, link))
96
+			ntpservers++;
97
+		envc += ntpservers ? 1 : 0;
98
+		for (v = TAILQ_FIRST(&optinfo->sip_list); v; v = TAILQ_NEXT(v, link))
99
+			sipservers++;
100
+		envc += sipservers ? 1 : 0;
101
+		for (v = TAILQ_FIRST(&optinfo->sipname_list); v;
102
+		    v = TAILQ_NEXT(v, link)) {
103
+			sipnamelen += v->val_vbuf.dv_len;
104
+		}
105
+		envc += sipnamelen ? 1 : 0;
106
 
107
-	for (v = TAILQ_FIRST(&optinfo->nis_list); v; v = TAILQ_NEXT(v, link))
108
-		nisservers++;
109
-	envc += nisservers ? 1 : 0;
110
-	for (v = TAILQ_FIRST(&optinfo->nisname_list); v;
111
-	    v = TAILQ_NEXT(v, link)) {
112
-		nisnamelen += v->val_vbuf.dv_len;
113
-	}
114
-	envc += nisnamelen ? 1 : 0;
115
+		for (v = TAILQ_FIRST(&optinfo->nis_list); v; v = TAILQ_NEXT(v, link))
116
+			nisservers++;
117
+		envc += nisservers ? 1 : 0;
118
+		for (v = TAILQ_FIRST(&optinfo->nisname_list); v;
119
+		    v = TAILQ_NEXT(v, link)) {
120
+			nisnamelen += v->val_vbuf.dv_len;
121
+		}
122
+		envc += nisnamelen ? 1 : 0;
123
 
124
-	for (v = TAILQ_FIRST(&optinfo->nisp_list); v; v = TAILQ_NEXT(v, link))
125
-		nispservers++;
126
-	envc += nispservers ? 1 : 0;
127
-	for (v = TAILQ_FIRST(&optinfo->nispname_list); v;
128
-	    v = TAILQ_NEXT(v, link)) {
129
-		nispnamelen += v->val_vbuf.dv_len;
130
-	}
131
-	envc += nispnamelen ? 1 : 0;
132
+		for (v = TAILQ_FIRST(&optinfo->nisp_list); v; v = TAILQ_NEXT(v, link))
133
+			nispservers++;
134
+		envc += nispservers ? 1 : 0;
135
+		for (v = TAILQ_FIRST(&optinfo->nispname_list); v;
136
+		    v = TAILQ_NEXT(v, link)) {
137
+			nispnamelen += v->val_vbuf.dv_len;
138
+		}
139
+		envc += nispnamelen ? 1 : 0;
140
 
141
-	for (v = TAILQ_FIRST(&optinfo->bcmcs_list); v; v = TAILQ_NEXT(v, link))
142
-		bcmcsservers++;
143
-	envc += bcmcsservers ? 1 : 0;
144
-	for (v = TAILQ_FIRST(&optinfo->bcmcsname_list); v;
145
-	    v = TAILQ_NEXT(v, link)) {
146
-		bcmcsnamelen += v->val_vbuf.dv_len;
147
+		for (v = TAILQ_FIRST(&optinfo->bcmcs_list); v; v = TAILQ_NEXT(v, link))
148
+			bcmcsservers++;
149
+		envc += bcmcsservers ? 1 : 0;
150
+		for (v = TAILQ_FIRST(&optinfo->bcmcsname_list); v;
151
+		    v = TAILQ_NEXT(v, link)) {
152
+			bcmcsnamelen += v->val_vbuf.dv_len;
153
+		}
154
+		envc += bcmcsnamelen ? 1 : 0;
155
 	}
156
-	envc += bcmcsnamelen ? 1 : 0;
157
-
158
 	/* allocate an environments array */
159
 	if ((envp = malloc(sizeof (char *) * envc)) == NULL) {
160
 		d_printf(LOG_NOTICE, FNAME,
161
@@ -170,216 +198,219 @@ client6_script(scriptpath, state, optinf
162
 	if ((envp[i++] = strdup(reason)) == NULL) {
163
 		d_printf(LOG_NOTICE, FNAME,
164
 		    "failed to allocate reason strings");
165
-		ret = -1;
166
+		ret = -1; 
167
 		goto clean;
168
 	}
169
+
170
 	/* "var=addr1 addr2 ... addrN" + null char for termination */
171
-	if (dnsservers) {
172
-		elen = sizeof (dnsserver_str) +
173
-		    (INET6_ADDRSTRLEN + 1) * dnsservers + 1;
174
-		if ((s = envp[i++] = malloc(elen)) == NULL) {
175
-			d_printf(LOG_NOTICE, FNAME,
176
-			    "failed to allocate strings for DNS servers");
177
-			ret = -1;
178
-			goto clean;
179
-		}
180
-		memset(s, 0, elen);
181
-		snprintf(s, elen, "%s=", dnsserver_str);
182
-		for (v = TAILQ_FIRST(&optinfo->dns_list); v;
183
-		    v = TAILQ_NEXT(v, link)) {
184
-			char *addr;
185
+	if(state != DHCP6S_EXIT)
186
+	{
187
+		if (dnsservers) {
188
+			elen = sizeof (dnsserver_str) +
189
+			    (INET6_ADDRSTRLEN + 1) * dnsservers + 1;
190
+			if ((s = envp[i++] = malloc(elen)) == NULL) {
191
+				d_printf(LOG_NOTICE, FNAME,
192
+				    "failed to allocate strings for DNS servers");
193
+				ret = -1;
194
+				goto clean;
195
+			}
196
+			memset(s, 0, elen);
197
+			snprintf(s, elen, "%s=", dnsserver_str);
198
+			for (v = TAILQ_FIRST(&optinfo->dns_list); v;
199
+			    v = TAILQ_NEXT(v, link)) {
200
+				char *addr;
201
 
202
-			addr = in6addr2str(&v->val_addr6, 0);
203
-			strlcat(s, addr, elen);
204
-			strlcat(s, " ", elen);
205
-		}
206
-	}
207
-	if (ntpservers) {
208
-		elen = sizeof (ntpserver_str) +
209
-		    (INET6_ADDRSTRLEN + 1) * ntpservers + 1;
210
-		if ((s = envp[i++] = malloc(elen)) == NULL) {
211
-			d_printf(LOG_NOTICE, FNAME,
212
-			    "failed to allocate strings for NTP servers");
213
-			ret = -1;
214
-			goto clean;
215
+				addr = in6addr2str(&v->val_addr6, 0);
216
+				strlcat(s, addr, elen);
217
+				strlcat(s, " ", elen);
218
+			}
219
 		}
220
-		memset(s, 0, elen);
221
-		snprintf(s, elen, "%s=", ntpserver_str);
222
-		for (v = TAILQ_FIRST(&optinfo->ntp_list); v;
223
-		    v = TAILQ_NEXT(v, link)) {
224
-			char *addr;
225
+		if (ntpservers) {
226
+			elen = sizeof (ntpserver_str) +
227
+			    (INET6_ADDRSTRLEN + 1) * ntpservers + 1;
228
+			if ((s = envp[i++] = malloc(elen)) == NULL) {
229
+				d_printf(LOG_NOTICE, FNAME,
230
+				    "failed to allocate strings for NTP servers");
231
+				ret = -1;
232
+				goto clean;
233
+			}
234
+			memset(s, 0, elen);
235
+			snprintf(s, elen, "%s=", ntpserver_str);
236
+			for (v = TAILQ_FIRST(&optinfo->ntp_list); v;
237
+			    v = TAILQ_NEXT(v, link)) {
238
+				char *addr;
239
 
240
-			addr = in6addr2str(&v->val_addr6, 0);
241
-			strlcat(s, addr, elen);
242
-			strlcat(s, " ", elen);
243
+				addr = in6addr2str(&v->val_addr6, 0);
244
+				strlcat(s, addr, elen);
245
+				strlcat(s, " ", elen);
246
+			}
247
 		}
248
-	}
249
 
250
-	if (dnsnamelen) {
251
-		elen = sizeof (dnsname_str) + dnsnamelen + 1;
252
-		if ((s = envp[i++] = malloc(elen)) == NULL) {
253
-			d_printf(LOG_NOTICE, FNAME,
254
-			    "failed to allocate strings for DNS name");
255
-			ret = -1;
256
-			goto clean;
257
-		}
258
-		memset(s, 0, elen);
259
-		snprintf(s, elen, "%s=", dnsname_str);
260
-		for (v = TAILQ_FIRST(&optinfo->dnsname_list); v;
261
-		    v = TAILQ_NEXT(v, link)) {
262
-			strlcat(s, v->val_vbuf.dv_buf, elen);
263
-			strlcat(s, " ", elen);
264
+		if (dnsnamelen) {
265
+			elen = sizeof (dnsname_str) + dnsnamelen + 1;
266
+			if ((s = envp[i++] = malloc(elen)) == NULL) {
267
+				d_printf(LOG_NOTICE, FNAME,
268
+				    "failed to allocate strings for DNS name");
269
+				ret = -1;
270
+				goto clean;
271
+			}
272
+			memset(s, 0, elen);
273
+			snprintf(s, elen, "%s=", dnsname_str);
274
+			for (v = TAILQ_FIRST(&optinfo->dnsname_list); v;
275
+			    v = TAILQ_NEXT(v, link)) {
276
+				strlcat(s, v->val_vbuf.dv_buf, elen);
277
+				strlcat(s, " ", elen);
278
+			}
279
 		}
280
-	}
281
 
282
-	if (sipservers) {
283
-		elen = sizeof (sipserver_str) +
284
-		    (INET6_ADDRSTRLEN + 1) * sipservers + 1;
285
-		if ((s = envp[i++] = malloc(elen)) == NULL) {
286
-			d_printf(LOG_NOTICE, FNAME,
287
-			    "failed to allocate strings for SIP servers");
288
-			ret = -1;
289
-			goto clean;
290
-		}
291
-		memset(s, 0, elen);
292
-		snprintf(s, elen, "%s=", sipserver_str);
293
-		for (v = TAILQ_FIRST(&optinfo->sip_list); v;
294
-		    v = TAILQ_NEXT(v, link)) {
295
-			char *addr;
296
+		if (sipservers) {
297
+			elen = sizeof (sipserver_str) +
298
+			    (INET6_ADDRSTRLEN + 1) * sipservers + 1;
299
+			if ((s = envp[i++] = malloc(elen)) == NULL) {
300
+				d_printf(LOG_NOTICE, FNAME,
301
+				    "failed to allocate strings for SIP servers");
302
+				ret = -1;
303
+				goto clean;
304
+			}
305
+			memset(s, 0, elen);
306
+			snprintf(s, elen, "%s=", sipserver_str);
307
+			for (v = TAILQ_FIRST(&optinfo->sip_list); v;
308
+			    v = TAILQ_NEXT(v, link)) {
309
+				char *addr;
310
 
311
-			addr = in6addr2str(&v->val_addr6, 0);
312
-			strlcat(s, addr, elen);
313
-			strlcat(s, " ", elen);
314
-		}
315
-	}
316
-	if (sipnamelen) {
317
-		elen = sizeof (sipname_str) + sipnamelen + 1;
318
-		if ((s = envp[i++] = malloc(elen)) == NULL) {
319
-			d_printf(LOG_NOTICE, FNAME,
320
-			    "failed to allocate strings for SIP domain name");
321
-			ret = -1;
322
-			goto clean;
323
+				addr = in6addr2str(&v->val_addr6, 0);
324
+				strlcat(s, addr, elen);
325
+				strlcat(s, " ", elen);
326
+			}
327
 		}
328
-		memset(s, 0, elen);
329
-		snprintf(s, elen, "%s=", sipname_str);
330
-		for (v = TAILQ_FIRST(&optinfo->sipname_list); v;
331
-		    v = TAILQ_NEXT(v, link)) {
332
-			strlcat(s, v->val_vbuf.dv_buf, elen);
333
-			strlcat(s, " ", elen);
334
+		if (sipnamelen) {
335
+			elen = sizeof (sipname_str) + sipnamelen + 1;
336
+			if ((s = envp[i++] = malloc(elen)) == NULL) {
337
+				d_printf(LOG_NOTICE, FNAME,
338
+				    "failed to allocate strings for SIP domain name");
339
+				ret = -1;
340
+				goto clean;
341
+			}
342
+			memset(s, 0, elen);
343
+			snprintf(s, elen, "%s=", sipname_str);
344
+			for (v = TAILQ_FIRST(&optinfo->sipname_list); v;
345
+			    v = TAILQ_NEXT(v, link)) {
346
+				strlcat(s, v->val_vbuf.dv_buf, elen);
347
+				strlcat(s, " ", elen);
348
+			}
349
 		}
350
-	}
351
 
352
-	if (nisservers) {
353
-		elen = sizeof (nisserver_str) +
354
-		    (INET6_ADDRSTRLEN + 1) * nisservers + 1;
355
-		if ((s = envp[i++] = malloc(elen)) == NULL) {
356
-			d_printf(LOG_NOTICE, FNAME,
357
-			    "failed to allocate strings for NIS servers");
358
-			ret = -1;
359
-			goto clean;
360
-		}
361
-		memset(s, 0, elen);
362
-		snprintf(s, elen, "%s=", nisserver_str);
363
-		for (v = TAILQ_FIRST(&optinfo->nis_list); v;
364
-		    v = TAILQ_NEXT(v, link)) {
365
-			char *addr;
366
+		if (nisservers) {
367
+			elen = sizeof (nisserver_str) +
368
+			    (INET6_ADDRSTRLEN + 1) * nisservers + 1;
369
+			if ((s = envp[i++] = malloc(elen)) == NULL) {
370
+				d_printf(LOG_NOTICE, FNAME,
371
+				    "failed to allocate strings for NIS servers");
372
+				ret = -1;
373
+				goto clean;
374
+			}
375
+			memset(s, 0, elen);
376
+			snprintf(s, elen, "%s=", nisserver_str);
377
+			for (v = TAILQ_FIRST(&optinfo->nis_list); v;
378
+			    v = TAILQ_NEXT(v, link)) {
379
+				char *addr;
380
 
381
-			addr = in6addr2str(&v->val_addr6, 0);
382
-			strlcat(s, addr, elen);
383
-			strlcat(s, " ", elen);
384
-		}
385
-	}
386
-	if (nisnamelen) {
387
-		elen = sizeof (nisname_str) + nisnamelen + 1;
388
-		if ((s = envp[i++] = malloc(elen)) == NULL) {
389
-			d_printf(LOG_NOTICE, FNAME,
390
-			    "failed to allocate strings for NIS domain name");
391
-			ret = -1;
392
-			goto clean;
393
+				addr = in6addr2str(&v->val_addr6, 0);
394
+				strlcat(s, addr, elen);
395
+				strlcat(s, " ", elen);
396
+			}
397
 		}
398
-		memset(s, 0, elen);
399
-		snprintf(s, elen, "%s=", nisname_str);
400
-		for (v = TAILQ_FIRST(&optinfo->nisname_list); v;
401
-		    v = TAILQ_NEXT(v, link)) {
402
-			strlcat(s, v->val_vbuf.dv_buf, elen);
403
-			strlcat(s, " ", elen);
404
+		if (nisnamelen) {
405
+			elen = sizeof (nisname_str) + nisnamelen + 1;
406
+			if ((s = envp[i++] = malloc(elen)) == NULL) {
407
+				d_printf(LOG_NOTICE, FNAME,
408
+				    "failed to allocate strings for NIS domain name");
409
+				ret = -1;
410
+				goto clean;
411
+			}
412
+			memset(s, 0, elen);
413
+			snprintf(s, elen, "%s=", nisname_str);
414
+			for (v = TAILQ_FIRST(&optinfo->nisname_list); v;
415
+			    v = TAILQ_NEXT(v, link)) {
416
+				strlcat(s, v->val_vbuf.dv_buf, elen);
417
+				strlcat(s, " ", elen);
418
+			}
419
 		}
420
-	}
421
 
422
-	if (nispservers) {
423
-		elen = sizeof (nispserver_str) +
424
-		    (INET6_ADDRSTRLEN + 1) * nispservers + 1;
425
-		if ((s = envp[i++] = malloc(elen)) == NULL) {
426
-			d_printf(LOG_NOTICE, FNAME,
427
-			    "failed to allocate strings for NIS+ servers");
428
-			ret = -1;
429
-			goto clean;
430
-		}
431
-		memset(s, 0, elen);
432
-		snprintf(s, elen, "%s=", nispserver_str);
433
-		for (v = TAILQ_FIRST(&optinfo->nisp_list); v;
434
-		    v = TAILQ_NEXT(v, link)) {
435
-			char *addr;
436
+		if (nispservers) {
437
+			elen = sizeof (nispserver_str) +
438
+			    (INET6_ADDRSTRLEN + 1) * nispservers + 1;
439
+			if ((s = envp[i++] = malloc(elen)) == NULL) {
440
+				d_printf(LOG_NOTICE, FNAME,
441
+				    "failed to allocate strings for NIS+ servers");
442
+				ret = -1;
443
+				goto clean;
444
+			}
445
+			memset(s, 0, elen);
446
+			snprintf(s, elen, "%s=", nispserver_str);
447
+			for (v = TAILQ_FIRST(&optinfo->nisp_list); v;
448
+			    v = TAILQ_NEXT(v, link)) {
449
+				char *addr;
450
 
451
-			addr = in6addr2str(&v->val_addr6, 0);
452
-			strlcat(s, addr, elen);
453
-			strlcat(s, " ", elen);
454
-		}
455
-	}
456
-	if (nispnamelen) {
457
-		elen = sizeof (nispname_str) + nispnamelen + 1;
458
-		if ((s = envp[i++] = malloc(elen)) == NULL) {
459
-			d_printf(LOG_NOTICE, FNAME,
460
-			    "failed to allocate strings for NIS+ domain name");
461
-			ret = -1;
462
-			goto clean;
463
+				addr = in6addr2str(&v->val_addr6, 0);
464
+				strlcat(s, addr, elen);
465
+				strlcat(s, " ", elen);
466
+			}
467
 		}
468
-		memset(s, 0, elen);
469
-		snprintf(s, elen, "%s=", nispname_str);
470
-		for (v = TAILQ_FIRST(&optinfo->nispname_list); v;
471
-		    v = TAILQ_NEXT(v, link)) {
472
-			strlcat(s, v->val_vbuf.dv_buf, elen);
473
-			strlcat(s, " ", elen);
474
+		if (nispnamelen) {
475
+			elen = sizeof (nispname_str) + nispnamelen + 1;
476
+			if ((s = envp[i++] = malloc(elen)) == NULL) {
477
+				d_printf(LOG_NOTICE, FNAME,
478
+				    "failed to allocate strings for NIS+ domain name");
479
+				ret = -1;
480
+				goto clean;
481
+			}
482
+			memset(s, 0, elen);
483
+			snprintf(s, elen, "%s=", nispname_str);
484
+			for (v = TAILQ_FIRST(&optinfo->nispname_list); v;
485
+			    v = TAILQ_NEXT(v, link)) {
486
+				strlcat(s, v->val_vbuf.dv_buf, elen);
487
+				strlcat(s, " ", elen);
488
+			}
489
 		}
490
-	}
491
 
492
-	if (bcmcsservers) {
493
-		elen = sizeof (bcmcsserver_str) +
494
-		    (INET6_ADDRSTRLEN + 1) * bcmcsservers + 1;
495
-		if ((s = envp[i++] = malloc(elen)) == NULL) {
496
-			d_printf(LOG_NOTICE, FNAME,
497
-			    "failed to allocate strings for BCMC servers");
498
-			ret = -1;
499
-			goto clean;
500
-		}
501
-		memset(s, 0, elen);
502
-		snprintf(s, elen, "%s=", bcmcsserver_str);
503
-		for (v = TAILQ_FIRST(&optinfo->bcmcs_list); v;
504
-		    v = TAILQ_NEXT(v, link)) {
505
-			char *addr;
506
+		if (bcmcsservers) {
507
+			elen = sizeof (bcmcsserver_str) +
508
+			    (INET6_ADDRSTRLEN + 1) * bcmcsservers + 1;
509
+			if ((s = envp[i++] = malloc(elen)) == NULL) {
510
+				d_printf(LOG_NOTICE, FNAME,
511
+				    "failed to allocate strings for BCMC servers");
512
+				ret = -1;
513
+				goto clean;
514
+			}
515
+			memset(s, 0, elen);
516
+			snprintf(s, elen, "%s=", bcmcsserver_str);
517
+			for (v = TAILQ_FIRST(&optinfo->bcmcs_list); v;
518
+			    v = TAILQ_NEXT(v, link)) {
519
+				char *addr;
520
 
521
-			addr = in6addr2str(&v->val_addr6, 0);
522
-			strlcat(s, addr, elen);
523
-			strlcat(s, " ", elen);
524
-		}
525
-	}
526
-	if (bcmcsnamelen) {
527
-		elen = sizeof (bcmcsname_str) + bcmcsnamelen + 1;
528
-		if ((s = envp[i++] = malloc(elen)) == NULL) {
529
-			d_printf(LOG_NOTICE, FNAME,
530
-			    "failed to allocate strings for BCMC domain name");
531
-			ret = -1;
532
-			goto clean;
533
+				addr = in6addr2str(&v->val_addr6, 0);
534
+				strlcat(s, addr, elen);
535
+				strlcat(s, " ", elen);
536
+			}
537
 		}
538
-		memset(s, 0, elen);
539
-		snprintf(s, elen, "%s=", bcmcsname_str);
540
-		for (v = TAILQ_FIRST(&optinfo->bcmcsname_list); v;
541
-		    v = TAILQ_NEXT(v, link)) {
542
-			strlcat(s, v->val_vbuf.dv_buf, elen);
543
-			strlcat(s, " ", elen);
544
+		if (bcmcsnamelen) {
545
+			elen = sizeof (bcmcsname_str) + bcmcsnamelen + 1;
546
+			if ((s = envp[i++] = malloc(elen)) == NULL) {
547
+				d_printf(LOG_NOTICE, FNAME,
548
+				    "failed to allocate strings for BCMC domain name");
549
+				ret = -1;
550
+				goto clean;
551
+			}
552
+			memset(s, 0, elen);
553
+			snprintf(s, elen, "%s=", bcmcsname_str);
554
+			for (v = TAILQ_FIRST(&optinfo->bcmcsname_list); v;
555
+			    v = TAILQ_NEXT(v, link)) {
556
+				strlcat(s, v->val_vbuf.dv_buf, elen);
557
+				strlcat(s, " ", elen);
558
+			}
559
 		}
560
 	}
561
-
562
 	/* launch the script */
563
 	pid = fork();
564
 	if (pid < 0) {
565
@@ -432,6 +463,5 @@ client6_script(scriptpath, state, optinf
566
 	for (i = 0; i < envc; i++)
567
 		free(envp[i]);
568
 	free(envp);
569
-
570
 	return ret;
571
 }
(7-7/11)