- diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
- index 5a89134..53ec774 100644
- --- a/dll/nfs41_np.c
- +++ b/dll/nfs41_np.c
- @@ -517,14 +517,20 @@ NPAddConnection3(
- WCHAR ServerName[NFS41_SYS_MAX_PATH_LEN];
- PWCHAR p;
- DWORD i;
- + LPWSTR lpLocalName = lpNetResource->lpLocalName;
- DbgP((L"--> NPAddConnection3(lpNetResource->lpLocalName='%s', "
- L"lpNetResource->lpRemoteName='%s', "
- L"username='%s', passwd='%s')\n",
- - lpNetResource->lpLocalName,
- + lpLocalName,
- lpNetResource->lpRemoteName,lpUserName,
- lpPassword));
- + if (lpLocalName == NULL) {
- + lpLocalName = L"_:";
- + DbgP((L"lpLocalName==NULL, changed to _:\n"));
- + }
- +
- Status = InitializeConnectionInfo(&Connection,
- (PMOUNT_OPTION_BUFFER)lpNetResource->lpComment,
- &ConnectionName);
- @@ -536,16 +542,16 @@ NPAddConnection3(
- // \device\miniredirector\;<DriveLetter>:\Server\Share
- // local name, must start with "X:"
- - if (lstrlen(lpNetResource->lpLocalName) < 2 ||
- - lpNetResource->lpLocalName[1] != L':') {
- - DbgP((L"lpNetResource->lpLocalName(='%s') "
- + if (lstrlen(lpLocalName) < 2 ||
- + lpLocalName[1] != L':') {
- + DbgP((L"lpLocalName(='%s') "
- "is not a device letter\n",
- - lpNetResource->lpLocalName));
- + lpLocalName));
- Status = WN_BAD_LOCALNAME;
- goto out;
- }
- - LocalName[0] = towupper(lpNetResource->lpLocalName[0]);
- + LocalName[0] = towupper(lpLocalName[0]);
- LocalName[1] = L':';
- LocalName[2] = L'\0';
- (void)StringCchCopyW(ConnectionName,
- @@ -659,6 +665,30 @@ NPAddConnection3(
- (wcslen(ConnectionName) + 1) * sizeof(WCHAR),
- (lstrlen(ConnectionName) + 1) * sizeof(WCHAR)));
- + if (lpNetResource->lpLocalName == NULL) {
- + wchar_t dummy_remotename[1024];
- + DWORD gc_status;
- + DWORD gc_remotename_size = 1024;
- +
- + gc_status = NPGetConnection(NULL,
- + dummy_remotename, &gc_remotename_size);
- + DbgP((L"lpNetResource->lpLocalName == NULL, "
- + "NPGetConnection() returned "
- + "gc_status=%d, dummy_remotename='%s'\n",
- + (int)gc_status, dummy_remotename));
- +
- + if (gc_status == WN_SUCCESS) {
- + /*
- + * Do not return |WN_ALREADY_CONNECTED| here, as UNC
- + * paths are reused
- + * We explicitly use this to skip |StoreConnectionInfo()|
- + * below, so we only have one stored UNC connection
- + */
- + Status = WN_SUCCESS;
- + goto out;
- + }
- + }
- + else {
- wszScratch[0] = L'\0';
- Status = QueryDosDevice(LocalName, wszScratch, 1024);
- DbgP((L"QueryDosDevice(lpDeviceName='%s',lpTargetPath='%s') "
- @@ -669,6 +699,7 @@ NPAddConnection3(
- Status = WN_ALREADY_CONNECTED;
- goto out;
- }
- + }
- MarshalConnectionInfo(&Connection);
- @@ -680,19 +711,21 @@ NPAddConnection3(
- goto out;
- }
- - DbgP((L"DefineDosDevice(lpNetResource->lpLocalName='%s', "
- + if (lpNetResource->lpLocalName != NULL) {
- + DbgP((L"DefineDosDevice(lpLocalName='%s', "
- L"ConnectionName='%s')\n",
- - lpNetResource->lpLocalName, ConnectionName));
- + lpLocalName, ConnectionName));
- if (!DefineDosDevice(DDD_RAW_TARGET_PATH |
- DDD_NO_BROADCAST_SYSTEM,
- - lpNetResource->lpLocalName,
- + lpLocalName,
- ConnectionName)) {
- Status = GetLastError();
- - DbgP((L"DefineDosDevice(lpNetResource->lpLocalName='%s',"
- + DbgP((L"DefineDosDevice(lpLocalName='%s',"
- L"ConnectionName='%s') failed with %d\n",
- - lpNetResource->lpLocalName, ConnectionName, Status));
- + lpLocalName, ConnectionName, Status));
- goto out_delconn;
- }
- + }
- // The connection was established and the local device mapping
- // added. Include this in the list of mapped devices.
- @@ -708,10 +741,12 @@ out:
- DbgP((L"<-- NPAddConnection3 returns %d\n", (int)Status));
- return Status;
- out_undefine:
- + if (lpNetResource->lpLocalName != NULL) {
- (void)DefineDosDevice(DDD_REMOVE_DEFINITION |
- DDD_RAW_TARGET_PATH |
- DDD_EXACT_MATCH_ON_REMOVE,
- LocalName, ConnectionName);
- + }
- out_delconn:
- SendTo_NFS41Driver(IOCTL_NFS41_DELCONN, ConnectionName,
- Connection.Buffer->NameLength, NULL, &CopyBytes);
- @@ -836,6 +871,11 @@ NPGetConnection(
- DbgP((L"--> NPGetConnection(lpLocalName='%s')\n", lpLocalName));
- + if (lpLocalName == NULL) {
- + lpLocalName = L"_:";
- + DbgP((L"lpLocalName==NULL, changed to _:\n"));
- + }
- +
- #ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
- (void)get_token_authenticationid(GetCurrentThreadEffectiveToken(),
- &authenticationid);
UNC mount prototype
Posted by Anonymous on Wed 2nd Oct 2024 16:56
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.