Commit Graph

220 Commits

Author SHA1 Message Date
Morten Linderud bca692f1e1
Updated readme for libera
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-05-21 15:32:45 +02:00
Hugo Osvaldo Barrera 0ba4f65dac Tweak unconvincing working 2021-05-21 10:20:13 +02:00
Hugo Barrera 9efc268827
Typo
Co-authored-by: Érico Nogueira Rolim <34201958+ericonr@users.noreply.github.com>
2021-05-21 10:18:58 +02:00
Hugo Barrera 7839c5f47b
Update docs/sbctl.8.txt
Co-authored-by: Érico Nogueira Rolim <34201958+ericonr@users.noreply.github.com>
2021-05-21 10:17:55 +02:00
Hugo Osvaldo Barrera 7b654ac28c Typos 2021-05-21 01:44:03 +02:00
Hugo Osvaldo Barrera fd444c444c Refine docs based on feedback 2021-05-21 01:20:42 +02:00
Hugo Osvaldo Barrera 74b581384f Extend the documentation a bit 2021-05-21 00:12:56 +02:00
Hugo Barrera 09181324a0
Update man entry for default cmdline
The default cmdline is `/etc/kernel/cmdline`, but the man page said `/proc/cmdline`.
2021-05-18 02:04:40 +00:00
igo95862 d3feae2791
Remove ioutil
Deprecated in GO 1.16
2021-05-16 21:14:42 +03:00
Morten Linderud f53632ebd2
util: Expand array in print generator
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-05-13 12:34:19 +02:00
Morten Linderud 35ebd7bba9
bundles: Handle command not found errors
Fixes #64

Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-05-13 12:33:58 +02:00
Morten Linderud e63eb3d6b1
Merge commit 'refs/pull/61/head' of github.com:Foxboron/sbctl 2021-05-09 16:49:18 +02:00
Morten Linderud 44d597c74e
Merge commit 'refs/pull/54/head' of github.com:Foxboron/sbctl 2021-05-09 16:43:50 +02:00
igo95862 e55ef14bf4
Redirect objcopy stderr to parent stderr 2021-05-05 11:15:50 +03:00
igo95862 02885c41db
Use argument list for objcopy instead of split by whitespace
The order of .splash argument has changed but I don't
believe it will have an effect on result.
2021-05-05 11:01:35 +03:00
igo95862 7d6d2c76ab
Directly pass arguments to subprocesses instead of args spliting 2021-05-04 22:16:57 +03:00
Morten Linderud 9060461b35
sbctl: Inverted bool broke key enrollment
Should get that integration tests.

Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-04-25 12:58:44 +02:00
Morten Linderud 3fcd3b0e84
Updated srcinfo
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-04-24 17:45:17 +02:00
Morten Linderud a33d0b40d8
Fixed sbctl hooks in PKGBUILD
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-04-24 17:41:15 +02:00
Érico Nogueira 63876f01d5 Use x/sys/unix for ioctl instead of rolling our own.
Keep FS_* constants which aren't listed in the package, and leave
SetAttr there, even though it's currently not used.

Leave a comment about this implementation not working on 64-bit big
endian systems. Chances of this software being run on such a platform
are very low, since at the moment, to my knowledge, Secure Boot on
64-bit big endian can only happen with aarch64_be, which is quite rare.
2021-04-18 00:38:49 -03:00
Morten Linderud 59ec7a813f
sbctl: IsImmutable should return false if the file does not exist
Weird efivarfs quirk is that sometimes empty vars have no file. This
means they are not immutable and we can write to them.

Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-04-18 03:29:29 +02:00
Morten Linderud a6445c4a2b
sbctl: Create valid x509 certs for the kernel
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-04-16 22:13:55 +02:00
Morten Linderud 4df69d6935
Merge branch 'morten/fix-hook' 2021-04-14 21:51:41 +02:00
Morten Linderud ad1dc957cb
Merge branch 'morten/cmdline' 2021-04-14 21:51:33 +02:00
Morten Linderud 8405a2a407
Merge branch 'morten/fix-permission' 2021-04-14 21:51:23 +02:00
Morten Linderud 9100e231ea
Merge branch 'morten/immutable' 2021-04-14 21:51:10 +02:00
Morten Linderud c50750ee7a
sbctl.hook: Renamed to be ordered last, added more paths
This should cover systemd and fwupd alike

Fixes #51

Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-04-14 21:38:08 +02:00
Morten Linderud 36a1849942
sbctl/bundle: Change default cmdline to /etc/kernel/cmdline
Should probably try include some documentation to this, but this changes
the default from /proc/cmdline to /etc/kernel/cmdline.

This is partially a standard and a bit more flexible for everyday use
for most people.

https://www.freedesktop.org/software/systemd/man/kernel-install.html

Fixes #39

Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-04-05 16:24:19 +02:00
Morten Linderud d69b59bb01
sbctl: Check for persmission denied. Use errors package
We can always stat files, but it's enough to figure out if we can
actually check the signature. Instead we try to open the file.

This patch also moves us to the new errors package

    $ sbctl verify
    ==> Verifying file database and EFI images in /efi...
      -> WARNING: /boot/EFI/BOOT/BOOTX64.EFI is not signed
      -> WARNING: /boot/EFI/arch/fwupdx64.efi is not signed
      -> WARNING: /boot/EFI/systemd/systemd-bootx64.efi is not signed
      -> ERROR: /tmp/vmlinuz-linux does not exist
      -> ERROR: /tmp/vmlinuz-linuz-test permission denied. Can't read file

