zipl: allow check for other locations of zipl.conf

Allow zipl to find zipl.conf in following order:
/run/zipl/zipl.conf
/etc/zipl.conf
/lib/s390-tools/zipl.conf

Whichever is found first will be used.

Fixes: https://github.com/ibm-s390-tools/s390-tools/issues/70
Closes: https://github.com/ibm-s390-tools/s390-tools/pull/71
Signed-off-by: Tuan Hoang <tmhoang@linux.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Tuan Hoang
2019-10-01 17:18:04 +02:00
committed by Jan Höppner
parent 19259aeb65
commit 275105fe3d
2 changed files with 17 additions and 2 deletions

View File

@@ -47,7 +47,9 @@
#define DEFAULTBOOT_SECTION "defaultboot"
#define ZIPL_CONF_VAR "ZIPLCONF"
#define ZIPL_RUNTIME_CONF "/run/zipl/zipl.conf"
#define ZIPL_DEFAULT_CONF TOOLS_SYSCONFDIR "/zipl.conf"
#define ZIPL_MINIMAL_CONF TOOLS_LIBDIR "/zipl.conf"
#define ZIPL_DEFAULT_BLSDIR "/boot/loader/entries"
#define ZIPL_STAGE3_PATH TOOLS_LIBDIR "/stage3.bin"
#define ZIPL_SIPL_PATH "/sys/firmware/ipl/has_secure"

View File

@@ -59,6 +59,14 @@ static struct option options[] = {
/* Command line option abbreviations */
static const char option_string[] = "-c:b:t:i:r:p:P:d:D:M:s:S:m:hHnVvaT:fk:";
/* Locations of zipl.conf configuration file */
static const char *zipl_conf[] = {
ZIPL_RUNTIME_CONF,
ZIPL_DEFAULT_CONF,
ZIPL_MINIMAL_CONF,
NULL
};
struct command_line {
char* data[SCAN_KEYWORD_NUM];
char* config;
@@ -1783,7 +1791,7 @@ get_job_from_config_file(struct command_line* cmdline, struct job_data* job)
char* filename;
char *blsdir;
char* source;
int rc, scan_size;
int i, rc, scan_size;
/* Read configuration file */
if (cmdline->config != NULL) {
@@ -1797,7 +1805,12 @@ get_job_from_config_file(struct command_line* cmdline, struct job_data* job)
ZIPL_CONF_VAR ")";
} else {
/* Use default config file */
filename = ZIPL_DEFAULT_CONF;
for (i = 0; zipl_conf[i]; i++) {
if (misc_check_readable_file(zipl_conf[i]) == 0) {
filename = zipl_conf[i];
break;
}
}
source = "";
}
printf("Using config file '%s'%s\n", filename, source);