pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: timebasedcoherency fixes&workarounds, fix 32bit share enumeration on 64bit kernel, cygwinaccount2nfs4account.ksh update, debug+misc, 2024-08-05
Posted by Anonymous on Mon 5th Aug 2024 17:12
raw | new post

  1. From 3ae3e2c16631af693444764a894a4a6c73cdd036 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Mon, 5 Aug 2024 13:53:04 +0200
  4. Subject: [PATCH 1/6] sys: Fix invalid |cur->nfs41_fobx| pointer crash in
  5.  |fcbopen_main()|
  6.  
  7. Fix invalid |cur->nfs41_fobx| pointer kernel crash in |fcbopen_main()|.
  8.  
  9. Stack trace looks like this:
  10. ---- snip ----
  11. nt!KeBugCheckEx
  12. nt!MiSystemFault+0x1ccd81
  13. nt!MmAccessFault+0x400
  14. nt!KiPageFault+0x36d
  15. nfs41_driver!fcbopen_main+0x105 [ms-nfs41-client\sys\nfs41_driver.c @ 7516]
  16. nt!PspSystemThreadStartup+0x55
  17. nt!KiStartSystemThread+0x28
  18. ---- snip ----
  19.  
  20. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  21. ---
  22. sys/nfs41_driver.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
  23.  1 file changed, 44 insertions(+), 2 deletions(-)
  24.  
  25. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  26. index 434ee90..b24bc4e 100644
  27. --- a/sys/nfs41_driver.c
  28. +++ b/sys/nfs41_driver.c
  29. @@ -4592,7 +4592,7 @@ static VOID nfs41_remove_fcb_entry(
  30.                  nfs41_fcb_list_entry, next);
  31.          if (cur->fcb == fcb) {
  32.  #ifdef DEBUG_CLOSE
  33. -            DbgP("nfs41_remove_srvopen_entry: Found match for fcb=0x%p\n", fcb);
  34. +            DbgP("nfs41_remove_fcb_entry: Found match for fcb=0x%p\n", fcb);
  35.  #endif
  36.              RemoveEntryList(pEntry);
  37.              RxFreePool(cur);
  38. @@ -4600,7 +4600,7 @@ static VOID nfs41_remove_fcb_entry(
  39.          }
  40.          if (pEntry->Flink == &openlist.head) {
  41.  #ifdef DEBUG_CLOSE
  42. -            DbgP("nfs41_remove_srvopen_entry: reached EOL looking "
  43. +            DbgP("nfs41_remove_fcb_entry: reached EOL looking "
  44.                  "for fcb 0x%p\n", fcb);
  45.  #endif
  46.              break;
  47. @@ -4610,6 +4610,38 @@ static VOID nfs41_remove_fcb_entry(
  48.      ExReleaseFastMutex(&fcblistLock);
  49.  }
  50.  
  51. +static VOID nfs41_invalidate_fobx_entry(
  52. +    IN OUT PMRX_FOBX pFobx)
  53. +{
  54. +    PLIST_ENTRY pEntry;
  55. +    nfs41_fcb_list_entry *cur;
  56. +    __notnull PNFS41_FOBX nfs41_fobx = NFS41GetFobxExtension(pFobx);
  57. +
  58. +    ExAcquireFastMutex(&fcblistLock);
  59. +
  60. +    pEntry = openlist.head.Flink;
  61. +    while (!IsListEmpty(&openlist.head)) {
  62. +        cur = (nfs41_fcb_list_entry *)CONTAINING_RECORD(pEntry,
  63. +                nfs41_fcb_list_entry, next);
  64. +        if (cur->nfs41_fobx == nfs41_fobx) {
  65. +#ifdef DEBUG_CLOSE
  66. +            DbgP("nfs41_invalidate_fobx_entry: Found match for fobx=0x%p\n", fobx);
  67. +#endif
  68. +            cur->nfs41_fobx = NULL;
  69. +            break;
  70. +        }
  71. +        if (pEntry->Flink == &openlist.head) {
  72. +#ifdef DEBUG_CLOSE
  73. +            DbgP("nfs41_invalidate_fobx_entry: reached EOL looking "
  74. +                "for fobx 0x%p\n", fobx);
  75. +#endif
  76. +            break;
  77. +        }
  78. +        pEntry = pEntry->Flink;
  79. +    }
  80. +    ExReleaseFastMutex(&fcblistLock);
  81. +}
  82. +
  83.  static NTSTATUS map_close_errors(
  84.      DWORD status)
  85.  {
  86. @@ -4713,6 +4745,9 @@ static NTSTATUS nfs41_DeallocateForFobx(
  87.      IN OUT PMRX_FOBX pFobx)
  88.  {
  89.      __notnull PNFS41_FOBX nfs41_fobx = NFS41GetFobxExtension(pFobx);
  90. +
  91. +    nfs41_invalidate_fobx_entry(pFobx);
  92. +
  93.      if (nfs41_fobx->acl) {
  94.          RxFreePool(nfs41_fobx->acl);
  95.          nfs41_fobx->acl = NULL;
  96. @@ -7509,6 +7544,13 @@ VOID fcbopen_main(PVOID ctx)
  97.  #endif
  98.              if (cur->skip) goto out;
  99.  
  100. +            /*
  101. +             * This can only happen if |nfs41_DeallocateForFobx()|
  102. +             * was called
  103. +             */
  104. +            if ((!cur->nfs41_fobx) || (!cur->nfs41_fobx->sec_ctx.ClientToken))
  105. +                goto out;
  106. +
  107.              pNetRootContext =
  108.                  NFS41GetNetRootExtension(cur->fcb->pNetRoot);
  109.              /* place an upcall for this srv_open */
  110. --
  111. 2.45.1
  112.  
  113. From ac94273d98ffe1333181b43042b30b0bff24be26 Mon Sep 17 00:00:00 2001
  114. From: Roland Mainz <roland.mainz@nrubsig.org>
  115. Date: Mon, 5 Aug 2024 15:53:54 +0200
  116. Subject: [PATCH 2/6] mount,sys: Add mount option to enable/disable time-based
  117.  coherency
  118.  
  119. Add mount option to enable/disable time-based coherency.
  120. "off" by default, because the time-based coherency causes
  121. crashes under Win32 "verifer" utilty.
  122.  
  123. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  124. ---
  125. mount/mount.c      |  2 ++
  126.  sys/nfs41_driver.c | 25 +++++++++++++++++++++++++
  127.  2 files changed, 27 insertions(+)
  128.  
  129. diff --git a/mount/mount.c b/mount/mount.c
  130. index 442c0d6..63efa11 100644
  131. --- a/mount/mount.c
  132. +++ b/mount/mount.c
  133. @@ -107,6 +107,8 @@ void PrintMountUsage(LPWSTR pProcess)
  134.          "\tnowritethru\tturns on rdbss caching for writes (default)\n"
  135.          "\tcache\tturns on rdbss caching (default)\n"
  136.          "\tnocache\tturns off rdbss caching\n"
  137. +        "\ttimebasedcoherency\tturns on time-based coherency\n"
  138. +        "\tnotimebasedcoherency\tturns off time-based coherency (default, due to bugs)\n"
  139.          "\twsize=#\twrite buffer size in bytes\n"
  140.          "\tcreatemode=\tspecify default POSIX permission mode\n"
  141.              "\t\tfor new files created on the NFS share.\n"
  142. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  143. index b24bc4e..c4b3af5 100644
  144. --- a/sys/nfs41_driver.c
  145. +++ b/sys/nfs41_driver.c
  146. @@ -308,6 +308,7 @@ typedef struct _NFS41_MOUNT_CONFIG {
  147.      BOOLEAN ReadOnly;
  148.      BOOLEAN write_thru;
  149.      BOOLEAN nocache;
  150. +    BOOLEAN timebasedcoherency;
  151.      WCHAR srv_buffer[SERVER_NAME_BUFFER_SIZE];
  152.      UNICODE_STRING SrvName; /* hostname, or hostname@port */
  153.      WCHAR mntpt_buffer[NFS41_SYS_MAX_PATH_LEN];
  154. @@ -416,6 +417,7 @@ typedef struct _NFS41_V_NET_ROOT_EXTENSION {
  155.      BOOLEAN                 read_only;
  156.      BOOLEAN                 write_thru;
  157.      BOOLEAN                 nocache;
  158. +    BOOLEAN                 timebasedcoherency;
  159.  } NFS41_V_NET_ROOT_EXTENSION, *PNFS41_V_NET_ROOT_EXTENSION;
  160.  #define NFS41GetVNetRootExtension(pVNetRoot)      \
  161.          (((pVNetRoot) == NULL) ? NULL :           \
  162. @@ -450,6 +452,7 @@ typedef struct _NFS41_FOBX {
  163.      DWORD deleg_type;
  164.      BOOLEAN write_thru;
  165.      BOOLEAN nocache;
  166. +    BOOLEAN timebasedcoherency;
  167.  } NFS41_FOBX, *PNFS41_FOBX;
  168.  #define NFS41GetFobxExtension(pFobx)  \
  169.          (((pFobx) == NULL) ? NULL : (PNFS41_FOBX)((pFobx)->Context))
  170. @@ -2891,6 +2894,7 @@ static void nfs41_MountConfig_InitDefaults(
  171.      Config->ReadOnly = FALSE;
  172.      Config->write_thru = FALSE;
  173.      Config->nocache = FALSE;
  174. +    Config->timebasedcoherency = FALSE; /* disabled by default because of bugs */
  175.      Config->SrvName.Length = 0;
  176.      Config->SrvName.MaximumLength = SERVER_NAME_BUFFER_SIZE;
  177.      Config->SrvName.Buffer = Config->srv_buffer;
  178. @@ -3046,6 +3050,14 @@ static NTSTATUS nfs41_MountConfig_ParseOptions(
  179.              status = nfs41_MountConfig_ParseBoolean(Option, &usValue,
  180.                  FALSE, &Config->nocache);
  181.          }
  182. +        else if (wcsncmp(L"timebasedcoherency", Name, NameLen) == 0) {
  183. +            status = nfs41_MountConfig_ParseBoolean(Option, &usValue,
  184. +                FALSE, &Config->timebasedcoherency);
  185. +        }
  186. +        else if (wcsncmp(L"notimebasedcoherency", Name, NameLen) == 0) {
  187. +            status = nfs41_MountConfig_ParseBoolean(Option, &usValue,
  188. +                TRUE, &Config->timebasedcoherency);
  189. +        }
  190.          else if (wcsncmp(L"timeout", Name, NameLen) == 0) {
  191.              status = nfs41_MountConfig_ParseDword(Option, &usValue,
  192.                  &Config->timeout, UPCALL_TIMEOUT_DEFAULT,
  193. @@ -3428,6 +3440,7 @@ static NTSTATUS nfs41_CreateVNetRoot(
  194.          pVNetRootContext->read_only = Config->ReadOnly;
  195.          pVNetRootContext->write_thru = Config->write_thru;
  196.          pVNetRootContext->nocache = Config->nocache;
  197. +        pVNetRootContext->timebasedcoherency = Config->timebasedcoherency;
  198.      } else {
  199.          /*
  200.           * Codepath for \\server@port\nfs4\path or
  201. @@ -3522,6 +3535,7 @@ static NTSTATUS nfs41_CreateVNetRoot(
  202.          pVNetRootContext->read_only = Config->ReadOnly;
  203.          pVNetRootContext->write_thru = Config->write_thru;
  204.          pVNetRootContext->nocache = Config->nocache;
  205. +        pVNetRootContext->timebasedcoherency = Config->timebasedcoherency;
  206.      }
  207.  
  208.      Config->use_nfspubfh = pubfh_prefix;
  209. @@ -3533,6 +3547,7 @@ static NTSTATUS nfs41_CreateVNetRoot(
  210.          "ReadOnly=%d, "
  211.          "write_thru=%d, "
  212.          "nocache=%d "
  213. +        "timebasedcoherency=%d "
  214.          "timeout=%d "
  215.          "createmode.use_nfsv3attrsea_mode=%d "
  216.          "Config->createmode.mode=0o%o "
  217. @@ -3543,6 +3558,7 @@ static NTSTATUS nfs41_CreateVNetRoot(
  218.          Config->ReadOnly?1:0,
  219.          Config->write_thru?1:0,
  220.          Config->nocache?1:0,
  221. +        Config->timebasedcoherency?1:0,
  222.          Config->timeout,
  223.          Config->createmode.use_nfsv3attrsea_mode?1:0,
  224.          Config->createmode.mode);
  225. @@ -4462,6 +4478,7 @@ retry_on_link:
  226.                  (FCB_STATE_READBUFFERING_ENABLED |
  227.                  FCB_STATE_READCACHING_ENABLED);
  228.          }
  229. +        nfs41_fobx->timebasedcoherency = pVNetRootContext->timebasedcoherency;
  230.          if (pVNetRootContext->nocache ||
  231.                  (params->CreateOptions & FILE_NO_INTERMEDIATE_BUFFERING)) {
  232.  #ifdef DEBUG_OPEN
  233. @@ -7551,6 +7568,14 @@ VOID fcbopen_main(PVOID ctx)
  234.              if ((!cur->nfs41_fobx) || (!cur->nfs41_fobx->sec_ctx.ClientToken))
  235.                  goto out;
  236.  
  237. +            if (!cur->nfs41_fobx->timebasedcoherency) {
  238. +#ifdef DEBUG_TIME_BASED_COHERENCY
  239. +                DbgP("fcbopen_main: timebasedcoherency disabled for "
  240. +                    "fcb=0x%p, nfs41_fobx=0x%p\n", cur->fcb, cur->nfs41_fobx);
  241. +#endif
  242. +                goto out;
  243. +            }
  244. +
  245.              pNetRootContext =
  246.                  NFS41GetNetRootExtension(cur->fcb->pNetRoot);
  247.              /* place an upcall for this srv_open */
  248. --
  249. 2.45.1
  250.  
  251. From 07081dacdc9d2e740868748066b259b0d55cf928 Mon Sep 17 00:00:00 2001
  252. From: Roland Mainz <roland.mainz@nrubsig.org>
  253. Date: Mon, 5 Aug 2024 15:57:56 +0200
  254. Subject: [PATCH 3/6] cygwin: cygwinaccount2nfs4account: Add --man/--help and
  255.  convert given user
  256.  
  257. cygwinaccount2nfs4account: Add --man/--help options and
  258. a mode to convert a given user.
  259.  
  260. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  261. ---
  262. .../cygwinaccount2nfs4account.ksh             | 237 ++++++++++++++++--
  263.  1 file changed, 211 insertions(+), 26 deletions(-)
  264.  
  265. diff --git a/cygwin/utils/cygwinaccount2nfs4account/cygwinaccount2nfs4account.ksh b/cygwin/utils/cygwinaccount2nfs4account/cygwinaccount2nfs4account.ksh
  266. index f765276..dbb440f 100644
  267. --- a/cygwin/utils/cygwinaccount2nfs4account/cygwinaccount2nfs4account.ksh
  268. +++ b/cygwin/utils/cygwinaccount2nfs4account/cygwinaccount2nfs4account.ksh
  269. @@ -25,7 +25,7 @@
  270.  #
  271.  
  272.  #
  273. -# cygwinaccount2nfs4account.ksh93 - transfer Cygwin user/group account
  274. +# cygwinaccount2nfs4account.ksh93 - convert Cygwin user/group account
  275.  # info to Linux/UNIX NFSv4 server account data
  276.  #
  277.  
  278. @@ -33,6 +33,13 @@
  279.  # Written by Roland Mainz <roland.mainz@nrubsig.org>
  280.  #
  281.  
  282. +function usage
  283. +{
  284. +       (( OPTIND=0 ))
  285. +       getopts -a "${1}" "${2}" OPT '-?'
  286. +       return 2
  287. +}
  288. +
  289.  function getent_passwd2compound
  290.  {
  291.         set -o nounset
  292. @@ -143,6 +150,10 @@ function accountdata2linuxscript
  293.         #
  294.         integer i
  295.  
  296. +       printf '\n\n#\n'
  297. +       printf '# Group data:\n'
  298. +       printf '#\n'
  299. +
  300.         for ((i=0 ; i < ${#accountdata.group_list[@]} ; i++ )) ; do
  301.                 nameref currgrp=accountdata.group_list[$i]
  302.  
  303. @@ -169,6 +180,10 @@ function accountdata2linuxscript
  304.         #
  305.         nameref curruser=accountdata.user
  306.  
  307. +       printf '\n\n#\n'
  308. +       printf '# User data:\n'
  309. +       printf '#\n'
  310. +
  311.         printf 'mkdir -p %q\n' "${curruser.homedir}"
  312.         printf 'useradd -u %s -g %s -G %q -s %q %q\n' \
  313.                 "${curruser.uid}" \
  314. @@ -183,58 +198,228 @@ function accountdata2linuxscript
  315.         return 0
  316.  }
  317.  
  318. +function print_nfs4_server_config
  319. +{
  320. +       nameref cfg=$1
  321. +
  322. +       # fixme: we need to figure out the real NFSv4 idmapping domain of the client
  323. +       printf '\n\n#\n'
  324. +       printf '# NFSv4 server config:\n'
  325. +       printf '#\n'
  326. +
  327. +       printf '# turn idmapper on, even for AUTH_SYS\n'
  328. +       printf '{\n'
  329. +       printf '\tprintf "[General]\\n"\n'
  330. +       printf '\tprintf "Domain = %s\\n"\n' "GLOBAL.LOC"
  331. +       printf '} >>"/etc/idmapd.conf"\n'
  332. +
  333. +       printf 'printf "options nfsd nfs4_disable_idmapping=N\\noptions nfs nfs4_disable_idmapping=N\\n" >>"/etc/modprobe.d/nfs.conf"\n'
  334. +       printf 'printf "NEED_IDMAPD=yes\\n" >>"/etc/default/nfs-common"\n'
  335. +
  336. +       return 0
  337. +}
  338.  
  339.  function convert_curruser2linuxscript
  340.  {
  341. +       nameref cfg=$1
  342. +       shift
  343. +
  344.         compound account_data
  345.         compound account_data.user
  346.         compound -a account_data.group_list
  347.         integer i=0
  348. -       typeset currgroup
  349. +       typeset -a group_list
  350.  
  351.         getent_passwd2compound account_data.user "$(id -u)"
  352.  
  353. -       for currgroup in $(id -G) ; do
  354. -               getent_group2compound account_data.group_list[$((i++))] "$currgroup"
  355. +       group_list=( $(id -G) )
  356. +
  357. +       #
  358. +       # Collect group information into "account_data" CPV
  359. +       #
  360. +       for ((i=0 ; i < ${#group_list[@]} ; i++ )) ; do
  361. +               getent_group2compound account_data.group_list[$i] "${group_list[$i]}"
  362.         done
  363.  
  364. -       print -v account_data
  365. +       ${cfg.debug} && print -u2 -v account_data
  366.  
  367. +       #
  368. +       # Generate Linux script from collected "account_data"
  369. +       #
  370.         accountdata2linuxscript account_data
  371.  
  372. -       # fixme: we need to figure out the real NFSv4 idmapping domain of the client
  373. -
  374. -       printf '# turn idmapper on, even for AUTH_SYS\n'
  375. -       printf '{\n'
  376. -       printf '\tprintf "[General]\\n"\n'
  377. -       printf '\tprintf "Domain = %s\\n"\n' "GLOBAL.LOC"
  378. -       printf '} >>"/etc/idmapd.conf"\n'
  379. +       #
  380. +       # Print NFSv4 server config
  381. +       #
  382. +       print_nfs4_server_config cfg
  383.  
  384. -       printf 'printf "options nfsd nfs4_disable_idmapping=N\\noptions nfs nfs4_disable_idmapping=N\\n" >>"/etc/modprobe.d/nfs.conf"\n'
  385. -       printf 'printf "NEED_IDMAPD=yes\\n" >>"/etc/default/nfs-common"\n'
  386. +       #
  387. +       # Done
  388. +       #
  389. +       printf '\n# Done.\n'
  390.  
  391.         return 0
  392.  }
  393.  
  394. +function convert_givenuser2linuxscript
  395. +{
  396. +       nameref cfg=$1
  397. +       shift
  398. +
  399. +       typeset username="$1"
  400. +
  401. +       compound account_data
  402. +       compound account_data.user
  403. +       compound -a account_data.group_list
  404. +       integer i=0
  405. +       typeset -a group_list
  406. +
  407. +       getent_passwd2compound account_data.user "$username"
  408. +
  409. +       compound out
  410. +
  411. +       #
  412. +       # Get group data from Directory Server
  413. +       #
  414. +
  415. +       #
  416. +       # query DS via powershell
  417. +       #
  418. +       out.stderr="${ { out.stdout="${
  419. +               queryuser="$username" powershell -Command '(New-Object System.DirectoryServices.DirectorySearcher("(&(objectCategory=User)(samAccountName=$("$env:queryuser")))")).FindOne().GetDirectoryEntry().memberOf'
  420. +               (( out.res=$? )) ; }" ; } 2>&1 ; }"
  421. +
  422. +       if [[ "${out.stderr}" != '' ]] || (( out.res != 0 )) ; then
  423. +               print -u2 $"%s: powershell querying groups from DS failed, msg=%q, res=%d\n" \
  424. +                       "$0" "${out.stderr}" out.res
  425. +               return 1
  426. +       fi
  427. +
  428. +       #
  429. +       # Parse LDAP-style output
  430. +       #
  431. +       dummy="${out.stdout//~(E)CN=(.+?),/dummy}"
  432. +       ${cfg.debug} && printf 'dummy=%q\n' "$dummy"
  433. +
  434. +       for ((i=0 ; i < ${#.sh.match[1][@]} ; i++)) ; do
  435. +               group_list+=( "${.sh.match[1][$i]}" )
  436. +       done
  437. +
  438. +       #
  439. +       # Collect group information into "account_data" CPV
  440. +       #
  441. +       for ((i=0 ; i < ${#group_list[@]} ; i++ )) ; do
  442. +               getent_group2compound account_data.group_list[$i] "${group_list[$i]}"
  443. +       done
  444. +
  445. +       ${cfg.debug} && print -u2 -v account_data
  446. +
  447. +       #
  448. +       # Generate Linux script from collected "account_data"
  449. +       #
  450. +       accountdata2linuxscript account_data
  451. +
  452. +       #
  453. +       # Print NFSv4 server config
  454. +       #
  455. +       print_nfs4_server_config cfg
  456. +
  457. +       #
  458. +       # Done
  459. +       #
  460. +       printf '\n# Done.\n'
  461. +
  462. +       return 0
  463. +}
  464.  
  465. -#
  466. -# ToDo:
  467. -# - Command-line options
  468. -# - Convert current user+groups to Linux bash script [done]
  469. -# - Convert current user+groups to /etc/passwd+/etc/group lines
  470. -# - Convert given user+groups to Linux bash script
  471. -# - Convert given user+groups to /etc/passwd+/etc/group lines
  472. -#
  473.  function main
  474.  {
  475. -       convert_curruser2linuxscript "$@"
  476. -       return $?
  477. +       set -o nounset
  478. +
  479. +       # fixme: Need better text layout for $ nfsurlconv --man #
  480. +       typeset -r cygwinaccount2nfs4account_usage=$'+
  481. +       [-?\n@(#)\$Id: cygwinaccount2nfs4account (Roland Mainz) 2024-08-01 \$\n]
  482. +       [-author?Roland Mainz <roland.mainz@nrubsig.org>]
  483. +       [+NAME?cygwinaccount2nfs4account - convert Cygwin user/group account
  484. +               info to Linux/UNIX NFSv4 server account data]
  485. +       [+DESCRIPTION?\bcygwinaccount2nfs4account\b convert Cygwin user/group account
  486. +               info to Linux/UNIX NFSv4 server account data.]
  487. +       [D:debug?Enable debugging.]
  488. +
  489. +       --man
  490. +
  491. +       [+SEE ALSO?\bksh93\b(1),\bms-nfs41-client\b(1),\bnfs\b(5)]
  492. +       '
  493. +
  494. +       compound c
  495. +       typeset -a c.args
  496. +       integer saved_optind_m1 # saved OPTIND-1
  497. +
  498. +       c.args=( "$@" )
  499. +
  500. +       typeset c.debug=false
  501. +
  502. +       #
  503. +       # Argument parsing
  504. +       #
  505. +       while getopts -a "${progname}" "${cygwinaccount2nfs4account_usage}" OPT "${c.args[@]}" ; do
  506. +               case "${OPT}" in
  507. +                       'D')
  508. +                               c.debug=true
  509. +                               ;;
  510. +                       *)
  511. +                               usage "${progname}" "${cygwinaccount2nfs4account_usage}"
  512. +                               return $?
  513. +                               ;;
  514. +               esac
  515. +       done
  516. +
  517. +       (( saved_optind_m1=OPTIND-1 ))
  518. +
  519. +       # remove options we just parsed from c.args
  520. +       for ((i=0 ; i < saved_optind_m1 ; i++)) ; do
  521. +               unset c.args[$i]
  522. +       done
  523. +
  524. +       #
  525. +       # c.args mighth be a sparse array (e.g. "([1]=aaa [2]=bbb [4]=ccc)")
  526. +       # right now after we removed processed options/arguments.
  527. +       # For easier processing below we "reflow" the array back to a
  528. +       # normal linear layout (e.g. ([0]=aaa [1]=bbb [2]=ccc)
  529. +       #
  530. +       c.args=( "${c.args[@]}" )
  531. +
  532. +       #
  533. +       # ToDo:
  534. +       # - Command-line options
  535. +       # - Convert current user+groups to Linux bash script [done]
  536. +       # - Convert current user+groups to /etc/passwd+/etc/group lines
  537. +       # - Convert given user+groups to Linux bash script
  538. +       # - Convert given user+groups to /etc/passwd+/etc/group lines
  539. +       #
  540. +
  541. +       if (( ${#c.args[@]} == 0 )) ; then
  542. +               print -u2 -f $"# Converting current user\n"
  543. +               convert_curruser2linuxscript c "$@"
  544. +       else
  545. +               print -u2 -f $"# Converting given user\n"
  546. +               convert_givenuser2linuxscript c "$@"
  547. +       fi
  548. +
  549. +       return 2
  550.  }
  551.  
  552. +#
  553. +# main
  554. +#
  555. +builtin cat
  556.  builtin id
  557. +builtin mkdir
  558. +builtin basename
  559.  
  560. -main "$@"
  561. -return $?
  562. +typeset progname="${ basename "${0}" ; }"
  563.  
  564. +main "$@"
  565. +exit $?
  566.  
  567.  # EOF.
  568. --
  569. 2.45.1
  570.  
  571. From 15bcf2f22684061993cbce0fca8e0f1e1d36083e Mon Sep 17 00:00:00 2001
  572. From: Roland Mainz <roland.mainz@nrubsig.org>
  573. Date: Mon, 5 Aug 2024 16:03:39 +0200
  574. Subject: [PATCH 4/6] sys: Remove |DbgEn()|/|DbgEx()| from |fcbopen_main()|
  575.  
  576. Remove |DbgEn()|/|DbgEx()| from |fcbopen_main()|, so any issues
  577. here are no longer hidden.
  578.  
  579. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  580. ---
  581. sys/nfs41_driver.c | 4 ++--
  582.  1 file changed, 2 insertions(+), 2 deletions(-)
  583.  
  584. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  585. index c4b3af5..ec68192 100644
  586. --- a/sys/nfs41_driver.c
  587. +++ b/sys/nfs41_driver.c
  588. @@ -7538,7 +7538,7 @@ VOID fcbopen_main(PVOID ctx)
  589.      NTSTATUS status;
  590.      LARGE_INTEGER timeout;
  591.  
  592. -    DbgEn();
  593. +//    DbgEn();
  594.      timeout.QuadPart = RELATIVE(SECONDS(30));
  595.      while(1) {
  596.          PLIST_ENTRY pEntry;
  597. @@ -7643,7 +7643,7 @@ out:
  598.          }
  599.          ExReleaseFastMutex(&fcblistLock);
  600.      }
  601. -    DbgEx();
  602. +//    DbgEx();
  603.  }
  604.  
  605.  
  606. --
  607. 2.45.1
  608.  
  609. From a9b754f34159580ead6ae5cdb1126af13996fc8c Mon Sep 17 00:00:00 2001
  610. From: Cedric Blancher <cedric.blancher@gmail.com>
  611. Date: Mon, 5 Aug 2024 17:46:19 +0200
  612. Subject: [PATCH 5/6] cygwin: 32bit apps on 64bit Windows cannot enumerate NFS
  613.  shares
  614.  
  615. 32bit apps on 64bit Windows cannot enumerate NFS shares, because
  616. the 32bit network provider DLL was not installed.
  617.  
  618. Signed-off-by: Roland Mainz <roland.mainz@nrubsig.org>
  619. ---
  620. cygwin/devel/msnfs41client.bash | 13 +++++++++++++
  621.  1 file changed, 13 insertions(+)
  622.  
  623. diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
  624. index 0553938..ce91e0d 100644
  625. --- a/cygwin/devel/msnfs41client.bash
  626. +++ b/cygwin/devel/msnfs41client.bash
  627. @@ -216,6 +216,16 @@ function nfsclient_adddriver
  628.  
  629.         rundll32 setupapi.dll,InstallHinfSection DefaultInstall 132 ./nfs41rdr.inf
  630.  
  631. +       #
  632. +       # Hack: Manually Add 32bit provider DLL to a 64bit system, so
  633. +       # 32bit applications can enumerate the ms-nfs41-client shares
  634. +       # (FIXME: technically nfs41rdr.inf should do this)
  635. +       #
  636. +       if [[ -d '/cygdrive/c/Windows/SysWOW64/' ]] ; then
  637. +               # copy from the 32bit install dir
  638. +               cp '../../../../../cygdrive/c/cygwin/lib/msnfs41client/nfs41_np.dll' '/cygdrive/c/Windows/SysWOW64/'
  639. +       fi
  640. +
  641.         return 0
  642.  }
  643.  
  644. @@ -234,6 +244,9 @@ function nfsclient_removedriver
  645.         nfs_install.exe 0
  646.         rundll32.exe setupapi.dll,InstallHinfSection DefaultUninstall 132 ./nfs41rdr.inf
  647.         rm /cygdrive/c/Windows/System32/nfs41_np.dll || true
  648. +       if [[ -d '/cygdrive/c/Windows/SysWOW64/' ]] ; then
  649. +               rm '/cygdrive/c/Windows/SysWOW64/nfs41_np.dll' || true
  650. +       fi
  651.         rm /cygdrive/c/Windows/System32/drivers/nfs41_driver.sys || true
  652.  
  653.         sync
  654. --
  655. 2.45.1
  656.  
  657. From 90dd1beb8fcfdb659732f8f173986595bf86a21a Mon Sep 17 00:00:00 2001
  658. From: Cedric Blancher <cedric.blancher@gmail.com>
  659. Date: Mon, 5 Aug 2024 17:48:15 +0200
  660. Subject: [PATCH 6/6] mount: Move share enumation cmd into own function
  661.  
  662. Move share enumation cmd into own function.
  663.  
  664. Signed-off-by: Roland Mainz <roland.mainz@nrubsig.org>
  665. ---
  666. mount/mount.c | 32 +++++++++++++++++++++++---------
  667.  1 file changed, 23 insertions(+), 9 deletions(-)
  668.  
  669. diff --git a/mount/mount.c b/mount/mount.c
  670. index 63efa11..a4b8eb1 100644
  671. --- a/mount/mount.c
  672. +++ b/mount/mount.c
  673. @@ -178,14 +178,6 @@ int mount_main(int argc, wchar_t *argv[])
  674.      wchar_t *mntopts[MAX_MNTOPTS] = { 0 };
  675.      int     num_mntopts = 0;
  676.  
  677. -    if (argc == 1) {
  678. -        /* list open nfs shares */
  679. -        result = EnumMounts(NULL);
  680. -        if (result)
  681. -            PrintErrorMessage(GetLastError());
  682. -        goto out;
  683. -    }
  684. -
  685.      result = InitializeMountOptions(&Options, MAX_OPTION_BUFFER_SIZE);
  686.      if (result) {
  687.          PrintErrorMessage(GetLastError());
  688. @@ -532,6 +524,24 @@ out:
  689.  }
  690.  
  691.  
  692. +static
  693. +int list_nfs_mounts_main(int argc, wchar_t *argv[])
  694. +{
  695. +    DWORD result;
  696. +
  697. +    /* Unused for now */
  698. +    (void)argc;
  699. +    (void)argv;
  700. +
  701. +    /* list open nfs shares */
  702. +    result = EnumMounts(NULL);
  703. +    if (result)
  704. +        PrintErrorMessage(GetLastError());
  705. +
  706. +    return result;
  707. +}
  708. +
  709. +
  710.  int __cdecl wmain(int argc, wchar_t *argv[])
  711.  {
  712.      DWORD result = NO_ERROR;
  713. @@ -545,7 +555,11 @@ int __cdecl wmain(int argc, wchar_t *argv[])
  714.      (void)_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
  715.      (void)_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
  716.  
  717. -    if (wcsstr(argv[0], L"nfs_mount")) {
  718. +    if (argc == 1) {
  719. +        result = list_nfs_mounts_main(argc, argv);
  720. +        goto out;
  721. +    }
  722. +    else if (wcsstr(argv[0], L"nfs_mount")) {
  723.          result = mount_main(argc, argv);
  724.          goto out;
  725.      }
  726. --
  727. 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