pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


msnfs41client: Fix assertions for new files/dirs for owner/owner_group
Posted by Anonymous on Tue 24th Oct 2023 12:52
raw | new post

  1. diff --git a/daemon/acl.c b/daemon/acl.c
  2. index 1d1eac4..4297722 100644
  3. --- a/daemon/acl.c
  4. +++ b/daemon/acl.c
  5. @@ -223,6 +223,18 @@ 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.  #endif /* NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID */
  23.  
  24. diff --git a/daemon/getattr.c b/daemon/getattr.c
  25. index 7c5f241..8595f5c 100644
  26. --- a/daemon/getattr.c
  27. +++ b/daemon/getattr.c
  28. @@ -80,6 +80,12 @@ static int handle_getattr(void *daemon_context, nfs41_upcall *upcall)
  29.      nfs41_open_state *state = upcall->state_ref;
  30.      nfs41_file_info info = { 0 };
  31.  
  32. +    if (((char *)state->session) == ((char *)0xdddddddddddddddd)) {
  33. +        eprintf("handle_getattr: Invalid session pointer 0xdddddddddddddddd\n");
  34. +        status = ERROR_INVALID_PARAMETER;
  35. +        goto out;
  36. +    }
  37. +
  38.      status = nfs41_cached_getattr(state->session, &state->file, &info);
  39.      if (status) {
  40.          eprintf("nfs41_cached_getattr() failed with %d\n", status);
  41. diff --git a/daemon/name_cache.c b/daemon/name_cache.c
  42. index 3f944fd..5bb6aee 100644
  43. --- a/daemon/name_cache.c
  44. +++ b/daemon/name_cache.c
  45. @@ -351,12 +351,24 @@ static void copy_attrs(
  46.      dst->type = src->type;
  47.      dst->numlinks = src->numlinks;
  48.      dst->mode = src->mode;
  49. -    EASSERT(src->owner != NULL);
  50. +    EASSERT(src->owner[0] != '\0');
  51. +    if (src->owner[0] != '\0') {
  52.          dst->owner = dst->owner_buf;
  53.          (void)strcpy(dst->owner, src->owner);
  54. -    EASSERT(src->owner_group != NULL);
  55. +    }
  56. +    else {
  57. +        /* this should only happen for newly created files7dirs */
  58. +        dst->owner = NULL;
  59. +    }
  60. +    EASSERT(src->owner_group[0] != '\0');
  61. +    if (src->owner_group[0] != '\0') {
  62.          dst->owner_group = dst->owner_group_buf;
  63.          (void)strcpy(dst->owner_group, src->owner_group);
  64. +    }
  65. +    else {
  66. +        /* this should only happen for newly created files7dirs */
  67. +        dst->owner_group = NULL;
  68. +    }
  69.      dst->fileid = src->fileid;
  70.      dst->hidden = src->hidden;
  71.      dst->system = src->system;
  72. @@ -369,8 +381,11 @@ static void copy_attrs(
  73.      dst->attrmask.arr[1] = FATTR4_WORD1_MODE
  74.          | FATTR4_WORD1_NUMLINKS | FATTR4_WORD1_TIME_ACCESS
  75.          | FATTR4_WORD1_TIME_CREATE | FATTR4_WORD1_TIME_MODIFY
  76. -        | FATTR4_WORD1_SYSTEM
  77. -        | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
  78. +        | FATTR4_WORD1_SYSTEM;
  79. +    if (dst->owner)
  80. +        dst->attrmask.arr[1] |= FATTR4_WORD1_OWNER;
  81. +    if (dst->owner_group)
  82. +        dst->attrmask.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
  83.  }
  84.  
  85.  
  86. diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
  87. index 9bde0f0..6889a79 100644
  88. --- a/daemon/nfs41_xdr.c
  89. +++ b/daemon/nfs41_xdr.c
  90. @@ -1815,6 +1815,7 @@ static bool_t decode_file_attrs(
  91.              EASSERT(owner_len > 0);
  92.              EASSERT(owner_len < sizeof(info->owner_group_buf));
  93.              info->owner[owner_len] = '\0';
  94. +            EASSERT(info->owner[0] != '\0');
  95.          }
  96.          if (attrs->attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) {
  97.              if (info->owner_group == NULL)
  98. @@ -1830,6 +1831,7 @@ static bool_t decode_file_attrs(
  99.              EASSERT(owner_group_len > 0);
  100.              EASSERT(owner_group_len < sizeof(info->owner_group_buf));
  101.              info->owner_group[owner_group_len] = '\0';
  102. +            EASSERT(info->owner_group[0] != '\0');
  103.          }
  104.          if (attrs->attrmask.arr[1] & FATTR4_WORD1_SPACE_AVAIL) {
  105.              if (!xdr_u_hyper(xdr, &info->space_avail))
  106. diff --git a/daemon/open.c b/daemon/open.c
  107. index a9ffcb0..35ff2b1 100644
  108. --- a/daemon/open.c
  109. +++ b/daemon/open.c
  110. @@ -669,12 +669,47 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  111.          gid_t map_gid = -1;
  112.          char *at_ch; /* pointer to '@' */
  113.  
  114. +#if 1
  115. +        /* this should only happen for newly created files/dirs */
  116. +        if (((info.attrmask.arr[1] & FATTR4_WORD1_OWNER) == 0) ||
  117. +            ((info.attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) == 0)) {
  118. +            bitmap4 og_attr_request = { 0 };
  119. +            nfs41_file_info og_info = { 0 };
  120. +            nfsacl41 acl = { 0 };
  121. +
  122. +            og_attr_request.count = 2;
  123. +            og_attr_request.arr[1] =
  124. +                FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
  125. +            og_info.owner = og_info.owner_buf;
  126. +            og_info.owner_group = og_info.owner_group_buf;
  127. +            status = nfs41_getattr(state->session, &state->file,
  128. +                &og_attr_request, &og_info);
  129. +            if (status) {
  130. +                eprintf("get_stat_data: nfs41_getattr('%s') "
  131. +                    "failed with %d\n",
  132. +                    state->path.path,
  133. +                    status);
  134. +                goto out_free_state;
  135. +            }
  136. +
  137. +            info.owner = info.owner_buf;
  138. +            (void)strcpy(info.owner, og_info.owner);
  139. +            info.attrmask.arr[1] |= FATTR4_WORD1_OWNER;
  140. +            info.owner_group = info.owner_group_buf;
  141. +            (void)strcpy(info.owner_group, og_info.owner_group);
  142. +            info.attrmask.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
  143. +        }
  144. +#endif
  145. +
  146.          EASSERT((info.attrmask.arr[1] & FATTR4_WORD1_OWNER) != 0);
  147.          EASSERT((info.attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) != 0);
  148.          EASSERT(info.owner != NULL);
  149.          EASSERT(info.owner_group != NULL);
  150.          EASSERT(info.owner == info.owner_buf);
  151.          EASSERT(info.owner_group == info.owner_group_buf);
  152. +        EASSERT(strlen(info.owner) > 0);
  153. +        EASSERT(strlen(info.owner_group) > 0);
  154. +
  155.          /* Make copies as we will modify  them */
  156.          (void)strcpy(owner, info.owner);
  157.          (void)strcpy(owner_group, info.owner_group);
  158. @@ -698,8 +733,9 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  159.          }
  160.          else {
  161.              args->owner_local_uid = NFS_USER_NOBODY_UID;
  162. -            eprintf("get_stat_data: "
  163. +            eprintf("get_stat_data('%s'): "
  164.                  "no username mapping for '%s', fake uid=%d\n",
  165. +                state->path.path,
  166.                  owner, args->owner_local_uid);
  167.          }
  168.  
  169. @@ -721,12 +757,14 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  170.          }
  171.          else {
  172.              args->owner_group_local_gid = NFS_GROUP_NOGROUP_GID;
  173. -            eprintf("get_stat_data: "
  174. +            eprintf("get_stat_data('%s'): "
  175.                  "no group mapping for '%s', fake gid=%d\n",
  176. +                state->path.path,
  177.                  owner_group, args->owner_group_local_gid);
  178.          }
  179.  
  180. -        dprintf(1, "handle_open: stat: owner=%u/'%s', owner_group=%u/'%s'\n",
  181. +        dprintf(1, "handle_open('%s'): stat: owner=%u/'%s', owner_group=%u/'%s'\n",
  182. +            state->path.path,
  183.              (unsigned int)args->owner_local_uid, owner,
  184.              (unsigned int)args->owner_group_local_gid, owner_group);
  185.  #endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  186. diff --git a/daemon/util.c b/daemon/util.c
  187. index 07aa2c6..c482624 100644
  188. --- a/daemon/util.c
  189. +++ b/daemon/util.c
  190. @@ -207,7 +207,9 @@ void nfs41_file_info_cpy(
  191.      IN const nfs41_file_info *src)
  192.  {
  193.      (void)memcpy(dest, src, sizeof(nfs41_file_info));
  194. +    if (src->owner != NULL)
  195.          dest->owner = dest->owner_buf;
  196. +    if (src->owner_group != NULL)
  197.          dest->owner_group = dest->owner_group_buf;
  198.  }
  199.  
  200. diff --git a/sys/nfs41_build_features.h b/sys/nfs41_build_features.h
  201. index 93ee7a9..d43334a 100644
  202. --- a/sys/nfs41_build_features.h
  203. +++ b/sys/nfs41_build_features.h
  204. @@ -32,19 +32,19 @@
  205.  /*
  206.   * NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES - return local uid/gid values
  207.   */
  208. -// #define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
  209. +#define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
  210.  
  211.  /*
  212.   * NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID - give NFS
  213.   * files which do not map to a local account a SID in the
  214.   * Unix_User+x/Unix_Group+x range
  215.   */
  216. -// #define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
  217. +#define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
  218.  
  219.  /*
  220.   * NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN - use Cygwin /usr/bin/getent
  221.   * as "name service"
  222.   */
  223. -// #define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
  224. +#define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
  225.  
  226.  #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