int
set_loop(const char *device, const char *file, unsigned long long offset,
- const char *encryption, int pfd, int *options, int keysz, int hash_pass) {
- unsigned long long sizelimit, const char *encryption, int pfd, int *options) {
++ unsigned long long sizelimit, const char *encryption, int pfd, int *options,
++ int keysz, int hash_pass) {
struct loop_info64 loopinfo64;
int fd, ffd, mode, i;
char *pass;
}
int
- set_loop (const char *device, const char *file, unsigned long long offset,
- const char *encryption, int pfd, int *options, int keysz, int hash_pass) {
+ set_loop(const char *device, const char *file, unsigned long long offset,
- unsigned long long sizelimit, const char *encryption, int pfd, int *loopro,
- int keysz, int hash_pass) {
++ unsigned long long sizelimit, const char *encryption, int pfd, int *options,
++ int keysz, int hash_pass) {
mutter();
return 1;
}
" -e | --encryption <type> enable data encryption with specified <name/num>\n"
" -h | --help this help\n"
" -o | --offset <num> start at offset <num> into file\n"
+ " --sizelimit <num> loop limited to only <num> bytes of the file\n"
" -p | --pass-fd <num> read passphrase from file descriptor <num>\n"
" -r | --read-only setup read-only loop device\n"
- " -s | --show print device name (with -f <file>)\n"
+ " --show print device name (with -f <file>)\n"
+ " -N | --nohashpass Do not hash the given password (Debian hashes)\n"
+ " -k | --keybits <num> specify number of bits in the hashed key given\n"
+ " to the cipher. Some ciphers support several key\n"
+ " sizes and might be more efficient with a smaller\n"
+ " key size. Key sizes < 128 are generally not\n"
+ " recommended\n"
- " -v | --verbose verbose mode\n\n"),
- progname);
+ " -v | --verbose verbose mode\n\n"));
exit(1);
}
int
main(int argc, char **argv) {
- char *p, *offset, *encryption, *passfd, *device, *file, *assoc;
+ char *p, *offset, *sizelimit, *encryption, *passfd, *device, *file, *assoc;
+ char *keysize;
int delete, find, c, all;
int res = 0;
int showdev = 0;
int ro = 0;
int pfd = -1;
- unsigned long long off;
+ int keysz = 0;
+ int hash_pass = 1;
+ unsigned long long off, slimit;
struct option longopts[] = {
{ "all", 0, 0, 'a' },
{ "detach", 0, 0, 'd' },
{ "encryption", 1, 0, 'e' },
{ "find", 0, 0, 'f' },
{ "help", 0, 0, 'h' },
+ { "keybits", 1, 0, 'k' },
+ { "nopasshash", 0, 0, 'N' },
+ { "nohashpass", 0, 0, 'N' },
{ "associated", 1, 0, 'j' },
{ "offset", 1, 0, 'o' },
+ { "sizelimit", 1, 0, 128 },
{ "pass-fd", 1, 0, 'p' },
{ "read-only", 0, 0, 'r' },
{ "show", 0, 0, 's' },
delete = find = all = 0;
off = 0;
- offset = encryption = passfd = NULL;
+ slimit = 0;
- assoc = offset = sizelimit = encryption = passfd = NULL;
+ assoc = offset = encryption = passfd = NULL;
+ keysize = NULL;
progname = argv[0];
if ((p = strrchr(progname, '/')) != NULL)
else {
if (passfd && sscanf(passfd, "%d", &pfd) != 1)
usage();
+ if (keysize && sscanf(keysize,"%d",&keysz) != 1)
+ usage();
do {
- res = set_loop(device, file, off, encryption, pfd, &ro, keysz, hash_pass);
- res = set_loop(device, file, off, slimit, encryption, pfd, &ro);
++ res = set_loop(device, file, off, slimit, encryption, pfd, &ro, keysz, hash_pass);
if (res == 2 && find) {
if (verbose)
printf("stolen loop=%s...trying again\n",
static int opt_nofail = 0;
- static const char *opt_loopdev, *opt_vfstype, *opt_offset, *opt_encryption,
- *opt_speed, *opt_comment, *opt_uhelper;
+ static const char *opt_loopdev, *opt_vfstype, *opt_offset, *opt_sizelimit,
+ *opt_encryption, *opt_speed, *opt_comment, *opt_uhelper;
+static const char *opt_keybits, *opt_nohashpass;
static int mounted (const char *spec0, const char *node0);
static int check_special_mountprog(const char *spec, const char *node,
{ "loop=", 0, &opt_loopdev },
{ "vfs=", 1, &opt_vfstype },
{ "offset=", 0, &opt_offset },
+ { "sizelimit=", 0, &opt_sizelimit },
{ "encryption=", 0, &opt_encryption },
+ { "keybits=", 0, &opt_keybits },
+ { "nohashpass", 0, &opt_nohashpass },
{ "speed=", 0, &opt_speed },
{ "comment=", 1, &opt_comment },
{ "uhelper=", 0, &opt_uhelper },
*type = opt_vfstype;
}
- *loop = ((*flags & MS_LOOP) || *loopdev || opt_offset || opt_encryption || opt_keybits);
- *loop = ((*flags & MS_LOOP) || *loopdev || opt_offset || opt_sizelimit || opt_encryption);
++ *loop = ((*flags & MS_LOOP) || *loopdev || opt_offset || opt_sizelimit || opt_encryption || opt_keybits);
*loopfile = *spec;
if (*loop) {
return EX_SYSERR; /* no more loop devices */
if (verbose)
printf(_("mount: going to use the loop device %s\n"), *loopdev);
-
+ if (!keysz && opt_keybits)
+ keysz = strtoul(opt_keybits, NULL, 0);
+ if (opt_nohashpass)
+ hash_pass=0;
- if ((res = set_loop(*loopdev, *loopfile, offset,
+ if ((res = set_loop(*loopdev, *loopfile, offset, sizelimit,
- opt_encryption, pfd, &loop_opts))) {
+ opt_encryption, pfd, &loop_opts, keysz, hash_pass))) {
if (res == 2) {
/* loop dev has been grabbed by some other process,
try again, if not given explicitly */