From: Jeffrey Altman Date: Thu, 6 May 2004 21:46:31 +0000 (+0000) Subject: afsd-20040506 X-Git-Tag: openafs-devel-1_3_64~28 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=d941303ccc06e2d5ee517d8f25f5b4e095e2ad2f;p=packages%2Fo%2Fopenafs.git afsd-20040506 Andrei provided a replacement for the pattern matching algorithm. It has been applied but the old version is still there and can be activated with a #define The KFW_AFS_get_cred() routine does not use the "instance" parameter so removed it. --- diff --git a/src/WINNT/afsd/afsd_init.c b/src/WINNT/afsd/afsd_init.c index 30b905c6b..8f428fe17 100644 --- a/src/WINNT/afsd/afsd_init.c +++ b/src/WINNT/afsd/afsd_init.c @@ -94,6 +94,12 @@ int cm_dnsEnabled = 1; char cm_NetBiosName[32]; +extern initUpperCaseTable(); +void afsd_initUpperCaseTable() +{ + initUpperCaseTable(); +} + void afsi_start() { @@ -211,6 +217,8 @@ int afsd_InitCM(char **reasonP) WSAStartup(0x0101, &WSAjunk); + afsd_initUpperCaseTable(); + /* setup osidebug server at RPC slot 1000 */ osi_LongToUID(1000, &debugID); code = osi_InitDebug(&debugID); diff --git a/src/WINNT/afsd/afskfw.c b/src/WINNT/afsd/afskfw.c index 38402c2af..d03dc24f7 100644 --- a/src/WINNT/afsd/afskfw.c +++ b/src/WINNT/afsd/afskfw.c @@ -1149,7 +1149,6 @@ KFW_import_ccache_data(void) int KFW_AFS_get_cred(char * username, - char * instance, char * cell, char * password, int lifetime, @@ -1174,11 +1173,7 @@ KFW_AFS_get_cred(char * username, if ( IsDebuggerPresent() ) { OutputDebugString("KFW_AFS_get_cred for token "); OutputDebugString(username); - if ( instance ) { - OutputDebugString("/"); - OutputDebugString(instance); - } - OutputDebugString("@"); + OutputDebugString(" in cell "); OutputDebugString(cell); OutputDebugString("\n"); } @@ -1204,8 +1199,8 @@ KFW_AFS_get_cred(char * username, } code = pkrb5_build_principal(ctx, &principal, strlen(realm), - realm, username, - (instance && instance[0]) ? instance : NULL, + realm, username, + NULL, NULL); code = KFW_get_ccache(ctx, principal, &cc); diff --git a/src/WINNT/afsd/afskfw.h b/src/WINNT/afsd/afskfw.h index d856013e0..995d038fb 100644 --- a/src/WINNT/afsd/afskfw.h +++ b/src/WINNT/afsd/afskfw.h @@ -49,7 +49,6 @@ int KFW_is_available(void); int KFW_AFS_destroy_tickets_for_cell(char *); int KFW_AFS_renew_expiring_tokens(void); int KFW_AFS_get_cred( char * username, - char * instance, char * cell, char * password, int lifetime, diff --git a/src/WINNT/afsd/afslogon.c b/src/WINNT/afsd/afslogon.c index 6fd8924f3..8cb927031 100644 --- a/src/WINNT/afsd/afslogon.c +++ b/src/WINNT/afsd/afslogon.c @@ -428,7 +428,7 @@ DWORD APIENTRY NPLogonNotify( if (ISLOGONINTEGRATED(LogonOption) && !ISHIGHSECURITY(LogonOption)) { if ( KFW_is_available() ) - code = KFW_AFS_get_cred(uname, "", cell, password, 0, uname, &reason); + code = KFW_AFS_get_cred(uname, cell, password, 0, uname, &reason); else code = ka_UserAuthenticateGeneral2(KA_USERAUTH_VERSION+KA_USERAUTH_AUTHENT_LOGON, uname, "", cell, password, uname, 0, &pw_exp, 0, @@ -447,7 +447,7 @@ DWORD APIENTRY NPLogonNotify( else if (ISLOGONINTEGRATED(LogonOption) && ISHIGHSECURITY(LogonOption)) { if ( KFW_is_available() ) - code = KFW_AFS_get_cred(uname, "", cell, password, 0, RandomName, &reason); + code = KFW_AFS_get_cred(uname, cell, password, 0, RandomName, &reason); else code = ka_UserAuthenticateGeneral2(KA_USERAUTH_VERSION+KA_USERAUTH_AUTHENT_LOGON, uname, "", cell, password,RandomName, 0, &pw_exp, 0, diff --git a/src/WINNT/afsd/smb3.c b/src/WINNT/afsd/smb3.c index 48939ee2e..1af141041 100644 --- a/src/WINNT/afsd/smb3.c +++ b/src/WINNT/afsd/smb3.c @@ -1745,6 +1745,71 @@ long smb_ApplyV3DirListPatches(cm_scache_t *dscp, return code; } +#ifndef USE_OLD_MATCHING +// char table for case insensitive comparison +char mapCaseTable[256]; + +VOID initUpperCaseTable(VOID) +{ + int i; + for (i = 0; i < 256; ++i) + mapCaseTable[i] = toupper(i); + // make '"' match '.' + mapCaseTable[(int)'"'] = toupper('.'); +} + +// Compare 'pattern' (containing metacharacters '*' and '?') with the file +// name 'name'. +// Note : this procedure works recursively calling itself. +// Parameters +// PSZ pattern : string containing metacharacters. +// PSZ name : file name to be compared with 'pattern'. +// Return value +// BOOL : TRUE/FALSE (match/mistmatch) + +BOOL szWildCardMatchFileName(PSZ pattern, PSZ name) { + PSZ pename; // points to the last 'name' character + PSZ p; + pename = name + strlen(name) - 1; + while (*name) { + switch (*pattern) { + case '?': + if (*(++pattern) != '<' || *(++pattern) != '*') { + if (*name == '.') return FALSE; + ++name; + break; + } /* endif */ + case '<': + case '*': + while ((*pattern == '<') || (*pattern == '*') || (*pattern == '?')) ++pattern; + if (!*pattern) return TRUE; + for (p = pename; p >= name; --p) { + if ((mapCaseTable[*p] == mapCaseTable[*pattern]) && + szWildCardMatchFileName(pattern + 1, p + 1)) + return TRUE; + } /* endfor */ + return FALSE; + default: + if (mapCaseTable[*name] != mapCaseTable[*pattern]) return FALSE; + ++pattern, ++name; + break; + } /* endswitch */ + } /* endwhile */ return !*pattern; +} + +/* do a case-folding search of the star name mask with the name in namep. + * Return 1 if we match, otherwise 0. + */ +int smb_V3MatchMask(char *namep, char *maskp, int flags) +{ + /* make sure we only match 8.3 names, if requested */ + if ((flags & CM_FLAG_8DOT3) && !cm_Is8Dot3(namep)) + return 0; + + return szWildCardMatchFileName(maskp, namep) ? 1:0; +} + +#else /* USE_OLD_MATCHING */ /* do a case-folding search of the star name mask with the name in namep. * Return 1 if we match, otherwise 0. */ @@ -1882,6 +1947,7 @@ int smb_V3MatchMask(char *namep, char *maskp, int flags) } } } +#endif /* USE_OLD_MATCHING */ long smb_ReceiveTran2SearchDir(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *opx) {