void zuluCryptEXEGetOpts( int argc,char * argv[],struct_opts * stopts ) { int c ; int k = 0 ; int n = 0 ; zuluCryptEXEGetOptsSetDefault( stopts ) ; while ( ( c = getopt( argc,argv,"MHZCUWTJLORBXASNPkhocsarqwibEDs:m:d:p:f:e:Y:i:z:g:y:u:l:n:j:t:G:F:V:K:" ) ) != -1 ) { switch( c ){ case( 'H' ) : stopts->action = 'H' ; break ; case( 'C' ) : stopts->action = 'C' ; break ; case( 'U' ) : stopts->action = 'U' ; break ; case( 'W' ) : stopts->action = 'W' ; break ; case( 'E' ) : stopts->action = 'E' ; break ; case( 'D' ) : stopts->action = 'D' ; break ; case( 'X' ) : stopts->action = 'X' ; break ; case( 'J' ) : stopts->action = 'J' ; break ; case( 'L' ) : stopts->action = 'L' ; break ; case( 'o' ) : stopts->action = 'o' ; break ; case( 'c' ) : stopts->action = 'c' ; break ; case( 's' ) : stopts->action = 's' ; break ; case( 'a' ) : stopts->action = 'a' ; break ; case( 'r' ) : stopts->action = 'r' ; break ; case( 'q' ) : stopts->action = 'q' ; break ; case( 'w' ) : stopts->action = 'w' ; break ; case( 'i' ) : stopts->action = 'i' ; break ; case( 'b' ) : stopts->action = 'b' ; break ; case( 'P' ) : stopts->action = 'P' ; break ; case( 'O' ) : stopts->action = 'O' ; stopts->open_mount = 0 ; break ; case( 'T' ) : stopts->print_partition_type = 1 ; break; case( 'M' ) : stopts->share = 1 ; break ; stopts->share = 1 ; break ; case( 'Z' ) : stopts->print_partition_type = 2 ; break; case( 'B' ) : stopts->action = 'B' ; stopts->key_source = optarg ; break ; case( 'G' ) : stopts->plugin_path = optarg ; break ; case( 'R' ) : stopts->action = 'R' ; stopts->key_source = optarg ; break ; case( 'k' ) : stopts->ask_confirmation = 0 ; break ; /* * ZULUCRYPTallPartitions,ZULUCRYPTsystemPartitions and ZULUCRYPTnonSystemPartitions * are set in ../constants.h */ case( 'A' ) : stopts->partition_number = ZULUCRYPTallPartitions ; stopts->action = 'A' ; break ; case( 'S' ) : stopts->partition_number = ZULUCRYPTsystemPartitions ; stopts->action = 'S' ; break ; case( 'N' ) : stopts->partition_number = ZULUCRYPTnonSystemPartitions ; stopts->action = 'N' ; break ; case( 't' ) : stopts->type = optarg ; break ; case( 'K' ) : stopts->uid = optarg ; break ; case( 'm' ) : stopts->mount_point = optarg ; break ; case( 'd' ) : stopts->device = optarg ; break ; case( 'p' ) : stopts->key_source = "-p" ; stopts->key = optarg ; break ; case( 'F' ) : if( k < TRUECRYPT_MAX_KEYFILES ){ /* * TRUECRYPT_MAX_KEYFILES is set at libzuluCrypt-exe.h */ stopts->tcrypt_multiple_keyfiles[ k ] = optarg ; k++ ; } break ; case( 'f' ) : stopts->key_source = "-f" ; stopts->key = optarg ; break ; case( 'e' ) : stopts->m_opts = optarg ; stopts->tcrypt_hidden_volume_size = optarg ; break ; case( 'Y' ) : stopts->fs_opts = optarg ; break ; case( 'z' ) : stopts->fs = optarg ; stopts->back_up_file_path = optarg ; break ; case( 'g' ) : stopts->rng = optarg ; break ; case( 'y' ) : stopts->existing_key_source = "-p" ; stopts->existing_key = optarg ; break ; case( 'u' ) : stopts->existing_key_source = "-f" ; stopts->existing_key = optarg ; break ; case( 'V' ) : if( n < TRUECRYPT_MAX_KEYFILES ){ /* * TRUECRYPT_MAX_KEYFILES is set at libzuluCrypt-exe.h */ stopts->tcrypt_hidden_volume_multiple_keyfiles[ n ] = optarg ; n++ ; } break ; case( 'l' ) : stopts->new_key_source = "-p" ; stopts->new_key = optarg ; stopts->tcrypt_hidden_volume_key = optarg ; break ; case( 'n' ) : stopts->new_key_source = "-f" ; stopts->new_key = optarg ; break ; default: printf( "run zuluCrypt-cli --help for help\n" ) ; } } }
int zuluMountCryptoMount( ARGS * args ) { const char * type = args->type ; const char * offset = args->offset ; const char * device = args->device ; const char * UUID = args->uuid ; const char * mode = args->m_opts ; uid_t uid = args->uid ; const char * key = args->key ; const char * key_source = args->key_source ; const char * m_point = args->m_point ; const char * fs_opts = args->fs_opts ; int mount_point_option = args->mpo ; int share = args->share ; int st ; /* * the struct is declared in ../zuluCrypt-cli/bin/libzuluCrypt-exe.h */ struct_opts opts ; const char * mapping_name ; char * path = NULL ; string_t str = StringVoid ; if( UUID == NULL ){ if( StringPrefixEqual( device,"/dev/loop" ) ){ /* * zuluCryptLoopDeviceAddress_1() is defined in ../zuluCrypt-cli/create_loop_device.c */ path = zuluCryptLoopDeviceAddress_1( device ) ; if( path == NULL ){ return 20 ; }else{ mapping_name = path + StringLastIndexOfChar_1( path,'/' ) + 1 ; } }else{ mapping_name = device + StringLastIndexOfChar_1( device,'/' ) + 1 ; } }else{ str = String( UUID ) ; StringRemoveString( str,"\"" ) ; mapping_name = StringReplaceString( str,"UUID=","UUID-" ) ; } /* * zuluCryptEXEGetOptsSetDefault() is defined in ../zuluCrypt-cli/bin/get_opts.c */ zuluCryptEXEGetOptsSetDefault( &opts ) ; if( StringPrefixEqual( key_source,"-G" ) ){ opts.plugin_path = key ; } opts.mount_point = m_point ; opts.device = device ; opts.m_opts = mode ; opts.key = key ; opts.key_source = key_source ; opts.mount_point_option = mount_point_option ; opts.share = share ; opts.fs_opts = fs_opts ; opts.env = StringListStringArray( args->env ) ; opts.offset = offset ; opts.type = type ; memcpy( opts.tcrypt_multiple_keyfiles,args->tcrypt_multiple_keyfiles, sizeof( args->tcrypt_multiple_keyfiles ) ) ; /* * zuluCryptEXEOpenVolume() is defined in ../zuluCrypt-cli/bin/open_volume.c */ st = zuluCryptEXEOpenVolume( &opts,mapping_name,uid ) ; StringDelete( &str ) ; StringFree( opts.env ) ; StringFree( path ) ; return st ; }