pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


msnfs41client: Patch to add a Win32 "ms-nfs41-client-service", 2024-04-19
Posted by Anonymous on Fri 19th Apr 2024 16:27
raw | new post

  1. From a5864c9a7cb46803fc193d4cf6d1119b98770a13 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Fri, 19 Apr 2024 17:06:42 +0200
  4. Subject: [PATCH] cygwin: RFE: Add a Windows service
  5.  ("ms-nfs41-client-service") for "nfsd_debug"
  6.  
  7. RFE: Add a Windows service ("ms-nfs41-client-service") for
  8. "nfsd_debug.exe", "disabled" by default.
  9.  
  10. The service is implemented via Cygwin cygrunsrv, and calls the
  11. $ /sbin/msnfs41client run_daemon # script.
  12.  
  13. ** Usage (as Adminstrator):
  14.  
  15. $ sc start ms-nfs41-client-service
  16.  
  17. ** Notes:
  18. - requires "Adminstrator" account, and one nfsd client daemon is
  19.   used for all users on a machine.
  20.  
  21. - The "ms-nfs41-client-service" service is installed by default as
  22.   "disabled" and therefore always requires a "manual" start (e.g.
  23.   $ sc start ms-nfs41-client-service #)
  24.  
  25. - note that DOS devices are virtualised per LSA Logon, so each Logon
  26.   needs to do a separare nfs_mount.exe to mount a NFSv4 share
  27.  
  28. - nfsd_debug.exe will run as user "SYSTEM", but will do user
  29.   impersonation for each request
  30.  
  31. - stopping the service will NOT unmount filesystems, and due to a
  32.   bug a reboot is required to restart and mount any NFSv4
  33.   filesystems again
  34.  
  35. ** Administration:
  36. - Follow new log messages:
  37.   $ tail -f '/var/log/ms-nfs41-client-service.log'
  38.  
  39. - Query service status:
  40.   $ sc queryex ms-nfs41-client-service
  41.  
  42. - Query service config:
  43.   $ sc qc ms-nfs41-client-service
  44.  
  45. - Start service automatically:
  46.   (nfsd_debug.exe will be started automagically, but mounts are
  47.   not restored):
  48.   $ sc config ms-nfs41-client-service start=auto
  49.  
  50. - Start service manually (default):
  51.   $ sc config ms-nfs41-client-service start=disabled
  52.  
  53. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  54. ---
  55. cygwin/README.bintarball.txt    | 39 ++++++++++++++++++++++++++++++++-
  56.  cygwin/devel/msnfs41client.bash | 38 ++++++++++++++++++++++++++++----
  57.  2 files changed, 72 insertions(+), 5 deletions(-)
  58.  
  59. diff --git a/cygwin/README.bintarball.txt b/cygwin/README.bintarball.txt
  60. index c0c2bf3..9e94ddd 100644
  61. --- a/cygwin/README.bintarball.txt
  62. +++ b/cygwin/README.bintarball.txt
  63. @@ -129,7 +129,44 @@ $ (set -o xtrace ; cd / && tar -tf ~/download/${bintarball.base_filename}.tar.bz
  64.  # 7. Usage:
  65.  #
  66.  
  67. -# Run the NFSv4 client daemon:
  68. +# Option a)
  69. +# * Start NFSv4 client daemon as Windows service (requires
  70. +# "Adminstrator" account):
  71. +
  72. +$ sc start ms-nfs41-client-service
  73. +
  74. +# * Notes:
  75. +# - requires "Adminstrator" account, and one nfsd client daemon is
  76. +#   used for all users on a machine.
  77. +# - The "ms-nfs41-client-service" service is installed by default as
  78. +#   "disabled" and therefore always requires a "manual" start (e.g.
  79. +#   $ sc start ms-nfs41-client-service #)
  80. +# - note that DOS devices are virtualised per LSA Logon, so each Logon
  81. +#   needs to do a separare nfs_mount.exe to mount a NFSv4 share
  82. +# - nfsd_debug.exe will run as user "SYSTEM", but will do user
  83. +#   impersonation for each request
  84. +# - stopping the service will NOT unmount filesystems, and due to a
  85. +#   bug a reboot is required to restart and mount any NFSv4
  86. +#   filesystems again
  87. +
  88. +# * Administration:
  89. +# - Follow new log messages:
  90. +$ tail -f '/var/log/ms-nfs41-client-service.log'
  91. +# - Query service status:
  92. +$ sc queryex ms-nfs41-client-service
  93. +# - Query service config:
  94. +$ sc qc ms-nfs41-client-service
  95. +# - Start service automatically:
  96. +# (nfsd_debug.exe will be started automagically, but mounts are
  97. +# not restored):
  98. +$ sc config ms-nfs41-client-service start=auto
  99. +# - Start service manually (default):
  100. +$ sc config ms-nfs41-client-service start=disabled
  101. +
  102. +
  103. +# Option b)
  104. +# Run the NFSv4 client daemon manually:
  105. +#
  106.  # - run this preferably as "Administrator", but this is not a requirement
  107.  # - requires separate terminal
  108.  $ /sbin/msnfs41client run_daemon
  109. diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
  110. index 066a4fa..1325d6f 100644
  111. --- a/cygwin/devel/msnfs41client.bash
  112. +++ b/cygwin/devel/msnfs41client.bash
  113. @@ -123,6 +123,32 @@ function nfsclient_install
  114.  
  115.         openfiles /local ON
  116.  
  117. +       #
  118. +       # install "msnfs41client run_daemon" as system service
  119. +       # 'ms-nfs41-client-service'
  120. +       # "off" by default, requires manual starting
  121. +       #
  122. +
  123. +       # remove 'ms-nfs41-client-service'
  124. +       sc stop 'ms-nfs41-client-service' || true
  125. +       cygrunsrv --remove 'ms-nfs41-client-service' || true
  126. +       if [[ -f '/var/log/ms-nfs41-client-service.log' ]] ; then
  127. +               mv \
  128. +                       '/var/log/ms-nfs41-client-service.log' \
  129. +                       "/var/log/ms-nfs41-client-service.log.old$(date +%Y%m%d_%Hh%Mm)"
  130. +       fi
  131. +
  132. +       # install new 'ms-nfs41-client-service'
  133. +       cygrunsrv --install \
  134. +               'ms-nfs41-client-service' \
  135. +               --path "$PWD/msnfs41client" \
  136. +               --args 'run_daemon' \
  137. +               --type 'manual' \
  138. +               --chdir "$PWD"
  139. +
  140. +       # query new 'ms-nfs41-client-service'
  141. +       sc query 'ms-nfs41-client-service'
  142. +
  143.         # check whether the driver really has been installed
  144.         md5sum \
  145.                 "$PWD/nfs41_driver.sys" \
  146. @@ -135,13 +161,15 @@ function nfsclient_install
  147.  
  148.  function nfsclient_rundeamon
  149.  {
  150. -       set -o xtrace
  151.         set -o nounset
  152.  
  153. -       printf '# uname='%s' isadmin=%d\n' \
  154. +       printf '# user='%s' uname='%s' isadmin=%d\n' \
  155. +               "$(id -u -n)" \
  156.                 "$(uname -a)" \
  157.                 "$(is_windows_admin_account ; printf "%d\n" $((${?}?0:1)))"
  158.  
  159. +       set -o xtrace
  160. +
  161.         typeset -a nfsd_args=(
  162.                 'nfsd_debug.exe'
  163.                 '-d' '0'
  164. @@ -226,13 +254,15 @@ function nfsclient_rundeamon
  165.  
  166.  function nfsclient_system_rundeamon
  167.  {
  168. -       set -o xtrace
  169.         set -o nounset
  170.  
  171. -       printf '# uname='%s' isadmin=%d\n' \
  172. +       printf '# user='%s' uname='%s' isadmin=%d\n' \
  173. +               "$(id -u -n)" \
  174.                 "$(uname -a)" \
  175.                 "$(is_windows_admin_account ; printf "%d\n" $((${?}?0:1)))"
  176.  
  177. +       set -o xtrace
  178. +
  179.         typeset -a nfsd_args=(
  180.                 'nfsd_debug.exe'
  181.                 '-d' '0'
  182. --
  183. 2.43.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