From: LaMont Jones Date: Thu, 21 Feb 2008 14:19:30 +0000 (-0700) Subject: Merge commit 'origin/master' X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02c7bd26732561d018a1684a2053556a1206411c;p=util-linux Merge commit 'origin/master' Conflicts: mount/lomount.c mount/losetup.8 mount/mount.c --- 02c7bd26732561d018a1684a2053556a1206411c diff --cc mount/lomount.c index 3d9808eb,ac379c0d..04b0f279 --- a/mount/lomount.c +++ b/mount/lomount.c @@@ -371,7 -609,7 +610,7 @@@ digits_only(const char *s) int set_loop(const char *device, const char *file, unsigned long long offset, - const char *encryption, int pfd, int *loopro, int keysz, int hash_pass) { - const char *encryption, int pfd, int *options) { ++ const char *encryption, int pfd, int *options, int keysz, int hash_pass) { struct loop_info64 loopinfo64; int fd, ffd, mode, i; char *pass; @@@ -603,7 -796,7 +864,7 @@@ mutter(void) int set_loop (const char *device, const char *file, unsigned long long offset, -- const char *encryption, int *loopro) { ++ const char *encryption, int pfd, int *options, int keysz, int hash_pass) { mutter(); return 1; } @@@ -657,8 -845,7 +919,8 @@@ usage(void) int main(int argc, char **argv) { - char *p, *offset, *encryption, *passfd, *device, *file; + char *p, *offset, *encryption, *passfd, *device, *file, *assoc; + char *keysize; int delete, find, c, all; int res = 0; int showdev = 0; @@@ -673,9 -858,7 +935,10 @@@ { "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' }, { "pass-fd", 1, 0, 'p' }, { "read-only", 0, 0, 'r' }, @@@ -690,14 -873,13 +953,15 @@@ delete = find = all = 0; off = 0; + offset = encryption = passfd = NULL; + assoc = offset = encryption = passfd = NULL; + keysize = NULL; progname = argv[0]; if ((p = strrchr(progname, '/')) != NULL) progname = p+1; - while ((c = getopt_long(argc, argv, "ade:E:fhk:No:p:rsv", - while ((c = getopt_long(argc, argv, "ade:E:fhj:o:p:rsv", ++ while ((c = getopt_long(argc, argv, "ade:E:fhj:k:No:p:rsv", longopts, NULL)) != -1) { switch (c) { case 'a': @@@ -716,11 -898,8 +980,13 @@@ case 'f': find = 1; break; + case 'j': + assoc = optarg; + case 'k': + keysize = optarg; + break; + case 'N': + hash_pass = 0; break; case 'o': offset = optarg; @@@ -781,14 -969,10 +1056,12 @@@ else if (file == NULL) res = show_loop(device); else { - if (offset && sscanf(offset, "%llu", &off) != 1) - usage(); 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); + res = set_loop(device, file, off, encryption, pfd, &ro, keysz, hash_pass); if (res == 2 && find) { if (verbose) printf("stolen loop=%s...trying again\n", diff --cc mount/losetup.8 index f72d7ad9,400ec2ca..c90360c2 --- a/mount/losetup.8 +++ b/mount/losetup.8 @@@ -73,19 -75,17 +75,22 @@@ enable data encryption with specified n .IP "\fB\-f, \-\-find\fP" find the first unused loop device. If a .I file - argument is present, use this device. Otherwise, print its name. + argument is present, use this device. Otherwise, print its name .IP "\fB\-h, \-\-help\fP" print help + .IP "\fB\-j, \-\-associated \fIfile\fP" + show status of all loop devices associated with given + .I file +.IP "\fB\-k, \-\-keybits \fInum\fP" +set the number of bits to use in key to \fInum\fP. +.IP "\fB\-N, \-\-nohashpass\fP" +Do not hash the password. By default, Debian systems run the password through a +hash function, non-Debian systems tend not to. .IP "\fB\-o, \-\-offset \fIoffset\fP" - The data start is moved \fIoffset\fP bytes into the specified file or - device. + the data start is moved \fIoffset\fP bytes into the specified file or + device .IP "\fB\-p, \-\-pass-fd \fInum\fP" - Read the passphrase from file descriptor with number + read the passphrase from file descriptor with number .I num instead of from the terminal .IP "\fB\-r, \-\-read-only\fP" diff --cc mount/mount.c index 0f014f19,ccdcba53..707729ab --- a/mount/mount.c +++ b/mount/mount.c @@@ -939,12 -932,9 +944,12 @@@ loop_check(const char **spec, const cha 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, - opt_encryption, pfd, &loopro, keysz, hash_pass))) { - 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 */ @@@ -2037,15 -2034,6 +2054,9 @@@ main(int argc, char *argv[]) die (EX_USAGE, _("mount: only root can do that")); } - if (!nomtab && mtab_does_not_exist()) { - if (verbose > 1) - printf(_("mount: no %s found - creating it..\n"), - _PATH_MOUNTED); - create_mtab (); - } - + if (keysize && sscanf(keysize,"%d",&keysz) != 1) + die (EX_USAGE, _("mount: argument to --keybits or -k must be a number")); ++ atexit(unlock_mtab); switch (argc+specseen) {