summaryrefslogtreecommitdiff
path: root/src/shared/efivars.c
Commit message (Collapse)AuthorAgeFilesLines
* efivars: modernize efi_get_variable() a bitLennart Poettering2019-07-251-27/+44
| | | | | Primarily, make sure the return parameters are all individually optional.
* tree-wide: some more [static] related fixesLennart Poettering2019-07-121-0/+2
| | | | | | | | | | | let's add [static] where it was missing so far Drop [static] on parameters that can be NULL. Add an assert() around parameters that have [static] and can't be NULL hence. Add some "const" where it was forgotten.
* efivars: allow plus in the entry nameYu Watanabe2019-05-191-1/+1
| | | | Closes #12572.
* tree-wide: drop !! casts to booleansFrantisek Sumsal2019-04-281-1/+1
| | | | Done by coccinelle/bool-cast.cocci
* efivars: add helper to format efivarfs pathZbigniew Jędrzejewski-Szmek2019-04-051-6/+15
|
* tree-wide: use SD_ID128_UUID_FORMAT_STR as appropriateZbigniew Jędrzejewski-Szmek2019-04-051-1/+1
|
* util: split out sorting related calls to new sort-util.[ch]Lennart Poettering2019-03-131-1/+1
|
* efivars: make sure efi_loader_entry_name_valid() is always compiled inLennart Poettering2019-03-111-10/+10
| | | | | | | | The string validation should always be done correctly, and not fail just because EFI is turned off. After all an EFI loader entry name string remains properly formatted regardless if EFI is on or off... Fixes: #11948
* shared/bootspec: treat empty EFI vars as missingZbigniew Jędrzejewski-Szmek2019-03-061-1/+1
| | | | | We shouldn't really make any fuss about this. Also, change 'var' to 'variable' for consistency with systemctl.c.
* efivars: extend character set that may be used in boot loader entry ids a bitLennart Poettering2019-03-051-1/+1
| | | | See https://github.com/systemd/systemd/pull/10495#discussion_r233992570
* efivars: remove direct access to unaligned structure membersZbigniew Jędrzejewski-Szmek2019-02-051-43/+47
| | | | | | | | | | | | Most of the accesses *were* aligned. The only one that definetely wasn't was to drive_path->part_start and drive_path->part_size, because those both expect 8 byte alignment, and are at offsets 4 and 12 in the packed structure. Because of the way that device_path structure is defined and used, we expect that device_path.length is always two-byte aligned. This adds asserts in various places to ensure the proper alignment, and uses memcpy in other places where the alignment might be off.
* efivars: make sure that _packed_ structure members are actually aligned as ↵Zbigniew Jędrzejewski-Szmek2019-02-051-14/+28
| | | | | | | | | | | | | expected When looking for the terminating double-NUL, don't just read the memory until the terminator is found, but use the information we got about the buffer size. The length parameter passed to utf16_to_utf8() would include the terminator, so the converted string would end up with two terminators (the original one converted to "utf8", still 0, and then the one that was always added anyway). Instead let's pass just the length of the actual data to utf16_to_utf8().
* tree-wide: use c99 static for array size declarationsZbigniew Jędrzejewski-Szmek2019-01-041-1/+1
| | | | | | | | | | | | | | | | https://hamberg.no/erlend/posts/2013-02-18-static-array-indices.html This only works with clang, unfortunately gcc doesn't seem to implement the check (tested with gcc-8.2.1-5.fc29.x86_64). Simulated error: [2/3] Compiling C object 'systemd-nspawn@exe/src_nspawn_nspawn.c.o'. ../src/nspawn/nspawn.c:3179:45: warning: array argument is too small; contains 15 elements, callee requires at least 16 [-Warray-bounds] candidate = (uid_t) siphash24(arg_machine, strlen(arg_machine), hash_key); ^ ~~~~~~~~ ../src/basic/siphash24.h:24:64: note: callee declares array parameter as static here uint64_t siphash24(const void *in, size_t inlen, const uint8_t k[static 16]); ^~~~~~~~~~~~
* coccinelle: make use of SYNTHETIC_ERRNOZbigniew Jędrzejewski-Szmek2018-11-221-4/+3
| | | | | | | | | | | Ideally, coccinelle would strip unnecessary braces too. But I do not see any option in coccinelle for this, so instead, I edited the patch text using search&replace to remove the braces. Unfortunately this is not fully automatic, in particular it didn't deal well with if-else-if-else blocks and ifdefs, so there is an increased likelikehood be some bugs in such spots. I also removed part of the patch that coccinelle generated for udev, where we returns -1 for failure. This should be fixed independently.
* fix build with -Defi=falseasavah2018-11-161-12/+12
|
* efivars: let's add some validation of boot menu entry name syntaxLennart Poettering2018-11-161-4/+17
|
* efivars: add new helper efi_set_variable_string()Lennart Poettering2018-11-161-13/+23
| | | | Let's make it easier to parse an UTF-16 string properly.
* bootctl: display loader features in a pretty way.Lennart Poettering2018-11-161-0/+50
|
* efivars: add missing OOM checkLennart Poettering2018-10-131-0/+3
| | | | CID #1395833
* efivars: check path_len before using it as loop boundaryDavid Tardon2018-10-121-2/+6
|
* bootctl: include boot entries discovered by the boot loader but not in $BOOT ↵Lennart Poettering2018-10-081-0/+51
| | | | | | | in the "list" output Let's use the new LoaderEntries efi var for this, and show all entries we couldn't find via the config snippets.
* efivars: newer efivarfs sets FS_IMMUTABLE_FL by default, deal with thatLennart Poettering2018-10-081-7/+48
| | | | | | | | | On EFI variables that aren't whitelisted in the kernel the FS_IMMUTABLE_FL is set, as protection against accidental removal/modification. Since our own variables do not appear in those whielists, and we are not changing these variables, let's unset the flag temporarily when needed. We restore the flag after all writes, just in case.
* efivars: some trivial coding style updatesLennart Poettering2018-10-081-16/+12
|
* efivars: check whether we are booted with EFI before reading/writing to ↵Lennart Poettering2018-10-081-8/+40
| | | | | | | | variables We do these checks only for the high-level calls as for the low-level ones it might make sense in some exotic uses to read the host EFI data from a container or so.
* efi: detect containers in is_efi_boot()Lennart Poettering2018-10-081-2/+5
| | | | | Let's make sure that we never assume we booted up in EFI mode if we are run in a container.
* tree-wide: use typesafe_qsort()Yu Watanabe2018-09-191-5/+3
|
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-04-051-10/+6
|
* macro: introduce TAKE_PTR() macroLennart Poettering2018-03-221-4/+2
| | | | | | | | | | | | | | | | This macro will read a pointer of any type, return it, and set the pointer to NULL. This is useful as an explicit concept of passing ownership of a memory area between pointers. This takes inspiration from Rust: https://doc.rust-lang.org/std/option/enum.Option.html#method.take and was suggested by Alan Jenkins (@sourcejedi). It drops ~160 lines of code from our codebase, which makes me like it. Also, I think it clarifies passing of ownership, and thus helps readability a bit (at least for the initiated who know the new macro)
* efivars: if OsIndicationsSupported does not exist, assume that ↵Lennart Poettering2017-11-241-0/+2
| | | | | | | | reboot-to-firmware is not available It's not advertised and hence not available. Fixes: #7424
* efivars: minor coding style improvementsLennart Poettering2017-11-241-13/+14
|
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* build-sys: use #if Y instead of #ifdef Y everywhereZbigniew Jędrzejewski-Szmek2017-10-041-1/+1
| | | | | | | | | | | | | | | The advantage is that is the name is mispellt, cpp will warn us. $ git grep -Ee "conf.set\('(HAVE|ENABLE)_" -l|xargs sed -r -i "s/conf.set\('(HAVE|ENABLE)_/conf.set10('\1_/" $ git grep -Ee '#ifn?def (HAVE|ENABLE)' -l|xargs sed -r -i 's/#ifdef (HAVE|ENABLE)/#if \1/; s/#ifndef (HAVE|ENABLE)/#if ! \1/;' $ git grep -Ee 'if.*defined\(HAVE' -l|xargs sed -i -r 's/defined\((HAVE_[A-Z0-9_]*)\)/\1/g' $ git grep -Ee 'if.*defined\(ENABLE' -l|xargs sed -i -r 's/defined\((ENABLE_[A-Z0-9_]*)\)/\1/g' + manual changes to meson.build squash! build-sys: use #if Y instead of #ifdef Y everywhere v2: - fix incorrect setting of HAVE_LIBIDN2
* efivars: don't crash when somebody wants to remove an efi variableLennart Poettering2017-09-081-1/+1
| | | | | | | This corrects b3c908b4a230c5cca0dcdd7e94d02ec54a298abf by allowing a NULL value again for variable deletion. Fixes: #6753
* shared: assert the source for memcpyThomas Hindoe Paaboel Andersen2017-04-281-0/+1
|
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* shared: include what we useThomas Hindoe Paaboel Andersen2015-12-061-0/+10
| | | | | The next step of a general cleanup of our includes. This one mostly adds missing includes but there are a few removals as well.
* tree-wide: sort includesThomas Hindoe Paaboel Andersen2015-11-161-2/+2
| | | | Sort the includes accoding to the new coding style.
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split out printf() helpers to stdio-util.hLennart Poettering2015-10-271-0/+1
|
* util-lib: introduce dirent-util.[ch] for directory entry callsLennart Poettering2015-10-271-0/+1
| | | | Also, move a couple of more path-related functions to path-util.c.
* util-lib: split string parsing related calls from util.[ch] into parse-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split out IO related calls to io-util.[ch]Lennart Poettering2015-10-261-0/+1
|
* util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering2015-10-251-2/+3
| | | | | There are more than enough to deserve their own .c file, hence move them over.
* basic: rework virtualization detection APILennart Poettering2015-09-071-1/+1
| | | | | | Introduce a proper enum, and don't pass around string ids anymore. This simplifies things quite a bit, and makes virtualization detection more similar to architecture detection.
* logind: some firmware implementations remove OsIndications if it is unsetLennart Poettering2015-07-111-1/+13
| | | | | | We shouldn't fall over that, and just assume it is 0 in this case. Fixes #499.
* tree-wide: remove spurious spaceThomas Hindoe Paaboel Andersen2015-06-081-1/+1
|
* shared: efivars - fix compile on non-EFI systemsTom Gundersen2015-04-101-10/+10
| | | | | systemctl and logind were unconditionally using functions that were not compiled on non-EFI systems. Add stubs returning -EOPNOTSUPP to fix compile again.