1.0

Table Of Contents
CHAPTER 14 Understanding Policies
251
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
char *name;
char *keydata;
} UserListType;
static UserListType userList[] = {
{"charlie", "E1C4F612135B4D98A33B2C9BD595025D"},
{"kathy", "C79AFFEF773D61225751C2566858DB08"},
{"beth", "05B169B439B26AAB2EA4F755B7E3800C"},
{"ernie", "8CE63D4AA2068BD8AFF2D1B05F3495A5"},
{"bert", "172B1619B2EFBE0E4F381AA1C428F049"},
NULL
};
int
main(int argc,
char *argv[])
{
char *username;
int counter;
int result = 1;
/* Get the username from the env. var TEST_USERNAME */
username = getenv("TEST_USERNAME");
if (username == NULL) {
/* No user specified, exit with an error */
fprintf(stderr, "TEST_USERNAME not set\n");
goto exit;
}
counter = 0;
while (userList[counter].name != NULL) {
if (strcmp(userList[counter].name, username) == 0) {
/* Found the right user; print their key */
printf("%s", userList[counter].keydata);
result = 0;
goto exit;
}