/* special CompFindUser routine that builds up a princ and then calls finduser on it. If found, returns char * to user string, otherwise returns NULL. The resulting string should be immediately copied to other storage prior to release of mutex. */ static int CompFindUser(struct afsconf_dir *adir, char *name, char *sep, char *inst, char *realm, struct rx_identity **identity) { static char fullname[MAXKTCNAMELEN + MAXKTCNAMELEN + MAXKTCREALMLEN + 3]; struct rx_identity *testId; /* always must have name */ if (!name || !name[0]) { return 0; } if (strlcpy(fullname, name, sizeof(fullname)) >= sizeof(fullname)) return 0; /* might have instance */ if (inst && inst[0]) { if (!sep || !sep[0]) { return 0; } if (strlcat(fullname, sep, sizeof(fullname)) >= sizeof(fullname)) return 0; if (strlcat(fullname, inst, sizeof(fullname)) >= sizeof(fullname)) return 0; } /* might have realm */ if (realm && realm[0]) { if (strlcat(fullname, "@", sizeof(fullname)) >= sizeof(fullname)) return 0; if (strlcat(fullname, realm, sizeof(fullname)) >= sizeof(fullname)) return 0; } testId = rx_identity_new(RX_ID_KRB4, fullname, fullname, strlen(fullname)); if (afsconf_IsSuperIdentity(adir, testId)) { if (identity) *identity = testId; else rx_identity_free(&testId); return 1; } rx_identity_free(&testId); return 0; }
static void testNewIterator(struct afsconf_dir *dir, int num, struct rx_identity *id) { struct rx_identity *fileId; ok((afsconf_GetNthIdentity(dir, num, &fileId) == 0), "Identity %d successfully returned", num); ok(rx_identity_match(fileId, id), "Identity %d matches", num); rx_identity_free(&fileId); }
int afsconf_GetNthUser(struct afsconf_dir *adir, afs_int32 an, char *abuffer, afs_int32 abufferLen) { struct rx_identity *identity; int code; code = GetNthIdentityOrUser(adir, an, &identity, 0); if (code == 0) { strlcpy(abuffer, identity->displayName, abufferLen); rx_identity_free(&identity); } return code; }
int afsconf_AddUser(struct afsconf_dir *adir, char *aname) { struct rx_identity *user; int code; user = rx_identity_new(RX_ID_KRB4, aname, aname, strlen(aname)); if (user == NULL) return ENOMEM; code = afsconf_AddIdentity(adir, user); rx_identity_free(&user); return code; }
int afsconf_DeleteUser(struct afsconf_dir *adir, char *name) { struct rx_identity *user; int code; user = rx_identity_new(RX_ID_KRB4, name, name, strlen(name)); if (!user) return ENOMEM; code = afsconf_DeleteIdentity(adir, user); rx_identity_free(&user); return code; }
int afsconf_GetNthUser(struct afsconf_dir *adir, afs_int32 an, char *abuffer, afs_int32 abufferLen) { struct rx_identity *identity; int code; code = GetNthIdentityOrUser(adir, an, &identity, 0); if (code == 0) { strlcpy(abuffer, identity->displayName, abufferLen); rx_identity_free(&identity); } if (code == -1) { /* The new functions use -1 to indicate EOF, but the old interface * uses 1 to indicate EOF. */ code = 1; } return code; }
afs_int32 afsconf_SuperUser(struct afsconf_dir *adir, struct rx_call *acall, char *namep) { struct rx_identity *identity; int ret; if (namep) { ret = afsconf_SuperIdentity(adir, acall, &identity); if (ret) { if (identity->kind == RX_ID_KRB4) { strlcpy(namep, identity->displayName, MAXKTCNAMELEN-1); } else { snprintf(namep, MAXKTCNAMELEN-1, "eName: %s", identity->displayName); } rx_identity_free(&identity); } } else { ret = afsconf_SuperIdentity(adir, acall, NULL); } return ret; }