]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Add rx security index enum
authorSimon Wilkinson <sxw@your-file-system.com>
Thu, 4 Feb 2010 15:09:34 +0000 (15:09 +0000)
committerDerrick Brashear <shadow@dementia.org>
Tue, 9 Feb 2010 17:07:09 +0000 (09:07 -0800)
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 <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
13 files changed:
src/aklog/klog.c
src/auth/authcon.c
src/bozo/bos.c
src/bucoord/ubik_db_if.c
src/ptserver/ptuser.c
src/rx/rx.h
src/rxkad/test/stress_c.c
src/ubik/uinit.c
src/uss/uss_vol.c
src/venus/afsio.c
src/viced/fsprobe.c
src/viced/host.c
src/viced/viced.c

index 8120c0f8e955fbeb58d16cf1102b7aee2e7b4be4..a5097783861815e64b5934934bb7ba0d0145e8d3 100644 (file)
@@ -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);
index 5f415a676f869ddbaf1f7507e707ed5e09d34c62..36b0670c5d869274d672a52e32f8f5721f0c291d 100644 (file)
@@ -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;
     }
index d3e67ac4db2682ad17a3e2e431c585a1cc75fde5..e8a82bd3cb3489c9e8f3f02e07c84209398add49 100644 (file)
@@ -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 =
index 3dfee3ddefbe67497bf50ed30ea1261bed6aee0b..dbf253bba1f164612d8193448a0b161c444121e0 100644 (file)
@@ -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();
 
index c4969699e90f986a7e78bd605f107444aae662fd..b3ee8be6a21b864e8d9c5da0af785f4b5106f4a1 100644 (file)
@@ -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);
index eb9699e5d2178671b27213245bf63b494330ae14..8f7908676f6f61758c137d9fbf7c03a17d598927 100644 (file)
@@ -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;
index a9a131a9dbe60059485961c0fd6712b4cc74b95a..a3e27aaa102828fbe1ae680c0904e7b026d4bafc 100644 (file)
@@ -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;
index bb609c4d72869e7d1f61078bb0faa7d7983563ac..24283ee945919db22d8ca593813632021860ef3d 100644 (file)
@@ -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);
index 595aae23bf2d0d35639f6d301c0aa6df58d04be5..109d2dd2fc5c565a54cb3e9a75886724213f4616 100644 (file)
@@ -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);
index e795e6bb0da658cf623cc2f2df7e6a8769e1eed1..400651bde679efa1aab23ed981856b48ee30336c 100644 (file)
@@ -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();
        }
     }
index ff2f5ee07778b17f0d2ba118af74c04283709b7e..f4e30f8c2d776098111e2f168e98493091a9b65f 100644 (file)
@@ -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] =
index 89efeb72cd4859efc076c8b613d26b3a134ac575..8796bddeeb41c690dcf349a1d716d1b60907fc60 100644 (file)
@@ -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!!! */
index 15e9c3f22ec5c613417b4150ed771ea27bd32c4c..c0245cf0f05c40fab4749e3593b02512e61d3602 100644 (file)
@@ -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;