# File lib/puppet/util/selinux.rb, line 43 43: def get_selinux_default_context(file) 44: unless selinux_support? 45: return nil 46: end 47: # If the filesystem has no support for SELinux labels, return a default of nil 48: # instead of what matchpathcon would return 49: unless selinux_label_support?(file) 50: return nil 51: end 52: # If the file exists we should pass the mode to matchpathcon for the most specific 53: # matching. If not, we can pass a mode of 0. 54: begin 55: filestat = File.lstat(file) 56: mode = filestat.mode 57: rescue Errno::ENOENT 58: mode = 0 59: end 60: retval = Selinux.matchpathcon(file, mode) 61: if retval == -1 62: return nil 63: end 64: return retval[1] 65: end