Skip to content

Commit f9cc604

Browse files
committed
trim spaces from list of templates
right now an object like this: defined host { use template1, template2 } would fail, because of the space character. This patch trims the list elements. Signed-off-by: Sven Nierlein <[email protected]>
1 parent d74398c commit f9cc604

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/naemon/xodtemplate.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3132,6 +3132,7 @@ static int xodtemplate_resolve_timeperiod(xodtemplate_timeperiod *this_timeperio
31323132
/* apply all templates */
31333133
template_name_ptr = template_names;
31343134
for (temp_ptr = my_strsep(&template_name_ptr, ","); temp_ptr != NULL; temp_ptr = my_strsep(&template_name_ptr, ",")) {
3135+
temp_ptr = trim(temp_ptr);
31353136

31363137
template_timeperiod = xodtemplate_find_timeperiod(temp_ptr);
31373138
if (template_timeperiod == NULL) {
@@ -3219,6 +3220,7 @@ static int xodtemplate_resolve_command(xodtemplate_command *this_command)
32193220
/* apply all templates */
32203221
template_name_ptr = template_names;
32213222
for (temp_ptr = my_strsep(&template_name_ptr, ","); temp_ptr != NULL; temp_ptr = my_strsep(&template_name_ptr, ",")) {
3223+
temp_ptr = trim(temp_ptr);
32223224

32233225
template_command = xodtemplate_find_command(temp_ptr);
32243226
if (template_command == NULL) {
@@ -3265,6 +3267,7 @@ static int xodtemplate_resolve_contactgroup(xodtemplate_contactgroup *this_conta
32653267
/* apply all templates */
32663268
template_name_ptr = template_names;
32673269
for (temp_ptr = my_strsep(&template_name_ptr, ","); temp_ptr != NULL; temp_ptr = my_strsep(&template_name_ptr, ",")) {
3270+
temp_ptr = trim(temp_ptr);
32683271

32693272
template_contactgroup = xodtemplate_find_contactgroup(temp_ptr);
32703273
if (template_contactgroup == NULL) {
@@ -3315,6 +3318,7 @@ static int xodtemplate_resolve_hostgroup(xodtemplate_hostgroup *this_hostgroup)
33153318
/* apply all templates */
33163319
template_name_ptr = template_names;
33173320
for (temp_ptr = my_strsep(&template_name_ptr, ","); temp_ptr != NULL; temp_ptr = my_strsep(&template_name_ptr, ",")) {
3321+
temp_ptr = trim(temp_ptr);
33183322

33193323
template_hostgroup = xodtemplate_find_hostgroup(temp_ptr);
33203324
if (template_hostgroup == NULL) {
@@ -3368,6 +3372,7 @@ static int xodtemplate_resolve_servicegroup(xodtemplate_servicegroup *this_servi
33683372
/* apply all templates */
33693373
template_name_ptr = template_names;
33703374
for (temp_ptr = my_strsep(&template_name_ptr, ","); temp_ptr != NULL; temp_ptr = my_strsep(&template_name_ptr, ",")) {
3375+
temp_ptr = trim(temp_ptr);
33713376

33723377
template_servicegroup = xodtemplate_find_servicegroup(temp_ptr);
33733378
if (template_servicegroup == NULL) {
@@ -3421,6 +3426,7 @@ static int xodtemplate_resolve_servicedependency(xodtemplate_servicedependency *
34213426
/* apply all templates */
34223427
template_name_ptr = template_names;
34233428
for (temp_ptr = my_strsep(&template_name_ptr, ","); temp_ptr != NULL; temp_ptr = my_strsep(&template_name_ptr, ",")) {
3429+
temp_ptr = trim(temp_ptr);
34243430

34253431
template_servicedependency = xodtemplate_find_servicedependency(temp_ptr);
34263432
if (template_servicedependency == NULL) {
@@ -3490,6 +3496,7 @@ static int xodtemplate_resolve_serviceescalation(xodtemplate_serviceescalation *
34903496
/* apply all templates */
34913497
template_name_ptr = template_names;
34923498
for (temp_ptr = my_strsep(&template_name_ptr, ","); temp_ptr != NULL; temp_ptr = my_strsep(&template_name_ptr, ",")) {
3499+
temp_ptr = trim(temp_ptr);
34933500

34943501
template_serviceescalation = xodtemplate_find_serviceescalation(temp_ptr);
34953502
if (template_serviceescalation == NULL) {
@@ -3565,6 +3572,7 @@ static int xodtemplate_resolve_contact(xodtemplate_contact *this_contact)
35653572
/* apply all templates */
35663573
template_name_ptr = template_names;
35673574
for (temp_ptr = my_strsep(&template_name_ptr, ","); temp_ptr != NULL; temp_ptr = my_strsep(&template_name_ptr, ",")) {
3575+
temp_ptr = trim(temp_ptr);
35683576

35693577
template_contact = xodtemplate_find_contact(temp_ptr);
35703578
if (template_contact == NULL) {
@@ -3647,6 +3655,7 @@ static int xodtemplate_resolve_host(xodtemplate_host *this_host)
36473655
/* apply all templates */
36483656
template_name_ptr = template_names;
36493657
for (temp_ptr = my_strsep(&template_name_ptr, ","); temp_ptr != NULL; temp_ptr = my_strsep(&template_name_ptr, ",")) {
3658+
temp_ptr = trim(temp_ptr);
36503659

36513660
template_host = xodtemplate_find_host(temp_ptr);
36523661
if (template_host == NULL) {
@@ -3765,6 +3774,7 @@ static int xodtemplate_resolve_service(xodtemplate_service *this_service)
37653774
/* apply all templates */
37663775
template_name_ptr = template_names;
37673776
for (temp_ptr = my_strsep(&template_name_ptr, ","); temp_ptr != NULL; temp_ptr = my_strsep(&template_name_ptr, ",")) {
3777+
temp_ptr = trim(temp_ptr);
37683778

37693779
template_service = xodtemplate_find_service(temp_ptr);
37703780
if (template_service == NULL) {
@@ -3874,6 +3884,7 @@ static int xodtemplate_resolve_hostdependency(xodtemplate_hostdependency *this_h
38743884
/* apply all templates */
38753885
template_name_ptr = template_names;
38763886
for (temp_ptr = my_strsep(&template_name_ptr, ","); temp_ptr != NULL; temp_ptr = my_strsep(&template_name_ptr, ",")) {
3887+
temp_ptr = trim(temp_ptr);
38773888

38783889
template_hostdependency = xodtemplate_find_hostdependency(temp_ptr);
38793890
if (template_hostdependency == NULL) {
@@ -3928,6 +3939,7 @@ static int xodtemplate_resolve_hostescalation(xodtemplate_hostescalation *this_h
39283939
/* apply all templates */
39293940
template_name_ptr = template_names;
39303941
for (temp_ptr = my_strsep(&template_name_ptr, ","); temp_ptr != NULL; temp_ptr = my_strsep(&template_name_ptr, ",")) {
3942+
temp_ptr = trim(temp_ptr);
39313943

39323944
template_hostescalation = xodtemplate_find_hostescalation(temp_ptr);
39333945
if (template_hostescalation == NULL) {
@@ -3982,6 +3994,7 @@ static int xodtemplate_resolve_hostextinfo(xodtemplate_hostextinfo *this_hostext
39823994
/* apply all templates */
39833995
template_name_ptr = template_names;
39843996
for (temp_ptr = my_strsep(&template_name_ptr, ","); temp_ptr != NULL; temp_ptr = my_strsep(&template_name_ptr, ",")) {
3997+
temp_ptr = trim(temp_ptr);
39853998

39863999
template_hostextinfo = xodtemplate_find_hostextinfo(temp_ptr);
39874000
if (template_hostextinfo == NULL) {
@@ -4047,6 +4060,7 @@ static int xodtemplate_resolve_serviceextinfo(xodtemplate_serviceextinfo *this_s
40474060
/* apply all templates */
40484061
template_name_ptr = template_names;
40494062
for (temp_ptr = my_strsep(&template_name_ptr, ","); temp_ptr != NULL; temp_ptr = my_strsep(&template_name_ptr, ",")) {
4063+
temp_ptr = trim(temp_ptr);
40504064

40514065
template_serviceextinfo = xodtemplate_find_serviceextinfo(temp_ptr);
40524066
if (template_serviceextinfo == NULL) {

0 commit comments

Comments
 (0)