Commit graph

150 commits

Author SHA1 Message Date
Lennart Poettering 5fa6c13c7b bootctl: use F_TYPE_EQUAL() to compare statfs' .f_type field
After all, the field is kinda borked.
2016-07-21 11:37:58 +02:00
Lennart Poettering 846b8fc30d bootctl: move toupper() implementation to string-util.h
We already have tolower() calls there, hence let's unify this at one place.
Also, update the code to only use ASCII operations, so that we don't end up
being locale dependant.
2016-07-21 11:37:58 +02:00
Lennart Poettering 181ccb43ea bootctl: make use of STRV_FOREACH() where we can 2016-07-21 11:37:58 +02:00
Lennart Poettering 2f2c539cd4 bootctl: rework to use common verbs parsing, and add searching of ESP path
This rearranges bootctl a bit, so that it uses the usual verbs parsing
routines, and automatically searches the ESP in /boot, /efi or /boot/efi, thus
increasing compatibility with mainstream distros that insist on /boot/efi.

This also adds minimal support for running bootctl in a container environment:
when run inside a container verification of the ESP via raw block device
access, trusting the container manager to mount the ESP correctly. Moreover,
EFI variables are not accessed when running in the container.
2016-07-21 11:37:58 +02:00
Lennart Poettering c18532e031 bootctl: fix error message check 2016-07-21 11:10:35 +02:00
Lennart Poettering 25579a43ef bootctl: minor coding style improvements 2016-07-21 11:10:35 +02:00
Alexander Kurtz 00f69504a2 bootctl: Always use upper case for "/EFI/BOOT" and "/EFI/BOOT/BOOT*.EFI".
If the ESP is not mounted with "iocharset=ascii", but with "iocharset=utf8"
(which is for example the default in Debian), the file system becomes case
sensitive. This means that a file created as "FooBarBaz" cannot be accessed as
"foobarbaz" since those are then considered different files.

Moreover, a file created as "FooBar" can then also not be accessed as "foobar",
and it also prevents such a file from being created, as both would use the same
8.3 short name "FOOBAR".

Even though the UEFI specification [0] does give the canonical spelling for
the files mentioned above, not all implementations completely conform to that,
so it's possible that those files would already exist, but with a different
spelling, causing subtle bugs when scanning or modifying the ESP.

While the proper fix would of course be that everybody conformed to the
standard, we can work around this problem by just referencing the files by
their 8.3 short names, i.e. using upper case.

Fixes: #3740

