For now, perm table does not set the thrid parameter to anything useful
Finally implemented the permanent permission tables using sqlite3. For now, performance wasn't a consideration. There are a lot of optimizations that could be made, like having prepared queries. The code remains fairly untested.