pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for NFSv4.1 client identification+misc, 2024-03-13
Posted by Anonymous on Wed 13th Mar 2024 18:33
raw | new post

  1. From bb7a987aef144520be8b3f085aac50aee7194119 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Wed, 13 Mar 2024 18:27:46 +0100
  4. Subject: [PATCH 1/2] cygwin: bintarball README should automagically get
  5.  filename+sha256 hash [refix]
  6.  
  7. Fix tarball generation, which was disabled by accident in the original commit.
  8.  
  9. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  10. ---
  11. cygwin/Makefile | 2 +-
  12.  1 file changed, 1 insertion(+), 1 deletion(-)
  13.  
  14. diff --git a/cygwin/Makefile b/cygwin/Makefile
  15. index 71afd3c..4052c21 100644
  16. --- a/cygwin/Makefile
  17. +++ b/cygwin/Makefile
  18. @@ -111,7 +111,7 @@ bintarball: installdest
  19.         base_filename="msnfs41client_cygwin_binaries_$$(date +%Y%m%d_%Hh%Mm)_git$$(git rev-parse --short HEAD)" ; \
  20.         ( \
  21.         cd "$(DESTDIR)" && \
  22. -       true tar -cvf - \
  23. +       tar -cvf - \
  24.                 --owner=SYSTEM:18 \
  25.                 --group=SYSTEM:18 \
  26.                 cygdrive/c/cygwin64 | \
  27. --
  28. 2.43.0
  29.  
  30. From 9ba02b3b9456b860edc32e1bebb1e19ef3240074 Mon Sep 17 00:00:00 2001
  31. From: Roland Mainz <roland.mainz@nrubsig.org>
  32. Date: Wed, 13 Mar 2024 18:53:00 +0100
  33. Subject: [PATCH 2/2] daemon: The client should identify itself via NFSv4.1
  34.  |nii_name| and |nii_domain|
  35.  
  36. We should provide values for |nii_name| and |nii_domain| so NFSv4.1
  37. server admins can properly idently our NFSv4.1 client, e.g.
  38. on Linux via $ grep -E 'Implementation' /proc/fs/nfsd/clients/*/info #
  39.  
  40. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  41. ---
  42. daemon/nfs41_daemon.c | 61 +++++++++++++++++++++++++++++++++++++++++++
  43.  daemon/nfs41_daemon.h |  1 +
  44.  daemon/nfs41_ops.c    | 20 +++++++++++++-
  45.  3 files changed, 81 insertions(+), 1 deletion(-)
  46.  
  47. diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
  48. index a7ce502..9ba7885 100644
  49. --- a/daemon/nfs41_daemon.c
  50. +++ b/daemon/nfs41_daemon.c
  51. @@ -520,6 +520,66 @@ void nfsd_crt_debug_init(void)
  52.  #endif /* _DEBUG */
  53.  }
  54.  
  55. +static
  56. +void init_version_string(void)
  57. +{
  58. +    char uname_buff[256];
  59. +    char *s;
  60. +    DWORD buff_read;
  61. +
  62. +    /*
  63. +     * gisburn: fixme:
  64. +     * We should get the Windows version numbers from the
  65. +     * Windows registry, unfortunately this is going to be a
  66. +     * another variantion of vesion hell, as |GetVersionEx()|
  67. +     * is depreciated
  68. +     */
  69. +    subcmd_popen_context *scmd_uname = subcmd_popen("C:\\cygwin64\\bin\\uname.exe -a");
  70. +    if (scmd_uname) {
  71. +        buff_read = 0;
  72. +        if (subcmd_readcmdoutput(scmd_uname, uname_buff, sizeof(uname_buff), &buff_read)) {
  73. +            /* Remove trailing newline */
  74. +            if ((buff_read > 0) && (uname_buff[buff_read-1] == '\n'))
  75. +                uname_buff[buff_read-1] = '\0';
  76. +            else
  77. +                uname_buff[buff_read] = '\0';
  78. +
  79. +            /* Stomp newline&co. */
  80. +            for (s = uname_buff ; *s != '\0' ; s++) {
  81. +                if ((*s == '\n') || (*s == '\r'))
  82. +                    *s = ' ';
  83. +            }
  84. +        }
  85. +        else {
  86. +            eprintf("init_version_string: subcmd_readcmdoutput() for 'uname -a' failed\n");
  87. +            uname_buff[0] = '\0';
  88. +        }
  89. +        subcmd_pclose(scmd_uname);
  90. +    }
  91. +    else {
  92. +        eprintf("init_version_string: subcmd_popen() for 'uname -a' failed\n");
  93. +        uname_buff[0] = '\0';
  94. +    }
  95. +
  96. +    /*
  97. +     * gisburn: fixme:
  98. +     * 1. We should include cygwin uname output only in Cygwin mode
  99. +     * 2. We should determinate the Windows version numvber ourselves
  100. +     * 3. We should include our own version and git tag
  101. +     * 4. We should honor RFC5661: "... it is RECOMMENDED
  102. +     *   that the nii_name be used to distinguish machine architecture,
  103. +     *   machine platforms, revisions, versions, and patch levels. The
  104. +     *   nii_date field is the timestamp of when the software instance
  105. +     *   was published or built..."
  106. +     */
  107. +    (void)snprintf(nfs41_dg.nfs41_nii_name,
  108. +        sizeof(nfs41_dg.nfs41_nii_name),
  109. +        "msnfs41client 0.1 WinNT NFSv4.1 client, cygwin_vers='%s'",
  110. +        uname_buff);
  111. +    DPRINTF(1, ("init_version_string: versionstring='%s'\n",
  112. +        nfs41_dg.nfs41_nii_name));
  113. +}
  114. +
  115.  #ifdef STANDALONE_NFSD
  116.  void __cdecl _tmain(int argc, TCHAR *argv[])
  117.  #else
  118. @@ -539,6 +599,7 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv)
  119.          exit(1);
  120.      set_debug_level(cmd_args.debug_level);
  121.      open_log_files();
  122. +    init_version_string();
  123.      nfsd_crt_debug_init();
  124.  #ifdef NFS41_DRIVER_SID_CACHE
  125.      sidcache_init();
  126. diff --git a/daemon/nfs41_daemon.h b/daemon/nfs41_daemon.h
  127. index 9801379..2ab4366 100644
  128. --- a/daemon/nfs41_daemon.h
  129. +++ b/daemon/nfs41_daemon.h
  130. @@ -40,6 +40,7 @@ typedef struct __nfs41_daemon_globals {
  131.      int default_gid;
  132.      ssize_t num_worker_threads;
  133.      int crtdbgmem_flags;
  134. +    char nfs41_nii_name[256];
  135.  } nfs41_daemon_globals;
  136.  
  137.  #define NFS41D_GLOBALS_CRTDBGMEM_FLAGS_NOT_SET (-1)
  138. diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c
  139. index f5dce66..4790484 100644
  140. --- a/daemon/nfs41_ops.c
  141. +++ b/daemon/nfs41_ops.c
  142. @@ -27,6 +27,7 @@
  143.  #include <time.h>
  144.  
  145.  #include "nfs41_build_features.h"
  146. +#include "nfs41_daemon.h"
  147.  #include "nfs41_ops.h"
  148.  #include "nfs41_compound.h"
  149.  #include "nfs41_xdr.h"
  150. @@ -60,14 +61,31 @@ int nfs41_exchange_id(
  151.      nfs_argop4 argop;
  152.      nfs_resop4 resop;
  153.      nfs41_exchange_id_args ex_id;
  154. +    nfs_impl_id4 impl_id = { 0 };
  155. +
  156. +    /* fixme: This should be a function argument */
  157. +    extern nfs41_daemon_globals nfs41_dg;
  158.  
  159.      compound_init(&compound, &argop, &resop, "exchange_id");
  160.  
  161.      compound_add_op(&compound, OP_EXCHANGE_ID, &ex_id, res_out);
  162. +
  163. +    /* gisburn: fixme: We do not have that domain yet */
  164. +    impl_id.nii_domain      = "msnfs41client.org";
  165. +    impl_id.nii_domain_len  = (uint32_t)strlen(impl_id.nii_domain);
  166. +    impl_id.nii_name        = nfs41_dg.nfs41_nii_name;
  167. +    impl_id.nii_name_len    = (uint32_t)strlen(impl_id.nii_name);
  168. +    /*
  169. +     * gisburn: fixme: |impl_id.nii_date| should be the timestamp
  170. +     * of the binary
  171. +     */
  172. +    impl_id.nii_date.seconds = 0LL;
  173. +    impl_id.nii_date.nseconds = 0UL;
  174. +
  175.      ex_id.eia_clientowner = owner;
  176.      ex_id.eia_flags = flags_in;
  177.      ex_id.eia_state_protect.spa_how = SP4_NONE;
  178. -    ex_id.eia_client_impl_id = NULL;
  179. +    ex_id.eia_client_impl_id = &impl_id;
  180.  
  181.      res_out->server_owner.so_major_id_len = NFS4_OPAQUE_LIMIT;
  182.      res_out->server_scope_len = NFS4_OPAQUE_LIMIT;
  183. --
  184. 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