library/src/filesystem/BP-FilesystemRegistryPolicyCheckValidators.cc
// Check a file against the symlink policy.
Check a file against the symlink policy.
Check a file against the symlink policy .
BP_BOOL BP_FSRegCheckFileAgainstCrawlSymlinkPolicy
(
		BP_FSREG_CHECK_FILE_FUNC_PARMS
)
{
	BP_FSREG_CHECK_POLICY_FUNC_ENTRY_RUN_NULL_CHECKS(BP_FALSE);
	if(file_dirent->d_type == DT_LNK)
		policy_analysis_inout->is_symlink = BP_TRUE;
	BP_HASH_TABLE_ENTER_CRITICAL_SECTION(fs_reg->hreg);
	if(BP_FLAG_IS_SET(fs_reg_pol->symlink_policy, BP_FS_SYMLINK_POLICY_FLAG_IGNORE_ALL) && policy_analysis_inout->is_symlink)
	{
		policy_analysis_inout->symlink_ignore_all_match = BP_TRUE;
	}
	if(BP_FLAG_IS_SET(fs_reg_pol->symlink_policy, BP_FS_SYMLINK_POLICY_FLAG_ONLY) && policy_analysis_inout->is_symlink)
	{
		policy_analysis_inout->symlink_only_match = BP_TRUE;
	}
	if(BP_FLAG_IS_SET(fs_reg_pol->symlink_policy, BP_FS_SYMLINK_POLICY_FLAG_FOLLOW_DIRECTORIES) && policy_analysis_inout->is_symlink)
	{
		if(BP_STAT_MODE_IS_IFDIR(file_stat->st_mode))
			policy_analysis_inout->symlink_follow_directories_match = BP_TRUE;
	}
	if(policy_analysis_inout->is_symlink)
	{
		if(BP_STAT_MODE_IS_IFDIR(file_stat->st_mode))
			policy_analysis_inout->symlink_target_is_directory = BP_TRUE;
		if(BP_STAT_MODE_IS_IREG(file_stat->st_mode))
			policy_analysis_inout->symlink_target_is_file = BP_TRUE;
	}
	BP_HASH_TABLE_LEAVE_CRITICAL_SECTION(fs_reg->hreg);
	return BP_TRUE;
}
BP_BOOL BP_FSRegCheckFileAgainstCrawlSymlinkPolicy ( BP_FSREG_CHECK_FILE_FUNC_PARMS ) { BP_FSREG_CHECK_POLICY_FUNC_ENTRY_RUN_NULL_CHECKS ( BP_FALSE ) ; if ( file_dirent -> d_type == DT_LNK ) policy_analysis_inout -> is_symlink = BP_TRUE ; BP_HASH_TABLE_ENTER_CRITICAL_SECTION ( fs_reg -> hreg ) ; if ( BP_FLAG_IS_SET ( fs_reg_pol -> symlink_policy , BP_FS_SYMLINK_POLICY_FLAG_IGNORE_ALL ) && policy_analysis_inout -> is_symlink ) { policy_analysis_inout -> symlink_ignore_all_match = BP_TRUE ; } if ( BP_FLAG_IS_SET ( fs_reg_pol -> symlink_policy , BP_FS_SYMLINK_POLICY_FLAG_ONLY ) && policy_analysis_inout -> is_symlink ) { policy_analysis_inout -> symlink_only_match = BP_TRUE ; } if ( BP_FLAG_IS_SET ( fs_reg_pol -> symlink_policy , BP_FS_SYMLINK_POLICY_FLAG_FOLLOW_DIRECTORIES ) && policy_analysis_inout -> is_symlink ) { if ( BP_STAT_MODE_IS_IFDIR ( file_stat -> st_mode ) ) policy_analysis_inout -> symlink_follow_directories_match = BP_TRUE ; } if ( policy_analysis_inout -> is_symlink ) { if ( BP_STAT_MODE_IS_IFDIR ( file_stat -> st_mode ) ) policy_analysis_inout -> symlink_target_is_directory = BP_TRUE ; if ( BP_STAT_MODE_IS_IREG ( file_stat -> st_mode ) ) policy_analysis_inout -> symlink_target_is_file = BP_TRUE ; } BP_HASH_TABLE_LEAVE_CRITICAL_SECTION ( fs_reg -> hreg ) ; return BP_TRUE ; }
Check a file against the symlink policy.
Check a file against the symlink policy .
// run initial null parameter checks // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Check if Symlink %%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // type must be link data directly from opendir/readdir // enter critical section before creating new record // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Run Individual Flag Checks %%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // BP_FS_SYMLINK_POLICY_FLAG_IGNORE_ALL         = 1, // BP_FS_SYMLINK_POLICY_FLAG_ONLY               = 2, // BP_FS_SYMLINK_POLICY_FLAG_FOLLOW_DIRECTORIES = 3 // run ignore symlink check // set ignore all match // only check // set ignore all match // run follow directories check // if the file stat (NOT LSTAT) st_mode is a directory, set the match here // if it's a symlink, we have to mark whatever the symlink points to // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Unlock and Exit %%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // unlock and exit // return indicating true (all checks passed ok)