Esempio n. 1
0
static string_t _get_mapper_property_from_udev( const char * mapper,const char * prefix,size_t position )
{
	DIR * dir = opendir( "/dev/disk/by-id/" ) ;
	struct dirent * e ;

	const char * f = mapper + StringSize( crypt_get_dir() ) + 1 ;

	stringList_t stl ;

	string_t st = StringVoid ;

	if( dir != NULL ){

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

			if( StringStartsAndEndsWith( e->d_name,prefix,f ) ){

				stl = StringListSplit( e->d_name,'-' ) ;

				st = StringListCopyStringAt( stl,position ) ;

				StringListDelete( &stl ) ;

				break ;
			}
		}

		closedir( dir ) ;
	}

	return st ;
}
Esempio n. 2
0
static inline int _option_contain_not_allowed( const char * fs,const char * fs_opts )
{
	stringList_t stl = StringListSplit( fs_opts,',' ) ;

	int r = 1 ;

	if( stl != StringListVoid ){
		if( StringHasAtLeastOneComponent_1( fs,"fat","dos",NULL ) ){
			r = allowed_vfat( stl ) ;
		}else if( StringsAreEqual( fs,"ntfs" ) ){
			r = allowed_ntfs( stl ) ;
		}else if( StringsAreEqual( fs,"udf" ) ){
			r = allowed_udf( stl ) ;
		}else if( StringsAreEqual( fs,"iso9660" ) ){
			r = allowed_iso9660( stl ) ;
		}else if( StringsAreEqual( fs,"btrfs" ) ){
			r = allowed_btrfs( stl ) ;
		}else{
			r = 1 ;
		}
		StringListDelete( &stl ) ;
	}else{
		r = 1 ;
	}

	return r ;
}
Esempio n. 3
0
int zuluCryptOpenPlain_2( const char * device,const char * mapper,
			  const char * mode,const char * key,size_t key_len,
			  const char * options )
{
	open_struct_t opt ;

	stringList_t stl ;

	int r ;

	char * const * e = NULL ;
	size_t n = 0 ;

	args s = { "/dev/urandom","aes","cbc-essiv:sha256","256","ripemd160","0" } ;

	memset( &opt,'\0',sizeof( open_struct_t ) ) ;

	opt.device      = device ;
	opt.mapper_name = mapper ;
	opt.key         = key ;
	opt.key_len     = key_len ;
	opt.m_opts      = mode ;
	opt.variables   = &s ;

	stl = StringListSplit( options,'.' ) ;

	StringListStringArray_1( &e,&n,stl ) ;

	if( n == 6 ){

		s.rng     = *( e + 0 ) ;
		s.algo    = *( e + 1 ) ;
		s.cipher  = *( e + 2 ) ;
		s.keySize = *( e + 3 ) ;
		s.hash    = *( e + 4 ) ;
		s.offset  = *( e + 5 ) ;

	}else if( n == 5 ){

		s.algo    = *( e + 0 ) ;
		s.cipher  = *( e + 1 ) ;
		s.keySize = *( e + 2 ) ;
		s.hash    = *( e + 3 ) ;
		s.offset  = *( e + 4 ) ;
	}

	/*
	 * zuluCryptResolveDevicePath_0() is defined in resolve_path.c
	 */
	r = zuluCryptResolveDevicePath_0( _open_plain,&opt,2 ) ;

	StringListDelete( &stl ) ;

	StringFree( e ) ;

	return r ;
}
Esempio n. 4
0
static void _get_file_system_options_from_config_file( const char * device,string_t st )
{
	char * f ;
	const char * e ;

	StringListIterator it  ;
	StringListIterator end ;

	string_t xt = StringGetFromFile( "/etc/zuluCrypt/fs_options" ) ;

	stringList_t stl = StringListStringSplit( xt,'\n' ) ;

	stringList_t stz ;

	StringDelete( &xt ) ;

	f = _get_uuid_from_device( device ) ;

	StringListGetIterators( stl,&it,&end ) ;

	while( it != end  ){
		e = StringRemoveString( *it,"\"" ) ;
		it++ ;
		if( StringPrefixMatch( e,"UUID=",5 ) ){
			if( StringPrefixEqual( e + 5,f ) ){
				stz = StringListSplit( e,' ' ) ;
				e = StringListContentAtSecondPlace( stz ) ;
				StringMultipleAppend( st,",",e,NULL ) ;
				StringListDelete( &stz ) ;
				break ;
			}
		}
	}

	StringListDelete( &stl ) ;
	StringFree( f ) ;
}
Esempio n. 5
0
void zuluCryptTrueCryptVeraCryptVolumeInfo( const char * type,tvcrypt * e )
{
	stringList_t stl = StringListSplit( type,'.' ) ;

	size_t p = StringListSize( stl ) ;

	const char * q ;

	memset( e,'\0',sizeof( tvcrypt ) ) ;

	if( p > 0 ){

		e->type = StringListCopyStringAtFirstPlace( stl ) ;

		if( p > 1 ){

			q = StringListContentAtSecondPlace( stl ) ;

			e->iteration_count = ( int )StringConvertToInt( q ) ;
		}
	}

	StringListDelete( &stl ) ;
}
Esempio n. 6
0
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 ;
}