pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


msnfs41client: owner/group name caching prototype
Posted by Anonymous on Thu 19th Oct 2023 18:05
raw | new post
view followups (newest first): msnfs41client: owner/group name caching prototype by Anonymous
modification of post by Anonymous (view diff)

  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/daemon_debug.h b/daemon/daemon_debug.h
  26. index f484d58..85b0507 100644
  27. --- a/daemon/daemon_debug.h
  28. +++ b/daemon/daemon_debug.h
  29. @@ -34,6 +34,11 @@
  30.  #define DEFAULT_DEBUG_LEVEL 1
  31.  
  32.  
  33. +#define DASSERT(exp) \
  34. +    if (!(exp)) { \
  35. +        dprintf(0, "ASSERTION '%s' in %s/%ld failed.\n", \
  36. +            __FILE__, (long)__LINE__, ""#exp""); }
  37. +
  38.  /* daemon_debug.h */
  39.  void set_debug_level(int level);
  40.  void dprintf(int level, LPCSTR format, ...);
  41. diff --git a/daemon/lookup.c b/daemon/lookup.c
  42. index ea0a9d2..a2862de 100644
  43. --- a/daemon/lookup.c
  44. +++ b/daemon/lookup.c
  45. @@ -85,7 +85,8 @@ static void init_component_args(
  46.      args->attr_request.arr[1] = FATTR4_WORD1_MODE
  47.          | FATTR4_WORD1_NUMLINKS | FATTR4_WORD1_SYSTEM
  48.          | FATTR4_WORD1_TIME_ACCESS | FATTR4_WORD1_TIME_CREATE
  49. -        | FATTR4_WORD1_TIME_MODIFY;
  50. +        | FATTR4_WORD1_TIME_MODIFY
  51. +        | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
  52.  
  53.      args->getrootattr.attr_request = &args->attr_request;
  54.      res->root.path = path;
  55. diff --git a/daemon/name_cache.c b/daemon/name_cache.c
  56. index eaa0f36..3770214 100644
  57. --- a/daemon/name_cache.c
  58. +++ b/daemon/name_cache.c
  59. @@ -401,7 +401,11 @@ struct nfs41_name_cache {
  60.  static __inline bool_t name_cache_enabled(
  61.      IN struct nfs41_name_cache *cache)
  62.  {
  63. +#if 1
  64. +    return 0; /* fixme: caching of owner/owner_group not supported yet */
  65. +#else
  66.      return cache->expiration > 0;
  67. +#endif
  68.  }
  69.  
  70.  static __inline void name_cache_entry_rename(
  71. diff --git a/daemon/nfs41_types.h b/daemon/nfs41_types.h
  72. index c5bad79..18a763a 100644
  73. --- a/daemon/nfs41_types.h
  74. +++ b/daemon/nfs41_types.h
  75. @@ -236,6 +236,10 @@ typedef struct __nfs41_file_info {
  76.      char                    *owner;
  77.      char                    *owner_group;
  78.      uint32_t                aclsupport;
  79. +
  80. +    /* Buffers */
  81. +    char owner_buf[NFS4_OPAQUE_LIMIT+1];
  82. +    char owner_group_buf[NFS4_OPAQUE_LIMIT+1];
  83.  } nfs41_file_info;
  84.  
  85.  #endif /* !__NFS41_DAEMON_TYPES_H__ */
  86. diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
  87. index 176b613..67c9bf6 100644
  88. --- a/daemon/nfs41_xdr.c
  89. +++ b/daemon/nfs41_xdr.c
  90. @@ -1802,19 +1802,33 @@ static bool_t decode_file_attrs(
  91.                  return FALSE;
  92.          }
  93.          if (attrs->attrmask.arr[1] & FATTR4_WORD1_OWNER) {
  94. -            char *ptr = &info->owner[0];
  95. +            if (info->owner == NULL)
  96. +                info->owner = info->owner_buf;
  97. +
  98. +            char *ptr = info->owner;
  99.              uint32_t owner_len;
  100.              if (!xdr_bytes(xdr, &ptr, &owner_len,
  101. -                            NFS4_OPAQUE_LIMIT))
  102. +                            NFS4_OPAQUE_LIMIT)) {
  103. +                info->owner = NULL;
  104.                  return FALSE;
  105. +            }
  106. +            DASSERT(owner_len > 0);
  107. +            DASSERT(owner_len < sizeof(info->owner_group_buf));
  108.              info->owner[owner_len] = '\0';
  109.          }
  110.          if (attrs->attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) {
  111. -            char *ptr = &info->owner_group[0];
  112. +            if (info->owner_group == NULL)
  113. +                info->owner_group = info->owner_group_buf;
  114. +
  115. +            char *ptr = info->owner_group;
  116.              uint32_t owner_group_len;
  117.              if (!xdr_bytes(xdr, &ptr, &owner_group_len,
  118. -                            NFS4_OPAQUE_LIMIT))
  119. +                            NFS4_OPAQUE_LIMIT)) {
  120. +                info->owner_group = NULL;
  121.                  return FALSE;
  122. +            }
  123. +            DASSERT(owner_group_len > 0);
  124. +            DASSERT(owner_group_len < sizeof(info->owner_group_buf));
  125.              info->owner_group[owner_group_len] = '\0';
  126.          }
  127.          if (attrs->attrmask.arr[1] & FATTR4_WORD1_SPACE_AVAIL) {
  128. diff --git a/daemon/open.c b/daemon/open.c
  129. index 13e82b2..d1220b3 100644
  130. --- a/daemon/open.c
  131. +++ b/daemon/open.c
  132. @@ -664,32 +664,19 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  133.  
  134.  #ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  135.          bitmap4 og_attr_request = { 0 };
  136. -        nfs41_file_info og_info = { 0 };
  137. -        char owner[NFS4_OPAQUE_LIMIT], group[NFS4_OPAQUE_LIMIT];
  138. +        char owner[NFS4_OPAQUE_LIMIT], owner_group[NFS4_OPAQUE_LIMIT];
  139.          nfsacl41 acl = { 0 };
  140.  
  141. -        /*
  142. -         * gisburn:
  143. -         * 1. We should cache owner/group information
  144. -         * 2. We should always ask for
  145. -         * FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP with the other
  146. -         * attributes
  147. -         */
  148. -        og_attr_request.count = 2;
  149. -        og_attr_request.arr[1] = FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
  150. -        og_info.owner = owner;
  151. -        og_info.owner_group = group;
  152. -        status = nfs41_getattr(state->session, &state->file, &og_attr_request, &og_info);
  153. -        if (status) {
  154. -            eprintf("get_stat_data: nfs41_cached_getattr() failed with %d\n",
  155. -            status);
  156. -        }
  157. -
  158.          uid_t map_uid = -1;
  159.          gid_t gid_dummy = -1;
  160.          gid_t map_gid = -1;
  161.          char *at_ch; /* pointer to '@' */
  162.  
  163. +        DASSERT(info.owner != NULL);
  164. +        DASSERT(info.owner_group != NULL);
  165. +        (void)strcpy(owner, info.owner?info.owner:"<FIXME_OWNER>");
  166. +        (void)strcpy(owner_group, info.owner_group?info.owner_group:"<FIXME_GROUP>");
  167. +
  168.          /*
  169.           * Map owner to local uid
  170.           *
  171. @@ -697,12 +684,12 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  172.           *  ("gisburn") or username@domain ("gisburn@sun.com")
  173.           */
  174.          /* stomp over '@' */
  175. -        if (at_ch = strchr(og_info.owner, '@'))
  176. +        if (at_ch = strchr(owner, '@'))
  177.              *at_ch = '\0';
  178.  
  179.          if (nfs41_idmap_name_to_ids(
  180.              nfs41dg->idmapper,
  181. -            og_info.owner,
  182. +            owner,
  183.              &map_uid,
  184.              &gid_dummy) == 0) {
  185.               args->owner_local_uid = map_uid;
  186. @@ -711,7 +698,7 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  187.              args->owner_local_uid = NFS_USER_NOBODY_UID;
  188.              eprintf("get_stat_data: "
  189.                  "no username mapping for '%s', fake uid=%d\n",
  190. -                og_info.owner, args->owner_local_uid);
  191. +                owner, args->owner_local_uid);
  192.          }
  193.  
  194.          /*
  195. @@ -721,12 +708,12 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  196.           * ("gisgrp") or username@domain ("gisgrp@sun.com")
  197.           */
  198.          /* stomp over '@' */
  199. -        if (at_ch = strchr(og_info.owner_group, '@'))
  200. +        if (at_ch = strchr(owner_group, '@'))
  201.              *at_ch = '\0';
  202.  
  203.          if (nfs41_idmap_group_to_gid(
  204.              nfs41dg->idmapper,
  205. -            og_info.owner_group,
  206. +            owner_group,
  207.              &map_gid) == 0) {
  208.              args->owner_group_local_gid = map_gid;
  209.          }
  210. @@ -734,12 +721,12 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  211.              args->owner_group_local_gid = NFS_GROUP_NOGROUP_GID;
  212.              eprintf("get_stat_data: "
  213.                  "no group mapping for '%s', fake gid=%d\n",
  214. -                og_info.owner_group, args->owner_group_local_gid);
  215. +                owner_group, args->owner_group_local_gid);
  216.          }
  217.  
  218.          dprintf(1, "handle_open: stat: owner=%u/'%s', owner_group=%u/'%s'\n",
  219. -            (unsigned int)args->owner_local_uid, og_info.owner,
  220. -            (unsigned int)args->owner_group_local_gid, og_info.owner_group);
  221. +            (unsigned int)args->owner_local_uid, owner,
  222. +            (unsigned int)args->owner_group_local_gid, owner_group);
  223.  #endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  224.      } else {
  225.          nfs41_file_info createattrs = { 0 };
  226. diff --git a/sys/nfs41_build_features.h b/sys/nfs41_build_features.h
  227. index 93ee7a9..d43334a 100644
  228. --- a/sys/nfs41_build_features.h
  229. +++ b/sys/nfs41_build_features.h
  230. @@ -32,19 +32,19 @@
  231.  /*
  232.   * NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES - return local uid/gid values
  233.   */
  234. -// #define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
  235. +#define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
  236.  
  237.  /*
  238.   * NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID - give NFS
  239.   * files which do not map to a local account a SID in the
  240.   * Unix_User+x/Unix_Group+x range
  241.   */
  242. -// #define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
  243. +#define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
  244.  
  245.  /*
  246.   * NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN - use Cygwin /usr/bin/getent
  247.   * as "name service"
  248.   */
  249. -// #define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
  250. +#define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
  251.  
  252.  #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