- From fff43f3c6d1da6b9779a84bb4db120d064f020f4 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 20 Feb 2024 08:15:37 +0100
- Subject: [PATCH 1/2] daemon: Add better debug output to setattr chown/chgrp
- codepath
- Add better debug output to the serattr codepath used by chown and
- chgrp.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/acl.c | 16 ++++++++--
- daemon/daemon_debug.c | 71 +++++++++++++++++++++++++++++++++++++++++++
- daemon/daemon_debug.h | 1 +
- 3 files changed, 86 insertions(+), 2 deletions(-)
- diff --git a/daemon/acl.c b/daemon/acl.c
- index deecc38..deea6ab 100644
- --- a/daemon/acl.c
- +++ b/daemon/acl.c
- @@ -578,11 +578,15 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
- add_domain:
- memcpy(who_out+size, "@", sizeof(char));
- memcpy(who_out+size+1, domain, strlen(domain)+1);
- - DPRINTF(ACLLVL, ("map_nfs4ace_who: who='%s'\n", who_out));
- if (who) free(who);
- status = ERROR_SUCCESS;
- out:
- - DPRINTF(ACLLVL, ("<-- map_nfs4ace_who() returns %d\n", status));
- + if (status) {
- + DPRINTF(ACLLVL, ("<-- map_nfs4ace_who() returns %d\n", status));
- + }
- + else {
- + DPRINTF(ACLLVL, ("<-- map_nfs4ace_who(who_out='%s') returns %d\n", who_out, status));
- + }
- if (sidstr)
- LocalFree(sidstr);
- return status;
- @@ -760,12 +764,20 @@ 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)) {
- + 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",
- nfs_error_string(status)));
- status = nfs_to_windows_error(status, ERROR_NOT_SUPPORTED);
- }
- + else {
- + if (DPRINTF_LEVEL_ENABLED(ACLLVL)) {
- + print_nfs41_file_info("handle_setacl: nfs41_setattr() success info OUT:", &info);
- + }
- + }
- args->ctime = info.change;
- if (args->query & DACL_SECURITY_INFORMATION)
- free(nfs4_acl.aces);
- diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
- index 67b79c3..9941ce2 100644
- --- a/daemon/daemon_debug.c
- +++ b/daemon/daemon_debug.c
- @@ -731,3 +731,74 @@ void print_nfs_access_mask(int on, int m)
- if (m & ACE4_SYNCHRONIZE)
- dprintf_out("\tACE4_SYNCHRONIZE\n");
- }
- +
- +
- +void print_nfs41_file_info(
- + const char *label,
- + const void *vinfo)
- +{
- + const nfs41_file_info *info = vinfo;
- + char buf[512];
- + char *p;
- +
- + buf[0] = '\0';
- + p = buf;
- +
- +#define PRNFS41FI_FMT(str, arg) \
- + p += snprintf(p, (sizeof(buf)-(p-buf)), (str), (arg))
- +
- + PRNFS41FI_FMT("attrmask.count=%d, ", (int)info->attrmask.count);
- +
- + if (info->attrmask.count >= 1) {
- + PRNFS41FI_FMT("{ attrmask.arr[0]=0x%x, ", (int)info->attrmask.arr[0]);
- + if (info->attrmask.arr[0] & FATTR4_WORD0_TYPE)
- + PRNFS41FI_FMT("type=%d, ", (int)(info->type & NFS_FTYPE_MASK));
- + if (info->attrmask.arr[0] & FATTR4_WORD0_CHANGE)
- + PRNFS41FI_FMT("change=%lld, ", (long long)info->change);
- + if (info->attrmask.arr[0] & FATTR4_WORD0_SIZE)
- + PRNFS41FI_FMT("size=%lld, ", (long long)info->size);
- + if (info->attrmask.arr[0] & FATTR4_WORD0_HIDDEN)
- + PRNFS41FI_FMT("hidden=%d, ", (int)info->hidden);
- + if (info->attrmask.arr[0] & FATTR4_WORD0_ARCHIVE)
- + PRNFS41FI_FMT("archive=%d, ", (int)info->archive);
- + p += snprintf(p, (sizeof(buf)-(p-buf)), "} ");
- + }
- + if (info->attrmask.count >= 2) {
- + PRNFS41FI_FMT("{ attrmask.arr[1]=0x%x, ", (int)info->attrmask.arr[1]);
- + if (info->attrmask.arr[1] & FATTR4_WORD1_MODE)
- + PRNFS41FI_FMT("mode=0x%lx, ", (long)info->mode);
- + if (info->attrmask.arr[1] & FATTR4_WORD1_OWNER) {
- + EASSERT(info->owner != NULL);
- + PRNFS41FI_FMT("owner='%s', ", info->owner);
- + }
- + if (info->attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) {
- + EASSERT(info->owner_group != NULL);
- + PRNFS41FI_FMT("owner_group='%s', ", info->owner_group);
- + }
- + if (info->attrmask.arr[1] & FATTR4_WORD1_NUMLINKS)
- + PRNFS41FI_FMT("numlinks=%ld, ", (long)info->numlinks);
- + if (info->attrmask.arr[1] & FATTR4_WORD1_TIME_ACCESS) {
- + p += snprintf(p, (sizeof(buf)-(p-buf)),
- + "time_access=(%lds/%ldns), ",
- + (long)info->time_access.seconds,
- + (long)info->time_access.nseconds);
- + }
- + if (info->attrmask.arr[1] & FATTR4_WORD1_TIME_CREATE) {
- + p += snprintf(p, (sizeof(buf)-(p-buf)),
- + "time_create=(%lds/%ldns), ",
- + (long)info->time_create.seconds,
- + (long)info->time_create.nseconds);
- + }
- + if (info->attrmask.arr[1] & FATTR4_WORD1_TIME_MODIFY) {
- + p += snprintf(p, (sizeof(buf)-(p-buf)),
- + "time_modify=(%lds/%ldns), ",
- + (long)info->time_modify.seconds,
- + (long)info->time_modify.nseconds);
- + }
- + if (info->attrmask.arr[1] & FATTR4_WORD1_SYSTEM)
- + PRNFS41FI_FMT("system=%d, ", (int)info->system);
- + p += snprintf(p, (sizeof(buf)-(p-buf)), "} ");
- + }
- +
- + dprintf_out("%s={ %s }\n", label, buf);
- +}
- diff --git a/daemon/daemon_debug.h b/daemon/daemon_debug.h
- index 6fa16d7..0840c7b 100644
- --- a/daemon/daemon_debug.h
- +++ b/daemon/daemon_debug.h
- @@ -102,6 +102,7 @@ void print_sr_status_flags(int level, int flags);
- void open_log_files();
- void close_log_files();
- const char* secflavorop2name(DWORD sec_flavor);
- +void print_nfs41_file_info(const char *label, void *vinfo);
- /* pnfs_debug.c */
- enum pnfs_status;
- --
- 2.43.0
- From b6675061ab429bf8b47505cfa39d2c914d10e185 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 20 Feb 2024 08:18:30 +0100
- Subject: [PATCH 2/2] daemon: |nfs41_setattr()| should return owner/owner_group
- if we changed them
- |nfs41_setattr()| should return owner/owner_group from the server
- if we changed them.
- We need this information for two cases:
- 1. Return the owner/owner_group used by the server, to cover cases
- like /etc/exports "all_squash"
- 2. Update the name cache with the new owner/owner_group
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/nfs41_ops.c | 26 ++++++++++++++++++++++++++
- 1 file changed, 26 insertions(+)
- diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c
- index 50c1809..9b47b6b 100644
- --- a/daemon/nfs41_ops.c
- +++ b/daemon/nfs41_ops.c
- @@ -3,6 +3,7 @@
- *
- * Olga Kornievskaia <aglo@umich.edu>
- * Casey Bodley <cbodley@umich.edu>
- + * Roland Mainz <roland.mainz@nrubsig.org>
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- @@ -1387,6 +1388,31 @@ int nfs41_setattr(
- setattr_args.info = info;
- nfs41_superblock_getattr_mask(file->fh.superblock, &attr_request);
- +
- + if (info->attrmask.count >= 2) {
- + /*
- + * If we set owner and/or owner_group make sure we ask
- + * the server to send the values back for two reasons:
- + * 1, Handle cases like "all_squash" (e.g. nfsd turns
- + * owner/owner_group always into "nobody"/"nogroup")
- + * 2. Make sure we update the name cache with the new
- + * owner/owner_group
- + *
- + * Note that this can be a bit tricky as we might pass
- + * a "name@domain" string to the server, but get a numeric
- + * uid/gid as strings back, which means the name cache
- + * might have both representations.
- + */
- + if (info->attrmask.arr[1] & FATTR4_WORD1_OWNER) {
- + attr_request.count = 2;
- + attr_request.arr[1] |= FATTR4_WORD1_OWNER;
- + }
- + if (info->attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) {
- + attr_request.count = 2;
- + attr_request.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
- + }
- + }
- +
- compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
- getattr_args.attr_request = &attr_request;
- getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
- --
- 2.43.0
msnfs41client: Patches for stale namecache owner/owner_group info afer chgrp/chown
Posted by Anonymous on Tue 20th Feb 2024 07:33
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.