pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


msnfs41client: diff -w tarball generation prototype+idmapper fix 2023-12-07
Posted by Anonymous on Thu 7th Dec 2023 14:19
raw | new post
view followups (newest first): msnfs41client: diff -w tarball generation prototype+idmapper fix 2023-12-07 by Anonymous
modification of post by Anonymous (view diff)

  1. diff --git a/cygwin/Makefile b/cygwin/Makefile
  2. index b7a3b1e..41e2340 100644
  3. --- a/cygwin/Makefile
  4. +++ b/cygwin/Makefile
  5. @@ -57,7 +57,11 @@ installdest: $(VS_BUILD_DIR)/nfsd.exe \
  6.         fi
  7.         mkdir -p $(DESTDIR)
  8.         mkdir -p $(DESTDIR)/cygdrive/c/cygwin64/sbin/
  9. -       mkdir -p $(DESTDIR)/cygdrive/c/cygwin64/usr/bin
  10. +       # /usr/bin is a bind mount to C:/cygwin64/bin, so copy binaries to /cygdrive/c/cygwin64/bin
  11. +       mkdir -p $(DESTDIR)/cygdrive/c/cygwin64/bin
  12. +       # /usr/lib is a bind mount to C:/cygwin64/lib, so copy library data to /cygdrive/c/cygwin64/lib
  13. +       mkdir -p $(DESTDIR)/cygdrive/c/cygwin64/lib
  14. +       mkdir -p $(DESTDIR)/cygdrive/c/cygwin64/lib/msnfs41client
  15.         cp -r $(VS_BUILD_DIR)/nfsd.exe          $(DESTDIR)/cygdrive/c/cygwin64/sbin/nfsd_debug.exe
  16.         cp -r $(VS_BUILD_DIR)/nfsd.pdb          $(DESTDIR)/cygdrive/c/cygwin64/sbin/nfsd_debug.pdb
  17.         cp -r $(VS_BUILD_DIR)/nfs_mount.*       $(DESTDIR)/cygdrive/c/cygwin64/sbin/.
  18. @@ -70,15 +74,16 @@ installdest: $(VS_BUILD_DIR)/nfsd.exe \
  19.         cp $(PROJECT_BASEDIR_DIR)/etc_netconfig $(DESTDIR)/cygdrive/c/cygwin64/sbin/.
  20.         cp $(PROJECT_BASEDIR_DIR)/ms-nfs41-idmap.conf           $(DESTDIR)/cygdrive/c/cygwin64/sbin/.
  21.         cp $(CYGWIN_MAKEFILE_DIR)/devel/msnfs41client.bash      $(DESTDIR)/cygdrive/c/cygwin64/sbin/.
  22. +       cp $(PROJECT_BASEDIR_DIR)/cygwin_idmapper.ksh           $(DESTDIR)/cygdrive/c/cygwin64/lib/msnfs41client/.
  23.         cp $(CYGWIN_MAKEFILE_DIR)/utils/mount_sshnfs/mount_sshnfs.ksh $(DESTDIR)/cygdrive/c/cygwin64/sbin/mount_sshnfs
  24.         chmod a+x $(DESTDIR)/cygdrive/c/cygwin64/sbin/mount_sshnfs
  25.         cp $(CYGWIN_MAKEFILE_DIR)/utils/sshnfs/sshnfs.ksh $(DESTDIR)/cygdrive/c/cygwin64/sbin/sshnfs
  26.         chmod a+x $(DESTDIR)/cygdrive/c/cygwin64/sbin/sshnfs
  27.         @ printf "# Package tests\n"
  28. -       cp tests/winfsinfo1/winfsinfo.exe $(DESTDIR)/cygdrive/c/cygwin64/usr/bin/winfsinfo.exe
  29. +       cp tests/winfsinfo1/winfsinfo.exe $(DESTDIR)/cygdrive/c/cygwin64/bin/winfsinfo.exe
  30.         @ printf "# Package ksh93&co (if available) since Cygwin does not ship with it yet\n"
  31. -       [[ -x /usr/bin/ksh93.exe ]] && cp /usr/bin/ksh93.exe $(DESTDIR)/cygdrive/c/cygwin64/usr/bin/ksh93.exe
  32. -       [[ -x /usr/bin/shcomp.exe ]] && cp /usr/bin/shcomp.exe $(DESTDIR)/cygdrive/c/cygwin64/usr/bin/shcomp.exe
  33. +       [[ -x /usr/bin/ksh93.exe ]] && cp /usr/bin/ksh93.exe $(DESTDIR)/cygdrive/c/cygwin64/bin/ksh93.exe
  34. +       [[ -x /usr/bin/shcomp.exe ]] && cp /usr/bin/shcomp.exe $(DESTDIR)/cygdrive/c/cygwin64/bin/shcomp.exe
  35.         @ printf "# Set file flags\n"
  36.         (cd $(DESTDIR)/cygdrive/c/cygwin64/sbin/ ; chmod a+x *.exe *.dll *.sys *.bash)
  37.         @printf "\n#\n# TEST sbin dir is %s\n#\n" "$(DESTDIR)/cygdrive/c/cygwin64/sbin/"
  38. @@ -86,6 +91,14 @@ installdest: $(VS_BUILD_DIR)/nfsd.exe \
  39.         @printf "\n#\n# Now use\n# $$ cd '%s' && bash ./msnfs41client.bash install #\n# to install the kernel driver as Admin\n#\n" \
  40.                 "$(DESTDIR)/cygdrive/c/cygwin64/sbin/"
  41.  
  42. +bintarball: installdest
  43. +       (cd destdir && \
  44. +       tar -cvf - \
  45. +               --owner=SYSTEM \
  46. +               --group=SYSTEM \
  47. +               cygdrive/c/cygwin64 | \
  48. +                       bzip2 -9 >msnfs41client_cygwin_binaries.tar.bz2)
  49. +
  50.  #
  51.  # clean destdir/, but only if nfsd*.exe does not use it right now
  52.  #
  53. @@ -94,6 +107,6 @@ cleandest:
  54.                 printf 'DIR %q is in use by a process\n' "$DESTDIR" 1>&2 ; \
  55.                 exit 1 ; \
  56.         fi
  57. -       rm -r "$(DESTDIR)"
  58. +       rm -rf "$(DESTDIR)"
  59.  
  60.  # EOF.
  61. diff --git a/daemon/getattr.c b/daemon/getattr.c
  62. index 7c5f241..7621dba 100644
  63. --- a/daemon/getattr.c
  64. +++ b/daemon/getattr.c
  65. @@ -59,8 +59,19 @@ int nfs41_cached_getattr(
  66.  static int parse_getattr(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
  67.  {
  68.      int status;
  69. +#if 1
  70. +    EASSERT(length > 4);
  71. +    if (length <= 4) {
  72. +        status = ERROR_INVALID_PARAMETER;
  73. +        goto out;
  74. +    }
  75. +    EASSERT(upcall->state_ref != NULL);
  76. +    if (upcall->state_ref == NULL) {
  77. +        status = ERROR_INVALID_PARAMETER;
  78. +        goto out;
  79. +    }
  80. +#endif
  81.      getattr_upcall_args *args = &upcall->args.getattr;
  82. -
  83.      status = safe_read(&buffer, &length, &args->query_class, sizeof(args->query_class));
  84.      if (status) goto out;
  85.      status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
  86. @@ -80,6 +91,21 @@ static int handle_getattr(void *daemon_context, nfs41_upcall *upcall)
  87.      nfs41_open_state *state = upcall->state_ref;
  88.      nfs41_file_info info = { 0 };
  89.  
  90. +#if 1
  91. +    if (((char *)state->session) == ((char *)0xdddddddddddddddd)) {
  92. +        eprintf("handle_getattr: Invalid session pointer 0xdddddddddddddddd\n");
  93. +        status = ERROR_INVALID_PARAMETER;
  94. +        goto out;
  95. +    }
  96. +
  97. +    EASSERT(state->file.fh.superblock != NULL);
  98. +    if (state->file.fh.superblock == NULL) {
  99. +        /* gisburn: fixme: maybe this should be |ERROR_INTERNAL_ERROR| ? */
  100. +        status = ERROR_INVALID_PARAMETER;
  101. +        goto out;
  102. +    }
  103. +#endif
  104. +
  105.      status = nfs41_cached_getattr(state->session, &state->file, &info);
  106.      if (status) {
  107.          eprintf("nfs41_cached_getattr() failed with %d\n", status);
  108. diff --git a/daemon/idmap_cygwin.c b/daemon/idmap_cygwin.c
  109. index 64c1bff..f8bb74e 100644
  110. --- a/daemon/idmap_cygwin.c
  111. +++ b/daemon/idmap_cygwin.c
  112. @@ -40,7 +40,7 @@
  113.  
  114.  #define CYGWIN_IDMAPPER_SCRIPT \
  115.      ("C:\\cygwin64\\bin\\ksh93.exe " \
  116. -    "/home/roland_mainz/work/msnfs41_uidmapping/ms-nfs41-client/cygwin_idmapper.ksh")
  117. +    "/cygdrive/c/cygwin64/lib/msnfs41client/cygwin_idmapper.ksh")
  118.  
  119.  
  120.  #ifdef NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN
  121. diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
  122. index fe0683e..a43d51e 100644
  123. --- a/daemon/nfs41_daemon.c
  124. +++ b/daemon/nfs41_daemon.c
  125. @@ -415,7 +415,21 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv)
  126.  #ifdef _DEBUG
  127.      /* dump memory leaks to stderr on exit; this requires the debug heap,
  128.      /* available only when built in debug mode under visual studio -cbodley */
  129. -    _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
  130. +
  131. +    int crtsetdbgflags = 0;
  132. +    crtsetdbgflags |= _CRTDBG_ALLOC_MEM_DF;  /* use debug heap */
  133. +    crtsetdbgflags |= _CRTDBG_LEAK_CHECK_DF; /* report leaks on exit */
  134. +#if 1
  135. +    /*
  136. +     * _CRTDBG_DELAY_FREE_MEM_DF - Delay freeing of memory, but fill
  137. +     * memory blocks passed to |free()| with 0xdd. We rely on that to
  138. +     * see 0xdddddddddddddddd-pointers for use-after-free and catch
  139. +     * them in stress testing instead of having to deal with a core
  140. +     * dump
  141. +     */
  142. +    crtsetdbgflags |= _CRTDBG_DELAY_FREE_MEM_DF;
  143. +#endif
  144. +    (void)_CrtSetDbgFlag(crtsetdbgflags);
  145.      _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
  146.  
  147.      /*
  148. diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c
  149. index bcca070..f2a4f22 100644
  150. --- a/daemon/nfs41_ops.c
  151. +++ b/daemon/nfs41_ops.c
  152. @@ -400,6 +400,9 @@ int nfs41_open(
  153.      bool_t already_delegated = delegation->type == OPEN_DELEGATE_READ
  154.          || delegation->type == OPEN_DELEGATE_WRITE;
  155.  
  156. +    EASSERT(parent);
  157. +    EASSERT(parent->fh.superblock);
  158. +
  159.      /* depending on the claim type, OPEN expects CURRENT_FH set
  160.       * to either the parent directory, or to the file itself */
  161.      switch (claim->claim) {
  162. diff --git a/daemon/open.c b/daemon/open.c
  163. index 8c01ac1..1cbac2c 100644
  164. --- a/daemon/open.c
  165. +++ b/daemon/open.c
  166. @@ -99,6 +99,24 @@ static void open_state_free(
  167.  void nfs41_open_state_ref(
  168.      IN nfs41_open_state *state)
  169.  {
  170. +#if 1
  171. +    /*
  172. +     * gisburn: fixme: sometimes this happens under high parallel
  173. +     * usage with multiple mounts - but why ?
  174. +     * 0:038> kp
  175. +     * Child-SP          RetAddr           Call Site
  176. +     * 0000006d`431fde10 00007ff7`32f7d905 nfsd!nfs41_open_state_ref(struct __nfs41_open_state * state = 0x00000000`00000000)+0x31
  177. +     * 0000006d`431fdf30 00007ff7`32f4d284 nfsd!upcall_parse(unsigned char * buffer = 0x0000006d`431fe180 "???", unsigned int length = 8, struct __nfs41_upcall * upcall = 0x0000006d`431ff1e0)+0x2e5
  178. +     * 0000006d`431fe0b0 00007ffc`1ca24c7c nfsd!thread_main(void * args = 0x00007ff7`32fb6080)+0x144
  179. +     * 0000006d`431ffe00 00007ffc`4d4b7344 ucrtbased!thread_start<unsigned int (void * parameter = 0x0000025d`a9c6def0)+0x9c
  180. +     * 0000006d`431ffe60 00007ffc`4efc26b1 KERNEL32!BaseThreadInitThunk+0x14
  181. +     * 0000006d`431ffe90 00000000`00000000 ntdll!RtlUserThreadStart+0x21
  182. +     */
  183. +    EASSERT(state != NULL);
  184. +    if (state == NULL)
  185. +        return;
  186. +#endif
  187. +
  188.      const LONG count = InterlockedIncrement(&state->ref_count);
  189.  
  190.      dprintf(2, "nfs41_open_state_ref(%s) count %d\n", state->path.path, count);
  191. diff --git a/daemon/upcall.c b/daemon/upcall.c
  192. index bd13c61..7778429 100644
  193. --- a/daemon/upcall.c
  194. +++ b/daemon/upcall.c
  195. @@ -121,6 +121,7 @@ int upcall_parse(
  196.      /* parse the operation's arguments */
  197.      op = g_upcall_op_table[upcall->opcode];
  198.      if (op && op->parse) {
  199. +        EASSERT(length > 0);
  200.          status = op->parse(buffer, length, upcall);
  201.          if (status) {
  202.              eprintf("parsing of upcall '%s' failed with %d.\n",
  203. diff --git a/sys/nfs41_build_features.h b/sys/nfs41_build_features.h
  204. index 93ee7a9..d43334a 100644
  205. --- a/sys/nfs41_build_features.h
  206. +++ b/sys/nfs41_build_features.h
  207. @@ -32,19 +32,19 @@
  208.  /*
  209.   * NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES - return local uid/gid values
  210.   */
  211. -// #define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
  212. +#define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
  213.  
  214.  /*
  215.   * NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID - give NFS
  216.   * files which do not map to a local account a SID in the
  217.   * Unix_User+x/Unix_Group+x range
  218.   */
  219. -// #define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
  220. +#define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
  221.  
  222.  /*
  223.   * NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN - use Cygwin /usr/bin/getent
  224.   * as "name service"
  225.   */
  226. -// #define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
  227. +#define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
  228.  
  229.  #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */
  230. diff --git a/tests/winlocktest1/winlocktest1.ksh b/tests/winlocktest1/winlocktest1.ksh
  231. old mode 100644
  232. new mode 100755

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