From d5622d03196762bd8a60404fea98b4bb044e076d Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Thu, 4 Feb 2010 15:09:34 +0000 Subject: [PATCH 1/1] Add rx security index enum Add a enumerated type for rx security indexes, initially containing the values reserved for null, kad, gk, and k5. Start to use this type, and related names, rather than hard values throughout the code. Change-Id: Ic71e5da28b4270abf7b6688b2c6438f17268f1da Reviewed-on: http://gerrit.openafs.org/1242 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/aklog/klog.c | 4 ++-- src/auth/authcon.c | 14 +++++++------- src/bozo/bos.c | 4 ++-- src/bucoord/ubik_db_if.c | 8 ++++---- src/ptserver/ptuser.c | 4 ++-- src/rx/rx.h | 7 +++++++ src/rxkad/test/stress_c.c | 4 ++-- src/ubik/uinit.c | 5 +++-- src/uss/uss_vol.c | 2 +- src/venus/afsio.c | 4 ++-- src/viced/fsprobe.c | 4 ++-- src/viced/host.c | 6 +++--- src/viced/viced.c | 3 ++- 13 files changed, 39 insertions(+), 30 deletions(-) diff --git a/src/aklog/klog.c b/src/aklog/klog.c index 8120c0f..a509778 100644 --- a/src/aklog/klog.c +++ b/src/aklog/klog.c @@ -222,7 +222,7 @@ whoami(struct ktc_token *atoken, struct ktc_principal *aclient, int *vicep) { - int scIndex; + rx_securityIndex scIndex; int code; int i; struct ubik_client *ptconn = 0; @@ -234,7 +234,7 @@ whoami(struct ktc_token *atoken, memset(lnames, 0, sizeof *lnames); memset(lids, 0, sizeof *lids); - scIndex = 2; + scIndex = RX_SECIDX_KAD; sc = rxkad_NewClientSecurityObject(rxkad_auth, &atoken->sessionKey, atoken->kvno, atoken->ticketLen, atoken->ticket); diff --git a/src/auth/authcon.c b/src/auth/authcon.c index 5f415a6..36b0670 100644 --- a/src/auth/authcon.c +++ b/src/auth/authcon.c @@ -58,7 +58,7 @@ QuickAuth(struct rx_securityClass **astr, afs_int32 *aindex) register struct rx_securityClass *tc; tc = rxnull_NewClientSecurityObject(); *astr = tc; - *aindex = 0; + *aindex = RX_SECIDX_NULL; return 0; } @@ -77,7 +77,7 @@ afsconf_ServerAuth(void *arock, rxkad_NewServerSecurityObject(0, adir, afsconf_GetKey, NULL); if (tclass) { *astr = tclass; - *aindex = 2; /* kerberos security index */ + *aindex = RX_SECIDX_KAD; UNLOCK_GLOBAL_MUTEX; return 0; } else { @@ -134,7 +134,7 @@ GenericAuth(struct afsconf_dir *adir, rxkad_NewClientSecurityObject(enclevel, &session, kvno, ticketLen, tbuffer); *astr = tclass; - *aindex = 2; /* kerberos security index */ + *aindex = RX_SECIDX_KAD; return 0; } @@ -207,7 +207,7 @@ afsconf_ClientAuthToken(struct afsconf_cell *info, afs_int32 code; *sc = NULL; - *scIndex = 0; + *scIndex = RX_SECIDX_NULL; strcpy(sname.cell, info->name); sname.instance[0] = 0; @@ -230,7 +230,7 @@ afsconf_ClientAuthToken(struct afsconf_cell *info, ttoken.kvno, ttoken.ticketLen, ttoken.ticket); - *scIndex = 2; + *scIndex = RX_SECIDX_KAD; if (expires) *expires = ttoken.endTime; } @@ -314,7 +314,7 @@ afsconf_PickClientSecObj(struct afsconf_dir *dir, afsconf_secflags flags, afs_int32 code = 0; *sc = NULL; - *scIndex = 0; + *scIndex = RX_SECIDX_NULL; if (expires) expires = 0; @@ -355,7 +355,7 @@ afsconf_PickClientSecObj(struct afsconf_dir *dir, afsconf_secflags flags, } if (*sc == NULL) { *sc = rxnull_NewClientSecurityObject(); - *scIndex = 0; + *scIndex = RX_SECIDX_NULL; if (expires) *expires = NEVERDATE; } diff --git a/src/bozo/bos.c b/src/bozo/bos.c index d3e67ac..e8a82bd 100644 --- a/src/bozo/bos.c +++ b/src/bozo/bos.c @@ -177,7 +177,7 @@ GetConn(struct cmd_syndesc *as, int aencrypt) struct afsconf_dir *tdir = NULL; afsconf_secflags secFlags; struct rx_securityClass *sc; - int scIndex; + afs_int32 scIndex; hostname = as->parms[0].items->data; th = hostutil_GetHostByName(hostname); @@ -218,7 +218,7 @@ GetConn(struct cmd_syndesc *as, int aencrypt) exit(1); } - if (scIndex == 0) + if (scIndex == RX_SECIDX_NULL) fprintf(stderr, "bos: running unauthenticated\n"); tconn = diff --git a/src/bucoord/ubik_db_if.c b/src/bucoord/ubik_db_if.c index 3dfee3d..dbf253b 100644 --- a/src/bucoord/ubik_db_if.c +++ b/src/bucoord/ubik_db_if.c @@ -799,7 +799,7 @@ vldbClientInit(int noAuthFlag, int localauth, char *cellName, afs_int32 code = 0; struct afsconf_dir *acdir; struct rx_securityClass *sc; - afs_int32 i, scIndex = 0; /* Index of Rx security object - noauth */ + afs_int32 i, scIndex = RX_SECIDX_NULL; struct afsconf_cell info; struct rx_connection *serverconns[VLDB_MAXSERVERS]; afsconf_secflags secFlags; @@ -833,7 +833,7 @@ vldbClientInit(int noAuthFlag, int localauth, char *cellName, afs_com_err(whoami, code, "(configuring connection security)"); ERROR(BC_NOCELLCONFIG); } - if (scIndex == 0 && !noAuthFlag) + if (scIndex == RX_SECIDX_NULL && !noAuthFlag) afs_com_err(whoami, 0, "Can't get tokens - running unauthenticated"); /* tell UV module about default authentication */ @@ -907,7 +907,7 @@ udbClientInit(int noAuthFlag, int localauth, char *cellName) afs_com_err(whoami, code, "(configuring connection security)"); ERROR(BC_NOCELLCONFIG); } - if (&udbHandle.uh_scIndex == 0 && !noAuthFlag) + if (&udbHandle.uh_scIndex == RX_SECIDX_NULL && !noAuthFlag) afs_com_err(whoami, 0, "Can't get tokens - running unauthenticated"); if (info.numServers > MAXSERVERS) { @@ -1166,7 +1166,7 @@ udbLocalInit(void) return (-1); } - udbHandle.uh_scIndex = RX_SCINDEX_NULL; + udbHandle.uh_scIndex = RX_SECIDX_NULL; udbHandle.uh_secobj = (struct rx_securityClass *) rxnull_NewClientSecurityObject(); diff --git a/src/ptserver/ptuser.c b/src/ptserver/ptuser.c index c496969..b3ee8be 100644 --- a/src/ptserver/ptuser.c +++ b/src/ptserver/ptuser.c @@ -197,10 +197,10 @@ pr_Initialize(IN afs_int32 secLevel, IN const char *confDir, IN char *cell) if (sc == NULL) { sc = rxnull_NewClientSecurityObject(); - scIndex = 0; + scIndex = RX_SECIDX_NULL; } - if ((scIndex == 0) && (secLevel != 0)) + if ((scIndex == RX_SECIDX_NULL) && (secLevel != 0)) fprintf(stderr, "%s: Could not get afs tokens, running unauthenticated\n", whoami); diff --git a/src/rx/rx.h b/src/rx/rx.h index eb9699e..8f79086 100644 --- a/src/rx/rx.h +++ b/src/rx/rx.h @@ -706,6 +706,13 @@ struct rx_ackPacket { /* this shud be equal to VRESTARTING ( util/errors.h ) for old clients to work */ #define RX_RESTARTING (-100) +typedef enum { + RX_SECIDX_NULL = 0, + RX_SECIDX_KAD = 2, + RX_SECIDX_GK = 4, + RX_SECIDX_K5 = 5, +} rx_securityIndex; + struct rx_securityObjectStats { char type; /* 0:unk 1:null,2:vab 3:kad */ char level; diff --git a/src/rxkad/test/stress_c.c b/src/rxkad/test/stress_c.c index a9a131a..a3e27aa 100644 --- a/src/rxkad/test/stress_c.c +++ b/src/rxkad/test/stress_c.c @@ -1301,12 +1301,12 @@ rxkst_StartClient(parms) rxkad_NewClientSecurityObject(parms->authentication, &Ksession, kvno, ticketLen, ticket); assert(sc); - scIndex = 2; /* kerberos security index */ + scIndex = RX_SECIDX_KAD; } else { /* unauthenticated connection */ sc = rxnull_NewClientSecurityObject(); assert(sc); - scIndex = 0; /* null security index */ + scIndex = RX_SECIDX_NULL; } code = 0; diff --git a/src/ubik/uinit.c b/src/ubik/uinit.c index bb609c4..24283ee 100644 --- a/src/ubik/uinit.c +++ b/src/ubik/uinit.c @@ -52,7 +52,8 @@ ugen_ClientInit(int noAuthFlag, const char *confDir, char *cellName, afs_int32 s afs_int32 maxservers, char *serviceid, afs_int32 deadtime, afs_uint32 server, afs_uint32 port, afs_int32 usrvid) { - afs_int32 code, scIndex, secFlags, i; + afs_int32 code, secFlags, i; + afs_int32 scIndex; struct afsconf_cell info; struct afsconf_dir *tdir; struct rx_securityClass *sc; @@ -95,7 +96,7 @@ ugen_ClientInit(int noAuthFlag, const char *confDir, char *cellName, afs_int32 s fprintf(stderr, "%s: can't create client security object", funcName); return -1; } - if (scIndex == 0) { + if (scIndex == RX_SECIDX_NULL) { fprintf(stderr, "%s: Could not get afs tokens, running unauthenticated.\n", funcName); diff --git a/src/uss/uss_vol.c b/src/uss/uss_vol.c index 595aae2..109d2dd 100644 --- a/src/uss/uss_vol.c +++ b/src/uss/uss_vol.c @@ -168,7 +168,7 @@ InitThisModule(int a_noAuthFlag, char *a_confDir, char *a_cellName) printf("%s: Can't create client security object\n", uss_whoami); exit(1); } - if (scIndex == 0 && !a_noAuthFlag) { + if (scIndex == RX_SECIDX_NULL && !a_noAuthFlag) { fprintf(stderr, "%s: Couldn't get AFS tokens, running unauthenticated.\n", uss_whoami); diff --git a/src/venus/afsio.c b/src/venus/afsio.c index e795e6b..400651b 100644 --- a/src/venus/afsio.c +++ b/src/venus/afsio.c @@ -286,7 +286,7 @@ HandleLocalAuth(struct rx_securityClass **sc, afs_int32 *scIndex) afs_int32 code; *sc = NULL; - *scIndex = 0; + *scIndex = RX_SECIDX_NULL; tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH); if (!tdir) { @@ -1429,7 +1429,7 @@ FindCell(char *cellName) #endif code = afsconf_ClientAuthToken(&p->info, 0, &p->sc, &p->scIndex); if (code) { - p->scIndex = 0; + p->scIndex = RX_SECIDX_NULL; p->sc = rxnull_NewClientSecurityObject(); } } diff --git a/src/viced/fsprobe.c b/src/viced/fsprobe.c index ff2f5ee..f4e30f8 100644 --- a/src/viced/fsprobe.c +++ b/src/viced/fsprobe.c @@ -29,7 +29,7 @@ afs_int32 pxclient_Initialize(int auth, afs_int32 serverAddr) { afs_int32 code; - afs_int32 scIndex; + rx_securityIndex scIndex; struct rx_securityClass *sc; code = rx_Init(htons(2115) /*0 */ ); @@ -37,7 +37,7 @@ pxclient_Initialize(int auth, afs_int32 serverAddr) fprintf(stderr, "pxclient_Initialize: Could not initialize rx.\n"); return code; } - scIndex = 0; + scIndex = RX_SECIDX_NULL; rx_SetRxDeadTime(50); sc = rxnull_NewClientSecurityObject(); serverconns[0] = diff --git a/src/viced/host.c b/src/viced/host.c index 89efeb7..8796bdd 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -309,13 +309,13 @@ hpr_Initialize(struct ubik_client **uclient) if (code) ViceLog(0, ("hpr_Initialize: clientauthsecure returns %d %s (so trying noauth)", code, afs_error_message(code))); if (code) - scIndex = 0; /* use noauth */ + scIndex = RX_SECIDX_NULL; } else { afsconf_ClientAuthToken(&info, 0, &sc, &scIndex, NULL); } - if ((scIndex == 0) && (sc == NULL)) + if ((scIndex == RX_SECIDX_NULL) && (sc == NULL)) sc = rxnull_NewClientSecurityObject(); - if (scIndex == 0) + if (scIndex == RX_SECIDX_NULL) ViceLog(0, ("hpr_Initialize: Could not get afs tokens, running unauthenticated. [%d]", code)); memset(serverconns, 0, sizeof(serverconns)); /* terminate list!!! */ diff --git a/src/viced/viced.c b/src/viced/viced.c index 15e9c3f..c0245cf 100644 --- a/src/viced/viced.c +++ b/src/viced/viced.c @@ -1608,7 +1608,8 @@ struct ubik_client *cstruct; afs_int32 vl_Initialize(const char *confDir) { - afs_int32 code, scIndex = 0, i; + afs_int32 code, i; + afs_int32 scIndex = RX_SECIDX_NULL; struct afsconf_dir *tdir; struct rx_securityClass *sc; struct afsconf_cell info; -- 1.9.4