[PATCH] support "instance" in client credentials GUI

Joe Buehler <[email protected]>
Newsgroups gmane.comp.file-systems.openafs.devel.win32
Organization Spirent Communications, Inc.
Message-ID <[email protected]>
The below patch appears to fix the problem of not being able to authenticate with
a userid of (e.g.) "jhpb.admin".  I don't think I am using kfw so that path needs
to be tested.

I know next to nothing about this -- the algorithm was lifted from klog.
-- 
Joe Buehler

Index: src/WINNT/client_creds/creds.cpp
===================================================================
RCS file: /cvs/openafs/src/WINNT/client_creds/creds.cpp,v
retrieving revision 1.5
diff -u -r1.5 creds.cpp
--- src/WINNT/client_creds/creds.cpp	20 Mar 2004 01:01:07 -0000	1.5
+++ src/WINNT/client_creds/creds.cpp	5 May 2004 13:51:25 -0000
@@ -43,6 +43,7 @@
     typedef int (*ktc_ListTokens_t)(int cellNum, int *cellNumP, struct ktc_principal *serverName);
     typedef int (*ktc_ForgetToken_t)(struct ktc_principal *server);
     typedef int (*ka_UserAuthenticateGeneral_t)(int flags, char *name, char *instance, char *realm, char *password, int lifetime, int *password_expiresP, int spare, char **reasonP);
+   typedef int (*ka_ParseLoginName_t)(char *login, char *name, char *inst, char *cell);
     typedef long (*cm_GetRootCellName_t)(char *namep);
  }

@@ -58,6 +59,7 @@
     ktc_ListTokens_t ktc_ListTokensP;
     ktc_ForgetToken_t ktc_ForgetTokenP;
     ka_UserAuthenticateGeneral_t ka_UserAuthenticateGeneralP;
+   ka_ParseLoginName_t ka_ParseLoginNameP;
     cm_GetRootCellName_t cm_GetRootCellNameP;
     } l;

@@ -68,6 +70,7 @@
  #define ktc_ListTokens (*l.ktc_ListTokensP)
  #define ktc_ForgetToken (*l.ktc_ForgetTokenP)
  #define ka_UserAuthenticateGeneral (*l.ka_UserAuthenticateGeneralP)
+#define ka_ParseLoginName (*l.ka_ParseLoginNameP)
  #define cm_GetRootCellName (*l.cm_GetRootCellNameP)


@@ -84,6 +87,7 @@
           l.ktc_ListTokensP = (ktc_ListTokens_t)GetProcAddress (l.hInstLibTokens, "ktc_ListTokens");
           l.ktc_ForgetTokenP = (ktc_ForgetToken_t)GetProcAddress (l.hInstLibTokens, "ktc_ForgetToken");
           l.ka_UserAuthenticateGeneralP = (ka_UserAuthenticateGeneral_t)GetProcAddress (l.hInstLibTokens, "ka_UserAuthenticateGeneral");
+         l.ka_ParseLoginNameP = (ka_ParseLoginName_t)GetProcAddress (l.hInstLibTokens, "ka_ParseLoginName");

           if (!l.initAFSDirPathP ||
               !l.ka_InitP ||
@@ -91,7 +95,8 @@
               !l.ktc_GetTokenP ||
               !l.ktc_ListTokensP ||
               !l.ktc_ForgetTokenP ||
-             !l.ka_UserAuthenticateGeneralP)
+             !l.ka_UserAuthenticateGeneralP ||
+             !l.ka_ParseLoginNameP)
              {
              FreeLibrary (l.hInstLibTokens);
              l.hInstLibTokens = NULL;
@@ -392,10 +397,18 @@

        int Expiration = 0;

+	  char  name[sizeof(szNameA)];
+	  char  instance[sizeof(szNameA)];
+	  char  cell[sizeof(szNameA)];
+	  name[0] = '\0';
+	  instance[0] = '\0';
+	  cell[0] = '\0';
+	  ka_ParseLoginName(szNameA, name, instance, cell);
+
        if ( KFW_is_available() )
-          rc = KFW_AFS_get_cred(szNameA, NULL, szCellA, szPasswordA, 0, &Result);
+          rc = KFW_AFS_get_cred(name, instance, szCellA, szPasswordA, 0, &Result);
        else
-          rc = ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION, szNameA, "", szCellA, szPasswordA, 0, &Expiration, 0, &Result);
+          rc = ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION, name, instance, szCellA, szPasswordA, 0, &Expiration, 0, &Result);
        }

     if (!Silent && rc != 0)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.