Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaks bootloader if multiple menuentries present #5

Closed
Vogtinator opened this issue Jan 28, 2020 · 3 comments
Closed

Breaks bootloader if multiple menuentries present #5

Vogtinator opened this issue Jan 28, 2020 · 3 comments

Comments

@Vogtinator
Copy link
Member

If there are multiple menuentry to be emitted into grub.cfg, the hack in /etc/grub.d/83_health_check_marker breaks, which results in a corrupted configuration file.

This can be fixed by replacing the ugly hack with a much nicer one:

 # Reopen the now changed output file in append mode
 exec >> "$cfgfile"
@Vogtinator
Copy link
Member Author

Turns out the "much nicer hack" doesn't fully work either. I assumed that the scripts inside grub.d were sourced, but that's not the case, so they only share already opened file descriptors.

I'll try to find an equivalent of python3 -c 'import os; os.lseek(1, 0, os.SEEK_END)'.

@Vogtinator
Copy link
Member Author

This seems to work fine:

dd oflag=append count=0 status=none

It does

[pid  1146] fcntl(1, F_GETFL)           = 0x8001 (flags O_WRONLY|O_LARGEFILE)
[pid  1146] fcntl(1, F_SETFL, O_WRONLY|O_APPEND|O_LARGEFILE) = 0

so forces the O_APPEND flag to stdout. This is not quite the same as seeking to the end of the replaced file content, but forces that every write to stdout ends up appended. That's arguably much better.

laenion added a commit that referenced this issue Jan 30, 2020
The current health-checker GRUB injection snippet had the problem that multiple
menuentries would have required calculating the number of entries first.
With dd it is possible to make stdout always append to the file, so the
corresponding flag is set.
[gh##5]
@laenion
Copy link
Contributor

laenion commented Jan 30, 2020

Using to dd to set O_APPEND now as suggested.

@laenion laenion closed this as completed Jan 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants