"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "zuluCrypt-cli/lib/bitlocker.c" between
zuluCrypt-5.7.0.tar.xz and zuluCrypt-5.7.1.tar.xz

About: zuluCrypt is a simple but feature rich solution for hard drives encryption. It can manage PLAIN dm-crypt, LUKS, TrueCrypt and VeraCrypt encrypted volumes.

bitlocker.c  (zuluCrypt-5.7.0.tar.xz):bitlocker.c  (zuluCrypt-5.7.1.tar.xz)
skipping to change at line 28 skipping to change at line 28
*/ */
#include "includes.h" #include "includes.h"
#include <pwd.h> #include <pwd.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <stdio.h> #include <stdio.h>
#include <libcryptsetup.h>
static int zuluExit( int st,struct crypt_device * cd )
{
crypt_free( cd ) ;
return st ;
}
const char * zuluCryptBitLockerType() const char * zuluCryptBitLockerType()
{ {
return "crypto_BitLocker" ; return "crypto_BitLocker" ;
} }
const char * zuluCryptBitLockerFolderPrefix( void ) const char * zuluCryptBitLockerFolderPrefix( void )
{ {
return "cryptoBitlocker" ; return "cryptoBitlocker" ;
} }
const char * zuluCryptCryptsetupBitLockerType()
{
#ifdef CRYPT_BITLK
return CRYPT_BITLK ;
#else
return "" ;
#endif
}
int zuluCryptUseCryptsetupBitLocker( int r )
{
#ifdef CRYPT_BITLK
return r ;
#else
return 0 ;
#endif
}
int zuluCryptUseDislockerBitLocker( int r )
{
return !zuluCryptUseCryptsetupBitLocker( r ) ;
}
int zuluCryptIsDislockerMapperPath( const char * e )
{
return StringEndsWith_1( e,"/dislocker-file" ) ;
}
string_t zuluCryptBitLockerMapperPath( uid_t uid ) string_t zuluCryptBitLockerMapperPath( uid_t uid )
{ {
const char * m = zuluCryptBitLockerFolderPrefix() ; const char * m = zuluCryptBitLockerFolderPrefix() ;
return String_1( "/run/media/private/",getpwuid( uid )->pw_name,"/",m,NUL L ) ; return String_1( "/run/media/private/",getpwuid( uid )->pw_name,"/",m,NUL L ) ;
} }
string_t zuluCryptBitLockerMapperName( const char * e ) string_t zuluCryptBitLockerMapperName( const char * e )
{ {
string_t st ; string_t st ;
skipping to change at line 106 skipping to change at line 141
StringAppendString( a,b ) ; StringAppendString( a,b ) ;
StringAppend( a,"/dislocker-file" ) ; StringAppend( a,"/dislocker-file" ) ;
StringDelete( &b ) ; StringDelete( &b ) ;
return a ; return a ;
} }
int zuluCryptDeviceManagedByDislocker( const char * dev,uid_t uid )
{
struct stat st ;
string_t p = zuluCryptBitLockerFullMapperPath( uid,dev ) ;
int r = stat( StringContent( p ),&st ) ;
StringDelete( &p ) ;
return r == 0 ;
}
int zuluCryptBitLockerVolume( const char * e ) int zuluCryptBitLockerVolume( const char * e )
{ {
return StringEndsWith_1( e,"/dislocker-file" ) ; struct crypt_device * cd = NULL ;
int r ;
if( zuluCryptIsDislockerMapperPath( e ) ){
return 1 ;
}else{
if( !StringPrefixEqual( e,crypt_get_dir() ) ){
return 0 ;
}
if( crypt_init_by_name( &cd,e ) != 0 ){
return 0 ;
}
r = StringsAreEqual( crypt_get_type( cd ),zuluCryptCryptsetupBitL
ockerType() ) ;
crypt_free( cd ) ;
return r ;
}
} }
char * zuluCryptBitLockerUnmountPath( const char * e ) char * zuluCryptBitLockerUnmountPath( const char * e )
{ {
/* /*
* e will contain something like "/woof/bar/meaw/dislocker-file" * e will contain something like "/woof/bar/meaw/dislocker-file"
* and we want to remove the "/dislocker-file" part. * and we want to remove the "/dislocker-file" part.
*/ */
char * m = StringCopy_2( e ) ; char * m = StringCopy_2( e ) ;
skipping to change at line 234 skipping to change at line 300
return e ; return e ;
}else{ }else{
fprintf( stderr,"Looking for dislocker-fuse at \"%s\" : F AILED\n",e ) ; fprintf( stderr,"Looking for dislocker-fuse at \"%s\" : F AILED\n",e ) ;
} }
} }
return NULL ; return NULL ;
} }
int zuluCryptBitLockerUnlock( const open_struct_t * opts,string_t * xt ) static int _cryptsetup_unlock_bitlocker( const open_struct_t * opts,string_t * x t )
{ {
int r ; int r ;
const char * exe = _dislocker_fuse_path() ; struct crypt_device * cd = NULL ;
uint32_t flags = 0 ;
if( crypt_init( &cd,opts->device ) != 0 ){
return 4 ;
}
if( crypt_load( cd,zuluCryptCryptsetupBitLockerType(),NULL ) != 0 ){
return zuluExit( 4,cd ) ;
}
if( StringHasComponent( opts->m_opts,"ro" ) ){
flags = CRYPT_ACTIVATE_READONLY ;
}else{
flags = CRYPT_ACTIVATE_ALLOW_DISCARDS ;
}
r = crypt_activate_by_passphrase( cd,
opts->mapper_name,
CRYPT_ANY_SLOT,
opts->key,
opts->key_len,
flags ) ;
if( r == 0 ){
*xt = String( opts->mapper_path ) ;
return zuluExit( 0,cd ) ;
}else{
return zuluExit( 4,cd ) ;
}
}
static int _dislocker_unlock_bitlocker( const open_struct_t * opts,string_t * xt
)
{
int r ;
string_t st ; string_t st ;
const char * mapper_path ; const char * mapper_path ;
process_t p ; process_t p ;
string_t m ; string_t m ;
char * env[ 2 ] = { NULL,NULL } ; char * env[ 2 ] = { NULL,NULL } ;
const char * exe = _dislocker_fuse_path() ;
if( exe == NULL ){ if( exe == NULL ){
return 15 ; return 15 ;
} }
st = String_1( opts->mapper_path,opts->mapper_name,NULL ) ; st = String_1( opts->mapper_path,opts->mapper_name,NULL ) ;
mapper_path = StringContent( st ) ; mapper_path = StringContent( st ) ;
if( mkdir( mapper_path,S_IRWXU ) != 0 ){ if( mkdir( mapper_path,S_IRWXU ) != 0 ){
StringDelete( &st ) ; StringDelete( &st ) ;
return 2 ; return 2 ;
}else{ }else{
m = String_1( "DISLOCKER_PASSWORD=",opts->key,NULL ) ; m = String_1( "DISLOCKER_PASSWORD=",opts->key,NULL ) ;
*env = ( char * )StringContent( m ) ; env[ 0 ] = ( char * )StringContent( m ) ;
p = Process( exe,opts->device,"-u","--","-oallow_root",mapper_pat h,NULL ) ; p = Process( exe,opts->device,"-u","--","-oallow_root",mapper_pat h,NULL ) ;
ProcessSetEnvironmentalVariable( p,( char * const * )env ) ; ProcessSetEnvironmentalVariable( p,( char * const * )env ) ;
ProcessStart( p ) ; ProcessStart( p ) ;
r = ProcessWaitUntilFinished( &p ) ; r = ProcessWaitUntilFinished( &p ) ;
StringDelete( &m ) ; StringDelete( &m ) ;
skipping to change at line 290 skipping to change at line 396
StringAppend( st,"/dislocker-file" ) ; StringAppend( st,"/dislocker-file" ) ;
*xt = st ; *xt = st ;
return 0 ; return 0 ;
}else{ }else{
rmdir( mapper_path ) ; rmdir( mapper_path ) ;
StringDelete( &st ) ; StringDelete( &st ) ;
return 4 ; return 4 ;
} }
} }
} }
int zuluCryptBitLockerUnlock( const open_struct_t * opts,string_t * xt )
{
if( zuluCryptUseCryptsetupBitLocker( opts->use_cryptsetup_for_bitlocker )
){
return _cryptsetup_unlock_bitlocker( opts,xt ) ;
}else{
return _dislocker_unlock_bitlocker( opts,xt ) ;
}
}
 End of changes. 9 change blocks. 
4 lines changed or deleted 112 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)