[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] fix keysize/keybits handling of mount
Hi Astor!
The -k resp. parameter to mount was not working (the 'k' was missing
from the list of option characters in getopt). I removed that switch. It
should really be something you can stuff into /etc/fstab and therefore
it needs to be an option to be supplied via '-o'. So now there is a
keysize= option you can put into the options column of fstab(5) or
specify on the command line via '-o'. Additionally, it error()'s if
someone gives the keysize option w/o giving the encryption option, too.
Please check that if clause carfully. I don't know what I was doing
there...
This patch is completely untested, I did not even check if it compiles,
but I modelled this option along the offset option, so there should be
no big mistakes.
It's relative to a util-linux2.10r, patched with the util-linux patch
from 2.2.18.4pre1.
Please consider applying (after testing :-).
Marc
--
Marc Mutz <Marc@Mutz.com> http://EncryptionHOWTO.sourceforge.net/
University of Bielefeld, Dep. of Mathematics / Dep. of Physics
PGP-keyID's: 0xd46ce9ab (RSA), 0x7ae55b9e (DSS/DH)
--- util-linux-2.10r/mount/mount.c.orig Mon Jan 15 18:59:53 2001
+++ util-linux-2.10r/mount/mount.c Wed Jan 31 19:19:00 2001
@@ -113,9 +113,6 @@
/* Contains the fd no. to read the passphrase from, if any */
static int pfd = -1;
-/* Contains the preferred keysize in bits we want to use */
-static int keysz = 0;
-
/* Map from -o and fstab option strings to the flag argument to mount(2). */
struct opt_map {
const char *opt; /* option name */
@@ -192,7 +189,7 @@
};
static char *opt_loopdev, *opt_vfstype, *opt_offset, *opt_encryption,
- *opt_speed;
+ *opt_keysize, *opt_speed;
static struct string_opt_map {
char *tag;
@@ -203,6 +200,7 @@
{ "vfs=", 1, &opt_vfstype },
{ "offset=", 0, &opt_offset },
{ "encryption=", 0, &opt_encryption },
+ { "keysize=", 0, &opt_keysize },
{ "speed=", 0, &opt_speed },
{ NULL, 0, NULL }
};
@@ -536,7 +534,7 @@
static int
loop_check(char **spec, char **type, int *flags,
int *loop, char **loopdev, char **loopfile) {
- int looptype, offset;
+ int looptype, offset, keysize;
/*
* In the case of a loop mount, either type is of the form lo@/dev/loop5
@@ -561,6 +559,9 @@
*type = opt_vfstype;
}
+ if (*opt_keysize && !*opt_encryption)
+ error(_("mount: you cannot specify a keysize without specifying encryption"));
+
*loop = ((*flags & MS_LOOP) || *loopdev || opt_offset || opt_encryption);
*loopfile = *spec;
@@ -579,8 +580,9 @@
if (verbose)
printf(_("mount: going to use the loop device %s\n"), *loopdev);
offset = opt_offset ? strtoul(opt_offset, NULL, 0) : 0;
+ keysize = opt_keysize ? strtoul(opt_keysize, NULL, 0) : 0;
if (set_loop (*loopdev, *loopfile, offset, opt_encryption, pfd,
- keysz, &loopro)) {
+ keysize, &loopro)) {
if (verbose)
printf(_("mount: failed setting up loop device\n"));
return EX_FAIL;
@@ -1294,7 +1296,6 @@
{ "rw", 0, 0, 'w' },
{ "options", 1, 0, 'o' },
{ "pass-fd", 1, 0, 'p' },
- { "keybits", 1, 0, 'k' },
{ "types", 1, 0, 't' },
{ "bind", 0, 0, 128 },
{ "replace", 0, 0, 129 },
@@ -1341,7 +1342,6 @@
char *options = NULL, *spec, *node;
char *volumelabel = NULL;
char *passfd = NULL;
- char *keysize = NULL;
char *uuid = NULL;
string_list types = NULL;
struct mntentchn *mc;
@@ -1377,9 +1377,6 @@
case 'h': /* help */
usage (stdout, 0);
break;
- case 'k':
- keysize = optarg;
- break;
case 'l':
list_with_volumelabel = 1;
break;
@@ -1485,8 +1482,6 @@
if (passfd && sscanf(passfd,"%d",&pfd) != 1)
die (EX_USAGE, _("mount: argument to --pass-fd or -p must be a number"));
- if (keysize && sscanf(keysize,"%d",&keysz) != 1)
- die (EX_USAGE, _("mount: argument to --keybits or -k must be a number"));
switch (argc+specseen) {
case 0: