mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-09 18:45:54 +02:00
installer: Fix reading /proc/cmdline when launched by GRUB
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 <michael.tremer@ipfire.org> Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
This commit is contained in:
committed by
Arne Fitzenreiter
parent
618b9f3a76
commit
646d6b0670
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user