pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for Win32 *.inf, performance regression, per-user/logon mount namespaces+misc, 2024-06-13
Posted by Anonymous on Thu 13th Jun 2024 16:34
raw | new post

  1. From 4e5b7afe2e2417ebd0d821a23b6dc248f22f299c Mon Sep 17 00:00:00 2001
  2. From: Cedric Blancher <cedric.blancher@gmail.com>
  3. Date: Thu, 13 Jun 2024 09:08:18 +0200
  4. Subject: [PATCH 1/4] cygwin,nfs41rdr.inf: Add "removedriver" to msnfs41client,
  5.  fix nfs41rdr.inf, retire install bat
  6.  
  7. Add "removedriver" subcmd to msnfs41clientbash, fix nfs41rdr.inf,
  8. and retire install.bat+uninstall.bat
  9.  
  10. Signed-off-by: Roland Mainz <roland.mainz@nrubsig.org>
  11. ---
  12. cygwin/devel/msnfs41client.bash | 78 +++++++++++++++++++++++++++------
  13.  install.bat                     |  2 -
  14.  nfs41rdr.inf                    |  8 ++--
  15.  uninstall.bat                   |  2 -
  16.  4 files changed, 68 insertions(+), 22 deletions(-)
  17.  delete mode 100644 install.bat
  18.  delete mode 100644 uninstall.bat
  19.  
  20. diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
  21. index 2b66485..c83dcfc 100644
  22. --- a/cygwin/devel/msnfs41client.bash
  23. +++ b/cygwin/devel/msnfs41client.bash
  24. @@ -98,19 +98,8 @@ function nfsclient_install
  25.         chmod a+x *.dll
  26.         chmod a+x ../../sbin/nfs*.exe ../../sbin/libtirpc*.dll
  27.  
  28. -       if false ; then
  29. -               # install.bat needs PATH to include $PWD
  30. -               PATH="$PWD:$PATH" cmd /c install.bat
  31. -       else
  32. -               # devel: set default in case "nfs_install" ruined it:
  33. -               #regtool -s set '/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/NetworkProvider/Order/ProviderOrder' 'RDPNP,LanmanWorkstation,webclient'
  34. -
  35. -               printf 'before nfs_install: ProviderOrder="%s"\n' "$( strings -a '/proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/NetworkProvider/Order/ProviderOrder')"
  36. -               nfs_install -D
  37. -               printf 'after nfs_install:  ProviderOrder="%s"\n' "$( strings -a '/proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/NetworkProvider/Order/ProviderOrder')"
  38. -
  39. -               rundll32 setupapi.dll,InstallHinfSection DefaultInstall 132 ./nfs41rdr.inf
  40. -       fi
  41. +       # (re-)install driver
  42. +       nfsclient_adddriver
  43.  
  44.         mkdir -p /cygdrive/c/etc
  45.         cp etc_netconfig /cygdrive/c/etc/netconfig
  46. @@ -206,6 +195,52 @@ function nfsclient_install
  47.         return 0
  48.  }
  49.  
  50. +function nfsclient_adddriver
  51. +{
  52. +       set -o nounset
  53. +       set -o xtrace
  54. +       set -o errexit
  55. +
  56. +       # switch to the location where this script is installed,
  57. +       # because on Cygwin the script will be installed
  58. +       # in /cygdrive/c/cygwin/lib/msnfs41client/ (32bit) or
  59. +       # in /cygdrive/c/cygwin64/lib/msnfs41client/ (64bit).
  60. +       cd -P "$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")"
  61. +
  62. +       # devel: set default in case "nfs_install" ruined it:
  63. +       #regtool -s set '/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/NetworkProvider/Order/ProviderOrder' 'RDPNP,LanmanWorkstation,webclient'
  64. +
  65. +       printf 'before nfs_install: ProviderOrder="%s"\n' "$( strings -a '/proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/NetworkProvider/Order/ProviderOrder')"
  66. +       nfs_install -D
  67. +       printf 'after nfs_install:  ProviderOrder="%s"\n' "$( strings -a '/proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/NetworkProvider/Order/ProviderOrder')"
  68. +
  69. +       rundll32 setupapi.dll,InstallHinfSection DefaultInstall 132 ./nfs41rdr.inf
  70. +
  71. +       return 0
  72. +}
  73. +
  74. +function nfsclient_removedriver
  75. +{
  76. +       set -o nounset
  77. +       set -o xtrace
  78. +       set -o errexit
  79. +
  80. +       # switch to the location where this script is installed,
  81. +       # because on Cygwin the script will be installed
  82. +       # in /cygdrive/c/cygwin/lib/msnfs41client/ (32bit) or
  83. +       # in /cygdrive/c/cygwin64/lib/msnfs41client/ (64bit).
  84. +       cd -P "$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")"
  85. +
  86. +       nfs_install.exe 0
  87. +       rundll32.exe setupapi.dll,InstallHinfSection DefaultUninstall 132 ./nfs41rdr.inf
  88. +       rm /cygdrive/c/Windows/System32/nfs41_np.dll || true
  89. +       rm /cygdrive/c/Windows/System32/drivers/nfs41_driver.sys || true
  90. +
  91. +       sync
  92. +
  93. +       return 0
  94. +}
  95. +
  96.  function nfsclient_rundeamon
  97.  {
  98.         set -o nounset
  99. @@ -591,6 +626,23 @@ function main
  100.                         nfsclient_install
  101.                         return $?
  102.                         ;;
  103. +               #
  104. +               # 'removedriver' should only be used by developers,
  105. +               # as 'install' can always overwrite an existing driver
  106. +               #
  107. +               'removedriver')
  108. +                       check_machine_arch || (( numerr++ ))
  109. +                       require_cmd 'nfs_install.exe' || (( numerr++ ))
  110. +                       require_cmd 'rundll32.exe' || (( numerr++ ))
  111. +                       if ! is_windows_admin_account ; then
  112. +                               printf $"%s: %q requires Windows Adminstator permissions.\n" "$0" "$cmd"
  113. +                               (( numerr++ ))
  114. +                       fi
  115. +                       (( numerr > 0 )) && return 1
  116. +
  117. +                       nfsclient_removedriver
  118. +                       return $?
  119. +                       ;;
  120.                 'run_deamon' | 'run_daemon')
  121.                         check_machine_arch || (( numerr++ ))
  122.                         #require_cmd 'cdb.exe' || (( numerr++ ))
  123. diff --git a/install.bat b/install.bat
  124. deleted file mode 100644
  125. index cd79372..0000000
  126. --- a/install.bat
  127. +++ /dev/null
  128. @@ -1,2 +0,0 @@
  129. -nfs_install.exe
  130. -rundll32.exe setupapi.dll,InstallHinfSection DefaultInstall 132 ./nfs41rdr.inf
  131. diff --git a/nfs41rdr.inf b/nfs41rdr.inf
  132. index 02ee912..4274370 100644
  133. --- a/nfs41rdr.inf
  134. +++ b/nfs41rdr.inf
  135. @@ -1,10 +1,8 @@
  136.  [Version]
  137.  Signature="$CHICAGO$"
  138. -DriverVer=05/27/2009,1.0
  139. -ClassGUID={00000000-0000-0000-0000-000000000000}
  140. -;Its possible that we should be using:
  141. -;Class=NetService
  142. -;ClassGUID={4d36e974-e325-11ce-bfc1-08002be10318}
  143. +DriverVer=06/12/2024,1.0.0.0
  144. +Class=NetService
  145. +ClassGUID={4d36e974-e325-11ce-bfc1-08002be10318}
  146.  CatalogFile=catalogfile.cat
  147.  Provider=%ProviderName%
  148.  
  149. diff --git a/uninstall.bat b/uninstall.bat
  150. deleted file mode 100644
  151. index 4c714b3..0000000
  152. --- a/uninstall.bat
  153. +++ /dev/null
  154. @@ -1,2 +0,0 @@
  155. -nfs_install.exe 0
  156. -rundll32.exe setupapi.dll,InstallHinfSection DefaultUninstall 132 ./nfs41rdr.inf
  157. --
  158. 2.45.1
  159.  
  160. From 9d1c82edc9561d3cdd03005d65654c4d0088989a Mon Sep 17 00:00:00 2001
  161. From: Cedric Blancher <cedric.blancher@gmail.com>
  162. Date: Thu, 13 Jun 2024 09:11:54 +0200
  163. Subject: [PATCH 2/4] build.vc19: Kernel drivers for >= Win8 should use
  164.  BufferOverflowfastfailK.lib
  165.  
  166. Kernel drivers for >= Win8 should use "BufferOverflowfastfailK.lib"
  167. instead of "bufferoverflowk.lib".
  168.  
  169. Signed-off-by: Roland Mainz <roland.mainz@nrubsig.org>
  170. ---
  171. build.vc19/nfs41_driver/nfs41_driver.vcxproj | 16 ++++++++--------
  172.  1 file changed, 8 insertions(+), 8 deletions(-)
  173.  
  174. diff --git a/build.vc19/nfs41_driver/nfs41_driver.vcxproj b/build.vc19/nfs41_driver/nfs41_driver.vcxproj
  175. index 2165fc2..39f7bae 100644
  176. --- a/build.vc19/nfs41_driver/nfs41_driver.vcxproj
  177. +++ b/build.vc19/nfs41_driver/nfs41_driver.vcxproj
  178. @@ -142,7 +142,7 @@
  179.        <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
  180.      </ClCompile>
  181.      <Link>
  182. -      <AdditionalDependencies>$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ntoskrnl.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\hal.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\bufferoverflowk.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ksecdd.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rxce.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rdbsslib.lib;$(WindowsSdkDir)lib\win7\km\$(DDKPlatform)\copysup.lib</AdditionalDependencies>
  183. +      <AdditionalDependencies>$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ntoskrnl.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\hal.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\BufferOverflowfastfailK.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ksecdd.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rxce.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rdbsslib.lib;$(WindowsSdkDir)lib\win7\km\$(DDKPlatform)\copysup.lib</AdditionalDependencies>
  184.      </Link>
  185.    </ItemDefinitionGroup>
  186.    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
  187. @@ -154,7 +154,7 @@
  188.        <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
  189.      </ClCompile>
  190.      <Link>
  191. -      <AdditionalDependencies>$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ntoskrnl.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\hal.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\bufferoverflowk.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ksecdd.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rxce.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rdbsslib.lib;$(WindowsSdkDir)lib\win7\km\$(DDKPlatform)\copysup.lib</AdditionalDependencies>
  192. +      <AdditionalDependencies>$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ntoskrnl.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\hal.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\BufferOverflowfastfailK.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ksecdd.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rxce.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rdbsslib.lib;$(WindowsSdkDir)lib\win7\km\$(DDKPlatform)\copysup.lib</AdditionalDependencies>
  193.      </Link>
  194.    </ItemDefinitionGroup>
  195.    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
  196. @@ -166,7 +166,7 @@
  197.        <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
  198.      </ClCompile>
  199.      <Link>
  200. -      <AdditionalDependencies>$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ntoskrnl.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\hal.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\bufferoverflowk.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ksecdd.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rxce.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rdbsslib.lib;$(WindowsSdkDir)lib\win7\km\$(DDKPlatform)\copysup.lib</AdditionalDependencies>
  201. +      <AdditionalDependencies>$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ntoskrnl.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\hal.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\BufferOverflowfastfailK.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ksecdd.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rxce.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rdbsslib.lib;$(WindowsSdkDir)lib\win7\km\$(DDKPlatform)\copysup.lib</AdditionalDependencies>
  202.      </Link>
  203.    </ItemDefinitionGroup>
  204.    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
  205. @@ -178,7 +178,7 @@
  206.        <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
  207.      </ClCompile>
  208.      <Link>
  209. -      <AdditionalDependencies>$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ntoskrnl.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\hal.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\bufferoverflowk.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ksecdd.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rxce.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rdbsslib.lib;$(WindowsSdkDir)lib\win7\km\$(DDKPlatform)\copysup.lib</AdditionalDependencies>
  210. +      <AdditionalDependencies>$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ntoskrnl.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\hal.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\BufferOverflowfastfailK.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ksecdd.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rxce.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rdbsslib.lib;$(WindowsSdkDir)lib\win7\km\$(DDKPlatform)\copysup.lib</AdditionalDependencies>
  211.      </Link>
  212.    </ItemDefinitionGroup>
  213.    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
  214. @@ -190,7 +190,7 @@
  215.        <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
  216.      </ClCompile>
  217.      <Link>
  218. -      <AdditionalDependencies>$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ntoskrnl.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\hal.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\bufferoverflowk.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ksecdd.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rxce.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rdbsslib.lib;$(WindowsSdkDir)lib\win7\km\$(DDKPlatform)\copysup.lib</AdditionalDependencies>
  219. +      <AdditionalDependencies>$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ntoskrnl.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\hal.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\BufferOverflowfastfailK.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ksecdd.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rxce.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rdbsslib.lib;$(WindowsSdkDir)lib\win7\km\$(DDKPlatform)\copysup.lib</AdditionalDependencies>
  220.      </Link>
  221.    </ItemDefinitionGroup>
  222.    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
  223. @@ -202,7 +202,7 @@
  224.        <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
  225.      </ClCompile>
  226.      <Link>
  227. -      <AdditionalDependencies>$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ntoskrnl.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\hal.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\bufferoverflowk.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ksecdd.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rxce.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rdbsslib.lib;$(WindowsSdkDir)lib\win7\km\$(DDKPlatform)\copysup.lib</AdditionalDependencies>
  228. +      <AdditionalDependencies>$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ntoskrnl.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\hal.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\BufferOverflowfastfailK.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ksecdd.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rxce.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rdbsslib.lib;$(WindowsSdkDir)lib\win7\km\$(DDKPlatform)\copysup.lib</AdditionalDependencies>
  229.      </Link>
  230.    </ItemDefinitionGroup>
  231.    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
  232. @@ -214,7 +214,7 @@
  233.        <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
  234.      </ClCompile>
  235.      <Link>
  236. -      <AdditionalDependencies>$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ntoskrnl.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\hal.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\bufferoverflowk.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ksecdd.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rxce.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rdbsslib.lib;$(WindowsSdkDir)lib\win7\km\$(DDKPlatform)\copysup.lib</AdditionalDependencies>
  237. +      <AdditionalDependencies>$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ntoskrnl.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\hal.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\BufferOverflowfastfailK.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ksecdd.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rxce.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rdbsslib.lib;$(WindowsSdkDir)lib\win7\km\$(DDKPlatform)\copysup.lib</AdditionalDependencies>
  238.      </Link>
  239.    </ItemDefinitionGroup>
  240.    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
  241. @@ -226,7 +226,7 @@
  242.        <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
  243.      </ClCompile>
  244.      <Link>
  245. -      <AdditionalDependencies>$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ntoskrnl.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\hal.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\bufferoverflowk.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ksecdd.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rxce.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rdbsslib.lib;$(WindowsSdkDir)lib\win7\km\$(DDKPlatform)\copysup.lib</AdditionalDependencies>
  246. +      <AdditionalDependencies>$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ntoskrnl.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\hal.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\BufferOverflowfastfailK.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\ksecdd.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rxce.lib;$(WindowsSdkDir)lib0.0.19041.0\km\$(DDKPlatform)\rdbsslib.lib;$(WindowsSdkDir)lib\win7\km\$(DDKPlatform)\copysup.lib</AdditionalDependencies>
  247.      </Link>
  248.    </ItemDefinitionGroup>
  249.    <ItemGroup>
  250. --
  251. 2.45.1
  252.  
  253. From 2156996d27f265c26d83a443b7d08629a4a65de7 Mon Sep 17 00:00:00 2001
  254. From: Roland Mainz <roland.mainz@nrubsig.org>
  255. Date: Thu, 13 Jun 2024 09:14:39 +0200
  256. Subject: [PATCH 3/4] daemon: Performace regression, new accesstoken.c misses
  257.  SID cache
  258.  
  259. Fix performace regression, the new accesstoken.c did not include
  260. "nfs41_build_features.h", and therefore the SID cache was not used.
  261.  
  262. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  263. ---
  264. daemon/accesstoken.c | 6 ++++++
  265.  1 file changed, 6 insertions(+)
  266.  
  267. diff --git a/daemon/accesstoken.c b/daemon/accesstoken.c
  268. index a164b4e..8f98b5d 100644
  269. --- a/daemon/accesstoken.c
  270. +++ b/daemon/accesstoken.c
  271. @@ -19,10 +19,16 @@
  272.   * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  273.   */
  274.  
  275. +#include "nfs41_build_features.h"
  276.  #include "accesstoken.h"
  277. +#include "sid.h"
  278.  #include "daemon_debug.h"
  279.  #include <Lmcons.h>
  280.  
  281. +#ifndef _NFS41_DRIVER_BUILDFEATURES_
  282. +#error NFS41 build config not included
  283. +#endif
  284. +
  285.  /*
  286.   * Performance hack:
  287.   * GETTOKINFO_EXTRA_BUFFER - extra space for more data
  288. --
  289. 2.45.1
  290.  
  291. From eed40554e3cb33c1be038c18c5c9d79084d58e3b Mon Sep 17 00:00:00 2001
  292. From: Roland Mainz <roland.mainz@nrubsig.org>
  293. Date: Thu, 13 Jun 2024 17:17:31 +0200
  294. Subject: [PATCH 4/4] daemon,dll,nfs41_build_features.h: Separate mount
  295.  namespaces per |AuthenticationId|
  296.  
  297. Add new build config
  298. |NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE| which
  299. uses |TOKEN_GROUPS_AND_PRIVILEGES.AuthenticationId| for mount
  300. namespace separation between users and different logons of the
  301. same user.
  302. This avoid that mounts from different users can interfere
  303. with each other, e.g. if they are mounted with different
  304. mount (e.g. "rw" vs. "ro") options.
  305.  
  306. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  307. ---
  308. daemon/accesstoken.c   |  13 ++---
  309.  daemon/mount.c         |  39 +++++++++++++++
  310.  daemon/nfs41_client.c  |  24 +++++++--
  311.  dll/nfs41_np.c         | 111 +++++++++++++++++++++++++++++++++++++++--
  312.  dll/nfs41_np.h         |  17 ++++++-
  313.  nfs41_build_features.h |  10 ++++
  314.  6 files changed, 197 insertions(+), 17 deletions(-)
  315.  
  316. diff --git a/daemon/accesstoken.c b/daemon/accesstoken.c
  317. index 8f98b5d..4ad62b1 100644
  318. --- a/daemon/accesstoken.c
  319. +++ b/daemon/accesstoken.c
  320. @@ -32,12 +32,13 @@
  321.  /*
  322.   * Performance hack:
  323.   * GETTOKINFO_EXTRA_BUFFER - extra space for more data
  324. - * |GetTokenInformation()| for |TOKEN_USER| and |TOKEN_PRIMARY_GROUP|
  325. - * always fails in Win10 with |ERROR_INSUFFICIENT_BUFFER| if you
  326. - * just pass the |sizeof(TOKEN_*)| value. Instead of calling
  327. - * |GetTokenInformation()| with |NULL| arg to obtain the size to
  328. - * allocate we just provide 2048 bytes of extra space after the
  329. - * |TOKEN_*| size, and pray it is enough
  330. + * |GetTokenInformation()| for |TOKEN_USER|, |TOKEN_PRIMARY_GROUP|
  331. + * and |TOKEN_GROUPS_AND_PRIVILEGES| always fails in Win10 with
  332. + * |ERROR_INSUFFICIENT_BUFFER| if you just pass the |sizeof(TOKEN_*)|
  333. + * value.
  334. + * Instead of calling |GetTokenInformation()| with |NULL| arg to
  335. + * obtain the size to allocate we just provide 2048 bytes of extra
  336. + * space after the |TOKEN_*| size, and pray it is enough.
  337.   */
  338.  #define GETTOKINFO_EXTRA_BUFFER (2048)
  339.  
  340. diff --git a/daemon/mount.c b/daemon/mount.c
  341. index 4703b88..a6dab4e 100644
  342. --- a/daemon/mount.c
  343. +++ b/daemon/mount.c
  344. @@ -24,10 +24,14 @@
  345.  #include <strsafe.h>
  346.  #include <stdio.h>
  347.  
  348. +#include "nfs41_build_features.h"
  349.  #include "daemon_debug.h"
  350.  #include "nfs41_ops.h"
  351.  #include "upcall.h"
  352.  #include "util.h"
  353. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  354. +#include "accesstoken.h"
  355. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  356.  
  357.  
  358.  /* NFS41_MOUNT */
  359. @@ -72,9 +76,24 @@ static int handle_mount(void *daemon_context, nfs41_upcall *upcall)
  360.  
  361.      EASSERT(args->hostport != NULL);
  362.  
  363. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  364. +    LUID authenticationid = { .LowPart = 0, .HighPart = 0L };
  365. +
  366. +    /* We ignore errors here since this is for logging only */
  367. +    (void)get_token_authenticationid(upcall->currentthread_token,
  368. +        &authenticationid);
  369. +
  370. +    logprintf("mount(hostport='%s', path='%s', "
  371. +        "authid=(0x%x.0x%lx)) request\n",
  372. +        args->hostport?args->hostport:"<NULL>",
  373. +        args->path?args->path:"<NULL>",
  374. +        (int)authenticationid.LowPart,
  375. +        (long)authenticationid.HighPart);
  376. +#else
  377.      logprintf("mount(hostport='%s', path='%s') request\n",
  378.          args->hostport?args->hostport:"<NULL>",
  379.          args->path?args->path:"<NULL>");
  380. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  381.  
  382.      if (upcall->currentthread_token == INVALID_HANDLE_VALUE){
  383.          eprintf("handle_mount: Thread has no impersonation token\n");
  384. @@ -167,16 +186,36 @@ static int handle_mount(void *daemon_context, nfs41_upcall *upcall)
  385.      args->lease_time = client->session->lease_time;
  386.  out:
  387.      if (status == 0) {
  388. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  389. +        logprintf("mount(hostport='%s', path='%s', "
  390. +            "authid=(0x%x.0x%lx)) success, root=0x%p\n",
  391. +            args->hostport?args->hostport:"<NULL>",
  392. +            args->path?args->path:"<NULL>",
  393. +            (int)authenticationid.LowPart,
  394. +            (long)authenticationid.HighPart,
  395. +            root);
  396. +#else
  397.          logprintf("mount(hostport='%s', path='%s') success, root=0x%p\n",
  398.              args->hostport?args->hostport:"<NULL>",
  399.              args->path?args->path:"<NULL>",
  400.              root);
  401. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  402.      }
  403.      else {
  404. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  405. +        logprintf("mount(hostport='%s', path='%s', "
  406. +            "authid=(0x%x.0x%lx))) failed, status=%d\n",
  407. +            args->hostport?args->hostport:"<NULL>",
  408. +            args->path?args->path:"<NULL>",
  409. +            (int)authenticationid.LowPart,
  410. +            (long)authenticationid.HighPart,
  411. +            (int)status);
  412. +#else
  413.          logprintf("mount(hostport='%s', path='%s') failed, status=%d\n",
  414.              args->hostport?args->hostport:"<NULL>",
  415.              args->path?args->path:"<NULL>",
  416.              (int)status);
  417. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  418.      }
  419.      return status;
  420.  
  421. diff --git a/daemon/nfs41_client.c b/daemon/nfs41_client.c
  422. index f817d4e..4380efd 100644
  423. --- a/daemon/nfs41_client.c
  424. +++ b/daemon/nfs41_client.c
  425. @@ -3,6 +3,7 @@
  426.   *
  427.   * Olga Kornievskaia <aglo@umich.edu>
  428.   * Casey Bodley <cbodley@umich.edu>
  429. + * Roland Mainz <roland.mainz@nrubsig.org>
  430.   *
  431.   * This library is free software; you can redistribute it and/or modify it
  432.   * under the terms of the GNU Lesser General Public License as published by
  433. @@ -27,6 +28,7 @@
  434.  #include <wincrypt.h> /* for Crypt*() functions */
  435.  #include <winsock2.h> /* for hostent struct */
  436.  
  437. +#include "nfs41_build_features.h"
  438.  #include "tree.h"
  439.  #include "delegation.h"
  440.  #include "daemon_debug.h"
  441. @@ -370,31 +372,37 @@ int nfs41_client_owner(
  442.      const ULONGLONG time_created = GetTickCount64();
  443.      int status;
  444.      char username[UNLEN+1];
  445. +    HANDLE thrtoken = GetCurrentThreadEffectiveToken();
  446. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  447.      LUID authenticationid;
  448. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  449.  
  450.      /*
  451.       * gisburn: What about primary group (for /usr/bin/newgrp
  452.       * support) ?
  453.       */
  454. -    if (!get_token_user_name(GetCurrentThreadEffectiveToken(),
  455. +    if (!get_token_user_name(thrtoken,
  456.          username)) {
  457.          status = GetLastError();
  458.          eprintf("get_token_user_name() failed with %d\n", status);
  459.          goto out;
  460.      }
  461.  
  462. -    if (!get_token_authenticationid(GetCurrentThreadEffectiveToken(),
  463. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  464. +    if (!get_token_authenticationid(thrtoken,
  465.          &authenticationid)) {
  466.          status = GetLastError();
  467. -        eprintf("get_token_authenticationid() failed with %d\n", status);
  468. +        eprintf("nfs41_client_owner: get_token_authenticationid() "
  469. +            "failed with %d\n", status);
  470.          goto out;
  471.      }
  472.  
  473. -    DPRINTF(0, ("nfs41_client_owner: "
  474. -        "username='%s' authenticationid=(0x%x/0x%lx)\n",
  475. +    DPRINTF(1, ("nfs41_client_owner: "
  476. +        "username='%s' authid=(0x%x.0x%lx)\n",
  477.          username,
  478.          (int)authenticationid.LowPart,
  479.          (long)authenticationid.HighPart));
  480. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  481.  
  482.      /* owner.verifier = "time created" */
  483.      memcpy(owner->co_verifier, &time_created, sizeof(time_created));
  484. @@ -430,6 +438,11 @@ int nfs41_client_owner(
  485.          goto out_hash;
  486.      }
  487.  
  488. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  489. +    /*
  490. +     * |LUID| may have (hidden) padding fields, so we hash each
  491. +     * member seperately
  492. +     */
  493.      if (!CryptHashData(hash, (const BYTE*)&authenticationid.LowPart, (DWORD)sizeof(DWORD), 0)) {
  494.          status = GetLastError();
  495.          eprintf("CryptHashData() failed with %d\n", status);
  496. @@ -441,6 +454,7 @@ int nfs41_client_owner(
  497.          eprintf("CryptHashData() failed with %d\n", status);
  498.          goto out_hash;
  499.      }
  500. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  501.  
  502.      if (!CryptHashData(hash, (const BYTE*)&port, (DWORD)sizeof(port), 0)) {
  503.          status = GetLastError();
  504. diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
  505. index 9a4d7cd..1720558 100644
  506. --- a/dll/nfs41_np.c
  507. +++ b/dll/nfs41_np.c
  508. @@ -73,6 +73,56 @@ ULONG _cdecl NFS41DbgPrint(__in LPTSTR fmt, ...)
  509.      return rc;
  510.  }
  511.  
  512. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  513. +/*
  514. + * |equal_luid()| - |LUID| might contain padding fields, so
  515. + * we cannot use |memcpy()|!
  516. + */
  517. +static
  518. +bool equal_luid(LUID *l1, LUID *l2)
  519. +{
  520. +    return((l1->LowPart == l2->LowPart) &&
  521. +        (l1->HighPart == l2->HighPart));
  522. +}
  523. +
  524. +/*
  525. + * Performance hack:
  526. + * GETTOKINFO_EXTRA_BUFFER - extra space for more data
  527. + * |GetTokenInformation()| for |TOKEN_USER|, |TOKEN_PRIMARY_GROUP|
  528. + * and |TOKEN_GROUPS_AND_PRIVILEGES| always fails in Win10 with
  529. + * |ERROR_INSUFFICIENT_BUFFER| if you just pass the |sizeof(TOKEN_*)|
  530. + * value.
  531. + * Instead of calling |GetTokenInformation()| with |NULL| arg to
  532. + * obtain the size to allocate we just provide 2048 bytes of extra
  533. + * space after the |TOKEN_*| size, and pray it is enough.
  534. + */
  535. +#define GETTOKINFO_EXTRA_BUFFER (2048)
  536. +
  537. +static
  538. +bool get_token_authenticationid(HANDLE tok, LUID *out_authenticationid)
  539. +{
  540. +    DWORD tokdatalen;
  541. +    PTOKEN_GROUPS_AND_PRIVILEGES ptgp;
  542. +
  543. +    tokdatalen =
  544. +        sizeof(TOKEN_GROUPS_AND_PRIVILEGES)+GETTOKINFO_EXTRA_BUFFER;
  545. +    ptgp = _alloca(tokdatalen);
  546. +    if (!GetTokenInformation(tok, TokenGroupsAndPrivileges, ptgp,
  547. +        tokdatalen, &tokdatalen)) {
  548. +        DbgP((L"get_token_authenticationid: "
  549. +            L"GetTokenInformation(tok=0x%p, TokenGroupsAndPrivileges) "
  550. +            L"failed, "
  551. +            L"status=%d\n",
  552. +            (void *)tok, (int)GetLastError()));
  553. +        return false;
  554. +    }
  555. +
  556. +    *out_authenticationid = ptgp->AuthenticationId;
  557. +
  558. +    return true;
  559. +}
  560. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  561. +
  562.  int filter(unsigned int code)
  563.  {
  564.      DbgP((L"####Got exception %u\n", code));
  565. @@ -203,9 +253,17 @@ static DWORD StoreConnectionInfo(
  566.      PNFS41NP_NETRESOURCE pNfs41NetResource;
  567.      INT i;
  568.      bool FreeEntryFound = false;
  569. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  570. +    LUID authenticationid = { .LowPart = 0, .HighPart = 0L };
  571. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  572.  
  573.      DbgP((L"--> StoreConnectionInfo\n"));
  574.  
  575. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  576. +    (void)get_token_authenticationid(GetCurrentThreadEffectiveToken(),
  577. +        &authenticationid);
  578. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  579. +
  580.      status = OpenSharedMemory(&hMutex, &hMemory,
  581.          &(PVOID)pSharedMemory);
  582.      if (status)
  583. @@ -243,6 +301,9 @@ static DWORD StoreConnectionInfo(
  584.      pNfs41NetResource->dwDisplayType    =
  585.          lpNetResource->dwDisplayType;
  586.      pNfs41NetResource->dwUsage          = RESOURCEUSAGE_CONNECTABLE;
  587. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  588. +    pNfs41NetResource->MountAuthId      = authenticationid;
  589. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  590.      pNfs41NetResource->LocalNameLength  =
  591.          (USHORT)(wcslen(LocalName) + 1) * sizeof(WCHAR);
  592.      pNfs41NetResource->RemoteNameLength =
  593. @@ -660,10 +721,18 @@ NPCancelConnection(
  594.  
  595.      HANDLE  hMutex, hMemory;
  596.      PNFS41NP_SHARED_MEMORY  pSharedMemory;
  597. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  598. +    LUID authenticationid = { .LowPart = 0, .HighPart = 0L };
  599. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  600.  
  601.      DbgP((L"--> NPCancelConnection(lpName='%s', fForce=%d)\n",
  602.          lpName, (int)fForce));
  603.  
  604. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  605. +    (void)get_token_authenticationid(GetCurrentThreadEffectiveToken(),
  606. +        &authenticationid);
  607. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  608. +
  609.      Status = OpenSharedMemory(&hMutex,
  610.          &hMemory,
  611.          (PVOID)&pSharedMemory);
  612. @@ -684,7 +753,12 @@ NPCancelConnection(
  613.          pNetResource = &pSharedMemory->NetResources[Index];
  614.  
  615.          if (pNetResource->InUse) {
  616. -            if ((((wcslen(lpName)+1) * sizeof(WCHAR)) ==
  617. +            if (
  618. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  619. +                equal_luid(&authenticationid,
  620. +                    &pNetResource->MountAuthId) &&
  621. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  622. +                (((wcslen(lpName)+1) * sizeof(WCHAR)) ==
  623.                  pNetResource->LocalNameLength) &&
  624.                  (!wcscmp(lpName, pNetResource->LocalName))) {
  625.                  ULONG CopyBytes;
  626. @@ -749,9 +823,17 @@ NPGetConnection(
  627.  
  628.      HANDLE  hMutex, hMemory;
  629.      PNFS41NP_SHARED_MEMORY  pSharedMemory;
  630. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  631. +    LUID authenticationid = { .LowPart = 0, .HighPart = 0L };
  632. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  633.  
  634.      DbgP((L"--> NPGetConnection(lpLocalName='%s')\n", lpLocalName));
  635.  
  636. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  637. +    (void)get_token_authenticationid(GetCurrentThreadEffectiveToken(),
  638. +        &authenticationid);
  639. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  640. +
  641.      Status = OpenSharedMemory(&hMutex,
  642.          &hMemory,
  643.          (PVOID)&pSharedMemory);
  644. @@ -767,7 +849,13 @@ NPGetConnection(
  645.          pNetResource = &pSharedMemory->NetResources[Index];
  646.  
  647.          if (pNetResource->InUse) {
  648. -            if ((((wcslen(lpLocalName)+1)*sizeof(WCHAR)) ==
  649. +            if (
  650. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  651. +                equal_luid(&authenticationid,
  652. +                    &pNetResource->MountAuthId) &&
  653. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  654. +                (((wcslen(lpLocalName)+1)*sizeof(WCHAR)) ==
  655. +
  656.                      pNetResource->LocalNameLength) &&
  657.                      (!wcscmp(lpLocalName, pNetResource->LocalName))) {
  658.                  if (*lpBufferSize < pNetResource->RemoteNameLength) {
  659. @@ -853,11 +941,20 @@ NPEnumResource(
  660.      HANDLE  hMutex, hMemory;
  661.      PNFS41NP_SHARED_MEMORY  pSharedMemory;
  662.      PNFS41NP_NETRESOURCE pNfsNetResource;
  663. -    INT  Index = *(PULONG)hEnum;
  664. +    INT             Index = *(PULONG)hEnum;
  665. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  666. +    LUID            authenticationid =
  667. +        { .LowPart = 0, .HighPart = 0L };
  668. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  669.  
  670.      DbgP((L"--> NPEnumResource(hEnum=0x%x, *lpcCount=%d)\n",
  671.          HANDLE2INT(hEnum), (int)*lpcCount));
  672.  
  673. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  674. +    (void)get_token_authenticationid(GetCurrentThreadEffectiveToken(),
  675. +        &authenticationid);
  676. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  677. +
  678.      pNetResource = (LPNETRESOURCE) lpBuffer;
  679.      SpaceAvailable = *lpBufferSize;
  680.      EntriesCopied = 0;
  681. @@ -875,8 +972,12 @@ NPEnumResource(
  682.      {
  683.          pNfsNetResource = &pSharedMemory->NetResources[Index];
  684.  
  685. -        if (pNfsNetResource->InUse)
  686. -        {
  687. +        if (pNfsNetResource->InUse
  688. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  689. +            && equal_luid(&authenticationid,
  690. +                &pNfsNetResource->MountAuthId)
  691. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  692. +                ) {
  693.              SpaceNeeded  = sizeof(NETRESOURCE);
  694.              SpaceNeeded += pNfsNetResource->LocalNameLength;
  695.              SpaceNeeded += pNfsNetResource->RemoteNameLength;
  696. diff --git a/dll/nfs41_np.h b/dll/nfs41_np.h
  697. index 5f3d77c..c4c122d 100644
  698. --- a/dll/nfs41_np.h
  699. +++ b/dll/nfs41_np.h
  700. @@ -3,6 +3,7 @@
  701.   *
  702.   * Olga Kornievskaia <aglo@umich.edu>
  703.   * Casey Bodley <cbodley@umich.edu>
  704. + * Roland Mainz <roland.mainz@nrubsig.org>
  705.   *
  706.   * This library is free software; you can redistribute it and/or modify it
  707.   * under the terms of the GNU Lesser General Public License as published by
  708. @@ -22,9 +23,20 @@
  709.  #ifndef __NFS41_NP_H__
  710.  #define __NFS41_NP_H__
  711.  
  712. +#include "nfs41_build_features.h"
  713. +
  714.  #define NFS41NP_MUTEX_NAME  "NFS41NPMUTEX"
  715.  
  716. -#define NFS41NP_MAX_DEVICES 26
  717. +/*
  718. + * Maximum number of devices, 26 letters in alphabet, per user
  719. + */
  720. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  721. +#define NFS41NP_MAX_USERS   (128)
  722. +#define NFS41NP_MAX_DEVICES (26*NFS41NP_MAX_USERS)
  723. +#else
  724. +#define NFS41NP_MAX_DEVICES (26)
  725. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  726. +
  727.  
  728.  typedef struct __NFS41NP_NETRESOURCE {
  729.      BOOL    InUse;
  730. @@ -35,6 +47,9 @@ typedef struct __NFS41NP_NETRESOURCE {
  731.      DWORD   dwType;
  732.      DWORD   dwDisplayType;
  733.      DWORD   dwUsage;
  734. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  735. +    LUID    MountAuthId;
  736. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  737.      WCHAR   LocalName[NFS41_SYS_MAX_PATH_LEN];
  738.      WCHAR   RemoteName[NFS41_SYS_MAX_PATH_LEN];
  739.      WCHAR   ConnectionName[NFS41_SYS_MAX_PATH_LEN];
  740. diff --git a/nfs41_build_features.h b/nfs41_build_features.h
  741. index 7d12894..697f4d5 100644
  742. --- a/nfs41_build_features.h
  743. +++ b/nfs41_build_features.h
  744. @@ -107,4 +107,14 @@
  745.   */
  746.  #define NFS41_DRIVER_DISABLE_8DOT3_SHORTNAME_GENERATION 1
  747.  
  748. +/*
  749. + * NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE - use
  750. + * |TOKEN_GROUPS_AND_PRIVILEGES.AuthenticationId| for
  751. + * mount namespace separation between users.
  752. + * This avoid that mounts from different users can interfere
  753. + * with each other, e.g. if they are mounted with different
  754. + * mount (e.g. "rw" vs. "ro") options.
  755. + */
  756. +#define NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE 1
  757. +
  758.  #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */
  759. --
  760. 2.45.1

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.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at