If you drop the need for having the tickets only in memory, then you can drop a lot of C code: just kinit all the ccaches in the DIR and then let the Kerberos GSS mechanism take care of the rest.