From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Tremer To: development@lists.ipfire.org Subject: [PATCH] installer: Fix reading /proc/cmdline when launched by GRUB Date: Tue, 13 Jul 2021 15:44:20 +0000 Message-ID: <20210713154420.451-1-michael.tremer@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6016882386590805310==" List-Id: --===============6016882386590805310== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The installer was reading the kernel command line and was looking for certain values which configured the installer. GRUB appended a trailing newline character which was not accounted for and caused that the last parameter was not correctly compared to the list of possible keys. Fixes: #12656 - core 157: unattended installation don't work as expected on E= FI Signed-off-by: Michael Tremer --- src/installer/main.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/installer/main.c b/src/installer/main.c index 00d172888..fd20a1f37 100644 --- a/src/installer/main.c +++ b/src/installer/main.c @@ -290,18 +290,23 @@ static struct config { .language =3D DEFAULT_LANG, }; =20 -static void parse_command_line(struct config* c) { +static void parse_command_line(FILE* flog, struct config* c) { char buffer[STRING_SIZE]; char cmdline[STRING_SIZE]; =20 FILE* f =3D fopen("/proc/cmdline", "r"); - if (!f) + if (!f) { + fprintf(flog, "Could not open /proc/cmdline: %m"); return; + } =20 int r =3D fread(&cmdline, 1, sizeof(cmdline) - 1, f); if (r > 0) { - char* token =3D strtok(cmdline, " "); + // Remove the trailing newline + if (cmdline[r-1] =3D=3D '\n') + cmdline[r-1] =3D '\0'; =20 + char* token =3D strtok(cmdline, " "); while (token) { strncpy(buffer, token, sizeof(buffer)); char* val =3D buffer; @@ -403,7 +408,7 @@ int main(int argc, char *argv[]) { snprintf(title, sizeof(title), "%s - %s", DISTRO_NAME, DISTRO_SLOGAN); =20 // Parse parameters from the kernel command line - parse_command_line(&config); + parse_command_line(flog, &config); =20 if (config.unattended) { splashWindow(title, _("Warning: Unattended installation will start in 10 s= econds..."), 10); --=20 2.20.1 --===============6016882386590805310==--