Commit graph

130 commits

Author SHA1 Message Date
Vladimir Serbinenko
608bec5112 Support lseek64.
Android doesn't have 64-bit off_t, so use off64_t instead.
2017-05-03 12:24:43 +02:00
Andrei Borzenkov
a2932fbe8a osdep/linux: handle autofs entries in /proc/self/mountinfo
These entries have placeholder for device name and so are useless for our
purpose. grub failed with something like

grub-install: error: failed to get canonical path of `systemd-1'.

When we see autofs entry, record it (to keep parent-child relationship) but
continue to look for real mount. If it is found, we process it as usual. If
only autofs entry exists, attempt to trigger mount by opening mount point
and retry. Mount point itself is then kept open to avoid timeout.

Recent systemd is by default using automount for /boot/efi so this should
become more popular problem on EFI systems.

Closes: 49942
2017-01-24 20:05:19 +03:00
Corey Hickey
5f311e86d2 fix detection of non-LUKS CRYPT
grub_util_get_dm_abstraction() does a string comparison of insufficient
length. When using a UUID such as "CRYPT-PLAIN-sda6_crypt", the function
returns GRUB_DEV_ABSTRACTION_LUKS.

This results in the error:
    ./grub-probe: error: disk `cryptouuid/sda6_crypt' not found.

This appears to be a copy/paste error introduced in:
a10e7a5a89

The bug was (apparently) latent until revealed by:
3bca85b418

Signed-off-by: Corey Hickey <bugfood-c@fatooh.org>
2016-11-05 15:28:50 +03:00
Mike Gilbert
7a5b301e3a build: Use AC_HEADER_MAJOR to find device macros
Depending on the OS/libc, device macros are defined in different
headers. This change ensures we include the right one.

sys/types.h - BSD
sys/mkdev.h - Sun
sys/sysmacros.h - glibc (Linux)

glibc currently pulls sys/sysmacros.h into sys/types.h, but this may
change in a future release.

https://sourceware.org/ml/libc-alpha/2015-11/msg00253.html
2016-04-24 08:12:42 +03:00
Andrei Borzenkov
3bca85b418 devmapper: check for valid device abstraction in get_grub_dev
This was lost when code was refactored. Patch restores previous behavior.

It is still not clear whether this is the right one. Due to the way we
detect DM abstraction, partitions on DM are skipped, we fall through to
generic detection which ends up in assuming parent device is BIOS disk.

It is useful to install GRUB on VM disk from the host. But it also means
that GRUB will mistakenly allow install on real system as well.

For now let's fix regression; future behavior needs to be discussed.

Closes: 45163
2015-12-26 21:45:22 +03:00
Andrei Borzenkov
a9399f2e1e windows: correct LBA in generated EFI HDD media paths
GRUB keeps partition offset and size in units of 512B sectors. Media paths
are defined in terms of LBA which are presumed to match HDD sector size.

This is probably cosmetic (EFI requires that partition is searched by GUID)
and still incorrect if GPT was created using different logical block size.
But current code is obviously wrong and new has better chances to be correct.
2015-12-19 11:32:49 +03:00
Andrei Borzenkov
6a46cbcc5c unix: do not close stdin in grub_passwd_get
This makes it impossible to read from stdin without controlling tty:

10:/mnt # echo -e passwd\\npasswd | setsid ./grub-mkpasswd-pbkdf2
Enter password:
Reenter password: ./grub-mkpasswd-pbkdf2: error: failure to read password.
10:/mnt
2015-11-18 22:23:58 +03:00
Andrei Borzenkov
dff8d0e3f5 unix/getroot: remove unused MAJOR definition
We use major() everywhere, these definitions just add to confusion.
2015-11-07 17:02:21 +03:00
Andrei Borzenkov
349a381df0 devmapper/getroot: use makedev instead of direct shift
Fixes device detection with large number of devices.

Reported by Tim Wallberg <twalberg@comcast.net>
2015-11-07 09:46:46 +03:00
Michael Chang
7a210304eb Fix missing byte order conversion in get_btrfs_fs_prefix function
Since btrfs on-disk format uses little-endian, the searched item types
(ROOT_REF, INODE_REF) need converting the byte order in order to
function properly on big-endian systems.
2015-06-26 09:55:56 +03:00
Andrei Borzenkov
5d0ee3d7a1 unix/getroot: memory leak
Found by Coverity scan.
CID: 96605
2015-06-19 18:38:25 +03:00
Andrei Borzenkov
10a6d2d915 unix/relpath: memory leak
Found by Coverity scan.
CID: 96606
2015-06-19 18:38:25 +03:00
Andrei Borzenkov
5082ea6184 remove extra newlines in grub_util_* strings
grub_util_{info,warn,error} already add trailing newlines, so remove
them from format strings. Also trailing full stops are already added.
2015-05-13 09:47:17 +03:00
Toomas Soome
677dcaa92b getroot: include sys/mkdev.h for makedev
Solaris (like) systems need to include sys/mkdev.h for makedev() function.
2015-04-13 19:52:28 +03:00
Steve McIntyre
1a33de8b56 Recognize EFI platform even in case of mismatch between Linux and EFI.
Some x86 systems might be capable of running a 64-bit Linux kernel but
only use a 32-bit EFI (e.g. Intel Bay Trail systems). It's useful for
grub-install to be able to recognise such systems, to set the default
x86 platform correctly.

To allow grub-install to know the size of the firmware rather than
just the size of the kernel, there is now an extra EFI sysfs file to
describe the underlying firmware. Read that if possible, otherwise
fall back to the kernel type as before.

Signed-off-by: Steve McIntyre <steve@einval.com>
2015-03-27 14:51:51 +01:00
Vladimir Serbinenko
27d1a67f8a Fix canonicalize_file_name clash.
canonicalize_file_name clashed with gnulib function. Additionally
it was declared in 2 places: emu/misc.h and util/misc.h. Added
grub_ prefix and removed second declaration.
2015-03-04 01:00:19 +01:00
Andrei Borzenkov
637fc62699 linux/ofpath: fix descriptor leak
Found by: Coverity scan
2015-01-27 20:29:00 +03:00
Andrei Borzenkov
7ba137f628 linux/hostdisk: use strncpy instead of strlcpy
strlcpy is not available on Linux as part of standard libraries.
It probably is not worth extra configure checks espicially as we
need to handle missing function anyway.
2015-01-27 20:00:23 +03:00
Vladimir Serbinenko
8f95eae423 linux/ofpath: Fix error handling.
Found by: Coverity Scan.
2015-01-27 16:49:49 +01:00
Vladimir Serbinenko
c2fc41990a linux/hostdisk: Limit strcpy size to buffer size.
Found by: Coverity scan.
2015-01-27 16:48:53 +01:00
Andrei Borzenkov
e61f4eba18 linux/getroot: fix memory leak.
Found by: Coverity scan.
2015-01-26 23:04:09 +03:00
Andrei Borzenkov
e2a21238da linux/ofpath: fix various memory leaks.
Found by: Coverity scan.
2015-01-26 23:04:00 +03:00
Andrei Borzenkov
6704abade6 linux/getroot: fix descriptor leak.
Found by: Coverity scan.
2015-01-26 23:02:55 +03:00
Vladimir Serbinenko
8102540939 unix/password: Fix file descriptor leak.
Found by: Coverity scan.
2015-01-26 09:53:03 +01:00
Vladimir Serbinenko
cba5a85a67 linux/getroot: Fix error handling.
Found by: Coverity scan.
2015-01-26 09:51:48 +01:00
Vladimir Serbinenko
5adc6d76d3 linux/blocklist: Fix memory leak.
Found by: Coverity scan.
2015-01-26 09:50:58 +01:00
Vladimir Serbinenko
c14dff3ca7 devmapper/getroot: Fix memory leak.
Found by: Coverity scan.
2015-01-26 09:50:27 +01:00
Felix Janda
3bac4caa2b Remove direct _llseek code and require long filesystem libc. 2015-01-22 19:54:36 +01:00
Vladimir Serbinenko
68581b009f unix/cputime.c: Cache sc_clk_tck and check it for sanity. 2015-01-21 17:42:15 +01:00
Vladimir Serbinenko
ac8bac2496 haiku/getroot.c (grub_util_find_partition_start_os): Avoid division by zero. 2015-01-21 17:42:15 +01:00
Vladimir Serbinenko
111ab3b9cc osdep/linux/blocklist.c (grub_install_get_blocklist): Check blocksize validity. 2015-01-21 17:42:12 +01:00
Michael Chang
0aece00c54 * grub-core/osdep/unix/config.c: Remove extraneous comma. 2014-09-21 17:49:13 +02:00
Vladimir Serbinenko
9706066791 * grub-core/osdep/linux/getroot.c (grub_util_part_to_disk): Support NVMe device names. 2014-04-03 21:31:12 +02:00
Mike Gilbert
35f2d96c0d grub-install: support for partitioned partx loop devices.
* grub-core/osdep/linux/getroot.c (grub_util_part_to_disk): Detect
	/dev/loopX as being the parent of /dev/loopXpY.
