pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


backup 20240610
Posted by Anonymous on Mon 10th Jun 2024 16:54
raw | new post

  1. diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
  2. index ffce9be..a608467 100644
  3. --- a/cygwin/devel/msnfs41client.bash
  4. +++ b/cygwin/devel/msnfs41client.bash
  5. @@ -143,7 +143,13 @@ function nfsclient_install
  6.         bcdedit /dbgsettings local
  7.  
  8.         # set domain name
  9. +       typeset win_domainname=''
  10. +       if [[ -f '/proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters/Domain' ]] ; then
  11. +               win_domainname="$( strings '/proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters/Domain' )"
  12. +       fi
  13. +       if [[ "${win_domainname}" == '' ]] ; then
  14.                 regtool -s set '/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters/Domain' 'GLOBAL.LOC'
  15. +       fi
  16.  
  17.         # disable DFS
  18.         sc query Dfsc
  19. @@ -204,10 +210,11 @@ function nfsclient_rundeamon
  20.  {
  21.         set -o nounset
  22.  
  23. -       printf '# user='%s' uname='%s' isadmin=%d\n' \
  24. +       printf '# user="%s" uname="%s" isadmin=%d domainname="%s"\n' \
  25.                 "$(id -u -n)" \
  26.                 "$(uname -a)" \
  27. -               "$(is_windows_admin_account ; printf "%d\n" $((${?}?0:1)))"
  28. +               "$(is_windows_admin_account ; printf "%d\n" $((${?}?0:1)))" \
  29. +               "$(domainname)"
  30.  
  31.         # sync before starting nfs41 client daemon, to limit the damage
  32.         # if the kernel module generates a crash on startup
  33. @@ -301,10 +308,11 @@ function nfsclient_system_rundeamon
  34.  {
  35.         set -o nounset
  36.  
  37. -       printf '# user='%s' uname='%s' isadmin=%d\n' \
  38. +       printf '# user="%s" uname="%s" isadmin=%d domainname="%s"\n' \
  39.                 "$(id -u -n)" \
  40.                 "$(uname -a)" \
  41. -               "$(is_windows_admin_account ; printf "%d\n" $((${?}?0:1)))"
  42. +               "$(is_windows_admin_account ; printf "%d\n" $((${?}?0:1)))" \
  43. +               "$(domainname)"
  44.  
  45.         # sync before starting nfs41 client daemon, to limit the damage
  46.         # if the kernel module generates a crash on startup
  47. diff --git a/daemon/idmap.c b/daemon/idmap.c
  48. index 8fe4fd4..c09460c 100644
  49. --- a/daemon/idmap.c
  50. +++ b/daemon/idmap.c
  51. @@ -84,6 +84,7 @@ static const char CONFIG_FILENAME[] = "C:\\etc\\ms-nfs41-idmap.conf";
  52.  struct idmap_config {
  53.      /* ldap server information */
  54.      char hostname[NFS41_HOSTNAME_LEN+1];
  55. +    char localdomain_name[NFS41_HOSTNAME_LEN+1];
  56.      UINT port;
  57.      UINT version;
  58.      UINT timeout;
  59. @@ -728,7 +729,8 @@ static int idmap_lookup_user(
  60.                  ("# ATTR_USER_NAME: cygwin_getent_passwd: returned '%s', uid=%u, gid=%u\n",
  61.                  lookup->value, (unsigned int)cy_uid, (unsigned int)cy_gid));
  62.              (void)snprintf(principal_name, sizeof(principal_name),
  63. -                "%s@%s", (const char *)lookup->value, "GLOBAL.LOC");
  64. +                "%s@%s", (const char *)lookup->value,
  65. +                context->config.localdomain_name);
  66.              StringCchCopyA(user->username, VAL_LEN, lookup->value);
  67.              StringCchCopyA(user->principal, VAL_LEN, principal_name);
  68.              user->uid = cy_uid;
  69. @@ -758,7 +760,8 @@ static int idmap_lookup_user(
  70.                  ("# ATTR_PRINCIPAL: cygwin_getent_passwd: returned '%s', uid=%u, gid=%u\n",
  71.                  lookup->value, (unsigned int)cy_uid, (unsigned int)cy_gid));
  72.              (void)snprintf(principal_name, sizeof(principal_name),
  73. -                "%s@%s", (const char *)lookup->value, "GLOBAL.LOC");
  74. +                "%s@%s", (const char *)lookup->value,
  75. +                context->config.localdomain_name);
  76.  
  77.              if (!strcmp(principal_name, lookup->value)) {
  78.                  StringCchCopyA(user->username, VAL_LEN, search_name);
  79. @@ -785,7 +788,8 @@ static int idmap_lookup_user(
  80.              DPRINTF(CYGWINIDLVL,
  81.                  ("# ATTR_UID: cygwin_getent_passwd: returned '%s', uid=%u, gid=%u\n",
  82.                  res_username, (unsigned int)cy_uid, (unsigned int)cy_gid));
  83. -            (void)snprintf(principal_name, sizeof(principal_name), "%s@%s", res_username, "GLOBAL.LOC");
  84. +            (void)snprintf(principal_name, sizeof(principal_name),
  85. +                "%s@%s", res_username, context->config.localdomain_name);
  86.  
  87.              StringCchCopyA(user->username, VAL_LEN, res_username);
  88.              StringCchCopyA(user->principal, VAL_LEN, principal_name);
  89. @@ -929,7 +933,7 @@ out:
  90.  
  91.  /* public idmap interface */
  92.  int nfs41_idmap_create(
  93. -    struct idmap_context **context_out)
  94. +    struct idmap_context **context_out, const char *localdomain_name)
  95.  {
  96.      struct idmap_context *context;
  97.      int status = NO_ERROR;
  98. @@ -940,6 +944,14 @@ int nfs41_idmap_create(
  99.          goto out;
  100.      }
  101.  
  102. +    (void)strcpy_s(context->config.localdomain_name,
  103. +        sizeof(context->config.localdomain_name),
  104. +        localdomain_name);
  105. +    if (context == NULL) {
  106. +        status = GetLastError();
  107. +        goto out;
  108. +    }
  109. +
  110.      /* initialize the caches */
  111.      cache_init(&context->users, &user_cache_ops);
  112.      cache_init(&context->groups, &group_cache_ops);
  113. diff --git a/daemon/idmap.h b/daemon/idmap.h
  114. index 82b5867..6a74458 100644
  115. --- a/daemon/idmap.h
  116. +++ b/daemon/idmap.h
  117. @@ -30,7 +30,7 @@
  118.  typedef struct idmap_context nfs41_idmapper;
  119.  
  120.  int nfs41_idmap_create(
  121. -    nfs41_idmapper **context_out);
  122. +    nfs41_idmapper **context_out, const char *localdomain_name);
  123.  
  124.  void nfs41_idmap_free(
  125.      nfs41_idmapper *context);
  126. diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
  127. index febca0d..4797b00 100644
  128. --- a/daemon/nfs41_daemon.c
  129. +++ b/daemon/nfs41_daemon.c
  130. @@ -762,7 +762,10 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv)
  131.      nfs41_server_list_init();
  132.  
  133.      if (cmd_args.ldap_enable) {
  134. -        status = nfs41_idmap_create(&(nfs41_dg.idmapper));
  135. +        EASSERT(nfs41_dg.localdomain_name[0] != '\0');
  136. +
  137. +        status = nfs41_idmap_create(&(nfs41_dg.idmapper),
  138. +            nfs41_dg.localdomain_name);
  139.          if (status) {
  140.              eprintf("id mapping initialization failed with %d\n", status);
  141.              goto out_logs;
  142. diff --git a/libtirpc/src/clnt_vc.c b/libtirpc/src/clnt_vc.c
  143. index f15eb38..bc03ab3 100644
  144. --- a/libtirpc/src/clnt_vc.c
  145. +++ b/libtirpc/src/clnt_vc.c
  146. @@ -175,6 +175,7 @@ static cond_t   *vc_cv;
  147.  /* XXX Need Windows signal/event stuff XXX */
  148.  #define release_fd_lock(fd, mask) {    \
  149.         mutex_lock(&clnt_fd_lock);      \
  150. +        assert(vc_fd_locks[(fd)] != 0); \
  151.         vc_fd_locks[(fd)] = 0;          \
  152.         \
  153.         cond_broadcast(&vc_cv[(fd)]);   \
  154. @@ -195,6 +196,16 @@ static const char clnt_vc_str[] = "clnt_vc_create";
  155.  static const char clnt_read_vc_str[] = "read_vc";
  156.  static const char __no_mem_str[] = "out of memory";
  157.  
  158. +#if 1
  159. +#define TIRPCDbgEnter() __try {
  160. +
  161. +#define TIRPCDbgLeave() } \
  162. +    __except(EXCEPTION_EXECUTE_HANDLER) { \
  163. +        (void)fprintf(stderr, \
  164. +            "#### FATAL: exception in '%s'/%ld ####\n", \
  165. +            __FILE__, (long)__LINE__);  }
  166. +#endif
  167. +
  168.  /* callback thread */
  169.  #define CALLBACK_TIMEOUT 5000
  170.  #define        RQCRED_SIZE     400     /* this size is excessive */
  171. @@ -211,20 +222,45 @@ static unsigned int WINAPI clnt_cb_thread(void *args)
  172.  
  173.      (void)fprintf(stderr/*stdout*/,
  174.          "%04lx: cb: Callback thread running\n", (long)GetCurrentThreadId());
  175. +
  176. +#if 1
  177. +    int cond_wait_timed_fails;
  178. +    DWORD lasterr;
  179. +
  180. +loop_restart:
  181. +#endif
  182.      while(1) {
  183.          cb_req header;
  184.          void *res = NULL;
  185. +
  186. +#if 1
  187. +        TIRPCDbgEnter();
  188. +#endif
  189.          mutex_lock(&clnt_fd_lock);
  190. +#if 1
  191. +        cond_wait_timed_fails = 0;
  192. +#endif
  193.         while (vc_fd_locks[ct->ct_fd] ||
  194.              !ct->use_stored_reply_msg ||
  195.              (ct->use_stored_reply_msg && ct->reply_msg.rm_direction != CALL)) {
  196.              if (cl->shutdown)
  197.                  break;
  198.             if (!cond_wait_timed(&vc_cv[ct->ct_fd], &clnt_fd_lock,
  199. -                CALLBACK_TIMEOUT))
  200. +                CALLBACK_TIMEOUT)) {
  201. +#if 1
  202. +                lasterr = GetLastError();
  203. +                if (cond_wait_timed_fails++ > 2) {
  204. +                    mutex_unlock(&clnt_fd_lock);
  205. +                    (void)fprintf(stdout,
  206. +                        "%04lx: cb: possible deadlockm, lasterr=%d\n",
  207. +                        (long)GetCurrentThreadId(), (int)lasterr);
  208. +                    goto loop_restart;
  209. +                }
  210. +#endif
  211.                  if (!vc_fd_locks[ct->ct_fd])
  212.                      break;
  213.              }
  214. +       }
  215.         vc_fd_locks[ct->ct_fd] = 1;
  216.         mutex_unlock(&clnt_fd_lock);
  217.  
  218. @@ -316,6 +352,9 @@ skip_setlastfrag:
  219.          ct->ct_wait.tv_sec = saved_timeout_sec;
  220.          ct->ct_wait.tv_usec = saved_timeout_usec;
  221.          release_fd_lock(ct->ct_fd, mask);
  222. +#if 1
  223. +        TIRPCDbgLeave();
  224. +#endif
  225.      }
  226.  out:
  227.      return status;

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