pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


msnfs41 experiments backup diff
Posted by Anonymous on Mon 30th Oct 2023 16:55
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..97767fb 100644
  26. --- a/daemon/getattr.c
  27. +++ b/daemon/getattr.c
  28. @@ -60,7 +60,13 @@ static int parse_getattr(unsigned char *buffer, uint32_t length, nfs41_upcall *u
  29.  {
  30.      int status;
  31.      getattr_upcall_args *args = &upcall->args.getattr;
  32. -
  33. +#if 1
  34. +    EASSERT(length > 4);
  35. +    if (length <= 4) {
  36. +        status = ERROR_INVALID_PARAMETER;
  37. +        goto out;
  38. +    }
  39. +#endif
  40.      status = safe_read(&buffer, &length, &args->query_class, sizeof(args->query_class));
  41.      if (status) goto out;
  42.      status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
  43. @@ -80,6 +86,21 @@ static int handle_getattr(void *daemon_context, nfs41_upcall *upcall)
  44.      nfs41_open_state *state = upcall->state_ref;
  45.      nfs41_file_info info = { 0 };
  46.  
  47. +#if 1
  48. +    if (((char *)state->session) == ((char *)0xdddddddddddddddd)) {
  49. +        eprintf("handle_getattr: Invalid session pointer 0xdddddddddddddddd\n");
  50. +        status = ERROR_INVALID_PARAMETER;
  51. +        goto out;
  52. +    }
  53. +
  54. +    EASSERT(state->file.fh.superblock != NULL);
  55. +    if (state->file.fh.superblock == NULL) {
  56. +        /* gisburn: fixme: maybe this should be |ERROR_INTERNAL_ERROR| ? */
  57. +        status = ERROR_INVALID_PARAMETER;
  58. +        goto out;
  59. +    }
  60. +#endif
  61. +
  62.      status = nfs41_cached_getattr(state->session, &state->file, &info);
  63.      if (status) {
  64.          eprintf("nfs41_cached_getattr() failed with %d\n", status);
  65. diff --git a/daemon/idmap.c b/daemon/idmap.c
  66. index 00af1fe..6947b6c 100644
  67. --- a/daemon/idmap.c
  68. +++ b/daemon/idmap.c
  69. @@ -133,7 +133,7 @@ static const struct config_option g_options[] = {
  70.      OPT_ATTR("ldap_attr_gidNumber", "gidNumber", ATTR_GID),
  71.  
  72.      /* caching configuration */
  73. -    OPT_INT("cache_ttl", "60", cache_ttl),
  74. +    OPT_INT("cache_ttl", "6000", cache_ttl),
  75.  };
  76.  
  77.  
  78. diff --git a/daemon/name_cache.c b/daemon/name_cache.c
  79. index 3f944fd..bf2b064 100644
  80. --- a/daemon/name_cache.c
  81. +++ b/daemon/name_cache.c
  82. @@ -351,12 +351,24 @@ static void copy_attrs(
  83.      dst->type = src->type;
  84.      dst->numlinks = src->numlinks;
  85.      dst->mode = src->mode;
  86. -    EASSERT(src->owner != NULL);
  87. +    EASSERT(src->owner[0] != '\0');
  88. +    if (src->owner[0] != '\0') {
  89.          dst->owner = dst->owner_buf;
  90.          (void)strcpy(dst->owner, src->owner);
  91. -    EASSERT(src->owner_group != NULL);
  92. +    }
  93. +    else {
  94. +        /* this should only happen for newly created files/dirs */
  95. +        dst->owner = NULL;
  96. +    }
  97. +    EASSERT(src->owner_group[0] != '\0');
  98. +    if (src->owner_group[0] != '\0') {
  99.          dst->owner_group = dst->owner_group_buf;
  100.          (void)strcpy(dst->owner_group, src->owner_group);
  101. +    }
  102. +    else {
  103. +        /* this should only happen for newly created files/dirs */
  104. +        dst->owner_group = NULL;
  105. +    }
  106.      dst->fileid = src->fileid;
  107.      dst->hidden = src->hidden;
  108.      dst->system = src->system;
  109. @@ -369,8 +381,11 @@ static void copy_attrs(
  110.      dst->attrmask.arr[1] = FATTR4_WORD1_MODE
  111.          | FATTR4_WORD1_NUMLINKS | FATTR4_WORD1_TIME_ACCESS
  112.          | FATTR4_WORD1_TIME_CREATE | FATTR4_WORD1_TIME_MODIFY
  113. -        | FATTR4_WORD1_SYSTEM
  114. -        | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
  115. +        | FATTR4_WORD1_SYSTEM;
  116. +    if (dst->owner)
  117. +        dst->attrmask.arr[1] |= FATTR4_WORD1_OWNER;
  118. +    if (dst->owner_group)
  119. +        dst->attrmask.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
  120.  }
  121.  
  122.  
  123. diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
  124. index 9bde0f0..6889a79 100644
  125. --- a/daemon/nfs41_xdr.c
  126. +++ b/daemon/nfs41_xdr.c
  127. @@ -1815,6 +1815,7 @@ static bool_t decode_file_attrs(
  128.              EASSERT(owner_len > 0);
  129.              EASSERT(owner_len < sizeof(info->owner_group_buf));
  130.              info->owner[owner_len] = '\0';
  131. +            EASSERT(info->owner[0] != '\0');
  132.          }
  133.          if (attrs->attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) {
  134.              if (info->owner_group == NULL)
  135. @@ -1830,6 +1831,7 @@ static bool_t decode_file_attrs(
  136.              EASSERT(owner_group_len > 0);
  137.              EASSERT(owner_group_len < sizeof(info->owner_group_buf));
  138.              info->owner_group[owner_group_len] = '\0';
  139. +            EASSERT(info->owner_group[0] != '\0');
  140.          }
  141.          if (attrs->attrmask.arr[1] & FATTR4_WORD1_SPACE_AVAIL) {
  142.              if (!xdr_u_hyper(xdr, &info->space_avail))
  143. diff --git a/daemon/open.c b/daemon/open.c
  144. index a9ffcb0..1f8bd54 100644
  145. --- a/daemon/open.c
  146. +++ b/daemon/open.c
  147. @@ -99,6 +99,24 @@ static void open_state_free(
  148.  void nfs41_open_state_ref(
  149.      IN nfs41_open_state *state)
  150.  {
  151. +#if 1
  152. +    /*
  153. +     * gisburn: fixme: sometimes this happens under high parallel
  154. +     * usage with multiple mounts - but why ?
  155. +     * 0:038> kp
  156. +     * Child-SP          RetAddr           Call Site
  157. +     * 0000006d`431fde10 00007ff7`32f7d905 nfsd!nfs41_open_state_ref(struct __nfs41_open_state * state = 0x00000000`00000000)+0x31
  158. +     * 0000006d`431fdf30 00007ff7`32f4d284 nfsd!upcall_parse(unsigned char * buffer = 0x0000006d`431fe180 "???", unsigned int length = 8, struct __nfs41_upcall * upcall = 0x0000006d`431ff1e0)+0x2e5
  159. +     * 0000006d`431fe0b0 00007ffc`1ca24c7c nfsd!thread_main(void * args = 0x00007ff7`32fb6080)+0x144
  160. +     * 0000006d`431ffe00 00007ffc`4d4b7344 ucrtbased!thread_start<unsigned int (void * parameter = 0x0000025d`a9c6def0)+0x9c
  161. +     * 0000006d`431ffe60 00007ffc`4efc26b1 KERNEL32!BaseThreadInitThunk+0x14
  162. +     * 0000006d`431ffe90 00000000`00000000 ntdll!RtlUserThreadStart+0x21
  163. +     */
  164. +    EASSERT(state != NULL);
  165. +    if (state == NULL)
  166. +        return;
  167. +#endif
  168. +
  169.      const LONG count = InterlockedIncrement(&state->ref_count);
  170.  
  171.      dprintf(2, "nfs41_open_state_ref(%s) count %d\n", state->path.path, count);
  172. @@ -669,12 +687,47 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  173.          gid_t map_gid = -1;
  174.          char *at_ch; /* pointer to '@' */
  175.  
  176. +#if 1
  177. +        /* this should only happen for newly created files/dirs */
  178. +        if (((info.attrmask.arr[1] & FATTR4_WORD1_OWNER) == 0) ||
  179. +            ((info.attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) == 0)) {
  180. +            bitmap4 og_attr_request = { 0 };
  181. +            nfs41_file_info og_info = { 0 };
  182. +            nfsacl41 acl = { 0 };
  183. +
  184. +            og_attr_request.count = 2;
  185. +            og_attr_request.arr[1] =
  186. +                FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
  187. +            og_info.owner = og_info.owner_buf;
  188. +            og_info.owner_group = og_info.owner_group_buf;
  189. +            status = nfs41_getattr(state->session, &state->file,
  190. +                &og_attr_request, &og_info);
  191. +            if (status) {
  192. +                eprintf("get_stat_data: nfs41_getattr('%s') "
  193. +                    "failed with %d\n",
  194. +                    state->path.path,
  195. +                    status);
  196. +                goto out_free_state;
  197. +            }
  198. +
  199. +            info.owner = info.owner_buf;
  200. +            (void)strcpy(info.owner, og_info.owner);
  201. +            info.attrmask.arr[1] |= FATTR4_WORD1_OWNER;
  202. +            info.owner_group = info.owner_group_buf;
  203. +            (void)strcpy(info.owner_group, og_info.owner_group);
  204. +            info.attrmask.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
  205. +        }
  206. +#endif
  207. +
  208.          EASSERT((info.attrmask.arr[1] & FATTR4_WORD1_OWNER) != 0);
  209.          EASSERT((info.attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) != 0);
  210.          EASSERT(info.owner != NULL);
  211.          EASSERT(info.owner_group != NULL);
  212.          EASSERT(info.owner == info.owner_buf);
  213.          EASSERT(info.owner_group == info.owner_group_buf);
  214. +        EASSERT(strlen(info.owner) > 0);
  215. +        EASSERT(strlen(info.owner_group) > 0);
  216. +
  217.          /* Make copies as we will modify  them */
  218.          (void)strcpy(owner, info.owner);
  219.          (void)strcpy(owner_group, info.owner_group);
  220. @@ -698,8 +751,9 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  221.          }
  222.          else {
  223.              args->owner_local_uid = NFS_USER_NOBODY_UID;
  224. -            eprintf("get_stat_data: "
  225. +            eprintf("get_stat_data('%s'): "
  226.                  "no username mapping for '%s', fake uid=%d\n",
  227. +                state->path.path,
  228.                  owner, args->owner_local_uid);
  229.          }
  230.  
  231. @@ -721,12 +775,14 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  232.          }
  233.          else {
  234.              args->owner_group_local_gid = NFS_GROUP_NOGROUP_GID;
  235. -            eprintf("get_stat_data: "
  236. +            eprintf("get_stat_data('%s'): "
  237.                  "no group mapping for '%s', fake gid=%d\n",
  238. +                state->path.path,
  239.                  owner_group, args->owner_group_local_gid);
  240.          }
  241.  
  242. -        dprintf(1, "handle_open: stat: owner=%u/'%s', owner_group=%u/'%s'\n",
  243. +        dprintf(1, "handle_open('%s'): stat: owner=%u/'%s', owner_group=%u/'%s'\n",
  244. +            state->path.path,
  245.              (unsigned int)args->owner_local_uid, owner,
  246.              (unsigned int)args->owner_group_local_gid, owner_group);
  247.  #endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  248. diff --git a/daemon/util.c b/daemon/util.c
  249. index 07aa2c6..c482624 100644
  250. --- a/daemon/util.c
  251. +++ b/daemon/util.c
  252. @@ -207,7 +207,9 @@ void nfs41_file_info_cpy(
  253.      IN const nfs41_file_info *src)
  254.  {
  255.      (void)memcpy(dest, src, sizeof(nfs41_file_info));
  256. +    if (src->owner != NULL)
  257.          dest->owner = dest->owner_buf;
  258. +    if (src->owner_group != NULL)
  259.          dest->owner_group = dest->owner_group_buf;
  260.  }
  261.  
  262. diff --git a/libtirpc/src/clnt_vc.c b/libtirpc/src/clnt_vc.c
  263. index e0a9d30..bedbebe 100644
  264. --- a/libtirpc/src/clnt_vc.c
  265. +++ b/libtirpc/src/clnt_vc.c
  266. @@ -158,7 +158,7 @@ struct ct_data {
  267.   *      Yes, this is silly, and as soon as this code is proven to work, this
  268.   *      should be the first thing fixed.  One step at a time.
  269.   */
  270. -static int      *vc_fd_locks;
  271. +static volatile int      *vc_fd_locks;
  272.  extern mutex_t  clnt_fd_lock;
  273.  static cond_t   *vc_cv;
  274.  #ifndef _WIN32
  275. @@ -211,17 +211,26 @@ static unsigned int WINAPI clnt_cb_thread(void *args)
  276.      while(1) {
  277.          cb_req header;
  278.          void *res = NULL;
  279. +restart:
  280.          mutex_lock(&clnt_fd_lock);
  281.             while (vc_fd_locks[ct->ct_fd] ||
  282.                  !ct->use_stored_reply_msg ||
  283.                  (ct->use_stored_reply_msg && ct->reply_msg.rm_direction != CALL)) {
  284.              if (cl->shutdown)
  285.                  break;
  286. -                   if (!cond_wait_timed(&vc_cv[ct->ct_fd], &clnt_fd_lock,
  287. -                CALLBACK_TIMEOUT))
  288. -                if (!vc_fd_locks[ct->ct_fd])
  289. +            if (!cond_wait_timed(&vc_cv[ct->ct_fd], &clnt_fd_lock, CALLBACK_TIMEOUT)) {
  290. +                if (!vc_fd_locks[ct->ct_fd]) {
  291.                      break;
  292.                  }
  293. +                else
  294. +                {
  295. +                    mutex_unlock(&clnt_fd_lock);
  296. +                    fprintf(stderr, "%04x: clnt_cb_thread: restart...\n", GetCurrentThreadId());
  297. +                    SwitchToThread(); /* sched_yield() */
  298. +                    goto restart;
  299. +                }
  300. +            }
  301. +       }
  302.         vc_fd_locks[ct->ct_fd] = GetCurrentThreadId();
  303.         mutex_unlock(&clnt_fd_lock);
  304.  
  305. @@ -923,8 +932,13 @@ clnt_vc_destroy(cl)
  306.              GetCurrentThreadId(), cl->cb_thread);
  307.          cl->shutdown = 1;
  308.          mutex_unlock(&clnt_fd_lock);
  309. -        cond_signal(&vc_cv[ct_fd]);
  310. -        status = WaitForSingleObject(cl->cb_thread, INFINITE);
  311. +retry_signalandwaitforobject:
  312. +        cond_signal(&vc_cv[ct_fd]); /* fixme: should broadcast everyone waiting... */
  313. +        status = WaitForSingleObject(cl->cb_thread, 5000);
  314. +        if (status == WAIT_TIMEOUT) {
  315. +            fprintf(stderr, "%04x: clnt_vc_destroy: WaitForSingleObject timeout, retrying...\n", GetCurrentThreadId());
  316. +            goto retry_signalandwaitforobject;
  317. +        }
  318.          fprintf(stdout, "%04x: terminated callback thread\n", GetCurrentThreadId());
  319.          mutex_lock(&clnt_fd_lock);
  320.          while (vc_fd_locks[ct_fd])
  321. diff --git a/sys/nfs41_build_features.h b/sys/nfs41_build_features.h
  322. index 93ee7a9..d43334a 100644
  323. --- a/sys/nfs41_build_features.h
  324. +++ b/sys/nfs41_build_features.h
  325. @@ -32,19 +32,19 @@
  326.  /*
  327.   * NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES - return local uid/gid values
  328.   */
  329. -// #define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
  330. +#define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
  331.  
  332.  /*
  333.   * NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID - give NFS
  334.   * files which do not map to a local account a SID in the
  335.   * Unix_User+x/Unix_Group+x range
  336.   */
  337. -// #define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
  338. +#define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
  339.  
  340.  /*
  341.   * NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN - use Cygwin /usr/bin/getent
  342.   * as "name service"
  343.   */
  344. -// #define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
  345. +#define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
  346.  
  347.  #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