[0] <http://www.uefi.org/specifications>, version 2.6, section 3.5.1.1
2016-07-21 03:02:15 +02:00
Alexander Kurtz b7536c45ef bootctl: Use lower case string constants in case-insensitive comparisons. 2016-07-21 02:20:12 +02:00
Michael Biebl 595bfe7df2 Various fixes for typos found by lintian (#3705) 2016-07-12 12:52:11 +02:00
Zbigniew Jędrzejewski-Szmek 323b7dc903 tree-wide: rename draw_special_char to special_glyph
That function doesn't draw anything on it's own, just returns a string, which
sometimes is more than one character. Also remove "DRAW_" prefix from character
names, TREE_* and ARROW and BLACK_CIRCLE are unambigous on their own, don't
draw anything, and are always used as an argument to special_glyph().

Rename "DASH" to "MDASH", as there's more than one type of dash.
2016-05-09 15:17:57 -04:00
Daniel Mack b26fa1a2fb tree-wide: remove Emacs lines from all files
This should be handled fine now by .dir-locals.el, so need to carry that
stuff in every file.
2016-02-10 13:41:57 +01:00
Michal Sekletar e41256dcec bootctl: replace readdir() loops with FOREACH_DIRENT 2016-01-31 09:44:53 +01:00
Daniel Mack bc9d55c865 bootctl: use DRAW_TREE_RIGHT rather than hard-coded UTF-8 character
Fixes #2384
2016-01-20 13:14:14 +01:00
Lennart Poettering b5efdb8af4 util-lib: split out allocation calls into alloc-util.[ch] 2015-10-27 13:45:53 +01:00
Lennart Poettering 8752c5752f util-lib: move more locale-related calls to locale-util.[ch] 2015-10-27 13:25:56 +01:00
Lennart Poettering 0d39fa9c69 util-lib: move more file I/O related calls into fileio.[ch] 2015-10-27 13:25:55 +01:00
Lennart Poettering 3ffd4af220 util-lib: split out fd-related operations into fd-util.[ch]
There are more than enough to deserve their own .c file, hence move them
over.
2015-10-25 13:19:18 +01:00
Lennart Poettering 07630cea1f util-lib: split our string related calls from util.[ch] into its own file string-util.[ch]
There are more than enough calls doing string manipulations to deserve
its own files, hence do something about it.

This patch also sorts the #include blocks of all files that needed to be
updated, according to the sorting suggestions from CODING_STYLE. Since
pretty much every file needs our string manipulation functions this
effectively means that most files have sorted #include blocks now.

Also touches a few unrelated include files.
2015-10-24 23:05:02 +02:00
Lennart Poettering 3f6fd1ba65 util: introduce common version() implementation and use it everywhere
This also allows us to drop build.h from a ton of files, hence do so.
Since we touched the #includes of those files, let's order them properly
according to CODING_STYLE.
2015-09-29 21:08:37 +02:00
Karel Zak a592ab6ae8 bootctl: fix path in log message 2015-08-06 13:59:38 +02:00
Lennart Poettering dacd6cee76 tree-wide: port everything over to fflush_and_check()
Some places invoked fflush() directly with their own manual error
checking, let's unify all that by using fflush_and_check().

This also unifies the general error paths of fflush()+rename() file
writers.
2015-07-29 20:31:07 +02:00
Kay Sievers c11ae0bace bootctl: add missing newline 2015-07-25 03:26:32 +02:00
David Herrmann ab822b624b sd-boot: ignore missing /etc/machine-id
If /etc/machine-id is missing (eg., gold images), we should not fail
installing sd-boot. This is a perfectly fine use-case and we should simply
skip installing the default loader config in that case.
2015-07-15 12:04:31 +02:00
Miguel Bernal Marin 68cc17f131 bootctl: fix sdboot to systemd-boot
sdboot was renamed to systemd-boot

Fixes: e7dd673d1e ("gummiboot/sd-boot/systemd-boot: rename galore")

Signed-off-by: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
2015-07-04 17:03:50 -05:00
Thomas Hindoe Paaboel Andersen dd114e116b bootctl: fix an error check 2015-05-23 13:03:30 +02:00
Thomas Hindoe Paaboel Andersen 717442507b bootctl: ferror must be called before FILE is closed
Otherwise it will not show any error stored
2015-05-22 23:46:36 +02:00
Zbigniew Jędrzejewski-Szmek 551710cf2e bootctl: try to catch all errors
Do not print garbage on non-EFI installations.
2015-05-19 23:41:38 -04:00
Zbigniew Jędrzejewski-Szmek d3226d7796 bootctl: modernization
Use strjoina to avoid error handling, and openat to simplify things.

Some fixes on the way:
- ferror does not set errno, so the return value was wrong in some cases
- errors are propagated in more cases
- EFI/systemd was created, but EFI/systemd-boot was deleted
- something is always printed on error
- when checking the version, comparison was done against "systemd-bo" for some reason
- return value was converted from negative to EXIT_SUCCESS/EXIT_FAILURE twice,
  resulting in EXIT_SUCCESS all the time
2015-05-19 23:41:38 -04:00
Ronny Chevalier 39505e3c3b remove duplicated includes 2015-04-08 02:42:50 +02:00
Lennart Poettering c687863750 util: rework rm_rf() logic
- Move to its own file rm-rf.c

- Change parameters into a single flags parameter

- Remove "honour sticky" logic, it's unused these days
2015-04-06 10:57:53 +02:00
David Herrmann e0d065d405 bootctl: drop redundant parse_argv()
We already call parse_argv() from main(), don't call it here again.
2015-03-19 14:11:54 +01:00
Zbigniew Jędrzejewski-Szmek 1a1db450e5 bootctl: avoid NULL pointer dereference 2015-02-27 17:31:43 -05:00
Thomas Hindoe Paaboel Andersen 3a4efbff2e bootctl: check that partition uuid is valid
It probably is but check anyway to make coverity happy.

CID#1271354
2015-02-25 23:32:50 +01:00
Thomas Hindoe Paaboel Andersen 7cb0f263ad bootctl: fix mem leaks
CID#1271347/1271348
2015-02-25 00:00:32 +01:00
Thomas Hindoe Paaboel Andersen 2eec67acbb remove unused includes
This patch removes includes that are not used. The removals were found with
include-what-you-use which checks if any of the symbols from a header is
in use.
2015-02-23 23:53:42 +01:00
Tom Gundersen e7dd673d1e gummiboot/sd-boot/systemd-boot: rename galore
What used to be gummiboot, was renamed sd-boot when it was merged into
systemd. Let's try to be a bit more consistent with the rest of systemd
and rename it again as follows:

The EFI bootloader is now called 'systemd-bootx64.efi', and its sources are in
'src/boot/efi/'. The drop-in directory where bootctl will find EFI loaders
is now /usr/lib/systemd/boot/efi/.
2015-02-18 15:23:23 +01:00
Kay Sievers 0974a682d1 bootctl: add sd-boot support 2015-02-17 14:36:59 +01:00
Zbigniew Jędrzejewski-Szmek 601185b43d Unify parse_argv style
getopt is usually good at printing out a nice error message when
commandline options are invalid. It distinguishes between an unknown
option and a known option with a missing arg. It is better to let it
do its job and not use opterr=0 unless we actually want to suppress
messages. So remove opterr=0 in the few places where it wasn't really
useful.

When an error in options is encountered, we should not print a lengthy
help() and overwhelm the user, when we know precisely what is wrong
with the commandline. In addition, since help() prints to stdout, it
should not be used except when requested with -h or --help.

Also, simplify things here and there.
2014-08-03 21:46:07 -04:00
Thomas Hindoe Paaboel Andersen b226deba78 bootctl: remove unused options from getopt_long 2013-11-09 14:11:56 +01:00
Lennart Poettering eb9da376d7 clients: unify how we invoke getopt_long()
Among other things this makes sure we always expose a --version command
and show it in the help texts.
2013-11-06 18:28:39 +01:00
Thomas Hindoe Paaboel Andersen 82de16f92c bootctl: typo fix in help message 2013-11-06 00:29:49 +01:00
Koen Kooi 8b3227c90d bootctl: fix help text
It currently says 'time settings', change that to 'boot settings'.
2013-03-29 15:47:43 +01:00
Kay Sievers 0014c5221e bootctl: ESP --> Partition 2013-03-28 11:42:32 +01:00
Kay Sievers 33696ef458 bootctl: Binary: --> File: 2013-03-28 03:43:29 +01:00
Kay Sievers 3483fab948 bootctl: rename status output header 2013-03-27 13:55:09 +01:00
Kay Sievers 0876dc1c26 bootctl: print Options only when found 2013-03-10 23:18:50 +01:00
Kay Sievers bc6f2e7c62 bootctl: print secure boot flags 2013-03-10 22:48:27 +01:00
Kay Sievers 71bf4f6f6c bootctl: show "n/a" for empty boot option labels 2013-02-17 22:28:21 +01:00
Kay Sievers abb381b3b3 bootctl: print partition uuids as /dev/disk/by-partuuid/... 2013-02-11 23:20:02 +01:00
Kay Sievers 7b4d7cc082 bootctl: add boot loader and firmware interface tool 2013-02-11 19:35:52 +01:00