Пример #1
0
static inline int fs_family( const char * fs )
{
	if( StringAtLeastOneMatch_1( fs,"ntfs,","vfat","fat","msdos","umsdos","exfat",NULL ) ){
		return 1 ;
	}else if( StringAtLeastOneMatch_1( fs,"affs","hfs",NULL ) ){
		return 2 ;
	}else if( StringAtLeastOneMatch_1( fs,"iso9660","udf","squashfs",NULL ) ){
		return 3 ;
	}else{
		return 0 ;
	}
}
Пример #2
0
static stringList_t _zuluCryptAddMDRAIDVolumes( stringList_t stl )
{
	DIR * dir = opendir( "/dev/md/" ) ;
	struct dirent * entry ;
	char * e ;
	const char * f ;
	string_t st ;

	if( dir != NULL ){

		while( ( entry = readdir( dir ) ) != NULL ){

			f = entry->d_name ;

			if( !StringAtLeastOneMatch_1( f,".","..","md-device-map",NULL ) ){

				st = String( "/dev/md/" ) ;
				e = zuluCryptRealPath( StringAppend( st,f ) ) ;

				if( e != NULL ){

					StringListRemoveString( stl,e ) ;
					StringFree( e ) ;
				}

				stl = StringListAppendString_1( stl,&st ) ;
			}
		}
		closedir( dir ) ;
	}

	return stl ;
}
Пример #3
0
int zuluCryptFileSystemIsFUSEbased( const char * device )
{
	const char * cf = NULL ;
	int st ;
	blkid_probe blkid = blkid_new_probe_from_filename( device ) ;
	if( blkid != NULL ){
		blkid_do_probe( blkid ) ;
		blkid_probe_lookup_value( blkid,"TYPE",&cf,NULL ) ;
#if 1
		st = StringAtLeastOneMatch_1( cf,"ntfs","exfat",NULL ) ;
#else
		st = StringAtLeastOneMatch_1( cf,"ntfs",NULL ) ;
#endif
		blkid_free_probe( blkid ) ;
		return st ;
	}else{
		return 0 ;
	}
}
Пример #4
0
int zuluCryptCreateFileSystemInAVolume( const char * fs,const char * device_mapper )
{
	int status ;
	char * e = NULL ;
	
	process_t p = Process( ZULUCRYPTmkfs ) ;
	
	if( StringAtLeastOneMatch_1( fs,"ext2","ext3","ext4",NULL ) ){
		
		ProcessSetArgumentList( p,"-t",fs,"-m","1",device_mapper,ENDLIST ) ;
		
	}else if( StringsAreEqual( fs,"reiserfs" ) ){
		
		ProcessSetArgumentList( p,"-t",fs,"-f","-f","-q",device_mapper,ENDLIST ) ;
		
	}else if( StringsAreEqual( fs,"jfs" ) ){
		
		ProcessSetArgumentList( p,"-t",fs,"-q",device_mapper,ENDLIST ) ;
		
	}else if( StringsAreEqual( fs,"ntfs" ) ){
		
		ProcessSetArgumentList( p,"-t",fs,"-f",device_mapper,ENDLIST ) ;
		
	}else if( StringsAreEqual( fs,"xfs" ) ){
		
		ProcessSetArgumentList( p,"-t",fs,"-f",device_mapper,ENDLIST ) ;
		
	}else{
		ProcessSetArgumentList( p,"-t",fs,device_mapper,ENDLIST ) ;
		
		/*
		 * unhandled fs are processed here.They are given 60 seconds to accomplish their task
		 * and are assumed to be running in interactive more and are blocked waiting for user input
		 * when they fail to return in time and hence are killed since we cant get to them from GUI 
		 */
		
		ProcessSetOptionTimeout( p,60,SIGKILL ) ;
	}
	
	ProcessStart( p ) ;
	
	status = ProcessExitStatus( p ) ;
	
	if( status ){
		ProcessGetOutPut( p,&e,STDERROR ) ;
		if( e ){
			puts( e ) ;
			free( e ) ;
		}
	}
	
	ProcessDelete( &p ) ;
	return status ;
}
Пример #5
0
/*
 * raid path can be in format /dev/mdX or /dev/md/X.
 * We prefer the latter and if given the former,convert it to the latter if possible
 */
