--- mount/lomount.c.old 2003-10-04 01:13:13.021722872 +1000 +++ mount/lomount.c.old 2003-10-04 01:49:33.009314384 +1000 @@ -247,7 +247,7 @@ int set_loop(const char *device, const char *file, int offset, - const char *encryption, int pfd, int *loopro) { + const char *encryption, int pfd, int keysz, int *loopro) { struct loop_info64 loopinfo64; int fd, ffd, mode; char *pass; @@ -308,8 +308,12 @@ break; default: pass = xgetpass(pfd, _("Password: ")); - xstrncpy(loopinfo64.lo_encrypt_key, pass, LO_KEY_SIZE); - loopinfo64.lo_encrypt_key_size = LO_KEY_SIZE; + if (keysz) { + loopinfo64.lo_encrypt_key_size = keysz; + } else { + xstrncpy(loopinfo64.lo_encrypt_key, pass, LO_KEY_SIZE); + loopinfo64.lo_encrypt_key_size = LO_KEY_SIZE; + } } if (ioctl(fd, LOOP_SET_FD, ffd) < 0) { @@ -337,8 +341,8 @@ close (fd); if (verbose > 1) - printf(_("set_loop(%s,%s,%d): success\n"), - device, file, offset); + printf(_("set_loop(%s,%s,%d,%d): success\n"), + device, file, keysz, offset); return 0; fail: @@ -377,7 +381,7 @@ int set_loop (const char *device, const char *file, int offset, - const char *encryption, int *loopro) { + const char *encryption, int keysz, int *loopro) { mutter(); return 1; } @@ -411,7 +415,14 @@ fprintf(stderr, _("usage:\n\ %s loop_device # give info\n\ %s -d loop_device # delete\n\ - %s [ -e encryption ] [ -o offset ] loop_device file # setup\n"), + %s [ options ] loop_device file # setup\n\ + OPTIONS \n\ + -e \n\ + encryption, encrypt with \n\ + -k \n\ + specify the number of bits in the key give to\n\ + the cipher. Key sizes < 128 are generally not\n\ + recommended\n"), progname, progname, progname); exit(1); } @@ -445,11 +457,12 @@ int main(int argc, char **argv) { - char *offset, *encryption, *passfd; + char *offset, *encryption, *passfd, *keysize = 0; int delete, off, c; int res = 0; int ro = 0; int pfd = -1; + int keysz = 0; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); @@ -458,7 +471,7 @@ delete = off = 0; offset = encryption = passfd = NULL; progname = argv[0]; - while ((c = getopt(argc,argv,"de:E:o:p:v")) != -1) { + while ((c = getopt(argc,argv,"de:E:k:o:p:v")) != -1) { switch (c) { case 'd': delete = 1; @@ -467,6 +480,9 @@ case 'e': encryption = optarg; break; + case 'k': + keysize = optarg; + break; case 'o': offset = optarg; break; @@ -494,8 +510,10 @@ usage(); if (passfd && sscanf(passfd,"%d",&pfd) != 1) usage(); + if (keysize && sscanf(keysize,"%d",&keysz) != 1) + usage(); res = set_loop(argv[optind], argv[optind+1], off, - encryption, pfd, &ro); + encryption, pfd, keysz, &ro); } return res; } --- mount/lomount.h.old 2003-10-04 01:50:08.571908048 +1000 +++ mount/lomount.h.old 2003-10-04 01:50:14.472011096 +1000 @@ -1,6 +1,6 @@ extern int verbose; extern int set_loop(const char *, const char *, int, const char *, - int, int *); + int, int, int *); extern int del_loop(const char *); extern int is_loop_device(const char *); extern char * find_unused_loop_device(void); --- mount/mount.c.old 2003-10-04 01:53:16.372358040 +1000 +++ mount/mount.c.old 2003-10-04 02:06:03.877679496 +1000 @@ -195,7 +195,7 @@ }; static char *opt_loopdev, *opt_vfstype, *opt_offset, *opt_encryption, - *opt_speed; + *opt_speed, *opt_keybits; static struct string_opt_map { char *tag; @@ -207,6 +207,7 @@ { "offset=", 0, &opt_offset }, { "encryption=", 0, &opt_encryption }, { "speed=", 0, &opt_speed }, + { "keybits=", 0, &opt_keybits }, { NULL, 0, NULL } }; @@ -561,7 +562,7 @@ static int loop_check(char **spec, char **type, int *flags, int *loop, char **loopdev, char **loopfile) { - int looptype, offset; + int looptype, offset, keybits; /* * In the case of a loop mount, either type is of the form lo@/dev/loop5 @@ -604,8 +605,9 @@ if (verbose) printf(_("mount: going to use the loop device %s\n"), *loopdev); offset = opt_offset ? strtoul(opt_offset, NULL, 0) : 0; + keybits = opt_keybits ? strtoul(opt_keybits, NULL, 0) : 0; if (set_loop(*loopdev, *loopfile, offset, - opt_encryption, pfd, &loopro)) { + opt_encryption, pfd, keybits, &loopro)) { if (verbose) printf(_("mount: failed setting up loop device\n")); return EX_FAIL;