Difference between
modified post b120881 by Anonymous on Wed 20th Sep 2023 15:07
original post 36f61 by Anonymous on Tue 19th Sep 2023 17:08
Download diff
Show
old version |
new version |
both versions
| 1 | 1 | diff --git a/daemon/mount.c b/daemon/mount.c | |
| 2 | - | index 55345f6..50b986b 100644 | |
| 2 | + | index 55345f6..3b18cba 100644 | |
| 3 | 3 | --- a/daemon/mount.c | |
| 4 | 4 | +++ b/daemon/mount.c | |
| 5 | 5 | @@ -37,6 +37,8 @@ static int parse_mount(unsigned char *buffer, uint32_t length, nfs41_upcall *upc | |
| 6 | 6 | ||
| 7 | 7 | status = get_name(&buffer, &length, &args->hostname); | |
| 8 | 8 | if(status) goto out; | |
| 9 | 9 | + status = safe_read(&buffer, &length, &args->port, sizeof(DWORD)); | |
| 10 | 10 | + if (status) goto out; | |
| 11 | 11 | status = get_name(&buffer, &length, &args->path); | |
| 12 | 12 | if(status) goto out; | |
| 13 | 13 | status = safe_read(&buffer, &length, &args->sec_flavor, sizeof(DWORD)); | |
| 14 | 14 | @@ -46,10 +48,12 @@ static int parse_mount(unsigned char *buffer, uint32_t length, nfs41_upcall *upc | |
| 15 | 15 | status = safe_read(&buffer, &length, &args->wsize, sizeof(DWORD)); | |
| 16 | 16 | if (status) goto out; | |
| 17 | 17 | ||
| 18 | 18 | - dprintf(1, "parsing NFS14_MOUNT: srv_name=%s root=%s sec_flavor=%s " | |
| 19 | 19 | - "rsize=%d wsize=%d\n", args->hostname, args->path, | |
| 20 | - | + dprintf(1, "parsing NFS14_MOUNT: srv_name=%s port=%d root=%s " | |
| 20 | + | + dprintf(1, "parsing NFS41_MOUNT: srv_name=%s port=%d root=%s " | |
| 21 | 21 | + "sec_flavor=%s rsize=%d wsize=%d\n", args->hostname, args->port, args->path, | |
| 22 | 22 | secflavorop2name(args->sec_flavor), args->rsize, args->wsize); | |
| 23 | 23 | + return status; | |
| 24 | 24 | out: | |
| 25 | - | + dprintf(1, "parsing NFS14_MOUNT: failed %d\n", status); | |
| 25 | + | + dprintf(1, "parsing NFS41_MOUNT: failed %d\n", status); | |
| 26 | 26 | return status; | |
| 27 | 27 | } | |
| 28 | 28 | ||
| 29 | 29 | @@ -64,7 +68,7 @@ static int handle_mount(nfs41_upcall *upcall) | |
| 30 | 30 | nfs41_path_fh file; | |
| 31 | 31 | ||
| 32 | 32 | // resolve hostname,port | |
| 33 | 33 | - status = nfs41_server_resolve(args->hostname, 2049, &addrs); | |
| 34 | 34 | + status = nfs41_server_resolve(args->hostname, (unsigned short)args->port, &addrs); | |
| 35 | 35 | if (status) { | |
| 36 | 36 | eprintf("nfs41_server_resolve() failed with %d\n", status); | |
| 37 | 37 | goto out; | |
| 38 | 38 | @@ -76,7 +80,7 @@ static int handle_mount(nfs41_upcall *upcall) | |
| 39 | 39 | root = upcall->root_ref; | |
| 40 | 40 | } else { | |
| 41 | 41 | // create root | |
| 42 | 42 | - status = nfs41_root_create(args->hostname, args->sec_flavor, | |
| 43 | 43 | + status = nfs41_root_create(args->hostname, args->port, args->sec_flavor, | |
| 44 | 44 | args->wsize + WRITE_OVERHEAD, args->rsize + READ_OVERHEAD, &root); | |
| 45 | 45 | if (status) { | |
| 46 | 46 | eprintf("nfs41_root_create() failed %d\n", status); | |
| 47 | 47 | diff --git a/daemon/namespace.c b/daemon/namespace.c | |
| 48 | - | index ab16f49..11917e2 100644 | |
| 48 | + | index ab16f49..e3ea077 100644 | |
| 49 | 49 | --- a/daemon/namespace.c | |
| 50 | 50 | +++ b/daemon/namespace.c | |
| 51 | 51 | @@ -36,6 +36,7 @@ | |
| 52 | 52 | /* nfs41_root */ | |
| 53 | 53 | int nfs41_root_create( | |
| 54 | 54 | IN const char *name, | |
| 55 | 55 | + IN uint32_t port, | |
| 56 | 56 | IN uint32_t sec_flavor, | |
| 57 | 57 | IN uint32_t wsize, | |
| 58 | 58 | IN uint32_t rsize, | |
| 59 | 59 | @@ -44,7 +45,7 @@ int nfs41_root_create( | |
| 60 | 60 | int status = NO_ERROR; | |
| 61 | 61 | nfs41_root *root; | |
| 62 | 62 | ||
| 63 | 63 | - dprintf(NSLVL, "--> nfs41_root_create()\n"); | |
| 64 | 64 | + dprintf(NSLVL, "--> nfs41_root_create(name=%s, port=%d)\n", name, port); | |
| 65 | 65 | ||
| 66 | 66 | root = calloc(1, sizeof(nfs41_root)); | |
| 67 | 67 | if (root == NULL) { | |
| 68 | 68 | @@ -60,7 +61,7 @@ int nfs41_root_create( | |
| 69 | 69 | root->sec_flavor = sec_flavor; | |
| 70 | 70 | ||
| 71 | 71 | /* generate a unique client_owner */ | |
| 72 | 72 | - status = nfs41_client_owner(name, sec_flavor, &root->client_owner); | |
| 73 | 73 | + status = nfs41_client_owner(name, port, sec_flavor, &root->client_owner); | |
| 74 | 74 | if (status) { | |
| 75 | 75 | eprintf("nfs41_client_owner() failed with %d\n", status); | |
| 76 | 76 | free(root); | |
| 77 | 77 | @@ -443,6 +444,8 @@ static int referral_mount_location( | |
| 78 | 78 | int status = ERROR_BAD_NET_NAME; | |
| 79 | 79 | uint32_t i; | |
| 80 | 80 | ||
| 81 | 81 | + dprintf(NSLVL, "--> referral_mount_location()\n"); | |
| 82 | 82 | + | |
| 83 | 83 | /* create a client and session for the first available server */ | |
| 84 | 84 | for (i = 0; i < loc->server_count; i++) { | |
| 85 | 85 | /* XXX: only deals with 'address' as a hostname with default port */ | |
| 86 | 86 | @@ -453,6 +456,9 @@ static int referral_mount_location( | |
| 87 | 87 | if (status == NO_ERROR) | |
| 88 | 88 | break; | |
| 89 | 89 | } | |
| 90 | 90 | + | |
| 91 | 91 | + dprintf(NSLVL, "<-- referral_mount_location() returning %d\n", status); | |
| 92 | 92 | + | |
| 93 | 93 | return status; | |
| 94 | 94 | } | |
| 95 | 95 | ||
| 96 | 96 | diff --git a/daemon/nfs41.h b/daemon/nfs41.h | |
| 97 | 97 | index aa679a6..3902393 100644 | |
| 98 | 98 | --- a/daemon/nfs41.h | |
| 99 | 99 | +++ b/daemon/nfs41.h | |
| 100 | 100 | @@ -287,6 +287,7 @@ typedef struct __nfs41_root { | |
| 101 | 101 | /* nfs41_namespace.c */ | |
| 102 | 102 | int nfs41_root_create( | |
| 103 | 103 | IN const char *name, | |
| 104 | 104 | + IN uint32_t port, | |
| 105 | 105 | IN uint32_t sec_flavor, | |
| 106 | 106 | IN uint32_t wsize, | |
| 107 | 107 | IN uint32_t rsize, | |
| 108 | 108 | @@ -404,6 +405,7 @@ void nfs41_server_addrs( | |
| 109 | 109 | /* nfs41_client.c */ | |
| 110 | 110 | int nfs41_client_owner( | |
| 111 | 111 | IN const char *name, | |
| 112 | 112 | + IN uint32_t port, | |
| 113 | 113 | IN uint32_t sec_flavor, | |
| 114 | 114 | OUT client_owner4 *owner); | |
| 115 | 115 | ||
| 116 | 116 | diff --git a/daemon/nfs41_client.c b/daemon/nfs41_client.c | |
| 117 | - | index 0460fc5..01d19ac 100644 | |
| 117 | + | index 0460fc5..f5bac1d 100644 | |
| 118 | 118 | --- a/daemon/nfs41_client.c | |
| 119 | 119 | +++ b/daemon/nfs41_client.c | |
| 120 | 120 | @@ -353,6 +353,7 @@ out: | |
| 121 | 121 | ||
| 122 | 122 | int nfs41_client_owner( | |
| 123 | 123 | IN const char *name, | |
| 124 | 124 | + IN uint32_t port, | |
| 125 | 125 | IN uint32_t sec_flavor, | |
| 126 | 126 | OUT client_owner4 *owner) | |
| 127 | 127 | { | |
| 128 | - | diff --git a/daemon/nfs41_server.c b/daemon/nfs41_server.c | |
| 128 | + | @@ -405,6 +406,12 @@ int nfs41_client_owner( | |
| 129 | - | index d58c03a..ef8f0ac 100644 | |
| 129 | + | goto out_hash; | |
| 139 | 130 | } | |
| 140 | - | diff --git a/daemon/upcall.h b/daemon/upcall.h | |
| 131 | + | ||
| 141 | - | index fd26353..cf85598 100644 | |
| 132 | + | + if (!CryptHashData(hash, (const BYTE*)&port, (DWORD)sizeof(port), 0)) { | |
| 142 | - | --- a/daemon/upcall.h | |
| 133 | + | + status = GetLastError(); | |
| 143 | - | +++ b/daemon/upcall.h | |
| 134 | + | + eprintf("CryptHashData() failed with %d\n", status); | |
| 144 | - | @@ -30,6 +30,7 @@ | |
| 135 | + | + goto out_hash; | |
| 145 | - | /* structures for upcall arguments */ | |
| 136 | + | + } | |
| 146 | - | typedef struct __mount_upcall_args { | |
| 137 | + | + | |
| 147 | - | const char *hostname; | |
| 138 | + | /* add the mac address from each applicable adapter to the hash */ | |
| 148 | - | + DWORD port; | |
| 139 | + | status = hash_mac_addrs(hash); | |
| 149 | - | const char *path; | |
| 140 | + | if (status) { | |
| 150 | - | DWORD sec_flavor; | |
| 141 | + | diff --git a/daemon/nfs41_server.c b/daemon/nfs41_server.c | |
| 151 | - | DWORD rsize; | |
| 142 | + | index d58c03a..ef8f0ac 100644 | |
| 152 | - | diff --git a/mount/mount.c b/mount/mount.c | |
| 143 | + | --- a/daemon/nfs41_server.c | |
| 153 | - | index 4615fc9..6d8c8ee 100644 | |
| 144 | + | +++ b/daemon/nfs41_server.c | |
| 154 | - | --- a/mount/mount.c | |
| 145 | + | @@ -338,6 +338,6 @@ out: | |
| 155 | - | +++ b/mount/mount.c | |
| 146 | + | "error %d\n", hostname, port, status); | |
| 156 | - | @@ -61,13 +61,14 @@ static VOID PrintUsage(LPTSTR pProcess) | |
| 147 | + | else | |
| 157 | - | TEXT("\t-o <comma-separated mount options>\n") | |
| 148 | + | dprintf(SRVLVL, "<-- nfs41_server_resolve(%s:%u) returning " | |
| 158 | - | TEXT("Mount options:\n") | |
| 149 | + | - "%s\n", hostname, port, addrs->arr[0].uaddr); | |
| 159 | - | TEXT("\tro\tmount as read-only\n") | |
| 150 | + | + "OK %s\n", hostname, port, addrs->arr[0].uaddr); | |
| 160 | - | + TEXT("\tport=#\tTCP port to use (defaults to 2049)\n") | |
| 151 | + | return status; | |
| 169 | 152 | } | |
| 170 | - | ||
| 153 | + | diff --git a/daemon/upcall.h b/daemon/upcall.h | |
| 171 | - | DWORD __cdecl _tmain(DWORD argc, LPTSTR argv[]) | |
| 154 | + | index fd26353..9cdc0a1 100644 | |
| 172 | - | diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c | |
| 155 | + | --- a/daemon/upcall.h | |
| 173 | - | index da9327f..242b020 100644 | |
| 156 | + | +++ b/daemon/upcall.h | |
| 174 | - | --- a/sys/nfs41_driver.c | |
| 157 | + | @@ -30,6 +30,7 @@ | |
| 175 | - | +++ b/sys/nfs41_driver.c | |
| 158 | + | /* structures for upcall arguments */ | |
| 176 | - | @@ -166,6 +166,7 @@ typedef struct _updowncall_entry { | |
| 159 | + | typedef struct __mount_upcall_args { | |
| 177 | - | union { | |
| 160 | + | const char *hostname; | |
| 178 | - | struct { | |
| 161 | + | + DWORD port; | |
| 179 | - | PUNICODE_STRING srv_name; | |
| 162 | + | const char *path; | |
| 180 | - | + DWORD port; | |
| 163 | + | DWORD sec_flavor; | |
| 181 | - | PUNICODE_STRING root; | |
| 164 | + | DWORD rsize; | |
| 182 | - | PFILE_FS_ATTRIBUTE_INFORMATION FsAttrs; | |
| 165 | + | diff --git a/libtirpc/src/pmap_getport.c b/libtirpc/src/pmap_getport.c | |
| 183 | - | DWORD sec_flavor; | |
| 166 | + | index 45c8b1c..4d3a277 100644 | |
| 184 | - | @@ -314,6 +315,7 @@ DECLARE_CONST_UNICODE_STRING(SLASH, L"\\"); | |
| 167 | + | --- a/libtirpc/src/pmap_getport.c | |
| 185 | - | DECLARE_CONST_UNICODE_STRING(EMPTY_STRING, L""); | |
| 168 | + | +++ b/libtirpc/src/pmap_getport.c | |
| 186 | - | ||
| 169 | + | @@ -62,6 +62,7 @@ pmap_getport(address, program, version, protocol) | |
| 187 | - | #define SERVER_NAME_BUFFER_SIZE 1024 | |
| 170 | + | u_long version; | |
| 188 | - | +#define MOUNT_CONFIG_NFS_PORT_DEFAULT 2049 | |
| 171 | + | u_int protocol; | |
| 189 | - | #define MOUNT_CONFIG_RW_SIZE_MIN 1024 | |
| 172 | + | { | |
| 190 | - | #define MOUNT_CONFIG_RW_SIZE_DEFAULT 1048576 | |
| 173 | + | + (void)fprintf(stderr, "pmap_getport: returning default NFS port 2049\n"); | |
| 191 | - | #define MOUNT_CONFIG_RW_SIZE_MAX 1048576 | |
| 174 | + | return (u_short)2049; | |
| 192 | - | @@ -328,6 +330,7 @@ typedef struct _NFS41_MOUNT_CONFIG { | |
| 175 | + | } | |
| 193 | - | BOOLEAN nocache; | |
| 176 | + | #else | |
| 194 | - | WCHAR srv_buffer[SERVER_NAME_BUFFER_SIZE]; | |
| 177 | + | @@ -106,4 +107,4 @@ pmap_getport(address, program, version, protocol) | |
| 195 | - | UNICODE_STRING SrvName; | |
| 178 | + | address->sin_port = 0; | |
| 196 | - | + DWORD Port; | |
| 179 | + | return (port); | |
| 202 | 180 | } | |
| 203 | - | header_len = *len + length_as_utf8(entry->u.Mount.srv_name) + | |
| 181 | + | -#endif /* ! _WIN32 */ | |
| 204 | - | - length_as_utf8(entry->u.Mount.root) + 3 * sizeof(DWORD); | |
| 182 | + | \ No newline at end of file | |
| 205 | - | + length_as_utf8(entry->u.Mount.root) + 4 * sizeof(DWORD); | |
| 183 | + | +#endif /* ! _WIN32 */ | |
| 206 | - | if (header_len > buf_len) { | |
| 184 | + | diff --git a/mount/mount.c b/mount/mount.c | |
| 207 | - | status = STATUS_INSUFFICIENT_RESOURCES; | |
| 185 | + | index 4615fc9..6d8c8ee 100644 | |
| 208 | - | goto out; | |
| 186 | + | --- a/mount/mount.c | |
| 209 | - | } | |
| 187 | + | +++ b/mount/mount.c | |
| 210 | - | status = marshall_unicode_as_utf8(&tmp, entry->u.Mount.srv_name); | |
| 188 | + | @@ -61,13 +61,14 @@ static VOID PrintUsage(LPTSTR pProcess) | |
| 211 | - | if (status) goto out; | |
| 189 | + | TEXT("\t-o <comma-separated mount options>\n") | |
| 212 | - | + RtlCopyMemory(tmp, &entry->u.Mount.port, sizeof(DWORD)); | |
| 190 | + | TEXT("Mount options:\n") | |
| 213 | - | + tmp += sizeof(DWORD); | |
| 191 | + | TEXT("\tro\tmount as read-only\n") | |
| 214 | - | status = marshall_unicode_as_utf8(&tmp, entry->u.Mount.root); | |
| 192 | + | + TEXT("\tport=#\tTCP port to use (defaults to 2049)\n") | |
| 215 | - | if (status) goto out; | |
| 193 | + | TEXT("\trsize=#\tread buffer size in bytes\n") | |
| 216 | - | RtlCopyMemory(tmp, &entry->u.Mount.sec_flavor, sizeof(DWORD)); | |
| 194 | + | TEXT("\twsize=#\twrite buffer size in bytes\n") | |
| 217 | - | @@ -633,8 +638,9 @@ NTSTATUS marshal_nfs41_mount( | |
| 195 | + | TEXT("\tsec=krb5:krb5i:krb5p\tspecify gss security flavor\n") | |
| 218 | - | *len = header_len; | |
| 196 | + | TEXT("\twritethru\tturns off rdbss caching for writes\n") | |
| 197 | + | TEXT("\tnocache\tturns off rdbss caching\n") | |
| 219 | 202 | ||
| 220 | - | #ifdef DEBUG_MARSHAL_DETAIL | |
| 203 | + | DWORD __cdecl _tmain(DWORD argc, LPTSTR argv[]) | |
| 221 | - | - DbgP("marshal_nfs41_mount: server name=%wZ mount point=%wZ sec_flavor=%s " | |
| 204 | + | diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c | |
| 222 | - | - "rsize=%d wsize=%d\n", entry->u.Mount.srv_name, entry->u.Mount.root, | |
| 205 | + | index da9327f..080679e 100644 | |
| 223 | - | + DbgP("marshal_nfs41_mount: server name=%wZ port=%d mount point=%wZ " | |
| 206 | + | --- a/sys/nfs41_driver.c | |
| 224 | - | + "sec_flavor=%s rsize=%d wsize=%d\n", | |
| 207 | + | +++ b/sys/nfs41_driver.c | |
| 225 | - | + entry->u.Mount.srv_name, entry->u.Mount.port, entry->u.Mount.root, | |
| 208 | + | @@ -166,6 +166,7 @@ typedef struct _updowncall_entry { | |
| 226 | - | secflavorop2name(entry->u.Mount.sec_flavor), entry->u.Mount.rsize, | |
| 209 | + | union { | |
| 227 | - | entry->u.Mount.wsize); | |
| 210 | + | struct { | |
| 228 | - | #endif | |
| 211 | + | PUNICODE_STRING srv_name; | |
| 229 | - | @@ -2574,6 +2580,7 @@ NTSTATUS nfs41_mount( | |
| 212 | + | + DWORD port; | |
| 230 | - | if (status) goto out; | |
| 213 | + | PUNICODE_STRING root; | |
| 214 | + | PFILE_FS_ATTRIBUTE_INFORMATION FsAttrs; | |
| 231 | 218 | ||
| 232 | - | entry->u.Mount.srv_name = &config->SrvName; | |
| 219 | + | #define SERVER_NAME_BUFFER_SIZE 1024 | |
| 233 | - | + entry->u.Mount.port = config->Port; | |
| 220 | + | +#define MOUNT_CONFIG_NFS_PORT_DEFAULT 2049 | |
| 234 | - | entry->u.Mount.root = &config->MntPt; | |
| 221 | + | #define MOUNT_CONFIG_RW_SIZE_MIN 1024 | |
| 235 | - | entry->u.Mount.rsize = config->ReadSize; | |
| 222 | + | #define MOUNT_CONFIG_RW_SIZE_DEFAULT 1048576 | |
| 236 | - | entry->u.Mount.wsize = config->WriteSize; | |
| 223 | + | #define MOUNT_CONFIG_RW_SIZE_MAX 1048576 | |
| 237 | - | @@ -2606,6 +2613,7 @@ void nfs41_MountConfig_InitDefaults( | |
| 224 | + | @@ -328,6 +330,7 @@ typedef struct _NFS41_MOUNT_CONFIG { | |
| 238 | - | { | |
| 225 | + | BOOLEAN nocache; | |
| 239 | - | RtlZeroMemory(Config, sizeof(NFS41_MOUNT_CONFIG)); | |
| 226 | + | WCHAR srv_buffer[SERVER_NAME_BUFFER_SIZE]; | |
| 240 | - | ||
| 227 | + | UNICODE_STRING SrvName; | |
| 241 | - | + Config->Port = MOUNT_CONFIG_NFS_PORT_DEFAULT; | |
| 228 | + | + DWORD Port; | |
| 242 | - | Config->ReadSize = MOUNT_CONFIG_RW_SIZE_DEFAULT; | |
| 229 | + | WCHAR mntpt_buffer[MAX_PATH]; | |
| 243 | - | Config->WriteSize = MOUNT_CONFIG_RW_SIZE_DEFAULT; | |
| 230 | + | UNICODE_STRING MntPt; | |
| 244 | - | Config->ReadOnly = FALSE; | |
| 231 | + | WCHAR sec_flavor[MAX_SEC_FLAVOR_LEN]; | |
| 245 | - | @@ -2724,6 +2732,11 @@ NTSTATUS nfs41_MountConfig_ParseOptions( | |
| 232 | + | @@ -364,6 +367,15 @@ typedef struct _NFS41_V_NET_ROOT_EXTENSION { | |
| 246 | - | else | |
| 233 | + | FILE_FS_ATTRIBUTE_INFORMATION FsAttrs; | |
| 247 | - | RtlCopyUnicodeString(&Config->SrvName, &usValue); | |
| 234 | + | DWORD sec_flavor; | |
| 248 | - | } | |
| 235 | + | DWORD timeout; | |
| 249 | - | + else if (wcsncmp(L"port", Name, NameLen) == 0) { | |
| 236 | + | + /* | |
| 250 | - | + status = nfs41_MountConfig_ParseDword(Option, &usValue, | |
| 237 | + | + * gisburn: FIXME: Putting |port| here is wrong: | |
| 251 | - | + &Config->Port, 1, | |
| 238 | + | + * TCP port information should be encoded in the server name | |
| 252 | - | + 65535); | |
| 239 | + | + * (e.g. \\server@port\nfs4\path, to make sure we do not get | |
| 253 | - | + } | |
| 240 | + | + * conflicts in case of (ssh) port forwarding | |
| 254 | - | else if (wcsncmp(L"mntpt", Name, NameLen) == 0) { | |
| 241 | + | + * (see https://learn.microsoft.com/en-gb/windows/win32/api/davclnt/nf-davclnt-davgethttpfromuncpath | |
| 255 | - | if (usValue.Length > Config->MntPt.MaximumLength) | |
| 242 | + | + * how to specify ports in an UNC path) | |
| 256 | - | status = STATUS_NAME_TOO_LONG; | |
| 243 | + | + */ | |
| 257 | - | ||
| 244 | + | + DWORD port; | |
| 258 | - | ||
| 245 | + | USHORT MountPathLen; | |
| 259 | - | ||
| 246 | + | BOOLEAN read_only; | |
| 260 | - | ||
| 247 | + | BOOLEAN write_thru; | |
| 261 | - | ||
| 248 | + | @@ -615,13 +627,15 @@ NTSTATUS marshal_nfs41_mount( | |
| 262 | - | ||
| 249 | + | goto out; | |
| 263 | - | ||
| 250 | + | } | |
| 264 | - | ||
| 251 | + | header_len = *len + length_as_utf8(entry->u.Mount.srv_name) + | |
| 265 | - | ||
| 252 | + | - length_as_utf8(entry->u.Mount.root) + 3 * sizeof(DWORD); | |
| 266 | - | ||
| 253 | + | + length_as_utf8(entry->u.Mount.root) + 4 * sizeof(DWORD); | |
| 267 | - | ||
| 254 | + | if (header_len > buf_len) { | |
| 268 | - | ||
| 255 | + | status = STATUS_INSUFFICIENT_RESOURCES; | |
| 269 | - | ||
| 256 | + | goto out; | |
| 270 | - | ||
| 257 | + | } | |
| 271 | - | ||
| 258 | + | status = marshall_unicode_as_utf8(&tmp, entry->u.Mount.srv_name); | |
| 272 | - | ||
| 259 | + | if (status) goto out; | |
| 273 | - | ||
| 260 | + | + RtlCopyMemory(tmp, &entry->u.Mount.port, sizeof(DWORD)); | |
| 274 | - | ||
| 261 | + | + tmp += sizeof(DWORD); | |
| 275 | - | ||
| 262 | + | status = marshall_unicode_as_utf8(&tmp, entry->u.Mount.root); | |
| 276 | - | ||
| 263 | + | if (status) goto out; | |
| 277 | - | ||
| 264 | + | RtlCopyMemory(tmp, &entry->u.Mount.sec_flavor, sizeof(DWORD)); | |
| 278 | - | ||
| 265 | + | @@ -633,8 +647,9 @@ NTSTATUS marshal_nfs41_mount( | |
| 279 | - | ||
| 266 | + | *len = header_len; | |
| 280 | 267 | ||
| 281 | - | ||
| 268 | + | #ifdef DEBUG_MARSHAL_DETAIL | |
| 282 | - | ||
| 269 | + | - DbgP("marshal_nfs41_mount: server name=%wZ mount point=%wZ sec_flavor=%s " | |
| 283 | - | ||
| 270 | + | - "rsize=%d wsize=%d\n", entry->u.Mount.srv_name, entry->u.Mount.root, | |
| 284 | - | ||
| 271 | + | + DbgP("marshal_nfs41_mount: server name=%wZ port=%d mount point=%wZ " | |
| 285 | - | ||
| 272 | + | + "sec_flavor=%s rsize=%d wsize=%d\n", | |
| 286 | - | ||
| 273 | + | + entry->u.Mount.srv_name, entry->u.Mount.port, entry->u.Mount.root, | |
| 287 | - | ||
| 274 | + | secflavorop2name(entry->u.Mount.sec_flavor), entry->u.Mount.rsize, | |
| 288 | - | ||
| 275 | + | entry->u.Mount.wsize); | |
| 289 | - | ||
| 276 | + | #endif | |
| 290 | - | ||
| 277 | + | @@ -2566,14 +2581,15 @@ NTSTATUS nfs41_mount( | |
| 291 | 278 | ||
| 292 | - | ||
| 279 | + | #ifdef DEBUG_MOUNT | |
| 293 | - | ||
| 280 | + | DbgEn(); | |
| 294 | - | ||
| 281 | + | - DbgP("Server Name %wZ Mount Point %wZ SecFlavor %d\n", | |
| 295 | - | ||
| 282 | + | - &config->SrvName, &config->MntPt, sec_flavor); | |
| 296 | - | ||
| 283 | + | + DbgP("Server Name %wZ Port %d Mount Point %wZ SecFlavor %d\n", | |
| 297 | - | ||
| 284 | + | + &config->SrvName, config->Port, &config->MntPt, sec_flavor); | |
| 298 | - | ||
| 285 | + | #endif | |
| 299 | - | ||
| 286 | + | status = nfs41_UpcallCreate(NFS41_MOUNT, NULL, *session, | |
| 300 | - | ||
| 287 | + | INVALID_HANDLE_VALUE, *version, &config->MntPt, &entry); | |
| 301 | - | ||
| 288 | + | if (status) goto out; | |
| 302 | 289 | ||
| 303 | - | ||
| 290 | + | entry->u.Mount.srv_name = &config->SrvName; | |
| 304 | - | ||
| 291 | + | + entry->u.Mount.port = config->Port; | |
| 305 | - | ||
| 292 | + | entry->u.Mount.root = &config->MntPt; | |
| 306 | - | ||
| 293 | + | entry->u.Mount.rsize = config->ReadSize; | |
| 307 | - | ||
| 294 | + | entry->u.Mount.wsize = config->WriteSize; | |
| 308 | - | ||
| 295 | + | @@ -2606,6 +2622,7 @@ void nfs41_MountConfig_InitDefaults( | |
| 309 | - | ||
| 296 | + | { | |
| 310 | - | ||
| 297 | + | RtlZeroMemory(Config, sizeof(NFS41_MOUNT_CONFIG)); | |
| 311 | 298 | ||
| 312 | - | ||
| 299 | + | + Config->Port = MOUNT_CONFIG_NFS_PORT_DEFAULT; | |
| 313 | - | ||
| 300 | + | Config->ReadSize = MOUNT_CONFIG_RW_SIZE_DEFAULT; | |
| 314 | - | ||
| 301 | + | Config->WriteSize = MOUNT_CONFIG_RW_SIZE_DEFAULT; | |
| 315 | - | ||
| 302 | + | Config->ReadOnly = FALSE; | |
| 316 | - | ||
| 303 | + | @@ -2724,6 +2741,11 @@ NTSTATUS nfs41_MountConfig_ParseOptions( | |
| 317 | - | ||
| 304 | + | else | |
| 318 | - | ||
| 305 | + | RtlCopyUnicodeString(&Config->SrvName, &usValue); | |
| 319 | - | ||
| 306 | + | } | |
| 320 | - | ||
| 307 | + | + else if (wcsncmp(L"port", Name, NameLen) == 0) { | |
| 321 | - | ||
| 308 | + | + status = nfs41_MountConfig_ParseDword(Option, &usValue, | |
| 322 | - | ||
| 309 | + | + &Config->Port, 1, | |
| 323 | - | ||
| 310 | + | + 65535); | |
| 324 | - | ||
| 311 | + | + } | |
| 325 | - | ||
| 312 | + | else if (wcsncmp(L"mntpt", Name, NameLen) == 0) { | |
| 326 | - | ||
| 313 | + | if (usValue.Length > Config->MntPt.MaximumLength) | |
| 327 | - | ||
| 314 | + | status = STATUS_NAME_TOO_LONG; | |
| 328 | - | ||
| 315 | + | @@ -2910,6 +2932,8 @@ NTSTATUS nfs41_CreateVNetRoot( | |
| 329 | - | ||
| 316 | + | nfs41_MountConfig_InitDefaults(Config); | |
| 330 | 317 | ||
| 331 | - | ||
| 318 | + | if (pCreateNetRootContext->RxContext->Create.EaLength) { | |
| 332 | - | ||
| 319 | + | + /* Codepath for nfs_mount.exe */ | |
| 333 | - | ||
| 320 | + | + | |
| 334 | - | ||
| 321 | + | /* parse the extended attributes for mount options */ | |
| 335 | - | ||
| 322 | + | status = nfs41_MountConfig_ParseOptions( | |
| 336 | - | ||
| 323 | + | pCreateNetRootContext->RxContext->Create.EaBuffer, | |
| 337 | - | ||
| 324 | + | @@ -2920,13 +2944,25 @@ NTSTATUS nfs41_CreateVNetRoot( | |
| 338 | - | ||
| 325 | + | pVNetRootContext->read_only = Config->ReadOnly; | |
| 339 | - | ||
| 326 | + | pVNetRootContext->write_thru = Config->write_thru; | |
| 340 | - | ||
| 327 | + | pVNetRootContext->nocache = Config->nocache; | |
| 341 | - | ||
| 328 | + | + pVNetRootContext->port = Config->Port; | |
| 342 | - | ||
| 329 | + | } else { | |
| 343 | - | ||
| 330 | + | + /* Codepath for \\server:port\nfs4\path */ | |
| 344 | - | ||
| 331 | + | + | |
| 345 | - | ||
| 332 | + | /* use the SRV_CALL name (without leading \) as the hostname */ | |
| 346 | - | ||
| 333 | + | Config->SrvName.Buffer = pSrvCall->pSrvCallName->Buffer + 1; | |
| 347 | - | ||
| 334 | + | Config->SrvName.Length = | |
| 348 | - | ||
| 335 | + | pSrvCall->pSrvCallName->Length - sizeof(WCHAR); | |
| 349 | - | ||
| 336 | + | Config->SrvName.MaximumLength = | |
| 350 | - | ||
| 337 | + | pSrvCall->pSrvCallName->MaximumLength - sizeof(WCHAR); | |
| 351 | - | ||
| 338 | + | + /* | |
| 352 | - | ||
| 339 | + | + * gisburn: FIXME: Using |port| here is wrong: | |
| 353 | - | ||
| 340 | + | + * TCP port information should be encoded in the server name | |
| 354 | - | ||
| 341 | + | + * (e.g. \\server@port\nfs4\path, to make sure we do not get | |
| 355 | - | ||
| 342 | + | + * conflicts in case of (ssh) port forwarding | |
| 356 | - | ||
| 343 | + | + * (see https://learn.microsoft.com/en-gb/windows/win32/api/davclnt/nf-davclnt-davgethttpfromuncpath | |
| 357 | - | ||
| 344 | + | + * how to specify ports in an UNC path) | |
| 358 | - | ||
| 345 | + | + */ | |
| 359 | - | ||
| 346 | + | + Config->Port = pVNetRootContext->port; | |
| 360 | - | ||
| 347 | + | } | |
| 361 | - | ||
| 348 | + | pVNetRootContext->MountPathLen = Config->MntPt.Length; | |
| 362 | - | ||
| 349 | + | pVNetRootContext->timeout = Config->timeout; | |
| 363 | 350 |
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.
rovema.kpaste.net RSS