Fix permission issues when writting to lib or logs