memoize ensure_privilige function

There are multiple calls verifying same permissions again.