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

Syntax error when updating grub if a snapshot name contains one single quote #198

Closed
ajayyy opened this issue Jan 24, 2022 · 6 comments · Fixed by #226
Closed

Syntax error when updating grub if a snapshot name contains one single quote #198

ajayyy opened this issue Jan 24, 2022 · 6 comments · Fixed by #226
Assignees

Comments

@ajayyy
Copy link

ajayyy commented Jan 24, 2022

Generating grub configuration file ...
Found theme: /usr/share/grub/themes/manjaro/theme.txt
Found linux image: /boot/vmlinuz-5.15-x86_64
Found initrd image: /boot/intel-ucode.img /boot/initramfs-5.15-x86_64.img
Found initrd fallback image: /boot/initramfs-5.15-x86_64-fallback.img
Found linux image: /boot/vmlinuz-5.4-x86_64
Found initrd image: /boot/intel-ucode.img /boot/initramfs-5.4-x86_64.img
Found initrd fallback image: /boot/initramfs-5.4-x86_64-fallback.img
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found Windows Boot Manager on /dev/nvme0n1p1@/efi/Microsoft/Boot/bootmgfw.efi
Found Debian GNU/Linux 11 (bullseye) on /dev/nvme0n1p9
Found Windows Boot Manager on /dev/sda4@/efi/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for UEFI Firmware Settings ...
Detecting snapshots ...
<REDACTED>
Found 20 snapshot(s)
error: syntax error.
error: Incorrect command.
error: syntax error.
Syntax error at line 452
Syntax errors are detected in generated grub-btrfs.cfg file.
If you think an error has occurred , please file a bug report at " https://github.com/Antynea/grub-btrfs "
Unmount /tmp/grub-btrfs.590QglV0nS .. Success
Found memtest86+ image: /boot/memtest86+/memtest.bin
/usr/bin/grub-probe: warning: unknown device type nvme0n1.
done

I found that removing the single quote fixes it, and it does not occur when there are two single quotes.

Version: 4.1.1
Distro: Manjaro

@Schievel1 Schievel1 self-assigned this Oct 21, 2022
@Schievel1
Copy link
Collaborator

Hi,

when you ran grub-mkconf with a snapshot with a quote in it and it failed, can you post /boot/grub/grub-btrfs-new?

I probably just gonna add a function to sanitize the snapshot names and run every snapshot though it.

@blisshome
Copy link

I got the same syntax error messages when running grub-mkconfig, and the snapshot submenu of GRUB was empty. Both issues went away after removing the single quotation mark (possessive apostrophe, actually) in the description field of one of my Timeshift snapshots. I look forward to Schievel1's fix, but avoiding a single quotation mark/apostrophe in the description works for now. Thanks!
Running 5.19.17-1-MANJARO (64-bit) with grub-btrfs 4.11-2

@Schievel1
Copy link
Collaborator

Schievel1 commented Nov 16, 2022

I created a really small sanitize function. https://github.com/Antynea/grub-btrfs/pull/226/files#diff-9b6d1a434bd2a223bf71bbbb1393b35e131311e2a8369779c6be2a116626630fR165
All it does is removing the ' from the menu and submenu titles. That seems to be enough already.
However, I wonder if this function should remove more characters. But so far I tried ' !@#$%^&*()+={}[],<>.;: and they all go well. It's only ' that causes a problem. Do you have problems with any other characters that did not come to my mind?

I think we can not really do much other than sanitizing the string we return up to grub-mkconfig. This is grub-mkconfig which throws that error if I am not mistaken.
Right now this only sanitized the menu titles. I have to look into sanitizing actual snapshot names, I am afraid if we change the name we won’t be able to boot this snapshot

Schievel1 added a commit that referenced this issue Nov 16, 2022
Closes #198

Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
@blisshome
Copy link

I only encountered problems with the apostrophe. I suspect it causes an imbalance in the single quotes which confuses the syntax checker. Thanks for dealing with this.

@Schievel1
Copy link
Collaborator

I am only sanitizing the menu titles, which seems to be enough for when there is a ' in the comment of a snapshot.
I guess this also happens when there is a ' in the snapshot name.

This is more or less a note to myself to try that out, but you can give that a try as well if you want to.

@Schievel1
Copy link
Collaborator

Schievel1 commented Nov 19, 2022

Turns out in Timeshift you can not alter the snapshot names, its always the date. So no way to get a ' in there and no need to sanitize.

I think this is the same for snapper, isn't it? I just checked and there is only a way to provide a description, not a name for the snapshot.

Schievel1 added a commit that referenced this issue Nov 20, 2022
Closes #198

Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
Schievel1 added a commit that referenced this issue Nov 20, 2022
Closes #198

Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants