don't abort with error if realpath fails
PATCH 1/1 don't abort with error if realpath fails
Please consider (mostly useful to support device.map generated by GRUB legacy):
2006-09-17 Robert Millan <[email protected]>
* util/i386/pc/biosdisk.c (read_device_map): Don't abort with error if realpath fails (e.g. to cope with missing /dev/fd0 when we're aren't writing to floppy).
Signature · 4 lines
Robert Millan My spam trap is [email protected]. Note: this address is only intended for spam harvesters. Writing to it will get you added to my black list.
2006-09-17 Robert Millan <[email protected]>
* util/i386/pc/biosdisk.c (read_device_map): Don't abort with error if realpath fails (e.g. to cope with missing /dev/fd0 when we're aren't writing to floppy).
Index: util/i386/pc/biosdisk.c
===================================================================
RCS file: /sources/grub/grub2/util/i386/pc/biosdisk.c,v retrieving revision 1.12
i386/pc/biosdisk.c +4 -1
@@ -556,7 +556,10 @@symbolic links. */ map[drive] =xmalloc (PATH_MAX );if (!realpath (p, map[drive])) -grub_util_error ("Cannot get the real path of `%s'" , p); + { + map[drive] ='\0' ; +grub_util_info ("Cannot get the real path of `%s'" , p); + }#else map[drive] =xstrdup (p);#endif
Quoted 8 lines · Robert Millan
Please consider (mostly useful to support device.map generated by GRUB legacy):
2006-09-17 Robert Millan <[email protected]>
*
util/i386/pc/biosdisk.c(read_device_map): Don't abort with error if realpath fails (e.g. to cope with missing/dev/fd0when we're aren't writing to floppy).
Can you elaborate on the purpose? Personally I prefer a strict check for this part, since the installation of GRUB is potentially very dangerous!
Okuji
Quoted 4 lines · Yoshinori K. Okuji
Quoted 3 lines · Robert Millan
Please consider (mostly useful to support device.map generated by GRUB legacy):
Quoted 8 lines
Quoted 5 lines
2006-09-17 Robert Millan <[email protected]>
*
util/i386/pc/biosdisk.c(read_device_map): Don't abort with error if realpath fails (e.g. to cope with missing/dev/fd0when we're aren't writing to floppy).Can you elaborate on the purpose? Personally I prefer a strict check for this part, since the installation of GRUB is potentially very dangerous!
Sure. The purpose of realpath here isn't really to verify device existance; that ought to happen later if (and only if) we're actualy going to use that device.
Suppose this device.map:
(hd0) /dev/hda
(xxx) /dev/idontexist
Theoricaly, when grub-setup is told to act on (hd0) it shouldn't care that /dev/idontexist doesn't exist (it could be listed because it was generated by an older grub, because the device disappeared, etc). However, because of the realpath canonicalisation, as a collateral result we get to abort if _any_ of the entries are wrong:
#ifdef __linux__
/* On Linux, the devfs uses symbolic links horribly, and that
confuses the interface very much, so use realpath to expand
symbolic links. */
map[drive] = xmalloc (PATH_MAX);
if (! realpath (p, map[drive]))
grub_util_error ("Cannot get the real path of `%s'", p);
#else
map[drive] = xstrdup (p);#endif
My point is that grub should be fault tollerant and not care that /dev/idontexist is broken, specialy since device.map is a file that is subject for input from either user or older grub (including grub legacy), and we have little control about its contents.
Signature · 4 lines
Robert Millan My spam trap is [email protected]. Note: this address is only intended for spam harvesters. Writing to it will get you added to my black list.
Quoted 6 lines · Robert Millan
Sure. The purpose of realpath here isn't really to verify device existance; that ought to happen later if (and only if) we're actualy going to use that device.
Suppose this device.map:
Quoted 8 lines
(hd0)
/dev/hda
(xxx)/dev/idontexistTheoricaly, when grub-setup is told to act on (hd0) it shouldn't care that
/dev/idontexistdoesn't exist (it could be listed because it was generated by an older grub, because the device disappeared, etc). However, because of the realpath canonicalisation, as a collateral result we get to abort if _any_ of the entries are wrong:
I understand what you mean. Thank you.
Quoted 4 lines
My point is that grub should be fault tollerant and not care that
/dev/idontexistis broken, specialy since device.map is a file that is subject for input from either user or older grub (including grub legacy), and we have little control about its contents.
I describe my own opinion here. GRUB itself must be extremely fault-tolerant, as the user cannot boot up a machine if GRUB fails. However, the installer of GRUB must be extremely error-sensitive, as the user cannot boot up a machine if the installation happens _wrongly_. If a device map contains any error, it's likely that the user made some mistake or skip over erroneous information. Personally I much, much prefer that GRUB is not installed in this case. Failing in installing GRUB is better than making a machine unbootable.
Okuji
Quoted 23 lines · Yoshinori K. Okuji
Quoted 6 lines · Robert Millan
Sure. The purpose of realpath here isn't really to verify device existance; that ought to happen later if (and only if) we're actualy going to use that device.
Suppose this device.map:
Quoted 8 lines
(hd0)
/dev/hda
(xxx)/dev/idontexistTheoricaly, when grub-setup is told to act on (hd0) it shouldn't care that
/dev/idontexistdoesn't exist (it could be listed because it was generated by an older grub, because the device disappeared, etc). However, because of the realpath canonicalisation, as a collateral result we get to abort if _any_ of the entries are wrong:I understand what you mean. Thank you.
Quoted 4 lines
My point is that grub should be fault tollerant and not care that
/dev/idontexistis broken, specialy since device.map is a file that is subject for input from either user or older grub (including grub legacy), and we have little control about its contents.
Quoted 8 lines
I describe my own opinion here. GRUB itself must be extremely fault-tolerant, as the user cannot boot up a machine if GRUB fails. However, the installer of GRUB must be extremely error-sensitive, as the user cannot boot up a machine if the installation happens _wrongly_. If a device map contains any error, it's likely that the user made some mistake or skip over erroneous information. Personally I much, much prefer that GRUB is not installed in this case. Failing in installing GRUB is better than making a machine unbootable.
How could installation happen wrongly because of "(xxx) /dev/idontexist" ? If we're trying to write to (xxx), that will fail; otherwise, it doesn't interfere with what we're doing.
Signature · 4 lines
Robert Millan My spam trap is [email protected]. Note: this address is only intended for spam harvesters. Writing to it will get you added to my black list.
Quoted 33 lines · Robert Millan
Quoted 23 lines · Yoshinori K. Okuji
Quoted 6 lines · Robert Millan
Sure. The purpose of realpath here isn't really to verify device existance; that ought to happen later if (and only if) we're actualy going to use that device.
Suppose this device.map:
Quoted 8 lines
(hd0)
/dev/hda
(xxx)/dev/idontexistTheoricaly, when grub-setup is told to act on (hd0) it shouldn't care that
/dev/idontexistdoesn't exist (it could be listed because it was generated by an older grub, because the device disappeared, etc). However, because of the realpath canonicalisation, as a collateral result we get to abort if _any_ of the entries are wrong:I understand what you mean. Thank you.
Quoted 4 lines
My point is that grub should be fault tollerant and not care that
/dev/idontexistis broken, specialy since device.map is a file that is subject for input from either user or older grub (including grub legacy), and we have little control about its contents.Quoted 8 lines
I describe my own opinion here. GRUB itself must be extremely fault-tolerant, as the user cannot boot up a machine if GRUB fails. However, the installer of GRUB must be extremely error-sensitive, as the user cannot boot up a machine if the installation happens _wrongly_. If a device map contains any error, it's likely that the user made some mistake or skip over erroneous information. Personally I much, much prefer that GRUB is not installed in this case. Failing in installing GRUB is better than making a machine unbootable.
Quoted 3 lines
How could installation happen wrongly because of "(xxx)
/dev/idontexist" ? If we're trying to write to (xxx), that will fail; otherwise, it doesn't interfere with what we're doing.
(Besides, this code is only enabled on GNU/Linux. I think this shows that the intention when writing it wasn't error-sensitivity)
Signature · 4 lines
Robert Millan My spam trap is [email protected]. Note: this address is only intended for spam harvesters. Writing to it will get you added to my black list.
Quoted 2 lines · Robert Millan
(Besides, this code is only enabled on GNU/Linux. I think this shows that the intention when writing it wasn't error-sensitivity)
Wrong. The code was written only for GNU/Linux. That's it. I didn't bother myself with porting the installer.
Okuji
Quoted 36 lines · Robert Millan
Quoted 23 lines · Yoshinori K. Okuji
Quoted 6 lines · Robert Millan
Sure. The purpose of realpath here isn't really to verify device existance; that ought to happen later if (and only if) we're actualy going to use that device.
Suppose this device.map:
Quoted 8 lines
(hd0)
/dev/hda
(xxx)/dev/idontexistTheoricaly, when grub-setup is told to act on (hd0) it shouldn't care that
/dev/idontexistdoesn't exist (it could be listed because it was generated by an older grub, because the device disappeared, etc). However, because of the realpath canonicalisation, as a collateral result we get to abort if _any_ of the entries are wrong:I understand what you mean. Thank you.
Quoted 4 lines
My point is that grub should be fault tollerant and not care that
/dev/idontexistis broken, specialy since device.map is a file that is subject for input from either user or older grub (including grub legacy), and we have little control about its contents.Quoted 8 lines
I describe my own opinion here. GRUB itself must be extremely fault-tolerant, as the user cannot boot up a machine if GRUB fails. However, the installer of GRUB must be extremely error-sensitive, as the user cannot boot up a machine if the installation happens _wrongly_. If a device map contains any error, it's likely that the user made some mistake or skip over erroneous information. Personally I much, much prefer that GRUB is not installed in this case. Failing in installing GRUB is better than making a machine unbootable.
How could installation happen wrongly because of "(xxx)
/dev/idontexist" ? If we're trying to write to (xxx), that will fail; otherwise, it doesn't interfere with what we're doing.
Quoted 3 lines · I do not want to repeat the same sentense. I
Quoted 3 lines
If a
device map contains any error, it's likely that the user made some mistake or skip over erroneous information.
I do not like to accept a wrong device map, as it is obvious that the user is careless.
Okuji
Quoted 38 lines · Yoshinori K. Okuji
Quoted 33 lines · Robert Millan
Quoted 23 lines · Yoshinori K. Okuji
Quoted 6 lines · Robert Millan
Sure. The purpose of realpath here isn't really to verify device existance; that ought to happen later if (and only if) we're actualy going to use that device.
Suppose this device.map:
Quoted 8 lines
(hd0)
/dev/hda
(xxx)/dev/idontexistTheoricaly, when grub-setup is told to act on (hd0) it shouldn't care that
/dev/idontexistdoesn't exist (it could be listed because it was generated by an older grub, because the device disappeared, etc). However, because of the realpath canonicalisation, as a collateral result we get to abort if _any_ of the entries are wrong:I understand what you mean. Thank you.
Quoted 4 lines
My point is that grub should be fault tollerant and not care that
/dev/idontexistis broken, specialy since device.map is a file that is subject for input from either user or older grub (including grub legacy), and we have little control about its contents.Quoted 8 lines
I describe my own opinion here. GRUB itself must be extremely fault-tolerant, as the user cannot boot up a machine if GRUB fails. However, the installer of GRUB must be extremely error-sensitive, as the user cannot boot up a machine if the installation happens _wrongly_. If a device map contains any error, it's likely that the user made some mistake or skip over erroneous information. Personally I much, much prefer that GRUB is not installed in this case. Failing in installing GRUB is better than making a machine unbootable.
Quoted 3 lines
How could installation happen wrongly because of "(xxx)
/dev/idontexist" ? If we're trying to write to (xxx), that will fail; otherwise, it doesn't interfere with what we're doing.
Quoted 8 lines
Quoted 3 lines · I do not want to repeat the same sentense. I
Quoted 3 lines
If a
device map contains any error, it's likely that the user made some mistake or skip over erroneous information.I do not like to accept a wrong device map, as it is obvious that the user is careless.
Ok.
Signature · 4 lines
Robert Millan My spam trap is [email protected]. Note: this address is only intended for spam harvesters. Writing to it will get you added to my black list.