From patchwork Tue Jul 13 15:44:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tremer X-Patchwork-Id: 4516 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4GPQ185Xmsz3xCm for ; Tue, 13 Jul 2021 15:44:28 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4GPQ170Dfvz1PC; Tue, 13 Jul 2021 15:44:27 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4GPQ166086z2xqw; Tue, 13 Jul 2021 15:44:26 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4GPQ153hcpz2xm2 for ; Tue, 13 Jul 2021 15:44:25 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4GPQ14581yz9r; Tue, 13 Jul 2021 15:44:24 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1626191064; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=SKSByZsVoyJ4M7QYejDyp+1Mjo8YWaDWLVsdZFnoMVI=; b=2O1MGw+gElvsni2jvmW/lF8ioMqPlAtDXZe/G+Tk16Al3cuCuCx2hXBu7LJTVJ0ynxDN4g 5HKGKH71ZBcI8GCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1626191064; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=SKSByZsVoyJ4M7QYejDyp+1Mjo8YWaDWLVsdZFnoMVI=; b=mV5sA087krc+eGbmsoltNRVAwDqFfYKLTC61RYPPsTTIwCHzWVsV22uFddW7LtGyWBd2J/ qRFvYPIJPLnI8BGd8A6vY63q+NwrfPXVhagyy2LwiKaqmZUp1sEcj3XYXPI+lq1o/EFvch pVs6UTxinZlZ2JaDVqiU2bTCIaNzxFezTwtq7eW3qN2kuegUZ9BLaAMFW2X2siP3w4jggN HAYfD2k8sCUafvXqene/IpiwNCaEp+oWhXo+9OxURSJQoUSs/kgkHSt2UsxMUh2pf6K0mN j5MsUnHLUGF4fcueLjbyPM0uvb9+1nKn2cz/0Soea6fgCpbf8hheJ8XRhYeIdw== 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 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Tremer Errors-To: development-bounces@lists.ipfire.org Sender: "Development" 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 EFI 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 = DEFAULT_LANG, }; -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]; FILE* f = fopen("/proc/cmdline", "r"); - if (!f) + if (!f) { + fprintf(flog, "Could not open /proc/cmdline: %m"); return; + } int r = fread(&cmdline, 1, sizeof(cmdline) - 1, f); if (r > 0) { - char* token = strtok(cmdline, " "); + // Remove the trailing newline + if (cmdline[r-1] == '\n') + cmdline[r-1] = '\0'; + char* token = strtok(cmdline, " "); while (token) { strncpy(buffer, token, sizeof(buffer)); char* val = buffer; @@ -403,7 +408,7 @@ int main(int argc, char *argv[]) { snprintf(title, sizeof(title), "%s - %s", DISTRO_NAME, DISTRO_SLOGAN); // Parse parameters from the kernel command line - parse_command_line(&config); + parse_command_line(flog, &config); if (config.unattended) { splashWindow(title, _("Warning: Unattended installation will start in 10 seconds..."), 10);