pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Kernel+libtirpc+misc patches, 2023-11-06
Posted by Anonymous on Mon 6th Nov 2023 06:20
raw | new post

  1. From 2826a4b2e9152b50e7075cbad0f9dd87d9d85f7e Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Tue, 31 Oct 2023 11:33:44 +0100
  4. Subject: [PATCH 1/9] cygwin/devel/msnfs41client.bash: Remove custom uid
  5.  settings
  6.  
  7. Remove custom uid/uid settings in msnfs41client.bash
  8.  
  9. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  10. ---
  11. cygwin/devel/msnfs41client.bash | 10 ++++------
  12.  1 file changed, 4 insertions(+), 6 deletions(-)
  13.  
  14. diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
  15. index 454b4bc..da91627 100644
  16. --- a/cygwin/devel/msnfs41client.bash
  17. +++ b/cygwin/devel/msnfs41client.bash
  18. @@ -108,12 +108,11 @@ function nfsclient_rundeamon
  19.         #
  20.  
  21.         if false ; then
  22. -               gdb -ex=run --args nfsd_debug -d 0 --noldap --gid 1616 --uid 1616
  23. +               gdb -ex=run --args nfsd_debug -d 0 --noldap #--gid 1616 --uid 1616
  24.         else
  25.                 export _NT_ALT_SYMBOL_PATH="$(cygpath -w "$PWD");srv*https://msdl.microsoft.com/download/symbols"
  26.                 # use '!gflag +full;g' for heap tests, eats lots of memory
  27. -               # use '!gflag +soe;sxe -c "kp;gn" *;g' to report exceptions and then continue
  28. -               cdb -c '!gflag +soe;sxe -c "kp;gn" *;g' "$(cygpath -w "$PWD/nfsd_debug.exe")" -d 0 --noldap --gid 1616 --uid 1616
  29. +               cdb -c '!gflag +soe;sxe -c "kp;gn" *;g' "$(cygpath -w "$PWD/nfsd_debug.exe")" -d 0 --noldap #--gid 1616 --uid 1616
  30.         fi
  31.         return $?
  32.  }
  33. @@ -124,12 +123,11 @@ function nfsclient_system_rundeamon
  34.         set -o nounset
  35.  
  36.         if false ; then
  37. -               su_system gdb -ex=run --args nfsd_debug -d 0 --noldap --gid 1616 --uid 1616
  38. +               su_system gdb -ex=run --args nfsd_debug -d 0 --noldap #--gid 1616 --uid 1616
  39.         else
  40.                 export _NT_ALT_SYMBOL_PATH="$(cygpath -w "$PWD");srv*https://msdl.microsoft.com/download/symbols"
  41.                 # use '!gflag +full;g' for heap tests, eats lots of memory
  42. -               # use '!gflag +soe;sxe -c "kp;gn" *;g' to report exceptions and then continue
  43. -               su_system cdb -c '!gflag +soe;sxe -c "kp;gn" *;g' "$(cygpath -w "$PWD/nfsd_debug.exe")" -d 0 --noldap --gid 1616 --uid 1616
  44. +               su_system cdb -c '!gflag +soe;sxe -c "kp;gn" *;g' "$(cygpath -w "$PWD/nfsd_debug.exe")" -d 0 --noldap #--gid 1616 --uid 1616
  45.         fi
  46.         return $?
  47.  }
  48. --
  49. 2.42.0
  50.  
  51. From e87c0a0d120783491031b33ac55bb2ec3ecc942a Mon Sep 17 00:00:00 2001
  52. From: Roland Mainz <roland.mainz@nrubsig.org>
  53. Date: Wed, 1 Nov 2023 13:17:06 +0100
  54. Subject: [PATCH 2/9] libtirpc: Re-enable |warnx()| for libtirpc
  55.  
  56. |warnx()| rework in Win32-libtirpc:
  57. - Added Win32-specific |wintirpc_warnx()|
  58. - re-enable |warnx()| and use |wintirpc_warnx()|
  59. - added Win32-|assert()| macro, which uses |wintirpc_warnx()|
  60.  
  61. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  62. ---
  63. libtirpc/src/auth_unix.c     | 13 +++++-----
  64.  libtirpc/src/clnt_dg.c       |  2 +-
  65.  libtirpc/src/clnt_raw.c      |  6 +++--
  66.  libtirpc/src/crypt_client.c  |  2 +-
  67.  libtirpc/src/svc_dg.c        | 20 +++++++--------
  68.  libtirpc/src/svc_generic.c   | 47 ++++++++++++++++++------------------
  69.  libtirpc/src/svc_simple.c    | 36 +++++++++++++--------------
  70.  libtirpc/src/svc_vc.c        | 26 +++++++++++---------
  71.  libtirpc/src/wintirpc.c      | 11 ++++++++-
  72.  libtirpc/src/xdr.c           |  4 +--
  73.  libtirpc/src/xdr_array.c     |  2 +-
  74.  libtirpc/src/xdr_rec.c       |  6 ++---
  75.  libtirpc/src/xdr_reference.c |  2 +-
  76.  libtirpc/tirpc/wintirpc.h    | 10 ++++++++
  77.  14 files changed, 105 insertions(+), 82 deletions(-)
  78.  
  79. diff --git a/libtirpc/src/auth_unix.c b/libtirpc/src/auth_unix.c
  80. index ff86956..e9e9fa4 100644
  81. --- a/libtirpc/src/auth_unix.c
  82. +++ b/libtirpc/src/auth_unix.c
  83. @@ -66,8 +66,10 @@
  84.  #include <reentrant.h>
  85.  //#include <sys/param.h>
  86.  
  87. +#ifndef _WIN32
  88.  #include <assert.h>
  89. -//#include <err.h>
  90. +#include <err.h>
  91. +#endif /* !_WIN32 */
  92.  #include <stdio.h>
  93.  #include <stdlib.h>
  94.  //#include <unistd.h>
  95. @@ -125,14 +127,14 @@ authunix_create(machname, uid, gid, len, aup_gids)
  96.         auth = mem_alloc(sizeof(*auth));
  97.  #ifndef _KERNEL
  98.         if (auth == NULL) {
  99. -               // XXX warnx("authunix_create: out of memory");
  100. +               warnx("authunix_create: out of memory");
  101.                 goto cleanup_authunix_create;
  102.         }
  103.  #endif
  104.         au = mem_alloc(sizeof(*au));
  105.  #ifndef _KERNEL
  106.         if (au == NULL) {
  107. -               // XXX warnx("authunix_create: out of memory");
  108. +               warnx("authunix_create: out of memory");
  109.                 goto cleanup_authunix_create;
  110.         }
  111.  #endif
  112. @@ -165,7 +167,7 @@ authunix_create(machname, uid, gid, len, aup_gids)
  113.         au->au_origcred.oa_base = mem_alloc((u_int) len);
  114.  #else
  115.         if ((au->au_origcred.oa_base = mem_alloc((u_int) len)) == NULL) {
  116. -               // XXX warnx("authunix_create: out of memory");
  117. +               warnx("authunix_create: out of memory");
  118.                 goto cleanup_authunix_create;
  119.         }
  120.  #endif
  121. @@ -371,8 +373,7 @@ marshal_new_auth(auth)
  122.         xdrmem_create(xdrs, au->au_marshed, MAX_AUTH_BYTES, XDR_ENCODE);
  123.         if ((! xdr_opaque_auth(xdrs, &(auth->ah_cred))) ||
  124.             (! xdr_opaque_auth(xdrs, &(auth->ah_verf))))
  125. -               assert(0); // XXX
  126. -               // XXX warnx("auth_none.c - Fatal marshalling problem");
  127. +               warnx("auth_none.c - Fatal marshalling problem");
  128.         else
  129.                 au->au_mpos = XDR_GETPOS(xdrs);
  130.         XDR_DESTROY(xdrs);
  131. diff --git a/libtirpc/src/clnt_dg.c b/libtirpc/src/clnt_dg.c
  132. index e5b62ff..0e7427f 100644
  133. --- a/libtirpc/src/clnt_dg.c
  134. +++ b/libtirpc/src/clnt_dg.c
  135. @@ -300,7 +300,7 @@ clnt_dg_create(fd, svcaddr, program, version, sendsz, recvsz)
  136.        
  137.         return (cl);
  138.  err1:
  139. -       //warnx(mem_err_clnt_dg);
  140. +       warnx(mem_err_clnt_dg);
  141.         rpc_createerr.cf_stat = RPC_SYSTEMERROR;
  142.         rpc_createerr.cf_error.re_errno = errno;
  143.  err2:
  144. diff --git a/libtirpc/src/clnt_raw.c b/libtirpc/src/clnt_raw.c
  145. index 3953324..d97761b 100644
  146. --- a/libtirpc/src/clnt_raw.c
  147. +++ b/libtirpc/src/clnt_raw.c
  148. @@ -39,8 +39,10 @@
  149.  #include <wintirpc.h>
  150.  //#include <pthread.h>
  151.  #include <reentrant.h>
  152. +#ifndef _WIN32
  153.  #include <assert.h>
  154. -//#include <err.h>
  155. +#include <err.h>
  156. +#endif /* !_WIN32 */
  157.  #include <stdio.h>
  158.  #include <stdlib.h>
  159.  
  160. @@ -113,7 +115,7 @@ clnt_raw_create(prog, vers)
  161.         call_msg.rm_call.cb_vers = (u_int32_t)vers;
  162.         xdrmem_create(xdrs, clp->u.mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE);
  163.         if (! xdr_callhdr(xdrs, &call_msg))
  164. -               //warnx("clntraw_create - Fatal header serialization error.");
  165. +               warnx("clntraw_create - Fatal header serialization error.");
  166.         clp->mcnt = XDR_GETPOS(xdrs);
  167.         XDR_DESTROY(xdrs);
  168.  
  169. diff --git a/libtirpc/src/crypt_client.c b/libtirpc/src/crypt_client.c
  170. index 32023fb..73fa320 100644
  171. --- a/libtirpc/src/crypt_client.c
  172. +++ b/libtirpc/src/crypt_client.c
  173. @@ -63,7 +63,7 @@ _des_crypt_call(buf, len, dparms)
  174.                         break;
  175.         }
  176.         if (nconf == NULL) {
  177. -               //warnx("getnetconfig: %s", nc_sperror());
  178. +               warnx("getnetconfig: %s", nc_sperror());
  179.                 return(DESERR_HWERROR);
  180.         }
  181.         clnt = clnt_tp_create(NULL, CRYPT_PROG, CRYPT_VERS, nconf);
  182. diff --git a/libtirpc/src/svc_dg.c b/libtirpc/src/svc_dg.c
  183. index 8610c7a..b6bc541 100644
  184. --- a/libtirpc/src/svc_dg.c
  185. +++ b/libtirpc/src/svc_dg.c
  186. @@ -104,7 +104,7 @@ svc_dg_create(fd, sendsize, recvsize)
  187.         socklen_t slen;
  188.  
  189.         if (!__rpc_fd2sockinfo(fd, &si)) {
  190. -               // XXX warnx(svc_dg_str, svc_dg_err1);
  191. +               warnx(svc_dg_str, svc_dg_err1);
  192.                 return (NULL);
  193.         }
  194.         /*
  195. @@ -113,7 +113,7 @@ svc_dg_create(fd, sendsize, recvsize)
  196.         sendsize = __rpc_get_t_size(si.si_af, si.si_proto, (int)sendsize);
  197.         recvsize = __rpc_get_t_size(si.si_af, si.si_proto, (int)recvsize);
  198.         if ((sendsize == 0) || (recvsize == 0)) {
  199. -               // XXX warnx(svc_dg_str, svc_dg_err2);
  200. +               warnx(svc_dg_str, svc_dg_err2);
  201.                 return (NULL);
  202.         }
  203.  
  204. @@ -145,7 +145,7 @@ svc_dg_create(fd, sendsize, recvsize)
  205.         xprt_register(xprt);
  206.         return (xprt);
  207.  freedata:
  208. -       // XXX (void) warnx(svc_dg_str, __no_mem_str);
  209. +       warnx(svc_dg_str, __no_mem_str);
  210.         if (xprt) {
  211.                 if (su)
  212.                         (void) mem_free(su, sizeof (*su));
  213. @@ -392,13 +392,13 @@ svc_dg_enablecache(transp, size)
  214.  
  215.         mutex_lock(&dupreq_lock);
  216.         if (su->su_cache != NULL) {
  217. -               // XXX (void) warnx(cache_enable_str, enable_err, " ");
  218. +               warnx(cache_enable_str, enable_err, " ");
  219.                 mutex_unlock(&dupreq_lock);
  220.                 return (0);
  221.         }
  222.         uc = ALLOC(struct cl_cache, 1);
  223.         if (uc == NULL) {
  224. -               // XXX warnx(cache_enable_str, alloc_err, " ");
  225. +               warnx(cache_enable_str, alloc_err, " ");
  226.                 mutex_unlock(&dupreq_lock);
  227.                 return (0);
  228.         }
  229. @@ -406,7 +406,7 @@ svc_dg_enablecache(transp, size)
  230.         uc->uc_nextvictim = 0;
  231.         uc->uc_entries = ALLOC(cache_ptr, size * SPARSENESS);
  232.         if (uc->uc_entries == NULL) {
  233. -               // XXX warnx(cache_enable_str, alloc_err, "data");
  234. +               warnx(cache_enable_str, alloc_err, "data");
  235.                 FREE(uc, struct cl_cache, 1);
  236.                 mutex_unlock(&dupreq_lock);
  237.                 return (0);
  238. @@ -414,7 +414,7 @@ svc_dg_enablecache(transp, size)
  239.         MEMZERO(uc->uc_entries, cache_ptr, size * SPARSENESS);
  240.         uc->uc_fifo = ALLOC(cache_ptr, size);
  241.         if (uc->uc_fifo == NULL) {
  242. -               // XXX warnx(cache_enable_str, alloc_err, "fifo");
  243. +               warnx(cache_enable_str, alloc_err, "fifo");
  244.                 FREE(uc->uc_entries, cache_ptr, size * SPARSENESS);
  245.                 FREE(uc, struct cl_cache, 1);
  246.                 mutex_unlock(&dupreq_lock);
  247. @@ -468,7 +468,7 @@ cache_set(xprt, replylen)
  248.                         vicp = &(*vicp)->cache_next)
  249.                         ;
  250.                 if (*vicp == NULL) {
  251. -                       // XXX warnx(cache_set_str, cache_set_err1);
  252. +                       warnx(cache_set_str, cache_set_err1);
  253.                         mutex_unlock(&dupreq_lock);
  254.                         return;
  255.                 }
  256. @@ -477,13 +477,13 @@ cache_set(xprt, replylen)
  257.         } else {
  258.                 victim = ALLOC(struct cache_node, 1);
  259.                 if (victim == NULL) {
  260. -                       // XXX warnx(cache_set_str, cache_set_err2);
  261. +                       warnx(cache_set_str, cache_set_err2);
  262.                         mutex_unlock(&dupreq_lock);
  263.                         return;
  264.                 }
  265.                 newbuf = mem_alloc(su->su_iosz);
  266.                 if (newbuf == NULL) {
  267. -                       // XXX warnx(cache_set_str, cache_set_err3);
  268. +                       warnx(cache_set_str, cache_set_err3);
  269.                         FREE(victim, struct cache_node, 1);
  270.                         mutex_unlock(&dupreq_lock);
  271.                         return;
  272. diff --git a/libtirpc/src/svc_generic.c b/libtirpc/src/svc_generic.c
  273. index 80f5e87..47a12a3 100644
  274. --- a/libtirpc/src/svc_generic.c
  275. +++ b/libtirpc/src/svc_generic.c
  276. @@ -85,7 +85,7 @@ svc_create(dispatch, prognum, versnum, nettype)
  277.  /* VARIABLES PROTECTED BY xprtlist_lock: xprtlist */
  278.  
  279.         if ((handle = __rpc_setconf(nettype)) == NULL) {
  280. -               // XXX warnx("svc_create: unknown protocol");
  281. +               warnx("svc_create: unknown protocol");
  282.                 return (0);
  283.         }
  284.         while ((nconf = __rpc_getconf(handle)) != NULL) {
  285. @@ -96,10 +96,10 @@ svc_create(dispatch, prognum, versnum, nettype)
  286.                                 (void) rpcb_unset(prognum, versnum, nconf);
  287.                                 if (svc_reg(l->xprt, prognum, versnum,
  288.                                         dispatch, nconf) == FALSE) {
  289. -                                       // XXX warnx(
  290. -//             "svc_create: could not register prog %u vers %u on %s",
  291. -//                                     (unsigned)prognum, (unsigned)versnum,
  292. -//                                      nconf->nc_netid);
  293. +                                       warnx(
  294. +                                               "svc_create: could not register prog %u vers %u on %s",
  295. +                                               (unsigned)prognum, (unsigned)versnum,
  296. +                                               nconf->nc_netid);
  297.                                 } else {
  298.                                         num++;
  299.                                 }
  300. @@ -112,7 +112,7 @@ svc_create(dispatch, prognum, versnum, nettype)
  301.                         if (xprt) {
  302.                                 l = (struct xlist *)malloc(sizeof (*l));
  303.                                 if (l == NULL) {
  304. -                                       // XXX warnx("svc_create: no memory");
  305. +                                       warnx("svc_create: no memory");
  306.                                         mutex_unlock(&xprtlist_lock);
  307.                                         return (0);
  308.                                 }
  309. @@ -147,9 +147,9 @@ svc_tp_create(dispatch, prognum, versnum, nconf)
  310.         SVCXPRT *xprt;
  311.  
  312.         if (nconf == NULL) {
  313. -               // XXX warnx(
  314. -//     "svc_tp_create: invalid netconfig structure for prog %u vers %u",
  315. -//                             (unsigned)prognum, (unsigned)versnum);
  316. +               warnx(
  317. +                       "svc_tp_create: invalid netconfig structure for prog %u vers %u",
  318. +                       (unsigned)prognum, (unsigned)versnum);
  319.                 return (NULL);
  320.         }
  321.         xprt = svc_tli_create(RPC_ANYFD, nconf, NULL, 0, 0);
  322. @@ -159,10 +159,10 @@ svc_tp_create(dispatch, prognum, versnum, nconf)
  323.         /*LINTED const castaway*/
  324.         (void) rpcb_unset(prognum, versnum, (struct netconfig *) nconf);
  325.         if (svc_reg(xprt, prognum, versnum, dispatch, nconf) == FALSE) {
  326. -               // XXX warnx(
  327. -//             "svc_tp_create: Could not register prog %u vers %u on %s",
  328. -//                             (unsigned)prognum, (unsigned)versnum,
  329. -//                             nconf->nc_netid);
  330. +               warnx(
  331. +                       "svc_tp_create: Could not register prog %u vers %u on %s",
  332. +                       (unsigned)prognum, (unsigned)versnum,
  333. +                       nconf->nc_netid);
  334.                 SVC_DESTROY(xprt);
  335.                 return (NULL);
  336.         }
  337. @@ -194,14 +194,14 @@ svc_tli_create(fd, nconf, bindaddr, sendsz, recvsz)
  338.  
  339.         if (fd == RPC_ANYFD) {
  340.                 if (nconf == NULL) {
  341. -                       // XXX warnx("svc_tli_create: invalid netconfig");
  342. +                       warnx("svc_tli_create: invalid netconfig");
  343.                         return (NULL);
  344.                 }
  345.                 fd = __rpc_nconf2fd(nconf);
  346.                 if (fd == -1) {
  347. -                       // XXX warnx(
  348. -//                         "svc_tli_create: could not open connection for %s",
  349. -//                                     nconf->nc_netid);
  350. +                       warnx(
  351. +                               "svc_tli_create: could not open connection for %s",
  352. +                               nconf->nc_netid);
  353.                         return (NULL);
  354.                 }
  355.                 __rpc_nconf2sockinfo(nconf, &si);
  356. @@ -211,8 +211,7 @@ svc_tli_create(fd, nconf, bindaddr, sendsz, recvsz)
  357.                  * It is an open descriptor. Get the transport info.
  358.                  */
  359.                 if (!__rpc_fd2sockinfo(fd, &si)) {
  360. -                       // XXX warnx(
  361. -//             "svc_tli_create: could not get transport information");
  362. +                       warnx("svc_tli_create: could not get transport information");
  363.                         return (NULL);
  364.                 }
  365.         }
  366. @@ -227,8 +226,8 @@ svc_tli_create(fd, nconf, bindaddr, sendsz, recvsz)
  367.                                 ss.ss_family = si.si_af;
  368.                                 if (bind(_get_osfhandle(fd), (struct sockaddr *)(void *)&ss,
  369.                                     (socklen_t)si.si_alen) == SOCKET_ERROR) {
  370. -                                       // XXX warnx(
  371. -//                     "svc_tli_create: could not bind to anonymous port");
  372. +                                       warnx(
  373. +                                               "svc_tli_create: could not bind to anonymous port");
  374.                                         goto freedata;
  375.                                 }
  376.                         }
  377. @@ -237,8 +236,8 @@ svc_tli_create(fd, nconf, bindaddr, sendsz, recvsz)
  378.                         if (bind(_get_osfhandle(fd),
  379.                             (struct sockaddr *)bindaddr->addr.buf,
  380.                             (socklen_t)si.si_alen) == SOCKET_ERROR) {
  381. -                               // XXX warnx(
  382. -//             "svc_tli_create: could not bind to requested address");
  383. +                               warnx(
  384. +                                       "svc_tli_create: could not bind to requested address");
  385.                                 goto freedata;
  386.                         }
  387.                         wintirpc_listen(fd, (int)bindaddr->qlen);
  388. @@ -270,7 +269,7 @@ svc_tli_create(fd, nconf, bindaddr, sendsz, recvsz)
  389.                         xprt = svc_dg_create(fd, sendsz, recvsz);
  390.                         break;
  391.                 default:
  392. -                       // XXX warnx("svc_tli_create: bad service type");
  393. +                       warnx("svc_tli_create: bad service type");
  394.                         goto freedata;
  395.         }
  396.  
  397. diff --git a/libtirpc/src/svc_simple.c b/libtirpc/src/svc_simple.c
  398. index 17ec027..3ad528e 100644
  399. --- a/libtirpc/src/svc_simple.c
  400. +++ b/libtirpc/src/svc_simple.c
  401. @@ -103,15 +103,15 @@ rpc_reg(prognum, versnum, procnum, progname, inproc, outproc, nettype)
  402.         extern mutex_t proglst_lock;
  403.  
  404.         if (procnum == NULLPROC) {
  405. -               // XXXwarnx("%s can't reassign procedure number %u", rpc_reg_msg,
  406. -//                     NULLPROC);
  407. +               warnx("%s can't reassign procedure number %u", rpc_reg_msg,
  408. +                       NULLPROC);
  409.                 return (-1);
  410.         }
  411.  
  412.         if (nettype == NULL)
  413.                 nettype = "netpath";            /* The default behavior */
  414.         if ((handle = __rpc_setconf(nettype)) == NULL) {
  415. -               // XXX warnx(rpc_reg_err, rpc_reg_msg, __reg_err1);
  416. +               warnx(rpc_reg_err, rpc_reg_msg, __reg_err1);
  417.                 return (-1);
  418.         }
  419.  /* VARIABLES PROTECTED BY proglst_lock: proglst */
  420. @@ -145,19 +145,19 @@ rpc_reg(prognum, versnum, procnum, progname, inproc, outproc, nettype)
  421.                         if (svcxprt == NULL)
  422.                                 continue;
  423.                         if (!__rpc_fd2sockinfo(svcxprt->xp_fd, &si)) {
  424. -                               // XXX warnx(rpc_reg_err, rpc_reg_msg, __reg_err2);
  425. +                               warnx(rpc_reg_err, rpc_reg_msg, __reg_err2);
  426.                                 SVC_DESTROY(svcxprt);
  427.                                 continue;
  428.                         }
  429.                         recvsz = __rpc_get_t_size(si.si_af, si.si_proto, 0);
  430.                         if (recvsz == 0) {
  431. -                               // XXX warnx(rpc_reg_err, rpc_reg_msg, __reg_err3);
  432. +                               warnx(rpc_reg_err, rpc_reg_msg, __reg_err3);
  433.                                 SVC_DESTROY(svcxprt);
  434.                                 continue;
  435.                         }
  436.                         if (((xdrbuf = malloc((unsigned)recvsz)) == NULL) ||
  437.                                 ((netid = strdup(nconf->nc_netid)) == NULL)) {
  438. -                               // XXX warnx(rpc_reg_err, rpc_reg_msg, __no_mem_str);
  439. +                               warnx(rpc_reg_err, rpc_reg_msg, __no_mem_str);
  440.                                 SVC_DESTROY(svcxprt);
  441.                                 break;
  442.                         }
  443. @@ -180,9 +180,9 @@ rpc_reg(prognum, versnum, procnum, progname, inproc, outproc, nettype)
  444.                 }
  445.  
  446.                 if (!svc_reg(svcxprt, prognum, versnum, universal, nconf)) {
  447. -                       // XXX warnx("%s couldn't register prog %u vers %u for %s",
  448. -//                             rpc_reg_msg, (unsigned)prognum,
  449. -//                             (unsigned)versnum, netid);
  450. +                       warnx("%s couldn't register prog %u vers %u for %s",
  451. +                               rpc_reg_msg, (unsigned)prognum,
  452. +                               (unsigned)versnum, netid);
  453.                         if (madenow) {
  454.                                 SVC_DESTROY(svcxprt);
  455.                                 free(xdrbuf);
  456. @@ -193,7 +193,7 @@ rpc_reg(prognum, versnum, procnum, progname, inproc, outproc, nettype)
  457.  
  458.                 pl = malloc(sizeof (struct proglst));
  459.                 if (pl == NULL) {
  460. -                       // XXX warnx(rpc_reg_err, rpc_reg_msg, __no_mem_str);
  461. +                       warnx(rpc_reg_err, rpc_reg_msg, __no_mem_str);
  462.                         if (madenow) {
  463.                                 SVC_DESTROY(svcxprt);
  464.                                 free(xdrbuf);
  465. @@ -219,8 +219,8 @@ rpc_reg(prognum, versnum, procnum, progname, inproc, outproc, nettype)
  466.         mutex_unlock(&proglst_lock);
  467.  
  468.         if (done == FALSE) {
  469. -               // XXX warnx("%s cant find suitable transport for %s",
  470. -//                     rpc_reg_msg, nettype);
  471. +               warnx("%s cant find suitable transport for %s",
  472. +                       rpc_reg_msg, nettype);
  473.                 return (-1);
  474.         }
  475.         return (0);
  476. @@ -250,7 +250,7 @@ universal(rqstp, transp)
  477.         if (rqstp->rq_proc == NULLPROC) {
  478.                 if (svc_sendreply(transp, (xdrproc_t) xdr_void, NULL) ==
  479.                     FALSE) {
  480. -                       // XXX warnx("svc_sendreply failed");
  481. +                       warnx("svc_sendreply failed");
  482.                 }
  483.                 return;
  484.         }
  485. @@ -284,9 +284,9 @@ universal(rqstp, transp)
  486.                                 return;
  487.                         }
  488.                         if (!svc_sendreply(transp, pl->p_outproc, outdata)) {
  489. -                               // XXX warnx(
  490. -//                     "rpc: rpc_reg trouble replying to prog %u vers %u",
  491. -//                             (unsigned)prog, (unsigned)vers);
  492. +                               warnx(
  493. +                                       "rpc: rpc_reg trouble replying to prog %u vers %u",
  494. +                                       (unsigned)prog, (unsigned)vers);
  495.                                 mutex_unlock(&proglst_lock);
  496.                                 return;
  497.                         }
  498. @@ -297,7 +297,7 @@ universal(rqstp, transp)
  499.                 }
  500.         mutex_unlock(&proglst_lock);
  501.         /* This should never happen */
  502. -       // XXX warnx("rpc: rpc_reg: never registered prog %u vers %u",
  503. -//             (unsigned)prog, (unsigned)vers);
  504. +       warnx("rpc: rpc_reg: never registered prog %u vers %u",
  505. +               (unsigned)prog, (unsigned)vers);
  506.         return;
  507.  }
  508. diff --git a/libtirpc/src/svc_vc.c b/libtirpc/src/svc_vc.c
  509. index fcb6ff3..5c57685 100644
  510. --- a/libtirpc/src/svc_vc.c
  511. +++ b/libtirpc/src/svc_vc.c
  512. @@ -49,8 +49,10 @@
  513.  //#include <netinet/in.h>
  514.  //#include <netinet/tcp.h>
  515.  
  516. +#ifndef _WIN32
  517.  #include <assert.h>
  518. -//#include <err.h>
  519. +#include <err.h>
  520. +#endif /* !_WIN32 */
  521.  #include <errno.h>
  522.  #include <fcntl.h>
  523.  #include <stdio.h>
  524. @@ -156,7 +158,7 @@ svc_vc_create(fd, sendsize, recvsize)
  525.  
  526.         r = mem_alloc(sizeof(*r));
  527.         if (r == NULL) {
  528. -               // XXX warnx("svc_vc_create: out of memory");
  529. +               warnx("svc_vc_create: out of memory");
  530.                 goto cleanup_svc_vc_create;
  531.         }
  532.         if (!__rpc_fd2sockinfo(fd, &si))
  533. @@ -166,7 +168,7 @@ svc_vc_create(fd, sendsize, recvsize)
  534.         r->maxrec = __svc_maxrec;
  535.         xprt = mem_alloc(sizeof(SVCXPRT));
  536.         if (xprt == NULL) {
  537. -               // XXX warnx("svc_vc_create: out of memory");
  538. +               warnx("svc_vc_create: out of memory");
  539.                 goto cleanup_svc_vc_create;
  540.         }
  541.         xprt->xp_tp = NULL;
  542. @@ -180,12 +182,12 @@ svc_vc_create(fd, sendsize, recvsize)
  543.  
  544.         slen = sizeof (struct sockaddr_storage);
  545.         if (getsockname(_get_osfhandle(fd), (struct sockaddr *)(void *)&sslocal, &slen) == SOCKET_ERROR) {
  546. -               // XXX warnx("svc_vc_create: could not retrieve local addr");
  547. +               warnx("svc_vc_create: could not retrieve local addr");
  548.                 goto cleanup_svc_vc_create;
  549.         }
  550.  
  551.         if (!__rpc_set_netbuf(&xprt->xp_ltaddr, &sslocal, sizeof(sslocal))) {
  552. -               // XXX warnx("svc_vc_create: no mem for local addr");
  553. +               warnx("svc_vc_create: no mem for local addr");
  554.                 goto cleanup_svc_vc_create;
  555.         }
  556.         xprt_register(xprt);
  557. @@ -218,21 +220,21 @@ svc_fd_create(fd, sendsize, recvsize)
  558.  
  559.         slen = sizeof (struct sockaddr_storage);
  560.         if (getsockname(_get_osfhandle(fd), (struct sockaddr *)(void *)&ss, &slen) == SOCKET_ERROR) {
  561. -               // XXX warnx("svc_fd_create: could not retrieve local addr");
  562. +               warnx("svc_fd_create: could not retrieve local addr");
  563.                 goto freedata;
  564.         }
  565.         if (!__rpc_set_netbuf(&ret->xp_ltaddr, &ss, sizeof(ss))) {
  566. -               // XXX warnx("svc_fd_create: no mem for local addr");
  567. +               warnx("svc_fd_create: no mem for local addr");
  568.                 goto freedata;
  569.         }
  570.  
  571.         slen = sizeof (struct sockaddr_storage);
  572.         if (getpeername(fd, (struct sockaddr *)(void *)&ss, &slen) == SOCKET_ERROR) {
  573. -               // XXX warnx("svc_fd_create: could not retrieve remote addr");
  574. +               warnx("svc_fd_create: could not retrieve remote addr");
  575.                 goto freedata;
  576.         }
  577.         if (!__rpc_set_netbuf(&ret->xp_rtaddr, &ss, sizeof(ss))) {
  578. -               // XXX warnx("svc_fd_create: no mem for local addr");
  579. +               warnx("svc_fd_create: no mem for local addr");
  580.                 goto freedata;
  581.         }
  582.  
  583. @@ -262,20 +264,20 @@ makefd_xprt(fd, sendsize, recvsize)
  584.         assert(fd != SOCKET_ERROR);
  585.  
  586.          if (fd >= FD_SETSIZE) {
  587. -                // XXX warnx("svc_vc: makefd_xprt: fd too high\n");
  588. +                warnx("svc_vc: makefd_xprt: fd too high\n");
  589.                  xprt = NULL;
  590.                  goto done;
  591.          }
  592.  
  593.         xprt = mem_alloc(sizeof(SVCXPRT));
  594.         if (xprt == NULL) {
  595. -               // XXX warnx("svc_vc: makefd_xprt: out of memory");
  596. +               warnx("svc_vc: makefd_xprt: out of memory");
  597.                 goto done;
  598.         }
  599.         memset(xprt, 0, sizeof *xprt);
  600.         cd = mem_alloc(sizeof(struct cf_conn));
  601.         if (cd == NULL) {
  602. -               // XXX warnx("svc_tcp: makefd_xprt: out of memory");
  603. +               warnx("svc_tcp: makefd_xprt: out of memory");
  604.                 mem_free(xprt, sizeof(SVCXPRT));
  605.                 xprt = NULL;
  606.                 goto done;
  607. diff --git a/libtirpc/src/wintirpc.c b/libtirpc/src/wintirpc.c
  608. index f5b69d6..e75b023 100644
  609. --- a/libtirpc/src/wintirpc.c
  610. +++ b/libtirpc/src/wintirpc.c
  611. @@ -24,7 +24,6 @@
  612.  #include <rpc/rpc.h>
  613.  #include <stdio.h>
  614.  #include <winsock.h>
  615. -#include <assert.h>
  616.  
  617.  WSADATA WSAData;
  618.  
  619. @@ -298,6 +297,16 @@ int wintirpc_sendto(int s, const char *buf, int len, int flags,
  620.         return(sendto(_get_osfhandle(s), buf, len, flags, to, tolen));
  621.  }
  622.  
  623. +void wintirpc_warnx(const char *format, ...)
  624. +{
  625. +    va_list args;
  626. +    va_start(args, format);
  627. +    (void)fprintf(stderr, "%04x: ", GetCurrentThreadId());
  628. +    (void)vfprintf(stderr, format, args);
  629. +    (void)fflush(stderr);
  630. +    va_end(args);
  631. +}
  632. +
  633.  int tirpc_exit(void)
  634.  {
  635.         if (init == 0 || --init > 0)
  636. diff --git a/libtirpc/src/xdr.c b/libtirpc/src/xdr.c
  637. index 7f098b4..38a959d 100644
  638. --- a/libtirpc/src/xdr.c
  639. +++ b/libtirpc/src/xdr.c
  640. @@ -572,7 +572,7 @@ xdr_bytes(xdrs, cpp, sizep, maxsize)
  641.  #endif
  642.                 }
  643.                 if (sp == NULL) {
  644. -                       //warnx("xdr_bytes: out of memory");
  645. +                       warnx("xdr_bytes: out of memory");
  646.                         return (FALSE);
  647.                 }
  648.                 /* FALLTHROUGH */
  649. @@ -735,7 +735,7 @@ xdr_string(xdrs, cpp, maxsize)
  650.                 }
  651.  #endif
  652.                 if (sp == NULL) {
  653. -                       //warnx("xdr_string: out of memory");
  654. +                       warnx("xdr_string: out of memory");
  655.                         return (FALSE);
  656.                 }
  657.                 sp[size] = 0;
  658. diff --git a/libtirpc/src/xdr_array.c b/libtirpc/src/xdr_array.c
  659. index 3ab9ce5..f932efe 100644
  660. --- a/libtirpc/src/xdr_array.c
  661. +++ b/libtirpc/src/xdr_array.c
  662. @@ -94,7 +94,7 @@ xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc)
  663.                                 return (TRUE);
  664.                         *addrp = target = mem_alloc(nodesize);
  665.                         if (target == NULL) {
  666. -                               //warnx("xdr_array: out of memory");
  667. +                               warnx("xdr_array: out of memory");
  668.                                 return (FALSE);
  669.                         }
  670.                         memset(target, 0, nodesize);
  671. diff --git a/libtirpc/src/xdr_rec.c b/libtirpc/src/xdr_rec.c
  672. index 567f574..26afb48 100644
  673. --- a/libtirpc/src/xdr_rec.c
  674. +++ b/libtirpc/src/xdr_rec.c
  675. @@ -189,7 +189,7 @@ xdrrec_create(xdrs, sendsize, recvsize, tcp_handle, readit, writeit)
  676.         RECSTREAM *rstrm = mem_alloc(sizeof(RECSTREAM));
  677.  
  678.         if (rstrm == NULL) {
  679. -               //warnx("xdrrec_create: out of memory");
  680. +               warnx("xdrrec_create: out of memory");
  681.                 /*
  682.                  *  This is bad.  Should rework xdrrec_create to
  683.                  *  return a handle, and in this case return NULL
  684. @@ -199,14 +199,14 @@ xdrrec_create(xdrs, sendsize, recvsize, tcp_handle, readit, writeit)
  685.         rstrm->sendsize = sendsize = fix_buf_size(sendsize);
  686.         rstrm->out_base = mem_alloc(rstrm->sendsize);
  687.         if (rstrm->out_base == NULL) {
  688. -               //warnx("xdrrec_create: out of memory");
  689. +               warnx("xdrrec_create: out of memory");
  690.                 mem_free(rstrm, sizeof(RECSTREAM));
  691.                 return;
  692.         }
  693.         rstrm->recvsize = recvsize = fix_buf_size(recvsize);
  694.         rstrm->in_base = mem_alloc(recvsize);
  695.         if (rstrm->in_base == NULL) {
  696. -               //warnx("xdrrec_create: out of memory");
  697. +               warnx("xdrrec_create: out of memory");
  698.                 mem_free(rstrm->out_base, sendsize);
  699.                 mem_free(rstrm, sizeof(RECSTREAM));
  700.                 return;
  701. diff --git a/libtirpc/src/xdr_reference.c b/libtirpc/src/xdr_reference.c
  702. index 875cffb..cb43cba 100644
  703. --- a/libtirpc/src/xdr_reference.c
  704. +++ b/libtirpc/src/xdr_reference.c
  705. @@ -76,7 +76,7 @@ xdr_reference(xdrs, pp, size, proc)
  706.                 case XDR_DECODE:
  707.                         *pp = loc = (caddr_t) mem_alloc(size);
  708.                         if (loc == NULL) {
  709. -                               //warnx("xdr_reference: out of memory");
  710. +                               warnx("xdr_reference: out of memory");
  711.                                 return (FALSE);
  712.                         }
  713.                         memset(loc, 0, size);
  714. diff --git a/libtirpc/tirpc/wintirpc.h b/libtirpc/tirpc/wintirpc.h
  715. index d33ce74..ff2fda2 100644
  716. --- a/libtirpc/tirpc/wintirpc.h
  717. +++ b/libtirpc/tirpc/wintirpc.h
  718. @@ -107,6 +107,7 @@ int wintirpc_listen(int in_s, int backlog);
  719.  int wintirpc_accept(int s_fd, struct sockaddr *addr, int *addrlen);
  720.  int wintirpc_send(int s, const char *buf, int len, int flags);
  721.  int wintirpc_sendto(int s, const char *buf, int len, int flags, const struct sockaddr *to, int tolen);
  722. +void wintirpc_warnx(const char *format, ...);
  723.  void wintirpc_register_osfhandle_fd(SOCKET handle, int fd);
  724.  void wintirpc_unregister_osfhandle(SOCKET handle);
  725.  int wintirpc_handle2fd(SOCKET handle);
  726. @@ -114,4 +115,13 @@ int wintirpc_handle2fd(SOCKET handle);
  727.  /* Debugging function */
  728.  void wintirpc_debug(char *fmt, ...);
  729.  
  730. +/* Asserts */
  731. +#define assert(exp) \
  732. +    if (!(exp)) { \
  733. +        wintirpc_warnx("ASSERTION '%s' in '%s'/%ld failed.\n", \
  734. +            ""#exp"", __FILE__, (long)__LINE__); }
  735. +
  736. +/* Mappings Windows API to |wintirpc_*()|-API */
  737. +#define warnx wintirpc_warnx
  738. +
  739.  #endif /* !_TIRPC_WINTIRPC_H */
  740. --
  741. 2.42.0
  742.  
  743. From 7760f2ddb03fc87023109dba91c70aa3587f95a9 Mon Sep 17 00:00:00 2001
  744. From: Roland Mainz <roland.mainz@nrubsig.org>
  745. Date: Wed, 1 Nov 2023 13:48:57 +0100
  746. Subject: [PATCH 3/9] nfs_daemon should not call |assert()|
  747.  
  748. nfs_daemon should not call the fatal |assert()| function, we added
  749. |EASSERT()| (error asserts) and |DASSERT()| (debug assert) as
  750. non-fatal assertions to "daemon_debug.h" a while ago for such
  751. a purpose.
  752.  
  753. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  754. ---
  755. daemon/name_cache.c | 3 +--
  756.  1 file changed, 1 insertion(+), 2 deletions(-)
  757.  
  758. diff --git a/daemon/name_cache.c b/daemon/name_cache.c
  759. index 3f944fd..39168f4 100644
  760. --- a/daemon/name_cache.c
  761. +++ b/daemon/name_cache.c
  762. @@ -22,7 +22,6 @@
  763.  #include <Windows.h>
  764.  #include <strsafe.h>
  765.  #include <time.h>
  766. -#include <assert.h>
  767.  
  768.  #include "nfs41_ops.h"
  769.  #include "nfs41_compound.h"
  770. @@ -1068,7 +1067,7 @@ int nfs41_name_cache_delegreturn(
  771.      if (attributes->delegated) {
  772.          attributes->delegated = FALSE;
  773.          attr_cache_entry_deref(&cache->attributes, attributes);
  774. -        assert(cache->delegations > 0);
  775. +        EASSERT(cache->delegations > 0);
  776.          cache->delegations--;
  777.      }
  778.      status = NO_ERROR;
  779. --
  780. 2.42.0
  781.  
  782. From 981d8d3151214c2de1372855278b81fac23d79f9 Mon Sep 17 00:00:00 2001
  783. From: Roland Mainz <roland.mainz@nrubsig.org>
  784. Date: Wed, 1 Nov 2023 14:32:28 +0100
  785. Subject: [PATCH 4/9] nfs_daemon: Fix name cache issues with Cygwin |stat()|
  786.  uid/gid
  787.  
  788. nfs_daemon: Fix name cache issues with Cygwin |stat()| uid/gid
  789. vs. NFSv4 owner/owner_group
  790.  
  791. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  792. ---
  793. daemon/name_cache.c | 31 +++++++++++++++++++++++--------
  794.  daemon/nfs41_xdr.c  |  2 ++
  795.  daemon/open.c       | 44 +++++++++++++++++++++++++++++++++++++++++---
  796.  daemon/util.c       |  6 ++++--
  797.  4 files changed, 70 insertions(+), 13 deletions(-)
  798.  
  799. diff --git a/daemon/name_cache.c b/daemon/name_cache.c
  800. index 39168f4..8da2fff 100644
  801. --- a/daemon/name_cache.c
  802. +++ b/daemon/name_cache.c
  803. @@ -350,12 +350,24 @@ static void copy_attrs(
  804.      dst->type = src->type;
  805.      dst->numlinks = src->numlinks;
  806.      dst->mode = src->mode;
  807. -    EASSERT(src->owner != NULL);
  808. -    dst->owner = dst->owner_buf;
  809. -    (void)strcpy(dst->owner, src->owner);
  810. -    EASSERT(src->owner_group != NULL);
  811. -    dst->owner_group = dst->owner_group_buf;
  812. -    (void)strcpy(dst->owner_group, src->owner_group);
  813. +    EASSERT(src->owner[0] != '\0');
  814. +    if (src->owner[0] != '\0') {
  815. +        dst->owner = dst->owner_buf;
  816. +        (void)strcpy(dst->owner, src->owner);
  817. +    }
  818. +    else {
  819. +        /* this should only happen for newly created files/dirs */
  820. +        dst->owner = NULL;
  821. +    }
  822. +    EASSERT(src->owner_group[0] != '\0');
  823. +    if (src->owner_group[0] != '\0') {
  824. +        dst->owner_group = dst->owner_group_buf;
  825. +        (void)strcpy(dst->owner_group, src->owner_group);
  826. +    }
  827. +    else {
  828. +        /* this should only happen for newly created files/dirs */
  829. +        dst->owner_group = NULL;
  830. +    }
  831.      dst->fileid = src->fileid;
  832.      dst->hidden = src->hidden;
  833.      dst->system = src->system;
  834. @@ -368,8 +380,11 @@ static void copy_attrs(
  835.      dst->attrmask.arr[1] = FATTR4_WORD1_MODE
  836.          | FATTR4_WORD1_NUMLINKS | FATTR4_WORD1_TIME_ACCESS
  837.          | FATTR4_WORD1_TIME_CREATE | FATTR4_WORD1_TIME_MODIFY
  838. -        | FATTR4_WORD1_SYSTEM
  839. -        | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
  840. +        | FATTR4_WORD1_SYSTEM;
  841. +    if (dst->owner)
  842. +        dst->attrmask.arr[1] |= FATTR4_WORD1_OWNER;
  843. +    if (dst->owner_group)
  844. +        dst->attrmask.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
  845.  }
  846.  
  847.  
  848. diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
  849. index 9bde0f0..245bbff 100644
  850. --- a/daemon/nfs41_xdr.c
  851. +++ b/daemon/nfs41_xdr.c
  852. @@ -1815,6 +1815,7 @@ static bool_t decode_file_attrs(
  853.              EASSERT(owner_len > 0);
  854.              EASSERT(owner_len < sizeof(info->owner_group_buf));
  855.              info->owner[owner_len] = '\0';
  856. +            EASSERT(info->owner[0] != '\0');
  857.          }
  858.          if (attrs->attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) {
  859.              if (info->owner_group == NULL)
  860. @@ -1830,6 +1831,7 @@ static bool_t decode_file_attrs(
  861.              EASSERT(owner_group_len > 0);
  862.              EASSERT(owner_group_len < sizeof(info->owner_group_buf));
  863.              info->owner_group[owner_group_len] = '\0';
  864. +            EASSERT(info->owner_group[0] != '\0');
  865.          }
  866.          if (attrs->attrmask.arr[1] & FATTR4_WORD1_SPACE_AVAIL) {
  867.              if (!xdr_u_hyper(xdr, &info->space_avail))
  868. diff --git a/daemon/open.c b/daemon/open.c
  869. index a9ffcb0..3071041 100644
  870. --- a/daemon/open.c
  871. +++ b/daemon/open.c
  872. @@ -669,12 +669,47 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  873.          gid_t map_gid = -1;
  874.          char *at_ch; /* pointer to '@' */
  875.  
  876. +#if 1
  877. +        /* this should only happen for newly created files/dirs */
  878. +        if (((info.attrmask.arr[1] & FATTR4_WORD1_OWNER) == 0) ||
  879. +            ((info.attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) == 0)) {
  880. +            bitmap4 og_attr_request = { 0 };
  881. +            nfs41_file_info og_info = { 0 };
  882. +            nfsacl41 acl = { 0 };
  883. +
  884. +            og_attr_request.count = 2;
  885. +            og_attr_request.arr[1] =
  886. +                FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
  887. +            og_info.owner = og_info.owner_buf;
  888. +            og_info.owner_group = og_info.owner_group_buf;
  889. +            status = nfs41_getattr(state->session, &state->file,
  890. +                &og_attr_request, &og_info);
  891. +            if (status) {
  892. +                eprintf("get_stat_data: nfs41_getattr('%s') "
  893. +                    "failed with %d\n",
  894. +                    state->path.path,
  895. +                    status);
  896. +                goto out_free_state;
  897. +            }
  898. +
  899. +            info.owner = info.owner_buf;
  900. +            (void)strcpy(info.owner, og_info.owner);
  901. +            info.attrmask.arr[1] |= FATTR4_WORD1_OWNER;
  902. +            info.owner_group = info.owner_group_buf;
  903. +            (void)strcpy(info.owner_group, og_info.owner_group);
  904. +            info.attrmask.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
  905. +        }
  906. +#endif
  907. +
  908.          EASSERT((info.attrmask.arr[1] & FATTR4_WORD1_OWNER) != 0);
  909.          EASSERT((info.attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) != 0);
  910.          EASSERT(info.owner != NULL);
  911.          EASSERT(info.owner_group != NULL);
  912.          EASSERT(info.owner == info.owner_buf);
  913.          EASSERT(info.owner_group == info.owner_group_buf);
  914. +        EASSERT(strlen(info.owner) > 0);
  915. +        EASSERT(strlen(info.owner_group) > 0);
  916. +
  917.          /* Make copies as we will modify  them */
  918.          (void)strcpy(owner, info.owner);
  919.          (void)strcpy(owner_group, info.owner_group);
  920. @@ -698,8 +733,9 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  921.          }
  922.          else {
  923.              args->owner_local_uid = NFS_USER_NOBODY_UID;
  924. -            eprintf("get_stat_data: "
  925. +            eprintf("get_stat_data('%s'): "
  926.                  "no username mapping for '%s', fake uid=%d\n",
  927. +                state->path.path,
  928.                  owner, args->owner_local_uid);
  929.          }
  930.  
  931. @@ -721,12 +757,14 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  932.          }
  933.          else {
  934.              args->owner_group_local_gid = NFS_GROUP_NOGROUP_GID;
  935. -            eprintf("get_stat_data: "
  936. +            eprintf("get_stat_data('%s'): "
  937.                  "no group mapping for '%s', fake gid=%d\n",
  938. +                state->path.path,
  939.                  owner_group, args->owner_group_local_gid);
  940.          }
  941.  
  942. -        dprintf(1, "handle_open: stat: owner=%u/'%s', owner_group=%u/'%s'\n",
  943. +        dprintf(1, "handle_open('%s'): stat: owner=%u/'%s', owner_group=%u/'%s'\n",
  944. +            state->path.path,
  945.              (unsigned int)args->owner_local_uid, owner,
  946.              (unsigned int)args->owner_group_local_gid, owner_group);
  947.  #endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  948. diff --git a/daemon/util.c b/daemon/util.c
  949. index 07aa2c6..ef3ae7d 100644
  950. --- a/daemon/util.c
  951. +++ b/daemon/util.c
  952. @@ -207,8 +207,10 @@ void nfs41_file_info_cpy(
  953.      IN const nfs41_file_info *src)
  954.  {
  955.      (void)memcpy(dest, src, sizeof(nfs41_file_info));
  956. -    dest->owner = dest->owner_buf;
  957. -    dest->owner_group = dest->owner_group_buf;
  958. +    if (src->owner != NULL)
  959. +        dest->owner = dest->owner_buf;
  960. +    if (src->owner_group != NULL)
  961. +        dest->owner_group = dest->owner_group_buf;
  962.  }
  963.  
  964.  void get_file_time(
  965. --
  966. 2.42.0
  967.  
  968. From 83fbd7eea08bd5618672ee5ac038e4e0fbcb5918 Mon Sep 17 00:00:00 2001
  969. From: Roland Mainz <roland.mainz@nrubsig.org>
  970. Date: Wed, 1 Nov 2023 15:08:07 +0100
  971. Subject: [PATCH 5/9] msnfs41client.bash: Add support to follow the kernel
  972.  debug log
  973.  
  974. Add support to follow the kernel debug log via tail -f to
  975. msnfs41client.bash.
  976.  
  977. Requires DebugView from
  978. https://learn.microsoft.com/en-gb/sysinternals/downloads/debugview
  979.  
  980. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  981. ---
  982. cygwin/devel/msnfs41client.bash | 38 +++++++++++++++++++++++++++++++++
  983.  1 file changed, 38 insertions(+)
  984.  
  985. diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
  986. index da91627..23ca032 100644
  987. --- a/cygwin/devel/msnfs41client.bash
  988. +++ b/cygwin/devel/msnfs41client.bash
  989. @@ -72,9 +72,18 @@ function nfsclient_install
  990.         cp etc_netconfig /cygdrive/c/etc/netconfig
  991.         cp ms-nfs41-idmap.conf /cygdrive/c/etc/.
  992.  
  993. +       # make sure we can load the kernel driver
  994. +       # (does not work with SecureBoot)
  995.         bcdedit /set testsigning on
  996. +
  997. +       # enable local kernel debugging
  998. +       bcdedit /debug on
  999. +       bcdedit /dbgsettings local
  1000. +
  1001. +       # set domain name
  1002.         regtool -s set '/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters/Domain' 'GLOBAL.LOC'
  1003.  
  1004. +       # disable DFS
  1005.         sc query Dfsc
  1006.         sc stop Dfsc || true
  1007.         sc config Dfsc start=disabled
  1008. @@ -132,6 +141,23 @@ function nfsclient_system_rundeamon
  1009.         return $?
  1010.  }
  1011.  
  1012. +function watch_kernel_debuglog
  1013. +{
  1014. +       printf "# logging start...\n" 1>&2
  1015. +       # seperate process so SIGINT works
  1016. +       # use DebugView (https://learn.microsoft.com/en-gb/sysinternals/downloads/debugview) to print kernel log
  1017. +       bash -c '
  1018. +               klogname="msnfs41client_watch_kernel_debuglog$$.log"
  1019. +               dbgview64 /t /k /l "$klogname" &
  1020. +               (( dbgview_pid=$! ))
  1021. +               trap "(( dbgview_pid != 0)) && kill $dbgview_pid && wait ; (( dbgview_pid=0 ))" INT TERM EXIT
  1022. +               sleep 2
  1023. +               printf "# logging %s ...\n" "$klogname" 1>&2
  1024. +               tail -n0 -f "$klogname"'
  1025. +       printf "# logging done\n" 1>&2
  1026. +       return 0
  1027. +}
  1028. +
  1029.  function nfsclient_mount_homedir
  1030.  {
  1031.         set -o xtrace
  1032. @@ -239,6 +265,9 @@ function main
  1033.         # my own path to pstools
  1034.         PATH+=':/home/roland_mainz/work/win_pstools/'
  1035.  
  1036. +       # my own path to DebugView
  1037. +       PATH+=':/cygdrive/c/Users/roland_mainz/download/DebugView'
  1038. +
  1039.         case "$cmd" in
  1040.                 'install')
  1041.                         nfsclient_install
  1042. @@ -285,6 +314,15 @@ function main
  1043.                         return $?
  1044.                         ;;
  1045.                 # misc
  1046. +               'watch_kernel_debuglog')
  1047. +                       require_cmd 'dbgview64' || return 1
  1048. +                       if ! is_windows_admin_account ; then
  1049. +                               printf $"%s: %q requires Windows Adminstator permissions.\n" "$0" "$cmd"
  1050. +                               return 1
  1051. +                       fi
  1052. +                       watch_kernel_debuglog
  1053. +                       return $?
  1054. +                       ;;
  1055.                 'sys_terminal')
  1056.                         require_cmd 'mintty.exe' || return 1
  1057.                         if ! is_windows_admin_account ; then
  1058. --
  1059. 2.42.0
  1060.  
  1061. From 9acd0c968d522f2f940746a28d0f4be556e61d37 Mon Sep 17 00:00:00 2001
  1062. From: Roland Mainz <roland.mainz@nrubsig.org>
  1063. Date: Sun, 5 Nov 2023 17:54:52 +0100
  1064. Subject: [PATCH 6/9] sys/nfs41_driver: Fix "IOCTL_NFS41_WRITE failed with 31
  1065.  xid=... opcode=..."
  1066.  
  1067. Fix issues with |KeWaitForSingleObject()| getting interrupted. As
  1068. consequence the matching request was abandoned, and nfsd_debug printed
  1069. "IOCTL_NFS41_WRITE failed with 31 xid=... opcode=...", typically for
  1070. NFS41_FILE_QUERY.
  1071.  
  1072. Instead we now just retry the |KeWaitForSingleObject()|.
  1073.  
  1074. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  1075. ---
  1076. sys/nfs41_driver.c | 9 ++++++++-
  1077.  1 file changed, 8 insertions(+), 1 deletion(-)
  1078.  
  1079. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  1080. index 0368732..8c91c5a 100644
  1081. --- a/sys/nfs41_driver.c
  1082. +++ b/sys/nfs41_driver.c
  1083. @@ -1484,6 +1484,7 @@ NTSTATUS nfs41_UpcallWaitForReply(
  1084.          /* 02/15/2011 cbodley: added NFS41_UNLOCK for the same reason. locking
  1085.           * tests were triggering an interrupted unlock, which led to a bugcheck
  1086.           * in CloseSrvOpen() */
  1087. +retry_wait:
  1088.  #define MAKE_WAITONCLOSE_NONITERRUPTABLE
  1089.  #ifdef MAKE_WAITONCLOSE_NONITERRUPTABLE
  1090.          if (entry->opcode == NFS41_CLOSE || entry->opcode == NFS41_UNLOCK)
  1091. @@ -1509,9 +1510,15 @@ NTSTATUS nfs41_UpcallWaitForReply(
  1092.          goto out;
  1093.  
  1094.      switch(status) {
  1095. -    case STATUS_SUCCESS: break;
  1096.      case STATUS_USER_APC:
  1097.      case STATUS_ALERTED:
  1098. +        DbgP("nfs41_UpcallWaitForReply: KeWaitForSingleObject() "
  1099. +            "returned status(=%ld), "
  1100. +            "retry waiting for '%s' entry=%p xid=%lld\n",
  1101. +            (long)status,
  1102. +            opcode2string(entry->opcode), entry, entry->xid);
  1103. +        goto retry_wait;
  1104. +    case STATUS_SUCCESS: break;
  1105.      default:
  1106.          ExAcquireFastMutex(&entry->lock);
  1107.          if (entry->state == NFS41_DONE_PROCESSING) {
  1108. --
  1109. 2.42.0
  1110.  
  1111. From 99b655781f20ca29ee6fa4ad0ae2a729fbdec345 Mon Sep 17 00:00:00 2001
  1112. From: Roland Mainz <roland.mainz@nrubsig.org>
  1113. Date: Sun, 5 Nov 2023 18:10:27 +0100
  1114. Subject: [PATCH 7/9] sys/nfs41_driver: Fix header length
  1115.  |marshal_nfs41_filequery()|
  1116.  
  1117. Fix header length used by |marshal_nfs41_filequery()|, it was
  1118. missing the two HANDLE objects.
  1119.  
  1120. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  1121. ---
  1122. sys/nfs41_driver.c | 2 +-
  1123.  1 file changed, 1 insertion(+), 1 deletion(-)
  1124.  
  1125. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  1126. index 8c91c5a..6fc1351 100644
  1127. --- a/sys/nfs41_driver.c
  1128. +++ b/sys/nfs41_driver.c
  1129. @@ -1008,7 +1008,7 @@ NTSTATUS marshal_nfs41_filequery(
  1130.      if (status) goto out;
  1131.      else tmp += *len;
  1132.  
  1133. -    header_len = *len + 2 * sizeof(ULONG);
  1134. +    header_len = *len + 2 * sizeof(ULONG) + 2*sizeof(HANDLE);
  1135.      if (header_len > buf_len) {
  1136.          status = STATUS_INSUFFICIENT_RESOURCES;
  1137.          goto out;
  1138. --
  1139. 2.42.0
  1140.  
  1141. From faa3d8c9c274a211929b9f02f60186d58d806faa Mon Sep 17 00:00:00 2001
  1142. From: Roland Mainz <roland.mainz@nrubsig.org>
  1143. Date: Sun, 5 Nov 2023 18:16:35 +0100
  1144. Subject: [PATCH 8/9] sys/nfs41_driver: More debug code for NFS41_FILE_QUERY
  1145.  failure codepaths
  1146.  
  1147. Add more debug output in NFS41_FILE_QUERY failure codepaths.
  1148.  
  1149. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  1150. ---
  1151. sys/nfs41_driver.c | 33 ++++++++++++++++++++++++++++++---
  1152.  1 file changed, 30 insertions(+), 3 deletions(-)
  1153.  
  1154. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  1155. index 6fc1351..3900cec 100644
  1156. --- a/sys/nfs41_driver.c
  1157. +++ b/sys/nfs41_driver.c
  1158. @@ -5285,9 +5285,24 @@ NTSTATUS nfs41_QueryFileInformation(
  1159.      DbgEn();
  1160.      print_debug_filedirquery_header(RxContext);
  1161.  #endif
  1162. +    DbgP("--> nfs41_QueryFileInformation, RxContext->Info.LengthRemaining=%ld, "
  1163. +        "RxContext->LowIoContext.ParamsFor.IoCtl.InputBufferLength=%ld\n",
  1164. +        (long)RxContext->Info.LengthRemaining,
  1165. +        (long)RxContext->LowIoContext.ParamsFor.IoCtl.InputBufferLength);
  1166.  
  1167.      status = check_nfs41_dirquery_args(RxContext);
  1168. -    if (status) goto out;
  1169. +    if (status) {
  1170. +        print_error("check_nfs41_dirquery_args failed.\n");
  1171. +        goto out;
  1172. +    }
  1173. +
  1174. +    RtlZeroMemory(RxContext->Info.Buffer, RxContext->Info.LengthRemaining);
  1175. +
  1176. +    DbgP("nfs41_QueryFileInformation, RxContext->Info.LengthRemaining=%ld, "
  1177. +        "RxContext->LowIoContext.ParamsFor.IoCtl.{InputBufferLength=%ld,OutputBufferLength=%ld}\n",
  1178. +        (long)RxContext->Info.LengthRemaining,
  1179. +        (long)RxContext->LowIoContext.ParamsFor.IoCtl.InputBufferLength,
  1180. +        (long)RxContext->LowIoContext.ParamsFor.IoCtl.OutputBufferLength);
  1181.  
  1182.      switch (InfoClass) {
  1183.      case FileEaInformation:
  1184. @@ -5314,19 +5329,27 @@ NTSTATUS nfs41_QueryFileInformation(
  1185.      status = nfs41_UpcallCreate(NFS41_FILE_QUERY, &nfs41_fobx->sec_ctx,
  1186.          pVNetRootContext->session, nfs41_fobx->nfs41_open_state,
  1187.          pNetRootContext->nfs41d_version, SrvOpen->pAlreadyPrefixedName, &entry);
  1188. -    if (status) goto out;
  1189. +    if (status) {
  1190. +        print_error("nfs41_UpcallCreate() failed, status=%d\n", status);
  1191. +        goto out;
  1192. +    }
  1193.  
  1194.      entry->u.QueryFile.InfoClass = InfoClass;
  1195.      entry->buf = RxContext->Info.Buffer;
  1196.      entry->buf_len = RxContext->Info.LengthRemaining;
  1197.  
  1198.      status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
  1199. -    if (status) goto out;
  1200. +    if (status) {
  1201. +        print_error("nfs41_UpcallWaitForReply() failed, status=%d\n", status);
  1202. +        goto out;
  1203. +    }
  1204.  
  1205.      if (entry->status == STATUS_BUFFER_TOO_SMALL) {
  1206.          RxContext->InformationToReturn = entry->buf_len;
  1207. +        print_error("entry->status == STATUS_BUFFER_TOO_SMALL\n");
  1208.          status = STATUS_BUFFER_TOO_SMALL;
  1209.      } else if (entry->status == STATUS_SUCCESS) {
  1210. +        print_error("entry->status == STATUS_SUCCESS\n");
  1211.          BOOLEAN DeletePending = FALSE;
  1212.  #ifdef ENABLE_TIMINGS
  1213.          InterlockedIncrement(&getattr.sops);
  1214. @@ -5382,9 +5405,12 @@ NTSTATUS nfs41_QueryFileInformation(
  1215.              print_std_info(1, &nfs41_fcb->StandardInfo);
  1216.  #endif
  1217.              break;
  1218. +        default:
  1219. +            print_error("Unhandled/unsupported InfoClass(%d)\n", (int)InfoClass);
  1220.          }
  1221.      } else {
  1222.          status = map_queryfile_error(entry->status);
  1223. +        print_error("status(0x%lx) = map_queryfile_error(entry->status(0x%lx));\n", (long)status, (long)entry->status);
  1224.      }
  1225.      RxFreePool(entry);
  1226.  out:
  1227. @@ -5400,6 +5426,7 @@ out:
  1228.  #ifdef DEBUG_FILE_QUERY
  1229.      DbgEx();
  1230.  #endif
  1231. +    DbgP("<-- nfs41_QueryFileInformation, status=0x%lx\n", (long)status);
  1232.      return status;
  1233.  }
  1234.  
  1235. --
  1236. 2.42.0
  1237.  
  1238. From 97c9d90a241489de885c351cb4a5271044a33191 Mon Sep 17 00:00:00 2001
  1239. From: Roland Mainz <roland.mainz@nrubsig.org>
  1240. Date: Sun, 5 Nov 2023 18:29:46 +0100
  1241. Subject: [PATCH 9/9] sys/nfs41_driver: Allocate NFS41_SERVER_ENTRY from
  1242.  NonPagedPool
  1243.  
  1244. Allocate NFS41_SERVER_ENTRY from NonPagedPool, as mixing PagedPool
  1245. and NonPagedPool with the same pool tag is not recommended, and in
  1246. this case it makes more sense to allocate it from NonPagedPool as
  1247. the data are critical for the driver.
  1248.  
  1249. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  1250. ---
  1251. sys/nfs41_driver.c | 2 +-
  1252.  1 file changed, 1 insertion(+), 1 deletion(-)
  1253.  
  1254. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  1255. index 3900cec..55d7425 100644
  1256. --- a/sys/nfs41_driver.c
  1257. +++ b/sys/nfs41_driver.c
  1258. @@ -2509,7 +2509,7 @@ NTSTATUS _nfs41_CreateSrvCall(
  1259.      }
  1260.  
  1261.      /* Let's create our own representation of the server */
  1262. -    pServerEntry = (PNFS41_SERVER_ENTRY)RxAllocatePoolWithTag(PagedPool,
  1263. +    pServerEntry = (PNFS41_SERVER_ENTRY)RxAllocatePoolWithTag(NonPagedPool,
  1264.          sizeof(NFS41_SERVER_ENTRY), NFS41_MM_POOLTAG);
  1265.      if (pServerEntry == NULL) {
  1266.          status = STATUS_INSUFFICIENT_RESOURCES;
  1267. --
  1268. 2.42.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