Skip to content

Commit

Permalink
prevent leading spaces in rdomain-specific daemon config files
Browse files Browse the repository at this point in the history
Rules for rdomain-specific daemons have double-indentation in nshrc.
When generating configuration files for daemons strip double-indentation
instead of stripping only one level of indentation.

testing + ok Tom
  • Loading branch information
stspdotname committed Oct 31, 2024
1 parent 01bc5d4 commit e1e572a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void restart_dhcpd(int, char **, ...);
/* subroutines */
int fill_tmpfile(char **, char *, char **);
int edit_file(char *, mode_t, char *, char **);
int rule_writeline(char *, mode_t, char *);
int rule_writeline(char *, mode_t, char *, int);
int acq_lock(char *);
void rls_lock(int);

Expand Down Expand Up @@ -662,7 +662,8 @@ ctlhandler(int argc, char **argv, ...)
goto done;
}
/* write indented line to tmp config file */
rule_writeline(tmpfile, daemons->mode, saveline);
rule_writeline(tmpfile, daemons->mode, saveline,
cli_rtable);
goto done;
}
}
Expand Down Expand Up @@ -1048,7 +1049,7 @@ edit_file(char *tmpfile, mode_t mode, char *propername, char **args)
}

int
rule_writeline(char *fname, mode_t mode, char *writeline)
rule_writeline(char *fname, mode_t mode, char *writeline, int rdomain)
{
FILE *rulefile;

Expand All @@ -1057,8 +1058,12 @@ rule_writeline(char *fname, mode_t mode, char *writeline)
printf("%% Rule write failed: %s\n", strerror(errno));
return(1);
}
if (writeline[0] == ' ')
if (writeline[0] == ' ') {
writeline++;
/* Lines for rdomain-specific daemons are indented twice. */
if (rdomain > 0 && writeline[0] == ' ')
writeline++;
}
fprintf(rulefile, "%s", writeline);
fclose(rulefile);
chmod(fname, mode);
Expand Down

1 comment on commit e1e572a

@smytht
Copy link
Collaborator

@smytht smytht commented on e1e572a Oct 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excellent solves the config-diff bug after reboot

Please sign in to comment.