On 01/08/2010 06:20 PM, Chris Lumens wrote:
- status = system("/sbin/rsyslogd -c 4n -N1");
- dup2(stderr_dup, 2); /* restore stderr */
- if (status< 0 ||
!WIFEXITED(status) ||
WEXITSTATUS(status) != 0) {
printf("Unable to start syslog daemon due to its configuration file "
"being corrupted. Did you pass in a wrong \"syslog=\"?\n");
fatal_error(1);
I'm not sure this error message means much to most people - who's really going to care about the syslog configuration file? What kind of malformed syslog= errors are you expecting here, and is it possible to validate the parameter in getSyslog?
I am worried that the user could pass in a semicolon, whitespace or double quotes which could confuse rsyslog and break logging (even though I can't see a reason why one would do that). Of course we can avoid the test run completely by testing the syslogd parameter to only contain valid address characters (ipv4, ipv6 or a server name). I would do it in getSyslog() as you suggest:
if (!g_regex_match_simple("^[\w.:/\-\[\]]*$", addr, 0, 0)) { /* the parameter is malformed, disable its use */ addr[0] = '\0'; printf("The syslog= command line parameter is malformed and will be\n"); printf("ignored by the installer.\n"); sleep(5); }
(it is also possible to have a loop instead of the regular expression)
If you'll agree with solving it this way I will do one more testing compose to make sure that everything's still fine.
Ales