From: Simon Wilkinson Date: Sat, 11 Sep 2010 09:17:12 +0000 (+0100) Subject: tokens: Use the new tokens interface X-Git-Tag: upstream/1.8.0_pre1^2~4808 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=84d28ecf9d68852152cad1039042e10e38075a29;p=packages%2Fo%2Fopenafs.git tokens: Use the new tokens interface Change tokens so that it will use the new tokens interface. Note that this changes the output from the tokens command. Change-Id: If15d7d439b86a89afcafafe65d304324a186b8d3 Reviewed-on: http://gerrit.openafs.org/2749 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/src/log/tokens.c b/src/log/tokens.c index 826ffa1b4..ed91d956d 100644 --- a/src/log/tokens.c +++ b/src/log/tokens.c @@ -22,6 +22,7 @@ #include #include /*time(), ctime() */ #include +#include #include @@ -46,8 +47,10 @@ main(int argc, char **argv) time_t tokenExpireTime; /*When token expires */ char *expireString; /*Char string of expiration time */ char UserName[MAXKTCNAMELEN * 2 + 2]; /*Printable user name */ - struct ktc_principal serviceName, clientName; /* service name for ticket */ + char *cellName; + struct ktc_principal clientName; /* service name for ticket */ struct ktc_token token; /* the token we're printing */ + struct ktc_setTokenData *tokenSet; #ifdef AFS_AIX32_ENV /* @@ -78,47 +81,47 @@ main(int argc, char **argv) cellNum = 0; current_time = time(0); while (1) { - rc = ktc_ListTokens(cellNum, &cellNum, &serviceName); + rc = ktc_ListTokensEx(cellNum, &cellNum, &cellName); if (rc) { /* only error is now end of list */ printf(" --End of list--\n"); break; } else { /* get the ticket info itself */ - rc = ktc_GetToken(&serviceName, &token, sizeof(token), - &clientName); + rc = ktc_GetTokenEx(cellName, &tokenSet); if (rc) { printf - ("tokens: failed to get token info for service %s.%s.%s (code %d)\n", - serviceName.name, serviceName.instance, serviceName.cell, - rc); + ("tokens: failed to get token info for cell %s (code %d)\n", + cellName, rc); continue; } - tokenExpireTime = token.endTime; - strcpy(UserName, clientName.name); - if (clientName.instance[0] != 0) { - strcat(UserName, "."); - strcat(UserName, clientName.instance); - } - if (UserName[0] == 0) - printf("Tokens"); - else if (strncmp(UserName, "AFS ID", 6) == 0) { - printf("User's (%s) tokens", UserName); - } else if (strncmp(UserName, "Unix UID", 8) == 0) { - printf("Tokens"); - } else - printf("User %s's tokens", UserName); - printf(" for %s%s%s@%s ", serviceName.name, - serviceName.instance[0] ? "." : "", serviceName.instance, - serviceName.cell); - if (tokenExpireTime <= current_time) - printf("[>> Expired <<]\n"); - else { - expireString = ctime(&tokenExpireTime); - expireString += 4; /*Move past the day of week */ - expireString[12] = '\0'; - printf("[Expires %s]\n", expireString); + rc = token_extractRxkad(tokenSet, &token, NULL, &clientName); + if (rc == 0) { + tokenExpireTime = token.endTime; + strcpy(UserName, clientName.name); + if (clientName.instance[0] != 0) { + strcat(UserName, "."); + strcat(UserName, clientName.instance); + } + if (UserName[0] == 0) + printf("rxkad Tokens"); + else if (strncmp(UserName, "AFS ID", 6) == 0) { + printf("User's (%s) rxkad tokens", UserName); + } else if (strncmp(UserName, "Unix UID", 8) == 0) { + printf("RxkadTokens"); + } else + printf("User %s's rxkad tokens", UserName); + printf(" for %s ", cellName); + if (tokenExpireTime <= current_time) + printf("[>> Expired <<]\n"); + else { + expireString = ctime(&tokenExpireTime); + expireString += 4; /*Move past the day of week */ + expireString[12] = '\0'; + printf("[Expires %s]\n", expireString); + } } + token_FreeSet(&tokenSet); } } exit(0);