Bugfix: Do not free() static string in new runparts directive

This is a bugfix to 785c21d, which introduced the new runparts
directive in finit.conf

- Do not attempt to free() a static string, use same approach as
  username and hostname.

- Do not overwrite hostname, set the correct variable if runparts
  directive is found in finit.conf

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2012-10-08 11:42:19 +02:00
parent 7e3465a022
commit 77b0df3d07
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -64,9 +64,9 @@ void parse_finit_conf(char *file)
char line[LINE_SIZE];
char cmd[CMD_SIZE];
/* Default username and hostname */
username = strdup(DEFUSER);
hostname = strdup(DEFHOST);
rcsd = strdup(FINIT_RCSD);
if ((fp = fopen(file, "r")) != NULL) {
char *x;
@@ -124,7 +124,7 @@ void parse_finit_conf(char *file)
}
if (MATCH_CMD(line, "runparts ", x)) {
if (rcsd) free(rcsd);
hostname = build_cmd(NULL, x, CMD_SIZE);
rcsd = build_cmd(NULL, x, CMD_SIZE);
continue;
}
if (MATCH_CMD(line, "startx ", x)) {
+1 -1
View File
@@ -41,7 +41,7 @@ char *sdown = NULL;
char *network = NULL;
char *username = NULL;
char *hostname = NULL;
char *rcsd = FINIT_RCSD;
char *rcsd = NULL;
static void parse_kernel_cmdline(void)