pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for stale namecache owner/owner_group info afer chgrp/chown
Posted by Anonymous on Tue 20th Feb 2024 07:33
raw | new post

  1. From fff43f3c6d1da6b9779a84bb4db120d064f020f4 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Tue, 20 Feb 2024 08:15:37 +0100
  4. Subject: [PATCH 1/2] daemon: Add better debug output to setattr chown/chgrp
  5.  codepath
  6.  
  7. Add better debug output to the serattr codepath used by chown and
  8. chgrp.
  9.  
  10. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  11. ---
  12. daemon/acl.c          | 16 ++++++++--
  13.  daemon/daemon_debug.c | 71 +++++++++++++++++++++++++++++++++++++++++++
  14.  daemon/daemon_debug.h |  1 +
  15.  3 files changed, 86 insertions(+), 2 deletions(-)
  16.  
  17. diff --git a/daemon/acl.c b/daemon/acl.c
  18. index deecc38..deea6ab 100644
  19. --- a/daemon/acl.c
  20. +++ b/daemon/acl.c
  21. @@ -578,11 +578,15 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
  22.  add_domain:
  23.      memcpy(who_out+size, "@", sizeof(char));
  24.      memcpy(who_out+size+1, domain, strlen(domain)+1);
  25. -    DPRINTF(ACLLVL, ("map_nfs4ace_who: who='%s'\n", who_out));
  26.      if (who) free(who);
  27.      status = ERROR_SUCCESS;
  28.  out:
  29. -    DPRINTF(ACLLVL, ("<-- map_nfs4ace_who() returns %d\n", status));
  30. +    if (status) {
  31. +        DPRINTF(ACLLVL, ("<-- map_nfs4ace_who() returns %d\n", status));
  32. +    }
  33. +    else {
  34. +        DPRINTF(ACLLVL, ("<-- map_nfs4ace_who(who_out='%s') returns %d\n", who_out, status));
  35. +    }
  36.      if (sidstr)
  37.          LocalFree(sidstr);
  38.      return status;
  39. @@ -760,12 +764,20 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
  40.          OPEN_DELEGATE_WRITE, FALSE);
  41.  
  42.      nfs41_open_stateid_arg(state, &stateid);
  43. +    if (DPRINTF_LEVEL_ENABLED(ACLLVL)) {
  44. +        print_nfs41_file_info("handle_setacl: nfs41_setattr() info IN:", &info);
  45. +    }
  46.      status = nfs41_setattr(state->session, &state->file, &stateid, &info);
  47.      if (status) {
  48.          DPRINTF(ACLLVL, ("handle_setacl: nfs41_setattr() failed with error '%s'.\n",
  49.                  nfs_error_string(status)));
  50.          status = nfs_to_windows_error(status, ERROR_NOT_SUPPORTED);
  51.      }
  52. +    else {
  53. +        if (DPRINTF_LEVEL_ENABLED(ACLLVL)) {
  54. +            print_nfs41_file_info("handle_setacl: nfs41_setattr() success info OUT:", &info);
  55. +        }
  56. +    }
  57.      args->ctime = info.change;
  58.      if (args->query & DACL_SECURITY_INFORMATION)
  59.          free(nfs4_acl.aces);
  60. diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
  61. index 67b79c3..9941ce2 100644
  62. --- a/daemon/daemon_debug.c
  63. +++ b/daemon/daemon_debug.c
  64. @@ -731,3 +731,74 @@ void print_nfs_access_mask(int on, int m)
  65.      if (m & ACE4_SYNCHRONIZE)
  66.          dprintf_out("\tACE4_SYNCHRONIZE\n");
  67.  }
  68. +
  69. +
  70. +void print_nfs41_file_info(
  71. +    const char *label,
  72. +    const void *vinfo)
  73. +{
  74. +    const nfs41_file_info *info = vinfo;
  75. +    char buf[512];
  76. +    char *p;
  77. +
  78. +    buf[0] = '\0';
  79. +    p = buf;
  80. +
  81. +#define PRNFS41FI_FMT(str, arg) \
  82. +    p += snprintf(p, (sizeof(buf)-(p-buf)), (str), (arg))
  83. +
  84. +    PRNFS41FI_FMT("attrmask.count=%d, ", (int)info->attrmask.count);
  85. +
  86. +    if (info->attrmask.count >= 1) {
  87. +        PRNFS41FI_FMT("{ attrmask.arr[0]=0x%x, ", (int)info->attrmask.arr[0]);
  88. +        if (info->attrmask.arr[0] & FATTR4_WORD0_TYPE)
  89. +            PRNFS41FI_FMT("type=%d, ", (int)(info->type & NFS_FTYPE_MASK));
  90. +        if (info->attrmask.arr[0] & FATTR4_WORD0_CHANGE)
  91. +            PRNFS41FI_FMT("change=%lld, ", (long long)info->change);
  92. +        if (info->attrmask.arr[0] & FATTR4_WORD0_SIZE)
  93. +            PRNFS41FI_FMT("size=%lld, ", (long long)info->size);
  94. +        if (info->attrmask.arr[0] & FATTR4_WORD0_HIDDEN)
  95. +            PRNFS41FI_FMT("hidden=%d, ", (int)info->hidden);
  96. +        if (info->attrmask.arr[0] & FATTR4_WORD0_ARCHIVE)
  97. +            PRNFS41FI_FMT("archive=%d, ", (int)info->archive);
  98. +        p += snprintf(p, (sizeof(buf)-(p-buf)), "} ");
  99. +    }
  100. +    if (info->attrmask.count >= 2) {
  101. +        PRNFS41FI_FMT("{ attrmask.arr[1]=0x%x, ", (int)info->attrmask.arr[1]);
  102. +        if (info->attrmask.arr[1] & FATTR4_WORD1_MODE)
  103. +            PRNFS41FI_FMT("mode=0x%lx, ", (long)info->mode);
  104. +        if (info->attrmask.arr[1] & FATTR4_WORD1_OWNER) {
  105. +            EASSERT(info->owner != NULL);
  106. +            PRNFS41FI_FMT("owner='%s', ", info->owner);
  107. +        }
  108. +        if (info->attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) {
  109. +            EASSERT(info->owner_group != NULL);
  110. +            PRNFS41FI_FMT("owner_group='%s', ", info->owner_group);
  111. +        }
  112. +        if (info->attrmask.arr[1] & FATTR4_WORD1_NUMLINKS)
  113. +            PRNFS41FI_FMT("numlinks=%ld, ", (long)info->numlinks);
  114. +        if (info->attrmask.arr[1] & FATTR4_WORD1_TIME_ACCESS) {
  115. +            p += snprintf(p, (sizeof(buf)-(p-buf)),
  116. +                "time_access=(%lds/%ldns), ",
  117. +                (long)info->time_access.seconds,
  118. +                (long)info->time_access.nseconds);
  119. +        }
  120. +        if (info->attrmask.arr[1] & FATTR4_WORD1_TIME_CREATE) {
  121. +            p += snprintf(p, (sizeof(buf)-(p-buf)),
  122. +                "time_create=(%lds/%ldns), ",
  123. +                (long)info->time_create.seconds,
  124. +                (long)info->time_create.nseconds);
  125. +        }
  126. +        if (info->attrmask.arr[1] & FATTR4_WORD1_TIME_MODIFY) {
  127. +            p += snprintf(p, (sizeof(buf)-(p-buf)),
  128. +                "time_modify=(%lds/%ldns), ",
  129. +                (long)info->time_modify.seconds,
  130. +                (long)info->time_modify.nseconds);
  131. +        }
  132. +        if (info->attrmask.arr[1] & FATTR4_WORD1_SYSTEM)
  133. +            PRNFS41FI_FMT("system=%d, ", (int)info->system);
  134. +        p += snprintf(p, (sizeof(buf)-(p-buf)), "} ");
  135. +    }
  136. +
  137. +    dprintf_out("%s={ %s }\n", label, buf);
  138. +}
  139. diff --git a/daemon/daemon_debug.h b/daemon/daemon_debug.h
  140. index 6fa16d7..0840c7b 100644
  141. --- a/daemon/daemon_debug.h
  142. +++ b/daemon/daemon_debug.h
  143. @@ -102,6 +102,7 @@ void print_sr_status_flags(int level, int flags);
  144.  void open_log_files();
  145.  void close_log_files();
  146.  const char* secflavorop2name(DWORD sec_flavor);
  147. +void print_nfs41_file_info(const char *label, void *vinfo);
  148.  
  149.  /* pnfs_debug.c */
  150.  enum pnfs_status;
  151. --
  152. 2.43.0
  153.  
  154. From b6675061ab429bf8b47505cfa39d2c914d10e185 Mon Sep 17 00:00:00 2001
  155. From: Roland Mainz <roland.mainz@nrubsig.org>
  156. Date: Tue, 20 Feb 2024 08:18:30 +0100
  157. Subject: [PATCH 2/2] daemon: |nfs41_setattr()| should return owner/owner_group
  158.  if we changed them
  159.  
  160. |nfs41_setattr()| should return owner/owner_group from the server
  161. if we changed them.
  162.  
  163. We need this information for two cases:
  164. 1. Return the owner/owner_group used by the server, to cover cases
  165. like /etc/exports "all_squash"
  166. 2. Update the name cache with the new owner/owner_group
  167.  
  168. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  169. ---
  170. daemon/nfs41_ops.c | 26 ++++++++++++++++++++++++++
  171.  1 file changed, 26 insertions(+)
  172.  
  173. diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c
  174. index 50c1809..9b47b6b 100644
  175. --- a/daemon/nfs41_ops.c
  176. +++ b/daemon/nfs41_ops.c
  177. @@ -3,6 +3,7 @@
  178.   *
  179.   * Olga Kornievskaia <aglo@umich.edu>
  180.   * Casey Bodley <cbodley@umich.edu>
  181. + * Roland Mainz <roland.mainz@nrubsig.org>
  182.   *
  183.   * This library is free software; you can redistribute it and/or modify it
  184.   * under the terms of the GNU Lesser General Public License as published by
  185. @@ -1387,6 +1388,31 @@ int nfs41_setattr(
  186.      setattr_args.info = info;
  187.  
  188.      nfs41_superblock_getattr_mask(file->fh.superblock, &attr_request);
  189. +
  190. +    if (info->attrmask.count >= 2) {
  191. +        /*
  192. +         * If we set owner and/or owner_group make sure we ask
  193. +         * the server to send the values back for two reasons:
  194. +         * 1, Handle cases like "all_squash" (e.g. nfsd turns
  195. +         * owner/owner_group always into "nobody"/"nogroup")
  196. +         * 2. Make sure we update the name cache with the new
  197. +         * owner/owner_group
  198. +         *
  199. +         * Note that this can be a bit tricky as we might pass
  200. +         * a "name@domain" string to the server, but get a numeric
  201. +         * uid/gid as strings back, which means the name cache
  202. +         * might have both representations.
  203. +         */
  204. +        if (info->attrmask.arr[1] & FATTR4_WORD1_OWNER) {
  205. +            attr_request.count = 2;
  206. +            attr_request.arr[1] |= FATTR4_WORD1_OWNER;
  207. +        }
  208. +        if (info->attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) {
  209. +            attr_request.count = 2;
  210. +            attr_request.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
  211. +        }
  212. +    }
  213. +
  214.      compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
  215.      getattr_args.attr_request = &attr_request;
  216.      getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  217. --
  218. 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