- From 7a23c6a197ea15d5411a31bda7b127e5ae608edb Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 12 Feb 2024 08:05:06 +0100
- Subject: [PATCH 1/5] daemon, sys: Propagate |ERROR_NONE_MAPPED| correctly and
- add more ACL debug output
- Propagate SETACL |ERROR_NONE_MAPPED| correctly and add more debug output
- to ACL codepath.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/acl.c | 81 +++++++++++++++++++++++++++++-----------------
- sys/nfs41_driver.c | 1 +
- 2 files changed, 52 insertions(+), 30 deletions(-)
- diff --git a/daemon/acl.c b/daemon/acl.c
- index 67ceb1a..499085e 100644
- --- a/daemon/acl.c
- +++ b/daemon/acl.c
- @@ -459,12 +459,14 @@ static void map_acemask(ACCESS_MASK mask, int file_type, uint32_t *nfs4_mask)
- static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_out, char *domain)
- {
- - int status = ERROR_INTERNAL_ERROR;
- + int status;
- DWORD size = 0, tmp_size = 0;
- SID_NAME_USE sid_type;
- LPSTR tmp_buf = NULL, who = NULL;
- LPSTR sidstr = NULL;
- + DPRINTF(ACLLVL, ("--> map_nfs4ace_who(sid=0x%p,owner_sid=0x%p, group_sid=0x%p)\n"));
- +
- /* for ace mapping, we want to map owner's sid into "owner@"
- * but for set_owner attribute we want to map owner into a user name
- * same applies to group
- @@ -474,14 +476,16 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
- if (EqualSid(sid, owner_sid)) {
- DPRINTF(ACLLVL, ("map_nfs4ace_who: this is owner's sid\n"));
- memcpy(who_out, ACE4_OWNER, strlen(ACE4_OWNER)+1);
- - return ERROR_SUCCESS;
- + status = ERROR_SUCCESS;
- + goto out;
- }
- }
- if (group_sid) {
- if (EqualSid(sid, group_sid)) {
- DPRINTF(ACLLVL, ("map_nfs4ace_who: this is group's sid\n"));
- memcpy(who_out, ACE4_GROUP, strlen(ACE4_GROUP)+1);
- - return ERROR_SUCCESS;
- + status = ERROR_SUCCESS;
- + goto out;
- }
- }
- status = is_well_known_sid(sid, who_out);
- @@ -490,8 +494,9 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
- size = (DWORD)strlen(ACE4_NOBODY);
- goto add_domain;
- }
- - else
- - return ERROR_SUCCESS;
- +
- + status = ERROR_SUCCESS;
- + goto out;
- }
- if (!ConvertSidToStringSidA(sid, &sidstr)) {
- @@ -533,8 +538,18 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
- }
- status = GetLastError();
- - if (status != ERROR_INSUFFICIENT_BUFFER)
- - return ERROR_INTERNAL_ERROR;
- + if (status == ERROR_NONE_MAPPED) {
- + DPRINTF(1, ("LookupAccountSidA() returned success, "
- + "GetLastError() returned ERROR_NONE_MAPPED\n"));
- + goto out;
- + }
- +
- + if (status != ERROR_INSUFFICIENT_BUFFER) {
- + DPRINTF(1, ("LookupAccountSidA() returned success, "
- + "GetLastError() returned %d\n", status));
- + status = ERROR_INTERNAL_ERROR;
- + goto out;
- + }
- who = malloc(size);
- if (who == NULL) {
- status = GetLastError();
- @@ -559,6 +574,7 @@ add_domain:
- if (who) free(who);
- status = ERROR_SUCCESS;
- out:
- + DPRINTF(ACLLVL, ("<-- map_nfs4ace_who() returns %d\n", status));
- if (sidstr)
- LocalFree(sidstr);
- return status;
- @@ -654,44 +670,49 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
- nfsacl41 nfs4_acl = { 0 };
- PSID sid = NULL, gsid = NULL;
- BOOL sid_default, gsid_default;
- + char ownerbuf[NFS4_OPAQUE_LIMIT+1];
- + char groupbuf[NFS4_OPAQUE_LIMIT+1];
- +
- + DPRINTF(ACLLVL, ("--> handle_setacl()\n"));
- if (args->query & OWNER_SECURITY_INFORMATION) {
- - char owner[NFS4_OPAQUE_LIMIT];
- DPRINTF(ACLLVL, ("handle_setacl: OWNER_SECURITY_INFORMATION\n"));
- status = GetSecurityDescriptorOwner(args->sec_desc, &sid, &sid_default);
- if (!status) {
- status = GetLastError();
- - eprintf("GetSecurityDescriptorOwner failed with %d\n", status);
- + eprintf("handle_setacl: GetSecurityDescriptorOwner failed with %d\n", status);
- goto out;
- }
- - info.owner = owner;
- - status = map_nfs4ace_who(sid, NULL, NULL, info.owner, nfs41dg->localdomain_name);
- +
- + status = map_nfs4ace_who(sid, NULL, NULL, ownerbuf,
- + nfs41dg->localdomain_name);
- if (status)
- goto out;
- - else {
- - info.attrmask.arr[1] |= FATTR4_WORD1_OWNER;
- - info.attrmask.count = 2;
- - }
- +
- + info.owner = ownerbuf;
- + info.attrmask.arr[1] |= FATTR4_WORD1_OWNER;
- + info.attrmask.count = 2;
- }
- +
- if (args->query & GROUP_SECURITY_INFORMATION) {
- - char group[NFS4_OPAQUE_LIMIT];
- DPRINTF(ACLLVL, ("handle_setacl: GROUP_SECURITY_INFORMATION\n"));
- status = GetSecurityDescriptorGroup(args->sec_desc, &sid, &sid_default);
- if (!status) {
- status = GetLastError();
- - eprintf("GetSecurityDescriptorOwner failed with %d\n", status);
- + eprintf("handle_setacl: GetSecurityDescriptorOwner failed with %d\n", status);
- goto out;
- }
- - info.owner_group = group;
- - status = map_nfs4ace_who(sid, NULL, NULL, info.owner_group,
- - nfs41dg->localdomain_name);
- +
- + status = map_nfs4ace_who(sid, NULL, NULL, groupbuf,
- + nfs41dg->localdomain_name);
- if (status)
- goto out;
- - else {
- - info.attrmask.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
- - info.attrmask.count = 2;
- - }
- +
- + info.owner_group = groupbuf;
- + info.attrmask.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
- + info.attrmask.count = 2;
- }
- +
- if (args->query & DACL_SECURITY_INFORMATION) {
- BOOL dacl_present, dacl_default;
- PACL acl;
- @@ -719,12 +740,11 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
- nfs41dg->localdomain_name);
- if (status)
- goto out;
- - else {
- - info.acl = &nfs4_acl;
- - info.attrmask.arr[0] |= FATTR4_WORD0_ACL;
- - if (!info.attrmask.count)
- - info.attrmask.count = 1;
- - }
- +
- + info.acl = &nfs4_acl;
- + info.attrmask.arr[0] |= FATTR4_WORD0_ACL;
- + if (!info.attrmask.count)
- + info.attrmask.count = 1;
- }
- /* break read delegations before SETATTR */
- @@ -742,6 +762,7 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
- if (args->query & DACL_SECURITY_INFORMATION)
- free(nfs4_acl.aces);
- out:
- + DPRINTF(ACLLVL, ("<-- handle_setacl() returning %d\n", status));
- return status;
- }
- diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
- index b102aab..b8bfb61 100644
- --- a/sys/nfs41_driver.c
- +++ b/sys/nfs41_driver.c
- @@ -5192,6 +5192,7 @@ NTSTATUS map_query_acl_error(
- switch (error) {
- case NO_ERROR: return STATUS_SUCCESS;
- case ERROR_NOT_SUPPORTED: return STATUS_NOT_SUPPORTED;
- + case ERROR_NONE_MAPPED: return STATUS_NONE_MAPPED;
- case ERROR_ACCESS_DENIED: return STATUS_ACCESS_DENIED;
- case ERROR_FILE_NOT_FOUND: return STATUS_OBJECT_NAME_NOT_FOUND;
- case ERROR_INVALID_PARAMETER: return STATUS_INVALID_PARAMETER;
- --
- 2.43.0
- From 80d750bd1c24130a57e16b20c97089015c1d93ca Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 12 Feb 2024 08:34:06 +0100
- Subject: [PATCH 2/5] daemon: Add |print_sid()| debug function to print SID
- string value
- Add |print_sid()| debug function to print SID string value with a text
- label to debug output.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/acl.c | 8 ++++++++
- daemon/daemon_debug.c | 18 ++++++++++++++++++
- daemon/daemon_debug.h | 2 ++
- 3 files changed, 28 insertions(+)
- diff --git a/daemon/acl.c b/daemon/acl.c
- index 499085e..6abe530 100644
- --- a/daemon/acl.c
- +++ b/daemon/acl.c
- @@ -473,6 +473,10 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
- */
- status = 0;
- if (owner_sid) {
- + if (DPRINTF_LEVEL_ENABLED(ACLLVL)) {
- + print_sid("owner_sid", owner_sid);
- + }
- +
- if (EqualSid(sid, owner_sid)) {
- DPRINTF(ACLLVL, ("map_nfs4ace_who: this is owner's sid\n"));
- memcpy(who_out, ACE4_OWNER, strlen(ACE4_OWNER)+1);
- @@ -481,6 +485,10 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
- }
- }
- if (group_sid) {
- + if (DPRINTF_LEVEL_ENABLED(ACLLVL)) {
- + print_sid("group_sid", group_sid);
- + }
- +
- if (EqualSid(sid, group_sid)) {
- DPRINTF(ACLLVL, ("map_nfs4ace_who: this is group's sid\n"));
- memcpy(who_out, ACE4_GROUP, strlen(ACE4_GROUP)+1);
- diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
- index 4187b91..e632233 100644
- --- a/daemon/daemon_debug.c
- +++ b/daemon/daemon_debug.c
- @@ -22,6 +22,7 @@
- #include <windows.h>
- #include <stdio.h>
- +#include <sddl.h>
- #include "daemon_debug.h"
- #include "from_kernel.h"
- @@ -297,6 +298,23 @@ void print_file_id_both_dir_info(int level, FILE_ID_BOTH_DIR_INFO *pboth_dir_inf
- pboth_dir_info->FileName);
- }
- +void print_sid(const char *label, PSID sid)
- +{
- + PSTR sidstr = NULL;
- +
- + if (ConvertSidToStringSidA(sid, &sidstr)) {
- + dprintf_out("%s=SID('%s')\n", label, sidstr);
- + LocalFree(sidstr);
- + }
- + else {
- + int status;
- +
- + status = GetLastError();
- + dprintf_out("%s=<ConvertSidToStringSidA() failed error=%d>\n",
- + label, status);
- + }
- +}
- +
- const char* opcode2string(DWORD opcode)
- {
- switch(opcode) {
- diff --git a/daemon/daemon_debug.h b/daemon/daemon_debug.h
- index b89c1d9..65e7d2a 100644
- --- a/daemon/daemon_debug.h
- +++ b/daemon/daemon_debug.h
- @@ -3,6 +3,7 @@
- *
- * Olga Kornievskaia <aglo@umich.edu>
- * Casey Bodley <cbodley@umich.edu>
- + * Roland Mainz <roland.mainz@nrubsig.org>
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- @@ -90,6 +91,7 @@ void print_disposition(int level, DWORD disposition);
- void print_access_mask(int level, DWORD access_mask);
- void print_share_mode(int level, DWORD mode);
- void print_file_id_both_dir_info(int level, FILE_ID_BOTH_DIR_INFO *p);
- +void print_sid(const char *label, PSID sid);
- const char* opcode2string(DWORD opcode);
- const char* nfs_opnum_to_string(int opnum);
- const char* nfs_error_string(int status);
- --
- 2.43.0
- From b727d65785205a16909e7e385d248c825af87cc0 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 12 Feb 2024 10:54:38 +0100
- Subject: [PATCH 3/5] tests: Add chown/chgrp/cp -p/mv tests to
- manual_testing.txt until we have a test suite
- Add chown/chgrp/cp -p/mv tests to manual_testing.txt until we have a test
- suite.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- tests/manual_testing.txt | 16 +++++++++++++++-
- 1 file changed, 15 insertions(+), 1 deletion(-)
- diff --git a/tests/manual_testing.txt b/tests/manual_testing.txt
- index 9d33d90..83407a9 100644
- --- a/tests/manual_testing.txt
- +++ b/tests/manual_testing.txt
- @@ -1,5 +1,5 @@
- #
- -# ms-nfs41-client manual testing sequence, 2024-01-05
- +# ms-nfs41-client manual testing sequence, 2024-02-12
- #
- # Draft version, needs to be turned into automated tests
- # if possible
- @@ -11,6 +11,20 @@
- # net start cygserver
- # sc query cygserver
- +#
- +# Tests for cp -p/mv/chmod/chgrp
- +# Testcases, all should print *ONLY* "OK" on stdout, nothing on stderr
- +---- snip ----
- +ksh93 -c 'builtin mv ; rm -f /tmp/x y ; touch /tmp/x ; mv /tmp/x y && print OK ; true'
- +ksh93 -c 'builtin mv ; rm -f /tmp/x y ; touch /tmp/x ; cp -p /tmp/x y && print OK ; true'
- +ksh93 -c 'builtin cp ; rm -f /tmp/x y ; touch /tmp/x ; cp -p /tmp/x y && print OK ; true'
- +ksh93 -c 'builtin cp ; rm -f x y ; touch x ; cp -p /tmp/x y && print OK ; true'
- +ksh93 -c 'builtin cp ; rm -f x y ; touch x ; cp -p x y && print OK ; true'
- +ksh93 -c 'builtin cp ; rm -f x y ; touch x ; /usr/bin/cp -p x y && print OK ; true'
- +ksh93 -c 'builtin id ; rm -f x ; touch x ; chown "$(id -u -n):$(id -g -n)" x && print OK'
- +ksh93 -c 'builtin id ; rm -f x ; touch x ; chgrp "$(id -g -n)" x && print OK'
- +---- snip ----
- +
- #
- # Compile each of the following package
- --
- 2.43.0
- From 43f3bc86adfdfe82bbe55183201f821a6e7330c2 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 12 Feb 2024 15:15:58 +0100
- Subject: [PATCH 4/5] daemon: Move SID cache build config to
- "nfs41_build_features.h"
- Add |NFS41_DRIVER_SID_CACHE| config flag to "nfs41_build_features.h"
- to control whether we build the username/groupname-to-SID cache
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/nfs41_daemon.c | 4 ++++
- daemon/sid.c | 20 ++++++++------------
- nfs41_build_features.h | 11 ++++++++---
- 3 files changed, 20 insertions(+), 15 deletions(-)
- diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
- index b5edc25..49567c6 100644
- --- a/daemon/nfs41_daemon.c
- +++ b/daemon/nfs41_daemon.c
- @@ -525,7 +525,11 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv)
- set_debug_level(cmd_args.debug_level);
- open_log_files();
- nfsd_crt_debug_init();
- +#ifdef NFS41_DRIVER_SID_CACHE
- sidcache_init();
- +#else
- + DPRINTF(0, ("SID cache disabled\n"));
- +#endif /* NFS41_DRIVER_SID_CACHE */
- /* acquire and store in global memory current dns domain name.
- * needed for acls */
- diff --git a/daemon/sid.c b/daemon/sid.c
- index b522232..f0091af 100644
- --- a/daemon/sid.c
- +++ b/daemon/sid.c
- @@ -176,11 +176,7 @@ BOOL allocate_unixgroup_sid(unsigned long gid, PSID *pSid)
- #endif /* NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID */
- -/* fixme: should be in sys/nfs41_build_features.h */
- -#define USE_SID_CACHE 1
- -
- -
- -#ifdef USE_SID_CACHE
- +#ifdef NFS41_DRIVER_SID_CACHE
- #define SIDCACHE_SIZE 20
- #define SIDCACHE_TTL 600
- @@ -305,7 +301,7 @@ done:
- LeaveCriticalSection(&cache->lock);
- return ret_sid;
- }
- -#endif /* USE_SID_CACHE */
- +#endif /* NFS41_DRIVER_SID_CACHE */
- int map_nfs4servername_2_sid(nfs41_daemon_globals *nfs41dg, int query, DWORD *sid_len, PSID *sid, LPCSTR name)
- @@ -328,17 +324,17 @@ int map_nfs4servername_2_sid(nfs41_daemon_globals *nfs41dg, int query, DWORD *si
- uid_t udummy = -1;
- gid_t gdummy = -1;
- -#ifdef USE_SID_CACHE
- +#ifdef NFS41_DRIVER_SID_CACHE
- if (*sid = sidcache_getcached(&user_sidcache, name)) {
- *sid_len = GetLengthSid(*sid);
- DPRINTF(1, ("map_nfs4servername_2_sid: returning cached sid for '%s'\n", name));
- return 0;
- }
- -#endif /* USE_SID_CACHE */
- +#endif /* NFS41_DRIVER_SID_CACHE */
- -#ifndef USE_SID_CACHE
- +#ifndef NFS41_DRIVER_SID_CACHE
- /* gisburn: fixme: We must cache this, or the performance impact will be devastating!! */
- -#endif /* !USE_SID_CACHE */
- +#endif /* !NFS41_DRIVER_SID_CACHE */
- if (!cygwin_getent_passwd(name, name_buff, &udummy, &gdummy)) {
- if (strcmp(name, name_buff)) {
- DPRINTF(1,
- @@ -486,14 +482,14 @@ int map_nfs4servername_2_sid(nfs41_daemon_globals *nfs41dg, int query, DWORD *si
- break;
- }
- out:
- -#ifdef USE_SID_CACHE
- +#ifdef NFS41_DRIVER_SID_CACHE
- if (*sid) {
- /* fixme: No other flags in |query| must be set!! */
- if (query & OWNER_SECURITY_INFORMATION) {
- sidcache_add(&user_sidcache, orig_name, *sid);
- }
- }
- -#endif /* USE_SID_CACHE */
- +#endif /* NFS41_DRIVER_SID_CACHE */
- return status;
- out_free_sid:
- diff --git a/nfs41_build_features.h b/nfs41_build_features.h
- index 3fdbe05..bb87fc0 100644
- --- a/nfs41_build_features.h
- +++ b/nfs41_build_features.h
- @@ -48,10 +48,9 @@
- #define NFS41_DRIVER_FEATURE_IDMAPPER_CYGWIN 1
- /*
- - * NFS41_DRIVER_STABILITY_HACKS - use horrible
- - * hacks to improve stabilty
- + * Enable cache for username/groupname to SID
- */
- -#define NFS41_DRIVER_STABILITY_HACKS 1
- +#define NFS41_DRIVER_SID_CACHE 1
- /*
- * NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX - nfs_mount.exe and
- @@ -64,4 +63,10 @@
- */
- #define NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX 1
- +/*
- + * NFS41_DRIVER_STABILITY_HACKS - use horrible
- + * hacks to improve stabilty
- + */
- +#define NFS41_DRIVER_STABILITY_HACKS 1
- +
- #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */
- --
- 2.43.0
- From 8c96f9a37f87c2e7c42f466b8f9ebadde9f99f8c Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 12 Feb 2024 16:25:34 +0100
- Subject: [PATCH 5/5] mount: nfs_mount should print nfs://-URL when listing all
- mounted nfs4 fs
- nfs_mount.exe should print nfs://-URL when listing all mounted nfs4
- filesystems.
- ToDo:
- In the future the default output should be better formatted and
- have an option to select which information should be presented.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- mount/enum.c | 116 +++++++++++++++++++++++++++++++++++++++++++++-----
- mount/mount.c | 1 -
- 2 files changed, 105 insertions(+), 12 deletions(-)
- diff --git a/mount/enum.c b/mount/enum.c
- index c9a6e38..5473a71 100644
- --- a/mount/enum.c
- +++ b/mount/enum.c
- @@ -27,24 +27,31 @@
- #include "nfs41_build_features.h"
- #include "nfs41_driver.h" /* NFS41_PROVIDER_NAME_A */
- +/* prototypes */
- +char *wcs2utf8str(const wchar_t *wstr);
- +void PrintErrorMessage(IN DWORD dwError);
- -void PrintErrorMessage(
- - IN DWORD dwError);
- -
- +/* fixme: this function needs a cleanup */
- static __inline
- void PrintMountLine(
- LPCTSTR local,
- LPCTSTR remote)
- {
- TCHAR *cygwin_unc_buffer = alloca((_tcslen(remote)+32)*sizeof(TCHAR));
- - TCHAR *b = cygwin_unc_buffer;
- - LPCTSTR s = remote;
- + char *cygwin_nfsurl_buffer = alloca(((_tcslen(remote)+32)*3));
- + TCHAR *b;
- + LPCTSTR s;
- TCHAR sc;
- #ifndef NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX
- - unsigned int backslash_counter = 0;
- + unsigned int backslash_counter;
- #endif
- - while((sc = *s++) != TEXT('\0')) {
- + for(b = cygwin_unc_buffer, s = remote
- +#ifndef NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX
- + , backslash_counter = 0
- +#endif
- + ;
- + (sc = *s++) != TEXT('\0') ; ) {
- switch(sc) {
- case TEXT('\\'):
- *b++ = TEXT('/');
- @@ -61,8 +68,93 @@ void PrintMountLine(
- }
- }
- *b = TEXT('\0');
- -// FIXME: We should print the URL
- - _tprintf(TEXT("%-8s\t%-40s\t%s\n"), local, remote, cygwin_unc_buffer);
- +
- +
- + /*
- + * print nfs://-URL
- + */
- +/*
- + * From RFC 1738 ("Uniform Resource Locators (URL)"):
- + * unsafe characters in URLS:
- + * "{", "}", "|", "\", "^", "~", "[", "]", and "`"
- + * characters which must always be encoded:
- + * "#", "%"
- + * characters which must be encoded because they have a special meaning:
- + * ";", "/", "?", ":", "@", "=" and "&"
- + * Only alphanumerics, "$-_.+!*'()," and reserved characters
- + * ("/" for nfs://-URLS) are allowed
- + */
- +#define ISVALIDURLCHAR(c) \
- + ( \
- + ((c) >= '0' && (c) <= '9') || \
- + ((c) >= 'a' && (c) <= 'z') || \
- + ((c) >= 'A' && (c) <= 'Z') || \
- + ((c) == '$') || ((c) == '-') || ((c) == '_') || ((c) == '.') || \
- + ((c) == '+') || ((c) == '!') || ((c) == '*') || ((c) == '\'') || \
- + ((c) == '(') || ((c) == ')') || ((c) == ',') || ((c) == '/') \
- + )
- +
- + unsigned int slash_counter = 0;
- + char *utf8unc = wcs2utf8str(cygwin_unc_buffer);
- + if (!utf8unc)
- + return;
- + char *utf8unc_p = utf8unc;
- + char *us = cygwin_nfsurl_buffer;
- +
- +#pragma warning( push )
- + /*
- + * Disable "'strcpy': This function or variable may be unsafe",
- + * in this context it is safe to use
- + */
- +#pragma warning (disable : 4996)
- + (void)strcpy(us, "nfs://");
- +#pragma warning( pop )
- + us+=6;
- +
- + /* skip leading "//" */
- + utf8unc_p += 2;
- +
- + for ( ; *utf8unc_p != '\0' ; ) {
- + char uc = *utf8unc_p++;
- +
- + if (uc == '/')
- + slash_counter++;
- +
- + /*
- + * Skip "nfs4", but not the last '/' to make the nfs://-URL
- + * an absolute URL, not a relative nfs://-URL.
- + * (This assumes that all input strings have "nfs4/"!)
- + */
- + if (slash_counter == 1) {
- + *us++ = uc;
- + utf8unc_p+=4;
- + continue;
- + }
- +
- + if ((uc == '@') && (slash_counter == 0)) {
- + *us++ = ':';
- + }
- + else if (ISVALIDURLCHAR(uc)) {
- + *us++ = uc;
- + }
- + else {
- +#pragma warning( push )
- + /*
- + * Disable "'sprintf': This function or variable may be unsafe",
- + * in this context it is safe to use
- + */
- +#pragma warning (disable : 4996)
- + (void)sprintf(us, "%%%2.2x", uc);
- +#pragma warning( pop )
- + us+=3;
- + }
- + }
- + *us = '\0';
- +
- + (void)_tprintf(TEXT("%-8s\t%-50s\t%-50s\t%-50S\n"),
- + local, remote, cygwin_unc_buffer, cygwin_nfsurl_buffer);
- +
- + free(utf8unc);
- }
- /* ENUM_RESOURCE_BUFFER_SIZE
- @@ -94,8 +186,10 @@ DWORD EnumMounts(
- if (result)
- goto out_free;
- - _tprintf(TEXT("Listing '%s' mounts:\n\n"), TEXT(NFS41_PROVIDER_NAME_A));
- - _tprintf(TEXT("%-8s\t%-40s\t%s\n"), TEXT("Volume"), TEXT("Remote path"), TEXT("Cygwin UNC path"));
- + (void)_tprintf(TEXT("Listing '%s' mounts:\n\n"),
- + TEXT(NFS41_PROVIDER_NAME_A));
- + (void)_tprintf(TEXT("%-8s\t%-50s\t%-50s\t%-50S\n"),
- + TEXT("Volume"), TEXT("Remote path"), TEXT("Cygwin UNC path"), "URL");
- do
- {
- diff --git a/mount/mount.c b/mount/mount.c
- index 01e5890..d480d05 100644
- --- a/mount/mount.c
- +++ b/mount/mount.c
- @@ -293,7 +293,6 @@ static void ConvertUnixSlashes(
- }
- -static
- char *wcs2utf8str(const wchar_t *wstr)
- {
- char *utf8str;
- --
- 2.43.0
msnfs41client: Patch for cp -p/mv/chown/chgrp error code propagation, nfs_mount.exe printing nfs://-URLs + misc, 2024-02-12
Posted by Anonymous on Mon 12th Feb 2024 15:50
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.