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.
char cm_NetBiosName[32];
+extern initUpperCaseTable();
+void afsd_initUpperCaseTable()
+{
+ initUpperCaseTable();
+}
+
void
afsi_start()
{
WSAStartup(0x0101, &WSAjunk);
+ afsd_initUpperCaseTable();
+
/* setup osidebug server at RPC slot 1000 */
osi_LongToUID(1000, &debugID);
code = osi_InitDebug(&debugID);
int
KFW_AFS_get_cred(char * username,
- char * instance,
char * cell,
char * password,
int lifetime,
if ( IsDebuggerPresent() ) {
OutputDebugString("KFW_AFS_get_cred for token ");
OutputDebugString(username);
- if ( instance ) {
- OutputDebugString("/");
- OutputDebugString(instance);
- }
- OutputDebugString("@");
+ OutputDebugString(" in cell ");
OutputDebugString(cell);
OutputDebugString("\n");
}
}
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);
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,
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,
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,
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.
*/
}
}
}
+#endif /* USE_OLD_MATCHING */
long smb_ReceiveTran2SearchDir(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *opx)
{