From cd37fd33f70c2196ff64188e32ff759590cb3748 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Sun, 12 Jul 2009 11:26:03 -0700 Subject: [PATCH] Make ktc_curpag generally available ktc_curpag isn't specific to a Kerberos v4 environment, so move it outside the AFS_KERBEROS_ENV #ifdef. Add it to the auth.h header and to the exports from the shared libafsauthent. Reviewed-on: http://gerrit.openafs.org/64 Verified-by: Derrick Brashear Reviewed-by: Derrick Brashear --- src/auth/auth.p.h | 1 + src/auth/ktc.c | 102 +++++++++++++------------- src/shlibafsauthent/Makefile.in | 2 +- src/shlibafsauthent/libafsauthent.exp | 1 + src/shlibafsauthent/libafsauthent.map | 1 + 5 files changed, 55 insertions(+), 52 deletions(-) diff --git a/src/auth/auth.p.h b/src/auth/auth.p.h index 3d990ad76..6c00bc87a 100644 --- a/src/auth/auth.p.h +++ b/src/auth/auth.p.h @@ -31,6 +31,7 @@ int ktc_GetToken(struct ktc_principal *, struct ktc_token *, int ktc_ListTokens(int, int *, struct ktc_principal *); int ktc_ForgetToken(struct ktc_principal *); int ktc_ForgetAllTokens(void); +afs_uint32 ktc_curpag(void); #ifdef AFS_NT40_ENV diff --git a/src/auth/ktc.c b/src/auth/ktc.c index 6d2675093..3c4a2ffa0 100644 --- a/src/auth/ktc.c +++ b/src/auth/ktc.c @@ -920,6 +920,57 @@ ktc_OldPioctl(void) return rc; } +afs_uint32 +ktc_curpag(void) +{ + int code; + struct ViceIoctl iob; + afs_int32 pag; + + /* now setup for the pioctl */ + iob.in = NULL; + iob.in_size = 0; + iob.out = &pag; + iob.out_size = sizeof(afs_int32); + + code = PIOCTL(0, VIOC_GETPAG, &iob, 0); + if (code < 0) { +#if defined(AFS_AIX52_ENV) + code = getpagvalue("afs"); + if (code < 0 && errno == EINVAL) + code = 0; + return code; +#elif defined(AFS_AIX51_ENV) + return -1; +#else + gid_t groups[NGROUPS_MAX]; + afs_uint32 g0, g1; + afs_uint32 h, l, ret; + + if (getgroups(sizeof groups / sizeof groups[0], groups) < 2) + return 0; + + g0 = groups[0] & 0xffff; + g1 = groups[1] & 0xffff; + g0 -= 0x3f00; + g1 -= 0x3f00; + if (g0 < 0xc000 && g1 < 0xc000) { + l = ((g0 & 0x3fff) << 14) | (g1 & 0x3fff); + h = (g0 >> 14); + h = (g1 >> 14) + h + h + h; + ret = ((h << 28) | l); + /* Additional testing */ + if (((ret >> 24) & 0xff) == 'A') + return ret; + else + return -1; + } + return -1; +#endif + } + return pag; +} + #ifdef AFS_KERBEROS_ENV /* @@ -1613,57 +1664,6 @@ afs_tf_dest_tkt(void) return 0; } -afs_uint32 -ktc_curpag(void) -{ - int code; - struct ViceIoctl iob; - afs_int32 pag; - - /* now setup for the pioctl */ - iob.in = NULL; - iob.in_size = 0; - iob.out = &pag; - iob.out_size = sizeof(afs_int32); - - code = PIOCTL(0, VIOC_GETPAG, &iob, 0); - if (code < 0) { -#if defined(AFS_AIX52_ENV) - code = getpagvalue("afs"); - if (code < 0 && errno == EINVAL) - code = 0; - return code; -#elif defined(AFS_AIX51_ENV) - return -1; -#else - gid_t groups[NGROUPS_MAX]; - afs_uint32 g0, g1; - afs_uint32 h, l, ret; - - if (getgroups(sizeof groups / sizeof groups[0], groups) < 2) - return 0; - - g0 = groups[0] & 0xffff; - g1 = groups[1] & 0xffff; - g0 -= 0x3f00; - g1 -= 0x3f00; - if (g0 < 0xc000 && g1 < 0xc000) { - l = ((g0 & 0x3fff) << 14) | (g1 & 0x3fff); - h = (g0 >> 14); - h = (g1 >> 14) + h + h + h; - ret = ((h << 28) | l); - /* Additional testing */ - if (((ret >> 24) & 0xff) == 'A') - return ret; - else - return -1; - } - return -1; -#endif - } - return pag; -} - int ktc_newpag(void) { diff --git a/src/shlibafsauthent/Makefile.in b/src/shlibafsauthent/Makefile.in index 63575babf..986a34911 100644 --- a/src/shlibafsauthent/Makefile.in +++ b/src/shlibafsauthent/Makefile.in @@ -1,7 +1,7 @@ # API version. When something changes, increment as appropriate. # Ignore at your own risk. LIBAFSAUTHENTMAJOR=1 -LIBAFSAUTHENTMINOR=0 +LIBAFSAUTHENTMINOR=1 # Copyright 2000, International Business Machines Corporation and others. # All Rights Reserved. diff --git a/src/shlibafsauthent/libafsauthent.exp b/src/shlibafsauthent/libafsauthent.exp index b5f82474a..b7f34af4e 100644 --- a/src/shlibafsauthent/libafsauthent.exp +++ b/src/shlibafsauthent/libafsauthent.exp @@ -47,6 +47,7 @@ ktc_GetToken ktc_ListTokens ktc_OldPioctl ktc_SetToken +ktc_curpag ubik_Call ubik_Call_New ubik_CallIter diff --git a/src/shlibafsauthent/libafsauthent.map b/src/shlibafsauthent/libafsauthent.map index 7bf00c097..9dd026d94 100644 --- a/src/shlibafsauthent/libafsauthent.map +++ b/src/shlibafsauthent/libafsauthent.map @@ -57,6 +57,7 @@ ktc_ListTokens; ktc_OldPioctl; ktc_SetToken; + ktc_curpag; ubik_Call; ubik_Call_New; ubik_CallIter; -- 2.39.5