示例#1
0
static stringList_t _get_mount_entries( const char * device )
{
	/*
	 * zuluCryptGetMountEntry() is defined in mountinfo.c
	 */
	stringList_t stl = zuluCryptGetMoutedList() ;

	StringListIterator it ;
	StringListIterator end ;

	string_t st = String_1( device," ",NULL ) ;

	StringListGetIterators( stl,&it,&end ) ;

	while( it != end ){

		if( StringStartsWith_1( *it,st ) ){

			it++ ;
		}else{
			StringListRemoveAt_1( stl,it,&end ) ;
		}
	}

	StringDelete( &st ) ;

	return stl ;
}
示例#2
0
static int _not_removed( stringList_t stl,StringListIterator it,StringListIterator * end )
{
	string_t st = *it ;

	StringListIterator e = it + 1 ;

	if( StringStartsWithAtLeastOne( st,"/dev/sd","/dev/hd","/dev/mmcblk",NULL ) ){

		/*
		 * we have a partition,lets continue
		 */

		if( e != *end ){

			/*
			 * we are not at the end of the list,ie,there is atleast one more entry
			 */

			if( StringStartsWith_1( *e,st ) ){

				/*
				 * *e will contain something like "/dev/sdc3"
				 * st will contain something like "/dev/sdc"
				 *
				 * This device is partitioned and hence we remove the "/dev/sdc" entry
				 * from the list since we dont care about it.
				 */

				StringListRemoveAt_1( stl,it,end ) ;

				return 0 ;
			}
		}
	}

	return 1 ;
}
示例#3
0
stringList_t zuluCryptPartitions( int option,uid_t uid )
{
	const char * device ;
	const char * e ;

	stringList_t non_system = StringListVoid ;
	stringList_t system     = StringListVoid ;

	string_t st ;

	stringList_t p ;
	stringList_t stl = zuluCryptVolumeList() ;

	StringListIterator it  ;
	StringListIterator end ;

	if( stl == StringListVoid ){
		return StringListVoid ;
	}
	if( option == ZULUCRYPTallPartitions ){
		return _remove_btfs_multiple_devices( stl ) ;
	}

	non_system = stl ;

	zuluCryptSecurityGainElevatedPrivileges() ;
	/*
	 * zuluCryptGetFstabList() is defined in ../lib/parse_fstab.c
	 */
	stl = zuluCryptGetFstabList( uid ) ;
	zuluCryptSecurityDropElevatedPrivileges() ;

	StringListGetIterators( stl,&it,&end ) ;
	/*
	 * gather an initial list of system and non system partitions by comparing entries in "/etc/fstab" and "/proc/partitions"
	 * fstab entries makes an initial list of system partitions.
	 * the difference btw list in "/proc/partitions" and "/etc/fstab" makes an initial list of non system partitions.
	 */
	while( it != end ){
		st = *it ;
		it++ ;
		if( StringStartsWith( st,"/" ) ){
			device = StringReplaceChar_1( st,0,' ','\0' ) ;
			system = StringListAppend( system,device ) ;
			StringListRemoveString( non_system,device ) ;
		}
	}

	StringListDelete( &stl ) ;

	/*
	 * read entried from "crypttab" and then add them to "system" if absent in that list and remove them from "non system" if present
	 * in that list
	 */
	p = zuluCryptGetPartitionFromCrypttab() ;
	if( p != StringListVoid ){
		StringListGetIterators( p,&it,&end ) ;
		while( it != end ){
			device = StringContent( *it ) ;
			it++ ;
			StringListAppendIfAbsent( system,device ) ;
			StringListRemoveIfPresent( non_system,device ) ;
		}
		StringListDelete( &p ) ;
	}

	/*
	 * read entried from "zuluCrypt-system" and then add them to "system" if absent in that list and remove them from "non system" if present
	 * in that list
	 */
	p = zuluCryptGetPartitionFromConfigFile( "/etc/zuluCrypt-system" ) ;
	if( p == StringListVoid ){
		/*
		 * This is the new path since zuluCrypt 4.6.9
		 */
		p = zuluCryptGetPartitionFromConfigFile( "/etc/zuluCrypt/system_volumes.list" ) ;
	}
	if( p != StringListVoid ){
		StringListGetIterators( p,&it,&end ) ;
		while( it != end ){
			device = StringContent( *it ) ;
			it++ ;
			StringListAppendIfAbsent( system,device ) ;
			StringListRemoveIfPresent( non_system,device ) ;
		}
		StringListDelete( &p ) ;
	}

	/*
	 * At this point:
	 * "system" contains system devices gathered from fstab,zuluCrypt-system and crypttab
	 * "non_system" contains non system devices gathered from /proc/partitions minus system partitions.
	 */

	StringListGetIterators( non_system,&it,&end ) ;

	/*
	 * now we consult udev if enabled and we move partition in the "non system" list to "system" list if udev think they are system
	 */
	while( it != end ){
		e = StringContent( *it ) ;
		if( _zuluCryptCheckSYSifDeviceIsSystem( e ) ){
			StringListAppendIfAbsent( system,e ) ;
			StringListRemoveAt_1( non_system,it,&end ) ;
		}else{
			it++ ;
		}
	}

	/*
	 * Now we read from a config file that contains devices that are not to be considered system and remove them from
	 * the system list if present in that list and add them to non system list if absent in that list
	 */
	p = zuluCryptGetPartitionFromConfigFile( "/etc/zuluCrypt-nonsystem" ) ;
	if( p == StringListVoid ){
		/*
		 * This is the new path since zuluCrypt 4.6.9
		 */
		p = zuluCryptGetPartitionFromConfigFile( "/etc/zuluCrypt/nonsystem_volumes.list" ) ;
	}
	if( p != StringListVoid ){
		StringListGetIterators( p,&it,&end ) ;
		while( it != end ){
			device = StringContent( *it ) ;
			it++ ;
			StringListRemoveString( system,device ) ;
			StringListAppendIfAbsent( non_system,device ) ;
		}
		StringListDelete( &p ) ;
	}

	if( option == ZULUCRYPTsystemPartitions ){
		StringListDelete( &non_system ) ;
		return _remove_btfs_multiple_devices( system ) ;
	}else{
		StringListDelete( &system ) ;
		return _remove_btfs_multiple_devices( non_system ) ;
	}
}