178fcea Fall back to /usr/lib/os-release when /etc/os-release is absent

Authored and Committed by Debarshi Ray 3 months ago
    Fall back to /usr/lib/os-release when /etc/os-release is absent
    
    It's not mandatory for /etc/os-release to be present.  The os-release(5)
    manual says [1]:
      The file /etc/os-release takes precedence over /usr/lib/os-release.
      Applications should check for the former, and exclusively use its data
      if it exists, and only fall back to /usr/lib/os-release if it is
      missing.
    
    A valid os-release(5) file is not expected to have any commands in it.
    Hence, there's no chance of a non-zero exit code from the last command
    inside /etc/os-release getting forwarded as the exit code of the attempt
    to source it [2], and getting misinterpreted as the file being absent.
    The /etc/os-release file is owned by root.  It's assumed that the root
    user knows what they are doing and has put in place a sane file.
    
    [1] https://www.freedesktop.org/software/systemd/man/os-release.html
    
    [2] https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.html
    
    https://pagure.io/fedora-autofirstboot/pull-request/4