pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


multiuser experiment
Posted by Anonymous on Tue 23rd Apr 2024 11:02
raw | new post

  1. diff --git a/daemon/namespace.c b/daemon/namespace.c
  2. index e490aad..7a22e5c 100644
  3. --- a/daemon/namespace.c
  4. +++ b/daemon/namespace.c
  5. @@ -23,11 +23,12 @@
  6.  #include <strsafe.h>
  7.  
  8.  #include "nfs41_ops.h"
  9. +#include "nfs41_daemon.h"
  10.  #include "util.h"
  11.  #include "daemon_debug.h"
  12.  
  13.  
  14. -#define NSLVL 2 /* dprintf level for namespace logging */
  15. +#define NSLVL 0 /* dprintf level for namespace logging */
  16.  
  17.  
  18.  #define client_entry(pos) list_container(pos, nfs41_client, root_entry)
  19. @@ -97,7 +98,7 @@ void nfs41_root_ref(
  20.  {
  21.      const LONG count = InterlockedIncrement(&root->ref_count);
  22.  
  23. -    DPRINTF(NSLVL, ("nfs41_root_ref() count %d\n", count));
  24. +//    DPRINTF(NSLVL, ("nfs41_root_ref() count %d\n", count));
  25.  }
  26.  
  27.  void nfs41_root_deref(
  28. @@ -105,7 +106,7 @@ void nfs41_root_deref(
  29.  {
  30.      const LONG count = InterlockedDecrement(&root->ref_count);
  31.  
  32. -    DPRINTF(NSLVL, ("nfs41_root_deref() count %d\n", count));
  33. +//    DPRINTF(NSLVL, ("nfs41_root_deref() count %d\n", count));
  34.      if (count == 0)
  35.          root_free(root);
  36.  }
  37. @@ -115,6 +116,8 @@ void nfs41_root_deref(
  38.  struct cl_addr_info {
  39.      const multi_addr4       *addrs;
  40.      uint32_t                roles;
  41. +    uid_t                   uid;
  42. +    gid_t                   gid;
  43.  };
  44.  
  45.  static int cl_addr_compare(
  46. @@ -136,6 +139,8 @@ static int cl_addr_compare(
  47.      /* match any address in 'addrs' with any address in client->rpc->addrs */
  48.      for (i = 0; i < info->addrs->count; i++)
  49.          if (multi_addr_find(&client->rpc->addrs, &info->addrs->arr[i], NULL))
  50. +            if ((client->rpc->uid == info->uid) &&
  51. +                (client->rpc->gid == info->gid))
  52.                  return NO_ERROR;
  53.  
  54.      return ERROR_FILE_NOT_FOUND;
  55. @@ -156,6 +161,13 @@ static int root_client_find_addrs(
  56.      info.addrs = addrs;
  57.      info.roles = nfs41_exchange_id_flags(is_data) & EXCHGID4_FLAG_MASK_PNFS;
  58.  
  59. +#if 1
  60. +extern nfs41_daemon_globals nfs41_dg;
  61. +int map_current_user_to_ids(nfs41_idmapper *idmapper, uid_t *puid, gid_t *pgid);
  62. +
  63. +    (void)map_current_user_to_ids(nfs41_dg.idmapper, &info.uid, &info.gid);
  64. +#endif
  65. +
  66.      entry = list_search(&root->clients, &info, cl_addr_compare);
  67.      if (entry) {
  68.          *client_out = client_entry(entry);
  69. diff --git a/daemon/nfs41_client.c b/daemon/nfs41_client.c
  70. index 2707414..c081df5 100644
  71. --- a/daemon/nfs41_client.c
  72. +++ b/daemon/nfs41_client.c
  73. @@ -369,6 +369,7 @@ int nfs41_client_owner(
  74.      const ULONGLONG time_created = GetTickCount64();
  75.      int status;
  76.      char username[UNLEN+1];
  77. +    char pgroupname[GNLEN+1];
  78.  
  79.      /*
  80.       * gisburn: What about primary group (for /usr/bin/newgrp
  81. @@ -380,6 +381,12 @@ int nfs41_client_owner(
  82.          eprintf("get_token_user_name() failed with %d\n", status);
  83.          goto out;
  84.      }
  85. +    if (!get_token_primarygroup_name(GetCurrentThreadEffectiveToken(),
  86. +        pgroupname)) {
  87. +        status = GetLastError();
  88. +        eprintf("get_token_primary_group_name() failed with %d\n", status);
  89. +        goto out;
  90. +    }
  91.  
  92.      /* owner.verifier = "time created" */
  93.      memcpy(owner->co_verifier, &time_created, sizeof(time_created));
  94. @@ -403,11 +410,26 @@ int nfs41_client_owner(
  95.          goto out_hash;
  96.      }
  97.  
  98. +#if 1
  99. +    /* hack */
  100. +    static int uniq_counter = 0;
  101. +    uniq_counter++;
  102. +    if (!CryptHashData(hash, (const BYTE*)&uniq_counter, (DWORD)sizeof(uniq_counter), 0)) {
  103. +        status = GetLastError();
  104. +        eprintf("CryptHashData() failed with %d\n", status);
  105. +        goto out_hash;
  106. +    }
  107. +#endif
  108.      if (!CryptHashData(hash, (const BYTE*)username, (DWORD)strlen(username), 0)) {
  109.          status = GetLastError();
  110.          eprintf("CryptHashData() failed with %d\n", status);
  111.          goto out_hash;
  112.      }
  113. +    if (!CryptHashData(hash, (const BYTE*)pgroupname, (DWORD)strlen(pgroupname), 0)) {
  114. +        status = GetLastError();
  115. +        eprintf("CryptHashData() failed with %d\n", status);
  116. +        goto out_hash;
  117. +    }
  118.  
  119.      if (!CryptHashData(hash, (const BYTE*)name, (DWORD)strlen(name), 0)) {
  120.          status = GetLastError();
  121. @@ -445,6 +467,15 @@ int nfs41_client_owner(
  122.          goto out_hash;
  123.      }
  124.  
  125. +#if 1
  126. +    (void)fprintf(stderr, "nfs41_client_owner: len=%d\nnfs41_client_owner: id='", owner->co_ownerid_len);
  127. +    unsigned int i;
  128. +    for (i=0 ; i < owner->co_ownerid_len ; i++) {
  129. +        (void)fprintf(stderr, "%2.2x", (int)*(((char *)owner->co_ownerid)+i));
  130. +    }
  131. +    (void)fprintf(stderr, "'\n");
  132. +#endif
  133. +
  134.  out_hash:
  135.      CryptDestroyHash(hash);
  136.  out_context:
  137. diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
  138. index c7bef5f..c0e21b2 100644
  139. --- a/daemon/nfs41_daemon.c
  140. +++ b/daemon/nfs41_daemon.c
  141. @@ -67,7 +67,7 @@ typedef struct _nfs41_process_thread {
  142.      uint32_t tid;
  143.  } nfs41_process_thread;
  144.  
  145. -static int map_current_user_to_ids(nfs41_idmapper *idmapper, uid_t *puid, gid_t *pgid)
  146. +int map_current_user_to_ids(nfs41_idmapper *idmapper, uid_t *puid, gid_t *pgid)
  147.  {
  148.      char username[UNLEN+1];
  149.      char pgroupname[GNLEN+1];

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