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