From 275105fe3d64d214f982a5c0eb113d806853919b Mon Sep 17 00:00:00 2001 From: Tuan Hoang Date: Tue, 1 Oct 2019 17:18:04 +0200 Subject: [PATCH] zipl: allow check for other locations of zipl.conf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Stefan Haberland Signed-off-by: Jan Höppner --- zipl/include/zipl.h | 2 ++ zipl/src/job.c | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/zipl/include/zipl.h b/zipl/include/zipl.h index 02827e2a..0ef06e4d 100644 --- a/zipl/include/zipl.h +++ b/zipl/include/zipl.h @@ -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" diff --git a/zipl/src/job.c b/zipl/src/job.c index 1178a7da..ccd9bb0d 100644 --- a/zipl/src/job.c +++ b/zipl/src/job.c @@ -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);