pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches to add (more) Windows builtin groups to the idmapper, cleanup+misc, 2025-10-09
Posted by Anonymous on Thu 9th Oct 2025 19:39
raw | new post

  1. From b35a92cc9d357262d315dad0d5d618e4364749fd Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Thu, 9 Oct 2025 18:58:23 +0200
  4. Subject: [PATCH 1/4] cygwin_idmapper.ksh: Add Windows builtin group
  5.  "Administrators" to idmapper
  6.  
  7. Add Windows builtin group "Administrators" to idmapper
  8.  
  9. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  10. ---
  11. cygwin_idmapper.ksh | 29 +++++++++++++++++++++++++++++
  12.  1 file changed, 29 insertions(+)
  13.  
  14. diff --git a/cygwin_idmapper.ksh b/cygwin_idmapper.ksh
  15. index 056bfa9..38f338d 100644
  16. --- a/cygwin_idmapper.ksh
  17. +++ b/cygwin_idmapper.ksh
  18. @@ -74,6 +74,13 @@ if (( $? == 0 )) && [[ "$stdout" != ~(El)Unknown\+Group: ]] ; then
  19.         c.localised_groupnames['None']="${stdout%%:*}"
  20.  fi
  21.  
  22. +# Group "Administrators" de_DE: "Administratoren"
  23. +# (primarily used by WindowsServer (2019) NFSv4.1 server)
  24. +stdout="$(getent group 'S-1-5-32-544')"
  25. +if (( $? == 0 )) && [[ "$stdout" != ~(El)Unknown\+Group: ]] ; then
  26. +       c.localised_groupnames['Administrators']="${stdout%%:*}"
  27. +fi
  28. +
  29.  compound -A localusers=(
  30.         #
  31.         # System accounts
  32. @@ -268,6 +275,28 @@ if [[ -v c.localised_groupnames['None'] ]] ; then
  33.         )
  34.  fi
  35.  
  36. +if [[ -v c.localised_groupnames['Administrators'] ]] ; then
  37. +       localgroups+=(
  38. +               ["${c.localised_groupnames['Administrators']}"]=(
  39. +                       localgroupname="${c.localised_groupnames['Administrators']}"
  40. +                       localgid=544
  41. +               )
  42. +               ['Administrators']=(
  43. +                       localgroupname="${c.localised_groupnames['Administrators']}"
  44. +                       localgid=544
  45. +               )
  46. +               # French Windows localised group name for "Administrators"
  47. +               ['Administrateurs']=(
  48. +                       localgroupname="${c.localised_groupnames['Administrators']}"
  49. +                       localgid=544
  50. +               )
  51. +               # German Windows localised group name for "Administrators"
  52. +               ['Administratoren']=(
  53. +                       localgroupname="${c.localised_groupnames['Administrators']}"
  54. +                       localgid=544
  55. +               )
  56. +       )
  57. +fi
  58.  
  59.  case "${c.mode}" in
  60.         'nfsserver_owner2localaccount')
  61. --
  62. 2.51.0
  63.  
  64. From 93dd24cf82ba66a502bf8785d35088ad5bf21686 Mon Sep 17 00:00:00 2001
  65. From: Roland Mainz <roland.mainz@nrubsig.org>
  66. Date: Thu, 9 Oct 2025 19:15:26 +0200
  67. Subject: [PATCH 2/4] cygwin_idmapper.ksh: Add Windows builtin group "Users" to
  68.  idmapper
  69.  
  70. Add Windows builtin group "Users" to idmapper.
  71.  
  72. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  73. ---
  74. cygwin_idmapper.ksh | 32 ++++++++++++++++++++++++++++++++
  75.  1 file changed, 32 insertions(+)
  76.  
  77. diff --git a/cygwin_idmapper.ksh b/cygwin_idmapper.ksh
  78. index 38f338d..03a3ed3 100644
  79. --- a/cygwin_idmapper.ksh
  80. +++ b/cygwin_idmapper.ksh
  81. @@ -81,6 +81,13 @@ if (( $? == 0 )) && [[ "$stdout" != ~(El)Unknown\+Group: ]] ; then
  82.         c.localised_groupnames['Administrators']="${stdout%%:*}"
  83.  fi
  84.  
  85. +# Group "Users" de_DE: "Benutzer", fr_FR: "Utilisateurs"
  86. +# (primarily used by WindowsServer (2019) NFSv4.1 server)
  87. +stdout="$(getent group 'S-1-5-32-545')"
  88. +if (( $? == 0 )) && [[ "$stdout" != ~(El)Unknown\+Group: ]] ; then
  89. +       c.localised_groupnames['Users']="${stdout%%:*}"
  90. +fi
  91. +
  92.  compound -A localusers=(
  93.         #
  94.         # System accounts
  95. @@ -286,6 +293,7 @@ if [[ -v c.localised_groupnames['Administrators'] ]] ; then
  96.                         localgid=544
  97.                 )
  98.                 # French Windows localised group name for "Administrators"
  99. +               # (from https://learn.microsoft.com/fr-fr/windows-server/identity/ad-ds/manage/understand-security-identifiers)
  100.                 ['Administrateurs']=(
  101.                         localgroupname="${c.localised_groupnames['Administrators']}"
  102.                         localgid=544
  103. @@ -298,6 +306,30 @@ if [[ -v c.localised_groupnames['Administrators'] ]] ; then
  104.         )
  105.  fi
  106.  
  107. +if [[ -v c.localised_groupnames['Users'] ]] ; then
  108. +       localgroups+=(
  109. +               ["${c.localised_groupnames['Users']}"]=(
  110. +                       localgroupname="${c.localised_groupnames['Users']}"
  111. +                       localgid=545
  112. +               )
  113. +               ['Users']=(
  114. +                       localgroupname="${c.localised_groupnames['Users']}"
  115. +                       localgid=545
  116. +               )
  117. +               # French Windows localised group name for "Users"
  118. +               # (from https://learn.microsoft.com/fr-fr/windows-server/identity/ad-ds/manage/understand-security-identifiers)
  119. +               ['Utilisateurs']=(
  120. +                       localgroupname="${c.localised_groupnames['Users']}"
  121. +                       localgid=545
  122. +               )
  123. +               # German Windows localised group name for "Users"
  124. +               ['Benutzer']=(
  125. +                       localgroupname="${c.localised_groupnames['Users']}"
  126. +                       localgid=545
  127. +               )
  128. +       )
  129. +fi
  130. +
  131.  case "${c.mode}" in
  132.         'nfsserver_owner2localaccount')
  133.                 #
  134. --
  135. 2.51.0
  136.  
  137. From e73b16b10875b0372044e28efad6be72a46ae5c4 Mon Sep 17 00:00:00 2001
  138. From: Roland Mainz <roland.mainz@nrubsig.org>
  139. Date: Thu, 9 Oct 2025 20:19:29 +0200
  140. Subject: [PATCH 3/4] sys: Minor cleanup in updowncall code
  141.  
  142. Minor cleanup in updowncall code.
  143.  
  144. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  145. ---
  146. sys/nfs41sys_updowncall.c | 69 ++++++++++++++++++++++-----------------
  147.  1 file changed, 39 insertions(+), 30 deletions(-)
  148.  
  149. diff --git a/sys/nfs41sys_updowncall.c b/sys/nfs41sys_updowncall.c
  150. index 78ec5a2..6d4c6c9 100644
  151. --- a/sys/nfs41sys_updowncall.c
  152. +++ b/sys/nfs41sys_updowncall.c
  153. @@ -56,6 +56,7 @@
  154.  #include <rx.h>
  155.  #include <windef.h>
  156.  #include <winerror.h>
  157. +#include <stdbool.h>
  158.  
  159.  #include <Ntstrsafe.h>
  160.  
  161. @@ -156,7 +157,9 @@ static void unmarshal_nfs41_header(
  162.      DbgP("[downcall header] "
  163.          "xid=%lld opcode='%s' status=0x%lx errno=%d\n",
  164.          tmp->xid,
  165. -        ENTRY_OPCODE2STRING(tmp), (long)tmp->status, tmp->errno);
  166. +        opcode2string(tmp->opcode),
  167. +        (long)tmp->status,
  168. +        tmp->errno);
  169.  #endif
  170.  }
  171.  
  172. @@ -496,8 +499,8 @@ retry_wait:
  173.                  UserMode, FALSE, &timeout);
  174.  
  175.      print_wait_status(0, "[downcall]", status,
  176. -        ENTRY_OPCODE2STRING(entry), entry,
  177. -        (entry?entry->xid:-1LL));
  178. +        opcode2string(entry->opcode), entry,
  179. +        entry->xid);
  180.  
  181.      switch(status) {
  182.      case STATUS_SUCCESS:
  183. @@ -520,7 +523,7 @@ retry_wait:
  184.                  "returned status(=0x%lx), "
  185.                  "retry waiting for '%s' entry=0x%p xid=%lld\n",
  186.                  (long)status,
  187. -                ENTRY_OPCODE2STRING(entry),
  188. +                opcode2string(entry->opcode),
  189.                  entry,
  190.                  entry->xid);
  191.              goto retry_wait;
  192. @@ -533,9 +536,9 @@ retry_wait:
  193.              break;
  194.          }
  195.          DbgP("[upcall] abandoning '%s' entry=0x%p xid=%lld\n",
  196. -            ENTRY_OPCODE2STRING(entry),
  197. +            opcode2string(entry->opcode),
  198.              entry,
  199. -            (entry?entry->xid:-1LL));
  200. +            entry->xid);
  201.          entry->state = NFS41_NOT_WAITING;
  202.          ExReleaseFastMutexUnsafe(&entry->lock);
  203.          goto out;
  204. @@ -617,8 +620,9 @@ NTSTATUS nfs41_downcall(
  205.      const unsigned char *inbuf;
  206.      const unsigned char *inbuf_orig;
  207.      PLIST_ENTRY pEntry;
  208. -    nfs41_updowncall_entry *tmp, *cur= NULL;
  209. -    BOOLEAN found = 0;
  210. +    nfs41_updowncall_entry *header_tmp;
  211. +    nfs41_updowncall_entry *cur = NULL;
  212. +    bool found = false;
  213.  
  214.      inbuf = inbuf_orig = LowIoContext->ParamsFor.IoCtl.pInputBuffer;
  215.  
  216. @@ -629,18 +633,18 @@ NTSTATUS nfs41_downcall(
  217.  #endif /* DEBUG_PRINT_DOWNCALL_HEXBUF */
  218.  
  219.  #ifdef USE_STACK_FOR_DOWNCALL_UPDOWNCALLENTRY_MEM
  220. -    nfs41_updowncall_entry stacktmp; /* rename this to |header_tmp| */
  221. +    nfs41_updowncall_entry header_tmp_from_stack;
  222.  
  223. -    tmp = &stacktmp;
  224. +    header_tmp = &header_tmp_from_stack;
  225.  #else
  226. -    tmp = nfs41_downcall_allocate_updowncall_entry();
  227. -    if (tmp == NULL) {
  228. +    header_tmp = nfs41_downcall_allocate_updowncall_entry();
  229. +    if (header_tmp == NULL) {
  230.          status = STATUS_INSUFFICIENT_RESOURCES;
  231.          goto out;
  232.      }
  233.  #endif /* USE_STACK_FOR_DOWNCALL_UPDOWNCALLENTRY_MEM */
  234.  
  235. -    unmarshal_nfs41_header(tmp, &inbuf);
  236. +    unmarshal_nfs41_header(header_tmp, &inbuf);
  237.  
  238.      ExAcquireFastMutexUnsafe(&downcalllist.lock);
  239.      pEntry = &downcalllist.head;
  240. @@ -648,8 +652,8 @@ NTSTATUS nfs41_downcall(
  241.      while (pEntry != NULL) {
  242.          cur = (nfs41_updowncall_entry *)CONTAINING_RECORD(pEntry,
  243.                  nfs41_updowncall_entry, next);
  244. -        if (cur->xid == tmp->xid) {
  245. -            found = 1;
  246. +        if (cur->xid == header_tmp->xid) {
  247. +            found = true;
  248.              break;
  249.          }
  250.          if (pEntry->Flink == &downcalllist.head)
  251. @@ -659,14 +663,17 @@ NTSTATUS nfs41_downcall(
  252.      ExReleaseFastMutexUnsafe(&downcalllist.lock);
  253.      SeStopImpersonatingClient();
  254.      if (!found) {
  255. -        print_error("Didn't find xid=%lld entry\n", tmp->xid);
  256. +        print_error("nfs41_downcall: Did not find xid=%lld entry\n",
  257. +            header_tmp->xid);
  258.          status = STATUS_NOT_FOUND;
  259.          goto out_free;
  260.      }
  261.  
  262.      ExAcquireFastMutexUnsafe(&cur->lock);
  263.      if (cur->state == NFS41_NOT_WAITING) {
  264. -        DbgP("[downcall] Nobody is waiting for this request!!!\n");
  265. +        DbgP("nfs41_downcall: "
  266. +            "Nobody is waiting for this request (xid=%lld)!\n",
  267. +            cur->xid);
  268.          switch(cur->opcode) {
  269.          case NFS41_SYSOP_WRITE:
  270.          case NFS41_SYSOP_READ:
  271. @@ -711,12 +718,12 @@ NTSTATUS nfs41_downcall(
  272.          goto out_free;
  273.      }
  274.      cur->state = NFS41_DONE_PROCESSING;
  275. -    cur->status = tmp->status;
  276. -    cur->errno = tmp->errno;
  277. +    cur->status = header_tmp->status;
  278. +    cur->errno = header_tmp->errno;
  279.      status = STATUS_SUCCESS;
  280.  
  281. -    if (!tmp->status) {
  282. -        switch (tmp->opcode) {
  283. +    if (!header_tmp->status) {
  284. +        switch (header_tmp->opcode) {
  285.          case NFS41_SYSOP_MOUNT:
  286.              unmarshal_nfs41_mount(cur, &inbuf);
  287.              break;
  288. @@ -775,11 +782,12 @@ NTSTATUS nfs41_downcall(
  289.           * passes a buffer which is too small)
  290.           */
  291.          ULONG bytesread_from_inbuf = (ULONG)(inbuf - inbuf_orig);
  292. -        if ((tmp->opcode != NFS41_SYSOP_VOLUME_QUERY) &&
  293. +        if ((header_tmp->opcode != NFS41_SYSOP_VOLUME_QUERY) &&
  294.              (bytesread_from_inbuf != inbuf_len)) {
  295. -            print_error("nfs41_downcall: ASSERT: '%s': "
  296. +            print_error("nfs41_downcall: ASSERT: '%s' (xid=%lld): "
  297.                  "(inbuf(=0x%p)-inbuf_orig(=0x%p))(=%ld) != inbuf_len(=%ld)\n",
  298. -                opcode2string(tmp->opcode),
  299. +                opcode2string(header_tmp->opcode),
  300. +                cur->xid,
  301.                  inbuf,
  302.                  inbuf_orig,
  303.                  (long)bytesread_from_inbuf,
  304. @@ -807,9 +815,9 @@ NTSTATUS nfs41_downcall(
  305.                  nfs41_UpcallDestroy(cur);
  306.                  break;
  307.              default:
  308. -                print_error("##### nfs41_downcall: "
  309. +                print_error("nfs41_downcall: xid=%lld "
  310.                      "unknown async opcode=%d ####\n",
  311. -                    (int)cur->opcode);
  312. +                    cur->xid, (int)cur->opcode);
  313.                  break;
  314.          }
  315.      } else {
  316. @@ -820,7 +828,7 @@ out_free:
  317.  #ifdef USE_STACK_FOR_DOWNCALL_UPDOWNCALLENTRY_MEM
  318.      ;
  319.  #else
  320. -    nfs41_downcall_free_updowncall_entry(tmp);
  321. +    nfs41_downcall_free_updowncall_entry(header_tmp);
  322.  out:
  323.  #endif /* USE_STACK_FOR_DOWNCALL_UPDOWNCALLENTRY_MEM */
  324.  
  325. @@ -839,7 +847,7 @@ NTSTATUS nfs41_delayxid(
  326.      const unsigned char *inbuf_orig;
  327.      PLIST_ENTRY pEntry;
  328.      nfs41_updowncall_entry *cur = NULL;
  329. -    BOOLEAN found = FALSE;
  330. +    bool found = false;
  331.  
  332.      FsRtlEnterFileSystem();
  333.  
  334. @@ -863,8 +871,9 @@ NTSTATUS nfs41_delayxid(
  335.       */
  336.      ULONG bytesread_from_inbuf = (ULONG)(inbuf - inbuf_orig);
  337.      if (bytesread_from_inbuf != inbuf_len) {
  338. -        print_error("nfs41_delayxid: ASSERT: "
  339. +        print_error("nfs41_delayxid: ASSERT (xid=%lld): "
  340.              "(inbuf(=0x%p)-inbuf_orig(=0x%p))(=%ld) != inbuf_len(=%ld)\n",
  341. +            delayxid,
  342.              inbuf,
  343.              inbuf_orig,
  344.              (long)bytesread_from_inbuf,
  345. @@ -879,7 +888,7 @@ NTSTATUS nfs41_delayxid(
  346.          cur = (nfs41_updowncall_entry *)CONTAINING_RECORD(pEntry,
  347.                  nfs41_updowncall_entry, next);
  348.          if (cur->xid == delayxid) {
  349. -            found = TRUE;
  350. +            found = true;
  351.              break;
  352.          }
  353.          if (pEntry->Flink == &downcalllist.head)
  354. --
  355. 2.51.0
  356.  
  357. From f2514416343c745140313f9c480b856128734f25 Mon Sep 17 00:00:00 2001
  358. From: Roland Mainz <roland.mainz@nrubsig.org>
  359. Date: Thu, 9 Oct 2025 20:30:39 +0200
  360. Subject: [PATCH 4/4] cygwin: Add Cygwin DLL prototype patch to fix uid/gid
  361.  mapping
  362.  
  363. Add Cygwin DLL prototype patch to fix uid/gid mapping in cases
  364. where the machine does not use LDAP, and the NFS client uses
  365. Cygwin or UWIN to generate the uid/gid values.
  366.  
  367. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  368. ---
  369. .../cygwin_dll_fix_uidgid4nfsv4_fs.diff       | 40 +++++++++++++++++++
  370.  1 file changed, 40 insertions(+)
  371.  create mode 100644 cygwin/cygwin_patches/cygwin_dll_fix_uidgid4nfsv4_fs.diff
  372.  
  373. diff --git a/cygwin/cygwin_patches/cygwin_dll_fix_uidgid4nfsv4_fs.diff b/cygwin/cygwin_patches/cygwin_dll_fix_uidgid4nfsv4_fs.diff
  374. new file mode 100644
  375. index 0000000..3e339ff
  376. --- /dev/null
  377. +++ b/cygwin/cygwin_patches/cygwin_dll_fix_uidgid4nfsv4_fs.diff
  378. @@ -0,0 +1,40 @@
  379. +# prototype fix for Cygwin DLL to handle uids/gids correctly on
  380. +# NFSv4 filesystems.
  381. +# Without LDAP they use Cygwin or UWIN to obtain the uid/gid for files,
  382. +# which breaks the assumptions in |fhandler_base::fstat_by_nfs_ea()|
  383. +# and causes it to map all uid/gid values into the Unix_User+/Unix_Group SID
  384. +# range
  385. +diff --git a/winsup/cygwin/fhandler/disk_file.cc b/winsup/cygwin/fhandler/disk_file.cc
  386. +index d54d3747e..92a54d9db 100644
  387. +--- a/winsup/cygwin/fhandler/disk_file.cc
  388. ++++ b/winsup/cygwin/fhandler/disk_file.cc
  389. +@@ -239,8 +239,12 @@ fhandler_base::fstat_by_nfs_ea (struct stat *buf)
  390. +         domain = cygheap->dom.get_rfc2307_domain ();
  391. +         if ((ldap_open = (cldap.open (domain) == NO_ERROR)))
  392. +           map_uid = cldap.remap_uid (nfs_attr->uid);
  393. +-        if (map_uid == ILLEGAL_UID)
  394. +-          map_uid = MAP_UNIX_TO_CYGWIN_ID (nfs_attr->uid);
  395. ++        if (map_uid == ILLEGAL_UID) {
  396. ++            if (pc.has_acls())
  397. ++              map_uid = nfs_attr->uid;
  398. ++            else
  399. ++              map_uid = MAP_UNIX_TO_CYGWIN_ID (nfs_attr->uid);
  400. ++          }
  401. +         cygheap->ugid_cache.add_uid (nfs_attr->uid, map_uid);
  402. +         buf->st_uid = map_uid;
  403. +       }
  404. +@@ -258,8 +262,12 @@ fhandler_base::fstat_by_nfs_ea (struct stat *buf)
  405. +         domain = cygheap->dom.get_rfc2307_domain ();
  406. +         if ((ldap_open || cldap.open (domain) == NO_ERROR))
  407. +           map_gid = cldap.remap_gid (nfs_attr->gid);
  408. +-        if (map_gid == ILLEGAL_GID)
  409. +-          map_gid = MAP_UNIX_TO_CYGWIN_ID (nfs_attr->gid);
  410. ++        if (map_gid == ILLEGAL_GID) {
  411. ++            if (pc.has_acls())
  412. ++              map_gid = nfs_attr->gid;
  413. ++            else
  414. ++            map_gid = MAP_UNIX_TO_CYGWIN_ID (nfs_attr->gid);
  415. ++          }
  416. +         cygheap->ugid_cache.add_gid (nfs_attr->gid, map_gid);
  417. +         buf->st_gid = map_gid;
  418. +       }
  419. --
  420. 2.51.0

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