- From bbc56c7eed9a705359264ad7f86791d199528869 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Fri, 21 Jun 2024 12:13:51 +0200
- Subject: [PATCH 1/5] daemon: Improve ACL debug code
- Improve ACL debug code
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/acl.c | 14 ++++++--------
- 1 file changed, 6 insertions(+), 8 deletions(-)
- diff --git a/daemon/acl.c b/daemon/acl.c
- index 7ebc8ab..ffb8d6c 100644
- --- a/daemon/acl.c
- +++ b/daemon/acl.c
- @@ -768,16 +768,18 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
- DPRINTF(ACLLVL, ("--> map_nfs4ace_who(sid=0x%p,owner_sid=0x%p, group_sid=0x%p)\n"));
- + if (DPRINTF_LEVEL_ENABLED(ACLLVL)) {
- + print_sid("sid", sid);
- + print_sid("owner_sid", owner_sid);
- + print_sid("group_sid", group_sid);
- + }
- +
- /* for ace mapping, we want to map owner's sid into "owner@"
- * but for set_owner attribute we want to map owner into a user name
- * same applies to group
- */
- status = 0;
- if (owner_sid) {
- - if (DPRINTF_LEVEL_ENABLED(ACLLVL)) {
- - print_sid("owner_sid", owner_sid);
- - }
- -
- if (EqualSid(sid, owner_sid)) {
- DPRINTF(ACLLVL, ("map_nfs4ace_who: this is owner's sid\n"));
- memcpy(who_out, ACE4_OWNER, strlen(ACE4_OWNER)+1);
- @@ -787,10 +789,6 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
- }
- }
- if (group_sid) {
- - if (DPRINTF_LEVEL_ENABLED(ACLLVL)) {
- - print_sid("group_sid", group_sid);
- - }
- -
- if (EqualSid(sid, group_sid)) {
- DPRINTF(ACLLVL, ("map_nfs4ace_who: this is group's sid\n"));
- memcpy(who_out, ACE4_GROUP, strlen(ACE4_GROUP)+1);
- --
- 2.45.1
- From 7b3aa5d9596103e558061885f27bd5437ad994a3 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Sat, 22 Jun 2024 11:51:16 +0200
- Subject: [PATCH 2/5] daemon: |is_well_known_sid()| should return
- |SID_NAME_USE| for |WinCreator*|&co.
- |is_well_known_sid()| should return |SID_NAME_USE| for |WinCreatorOwnerSid|,
- |WinCreatorGroupSid| etc.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/acl.c | 18 +++++++++++-------
- 1 file changed, 11 insertions(+), 7 deletions(-)
- diff --git a/daemon/acl.c b/daemon/acl.c
- index ffb8d6c..0300e6b 100644
- --- a/daemon/acl.c
- +++ b/daemon/acl.c
- @@ -37,6 +37,7 @@
- #include "sid.h"
- #define ACLLVL 2 /* dprintf level for acl logging */
- +#define ACLLVL2 3 /* dprintf level for acl logging */
- /* Local prototypes */
- static void map_winace2nfs4aceflags(BYTE win_aceflags, uint32_t *nfs4_aceflags);
- @@ -453,7 +454,7 @@ out:
- return status;
- }
- -static int is_well_known_sid(PSID sid, char *who)
- +static int is_well_known_sid(PSID sid, char *who, SID_NAME_USE *snu_out)
- {
- int status, i;
- for (i = 0; i < 78; i++) {
- @@ -464,19 +465,23 @@ static int is_well_known_sid(PSID sid, char *who)
- switch((WELL_KNOWN_SID_TYPE)i) {
- case WinCreatorOwnerSid:
- memcpy(who, ACE4_OWNER, strlen(ACE4_OWNER)+1);
- + *snu_out = SidTypeUser;
- + return TRUE;
- + case WinCreatorGroupSid:
- + case WinBuiltinUsersSid:
- + memcpy(who, ACE4_GROUP, strlen(ACE4_GROUP)+1);
- + *snu_out = SidTypeGroup;
- return TRUE;
- case WinNullSid:
- memcpy(who, ACE4_NOBODY, strlen(ACE4_NOBODY)+1);
- + *snu_out = SidTypeUser;
- return TRUE;
- case WinAnonymousSid:
- memcpy(who, ACE4_ANONYMOUS, strlen(ACE4_ANONYMOUS)+1);
- return TRUE;
- case WinWorldSid:
- memcpy(who, ACE4_EVERYONE, strlen(ACE4_EVERYONE)+1);
- - return TRUE;
- - case WinCreatorGroupSid:
- - case WinBuiltinUsersSid:
- - memcpy(who, ACE4_GROUP, strlen(ACE4_GROUP)+1);
- + *snu_out = SidTypeGroup;
- return TRUE;
- case WinAuthenticatedUserSid:
- memcpy(who, ACE4_AUTHENTICATED, strlen(ACE4_AUTHENTICATED)+1);
- @@ -797,11 +802,10 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
- goto out;
- }
- }
- - status = is_well_known_sid(sid, who_out);
- + status = is_well_known_sid(sid, who_out, &sid_type);
- if (status) {
- if (!strncmp(who_out, ACE4_NOBODY, strlen(ACE4_NOBODY))) {
- who_size = (DWORD)strlen(ACE4_NOBODY);
- - sid_type = SidTypeUser;
- goto add_domain;
- }
- --
- 2.45.1
- From 8c8f5e22415f1ed6d3549ddfda119d96e61200b9 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Sat, 22 Jun 2024 11:56:47 +0200
- Subject: [PATCH 3/5] daemon: Better debug output for |map_dacl_2_nfs4acl()|
- Add better debug output for |map_dacl_2_nfs4acl()|
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/acl.c | 41 +++++++++++++---------
- daemon/daemon_debug.c | 82 +++++++++++++++++++++++++++++++++++++++++++
- daemon/daemon_debug.h | 3 ++
- 3 files changed, 110 insertions(+), 16 deletions(-)
- diff --git a/daemon/acl.c b/daemon/acl.c
- index 0300e6b..b42d638 100644
- --- a/daemon/acl.c
- +++ b/daemon/acl.c
- @@ -975,20 +975,6 @@ static int map_dacl_2_nfs4acl(PACL acl, PSID sid, PSID gsid, nfsacl41 *nfs4_acl,
- map_winaccessmask2nfs4acemask(win_mask,
- file_type, &nfs4_acl->aces[i].acemask);
- - if (DPRINTF_LEVEL_ENABLED(ACLLVL)) {
- - dprintf_out("win2nfs: nfs4_acl->aces[%d].who='%s', "
- - "acetype='%s', "
- - "win_mask=0x%lx, nfs_acemask=0x%lx\n",
- - i, nfs4_acl->aces[i].who,
- - (nfs4_acl->aces[i].acetype?
- - "DENIED ACE":"ALLOWED ACE"),
- - (long)win_mask, (long)nfs4_acl->aces[i].acemask);
- - print_windows_access_mask(nfs4_acl->aces[i].who,
- - win_mask);
- - print_nfs_access_mask(nfs4_acl->aces[i].who,
- - nfs4_acl->aces[i].acemask);
- - }
- -
- /*
- * Treat |SidTypeAlias| as (local) group
- *
- @@ -1001,13 +987,36 @@ static int map_dacl_2_nfs4acl(PACL acl, PSID sid, PSID gsid, nfsacl41 *nfs4_acl,
- */
- if ((who_sid_type == SidTypeGroup) ||
- (who_sid_type == SidTypeAlias)) {
- - DPRINTF(ACLLVL, ("map_dacl_2_nfs4acl: who_sid_type=%d: "
- + DPRINTF(ACLLVL, ("map_dacl_2_nfs4acl: who_sid_type='%s': "
- "aces[%d].who='%s': "
- "setting group flag\n",
- - (int)who_sid_type,
- + map_SID_NAME_USE2str(who_sid_type),
- i, nfs4_acl->aces[i].who));
- nfs4_acl->aces[i].aceflag |= ACE4_IDENTIFIER_GROUP;
- }
- +
- + if (DPRINTF_LEVEL_ENABLED(0)) {
- + dprintf_out("win2nfs: nfs4_acl->aces[%d]=(who='%s', "
- + "acetype='%s', "
- + "aceflag='%s'/0x%lx, "
- + "acemask='%s'/0x%lx(=win_mask=0x%lx)), "
- + "who_sid_type='%s'\n",
- + i,
- + nfs4_acl->aces[i].who,
- + map_nfs_acetype2str(nfs4_acl->aces[i].acetype),
- + nfs_aceflag2shortname(nfs4_acl->aces[i].aceflag),
- + nfs4_acl->aces[i].aceflag,
- + nfs_mask2shortname(nfs4_acl->aces[i].acemask),
- + (long)nfs4_acl->aces[i].acemask,
- + (long)win_mask,
- + map_SID_NAME_USE2str(who_sid_type));
- + if (DPRINTF_LEVEL_ENABLED(ACLLVL2)) {
- + print_windows_access_mask(nfs4_acl->aces[i].who,
- + win_mask);
- + print_nfs_access_mask(nfs4_acl->aces[i].who,
- + nfs4_acl->aces[i].acemask);
- + }
- + }
- }
- }
- status = ERROR_SUCCESS;
- diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
- index 9d555e1..ad685ce 100644
- --- a/daemon/daemon_debug.c
- +++ b/daemon/daemon_debug.c
- @@ -660,6 +660,25 @@ const char* gssauth_string(int type) {
- return "<invalid RPCSEC_SSPI_* gss auth type>";
- }
- +const char* map_SID_NAME_USE2str(SID_NAME_USE snu)
- +{
- + switch(snu) {
- +#define SID_NAME_USE_TO_STRLITERAL(e) case e: return #e;
- + SID_NAME_USE_TO_STRLITERAL(SidTypeUser)
- + SID_NAME_USE_TO_STRLITERAL(SidTypeGroup)
- + SID_NAME_USE_TO_STRLITERAL(SidTypeDomain)
- + SID_NAME_USE_TO_STRLITERAL(SidTypeAlias)
- + SID_NAME_USE_TO_STRLITERAL(SidTypeWellKnownGroup)
- + SID_NAME_USE_TO_STRLITERAL(SidTypeDeletedAccount)
- + SID_NAME_USE_TO_STRLITERAL(SidTypeInvalid)
- + SID_NAME_USE_TO_STRLITERAL(SidTypeUnknown)
- + SID_NAME_USE_TO_STRLITERAL(SidTypeComputer)
- + SID_NAME_USE_TO_STRLITERAL(SidTypeLabel)
- + SID_NAME_USE_TO_STRLITERAL(SidTypeLogonSession)
- + }
- + return "<unknown SID_NAME_USE type>";
- +}
- +
- const char *FILE_INFORMATION_CLASS2string(int fic)
- {
- switch(fic) {
- @@ -911,6 +930,69 @@ void print_nfs_access_mask(const char *label, uint32_t nfs_mask)
- dprintf_out("<-- print_nfs_access_mask\n");
- }
- +const char *nfs_mask2shortname(uint32_t nfs_mask)
- +{
- + /*
- + * |snam_buffer| - per thread buffer, we assume that
- + * the caller will not use the function multiple times
- + * in one |dprintf_out()|
- + */
- + __declspec(thread) static char snam_buffer[128];
- + char *sb = snam_buffer;
- + sb[0] = '\0';
- +#define WRITENFSMASKBITS(mflag, shortname) \
- + if (nfs_mask & (mflag)) { \
- + if (sb != snam_buffer) { \
- + *sb++ = ','; \
- + } \
- + sb = stpcpy(sb, (shortname)); \
- + }
- + WRITENFSMASKBITS(ACE4_READ_DATA, "RD");
- + WRITENFSMASKBITS(ACE4_WRITE_DATA, "WD");
- + WRITENFSMASKBITS(ACE4_APPEND_DATA, "AD");
- + WRITENFSMASKBITS(ACE4_READ_NAMED_ATTRS, "REA");
- + WRITENFSMASKBITS(ACE4_WRITE_NAMED_ATTRS, "WEA");
- + WRITENFSMASKBITS(ACE4_EXECUTE, "X");
- + WRITENFSMASKBITS(ACE4_DELETE_CHILD, "DC");
- + WRITENFSMASKBITS(ACE4_READ_ATTRIBUTES, "RA");
- + WRITENFSMASKBITS(ACE4_WRITE_ATTRIBUTES, "RA");
- + WRITENFSMASKBITS(ACE4_DELETE, "DE");
- + WRITENFSMASKBITS(ACE4_READ_ACL, "RACL");
- + WRITENFSMASKBITS(ACE4_WRITE_ACL, "WACL");
- + WRITENFSMASKBITS(ACE4_WRITE_OWNER, "WO");
- + WRITENFSMASKBITS(ACE4_SYNCHRONIZE, "S");
- +
- + return snam_buffer;
- +}
- +
- +const char *nfs_aceflag2shortname(uint32_t aceflag)
- +{
- + /*
- + * |sacf_buffer| - per thread buffer, we assume that
- + * the caller will not use the function multiple times
- + * in one |dprintf_out()|
- + */
- + __declspec(thread) static char sacf_buffer[128];
- + char *sb = sacf_buffer;
- + sb[0] = '\0';
- +#define WRITENFSACEFLAGBITS(mflag, shortname) \
- + if (aceflag & (mflag)) { \
- + if (sb != sacf_buffer) { \
- + *sb++ = ','; \
- + } \
- + sb = stpcpy(sb, (shortname)); \
- + }
- + WRITENFSACEFLAGBITS(ACE4_FILE_INHERIT_ACE, "(FI)");
- + WRITENFSACEFLAGBITS(ACE4_DIRECTORY_INHERIT_ACE, "(DI)");
- + WRITENFSACEFLAGBITS(ACE4_NO_PROPAGATE_INHERIT_ACE, "(NPI)");
- + WRITENFSACEFLAGBITS(ACE4_INHERIT_ONLY_ACE, "(IO)");
- + WRITENFSACEFLAGBITS(ACE4_SUCCESSFUL_ACCESS_ACE_FLAG, "(SA)");
- + WRITENFSACEFLAGBITS(ACE4_FAILED_ACCESS_ACE_FLAG, "(FA)");
- + WRITENFSACEFLAGBITS(ACE4_IDENTIFIER_GROUP, "(G)");
- + WRITENFSACEFLAGBITS(ACE4_INHERITED_ACE, "(I)");
- +
- + return sacf_buffer;
- +}
- void print_nfs41_file_info(
- const char *label,
- diff --git a/daemon/daemon_debug.h b/daemon/daemon_debug.h
- index e283296..3b376f0 100644
- --- a/daemon/daemon_debug.h
- +++ b/daemon/daemon_debug.h
- @@ -108,6 +108,8 @@ const char *map_nfs_ftype2str(int ftype);
- const char *map_nfs_acetype2str(uint32_t ace_type);
- void print_windows_access_mask(const char *label, ACCESS_MASK win_mask);
- void print_nfs_access_mask(const char *label, uint32_t nfs_mask);
- +const char *nfs_mask2shortname(uint32_t nfs_mask);
- +const char *nfs_aceflag2shortname(uint32_t aceflag);
- void print_hexbuf_no_asci(const char *title, const unsigned char *buf, int len);
- void print_hexbuf(const char *title, const unsigned char *buf, int len);
- void print_create_attributes(int level, DWORD create_opts);
- @@ -122,6 +124,7 @@ const char* nfs_opnum_to_string(int opnum);
- const char* nfs_error_string(int status);
- const char* rpc_error_string(int status);
- const char* gssauth_string(int type);
- +const char* map_SID_NAME_USE2str(SID_NAME_USE snu);
- const char *FILE_INFORMATION_CLASS2string(int fic);
- void print_condwait_status(int level, int status);
- void print_sr_status_flags(int level, int flags);
- --
- 2.45.1
- From 992460e092c1731e5824b6187934f21a3105d6e8 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Sat, 22 Jun 2024 13:58:19 +0200
- Subject: [PATCH 4/5] daemon: Add ACLLVL1-ACLLVL3 for more fine-grained ACL
- debug outpit control
- Add ACLLVL1-ACLLVL3 for more fine-grained ACL debug outpit control
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/acl.c | 84 +++++++++++++++++++++++++++-------------------------
- 1 file changed, 44 insertions(+), 40 deletions(-)
- diff --git a/daemon/acl.c b/daemon/acl.c
- index b42d638..e91e831 100644
- --- a/daemon/acl.c
- +++ b/daemon/acl.c
- @@ -36,8 +36,10 @@
- #include "nfs41_xdr.h"
- #include "sid.h"
- -#define ACLLVL 2 /* dprintf level for acl logging */
- -#define ACLLVL2 3 /* dprintf level for acl logging */
- +/* |DPRINTF()| levels for acl logging */
- +#define ACLLVL1 1
- +#define ACLLVL2 2
- +#define ACLLVL3 3
- /* Local prototypes */
- static void map_winace2nfs4aceflags(BYTE win_aceflags, uint32_t *nfs4_aceflags);
- @@ -115,7 +117,7 @@ static int convert_nfs4acl_2_dacl(nfs41_daemon_globals *nfs41dg,
- LPSTR domain = NULL;
- BOOLEAN flag;
- - DPRINTF(ACLLVL, ("--> convert_nfs4acl_2_dacl(acl=0x%p,file_type='%s'(=%d))\n",
- + DPRINTF(ACLLVL2, ("--> convert_nfs4acl_2_dacl(acl=0x%p,file_type='%s'(=%d))\n",
- acl, map_nfs_ftype2str(file_type), file_type));
- sids = malloc(acl->count * sizeof(PSID));
- @@ -125,7 +127,7 @@ static int convert_nfs4acl_2_dacl(nfs41_daemon_globals *nfs41dg,
- }
- for (i = 0; i < acl->count; i++) {
- convert_nfs4name_2_user_domain(acl->aces[i].who, &domain);
- - DPRINTF(ACLLVL, ("convert_nfs4acl_2_dacl: for user='%s' domain='%s'\n",
- + DPRINTF(ACLLVL2, ("convert_nfs4acl_2_dacl: for user='%s' domain='%s'\n",
- acl->aces[i].who, domain?domain:"<null>"));
- status = check_4_special_identifiers(acl->aces[i].who, &sids[i],
- &sid_len, &flag);
- @@ -137,7 +139,7 @@ static int convert_nfs4acl_2_dacl(nfs41_daemon_globals *nfs41dg,
- bool isgroupacl = (acl->aces[i].aceflag & ACE4_IDENTIFIER_GROUP)?true:false;
- if (isgroupacl) {
- - DPRINTF(ACLLVL,
- + DPRINTF(ACLLVL2,
- ("convert_nfs4acl_2_dacl: aces[%d].who='%s': "
- "Setting group flag\n",
- i, acl->aces[i].who));
- @@ -172,7 +174,7 @@ static int convert_nfs4acl_2_dacl(nfs41_daemon_globals *nfs41dg,
- map_nfs4acemask2winaccessmask(acl->aces[i].acemask,
- file_type, &mask);
- - if (DPRINTF_LEVEL_ENABLED(ACLLVL)) {
- + if (DPRINTF_LEVEL_ENABLED(ACLLVL1)) {
- dprintf_out("nfs2win: acl->aces[%d].who='%s': "
- "acetype='%s', "
- "nfs_acemask=0x%lx, win_mask=0x%lx, "
- @@ -225,7 +227,7 @@ static int convert_nfs4acl_2_dacl(nfs41_daemon_globals *nfs41dg,
- *sids_out = sids;
- *dacl_out = dacl;
- out:
- - DPRINTF(ACLLVL, ("<-- convert_nfs4acl_2_dacl("
- + DPRINTF(ACLLVL2, ("<-- convert_nfs4acl_2_dacl("
- "acl=0x%p,file_type='%s'(=%d)) returning %d\n",
- acl, map_nfs_ftype2str(file_type), file_type, status));
- return status;
- @@ -253,7 +255,7 @@ static int handle_getacl(void *daemon_context, nfs41_upcall *upcall)
- char owner[NFS4_OPAQUE_LIMIT+1], group[NFS4_OPAQUE_LIMIT+1];
- nfsacl41 acl = { 0 };
- - DPRINTF(ACLLVL, ("--> handle_getacl(state->path.path='%s')\n",
- + DPRINTF(ACLLVL1, ("--> handle_getacl(state->path.path='%s')\n",
- state->path.path));
- if (args->query & DACL_SECURITY_INFORMATION) {
- @@ -295,7 +297,7 @@ use_nfs41_getattr:
- */
- if ((info.attrmask.arr[1] &
- (FATTR4_WORD1_OWNER|FATTR4_WORD1_OWNER_GROUP)) != (FATTR4_WORD1_OWNER|FATTR4_WORD1_OWNER_GROUP)) {
- - DPRINTF(ACLLVL, ("handle_getattr: owner/owner_group not in cache, doing full lookup...\n"));
- + DPRINTF(ACLLVL2, ("handle_getattr: owner/owner_group not in cache, doing full lookup...\n"));
- goto use_nfs41_getattr;
- }
- }
- @@ -322,7 +324,7 @@ use_nfs41_getattr:
- if (args->query & OWNER_SECURITY_INFORMATION) {
- // parse user@domain. currently ignoring domain part XX
- convert_nfs4name_2_user_domain(info.owner, &domain);
- - DPRINTF(ACLLVL, ("handle_getacl: OWNER_SECURITY_INFORMATION: for user='%s' "
- + DPRINTF(ACLLVL2, ("handle_getacl: OWNER_SECURITY_INFORMATION: for user='%s' "
- "domain='%s'\n", info.owner, domain?domain:"<null>"));
- sid_len = 0;
- status = map_nfs4servername_2_sid(nfs41dg,
- @@ -340,7 +342,7 @@ use_nfs41_getattr:
- if (args->query & GROUP_SECURITY_INFORMATION) {
- convert_nfs4name_2_user_domain(info.owner_group, &domain);
- - DPRINTF(ACLLVL, ("handle_getacl: GROUP_SECURITY_INFORMATION: for '%s' "
- + DPRINTF(ACLLVL2, ("handle_getacl: GROUP_SECURITY_INFORMATION: for '%s' "
- "domain='%s'\n", info.owner_group, domain?domain:"<null>"));
- sid_len = 0;
- status = map_nfs4servername_2_sid(nfs41dg,
- @@ -356,7 +358,7 @@ use_nfs41_getattr:
- }
- }
- if (args->query & DACL_SECURITY_INFORMATION) {
- - DPRINTF(ACLLVL, ("handle_getacl: DACL_SECURITY_INFORMATION\n"));
- + DPRINTF(ACLLVL2, ("handle_getacl: DACL_SECURITY_INFORMATION\n"));
- status = convert_nfs4acl_2_dacl(nfs41dg,
- info.acl, state->type, &dacl, &sids);
- if (status)
- @@ -408,7 +410,9 @@ out:
- nfsacl41_free(info.acl);
- }
- - DPRINTF(ACLLVL, ("<-- handle_getacl() returning %d\n", status));
- + DPRINTF(ACLLVL1, ("<-- handle_getacl(state->path.path='%s') "
- + "returning %d\n",
- + state->path.path, status));
- return status;
- }
- @@ -461,7 +465,7 @@ static int is_well_known_sid(PSID sid, char *who, SID_NAME_USE *snu_out)
- status = IsWellKnownSid(sid, (WELL_KNOWN_SID_TYPE)i);
- if (!status) continue;
- else {
- - DPRINTF(ACLLVL, ("WELL_KNOWN_SID_TYPE %d\n", i));
- + DPRINTF(ACLLVL3, ("WELL_KNOWN_SID_TYPE %d\n", i));
- switch((WELL_KNOWN_SID_TYPE)i) {
- case WinCreatorOwnerSid:
- memcpy(who, ACE4_OWNER, strlen(ACE4_OWNER)+1);
- @@ -522,7 +526,7 @@ static void map_winace2nfs4aceflags(BYTE win_aceflags, uint32_t *nfs4_aceflags)
- *nfs4_aceflags |= ACE4_INHERIT_ONLY_ACE;
- if (win_aceflags & INHERITED_ACE)
- *nfs4_aceflags |= ACE4_INHERITED_ACE;
- - DPRINTF(ACLLVL,
- + DPRINTF(ACLLVL3,
- ("map_winace2nfs4aceflags: win_aceflags=0x%x nfs4_aceflags=0x%x\n",
- (int)win_aceflags, (int)*nfs4_aceflags));
- }
- @@ -539,7 +543,7 @@ static void map_nfs4aceflags2winaceflags(uint32_t nfs4_aceflags, DWORD *win_acef
- *win_aceflags |= INHERIT_ONLY_ACE;
- if (nfs4_aceflags & ACE4_INHERITED_ACE)
- *win_aceflags |= INHERITED_ACE;
- - DPRINTF(ACLLVL,
- + DPRINTF(ACLLVL3,
- ("map_nfs4aceflags2winace: nfs4_aceflags=0x%x win_aceflags=0x%x\n",
- (int)nfs4_aceflags, (int)*win_aceflags));
- }
- @@ -771,9 +775,9 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
- DWORD who_size = sizeof(who_buf), domain_size = sizeof(domain_buf);
- LPSTR sidstr = NULL;
- - DPRINTF(ACLLVL, ("--> map_nfs4ace_who(sid=0x%p,owner_sid=0x%p, group_sid=0x%p)\n"));
- + DPRINTF(ACLLVL2, ("--> map_nfs4ace_who(sid=0x%p,owner_sid=0x%p, group_sid=0x%p)\n"));
- - if (DPRINTF_LEVEL_ENABLED(ACLLVL)) {
- + if (DPRINTF_LEVEL_ENABLED(ACLLVL2)) {
- print_sid("sid", sid);
- print_sid("owner_sid", owner_sid);
- print_sid("group_sid", group_sid);
- @@ -786,7 +790,7 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
- status = 0;
- if (owner_sid) {
- if (EqualSid(sid, owner_sid)) {
- - DPRINTF(ACLLVL, ("map_nfs4ace_who: this is owner's sid\n"));
- + DPRINTF(ACLLVL2, ("map_nfs4ace_who: this is owner's sid\n"));
- memcpy(who_out, ACE4_OWNER, strlen(ACE4_OWNER)+1);
- sid_type = SidTypeUser;
- status = ERROR_SUCCESS;
- @@ -795,7 +799,7 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
- }
- if (group_sid) {
- if (EqualSid(sid, group_sid)) {
- - DPRINTF(ACLLVL, ("map_nfs4ace_who: this is group's sid\n"));
- + DPRINTF(ACLLVL2, ("map_nfs4ace_who: this is group's sid\n"));
- memcpy(who_out, ACE4_GROUP, strlen(ACE4_GROUP)+1);
- sid_type = SidTypeGroup;
- status = ERROR_SUCCESS;
- @@ -826,7 +830,7 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
- lasterr = GetLastError();
- if (status) {
- - DPRINTF(ACLLVL, ("map_nfs4ace_who: "
- + DPRINTF(ACLLVL2, ("map_nfs4ace_who: "
- "LookupAccountSid(sidtostr(sid)='%s', who_buf='%s', "
- "who_size=%d, domain='%s', domain_size=%d) "
- "returned success, status=%d, GetLastError=%d\n",
- @@ -834,7 +838,7 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
- domain_buf, domain_size, status, lasterr));
- }
- else {
- - DPRINTF(ACLLVL, ("map_nfs4ace_who: "
- + DPRINTF(ACLLVL2, ("map_nfs4ace_who: "
- "LookupAccountSid(sidtostr(sid)='%s', who_size=%d, "
- "domain_size=%d) returned failure, status=%d, "
- "GetLastError=%d\n",
- @@ -850,7 +854,7 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
- * SIDs
- */
- case ERROR_NONE_MAPPED:
- - DPRINTF(ACLLVL, ("map_nfs4ace_who: LookupAccountSidA() "
- + DPRINTF(ACLLVL2, ("map_nfs4ace_who: LookupAccountSidA() "
- "returned ERROR_NONE_MAPPED for sidstr='%s'\n",
- sidstr));
- status = lasterr;
- @@ -881,11 +885,11 @@ add_domain:
- status = ERROR_SUCCESS;
- out:
- if (status) {
- - DPRINTF(ACLLVL,
- + DPRINTF(ACLLVL2,
- ("<-- map_nfs4ace_who() returns %d\n", status));
- }
- else {
- - DPRINTF(ACLLVL,
- + DPRINTF(ACLLVL2,
- ("<-- map_nfs4ace_who(who_out='%s', sid_type=%d) "
- "returns %d\n",
- who_out, sid_type, status));
- @@ -903,7 +907,7 @@ static int map_dacl_2_nfs4acl(PACL acl, PSID sid, PSID gsid, nfsacl41 *nfs4_acl,
- {
- int status;
- if (acl == NULL) {
- - DPRINTF(ACLLVL, ("this is a NULL dacl: all access to an object\n"));
- + DPRINTF(ACLLVL2, ("this is a NULL dacl: all access to an object\n"));
- nfs4_acl->count = 1;
- nfs4_acl->aces = calloc(1, sizeof(nfsace4));
- if (nfs4_acl->aces == NULL) {
- @@ -925,8 +929,8 @@ static int map_dacl_2_nfs4acl(PACL acl, PSID sid, PSID gsid, nfsacl41 *nfs4_acl,
- SID_NAME_USE who_sid_type = 0;
- ACCESS_MASK win_mask;
- - DPRINTF(ACLLVL, ("NON-NULL dacl with %d ACEs\n", acl->AceCount));
- - if (DPRINTF_LEVEL_ENABLED(ACLLVL)) {
- + DPRINTF(ACLLVL2, ("NON-NULL dacl with %d ACEs\n", acl->AceCount));
- + if (DPRINTF_LEVEL_ENABLED(ACLLVL3)) {
- print_hexbuf_no_asci("ACL\n",
- (const unsigned char *)acl, acl->AclSize);
- }
- @@ -945,11 +949,11 @@ static int map_dacl_2_nfs4acl(PACL acl, PSID sid, PSID gsid, nfsacl41 *nfs4_acl,
- goto out_free;
- }
- tmp_pointer = (PBYTE)ace;
- - if (DPRINTF_LEVEL_ENABLED(ACLLVL)) {
- + if (DPRINTF_LEVEL_ENABLED(ACLLVL3)) {
- print_hexbuf_no_asci("ACE\n",
- (const unsigned char *)ace, ace->AceSize);
- }
- - DPRINTF(ACLLVL, ("ACE TYPE: %x\n", ace->AceType));
- + DPRINTF(ACLLVL3, ("ACE TYPE: %x\n", ace->AceType));
- if (ace->AceType == ACCESS_ALLOWED_ACE_TYPE)
- nfs4_acl->aces[i].acetype = ACE4_ACCESS_ALLOWED_ACE_TYPE;
- else if (ace->AceType == ACCESS_DENIED_ACE_TYPE)
- @@ -987,7 +991,7 @@ static int map_dacl_2_nfs4acl(PACL acl, PSID sid, PSID gsid, nfsacl41 *nfs4_acl,
- */
- if ((who_sid_type == SidTypeGroup) ||
- (who_sid_type == SidTypeAlias)) {
- - DPRINTF(ACLLVL, ("map_dacl_2_nfs4acl: who_sid_type='%s': "
- + DPRINTF(ACLLVL3, ("map_dacl_2_nfs4acl: who_sid_type='%s': "
- "aces[%d].who='%s': "
- "setting group flag\n",
- map_SID_NAME_USE2str(who_sid_type),
- @@ -995,7 +999,7 @@ static int map_dacl_2_nfs4acl(PACL acl, PSID sid, PSID gsid, nfsacl41 *nfs4_acl,
- nfs4_acl->aces[i].aceflag |= ACE4_IDENTIFIER_GROUP;
- }
- - if (DPRINTF_LEVEL_ENABLED(0)) {
- + if (DPRINTF_LEVEL_ENABLED(ACLLVL1)) {
- dprintf_out("win2nfs: nfs4_acl->aces[%d]=(who='%s', "
- "acetype='%s', "
- "aceflag='%s'/0x%lx, "
- @@ -1041,11 +1045,11 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
- char ownerbuf[NFS4_OPAQUE_LIMIT+1];
- char groupbuf[NFS4_OPAQUE_LIMIT+1];
- - DPRINTF(ACLLVL, ("--> handle_setacl(state->path.path='%s')\n",
- + DPRINTF(ACLLVL1, ("--> handle_setacl(state->path.path='%s')\n",
- state->path.path));
- if (args->query & OWNER_SECURITY_INFORMATION) {
- - DPRINTF(ACLLVL, ("handle_setacl: OWNER_SECURITY_INFORMATION\n"));
- + DPRINTF(ACLLVL2, ("handle_setacl: OWNER_SECURITY_INFORMATION\n"));
- status = GetSecurityDescriptorOwner(args->sec_desc, &sid, &sid_default);
- if (!status) {
- status = GetLastError();
- @@ -1067,7 +1071,7 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
- }
- if (args->query & GROUP_SECURITY_INFORMATION) {
- - DPRINTF(ACLLVL, ("handle_setacl: GROUP_SECURITY_INFORMATION\n"));
- + DPRINTF(ACLLVL2, ("handle_setacl: GROUP_SECURITY_INFORMATION\n"));
- status = GetSecurityDescriptorGroup(args->sec_desc, &sid, &sid_default);
- if (!status) {
- status = GetLastError();
- @@ -1091,7 +1095,7 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
- if (args->query & DACL_SECURITY_INFORMATION) {
- BOOL dacl_present, dacl_default;
- PACL acl;
- - DPRINTF(ACLLVL, ("handle_setacl: DACL_SECURITY_INFORMATION\n"));
- + DPRINTF(ACLLVL2, ("handle_setacl: DACL_SECURITY_INFORMATION\n"));
- status = GetSecurityDescriptorDacl(args->sec_desc, &dacl_present,
- &acl, &dacl_default);
- if (!status) {
- @@ -1127,17 +1131,17 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
- OPEN_DELEGATE_WRITE, FALSE);
- nfs41_open_stateid_arg(state, &stateid);
- - if (DPRINTF_LEVEL_ENABLED(ACLLVL)) {
- + if (DPRINTF_LEVEL_ENABLED(ACLLVL2)) {
- print_nfs41_file_info("handle_setacl: nfs41_setattr() info IN:", &info);
- }
- status = nfs41_setattr(state->session, &state->file, &stateid, &info);
- if (status) {
- - DPRINTF(ACLLVL, ("handle_setacl: nfs41_setattr() failed with error '%s'.\n",
- + DPRINTF(ACLLVL1, ("handle_setacl: nfs41_setattr() failed with error '%s'.\n",
- nfs_error_string(status)));
- status = nfs_to_windows_error(status, ERROR_NOT_SUPPORTED);
- }
- else {
- - if (DPRINTF_LEVEL_ENABLED(ACLLVL)) {
- + if (DPRINTF_LEVEL_ENABLED(ACLLVL1)) {
- print_nfs41_file_info("handle_setacl: nfs41_setattr() success info OUT:", &info);
- }
- }
- @@ -1145,7 +1149,7 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
- if (args->query & DACL_SECURITY_INFORMATION)
- free(nfs4_acl.aces);
- out:
- - DPRINTF(ACLLVL, ("<-- handle_setacl() returning %d\n", status));
- + DPRINTF(ACLLVL1, ("<-- handle_setacl() returning %d\n", status));
- return status;
- }
- --
- 2.45.1
- From 05e98895f9697c139dc36729303742e3d086a704 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Sat, 22 Jun 2024 15:08:33 +0200
- Subject: [PATCH 5/5] tests: Add nfsbuildtest.ksh93 (gcc) build torture test
- Add nfsbuildtest.ksh93 (gcc) build torture test
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- tests/nfsbuildtest/nfsbuildtest.ksh93 | 131 ++++++++++++++++++++++++++
- 1 file changed, 131 insertions(+)
- create mode 100644 tests/nfsbuildtest/nfsbuildtest.ksh93
- diff --git a/tests/nfsbuildtest/nfsbuildtest.ksh93 b/tests/nfsbuildtest/nfsbuildtest.ksh93
- new file mode 100644
- index 0000000..fe7d492
- --- /dev/null
- +++ b/tests/nfsbuildtest/nfsbuildtest.ksh93
- @@ -0,0 +1,131 @@
- +#!/usr/bin/ksh93
- +
- +#
- +# nfsbuildtest.ksh93
- +#
- +# Simple NFSv4 torture test by building gcc in parallel
- +# on a NFS filesystem
- +#
- +set -o xtrace
- +set -o errexit
- +set -o nounset
- +
- +#
- +# build config
- +#
- +typeset config_cp_p_function_not_implemented_workaround=false
- +typeset config_use_posix_ksh93_builtins=true
- +
- +compound gitdata=(
- + typeset url='git://repo.or.cz/gcc.git'
- + # use fixed git tag, so build times are compareable
- + typeset tag='releases/gcc-13.1.0'
- +)
- +
- +typeset -a configure_options=(
- + # Per irc://irc.oftc.net/#gcc:
- + # ".. pch is broken on windows as allocation using the fixed
- + # address might not succeed in general and there is fixed
- + # retry loop using delay that kills all performance
- + # benefits..."
- + '--disable-libstdcxx-pch'
- +)
- +
- +#
- +# temp dir setup
- +#
- +
- +# fixme: Does not work with NFSv4.1 filesystem from exported Linux tmpfs - why ?
- +#tmpdir='/cygdrive/m/tmpdir'
- +#mkdir -p "$tmpdir"
- +#chmod a=rwxt "$tmpdir"
- +#if [[ -d "$tmpdir" && -w "$tmpdir" ]] ; then
- +# export TMPDIR="$tmpdir"
- +#fi
- +
- +#
- +# print user info
- +#
- +id -a
- +pwd
- +
- +#
- +# source checkout
- +#
- +
- +#time git -c checkout.workers=16 clone -b "${gitdata.tag}" --single-branch git://gcc.gnu.org/git/gcc.git
- +#time git -c checkout.workers=16 clone -b "${gitdata.tag}" --single-branch https://github.com/gcc-mirror/gcc.git
- +
- +if [[ -f '../gitbundles/gcc.bundle' ]] ; then
- + # Use local bundle as cache,
- + # so build times only depend on local filesystem performance
- + # and not HTTPS speed
- + #
- + # The bundle was created like this:
- + # ---- snip ----
- + # git clone git://repo.or.cz/gcc.git
- + # cd gcc
- + # git bundle create '../gitbundles/gcc.bundle' --all
- + # cd ..
- + # rm -Rf gcc
- + # ---- snip ----
- + time git -c checkout.workers=16 clone -b "${gitdata.tag}" --single-branch '../gitbundles/gcc.bundle'
- +else
- + time git -c checkout.workers=16 clone -b "${gitdata.tag}" --single-branch "${gitdata.url}"
- +fi
- +
- +cd "$PWD/gcc/"
- +
- +if $config_use_posix_ksh93_builtins ; then
- + PATH="/usr/ast/bin:/opt/ast/bin:$PATH"
- +fi
- +
- +#
- +# patch sources and configure build
- +#
- +
- +# Cygwin: workaround for configure using cp -p where ln -s should be used
- +# (this is an automake/autoconf issue, they should trust Cygwin and not use
- +# ancient workarounds for issues which no longer exists)
- +(set -o xtrace ; sed -i "s/as_ln_s='cp -pR'/as_ln_s='ln -s'/g" $(find . -name 'configure') )
- +
- +if $config_use_posix_ksh93_builtins ; then
- + (set -o xtrace ; sed -i "s/\/bin\/sh/\/bin\/ksh93/g" $(find . -name 'configure') )
- +fi
- +
- +if $config_use_posix_ksh93_builtins ; then
- + ksh93 ./configure "${configure_options[@]}"
- +else
- + bash ./configure "${configure_options[@]}"
- +fi
- +
- +if $config_cp_p_function_not_implemented_workaround ; then
- + # workaround for $ cp -p # failing with "Function not
- + # implemented" in older versions of ms-nfs41-client
- + if $config_use_posix_ksh93_builtins ; then
- + (
- + set -o xtrace
- + sed -i -r 's/(cp.*)([[:space:]]+-p[[:space:]]+)/\2 -A pt /g' \
- + $(find . -name 'Makefile' -o -name 'Makefile.in')
- + )
- + else
- + (
- + set -o xtrace ; sed -i -r 's/(cp.*)([[:space:]]+-p[[:space:]]+)/\2--no-preserve=ownership /g' \
- + $(find . -name 'Makefile' -o -name 'Makefile.in')
- + )
- + fi
- +fi
- +
- +if $config_use_posix_ksh93_builtins ; then
- + # replace /bin/sh with /bin/ksh93 for speed
- + (set -o xtrace ; sed -i -r 's/\/bin\/sh/\/bin\/ksh93/g' \
- + $(find . -name 'Makefile' -o -name 'Makefile.in') )
- +fi
- +
- +#
- +# build gcc
- +#
- +time ksh93 -c 'export SHELL=/bin/ksh93 ; (yes | make -j8 all)'
- +echo $?
- +
- +echo "#Done."
- --
- 2.45.1
msnfs41client: ACL debug, NFS gcc build torture tests+misc, 2024-06-22
Posted by Anonymous on Sat 22nd Jun 2024 14:41
raw | new post
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.