pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


msnfs41client: owner/group name caching prototype
Posted by Anonymous on Thu 19th Oct 2023 15:13
raw | new post
view followups (newest first): msnfs41client: owner/group name caching prototype by Anonymous

  1. diff --git a/daemon/acl.c b/daemon/acl.c
  2. index 1d1eac4..9c30eeb 100644
  3. --- a/daemon/acl.c
  4. +++ b/daemon/acl.c
  5. @@ -223,6 +223,19 @@ static int map_name_2_sid(nfs41_daemon_globals *nfs41dg, int query, DWORD *sid_l
  6.              name = "roland_mainz";
  7.              dprintf(ACLLVL, "map_name_2_sid: remap 1616 --> roland_mainz\n");
  8.          }
  9. +        else if (!strcmp(name, "swulsch")) {
  10. +            name = "siegfried_wulsch";
  11. +            dprintf(ACLLVL, "map_name_2_sid: remap swulsch --> siegfried_wulsch\n");
  12. +        }
  13. +        else if (!strcmp(name, "197609")) {
  14. +            name = "siegfried_wulsch";
  15. +            dprintf(ACLLVL, "map_name_2_sid: remap 197609 --> siegfried_wulsch\n");
  16. +        }
  17. +        else if (!strcmp(name, "1818")) {
  18. +            name = "siegfried_wulsch";
  19. +            dprintf(ACLLVL, "map_name_2_sid: remap 1818 --> siegfried_wulsch\n");
  20. +        }
  21. +
  22.      }
  23.  #endif /* NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID */
  24.  
  25. diff --git a/daemon/lookup.c b/daemon/lookup.c
  26. index ea0a9d2..a2862de 100644
  27. --- a/daemon/lookup.c
  28. +++ b/daemon/lookup.c
  29. @@ -85,7 +85,8 @@ static void init_component_args(
  30.      args->attr_request.arr[1] = FATTR4_WORD1_MODE
  31.          | FATTR4_WORD1_NUMLINKS | FATTR4_WORD1_SYSTEM
  32.          | FATTR4_WORD1_TIME_ACCESS | FATTR4_WORD1_TIME_CREATE
  33. -        | FATTR4_WORD1_TIME_MODIFY;
  34. +        | FATTR4_WORD1_TIME_MODIFY
  35. +        | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
  36.  
  37.      args->getrootattr.attr_request = &args->attr_request;
  38.      res->root.path = path;
  39. diff --git a/daemon/name_cache.c b/daemon/name_cache.c
  40. index eaa0f36..3770214 100644
  41. --- a/daemon/name_cache.c
  42. +++ b/daemon/name_cache.c
  43. @@ -401,7 +401,11 @@ struct nfs41_name_cache {
  44.  static __inline bool_t name_cache_enabled(
  45.      IN struct nfs41_name_cache *cache)
  46.  {
  47. +#if 1
  48. +    return 0; /* fixme: caching of owner/owner_group not supported yet */
  49. +#else
  50.      return cache->expiration > 0;
  51. +#endif
  52.  }
  53.  
  54.  static __inline void name_cache_entry_rename(
  55. diff --git a/daemon/nfs41_types.h b/daemon/nfs41_types.h
  56. index c5bad79..abdf2c2 100644
  57. --- a/daemon/nfs41_types.h
  58. +++ b/daemon/nfs41_types.h
  59. @@ -236,6 +236,10 @@ typedef struct __nfs41_file_info {
  60.      char                    *owner;
  61.      char                    *owner_group;
  62.      uint32_t                aclsupport;
  63. +    
  64. +    /* Buffers */
  65. +    char owner_buf[NFS4_OPAQUE_LIMIT+1];
  66. +    char owner_group_buf[NFS4_OPAQUE_LIMIT+1];
  67.  } nfs41_file_info;
  68.  
  69.  #endif /* !__NFS41_DAEMON_TYPES_H__ */
  70. diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
  71. index 176b613..94f6d4a 100644
  72. --- a/daemon/nfs41_xdr.c
  73. +++ b/daemon/nfs41_xdr.c
  74. @@ -1802,19 +1802,31 @@ static bool_t decode_file_attrs(
  75.                  return FALSE;
  76.          }
  77.          if (attrs->attrmask.arr[1] & FATTR4_WORD1_OWNER) {
  78. -            char *ptr = &info->owner[0];
  79. +            if (info->owner == NULL)
  80. +                info->owner = info->owner_buf;
  81. +
  82. +            char *ptr = info->owner;
  83.              uint32_t owner_len;
  84.              if (!xdr_bytes(xdr, &ptr, &owner_len,
  85. -                            NFS4_OPAQUE_LIMIT))
  86. +                            NFS4_OPAQUE_LIMIT)) {
  87. +                info->owner = NULL;
  88.                  return FALSE;
  89. +            }
  90. +            /* fixme: add assert |owner_len < buffer size| */
  91.              info->owner[owner_len] = '\0';
  92.          }
  93.          if (attrs->attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) {
  94. -            char *ptr = &info->owner_group[0];
  95. +            if (info->owner_group == NULL)
  96. +                info->owner_group = info->owner_group_buf;
  97. +
  98. +            char *ptr = info->owner_group;
  99.              uint32_t owner_group_len;
  100.              if (!xdr_bytes(xdr, &ptr, &owner_group_len,
  101. -                            NFS4_OPAQUE_LIMIT))
  102. +                            NFS4_OPAQUE_LIMIT)) {
  103. +                info->owner_group = NULL;
  104.                  return FALSE;
  105. +            }
  106. +            /* fixme: add assert |owner_len < buffer size| */
  107.              info->owner_group[owner_group_len] = '\0';
  108.          }
  109.          if (attrs->attrmask.arr[1] & FATTR4_WORD1_SPACE_AVAIL) {
  110. diff --git a/daemon/open.c b/daemon/open.c
  111. index 13e82b2..1b60296 100644
  112. --- a/daemon/open.c
  113. +++ b/daemon/open.c
  114. @@ -665,9 +665,11 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  115.  #ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  116.          bitmap4 og_attr_request = { 0 };
  117.          nfs41_file_info og_info = { 0 };
  118. -        char owner[NFS4_OPAQUE_LIMIT], group[NFS4_OPAQUE_LIMIT];
  119.          nfsacl41 acl = { 0 };
  120.  
  121. +#if 1
  122. +        (void)memcpy(&og_info, &info, sizeof(nfs41_file_info));
  123. +#else
  124.          /*
  125.           * gisburn:
  126.           * 1. We should cache owner/group information
  127. @@ -677,14 +679,16 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  128.           */
  129.          og_attr_request.count = 2;
  130.          og_attr_request.arr[1] = FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
  131. -        og_info.owner = owner;
  132. -        og_info.owner_group = group;
  133. +        /* nfs41_getattr() will give us |og_info.owner_buf| on success */
  134. +        og_info.owner = NULL;
  135. +        /* nfs41_getattr() will give us |og_info.owner_group_buf| on success */
  136. +        og_info.owner_group = NULL;
  137.          status = nfs41_getattr(state->session, &state->file, &og_attr_request, &og_info);
  138.          if (status) {
  139.              eprintf("get_stat_data: nfs41_cached_getattr() failed with %d\n",
  140.              status);
  141.          }
  142. -
  143. +#endif
  144.          uid_t map_uid = -1;
  145.          gid_t gid_dummy = -1;
  146.          gid_t map_gid = -1;
  147. diff --git a/sys/nfs41_build_features.h b/sys/nfs41_build_features.h
  148. index 93ee7a9..d43334a 100644
  149. --- a/sys/nfs41_build_features.h
  150. +++ b/sys/nfs41_build_features.h
  151. @@ -32,19 +32,19 @@
  152.  /*
  153.   * NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES - return local uid/gid values
  154.   */
  155. -// #define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
  156. +#define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
  157.  
  158.  /*
  159.   * NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID - give NFS
  160.   * files which do not map to a local account a SID in the
  161.   * Unix_User+x/Unix_Group+x range
  162.   */
  163. -// #define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
  164. +#define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
  165.  
  166.  /*
  167.   * NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN - use Cygwin /usr/bin/getent
  168.   * as "name service"
  169.   */
  170. -// #define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
  171. +#define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
  172.  
  173.  #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */

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