From 95ae30c30d98a3219fd021e0ed83200c1b6c266f Mon Sep 17 00:00:00 2001 From: Mark Vitale Date: Wed, 22 May 2019 23:03:11 -0400 Subject: [PATCH] auth: eliminate pointless retries in ktc_ListTokensEx ktc_ListTokensEx is an iterator to provide the names of each cell for which a user has a token set. It does this by looking for the 1 through nth token set for a given user. However, as currently implemented, it always continues searching up to the 100x safety limit even when there are no more token sets for the user. Instead, return immediately when VIOC_GETTOK2 returns EDOM (no more tokens for this user). Introduced by commit a86ad262d2a8be36f43ab0885a84dde37ddfc464 'auth: Add the ktc_ListTokensEx function'. Change-Id: I880edc80fc6c5580e5919b74b0b561317a1455f0 Reviewed-on: https://gerrit.openafs.org/13598 Reviewed-by: Andrew Deason Tested-by: BuildBot Reviewed-by: Benjamin Kaduk --- src/auth/ktc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/auth/ktc.c b/src/auth/ktc.c index 34abc5e..0c24908 100644 --- a/src/auth/ktc.c +++ b/src/auth/ktc.c @@ -794,6 +794,9 @@ ktc_ListTokensEx(int prevIndex, int *newIndex, char **cellName) { code = PIOCTL(0, VIOC_GETTOK2, &iob, 0); + if (code == -1 && errno == EDOM) + return KTC_NOENT; /* no more tokens to be found */ + /* Can't use new pioctl, so must use old one */ if (code == -1 && errno == EINVAL) { struct ktc_principal server; -- 1.9.4