Lines 247-253
Link Here
|
247 |
|
247 |
|
248 |
int |
248 |
int |
249 |
set_loop(const char *device, const char *file, int offset, |
249 |
set_loop(const char *device, const char *file, int offset, |
250 |
const char *encryption, int pfd, int *loopro) { |
250 |
const char *encryption, int pfd, int keysz, int *loopro) { |
251 |
struct loop_info64 loopinfo64; |
251 |
struct loop_info64 loopinfo64; |
252 |
int fd, ffd, mode; |
252 |
int fd, ffd, mode; |
253 |
char *pass; |
253 |
char *pass; |
Lines 308-315
Link Here
|
308 |
break; |
308 |
break; |
309 |
default: |
309 |
default: |
310 |
pass = xgetpass(pfd, _("Password: ")); |
310 |
pass = xgetpass(pfd, _("Password: ")); |
311 |
xstrncpy(loopinfo64.lo_encrypt_key, pass, LO_KEY_SIZE); |
311 |
if (keysz) { |
312 |
loopinfo64.lo_encrypt_key_size = LO_KEY_SIZE; |
312 |
loopinfo64.lo_encrypt_key_size = keysz; |
|
|
313 |
} else { |
314 |
xstrncpy(loopinfo64.lo_encrypt_key, pass, LO_KEY_SIZE); |
315 |
loopinfo64.lo_encrypt_key_size = LO_KEY_SIZE; |
316 |
} |
313 |
} |
317 |
} |
314 |
|
318 |
|
315 |
if (ioctl(fd, LOOP_SET_FD, ffd) < 0) { |
319 |
if (ioctl(fd, LOOP_SET_FD, ffd) < 0) { |
Lines 337-344
Link Here
|
337 |
|
341 |
|
338 |
close (fd); |
342 |
close (fd); |
339 |
if (verbose > 1) |
343 |
if (verbose > 1) |
340 |
printf(_("set_loop(%s,%s,%d): success\n"), |
344 |
printf(_("set_loop(%s,%s,%d,%d): success\n"), |
341 |
device, file, offset); |
345 |
device, file, keysz, offset); |
342 |
return 0; |
346 |
return 0; |
343 |
|
347 |
|
344 |
fail: |
348 |
fail: |
Lines 377-383
Link Here
|
377 |
|
381 |
|
378 |
int |
382 |
int |
379 |
set_loop (const char *device, const char *file, int offset, |
383 |
set_loop (const char *device, const char *file, int offset, |
380 |
const char *encryption, int *loopro) { |
384 |
const char *encryption, int keysz, int *loopro) { |
381 |
mutter(); |
385 |
mutter(); |
382 |
return 1; |
386 |
return 1; |
383 |
} |
387 |
} |
Lines 411-417
Link Here
|
411 |
fprintf(stderr, _("usage:\n\ |
415 |
fprintf(stderr, _("usage:\n\ |
412 |
%s loop_device # give info\n\ |
416 |
%s loop_device # give info\n\ |
413 |
%s -d loop_device # delete\n\ |
417 |
%s -d loop_device # delete\n\ |
414 |
%s [ -e encryption ] [ -o offset ] loop_device file # setup\n"), |
418 |
%s [ options ] loop_device file # setup\n\ |
|
|
419 |
OPTIONS \n\ |
420 |
-e <cipher> \n\ |
421 |
encryption, encrypt with <cipher>\n\ |
422 |
-k <number> \n\ |
423 |
specify the number of bits in the key give to\n\ |
424 |
the cipher. Key sizes < 128 are generally not\n\ |
425 |
recommended\n"), |
415 |
progname, progname, progname); |
426 |
progname, progname, progname); |
416 |
exit(1); |
427 |
exit(1); |
417 |
} |
428 |
} |
Lines 445-455
Link Here
|
445 |
|
457 |
|
446 |
int |
458 |
int |
447 |
main(int argc, char **argv) { |
459 |
main(int argc, char **argv) { |
448 |
char *offset, *encryption, *passfd; |
460 |
char *offset, *encryption, *passfd, *keysize = 0; |
449 |
int delete, off, c; |
461 |
int delete, off, c; |
450 |
int res = 0; |
462 |
int res = 0; |
451 |
int ro = 0; |
463 |
int ro = 0; |
452 |
int pfd = -1; |
464 |
int pfd = -1; |
|
|
465 |
int keysz = 0; |
453 |
|
466 |
|
454 |
setlocale(LC_ALL, ""); |
467 |
setlocale(LC_ALL, ""); |
455 |
bindtextdomain(PACKAGE, LOCALEDIR); |
468 |
bindtextdomain(PACKAGE, LOCALEDIR); |
Lines 458-464
Link Here
|
458 |
delete = off = 0; |
471 |
delete = off = 0; |
459 |
offset = encryption = passfd = NULL; |
472 |
offset = encryption = passfd = NULL; |
460 |
progname = argv[0]; |
473 |
progname = argv[0]; |
461 |
while ((c = getopt(argc,argv,"de:E:o:p:v")) != -1) { |
474 |
while ((c = getopt(argc,argv,"de:E:k:o:p:v")) != -1) { |
462 |
switch (c) { |
475 |
switch (c) { |
463 |
case 'd': |
476 |
case 'd': |
464 |
delete = 1; |
477 |
delete = 1; |
Lines 467-472
Link Here
|
467 |
case 'e': |
480 |
case 'e': |
468 |
encryption = optarg; |
481 |
encryption = optarg; |
469 |
break; |
482 |
break; |
|
|
483 |
case 'k': |
484 |
keysize = optarg; |
485 |
break; |
470 |
case 'o': |
486 |
case 'o': |
471 |
offset = optarg; |
487 |
offset = optarg; |
472 |
break; |
488 |
break; |
Lines 494-501
Link Here
|
494 |
usage(); |
510 |
usage(); |
495 |
if (passfd && sscanf(passfd,"%d",&pfd) != 1) |
511 |
if (passfd && sscanf(passfd,"%d",&pfd) != 1) |
496 |
usage(); |
512 |
usage(); |
|
|
513 |
if (keysize && sscanf(keysize,"%d",&keysz) != 1) |
514 |
usage(); |
497 |
res = set_loop(argv[optind], argv[optind+1], off, |
515 |
res = set_loop(argv[optind], argv[optind+1], off, |
498 |
encryption, pfd, &ro); |
516 |
encryption, pfd, keysz, &ro); |
499 |
} |
517 |
} |
500 |
return res; |
518 |
return res; |
501 |
} |
519 |
} |