2014-01-26 02:56:04 +01:00
Colin Watson
049f63824c Ignore EPERM when modifying kern.geom.debugflags
Many tests fail when run as a non-root user on FreeBSD.  The failures
all amount to an inability to open files using grub_util_fd_open,
because we cannot set the kern.geom.debugflags sysctl.  This sysctl is
indeed important to allow us to do such things as installing GRUB to the
MBR, but if we need to do that and can't then we will get an error
later.  Enforcing it here is unnecessary and prevents otherwise
perfectly reasonable operations.
2014-01-19 14:38:07 +00:00
Colin Watson
09a836e59c freebsd/hostdisk.c is only ever compiled on FreeBSD
* grub-core/osdep/freebsd/hostdisk.c (grub_util_fd_open): Remove
redundant preprocessor conditional.
2014-01-17 02:30:52 +00:00
Andrey Borzenkov
a6e7719bbe fix EFI detection on Windows
We are on legacy BIOS if GetFirmwareEnvironmentVariable fails (returns
zero) *and* extended error information is ERROR_INVALID_FUNCTION.

Cf. http://msdn.microsoft.com/en-us/library/windows/desktop/ms724325%28v=vs.85%29.aspx
2013-12-25 22:36:28 +04:00
Vladimir Serbinenko
e5fa26e573 Make newly-created files other than grub.cfg world-readable. 2013-12-24 17:36:10 +01:00
Vladimir Serbinenko
f7c7c4d4ad Make grub_util_device_is_mapped_stat available in grub-emu core. 2013-12-24 16:56:14 +01:00
Vladimir Serbinenko
e88f0420b9 Make grub_util_devmapper_part_to_disk and grub_util_find_partition_start
follow the same algorithm to avoid method mismatch. Don't assume
	DMRAID- UUID to mean full disk but instead check that mapping is linear.
2013-12-24 14:16:57 +01:00
Vladimir Serbinenko
0b602bf9ad * grub-core/osdep/unix/getroot.c: Non-unix build fix. 2013-12-21 18:10:05 +01:00
Vladimir Serbinenko
ae558c2ccf Enable -Wformat=2 if it's supported. 2013-12-21 15:28:28 +01:00
Vladimir Serbinenko
579ee114b1 Add missing static qualifiers. 2013-12-21 13:50:13 +01:00
Vladimir Serbinenko
5dbde526a8 Inline printf templates when possible to enable format checking. 2013-12-21 13:40:18 +01:00
David Prévot
496a6b3024 Correct some translatable strings. 2013-12-21 03:03:31 +01:00
Vladimir Serbinenko
bfdfeb2508 Clarify several translatable messages. 2013-12-21 01:41:16 +01:00
Colin Watson
3bc1b2daab Fix various build problems on GNU/Hurd.
* grub-core/osdep/unix/getroot.c (strip_extra_slashes): Move inside
!defined (__GNU__).
(xgetcwd): Likewise.
* include/grub/emu/hostdisk.h (grub_util_hurd_get_disk_info)
[__GNU__]: Add prototype.
* util/getroot.c (grub_util_biosdisk_get_grub_dev) [__GNU__]: Format
long int using %ld rather than %d.
2013-12-20 14:02:27 +00:00
Vladimir Serbinenko
7a7f52388b Make grub_util_get_windows_path_real static. 2013-12-18 07:45:15 +01:00
Vladimir Serbinenko
57a691b7e7 Decrease number of strings to translate. 2013-12-18 07:26:13 +01:00
Vladimir Serbinenko
636977b089 Mark strings for translation and add remaining ones to exclude list. 2013-12-18 06:50:24 +01:00