string_t zuluCryptResolveMDPath_1( const char * path )
{
	struct dirent * entry ;

	char * e ;

	const char * f = "/dev/md/" ;

	DIR * dir = opendir( f ) ;

	string_t st = String( f ) ;

	if( dir != NULL ){

		while( ( entry = readdir( dir ) ) != NULL ){

			f = entry->d_name ;

			if( !StringAtLeastOneMatch_1( f,".","..",NULL ) ){

				e = zuluCryptRealPath( StringAppendAt( st,8,f ) ) ;

				if( StringsAreEqual( path,e ) ){

					StringFree( e ) ;

					return zuluExit( dir,st ) ;
				}else{
					StringFree( e ) ;
				}
			}
		}
	}

	StringReplace( st,path ) ;

	return zuluExit( dir,st ) ;
}
Пример #6
0
static stringList_t _zuluCryptAddLVMVolumes( stringList_t stl )
{
	struct dirent * entry ;

	string_t st ;
	string_t xt ;

	DIR * dir = opendir( "/dev/mapper/" ) ;

	if( dir != NULL ){

		st = String( "/dev/mapper/" ) ;

		while( ( entry = readdir( dir ) ) != NULL ){

			if( !StringAtLeastOneMatch_1( entry->d_name,".","..","control",NULL ) ){

				/*
				 * zuluCryptConvertIfPathIsLVM() is defined in ../lib/resolve_paths.c
				 */

				xt = zuluCryptConvertIfPathIsLVM( StringAppendAt( st,12,entry->d_name ) ) ;

				if( StringStartsWith( xt,"/dev/mapper/" ) ){

					StringDelete( &xt ) ;
				}else{
					stl = StringListAppendString_1( stl,&xt ) ;
				}
			}
		}
		StringDelete( &st ) ;
		closedir( dir ) ;
	}

	return stl ;
}
Пример #7
0
static string_t _get_crypto_info_from_tcplay( const char * mapper )
{
	int key_size ;

	int ro ;

	int64_t offset ;

	tc_api_task task ;

	char buff[ SIZE ] ;
	char * buffer = buff ;

	const char * z ;

	string_t p = StringVoid ;

	string_t q ;

	if( tc_api_initialize() ){

		if( tc_api_task_initialize( &task,"info_mapped" ) ){

			p = String( mapper ) ;

			mapper = mapper + StringLastIndexOfChar_1( mapper,'/' ) + 1 ;

			tc_api_task_set( task,"map_name",mapper ) ;

			tc_api_task_do( task ) ;

			tc_api_task_info_get( task,"status",sizeof( buff ),buff ) ;

			StringMultipleAppend( p," is ",buff,".",NULL ) ;

			if( StringAtLeastOneMatch_1( buff,"active","active and is in use",NULL ) ){

				tc_api_task_info_get( task,"type",sizeof( buff ),buff ) ;

				q = String( buff ) ;

				StringMultipleAppend( p," \n type:   \t",StringToLowerCase( q ),NULL ) ;

				StringDelete( &q ) ;

				tc_api_task_info_get( task,"cipher",sizeof( buff ),buff ) ;

				/*
				 * zuluCryptConvertCipher() is defined in create_tcrypt.c
				 */
				StringMultipleAppend( p,"\n cipher:\t",zuluCryptConvertCipher( buff ),"-xts-plain64",NULL ) ;

				tc_api_task_info_get( task,"key_bits",sizeof( key_size ),&key_size ) ;

				z = StringIntToString_1( buffer,SIZE,key_size ) ;

				StringMultipleAppend( p,"\n keysize:\t",z," bits",NULL ) ;

				tc_api_task_info_get( task,"iv_offset",sizeof( offset ),&offset ) ;

				z = StringIntToString_1( buffer,SIZE,offset / 512 ) ;

				StringMultipleAppend( p,"\n offset:\t",z," sectors",NULL ) ;

				zuluCryptFormatSize( offset,buffer,SIZE ) ;

				StringMultipleAppend( p," / ",buffer,NULL ) ;

				tc_api_task_info_get( task,"device",sizeof( buff ),buff ) ;

				_device_info( p,buff ) ;

				tc_api_task_info_get( task,"mode",sizeof( ro ),&ro ) ;

				if( ro ){

					StringAppend( p,"\n mode:   \tread only" ) ;
				}else{
					StringAppend( p,"\n mode:   \tread and write" ) ;
				}

				StringAppend( p,"\n active slots:\tNil" ) ;
			}

			tc_api_task_uninit( task ) ;
		}

		tc_api_uninit() ;
	}

	return p ;
}