From 2cd573ce0a532d2db209225e183c6f4c926ae997 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Wed, 11 Jul 2001 18:25:56 +0000 Subject: [PATCH] libadmin-kas-bugfixes-20010711 fixes for the following report from "Jeremy Stribling" - In the GetPrincipalLockStatus function, an attempt is made to set the lockedUntil variable to the minimum locked value for that principal among all servers. However, lockedUntil is set to 0 immediately before this, and so all attempts to find a locked value less than it fails, and so lockedUntil always comes out of that function as 0. - Also in the GetPrincipalLockStatus function, if the principal is locked out according to all servers, then the main loop will exit when ubik_CallIter returns the UNOSERVERS error code. But, since the return code for GetPrincipalLockStatus is set to 1 if and only if ubik_CallIter returns an error code of 0, this results in an return code of 0 being returned for GetPrincipalLockStatus when in reality no error occured. - A similar problem occurs in the kas_PrincipalUnlock function. If the principal is not currently locked out of any server, ubik_CallIter will iterate through all servers and return a UNOSERVERS error code. Again, in this case the return code of kas_PrincipalUnlock will not be set to 1 and an error will be indicated even though no error occured. - In kas_PrincipalKeySet, the return code is never set to 1, even when it completes successfully, so it seems that an error always occurs when calling this function. --- src/libadmin/kas/afs_kasAdmin.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libadmin/kas/afs_kasAdmin.c b/src/libadmin/kas/afs_kasAdmin.c index 76caad9f0..cb76959a6 100644 --- a/src/libadmin/kas/afs_kasAdmin.c +++ b/src/libadmin/kas/afs_kasAdmin.c @@ -665,6 +665,7 @@ static int GetPrincipalLockStatus( afs_status_t tst = 0; unsigned int locked; int count=0; + int once = 0; /* * Validate input arguments and make rpc. @@ -714,8 +715,9 @@ static int GetPrincipalLockStatus( &locked, 0, 0, 0, 0); if (tst == 0) { if (locked) { - if (locked < *lockedUntil) { + if ((locked < *lockedUntil) || !once) { *lockedUntil = locked; + once++; } } } @@ -728,7 +730,7 @@ static int GetPrincipalLockStatus( if ((tst == 0) && (locked == 0)) { *lockedUntil = 0; } - if (tst == 0) { + if ((tst == 0) || (tst == UNOSERVERS)) { rc = 1; } @@ -1145,6 +1147,9 @@ int ADMINAPI kas_PrincipalKeySet( if (tst) { goto fail_kas_PrincipalKeySet; } + + /* If we failed to fail we must have succeeded */ + rc = 1; fail_kas_PrincipalKeySet: @@ -1286,7 +1291,7 @@ int ADMINAPI kas_PrincipalUnlock( } } while (tst != UNOSERVERS); - if (tst == 0) { + if ((tst == 0) || (tst == UNOSERVERS)){ rc = 1; } -- 2.39.5