mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-11-04 05:12:30 +00:00 
			
		
		
		
	probe-utils.pm: refactor switch statement
switch() is only available if explicitly declared. switch to a for block using elsif to return a value.
This commit is contained in:
		@@ -252,17 +252,20 @@ sub is_selinux_enable {
 | 
			
		||||
 | 
			
		||||
#------------------------------------------
 | 
			
		||||
sub is_selinux_enforcing {
 | 
			
		||||
    my $retval = 0;
 | 
			
		||||
    if (-e "/usr/sbin/getenforce") {
 | 
			
		||||
        my $enforce_mode = `/usr/sbin/getenforce`;
 | 
			
		||||
        chomp $enforce_mode;
 | 
			
		||||
        switch ($enforce_mode) {
 | 
			
		||||
          case "Disabled" { return 0; }
 | 
			
		||||
          case "Permissive" { return 0; }
 | 
			
		||||
          case "Enforcing" { return 1; }
 | 
			
		||||
          else { return 0; }
 | 
			
		||||
        for ($enforce_mode) {
 | 
			
		||||
          if    (/Disabled/)   { $retval = 0; }
 | 
			
		||||
          elsif (/Permissive/) { $retval = 0; }
 | 
			
		||||
          elsif (/Enforcing/)  { $retval = 1; }
 | 
			
		||||
          else { $retval = 0; }
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        return 0;
 | 
			
		||||
        $retval = 0;
 | 
			
		||||
    }
 | 
			
		||||
    return $retval;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#------------------------------------------
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user