コード例 #1
0
ファイル: resolve_paths.c プロジェクト: DarkDare/zuluCrypt
char * zuluCryptResolvePath( const char * path )
{
	char * e ;
	char * f ;

	if( StringsAreEqual( path,"/dev/root" ) ){

		e = _zuluCryptResolveDevRoot() ;

		if( e == NULL ){

			return StringCopy_2( path ) ;
		}else{
			return e ;
		}
	}else if( StringPrefixEqual( path,"/dev/disk/by-" ) ){
		/*
		 * zuluCryptRealPath() is defined in real_path.c
		 */
		e = zuluCryptRealPath( path ) ;

		if( e == NULL ){

			return StringCopy_2( path ) ;
		}else{
			if( StringPrefixEqual( e,"/dev/mapper/" ) ){

				f = _convert_if_path_is_lvm( e ) ;
				StringFree( e ) ;

				return f ;
			}else{
				return e ;
			}
		}
	}else if( StringPrefixEqual( path,"/dev/mapper/" ) ){

		return _convert_if_path_is_lvm( path ) ;

	}else if( StringPrefixEqual( path,"/dev/md" ) ){

		return zuluCryptResolveMDPath( path ) ;

	}else if( StringPrefixEqual( path,"/dev/dm-" ) ){

		return zuluCryptResolveDMPath( path ) ;

	}else if( StringPrefixEqual( path,"/dev/loop" ) ){
		/*
		 * zuluCryptLoopDeviceAddress() is defined in create_loop_device.c
		 */
		return zuluCryptLoopDeviceAddress( path ) ;
	}else{
		return StringCopy_2( path ) ;
	}
}
コード例 #2
0
static int _zuluCryptUnmountVolume_0( string_t st,char ** m_point )
{
	int h ;

	stringList_t stl = StringListStringSplit( st,' ' ) ;

	StringListIterator it = StringListBegin( stl ) ;

	/*
	 * zuluCryptDecodeMountEntry() is defined in mount_volume.c
	 */
	const char * mout_point = zuluCryptDecodeMountEntry( *( it + 1 ) ) ;

	if( StringContains( *( it + 2 ),"fuse" ) ){

		/*
		 * Dont know whats going on but FUSE based file systems do not seem to work with umount()
		 */
		h = _unmount( _unmount_fuse,mout_point ) ;
	}else{
		h = _unmount( _unmount_rest,mout_point ) ;
	}

	if( h == 0 && m_point != NULL ){

		*m_point = StringCopy_2( mout_point ) ;
	}

	StringListDelete( &stl ) ;

	return h ;
}
コード例 #3
0
ファイル: resolve_paths.c プロジェクト: DarkDare/zuluCrypt
char * zuluCryptResolvePath_4( const char * path )
{
	if( StringPrefixEqual( path,"/dev/loop" ) ){

		return StringCopy_2( path ) ;
	}else{
		return zuluCryptResolvePath( path ) ;
	}
}
コード例 #4
0
ファイル: open_plain.c プロジェクト: mhogomchungu/zuluCrypt
static u_int64_t _offset( const char * offset )
{
	char * e ;

	u_int64_t r = 0 ;

	size_t s = StringSize( offset ) ;

	if( s == 0 ){

		return 0 ;
	}else{
		e = StringCopy_2( offset ) ;

		if( StringEndsWithAtLeastOne( e,"m","MB","mb","Mb","M",NULL ) ){

			r = StringConvertToInt( _remove_letters( e ) ) ;
			r = 2 * 1024 * r ;

		}else if( StringEndsWithAtLeastOne( e,"g","GB","gb","Gb","G",NULL ) ){

			r = StringConvertToInt( _remove_letters( e ) ) ;
			r = 2 * 1024 * 1024 * r ;

		}else if( StringEndsWithAtLeastOne( e,"t","TB","tb","Tb","T",NULL ) ){

			r = StringConvertToInt( _remove_letters( e ) ) ;
			r = 1.0 * 2 * 1024 * 1024 * 1024 * r ;

		}else if( StringEndsWithAtLeastOne( e,"k","KB","kb","Kb","K",NULL ) ){

			r = StringConvertToInt( _remove_letters( e ) ) ;
			r = 2 * r ;

		}else if( StringEndsWithAtLeastOne( e,"b","B",NULL ) ){

			r = StringConvertToInt( _remove_letters( e ) ) ;

			if( r < 512 ){
				r = 0 ;
			}else{
				r = r / 512 ;
			}
		}else {
			r = StringConvertToInt( offset ) ;
		}

		StringFree( e ) ;
	}

	return r ;
}
コード例 #5
0
ファイル: status.c プロジェクト: DarkDare/zuluCrypt
char * zuluCryptGetVolumeTypeFromMapperPath( const char * mapper )
{
	struct crypt_device * cd ;
	const char * type ;
	char * r ;
	string_t st ;

	if( StringPrefixNotEqual( mapper,crypt_get_dir() ) ){

		return StringCopy_2( "Nil" ) ;
	}

	if( crypt_init_by_name( &cd,mapper ) < 0 ){

		return StringCopy_2( "Nil" ) ;
	}

	type = crypt_get_type( cd ) ;

	if( type == NULL ){

		if( StringHasComponent( mapper,"veracrypt" ) ){

			r = StringCopy_2( "crypto_VCRYPT" ) ;

		}else if( StringHasComponent( mapper,"truecrypt" ) ){

			r = StringCopy_2( "crypto_TCRYPT" ) ;
		}else{
			r = _get_type_from_udev( mapper ) ;
		}
	}else{
		st = String_1( "crypto_",type,NULL ) ;
		r = StringDeleteHandle( &st ) ;
	}

	crypt_free( cd ) ;
	return r ;
}
コード例 #6
0
ファイル: status.c プロジェクト: DarkDare/zuluCrypt
static char * _get_type_from_udev( const char * mapper )
{
	string_t st = _get_mapper_property_from_udev( mapper,"dm-uuid-CRYPT-",TYPE ) ;

	if( st == StringVoid ){

		return StringCopy_2( "Nil" ) ;
	}else{
		StringPrepend( st,"crypto_" ) ;

		return StringDeleteHandle( &st ) ;
	}
}
コード例 #7
0
ファイル: mount_volume.c プロジェクト: Hasimir/zuluCrypt
static char * _get_uuid_from_device( const char * device )
{
	char * r = NULL ;
	const char * e = NULL ;
	blkid_probe blkid = blkid_new_probe_from_filename( device ) ;
	if( blkid != NULL ){
		blkid_do_probe( blkid ) ;
		blkid_probe_lookup_value( blkid,"UUID",&e,NULL ) ;
		r = StringCopy_2( e ) ;
		blkid_free_probe( blkid ) ;
	}
	return r ;
}
コード例 #8
0
ファイル: open_volume.c プロジェクト: DarkDare/zuluCrypt
static char * _device_path( const char * device )
{
	char * path ;

	if( StringPrefixEqual( device,"/dev/loop" ) ){

		zuluCryptSecurityGainElevatedPrivileges() ;
		/*
		 * zuluCryptLoopDeviceAddress_1() is defined in ../zuluCrypt-cli/create_loop_device.c
		 */
		path = zuluCryptLoopDeviceAddress_1( device ) ;

		zuluCryptSecurityDropElevatedPrivileges() ;

		if( path == NULL ){

			return StringCopy_2( device ) ;
		}else{
			return path ;
		}
	}else{
		return StringCopy_2( device ) ;
	}
}
コード例 #9
0
ファイル: open_plain.c プロジェクト: bankonme/zuluCrypt
static u_int64_t _offset( const char * offset )
{
	char * e ;
	char f   ;

	u_int64_t r = 0 ;

	size_t s = StringSize( offset ) ;

	if( s == 0 ){
		return 0 ;
	}else{
		f = *( offset + s - 1 ) ;
	}
	if( !( f >= '0' && f <= '9' ) ){
		/*
		 * The argument ends with a non digit number,assume the argument is not in offsets but
		 * in bytes and convert it to offsets
		 */
		e = StringCopy_2( offset ) ;
		*( e + s - 1 ) = '\0' ;
		r = StringConvertToInt( e ) ;
		if( f == 'b' || f == 'B' ) {
			if( r < 512 ){
				r = 0 ;
			}else{
				r = r / 512 ;
			}
		}else if( f == 'k' || f == 'K' ){
			r = 2 * r ;
		}else if( f == 'm' || f == 'M' ){
			r = 2 * 1024 * r ;
		}else if( f == 'g' || f == 'G' ){
			r = 2 * 1024 * 1024 * r ;
		}else if( f == 't' || f == 'T' ){
			r = 1.0 * 2 * 1024 * 1024 * 1024 * r ;
		}else{
			r = 0 ;
		}
		StringFree( e ) ;
	}else{
		r = StringConvertToInt( offset ) ;
	}

	return r ;
}