- From f3d37c4ac61e6c1206589dd744f5ce487a01476d Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 23 Sep 2024 18:08:19 +0200
- Subject: [PATCH] cygwin: RFE: ms-nfs41-client should have a service to mount
- global mounts
- RFE: ms-nfs41-client should have a service to mount global mounts.
- Reported-by: Martin Wege <martin.l.wege@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/Makefile.install | 4 +
- cygwin/README.bintarball.txt | 18 ++
- cygwin/devel/msnfs41client.bash | 73 +++++---
- .../mountall_msnfs41client.ksh | 164 ++++++++++++++++++
- 4 files changed, 236 insertions(+), 23 deletions(-)
- create mode 100644 cygwin/utils/mountall_msnfs41client/mountall_msnfs41client.ksh
- diff --git a/cygwin/Makefile.install b/cygwin/Makefile.install
- index 68f2b63..8c31d71 100644
- --- a/cygwin/Makefile.install
- +++ b/cygwin/Makefile.install
- @@ -55,6 +55,10 @@ installdest:
- git diff -w >"$(DESTDIR)/$(CYGWIN_BASEPATH)/usr/src/msnfs41client/msnfs41client_diff_w.diff"
- git diff >"$(DESTDIR)/$(CYGWIN_BASEPATH)/usr/src/msnfs41client/msnfs41client_diff.diff"
- @ printf "# Package utilties\n"
- + cp $(CYGWIN_MAKEFILE_DIR)/utils/mountall_msnfs41client/mountall_msnfs41client.ksh $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/mountall_msnfs41client
- + chmod a+x $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/mountall_msnfs41client
- + PATH+=":$(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/" \
- + /usr/bin/ksh93 $(CYGWIN_MAKEFILE_DIR)/utils/mountall_msnfs41client/mountall_msnfs41client.ksh --nroff 2>"$(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/man/man1/mountall_msnfs41client.1" || true
- cp $(CYGWIN_MAKEFILE_DIR)/utils/cygwinaccount2nfs4account/cygwinaccount2nfs4account.ksh $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/cygwinaccount2nfs4account
- chmod a+x $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/cygwinaccount2nfs4account
- PATH+=":$(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/" \
- diff --git a/cygwin/README.bintarball.txt b/cygwin/README.bintarball.txt
- index f5d4438..52b99a6 100644
- --- a/cygwin/README.bintarball.txt
- +++ b/cygwin/README.bintarball.txt
- @@ -262,6 +262,24 @@ $ net use N: /delete
- $ /sbin/nfs_mount
- +# Global/System-wide mounts:
- +Mounts created by user "SYSTEM" are useable by all users in a system.
- +Example usage:
- +---- snip ----
- +# Create a file /etc/fstab.msnfs41client, which list the mounts
- +# which should be available system-wide
- +$ cat /etc/fstab.msnfs41client
- +nfs://[fe80::21b:1bff:fec3:7713]//bigdisk V nfs rw 0 0
- +# run "ms-nfs41-client-globalmountall-service", which runs
- +# /sbin/mountall_msnfs41client as user "SYSTEM" to read
- +# /etc/fstab.msnfs41client and mount the matching filesystems
- +sc start ms-nfs41-client-globalmountall-service
- +---- snip ----
- +
- +BUG: Note that "ms-nfs41-client-globalmountall-service" currently
- +does not wait until nfsd*.exe is available for accepting mounts.
- +
- +
- #
- # 9. Notes:
- #
- diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
- index 14bbd9c..0ce778a 100755
- --- a/cygwin/devel/msnfs41client.bash
- +++ b/cygwin/devel/msnfs41client.bash
- @@ -185,6 +185,52 @@ function nfsclient_install
- # query new 'ms-nfs41-client-service'
- sc query 'ms-nfs41-client-service'
- + #
- + # install "mountall_msnfs41client" as system service
- + # 'ms-nfs41-client-globalmountall-service'
- + # "off" by default, requires manual starting
- + #
- +
- + # remove 'ms-nfs41-client-globalmountall-service'
- + sc stop 'ms-nfs41-client-globalmountall-service' || true
- + cygrunsrv --remove 'ms-nfs41-client-globalmountall-service' || true
- + if [[ -f '/var/log/ms-nfs41-client-globalmountall-service.log' ]] ; then
- + mv \
- + '/var/log/ms-nfs41-client-globalmountall-service.log' \
- + "/var/log/ms-nfs41-client-globalmountall-service.log.old$(date +%Y%m%d_%Hh%Mm)"
- + fi
- +
- + #
- + # create new '/var/log/ms-nfs41-client-globalmountall-service.log'
- + # so users can do a $ tail -f
- + # '/var/log/ms-nfs41-client-globalmountall-service.log' at any time
- + #
- + touch '/var/log/ms-nfs41-client-globalmountall-service.log'
- + chown SYSTEM:SYSTEM '/var/log/ms-nfs41-client-globalmountall-service.log'
- + chmod u+w,go-w '/var/log/ms-nfs41-client-globalmountall-service.log'
- +
- + # install new 'ms-nfs41-client-globalmountall-service'
- + cygrunsrv --install \
- + 'ms-nfs41-client-globalmountall-service' \
- + --path "$PWD/msnfs41client" \
- + --args 'sys_mount_globaldirs' \
- + --type 'manual' \
- + --chdir "$PWD"
- +
- + # install dummy /etc/fstab.msnfs41client if system does not have one
- + if [[ ! -f '/etc/fstab.msnfs41client' ]] ; then
- + {
- + printf '#\n'
- + printf '# /etc/fstab.msnfs41client - used by /sbin/mountall_msnfs41client\n'
- + printf '#\n\n'
- + printf '# nfs://[fe80::21b:1bff:fec3:7713]//bigdisk\tV\tnfs\trw\t0\t0\n\n'
- + printf '# EOF.\n'
- + } >'/etc/fstab.msnfs41client'
- + fi
- +
- + # query new 'ms-nfs41-client-globalmountall-service'
- + sc query 'ms-nfs41-client-globalmountall-service'
- +
- #
- # check whether ksh93 works
- # (The ms-nfs41-client cygwin idmapper uses ksh93 scripts for
- @@ -552,35 +598,15 @@ function nfsclient_system_mount_globaldirs
- set -o nounset
- set -o errexit
- - #
- - # ToDo: Add a /etc/fstab.msnfs41client file
- - # which is parsed for NFSv4.1 mounts like Linux/etc/fstab
- - # or SysV/Solaris/Illumos /etc/vfstab
- - #
- -
- - # purge any leftover persistent mappings to device P:
- - su_system net use 'P:' /delete || true
- - su_system nfs_mount -o sec=sys,rw 'P' 'nfs://derfwnb4966_ipv6linklocal//bigdisk'
- + mountall_msnfs41client
- return $?
- }
- function nfsclient_system_umount_globaldirs
- {
- - set -o xtrace
- - set -o nounset
- - set -o errexit
- -
- - #
- - # ToDo: Add a /etc/fstab.msnfs41client file
- - # which is parsed for NFSv4.1 mounts like Linux/etc/fstab
- - # or SysV/Solaris/Illumos /etc/vfstab
- - #
- -
- - # purge any leftover persistent mappings to device P:
- - su_system net use 'P:' /delete || true
- -
- - return $?
- + # fixme: needs to be implemented
- + return 1
- }
- function nfsclient_mount_homedir
- @@ -765,6 +791,7 @@ function main
- 'sys_mount_globaldirs')
- check_machine_arch || (( numerr++ ))
- require_cmd 'nfs_mount.exe' || (( numerr++ ))
- + require_cmd 'mountall_msnfs41client' || (( numerr++ ))
- require_cmd 'PsExec.exe' || (( numerr++ ))
- if ! is_windows_admin_account ; then
- printf $"%s: %q requires Windows Adminstator permissions.\n" "$0" "$cmd"
- diff --git a/cygwin/utils/mountall_msnfs41client/mountall_msnfs41client.ksh b/cygwin/utils/mountall_msnfs41client/mountall_msnfs41client.ksh
- new file mode 100644
- index 0000000..be19983
- --- /dev/null
- +++ b/cygwin/utils/mountall_msnfs41client/mountall_msnfs41client.ksh
- @@ -0,0 +1,164 @@
- +#!/bin/ksh93
- +
- +#
- +# MIT License
- +#
- +# Copyright (c) 2024 Roland Mainz <roland.mainz@nrubsig.org>
- +#
- +# Permission is hereby granted, free of charge, to any person obtaining a copy
- +# of this software and associated documentation files (the "Software"), to deal
- +# in the Software without restriction, including without limitation the rights
- +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- +# copies of the Software, and to permit persons to whom the Software is
- +# furnished to do so, subject to the following conditions:
- +#
- +# The above copyright notice and this permission notice shall be included in all
- +# copies or substantial portions of the Software.
- +#
- +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- +# SOFTWARE.
- +#
- +
- +#
- +# mountall_msnfs41client.ksh93 - mount all msnfs41client NFSv4.1
- +# filesystems listed in /etc/fstab.msnfs41client
- +#
- +
- +#
- +# Written by Roland Mainz <roland.mainz@nrubsig.org>
- +#
- +
- +
- +function parse_fstab_data
- +{
- + nameref fstab_entries=$1
- + integer currline=0
- + typeset leftover
- + typeset s
- +
- + for ((currline=0 ; ; currline++ )) ; do
- + read -r s || break
- + # skip empty lines+lines with spaces only
- + if [[ "$s" == ~(Elr)[[:space:]]* ]] ; then
- + continue
- + fi
- +
- + IFS=$' \t\n' read -r \
- + fs_spec \
- + fs_file \
- + fs_vfstype \
- + fs_mntops \
- + fs_freq \
- + fs_passno leftover <<<"$s" || break
- + if [[ "${fs_spec}" == ~(El)[[:space:]]*# ]] ; then
- + continue
- + fi
- + if [[ $leftover != '' ]] ; then
- + print -u2 -f $"%s: Parsing error in line %d\n" "$0" currline
- + continue
- + fi
- +
- + fstab_entries+=(
- + fs_spec="$fs_spec"
- + fs_file="$fs_file"
- + fs_vfstype="$fs_vfstype"
- + fs_mntops="$fs_mntops"
- + fs_freq="$fs_freq"
- + fs_passno="$fs_passno"
- + )
- + done
- +
- + return 0
- +}
- +
- +function read_etc_fstab
- +{
- + nameref arr=$1
- +
- + if [[ ! -r "$2" ]] ; then
- + print -u2 -f $"%s: Cannot open file %q\n" "$0" "$2"
- + return 1
- + fi
- +
- + parse_fstab_data arr <"$2"
- + return $?
- +}
- +
- +function fstabentries2nfs_mount_lines
- +{
- + nameref arr=$1
- + typeset i
- +
- + for i in "${!arr[@]}" ; do
- + nameref currfstabentry=arr[$i]
- +
- + #print -v currfstabentry
- +
- + if [[ "${currfstabentry.fs_vfstype}" != 'nfs' ]] ; then
- + continue
- + fi
- +
- + printf 'nfs_mount -o %q %q %q\n' \
- + "${currfstabentry.fs_mntops}" \
- + "${currfstabentry.fs_file}" \
- + "${currfstabentry.fs_spec}"
- + done
- + return 0
- +}
- +
- +function main
- +{
- + set -o errexit
- + compound c
- + compound -a c.fstab_entries
- +
- + # fixme: not implemented yet
- + if [[ "$1" == '--nroff' ]] ; then
- + return 0
- + fi
- +
- + printf $"# Start.\n"
- +
- + id -a
- +
- + read_etc_fstab c.fstab_entries '/etc/fstab.msnfs41client'
- +
- + cmdline="${ fstabentries2nfs_mount_lines c.fstab_entries ; }"
- +
- + #
- + # FIXME: We should wait until nfsd*.exe is
- + # running
- + #
- +
- + set -o xtrace
- + source '/dev/stdin' <<<"$cmdline"
- + set +o xtrace
- +
- + printf $"# Done.\n"
- + return 0
- +}
- +
- +
- +#
- +# Main
- +#
- +
- +export PATH='/bin:/usr/bin:/sbin:/usr/sbin'
- +# add dir (usually "/sbin") in front of PATH so we pick-up
- +# nfs_mount.
- +PATH="$(dirname "${.sh.file}"):$PATH"
- +printf '# PATH=%q\n' "$PATH"
- +
- +builtin basename
- +builtin dirname
- +builtin id
- +
- +main "$@"
- +exit $?
- +
- +# EOF.
- --
- 2.45.1
msnfs41client: Patch for global mount service, 2024-09-23
Posted by Anonymous on Mon 23rd Sep 2024 17:30
raw | new post
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.