From d44da96287a7cb5c6a67fd7c18112b52a6180085 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 6 May 2004 15:19:19 +0000 Subject: [PATCH] afscreds-20040506 creds.cpp: add support for principal name instances to the Obtain Tokens function. Previously instances were not parsed. main.cpp: Fix the -M (renewMaps) option to always call DoMapShare() mounttab.cpp: When removing a drive mapping, remove the "active" entry from the afsdsbmt.ini file. --- src/WINNT/client_creds/creds.cpp | 19 ++++++++++++++++--- src/WINNT/client_creds/main.cpp | 3 +-- src/WINNT/client_creds/mounttab.cpp | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/WINNT/client_creds/creds.cpp b/src/WINNT/client_creds/creds.cpp index 7cf0c594c..40447fa22 100644 --- a/src/WINNT/client_creds/creds.cpp +++ b/src/WINNT/client_creds/creds.cpp @@ -46,6 +46,7 @@ extern "C" { 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 long (*cm_GetRootCellName_t)(char *namep); + typedef int (*ka_ParseLoginName_t)(char *login, char *name, char *inst, char *cell); } static struct l @@ -60,6 +61,7 @@ static struct l 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; @@ -85,6 +87,7 @@ BOOL Creds_OpenLibraries (void) l.ktc_GetTokenP = (ktc_GetToken_t)GetProcAddress (l.hInstLibTokens, "ktc_GetToken"); l.ktc_ListTokensP = (ktc_ListTokens_t)GetProcAddress (l.hInstLibTokens, "ktc_ListTokens"); l.ktc_ForgetTokenP = (ktc_ForgetToken_t)GetProcAddress (l.hInstLibTokens, "ktc_ForgetToken"); + l.ka_ParseLoginNameP = (ka_ParseLoginName_t)GetProcAddress (l.hInstLibTokens, "ka_ParseLoginName"); l.ka_UserAuthenticateGeneralP = (ka_UserAuthenticateGeneral_t)GetProcAddress (l.hInstLibTokens, "ka_UserAuthenticateGeneral"); if (!l.initAFSDirPathP || @@ -93,6 +96,7 @@ BOOL Creds_OpenLibraries (void) !l.ktc_GetTokenP || !l.ktc_ListTokensP || !l.ktc_ForgetTokenP || + !l.ka_ParseLoginNameP || !l.ka_UserAuthenticateGeneralP) { FreeLibrary (l.hInstLibTokens); @@ -397,13 +401,22 @@ int ObtainNewCredentials (LPCTSTR pszCell, LPCTSTR pszUser, LPCTSTR pszPassword, 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, szSmbNameA[0] ? szSmbNameA : NULL, &Result); + rc = KFW_AFS_get_cred(name, instance, szCellA, szPasswordA, 0, szSmbNameA[0] ? szSmbNameA : NULL, &Result); else if ( szSmbNameA[0] ) rc = ka_UserAuthenticateGeneral2(KA_USERAUTH_VERSION+KA_USERAUTH_AUTHENT_LOGON, - szNameA, "", szCellA, szPasswordA, szSmbNameA, 0, &Expiration, 0, &Result); + name, instance, szCellA, szPasswordA, szSmbNameA, 0, &Expiration, 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) diff --git a/src/WINNT/client_creds/main.cpp b/src/WINNT/client_creds/main.cpp index ce24a9bf9..8c80613cd 100644 --- a/src/WINNT/client_creds/main.cpp +++ b/src/WINNT/client_creds/main.cpp @@ -334,8 +334,7 @@ BOOL InitApp (LPSTR pszCmdLineA) { if ( IsDebuggerPresent() ) OutputDebugString("Renewing Drive Maps\n"); - TestAndDoMapShare(SERVICE_START_PENDING); - TestAndDoMapShare(SERVICE_RUNNING); + DoMapShare(); } if (fShow) { diff --git a/src/WINNT/client_creds/mounttab.cpp b/src/WINNT/client_creds/mounttab.cpp index fde31de52..1fb6d431e 100644 --- a/src/WINNT/client_creds/mounttab.cpp +++ b/src/WINNT/client_creds/mounttab.cpp @@ -229,7 +229,7 @@ void Mount_OnRemove (HWND hDlg) Mount_OnUpdate (hDlg); } - + WriteActiveMap(List.aDriveMap[ iDriveSel ].chDrive, FALSE ); FreeDriveMapList (&List); } } -- 2.39.5