void zuluCryptSecuritySanitizeTheEnvironment( uid_t uid,stringList_t * stx ) { extern char ** environ ; const char ** env = ( const char ** ) environ ; ssize_t index ; stringList_t stl = StringListVoid ; string_t st ; StringListIterator it ; StringListIterator end ; if( uid ){;} /* * First,we make a copy of the enviromental varibales * Second,we clear the enviromental variable because we dont want it * Third,we return a copy of the enviromental variable because we want to pass it along * the plugins */ while( *env ){ stl = StringListAppend( stl,*env ) ; env++ ; } StringListGetIterators( stl,&it,&end ) ; while( it != end ){ st = *it ; it++ ; index = StringIndexOfChar( st,0,'=' ) ; if( index >= 0 ){ unsetenv( StringSubChar( st,index,'\0' ) ) ; StringSubChar( st,index,'=' ) ; } } *stx = stl ; }
int zuluMountCryptoUMount( ARGS * args ) { const char * device = args->device ; const char * UUID = args->uuid ; uid_t uid = args->uid ; const char * mapping_name ; char * path = NULL ; int st ; 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{ device = path ; } } mapping_name = device + StringLastIndexOfChar_1( device,'/' ) + 1 ; }else{ str = String( UUID ) ; StringRemoveString( str,"\"" ) ; mapping_name = StringSubChar( str,4,'-' ) ; } /* * zuluCryptEXECloseVolume() is defined in ../zuluCrypt-cli/bin/close_volume.c */ st = zuluCryptEXECloseVolume( device,mapping_name,uid ) ; StringDelete( &str ) ; StringFree( path ) ; return st ; }
stringList_t zuluCryptOpenedVolumesList( uid_t uid ) { const char * e ; const char * c ; const char * d ; const char * t ; char * f ; char * g ; StringListIterator it ; StringListIterator end ; ssize_t k ; string_t q ; string_t z ; string_t j ; stringList_t stx ; stringList_t list = StringListVoid ; stringList_t stl = zuluCryptGetMoutedList() ; if( uid ) { ; } /* * zuluCryptMapperPrefix() is defined in create_mapper_name.c */ j = String_1( zuluCryptMapperPrefix(),"/zuluCrypt-",NULL ) ; /* * t will probably contain "/dev/mapper/zuluCrypt-" */ t = StringContent( j ) ; StringListGetIterators( stl,&it,&end ) ; while( it != end ) { c = StringContent( *it ) ; it++ ; if( StringPrefixNotEqual( c,t ) ) { /* * we only care about zuluCrypt volumes and these volumes that we care about starts with * "/dev/mapper/zuluCrypt-" */ continue ; } if( StringHasComponent( c,"/run/media/public/" ) ) { /* * dont show mirror images due to bind mounts */ continue ; } stx = StringListSplit( c,' ' ) ; e = StringListContentAtFirstPlace( stx ) ; k = StringHasComponent_1( e,"-UUID-" ) ; if( k != -1 ) { q = StringListStringAtFirstPlace( stx ) ; /* * zuluCryptDecodeMountEntry() is defined in mount_volume.c */ d = zuluCryptDecodeMountEntry( StringListStringAtSecondPlace( stx ) ) ; /* * zuluCryptGetVolumeTypeFromMapperPath() is defined in status.c */ f = zuluCryptGetVolumeTypeFromMapperPath( StringContent( q ) ) ; e = StringSubChar( q,StringLastIndexOfChar( q,'-' ),'\0' ) + k + 6 ; z = String_1( "UUID=\"",e,"\"\t",d,"\t",f,NULL ) ; list = StringListAppendString_1( list,&z ) ; StringFree( f ) ; } else { /* * zuluCryptVolumeDeviceName() is defined in status.c */ g = zuluCryptVolumeDeviceName( e ) ; if( g != NULL ) { d = zuluCryptDecodeMountEntry( StringListStringAtSecondPlace( stx ) ) ; /* * zuluCryptGetVolumeTypeFromMapperPath() is defined in status.c */ f = zuluCryptGetVolumeTypeFromMapperPath( StringListContentAtFirstPlace( stx ) ) ; z = String_1( g,"\t",d,"\t",f,NULL ) ; list = StringListAppendString_1( list,&z ) ; StringFree( f ) ; StringFree( g ) ; } } StringListDelete( &stx ) ; } StringListDelete( &stl ) ; StringDelete( &j ) ; return list ; }