DM-Crypt Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [dm-crypt] shoulnt "crypt_init_by_name()" fail when the underlying device is no longer available?
@ 2012-11-27 22:26 .. ink ..
  2012-11-28 11:35 ` Milan Broz
  0 siblings, 1 reply; 5+ messages in thread
From: .. ink .. @ 2012-11-27 22:26 UTC (permalink / raw)
  To: dm-crypt

[-- Attachment #1: Type: text/plain, Size: 1267 bytes --]

test using cryptsetup version 1.5.1

simple test:
1. open a mapper against a device.

2 call crypt_init_by_name() on the mapper and the call return "0" to mean
success,this is expected.

3.Unplug the device.

4.call the function again and it still return "0" to mean success,shouldnt
it fail since the underlying device is no longer available?

Simple test to show this:

open a mapper against a device:
root@mtz ink]# cryptsetup luksOpen /dev/sdc6 sdc6
Enter passphrase for /dev/sdc6:

run the "test" program on the mapper and results are below( source code
below )
[root@mtz ink]# ./test /dev/mapper/sdc6
pass1
pass2

unplugged the device and rerun the test again and the results are below.
[root@mtz ink]# ./test /dev/mapper/sdc6
pass1
fail2
[root@mtz ink]#


source code of the test program:


#include<libcryptsetup.h>

int main( int argc,char * argv[] )
{
    const char * path = argv[ 1 ] ;
    struct crypt_device * cd;

    if( crypt_init_by_name( &cd,path ) < 0 ){
        puts( "fail1" ) ;
        crypt_free( cd ) ;
        return 1 ;
    }else{
        puts( "pass1" ) ;
    }

    const char * e = crypt_get_device_name( cd ) ;

    if( e ){
        puts( "pass2" ) ;
    }else{
        puts( "fail2" ) ;
    }

    crypt_free( cd ) ;

    return 0 ;
}

[-- Attachment #2: Type: text/html, Size: 1585 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-11-29 19:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-27 22:26 [dm-crypt] shoulnt "crypt_init_by_name()" fail when the underlying device is no longer available? .. ink ..
2012-11-28 11:35 ` Milan Broz
2012-11-28 18:29   ` .. ink ..
2012-11-29  9:02     ` Milan Broz
2012-11-29 19:32       ` .. ink ..

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox