Fix issue #1200: Restore ACL functionality

Uses os_* functions to restore ACL functionality, addresses #1200 
If `*mode == -1`, the memory will not be freed.