Fixes #46

Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-04-03 13:09:08 +02:00
Morten Linderud 99efd2a5e3
keys: sbkeysync can have "Permissiond denide" errors
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-04-03 12:30:52 +02:00
Morten Linderud 2572b38a8e
sbctl: Check for immutable files before sbkeysync
This allows us to give a sensible error for `enroll-keys` if the files
are set as immutable.

    $ sbctl enroll-keys
    ==> ERROR: File is immutable: /sys/firmware/efi/efivars/PK-8be4df61-93ca-11d2-aa0d-00e098032b8c
    ==> ERROR: File is immutable: /sys/firmware/efi/efivars/KEK-8be4df61-93ca-11d2-aa0d-00e098032b8c
    ==> ERROR: File is immutable: /sys/firmware/efi/efivars/db-d719b2cb-3d3a-4596-a3bc-dad00e67656f
    ==> ERROR: You need to chattr -i files in efivarfs

Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-04-03 12:27:44 +02:00
Morten Linderud a426eeb0c6
cmd/sbctl: Typo in err
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-03-12 23:01:15 +01:00
Morten Linderud 17fc0e5ff4
cmd/sbctl: proper exit if we fail creating bundle
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-03-06 19:53:13 +01:00
Morten Linderud 7cdab1f018
sbctl: Microcode won't always be passed
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-03-06 19:49:51 +01:00
Morten Linderud e40683e344
sbctl: Added missing format argument
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-03-06 19:49:35 +01:00
Morten Linderud 611f2818c6
Makefile: Fixup make before release
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-02-28 14:08:36 +01:00
Morten Linderud a0cd90a0b0
sbctl: Fixed up some missing error handling
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-02-28 14:06:58 +01:00
Morten Linderud 79d986f987
Merge branch 'pr-31' 2021-02-16 19:54:43 +01:00
Érico Rolim f94f185652 Use ReadOrCreateFile in ReadBundleDatabase.
Using the function also removed code that had hardcoded globals for the
location of some files instead of using the dbpath parameter.

Add error checking around the function where appropriate.

Also fail early when creating a new bundle if it isn't possible to
access the bundle database.

Signed-off-by: Érico Rolim <erico.erc@gmail.com>
2021-01-11 00:51:32 -03:00
Érico Rolim cc55d6e443 Add ReadOrCreateFile utility function.
This function will try to read a file into a byte buffer, and, if the
file doesn't exist, create its containing directory and the file itself.
If any of those actions fail due to permissions, the function will print
a warning about running the tool as root.

Reading from the file and bundle databases works like this, so the error
checking should be implemented in a single place.

Also, use the new function in ReadFileDatabase().

Signed-off-by: Érico Rolim <erico.erc@gmail.com>
2021-01-11 00:49:45 -03:00
Érico Rolim 92bb91172d Improve error propagation and permission checking.
- Introduces dependency on sys/unix for unix.Access. This is necessary
only in keys.go, since we run 'sbsign' as a command and can't check if
it failed due to permissions.

- Allows removing special casing in main.go for commands that don't
require root permissions.

- ReadFileDatabase() can now return errors due to the multiple ways in
which it can fail; it also warns the user about possibly requiring root.

- ReadFileDatabase() was using the global DBPath instead of its dbpath
parameter in multiple places. This has been fixed.

- VerifyESP() can now run without root.

- SignFile() checks if it can read the DB key before running sbsign.

Signed-off-by: Érico Rolim <erico.erc@gmail.com>
2021-01-11 00:49:45 -03:00
Érico Rolim 0a7c6e8bc5 Fix potential seg fault in ChecksumFile.
If ReadFile errors out, the error would only be checked after the
function attempts to read the buffer into the hasher. This commit fixes
that, checking the error as soon as possible.

Signed-off-by: Érico Rolim <erico.erc@gmail.com>
2021-01-11 00:43:21 -03:00
Érico Rolim 017b0c1dea Use err1 instead of err as a logger.
This allows err to be used anywhere as the error variable, instead of
having to use "e", for example. This commit also fixes a bug where the
PrintGenerateError() calls in CombineFiles() were using "err" as the
argument for error, when it should have been "e" - since "err" was the
logger and could be used in that way, the compiler didn't complain.

Signed-off-by: Érico Rolim <erico.erc@gmail.com>
2021-01-11 00:37:17 -03:00
Morten Linderud f92102ae2a
Moved from goefi to go-uefi
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-01-05 22:33:17 +01:00
Morten Linderud 9e9c3a1620
Add support channel
Signed-off-by: Morten Linderud <morten@linderud.pw>
2020-12-30 12:19:17 +01:00
physkets af64bdc245
Document the generate option of sign-all 2020-11-10 15:32:18 +00:00
Morten Linderud dfa6fb1baa
Merge branch 'pr-36' 2020-11-08 19:09:41 +01:00
Morten Linderud b09199482f
README: Fix build badge
Signed-off-by: Morten Linderud <morten@linderud.pw>
2020-11-08 19:09:12 +01:00
Érico Rolim 464b3c2f71 Fix lint step in CI.
Set GOBIN during `make deps` so staticcheck is installed directly in a
directory already in PATH.
2020-11-08 15:06:55 -03:00
Morten Linderud fe1f0365f9
Merge branch 'pr-33' 2020-11-08 19:01:38 +01:00