commit e1e572aed6981d7de50ea265e3360d3a6f006a96 from: Stefan Sperling date: Thu Oct 31 16:16:44 2024 UTC prevent leading spaces in rdomain-specific daemon config files 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 commit - 01bc5d48c9c87c8feffb618640ae989586f58c09 commit + e1e572aed6981d7de50ea265e3360d3a6f006a96 blob - 9270b99463cb1ad4a9e4150d2f673a0608250db5 blob + 67d439800ada0fbc2df3a934e0f22f6935f1f7af --- ctl.c +++ ctl.c @@ -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); @@ -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; } } @@ -1048,7 +1049,7 @@ edit_file(char *tmpfile, mode_t mode, char *propername } int -rule_writeline(char *fname, mode_t mode, char *writeline) +rule_writeline(char *fname, mode_t mode, char *writeline, int rdomain) { FILE *rulefile; @@ -1057,8 +1058,12 @@ rule_writeline(char *fname, mode_t mode, char *writeli 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);