pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for better idmapper debug output+idmapper ksh93 functional test, 2024-09-17
Posted by Anonymous on Tue 17th Sep 2024 16:35
raw | new post

  1. From e53d97e9bf5e78f91ac9d378b0e3eaa478eb6415 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Tue, 17 Sep 2024 13:17:04 +0200
  4. Subject: [PATCH 1/2] daemon: Improve debugging/error messages in Cygwin
  5.  idmapper
  6.  
  7. Improve debugging/error messages in Cygwin idmapper.
  8.  
  9. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  10. ---
  11. daemon/idmap_cygwin.c | 72 +++++++++++++++++++++++++++++++++----------
  12.  1 file changed, 55 insertions(+), 17 deletions(-)
  13.  
  14. diff --git a/daemon/idmap_cygwin.c b/daemon/idmap_cygwin.c
  15. index 3d4a1be..ec60142 100644
  16. --- a/daemon/idmap_cygwin.c
  17. +++ b/daemon/idmap_cygwin.c
  18. @@ -1,5 +1,5 @@
  19.  /* NFSv4.1 client for Windows
  20. - * Copyright X 2023 Roland Mainz <roland.mainz@nrubsig.org>
  21. + * Copyright (C) 2023-2024 Roland Mainz <roland.mainz@nrubsig.org>
  22.   *
  23.   * Roland Mainz <roland.mainz@nrubsig.org>
  24.   *
  25. @@ -65,7 +65,9 @@ int cygwin_getent_passwd(const char *name, char *res_loginname, uid_t *res_uid,
  26.      cpv_name_val *cnv_cur = NULL;
  27.      const char *localaccoutname = NULL;
  28.  
  29. -    DPRINTF(CYGWINIDLVL, ("--> cygwin_getent_passwd('%s')\n", name));
  30. +    DPRINTF(CYGWINIDLVL,
  31. +        ("--> cygwin_getent_passwd(name='%s')\n",
  32. +        name));
  33.  
  34.      /* fixme: better quoting for |name| needed */
  35.      (void)snprintf(cmdbuff, sizeof(cmdbuff),
  36. @@ -74,7 +76,10 @@ int cygwin_getent_passwd(const char *name, char *res_loginname, uid_t *res_uid,
  37.          name);
  38.      if ((script_pipe = subcmd_popen(cmdbuff)) == NULL) {
  39.          int last_error = GetLastError();
  40. -        DPRINTF(0, ("cygwin_getent_passwd: '%s' failed, GetLastError()='%d'\n",
  41. +        DPRINTF(0,
  42. +            ("cygwin_getent_passwd(name='%s'): "
  43. +            "'%s' failed, GetLastError()='%d'\n",
  44. +            name,
  45.              cmdbuff,
  46.              last_error));
  47.          goto fail;
  48. @@ -82,25 +87,37 @@ int cygwin_getent_passwd(const char *name, char *res_loginname, uid_t *res_uid,
  49.  
  50.      if (!subcmd_readcmdoutput(script_pipe,
  51.          buff, sizeof(buff), &num_buff_read)) {
  52. -        DPRINTF(0, ("cygwin_getent_passwd: subcmd_readcmdoutput() failed\n"));
  53. +        DPRINTF(0,
  54. +            ("cygwin_getent_passwd(name='%s'): "
  55. +            "subcmd_readcmdoutput() failed\n",
  56. +            name));
  57.          goto fail;
  58.      }
  59.  
  60.      buff[num_buff_read] = '\0';
  61.  
  62.      if (num_buff_read < 10) {
  63. -        DPRINTF(0, ("cygwin_getent_passwd: Could not read enough data, returned %d\n", (int)num_buff_read));
  64. +        DPRINTF(0,
  65. +            ("cygwin_getent_passwd(name='%s'): "
  66. +            "Could not read enough data, returned %d\n",
  67. +            name, (int)num_buff_read));
  68.          goto fail;
  69.      }
  70.  
  71.      cpvp = cpv_create_parser(buff, 0/*CPVFLAG_DEBUG_OUTPUT*/);
  72.      if (!cpvp) {
  73. -        DPRINTF(0, ("cygwin_getent_passwd: Could not create parser\n"));
  74. +        DPRINTF(0,
  75. +            ("cygwin_getent_passwd(name='%s'): "
  76. +            "Could not create parser\n",
  77. +            name));
  78.          goto fail;
  79.      }
  80.  
  81.      if (cpv_read_cpv_header(cpvp)) {
  82. -        DPRINTF(0, ("cygwin_getent_passwd: cpv_read_cpv_header failed\n"));
  83. +        DPRINTF(0,
  84. +            ("cygwin_getent_passwd(name='%s'): "
  85. +            "cpv_read_cpv_header failed\n",
  86. +            name));
  87.          goto fail;
  88.      }
  89.  
  90. @@ -149,7 +166,8 @@ fail:
  91.      cpv_free_parser(cpvp);
  92.  
  93.      if (res == 0) {
  94. -        DPRINTF(CYGWINIDLVL, ("<-- cygwin_getent_passwd('%s'): "
  95. +        DPRINTF(CYGWINIDLVL,
  96. +            ("<-- cygwin_getent_passwd(name='%s'): "
  97.              "returning res_uid=%u, res_gid=%u, res_loginname='%s'\n",
  98.              name,
  99.              (unsigned int)(*res_uid),
  100. @@ -157,7 +175,8 @@ fail:
  101.              res_loginname?res_loginname:"<NULL>"));
  102.      }
  103.      else {
  104. -        DPRINTF(CYGWINIDLVL, ("<-- cygwin_getent_passwd('%s'): no match found\n",
  105. +        DPRINTF(CYGWINIDLVL,
  106. +            ("<-- cygwin_getent_passwd(name='%s'): no match found\n",
  107.              name));
  108.      }
  109.  
  110. @@ -180,7 +199,9 @@ int cygwin_getent_group(const char* name, char* res_group_name, gid_t* res_gid)
  111.  
  112.      const char *localgroupname = NULL;
  113.  
  114. -    DPRINTF(CYGWINIDLVL, ("--> cygwin_getent_group('%s')\n", name));
  115. +    DPRINTF(CYGWINIDLVL,
  116. +        ("--> cygwin_getent_group(name='%s')\n",
  117. +        name));
  118.  
  119.      /* fixme: better quoting for |name| needed */
  120.      (void)snprintf(cmdbuff, sizeof(cmdbuff),
  121. @@ -189,7 +210,10 @@ int cygwin_getent_group(const char* name, char* res_group_name, gid_t* res_gid)
  122.          name);
  123.      if ((script_pipe = subcmd_popen(cmdbuff)) == NULL) {
  124.          int last_error = GetLastError();
  125. -        DPRINTF(0, ("cygwin_getent_group: '%s' failed, GetLastError()='%d'\n",
  126. +        DPRINTF(0,
  127. +            ("cygwin_getent_group(name='%s'): "
  128. +            "'%s' failed, GetLastError()='%d'\n",
  129. +            name,
  130.              cmdbuff,
  131.              last_error));
  132.          goto fail;
  133. @@ -197,25 +221,37 @@ int cygwin_getent_group(const char* name, char* res_group_name, gid_t* res_gid)
  134.  
  135.      if (!subcmd_readcmdoutput(script_pipe,
  136.          buff, sizeof(buff), &num_buff_read)) {
  137. -        DPRINTF(0, ("cygwin_getent_group: subcmd_readcmdoutput() failed\n"));
  138. +        DPRINTF(0,
  139. +            ("cygwin_getent_group(name='%s'): "
  140. +            "subcmd_readcmdoutput() failed\n",
  141. +            name));
  142.          goto fail;
  143.      }
  144.  
  145.      buff[num_buff_read] = '\0';
  146.  
  147.      if (num_buff_read < 10) {
  148. -        DPRINTF(0, ("cygwin_getent_group: Could not read enough data, returned %d\n", (int)num_buff_read));
  149. +        DPRINTF(0,
  150. +            ("cygwin_getent_group(name='%s'): "
  151. +            "Could not read enough data, returned %d\n",
  152. +            name, (int)num_buff_read));
  153.          goto fail;
  154.      }
  155.  
  156.      cpvp = cpv_create_parser(buff, 0/*CPVFLAG_DEBUG_OUTPUT*/);
  157.      if (!cpvp) {
  158. -        DPRINTF(0, ("cygwin_getent_group: Could not create parser\n"));
  159. +        DPRINTF(0,
  160. +            ("cygwin_getent_group(name='%s'): "
  161. +            "Could not create parser\n",
  162. +            name));
  163.          goto fail;
  164.      }
  165.  
  166.      if (cpv_read_cpv_header(cpvp)) {
  167. -        DPRINTF(0, ("cygwin_getent_group: cpv_read_cpv_header failed\n"));
  168. +        DPRINTF(0,
  169. +            ("cygwin_getent_group(name='%s'): "
  170. +            "cpv_read_cpv_header failed\n",
  171. +            name));
  172.          goto fail;
  173.      }
  174.  
  175. @@ -257,14 +293,16 @@ fail:
  176.      cpv_free_parser(cpvp);
  177.  
  178.      if (res == 0) {
  179. -        DPRINTF(CYGWINIDLVL, ("<-- cygwin_getent_group('%s'): "
  180. +        DPRINTF(CYGWINIDLVL,
  181. +            ("<-- cygwin_getent_group(name='%s'): "
  182.              "returning res_gid=%u, res_group_name='%s'\n",
  183.              name,
  184.              (unsigned int)(*res_gid),
  185.              res_group_name?res_group_name:"<NULL>"));
  186.      }
  187.      else {
  188. -        DPRINTF(CYGWINIDLVL, ("<-- cygwin_getent_group('%s'): no match found\n",
  189. +        DPRINTF(CYGWINIDLVL,
  190. +            ("<-- cygwin_getent_group(name='%s'): no match found\n",
  191.              name));
  192.      }
  193.  
  194. --
  195. 2.45.1
  196.  
  197. From aa934fe5f965d1c797a6a8d08d79947d8fe22b48 Mon Sep 17 00:00:00 2001
  198. From: Roland Mainz <roland.mainz@nrubsig.org>
  199. Date: Tue, 17 Sep 2024 13:49:44 +0200
  200. Subject: [PATCH 2/2] cygwin: msnfs41client.bash install subcmd should test if
  201.  ksh93 is working
  202.  
  203. msnfs41client.bash install subcmd should test if /usr/bin/ksh93 is
  204. working, as ksh93 is used by the Cygwin idmapper code to run a ksh93
  205. script to do the idmapping.
  206.  
  207. This is needed because ksh93 build with Cygwin 3.6 does not work
  208. on Cygwin 3.5.4, as reported in
  209. https://sourceforge.net/p/ms-nfs41-client/mailman/message/58817841/
  210.  
  211. Reported-by: Mark Liam Brown <brownmarkliam@gmail.com>
  212. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  213. ---
  214. cygwin/devel/msnfs41client.bash | 24 ++++++++++++++++++++++++
  215.  1 file changed, 24 insertions(+)
  216.  
  217. diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
  218. index dca774f..50efb21 100755
  219. --- a/cygwin/devel/msnfs41client.bash
  220. +++ b/cygwin/devel/msnfs41client.bash
  221. @@ -185,6 +185,30 @@ function nfsclient_install
  222.         # query new 'ms-nfs41-client-service'
  223.         sc query 'ms-nfs41-client-service'
  224.  
  225. +       #
  226. +       # check whether ksh93 works
  227. +       # (The ms-nfs41-client cygwin idmapper uses ksh93 scripts for
  228. +       # idmapping, and if ksh93 does not work properly nfsd*.exe
  229. +       # will not work)
  230. +       #
  231. +       set +o xtrace
  232. +       typeset cmdout
  233. +       cmdout="$( \
  234. +               { \
  235. +                       /usr/bin/ksh93 -c \
  236. +                               'compound c=(typeset -a ar); c.ar=("hello"); c.ar+=("world"); printf "%s" "${c.ar[*]}"' ; \
  237. +                       echo $? ; } 2>&1 \
  238. +               )"
  239. +
  240. +       if [[ "${cmdout}" != $'hello world0' ]] ; then
  241. +               printf $"ERROR: /usr/bin/ksh93 does not work, expected test output |%q|, got |%q|\n" \
  242. +                       $'hello world0' \
  243. +                       "$cmdout"
  244. +               return 1
  245. +       fi
  246. +       printf '/usr/bin/ksh93 is working\n'
  247. +       set -o xtrace
  248. +
  249.         # check whether the driver really has been installed
  250.         md5sum \
  251.                 "$PWD/nfs41_driver.sys" \
  252. --
  253. 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