pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


WS2022 compatility hacks
Posted by Anonymous on Mon 11th Nov 2024 13:17
raw | new post

  1. diff --git a/daemon/acl.c b/daemon/acl.c
  2. index 8622678..07de74e 100644
  3. --- a/daemon/acl.c
  4. +++ b/daemon/acl.c
  5. @@ -99,12 +99,24 @@ static int check_4_special_identifiers(char *who, PSID *sid, DWORD *sid_len,
  6.      *flag = TRUE;
  7.      if (!strncmp(who, ACE4_OWNER, strlen(ACE4_OWNER)-1))
  8.          type = WinCreatorOwnerSid;
  9. +#if 1
  10. +    else if (!strncmp(who, "CREATOR OWNER@", strlen("CREATOR OWNER@")-1))
  11. +        type = WinCreatorOwnerSid;
  12. +#endif
  13.      else if (!strncmp(who, ACE4_GROUP, strlen(ACE4_GROUP)-1))
  14.          type = WinCreatorGroupSid;
  15.      else if (!strncmp(who, ACE4_EVERYONE, strlen(ACE4_EVERYONE)-1))
  16.          type = WinWorldSid;
  17. +#if 1
  18. +    else if (!strncmp(who, "Everyone@", strlen("Everyone@")-1))
  19. +        type = WinWorldSid;
  20. +#endif
  21.      else if (!strncmp(who, ACE4_NOBODY, strlen(ACE4_NOBODY)))
  22.          type = WinNullSid;
  23. +#if 1
  24. +    else if (!strncmp(who, "NULL SID", strlen("NULL SID")))
  25. +        type = WinNullSid;
  26. +#endif
  27.      else
  28.          *flag = FALSE;
  29.      if (*flag)
  30. @@ -149,6 +161,10 @@ static int convert_nfs4acl_2_dacl(nfs41_daemon_globals *nfs41dg,
  31.          DPRINTF(ACLLVL2, ("convert_nfs4acl_2_dacl: for user='%s' domain='%s'\n",
  32.                  curr_nfsace->who, domain?domain:"<null>"));
  33.  
  34. +        EASSERT_MSG(!isdigit(curr_nfsace->who[0]),
  35. +            ("convert_nfs4acl_2_dacl: aces[%d]->who='%s' uses numeric id",
  36. +            (int)nfs_i, curr_nfsace->who));
  37. +
  38.  #ifdef NFS41_DRIVER_ACLS_SETACL_SKIP_WINNULLSID_ACES
  39.          /*
  40.           * Skip "nobody" ACEs - Cygwin uses |WinNullSid| ACEs (mapped
  41. @@ -174,6 +190,19 @@ static int convert_nfs4acl_2_dacl(nfs41_daemon_globals *nfs41dg,
  42.          if (!flag) {
  43.              bool isgroupacl = (curr_nfsace->aceflag & ACE4_IDENTIFIER_GROUP)?true:false;
  44.  
  45. +
  46. +#if 1
  47. +            if ((isgroupacl == false) && domain &&
  48. +                (!strcmp(domain, "BUILTIN"))) {
  49. +                if ((!strcmp(curr_nfsace->who, "Users")) ||
  50. +                    (!strcmp(curr_nfsace->who, "Administrators"))) {
  51. +                    DPRINTF(0, ("convert_nfs4acl_2_dacl: "
  52. +                        "force isgroupacl=true for for user='%s'\n",
  53. +                        curr_nfsace->who));
  54. +                    isgroupacl = true;
  55. +                }
  56. +            }
  57. +#endif
  58.              if (isgroupacl) {
  59.                  DPRINTF(ACLLVL2,
  60.                      ("convert_nfs4acl_2_dacl: aces[%d].who='%s': "
  61. @@ -1011,7 +1040,7 @@ int map_sid2nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid,
  62.                              "Unix_User+%d SID "
  63.                              "mapped to user '%s'\n",
  64.                              unixuser_uid, who_out));
  65. -                        goto add_domain;
  66. +                        goto no_add_domain;
  67.                      }
  68.  
  69.                      eprintf("map_sid2nfs4ace_who: "
  70. @@ -1032,7 +1061,7 @@ int map_sid2nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid,
  71.                              "Unix_Group+%d SID "
  72.                              "mapped to group '%s'\n",
  73.                              unixgroup_gid, who_out));
  74. -                        goto add_domain;
  75. +                        goto no_add_domain;
  76.                      }
  77.  
  78.                      eprintf("map_sid2nfs4ace_who: "
  79. @@ -1078,7 +1107,26 @@ err_none_mapped:
  80.      (void)memcpy(who_out, who_buf, who_size);
  81.  add_domain:
  82.      (void)memcpy(who_out+who_size, "@", sizeof(char));
  83. +
  84. +#if 1
  85. +    /* Fixup |domain| for Windows Sever 2022 NFSv4.1 server */
  86. +    if ((!strncmp(who_out, "Users@", who_size+1)) ||
  87. +        (!strncmp(who_out, "Administrators@", who_size+1))) {
  88. +        domain = "BUILTIN";
  89. +        DPRINTF(0,
  90. +            ("map_sid2nfs4ace_who: Fixup '%*s' domain='%s'\n",
  91. +            (int)who_size+1, who_out, domain));
  92. +    }
  93. +    else if (!strncmp(who_out, "SYSTEM@", who_size+1)) {
  94. +        domain = "NT AUTHORITY";
  95. +        DPRINTF(0,
  96. +            ("map_sid2nfs4ace_who: Fixup '%*s' domain='%s'\n",
  97. +            (int)who_size+1, who_out, domain));
  98. +    }
  99. +#endif
  100.      (void)memcpy(who_out+who_size+1, domain, strlen(domain)+1);
  101. +
  102. +no_add_domain:
  103.      status = ERROR_SUCCESS;
  104.  out:
  105.      if (status) {
  106. @@ -1326,8 +1374,8 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
  107.      char ownerbuf[NFS4_FATTR4_OWNER_LIMIT+1];
  108.      char groupbuf[NFS4_FATTR4_OWNER_LIMIT+1];
  109.  
  110. -    DPRINTF(ACLLVL1, ("--> handle_setacl(state->path.path='%s')\n",
  111. -        state->path.path));
  112. +    DPRINTF(ACLLVL1, ("--> handle_setacl(state->path.path='%s',args->query=0x%x)\n",
  113. +        state->path.path, (int)args->query));
  114.  
  115.      if (args->query & OWNER_SECURITY_INFORMATION) {
  116.          DPRINTF(ACLLVL2, ("handle_setacl: OWNER_SECURITY_INFORMATION\n"));
  117. @@ -1343,6 +1391,10 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
  118.          if (status)
  119.              goto out;
  120.  
  121. +        DPRINTF(0,
  122. +            ("handle_setacl: OWNER_SECURITY_INFORMATION, info.owner='%s'\n",
  123. +            ownerbuf));
  124. +
  125.          info.owner = ownerbuf;
  126.          info.attrmask.arr[1] |= FATTR4_WORD1_OWNER;
  127.          info.attrmask.count = 2;
  128. @@ -1365,6 +1417,10 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
  129.          if (status)
  130.              goto out;
  131.  
  132. +        DPRINTF(0,
  133. +            ("handle_setacl: GROUP_SECURITY_INFORMATION, info.owner_group='%s'\n",
  134. +            groupbuf));
  135. +
  136.          info.owner_group = groupbuf;
  137.          info.attrmask.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
  138.          info.attrmask.count = 2;
  139. diff --git a/daemon/sid.c b/daemon/sid.c
  140. index 2a63763..46eb8b0 100644
  141. --- a/daemon/sid.c
  142. +++ b/daemon/sid.c
  143. @@ -617,16 +617,30 @@ out_cache:
  144.               */
  145.              DPRINTF(1, ("map_nfs4servername_2_sid(query=%x,nfsname='%s'): "
  146.                  "SID_TYPE='SidTypeAlias' mapped to 'SidTypeGroup'\n",
  147. -                query, orig_nfsname, sid_type));
  148. +                query, orig_nfsname));
  149.              sid_type = SidTypeGroup;
  150.          }
  151.  
  152. +#if 1
  153. +        if ((query & OWNER_SECURITY_INFORMATION) &&
  154. +            (sid_type == SidTypeWellKnownGroup)) {
  155. +            if (!strcmp(orig_nfsname, "SYSTEM")) {
  156. +                DPRINTF(1, ("map_nfs4servername_2_sid(query=%x,nfsname='%s'): "
  157. +                    "SID_TYPE='SidTypeWellKnownGroup' mapped to 'SidTypeUser' for user\n",
  158. +                    query, orig_nfsname));
  159. +                sid_type = SidTypeUser;
  160. +            }
  161. +        }
  162. +#endif
  163. +
  164.          switch (sid_type) {
  165.              case SidTypeUser:
  166. -                sidcache_add(&user_sidcache, orig_nfsname, *sid);
  167. +                if (!isdigit(orig_nfsname[0]))
  168. +                    sidcache_add(&user_sidcache, orig_nfsname, *sid);
  169.                  break;
  170.              case SidTypeGroup:
  171. -                sidcache_add(&group_sidcache, orig_nfsname, *sid);
  172. +                if (!isdigit(orig_nfsname[0]))
  173. +                    sidcache_add(&group_sidcache, orig_nfsname, *sid);
  174.                  break;
  175.              default:
  176.                  eprintf("map_nfs4servername_2_sid(query=%x,nfsname='%s'): "

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