u_int32_t sfsserv::authalloc (const sfsauth_cred *cp, u_int n) { u_int32_t authno; for (u_int i = 0; i < n; i++) { const sfsauth_cred &c = cp[i]; switch (c.type) { case SFS_UNIXCRED: case SFS_NOCRED: { if (!(authno = authnoalloc ())) return 0; if (c.type == SFS_UNIXCRED) { const sfs_unixcred &uc = *c.unixcred; authtab[authno] = authunixint_create ("localhost", uc.uid, uc.gid, uc.groups.size (), uc.groups.base ()); credtab[authno] = c; } else { authtab[authno] = authuint_create (authno); credtab[authno].set_type (SFS_NOCRED); } return authno; } default: break; } } return 0; }
u_int32_t client::authalloc (const sfsauth_cred *cp, u_int n) { u_int authno = sfsserv::authalloc (cp, n); if (keytab.size () <= authno) keytab.setsize (authno + 1); for (u_int i = 0; i < n; i++) { const sfsauth_cred &c = cp[i]; if (c.type == SFS_PKCRED) { if (!authno) { warn << "saw user credentials without any UNIXCRED\n"; if (!(authno = authnoalloc ())) return 0; if (keytab.size () <= authno) keytab.setsize (authno + 1); } warn << "saw user credentials (SFS_PKCRED)\n"; keytab[authno] = *c.pkhash; break; } } if (groupstab.size () <= authno) groupstab.setsize (authno + 1); for (u_int i = 0; i < n; i++) { const sfsauth_cred &c = cp[i]; if (c.type == SFS_GROUPSCRED) { if (!authno) { warn << "saw user credentials without any UNIXCRED\n"; if (!(authno = authnoalloc ())) return 0; if (groupstab.size () <= authno) groupstab.setsize (authno + 1); } warn << "saw user credentials (SFS_GROUPSCRED)\n"; groupstab[authno].setsize (c.groups->size ()); for (unsigned int i = 0; i < c.groups->size (); i++) groupstab[authno][i] = (*c.groups)[i]; break; } } return authno; }