DEVEL15-windows-shell-add-symlink-20080206

LICENSE MIT

No longer attempt to validate the target of the symlink.
There is no method of doing so reliably.


(cherry picked from commit d78bff3dbd561f9d0f4976eeb264e601216a37c6)
This commit is contained in:
Jeffrey Altman 2008-02-06 17:53:55 +00:00
parent 7f024661e8
commit 3c7794c46f
2 changed files with 35 additions and 60 deletions

View File

@ -1995,7 +1995,7 @@ BOOL GetTokenInfo(CStringArray& tokenInfo)
return TRUE;
}
UINT MakeSymbolicLink(const char *strName, const char *strDir)
UINT MakeSymbolicLink(const char *strName, const char *strTarget)
{
struct ViceIoctl blob;
char space[MAXSIZE];
@ -2006,45 +2006,20 @@ UINT MakeSymbolicLink(const char *strName, const char *strDir)
HOURGLASS hourglass;
static char message[2048];
strcpy(path, strDir);
strcpy(path, strName);
parent = Parent(path);
sprintf(message,"MakeSymbolicLink: path = %s parent = %s\n",path,parent);
sprintf(message,"MakeSymbolicLink: name = %s target = %s parent = %s\n",strName,strTarget, parent);
OutputDebugString(message);
/*lets confirm its a good symlink*/
if (!IsPathInAfs(path)) {
const char * nbname = NetbiosName();
int len = strlen(nbname);
if (parent[0] == '\\' && parent[1] == '\\' &&
parent[len+2] == '\\' &&
parent[len+3] == '\0' &&
!strnicmp(nbname,&parent[2],len))
{
sprintf(path,"%sall\\%s", parent, &strDir[strlen(parent)]);
parent = Parent(path);
sprintf(message,"MakeSymbolicLink: new path = %s parent = %s\n",path,parent);
OutputDebugString(message);
if (!IsPathInAfs(parent)) {
ShowMessageBox(IDS_MAKE_LNK_NOT_AFS_ERROR, MB_ICONERROR, IDS_MAKE_LNK_NOT_AFS_ERROR);
return TRUE;
}
} else {
ShowMessageBox(IDS_MAKE_LNK_NOT_AFS_ERROR, MB_ICONERROR, IDS_MAKE_LNK_NOT_AFS_ERROR);
return TRUE;
}
}
if ( IsFreelanceRoot(parent) && !IsAdmin() ) {
ShowMessageBox(IDS_NOT_AFS_CLIENT_ADMIN_ERROR, MB_ICONERROR, IDS_NOT_AFS_CLIENT_ADMIN_ERROR);
return FALSE;
}
LPTSTR lpsz = new TCHAR[strlen(strDir)+1];
LPTSTR lpsz = new TCHAR[strlen(strTarget)+1];
_tcscpy(lpsz, strName);
strcpy(space, strDir);
strcpy(space, strTarget);
blob.out_size = 0;
blob.in_size = 1 + strlen(space);
blob.in = space;

View File

@ -66,37 +66,37 @@ END_MESSAGE_MAP()
void CMakeSymbolicLinkDlg::OnOK()
{
char space[64];
UINT code;
int i;
UpdateData(TRUE);
CString strName;
CString strDir;
m_Name.GetWindowText(strName);
m_Dir.GetWindowText(strDir);
char space[64];
UINT code;
int i;
UpdateData(TRUE);
CString strName;
CString strTarget;
m_Name.GetWindowText(strName);
m_Dir.GetWindowText(strTarget);
if (!IsPathInAfs(m_sBase)) {
MessageBeep((UINT)-1);
strDir+=" - Path is not in AFS directory";
AfxMessageBox(strDir,MB_OK);
return;
}
if (m_sBase.GetLength()>MAX_PATH-2)
{
MessageBeep((UINT)-1);
ShowMessageBox(IDS_CURRENT_DIRECTORY_PATH_TOO_LONG,MB_OK,IDS_CURRENT_DIRECTORY_PATH_TOO_LONG);
}
if (!SetCurrentDirectory(m_sBase))
{
MessageBeep((UINT)-1);
ShowMessageBox(IDS_UNABLE_TO_SET_CURRENT_DIRECTORY,MB_OK,IDS_UNABLE_TO_SET_CURRENT_DIRECTORY);
return;
}
if ((code=MakeSymbolicLink(strName,strDir))!=0){
MessageBeep((UINT)-1);
ShowMessageBox(IDS_UNABLE_TO_CREATE_SYMBOLIC_LINK,MB_OK,IDS_UNABLE_TO_CREATE_SYMBOLIC_LINK,code);
return;
}
CDialog::OnOK();
MessageBeep((UINT)-1);
strTarget+=" - Path is not in AFS directory";
AfxMessageBox(strTarget,MB_OK);
return;
}
if (m_sBase.GetLength()>MAX_PATH-2)
{
MessageBeep((UINT)-1);
ShowMessageBox(IDS_CURRENT_DIRECTORY_PATH_TOO_LONG,MB_OK,IDS_CURRENT_DIRECTORY_PATH_TOO_LONG);
}
if (!SetCurrentDirectory(m_sBase))
{
MessageBeep((UINT)-1);
ShowMessageBox(IDS_UNABLE_TO_SET_CURRENT_DIRECTORY,MB_OK,IDS_UNABLE_TO_SET_CURRENT_DIRECTORY);
return;
}
if ((code=MakeSymbolicLink(strName,strTarget))!=0){
MessageBeep((UINT)-1);
ShowMessageBox(IDS_UNABLE_TO_CREATE_SYMBOLIC_LINK,MB_OK,IDS_UNABLE_TO_CREATE_SYMBOLIC_LINK,code);
return;
}
CDialog::OnOK();
}
/*
void CMakeSymbolicLinkDlg::OnChangeName()