pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for idmapping local Windows accounts, cygwinaccount2nfs4account+misc, 2024-12-10
Posted by Anonymous on Tue 10th Dec 2024 17:28
raw | new post

  1. From a1228c175c8f6c34a855ba110823b5546760c053 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Tue, 10 Dec 2024 11:13:06 +0100
  4. Subject: [PATCH 1/6] sys: |nfs41_ExtendForCache()| should live with the r/w
  5.  code
  6.  
  7. Move |nfs41_ExtendForCache()| to the r/w source code file
  8.  
  9. Reported-by: Josh Hurst <joshhurst@gmail.com>
  10. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  11. ---
  12. sys/nfs41sys_driver.c    | 31 -------------------------------
  13.  sys/nfs41sys_driver.h    |  4 ++++
  14.  sys/nfs41sys_readwrite.c | 31 +++++++++++++++++++++++++++++++
  15.  3 files changed, 35 insertions(+), 31 deletions(-)
  16.  
  17. diff --git a/sys/nfs41sys_driver.c b/sys/nfs41sys_driver.c
  18. index c43a5c0..e2f8ed7 100644
  19. --- a/sys/nfs41sys_driver.c
  20. +++ b/sys/nfs41sys_driver.c
  21. @@ -659,37 +659,6 @@ out:
  22.      return status;
  23.  }
  24.  
  25. -static ULONG nfs41_ExtendForCache(
  26. -    IN OUT PRX_CONTEXT RxContext,
  27. -    IN PLARGE_INTEGER pNewFileSize,
  28. -    OUT PLARGE_INTEGER pNewAllocationSize)
  29. -{
  30. -    NTSTATUS status = STATUS_SUCCESS;
  31. -    __notnull PNFS41_FCB nfs41_fcb = NFS41GetFcbExtension(RxContext->pFcb);
  32. -#ifdef DEBUG_CACHE
  33. -    PLOWIO_CONTEXT LowIoContext  = &RxContext->LowIoContext;
  34. -    DbgEn();
  35. -    print_debug_header(RxContext);
  36. -    DbgP("input: bytecount=0x%lx filesize=0x%llx allocsize=0x%llx\n",
  37. -        (long)LowIoContext->ParamsFor.ReadWrite.ByteCount,
  38. -        (long long)pNewFileSize->QuadPart,
  39. -        (long long)pNewAllocationSize->QuadPart);
  40. -#endif
  41. -    pNewAllocationSize->QuadPart = pNewFileSize->QuadPart + 8192;
  42. -    nfs41_fcb->StandardInfo.AllocationSize.QuadPart =
  43. -        pNewAllocationSize->QuadPart;
  44. -    nfs41_fcb->StandardInfo.EndOfFile.QuadPart = pNewFileSize->QuadPart;
  45. -#ifdef DEBUG_CACHE
  46. -    DbgP("newfilesize=0x%llx newallocationsize=0x%llx\n",
  47. -        (long long)pNewFileSize->QuadPart,
  48. -        (long long)pNewAllocationSize->QuadPart);
  49. -#endif
  50. -#ifdef DEBUG_CACHE
  51. -    DbgEx();
  52. -#endif
  53. -    return status;
  54. -}
  55. -
  56.  VOID nfs41_remove_fcb_entry(
  57.      PMRX_FCB fcb)
  58.  {
  59. diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
  60. index 9d582a6..1c39ab6 100644
  61. --- a/sys/nfs41sys_driver.h
  62. +++ b/sys/nfs41sys_driver.h
  63. @@ -767,6 +767,10 @@ NTSTATUS nfs41_Read(
  64.      IN OUT PRX_CONTEXT RxContext);
  65.  NTSTATUS nfs41_Write(
  66.      IN OUT PRX_CONTEXT RxContext);
  67. +ULONG nfs41_ExtendForCache(
  68. +    IN OUT PRX_CONTEXT RxContext,
  69. +    IN PLARGE_INTEGER pNewFileSize,
  70. +    OUT PLARGE_INTEGER pNewAllocationSize);
  71.  
  72.  /* nfs41sys_symlink.c */
  73.  NTSTATUS marshal_nfs41_symlink(
  74. diff --git a/sys/nfs41sys_readwrite.c b/sys/nfs41sys_readwrite.c
  75. index 90d6d07..40ee1ca 100644
  76. --- a/sys/nfs41sys_readwrite.c
  77. +++ b/sys/nfs41sys_readwrite.c
  78. @@ -434,3 +434,34 @@ out:
  79.  #endif
  80.      return status;
  81.  }
  82. +
  83. +ULONG nfs41_ExtendForCache(
  84. +    IN OUT PRX_CONTEXT RxContext,
  85. +    IN PLARGE_INTEGER pNewFileSize,
  86. +    OUT PLARGE_INTEGER pNewAllocationSize)
  87. +{
  88. +    NTSTATUS status = STATUS_SUCCESS;
  89. +    __notnull PNFS41_FCB nfs41_fcb = NFS41GetFcbExtension(RxContext->pFcb);
  90. +#ifdef DEBUG_CACHE
  91. +    PLOWIO_CONTEXT LowIoContext  = &RxContext->LowIoContext;
  92. +    DbgEn();
  93. +    print_debug_header(RxContext);
  94. +    DbgP("input: bytecount=0x%lx filesize=0x%llx allocsize=0x%llx\n",
  95. +        (long)LowIoContext->ParamsFor.ReadWrite.ByteCount,
  96. +        (long long)pNewFileSize->QuadPart,
  97. +        (long long)pNewAllocationSize->QuadPart);
  98. +#endif
  99. +    pNewAllocationSize->QuadPart = pNewFileSize->QuadPart + 8192;
  100. +    nfs41_fcb->StandardInfo.AllocationSize.QuadPart =
  101. +        pNewAllocationSize->QuadPart;
  102. +    nfs41_fcb->StandardInfo.EndOfFile.QuadPart = pNewFileSize->QuadPart;
  103. +#ifdef DEBUG_CACHE
  104. +    DbgP("newfilesize=0x%llx newallocationsize=0x%llx\n",
  105. +        (long long)pNewFileSize->QuadPart,
  106. +        (long long)pNewAllocationSize->QuadPart);
  107. +#endif
  108. +#ifdef DEBUG_CACHE
  109. +    DbgEx();
  110. +#endif
  111. +    return status;
  112. +}
  113. --
  114. 2.45.1
  115.  
  116. From 6b5be83b0773eafa10f6dfad2f31c7b9011736aa Mon Sep 17 00:00:00 2001
  117. From: Roland Mainz <roland.mainz@nrubsig.org>
  118. Date: Tue, 10 Dec 2024 15:30:30 +0100
  119. Subject: [PATCH 2/6] cygwin_idmapper.ksh: Lookup local Windows accounts before
  120.  normal accounts
  121.  
  122. Lookup local Windows accounts before normal accounts, e.g.
  123. $ getent passwd "+{username} # / $ getent group "+{groupname} #,
  124. and then normal (domain) users via via
  125. $ getent passwd "{username} # / $ getent group "{groupname} #.
  126.  
  127. This fixes the reported issue that special machine-local admin
  128. accounts fail NFS idmapping.
  129.  
  130. Reported-by: Dietmar Kuenkler <dietmar.kuenkler@rovema.de>
  131. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  132. ---
  133. cygwin_idmapper.ksh | 50 +++++++++++++++++++++++++++++++++++++++++++--
  134.  1 file changed, 48 insertions(+), 2 deletions(-)
  135.  
  136. diff --git a/cygwin_idmapper.ksh b/cygwin_idmapper.ksh
  137. index 0a41b1f..be166f8 100644
  138. --- a/cygwin_idmapper.ksh
  139. +++ b/cygwin_idmapper.ksh
  140. @@ -180,6 +180,52 @@ compound -A localgroups=(
  141.         )
  142.  )
  143.  
  144. +function getent_local_domain_passwd
  145. +{
  146. +       integer res
  147. +       typeset passwdname="$1"
  148. +
  149. +       #
  150. +       # first try local accounts and if getent does
  151. +       # not find anything do a (normal) domain lookup
  152. +       #
  153. +       # Cygwin getent uses '+' prefix to search for local
  154. +       # accounts only
  155. +       #
  156. +       getent passwd "+${passwdname}"
  157. +       (( res=$? ))
  158. +
  159. +       if (( res == 2 )) ; then
  160. +               getent passwd "${passwdname}"
  161. +               (( res=$? ))
  162. +       fi
  163. +
  164. +       return $res
  165. +}
  166. +
  167. +function getent_local_domain_group
  168. +{
  169. +       integer res
  170. +       typeset groupname="$1"
  171. +
  172. +       #
  173. +       # first try local accounts and if getent does
  174. +       # not find anything do a (normal) domain lookup
  175. +       #
  176. +       # Cygwin getent uses '+' prefix to search for local
  177. +       # accounts only
  178. +       #
  179. +       getent group "+${groupname}"
  180. +       (( res=$? ))
  181. +
  182. +       if (( res == 2 )) ; then
  183. +               getent group "${groupname}"
  184. +               (( res=$? ))
  185. +       fi
  186. +
  187. +       return $res
  188. +}
  189. +
  190.  if [[ -v c.localised_groupnames['None'] ]] ; then
  191.         localgroups+=(
  192.                 ["${c.localised_groupnames['None']}"]=(
  193. @@ -229,7 +275,7 @@ case "${c.mode}" in
  194.                 #
  195.                 compound gec # getent compound var
  196.                 typeset dummy1 dummy2
  197. -               getent passwd "${c.name}" | \
  198. +               getent_local_domain_passwd "${c.name}" | \
  199.                         IFS=':' read gec.localaccountname dummy1 gec.localuid gec.localgid dummy2
  200.  
  201.                 if [[ "${gec.localaccountname-}" != '' ]] ; then
  202. @@ -268,7 +314,7 @@ case "${c.mode}" in
  203.                 #
  204.                 compound gec # getent compound var
  205.                 typeset dummy1 dummy2
  206. -               getent group "${c.name}" | \
  207. +               getent_local_domain_group "${c.name}" | \
  208.                         IFS=':' read gec.localgroupname dummy1 gec.localgid dummy2
  209.  
  210.                 if [[ "${gec.localgroupname-}" != '' ]] ; then
  211. --
  212. 2.45.1
  213.  
  214. From 6c23aae520a6a12887e9eabc297a8eb0bd19521f Mon Sep 17 00:00:00 2001
  215. From: Roland Mainz <roland.mainz@nrubsig.org>
  216. Date: Tue, 10 Dec 2024 15:49:19 +0100
  217. Subject: [PATCH 3/6] cygwin: cygwinaccount2nfs4account: Lookup local Windows
  218.  accounts before normal accounts
  219.  
  220. Lookup local Windows accounts before normal accounts, e.g.
  221. $ getent passwd "+{username} # / $ getent group "+{groupname} #,
  222. and then normal (domain) users via via
  223. $ getent passwd "{username} # / $ getent group "{groupname} #.
  224.  
  225. This fixes the reported issue that special machine-local admin
  226. accounts cannot be handled by cygwinaccount2nfs4account.ksh
  227.  
  228. Reported-by: Dietmar Kuenkler <dietmar.kuenkler@rovema.de>
  229. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  230. ---
  231. .../cygwinaccount2nfs4account.ksh             | 52 +++++++++++++++++--
  232.  1 file changed, 49 insertions(+), 3 deletions(-)
  233.  
  234. diff --git a/cygwin/utils/cygwinaccount2nfs4account/cygwinaccount2nfs4account.ksh b/cygwin/utils/cygwinaccount2nfs4account/cygwinaccount2nfs4account.ksh
  235. index dbb440f..c26414f 100644
  236. --- a/cygwin/utils/cygwinaccount2nfs4account/cygwinaccount2nfs4account.ksh
  237. +++ b/cygwin/utils/cygwinaccount2nfs4account/cygwinaccount2nfs4account.ksh
  238. @@ -40,6 +40,52 @@ function usage
  239.         return 2
  240.  }
  241.  
  242. +function getent_local_domain_passwd
  243. +{
  244. +       integer res
  245. +       typeset passwdname="$1"
  246. +
  247. +       #
  248. +       # first try local accounts and if getent does
  249. +       # not find anything do a (normal) domain lookup
  250. +       #
  251. +       # Cygwin getent uses '+' prefix to search for local
  252. +       # accounts only
  253. +       #
  254. +       getent passwd "+${passwdname}"
  255. +       (( res=$? ))
  256. +
  257. +       if (( res == 2 )) ; then
  258. +               getent passwd "${passwdname}"
  259. +               (( res=$? ))
  260. +       fi
  261. +
  262. +       return $res
  263. +}
  264. +
  265. +function getent_local_domain_group
  266. +{
  267. +       integer res
  268. +       typeset groupname="$1"
  269. +
  270. +       #
  271. +       # first try local accounts and if getent does
  272. +       # not find anything do a (normal) domain lookup
  273. +       #
  274. +       # Cygwin getent uses '+' prefix to search for local
  275. +       # accounts only
  276. +       #
  277. +       getent group "+${groupname}"
  278. +       (( res=$? ))
  279. +
  280. +       if (( res == 2 )) ; then
  281. +               getent group "${groupname}"
  282. +               (( res=$? ))
  283. +       fi
  284. +
  285. +       return $res
  286. +}
  287. +
  288.  function getent_passwd2compound
  289.  {
  290.         set -o nounset
  291. @@ -51,7 +97,7 @@ function getent_passwd2compound
  292.         compound out
  293.  
  294.         # capture getent output
  295. -       out.stderr="${ { out.stdout="${ getent passwd "$username" ; (( out.res=$? )) ; }" ; } 2>&1 ; }"
  296. +       out.stderr="${ { out.stdout="${ getent_local_domain_passwd "$username" ; (( out.res=$? )) ; }" ; } 2>&1 ; }"
  297.  
  298.         if [[ "${out.stderr}" != '' ]] || (( out.res != 0 )) ; then
  299.                 print -u2 $"%s: getent failed, msg=%q, res=%d\n" \
  300. @@ -102,7 +148,7 @@ function getent_group2compound
  301.         compound out
  302.  
  303.         # capture getent output
  304. -       out.stderr="${ { out.stdout="${ getent group "$groupname" ; (( out.res=$? )) ; }" ; } 2>&1 ; }"
  305. +       out.stderr="${ { out.stdout="${ getent_local_domain_group "$groupname" ; (( out.res=$? )) ; }" ; } 2>&1 ; }"
  306.  
  307.         if [[ "${out.stderr}" != '' ]] || (( out.res != 0 )) ; then
  308.                 print -u2 $"%s: getent failed, msg=%q, res=%d\n" \
  309. @@ -338,7 +384,7 @@ function main
  310.  
  311.         # fixme: Need better text layout for $ nfsurlconv --man #
  312.         typeset -r cygwinaccount2nfs4account_usage=$'+
  313. -       [-?\n@(#)\$Id: cygwinaccount2nfs4account (Roland Mainz) 2024-08-01 \$\n]
  314. +       [-?\n@(#)\$Id: cygwinaccount2nfs4account (Roland Mainz) 2024-12-10 \$\n]
  315.         [-author?Roland Mainz <roland.mainz@nrubsig.org>]
  316.         [+NAME?cygwinaccount2nfs4account - convert Cygwin user/group account
  317.                 info to Linux/UNIX NFSv4 server account data]
  318. --
  319. 2.45.1
  320.  
  321. From 952e2732b17b86092d9a4f1f7d39ccf783a7b44c Mon Sep 17 00:00:00 2001
  322. From: Roland Mainz <roland.mainz@nrubsig.org>
  323. Date: Tue, 10 Dec 2024 15:51:50 +0100
  324. Subject: [PATCH 4/6] cygwin: cygwinaccount2nfs4account: Fix error messages
  325.  
  326. Fix error messages in cygwinaccount2nfs4account.ksh
  327.  
  328. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  329. ---
  330. .../cygwinaccount2nfs4account/cygwinaccount2nfs4account.ksh | 6 +++---
  331.  1 file changed, 3 insertions(+), 3 deletions(-)
  332.  
  333. diff --git a/cygwin/utils/cygwinaccount2nfs4account/cygwinaccount2nfs4account.ksh b/cygwin/utils/cygwinaccount2nfs4account/cygwinaccount2nfs4account.ksh
  334. index c26414f..5ee474a 100644
  335. --- a/cygwin/utils/cygwinaccount2nfs4account/cygwinaccount2nfs4account.ksh
  336. +++ b/cygwin/utils/cygwinaccount2nfs4account/cygwinaccount2nfs4account.ksh
  337. @@ -100,7 +100,7 @@ function getent_passwd2compound
  338.         out.stderr="${ { out.stdout="${ getent_local_domain_passwd "$username" ; (( out.res=$? )) ; }" ; } 2>&1 ; }"
  339.  
  340.         if [[ "${out.stderr}" != '' ]] || (( out.res != 0 )) ; then
  341. -               print -u2 $"%s: getent failed, msg=%q, res=%d\n" \
  342. +               print -u2 -f $"%s: getent failed, msg=%q, res=%d\n" \
  343.                         "$0" "${out.stderr}" out.res
  344.                 return 1
  345.         fi
  346. @@ -151,7 +151,7 @@ function getent_group2compound
  347.         out.stderr="${ { out.stdout="${ getent_local_domain_group "$groupname" ; (( out.res=$? )) ; }" ; } 2>&1 ; }"
  348.  
  349.         if [[ "${out.stderr}" != '' ]] || (( out.res != 0 )) ; then
  350. -               print -u2 $"%s: getent failed, msg=%q, res=%d\n" \
  351. +               print -u2 -f $"%s: getent failed, msg=%q, res=%d\n" \
  352.                         "$0" "${out.stderr}" out.res
  353.                 return 1
  354.         fi
  355. @@ -336,7 +336,7 @@ function convert_givenuser2linuxscript
  356.                 (( out.res=$? )) ; }" ; } 2>&1 ; }"
  357.  
  358.         if [[ "${out.stderr}" != '' ]] || (( out.res != 0 )) ; then
  359. -               print -u2 $"%s: powershell querying groups from DS failed, msg=%q, res=%d\n" \
  360. +               print -u2 -f $"%s: powershell querying groups from DS failed, msg=%q, res=%d\n" \
  361.                         "$0" "${out.stderr}" out.res
  362.                 return 1
  363.         fi
  364. --
  365. 2.45.1
  366.  
  367. From cbcbdc6cf7bb3a1e6bfc255f2df94c1d43e05429 Mon Sep 17 00:00:00 2001
  368. From: Roland Mainz <roland.mainz@nrubsig.org>
  369. Date: Tue, 10 Dec 2024 15:52:40 +0100
  370. Subject: [PATCH 5/6] cygwin: Fix typo in cygwinaccount2nfs4account
  371.  
  372. Fix typo in cygwinaccount2nfs4account.ksh
  373.  
  374. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  375. ---
  376. .../cygwinaccount2nfs4account/cygwinaccount2nfs4account.ksh     | 2 +-
  377.  1 file changed, 1 insertion(+), 1 deletion(-)
  378.  
  379. diff --git a/cygwin/utils/cygwinaccount2nfs4account/cygwinaccount2nfs4account.ksh b/cygwin/utils/cygwinaccount2nfs4account/cygwinaccount2nfs4account.ksh
  380. index 5ee474a..f2c99bd 100644
  381. --- a/cygwin/utils/cygwinaccount2nfs4account/cygwinaccount2nfs4account.ksh
  382. +++ b/cygwin/utils/cygwinaccount2nfs4account/cygwinaccount2nfs4account.ksh
  383. @@ -382,7 +382,7 @@ function main
  384.  {
  385.         set -o nounset
  386.  
  387. -       # fixme: Need better text layout for $ nfsurlconv --man #
  388. +       # fixme: Need better text layout for $ cygwinaccount2nfs4account --man #
  389.         typeset -r cygwinaccount2nfs4account_usage=$'+
  390.         [-?\n@(#)\$Id: cygwinaccount2nfs4account (Roland Mainz) 2024-12-10 \$\n]
  391.         [-author?Roland Mainz <roland.mainz@nrubsig.org>]
  392. --
  393. 2.45.1
  394.  
  395. From a9f012af6fbf745f92b4a1d0e27b6efaaa2901f6 Mon Sep 17 00:00:00 2001
  396. From: Roland Mainz <roland.mainz@nrubsig.org>
  397. Date: Tue, 10 Dec 2024 17:14:46 +0100
  398. Subject: [PATCH 6/6] sys: |MmMapLockedPagesSpecifyCache()| should not BUGCHECK
  399.  on mapping failure
  400.  
  401. |MmMapLockedPagesSpecifyCache()| should not BUGCHECK on mapping failure.
  402.  
  403. Reported-by: Hermes Belusca-Maito <hermes.belusca-maito@reactos.org>
  404. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  405. ---
  406. sys/nfs41sys_dir.c       | 2 +-
  407.  sys/nfs41sys_openclose.c | 2 +-
  408.  sys/nfs41sys_readwrite.c | 2 +-
  409.  3 files changed, 3 insertions(+), 3 deletions(-)
  410.  
  411. diff --git a/sys/nfs41sys_dir.c b/sys/nfs41sys_dir.c
  412. index 0031cbf..815904a 100644
  413. --- a/sys/nfs41sys_dir.c
  414. +++ b/sys/nfs41sys_dir.c
  415. @@ -104,7 +104,7 @@ NTSTATUS marshal_nfs41_dirquery(
  416.      __try {
  417.          entry->u.QueryFile.mdl_buf =
  418.              MmMapLockedPagesSpecifyCache(entry->u.QueryFile.mdl,
  419. -                UserMode, MmCached, NULL, TRUE,
  420. +                UserMode, MmCached, NULL, FALSE,
  421.                  NormalPagePriority|MdlMappingNoExecute);
  422.          if (entry->u.QueryFile.mdl_buf == NULL) {
  423.              print_error("marshal_nfs41_dirquery: "
  424. diff --git a/sys/nfs41sys_openclose.c b/sys/nfs41sys_openclose.c
  425. index af0cf10..86473e5 100644
  426. --- a/sys/nfs41sys_openclose.c
  427. +++ b/sys/nfs41sys_openclose.c
  428. @@ -163,7 +163,7 @@ NTSTATUS marshal_nfs41_open(
  429.          if (entry->u.Open.EaMdl) {
  430.              entry->u.Open.EaBuffer =
  431.                  MmMapLockedPagesSpecifyCache(entry->u.Open.EaMdl,
  432. -                    UserMode, MmCached, NULL, TRUE,
  433. +                    UserMode, MmCached, NULL, FALSE,
  434.                      NormalPagePriority|MdlMappingNoExecute);
  435.              if (entry->u.Open.EaBuffer == NULL) {
  436.                  print_error("marshal_nfs41_open: "
  437. diff --git a/sys/nfs41sys_readwrite.c b/sys/nfs41sys_readwrite.c
  438. index 40ee1ca..050819c 100644
  439. --- a/sys/nfs41sys_readwrite.c
  440. +++ b/sys/nfs41sys_readwrite.c
  441. @@ -120,7 +120,7 @@ NTSTATUS marshal_nfs41_rw(
  442.  #pragma warning( pop )
  443.          entry->buf =
  444.              MmMapLockedPagesSpecifyCache(entry->u.ReadWrite.MdlAddress,
  445. -                UserMode, MmCached, NULL, TRUE, NormalPagePriority);
  446. +                UserMode, MmCached, NULL, FALSE, NormalPagePriority);
  447.          if (entry->buf == NULL) {
  448.              print_error("marshal_nfs41_rw: "
  449.                  "MmMapLockedPagesSpecifyCache() failed to map pages\n");
  450. --
  451. 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