pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


ACL work, backup 2024-06-15
Posted by Anonymous on Sat 15th Jun 2024 14:11
raw | new post
view followups (newest first): ACL work, backup 2024-06-18 by Anonymous

  1. diff --git a/daemon/acl.c b/daemon/acl.c
  2. index 54a5815..26dc42e 100644
  3. --- a/daemon/acl.c
  4. +++ b/daemon/acl.c
  5. @@ -100,6 +100,118 @@ static int check_4_special_identifiers(char *who, PSID *sid, DWORD *sid_len,
  6.      return status;
  7.  }
  8.  
  9. +static void map_nfs4acemask2winaccessmask(uint32_t nfs4_mask, int file_type, ACCESS_MASK *winmask)
  10. +{
  11. +    DPRINTF(0,
  12. +        ("--> map_nfs4acemask2winaccessmask("
  13. +            "nfs4_mask=0x%x,file_type=%d)\n",
  14. +            (int)nfs4_mask, file_type));
  15. +    print_nfs_access_mask(1, nfs4_mask);
  16. +    bool is_generic = false;
  17. +
  18. +    /*
  19. +     * Generic masks
  20. +     * (|ACE4_GENERIC_*| contain multiple bits
  21. +     */
  22. +    if ((nfs4_mask & ACE4_GENERIC_READ) == ACE4_GENERIC_READ) {
  23. +        *winmask |= GENERIC_READ;
  24. +        is_generic = true;
  25. +    }
  26. +    if ((nfs4_mask & ACE4_GENERIC_WRITE) == ACE4_GENERIC_WRITE) {
  27. +        *winmask |= GENERIC_WRITE;
  28. +        is_generic = true;
  29. +    }
  30. +    if ((nfs4_mask & ACE4_GENERIC_EXECUTE) == ACE4_GENERIC_EXECUTE) {
  31. +        *winmask |= GENERIC_EXECUTE;
  32. +        is_generic = true;
  33. +    }
  34. +    if (file_type == NF4DIR) {
  35. +        if ((nfs4_mask & ACE4_ALL_DIR) == ACE4_ALL_DIR) {
  36. +            *winmask |= GENERIC_ALL;
  37. +            is_generic = true;
  38. +        }
  39. +    }
  40. +    else {
  41. +        if ((nfs4_mask & ACE4_ALL_FILE) == ACE4_ALL_FILE) {
  42. +            *winmask |= GENERIC_ALL;
  43. +            is_generic = true;
  44. +        }
  45. +    }
  46. +#if 0
  47. +    if (is_generic)
  48. +        goto mapping_done;
  49. +#endif
  50. +    /* Individual flags */
  51. +    if (file_type == NF4DIR) {
  52. +        if (nfs4_mask & ACE4_LIST_DIRECTORY) {
  53. +            *winmask |= FILE_LIST_DIRECTORY;
  54. +        }
  55. +        if (nfs4_mask & ACE4_ADD_FILE) {
  56. +            *winmask |= FILE_ADD_FILE;
  57. +        }
  58. +        if (nfs4_mask & ACE4_ADD_SUBDIRECTORY) {
  59. +            *winmask |= FILE_ADD_SUBDIRECTORY;
  60. +        }
  61. +        if (nfs4_mask & ACE4_DELETE_CHILD) {
  62. +            *winmask |= FILE_DELETE_CHILD;
  63. +        }
  64. +        if (nfs4_mask & ACE4_EXECUTE) {
  65. +            *winmask |= FILE_TRAVERSE;
  66. +        }
  67. +    }
  68. +    else {
  69. +        if (nfs4_mask & ACE4_READ_DATA) {
  70. +            *winmask |= FILE_READ_DATA;
  71. +        }
  72. +        if (nfs4_mask & ACE4_WRITE_DATA) {
  73. +            *winmask |= FILE_WRITE_DATA;
  74. +        }
  75. +        if (nfs4_mask & ACE4_APPEND_DATA) {
  76. +            *winmask |= FILE_APPEND_DATA;
  77. +        }
  78. +        if (nfs4_mask & ACE4_EXECUTE) {
  79. +            *winmask |= FILE_EXECUTE;
  80. +        }
  81. +    }
  82. +
  83. +#ifdef NOT_IMPLEMENTED_YET
  84. +    if (nfs4_mask & ACE4_READ_NAMED_ATTRS) {
  85. +        *winmask |= xxx;
  86. +    }
  87. +    if (nfs4_mask & ACE4_WRITE_NAMED_ATTRS) {
  88. +        *winmask |= xxx;
  89. +    }
  90. +#endif /* NOT_IMPLEMENTED_YET */
  91. +    if (nfs4_mask & ACE4_READ_ATTRIBUTES) {
  92. +        *winmask |= FILE_READ_ATTRIBUTES;
  93. +    }
  94. +    if (nfs4_mask & ACE4_WRITE_ATTRIBUTES) {
  95. +        *winmask |= FILE_WRITE_ATTRIBUTES;
  96. +    }
  97. +    if (nfs4_mask & ACE4_READ_ACL) {
  98. +        *winmask |= READ_CONTROL;
  99. +    }
  100. +    if (nfs4_mask & ACE4_WRITE_ACL) {
  101. +        *winmask |= WRITE_DAC;
  102. +    }
  103. +    if (nfs4_mask & ACE4_WRITE_OWNER) {
  104. +        *winmask |= WRITE_OWNER;
  105. +    }
  106. +    if (nfs4_mask & ACE4_SYNCHRONIZE) {
  107. +        *winmask |= SYNCHRONIZE;
  108. +    }
  109. +    if (nfs4_mask & ACE4_DELETE) {
  110. +        *winmask |= DELETE;
  111. +    }
  112. +
  113. +mapping_done:
  114. +    print_windows_access_mask(1, *winmask);
  115. +    DPRINTF(0,
  116. +        ("<-- map_nfs4acemask2winaccessmask("
  117. +            "nfs4_mask=0x%x,file_type=%d,*winmask=0x%x)\n",
  118. +            (int)nfs4_mask, file_type, (int)*winmask));
  119. +}
  120. +
  121.  static int convert_nfs4acl_2_dacl(nfs41_daemon_globals *nfs41dg,
  122.      nfsacl41 *acl, int file_type, PACL *dacl_out, PSID **sids_out)
  123.  {
  124. @@ -162,8 +274,14 @@ static int convert_nfs4acl_2_dacl(nfs41_daemon_globals *nfs41dg,
  125.          for (i = 0; i < acl->count; i++) {
  126.              win_aceflags = 0;
  127.  
  128. +#if 0
  129.              // nfs4 acemask should be exactly the same as file access mask
  130.              mask = acl->aces[i].acemask;
  131. +#else
  132. +            mask = 0;
  133. +            map_nfs4acemask2winaccessmask(acl->aces[i].acemask,
  134. +                file_type, &mask);
  135. +#endif
  136.              map_nfs4aceflags2winaceflags(acl->aces[i].aceflag, &win_aceflags);
  137.  
  138.              DPRINTF(ACLLVL, ("aces[%d].who='%s': "
  139. @@ -523,34 +641,104 @@ static void map_nfs4aceflags2winaceflags(uint32_t nfs4_aceflags, DWORD *win_acef
  140.          (int)nfs4_aceflags, (int)*win_aceflags));
  141.  }
  142.  
  143. -static void map_winaccessmask2nfs4acemask(ACCESS_MASK mask, int file_type, uint32_t *nfs4_mask)
  144. +static void map_winaccessmask2nfs4acemask(ACCESS_MASK winmask, int file_type, uint32_t *nfs4_mask)
  145.  {
  146. -    DPRINTF(ACLLVL,
  147. -        ("--> map_winaccessmask2nfs4acemask(mask=0x%x)\n",
  148. -        (int)mask));
  149. -    print_windows_access_mask(ACLLVL, mask);
  150. +    DPRINTF(0,
  151. +        ("--> map_winaccessmask2nfs4acemask("
  152. +        "winmask=0x%x,file_type=%d)\n",
  153. +        (int)winmask, file_type));
  154. +    print_windows_access_mask(1, winmask);
  155.      /* check if any GENERIC bits set */
  156. -    if (mask & 0xf000000) {
  157. -        if (mask & GENERIC_ALL) {
  158. +    if (winmask & 0xf000000) {
  159. +        if (winmask & GENERIC_ALL) {
  160.              if (file_type == NF4DIR)
  161.                  *nfs4_mask |= ACE4_ALL_DIR;
  162.              else
  163.                  *nfs4_mask |= ACE4_ALL_FILE;
  164.          } else {
  165. -            if (mask & GENERIC_READ)
  166. +            if (winmask & GENERIC_READ)
  167.                  *nfs4_mask |= ACE4_GENERIC_READ;
  168. -            if (mask & GENERIC_WRITE)
  169. +            if (winmask & GENERIC_WRITE)
  170.                  *nfs4_mask |= ACE4_GENERIC_WRITE;
  171. -            if (mask & GENERIC_EXECUTE)
  172. +            if (winmask & GENERIC_EXECUTE)
  173.                  *nfs4_mask |= ACE4_GENERIC_EXECUTE;
  174.          }
  175.      }
  176. -    else /* ignoring generic and reserved bits */
  177. +    else {
  178. +#if 0
  179. +        /* ignoring generic and reserved bits */
  180.          *nfs4_mask = mask & 0x00ffffff;
  181. -    print_nfs_access_mask(ACLLVL, *nfs4_mask);
  182. -    DPRINTF(ACLLVL,
  183. -        ("<-- map_winaccessmask2nfs4acemask(mask=0x%x, *nfs4_mask=0x%x)\n",
  184. -        (int)mask, (int)*nfs4_mask));
  185. +#else
  186. +        /* Individual flags */
  187. +        if (file_type == NF4DIR) {
  188. +            if (winmask & FILE_LIST_DIRECTORY) {
  189. +                *nfs4_mask |= ACE4_LIST_DIRECTORY;
  190. +            }
  191. +            if (winmask & FILE_ADD_FILE) {
  192. +                *nfs4_mask |= ACE4_ADD_FILE;
  193. +            }
  194. +            if (winmask & FILE_ADD_SUBDIRECTORY) {
  195. +                *nfs4_mask |= ACE4_ADD_SUBDIRECTORY;
  196. +            }
  197. +            if (winmask & FILE_DELETE_CHILD) {
  198. +                *nfs4_mask |= ACE4_DELETE_CHILD;
  199. +            }
  200. +            if (winmask & FILE_TRAVERSE) {
  201. +                *nfs4_mask |= ACE4_EXECUTE;
  202. +            }
  203. +        }
  204. +        else {
  205. +            if (winmask & FILE_READ_DATA) {
  206. +                *nfs4_mask |= ACE4_READ_DATA;
  207. +            }
  208. +            if (winmask & FILE_WRITE_DATA) {
  209. +                *nfs4_mask |= ACE4_WRITE_DATA;
  210. +            }
  211. +            if (winmask & FILE_APPEND_DATA) {
  212. +                *nfs4_mask |= ACE4_APPEND_DATA;
  213. +            }
  214. +            if (winmask & FILE_EXECUTE) {
  215. +                *nfs4_mask |= ACE4_EXECUTE;
  216. +            }
  217. +        }
  218. +    }
  219. +
  220. +#ifdef NOT_IMPLEMENTED_YET
  221. +    if (winmask & xxx) {
  222. +        *nfs4_mask |= ACE4_READ_NAMED_ATTRS;
  223. +    }
  224. +    if (winmask & xxx) {
  225. +        *nfs4_mask |= ACE4_WRITE_NAMED_ATTRS;
  226. +    }
  227. +#endif /* NOT_IMPLEMENTED_YET */
  228. +    if (winmask & FILE_READ_ATTRIBUTES) {
  229. +        *nfs4_mask |= ACE4_READ_ATTRIBUTES;
  230. +    }
  231. +    if (winmask & FILE_WRITE_ATTRIBUTES) {
  232. +        *nfs4_mask |= ACE4_WRITE_ATTRIBUTES;
  233. +    }
  234. +    if (winmask & READ_CONTROL) {
  235. +        *nfs4_mask |= ACE4_READ_ACL;
  236. +    }
  237. +    if (winmask & WRITE_DAC) {
  238. +        *nfs4_mask |= ACE4_WRITE_ACL;
  239. +    }
  240. +    if (winmask & WRITE_OWNER) {
  241. +        *nfs4_mask |= ACE4_WRITE_OWNER;
  242. +    }
  243. +    if (winmask & SYNCHRONIZE) {
  244. +        *nfs4_mask |= ACE4_SYNCHRONIZE;
  245. +    }
  246. +    if (winmask & DELETE) {
  247. +        *nfs4_mask |= ACE4_DELETE;
  248. +    }
  249. +#endif
  250. +
  251. +    print_nfs_access_mask(1, *nfs4_mask);
  252. +    DPRINTF(0,
  253. +        ("<-- map_winaccessmask2nfs4acemask("
  254. +            "winmask=0x%x,file_type=%d,*nfs4_mask=0x%x)\n",
  255. +            (int)winmask, file_type, (int)*nfs4_mask));
  256.  }
  257.  
  258.  static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_out, char *domain, SID_NAME_USE *sid_type_out)
  259. diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
  260. index ab4cee6..685ecce 100644
  261. --- a/daemon/daemon_debug.c
  262. +++ b/daemon/daemon_debug.c
  263. @@ -805,7 +805,7 @@ void print_windows_access_mask(int on, ACCESS_MASK m)
  264.  {
  265.      if (!on)
  266.          return;
  267. -    if (!DPRINTF_LEVEL_ENABLED(1))
  268. +    if (!DPRINTF_LEVEL_ENABLED(0))
  269.          return;
  270.  
  271.      dprintf_out("--> print_windows_access_mask: %x\n", m);
  272. @@ -878,7 +878,7 @@ void print_windows_access_mask(int on, ACCESS_MASK m)
  273.  void print_nfs_access_mask(int on, int m)
  274.  {
  275.      if (!on) return;
  276. -    if (!DPRINTF_LEVEL_ENABLED(1))
  277. +    if (!DPRINTF_LEVEL_ENABLED(0))
  278.          return;
  279.  
  280.      dprintf_out("--> print_nfs_access_mask: %x\n", m);
  281. diff --git a/daemon/nfs41_const.h b/daemon/nfs41_const.h
  282. index 5010816..9613ea9 100644
  283. --- a/daemon/nfs41_const.h
  284. +++ b/daemon/nfs41_const.h
  285. @@ -373,30 +373,30 @@ enum nfs_ftype4 {
  286.  #define ACE4_WRITE_OWNER          0x00080000
  287.  #define ACE4_SYNCHRONIZE          0x00100000
  288.  
  289. -#define ACE4_ALL_FILE ACE4_READ_DATA|ACE4_WRITE_DATA|ACE4_APPEND_DATA| \
  290. +#define ACE4_ALL_FILE (ACE4_READ_DATA|ACE4_WRITE_DATA|ACE4_APPEND_DATA| \
  291.          ACE4_READ_NAMED_ATTRS|ACE4_WRITE_NAMED_ATTRS|ACE4_EXECUTE| \
  292.          ACE4_READ_ATTRIBUTES|ACE4_WRITE_ATTRIBUTES| \
  293.          ACE4_DELETE|ACE4_READ_ACL|ACE4_WRITE_ACL|ACE4_WRITE_OWNER| \
  294. -        ACE4_SYNCHRONIZE
  295. -#define ACE4_ALL_DIR ACE4_READ_DATA|ACE4_WRITE_DATA|ACE4_APPEND_DATA| \
  296. +        ACE4_SYNCHRONIZE)
  297. +#define ACE4_ALL_DIR (ACE4_READ_DATA|ACE4_WRITE_DATA|ACE4_APPEND_DATA| \
  298.          ACE4_READ_NAMED_ATTRS|ACE4_WRITE_NAMED_ATTRS|ACE4_EXECUTE| \
  299.          ACE4_DELETE_CHILD|ACE4_READ_ATTRIBUTES|ACE4_WRITE_ATTRIBUTES| \
  300.          ACE4_DELETE|ACE4_READ_ACL|ACE4_WRITE_ACL|ACE4_WRITE_OWNER| \
  301. -        ACE4_SYNCHRONIZE
  302. +        ACE4_SYNCHRONIZE)
  303.  
  304. -#define ACE4_GENERIC_READ ACE4_READ_DATA|ACE4_READ_NAMED_ATTRS| \
  305. -        ACE4_READ_ATTRIBUTES|ACE4_READ_ACL|ACE4_SYNCHRONIZE
  306. -#define ACE4_GENERIC_WRITE ACE4_WRITE_DATA|ACE4_WRITE_NAMED_ATTRS| \
  307. -        ACE4_WRITE_ATTRIBUTES|ACE4_READ_ACL|ACE4_SYNCHRONIZE
  308. -#define ACE4_GENERIC_EXECUTE ACE4_EXECUTE|ACE4_READ_ATTRIBUTES| \
  309. -        ACE4_READ_ACL|ACE4_SYNCHRONIZE
  310. +#define ACE4_GENERIC_READ (ACE4_READ_DATA|ACE4_READ_NAMED_ATTRS| \
  311. +        ACE4_READ_ATTRIBUTES|ACE4_READ_ACL|ACE4_SYNCHRONIZE)
  312. +#define ACE4_GENERIC_WRITE (ACE4_WRITE_DATA|ACE4_WRITE_NAMED_ATTRS| \
  313. +        ACE4_WRITE_ATTRIBUTES|ACE4_READ_ACL|ACE4_SYNCHRONIZE)
  314. +#define ACE4_GENERIC_EXECUTE (ACE4_EXECUTE|ACE4_READ_ATTRIBUTES| \
  315. +        ACE4_READ_ACL|ACE4_SYNCHRONIZE)
  316.  
  317.  
  318.  
  319. -#define ACE4_FILE_ALL_ACCESS ACE4_READ_DATA|ACE4_LIST_DIRECTORY| \
  320. +#define ACE4_FILE_ALL_ACCESS (ACE4_READ_DATA|ACE4_LIST_DIRECTORY| \
  321.          ACE4_WRITE_DATA|ACE4_ADD_FILE|ACE4_APPEND_DATA|ACE4_ADD_SUBDIRECTORY| \
  322.          ACE4_READ_NAMED_ATTRS|ACE4_WRITE_NAMED_ATTRS|ACE4_EXECUTE| \
  323. -        ACE4_READ_ATTRIBUTES|ACE4_WRITE_ATTRIBUTES
  324. +        ACE4_READ_ATTRIBUTES|ACE4_WRITE_ATTRIBUTES)
  325.  
  326.  /* ACLS aceflag4 field constants */
  327.  #define ACE4_FILE_INHERIT_ACE             0x00000001
  328. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  329. index 58a312c..ae86c2a 100644
  330. --- a/sys/nfs41_driver.c
  331. +++ b/sys/nfs41_driver.c
  332. @@ -371,7 +371,11 @@ typedef struct _NFS41_NETROOT_EXTENSION {
  333.          (PNFS41_NETROOT_EXTENSION)((pNetRoot)->Context))
  334.  
  335.  /* FileSystemName as reported by FileFsAttributeInfo query */
  336. +#if 1
  337.  #define FS_NAME     L"NFS"
  338. +#else
  339. +#define FS_NAME     L"NFS41"
  340. +#endif
  341.  #define FS_NAME_LEN (sizeof(FS_NAME) - sizeof(WCHAR))
  342.  #define FS_ATTR_LEN (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + FS_NAME_LEN)

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