netbiosName-cellname-20040306

Add support for a new form of automatic share name generation

        \\netbiosName\cellname

which means that on systems with the loopback adapter you can
now refer to the athena.mit.edu afs cell as \\afs\athena.mit.edu\

This is implemented within cm_FindShare().  If the share name is not
one of the special ones and cannot be found in the Submounts table,
check to see if it is a known cell name,  If so, create a path to
the share of /afs/sharename with the "sharename" being lower cased.
(I hope there are no cell names in mixed or upper case.  This won't
work.)
This commit is contained in:
Jeffrey Altman 2004-03-06 21:38:48 +00:00 committed by Jeffrey Altman
parent 4ec7d4f8c2
commit 2ad3f0377c

View File

@ -1159,7 +1159,7 @@ int smb_FindShare(smb_vc_t *vcp, smb_packet_t *inp, char *shareName,
smb_user_t *uidp; smb_user_t *uidp;
char temp[1024]; char temp[1024];
DWORD sizeTemp; DWORD sizeTemp;
char sbmtpath[256]; char sbmtpath[MAX_PATH];
char *p, *q; char *p, *q;
HKEY parmKey; HKEY parmKey;
DWORD code; DWORD code;
@ -1196,7 +1196,7 @@ int smb_FindShare(smb_vc_t *vcp, smb_packet_t *inp, char *shareName,
* to handle ioctl requests * to handle ioctl requests
*/ */
if (_stricmp(shareName, "ioctl$") == 0) { if (_stricmp(shareName, "ioctl$") == 0) {
*pathNamep = "/.__ioctl__"; *pathNamep = strdup("/.__ioctl__");
return 1; return 1;
} }
@ -1208,13 +1208,10 @@ int smb_FindShare(smb_vc_t *vcp, smb_packet_t *inp, char *shareName,
#endif /* !DJGPP */ #endif /* !DJGPP */
len = GetPrivateProfileString("AFS Submounts", shareName, "", len = GetPrivateProfileString("AFS Submounts", shareName, "",
pathName, sizeof(pathName), sbmtpath); pathName, sizeof(pathName), sbmtpath);
if (len == 0 || len == sizeof(pathName) - 1) { if (len != 0 && len != sizeof(pathName) - 1) {
*pathNamep = NULL;
return 0;
}
/* We can accept either unix or PC style AFS pathnames. Convert /* We can accept either unix or PC style AFS pathnames. Convert
Unix-style to PC style here for internal use. */ * Unix-style to PC style here for internal use.
*/
p = pathName; p = pathName;
if (strncmp(p, cm_mountRoot, strlen(cm_mountRoot)) == 0) if (strncmp(p, cm_mountRoot, strlen(cm_mountRoot)) == 0)
p += strlen(cm_mountRoot); /* skip mount path */ p += strlen(cm_mountRoot); /* skip mount path */
@ -1229,42 +1226,57 @@ int smb_FindShare(smb_vc_t *vcp, smb_packet_t *inp, char *shareName,
if (var = smb_stristr(p, VNUserName)) { if (var = smb_stristr(p, VNUserName)) {
uidp = smb_FindUID(vcp, ((smb_t *)inp)->uid, 0); uidp = smb_FindUID(vcp, ((smb_t *)inp)->uid, 0);
if (uidp && uidp->unp) if (uidp && uidp->unp)
smb_subst(p, var, sizeof(VNUserName), smb_subst(p, var, sizeof(VNUserName),uidp->unp->name);
uidp->unp->name);
else else
smb_subst(p, var, sizeof(VNUserName), smb_subst(p, var, sizeof(VNUserName)," ");
" ");
if (uidp) if (uidp)
smb_ReleaseUID(uidp); smb_ReleaseUID(uidp);
} }
else if (var = smb_stristr(p, VNLCUserName)) { else if (var = smb_stristr(p, VNLCUserName))
{
uidp = smb_FindUID(vcp, ((smb_t *)inp)->uid, 0); uidp = smb_FindUID(vcp, ((smb_t *)inp)->uid, 0);
if (uidp && uidp->unp) if (uidp && uidp->unp)
strcpy(temp, uidp->unp->name); strcpy(temp, uidp->unp->name);
else strcpy(temp, " "); else
strcpy(temp, " ");
_strlwr(temp); _strlwr(temp);
smb_subst(p, var, sizeof(VNLCUserName), temp); smb_subst(p, var, sizeof(VNLCUserName), temp);
if (uidp) if (uidp)
smb_ReleaseUID(uidp); smb_ReleaseUID(uidp);
} }
else if (var = smb_stristr(p, VNComputerName)) { else if (var = smb_stristr(p, VNComputerName))
{
sizeTemp = sizeof(temp); sizeTemp = sizeof(temp);
GetComputerName((LPTSTR)temp, &sizeTemp); GetComputerName((LPTSTR)temp, &sizeTemp);
smb_subst(p, var, sizeof(VNComputerName), smb_subst(p, var, sizeof(VNComputerName), temp);
temp);
} }
else if (var = smb_stristr(p, VNLCComputerName)) { else if (var = smb_stristr(p, VNLCComputerName))
{
sizeTemp = sizeof(temp); sizeTemp = sizeof(temp);
GetComputerName((LPTSTR)temp, &sizeTemp); GetComputerName((LPTSTR)temp, &sizeTemp);
_strlwr(temp); _strlwr(temp);
smb_subst(p, var, sizeof(VNLCComputerName), smb_subst(p, var, sizeof(VNLCComputerName), temp);
temp);
} }
else break; else
break;
} }
*pathNamep = strdup(p); *pathNamep = strdup(p);
return 1; return 1;
}
else /* create \\<netbiosName>\<cellname> */
{
if (cm_GetCell_Gen(shareName, temp, CM_FLAG_CREATE))
{
if (!stricmp(shareName, temp)) { /* no partial matches allowed */
sprintf(pathName,"/%s/",shareName);
*pathNamep = strdup(strlwr(pathName));
return 1;
}
}
}
/* failure */
*pathNamep = NULL;
return 0;
} }
/* find a dir search structure by cookie value, and return it held. /* find a dir search structure by cookie value, and return it held.