Fix permission checks

Change-Id: Iba4576760a287c28ed98d5a0755755130c6a638d