Checking permissions with access before open creates a time-of-check to time-of-use race.
Open the file first and check permissions on the resulting descriptor with fstat.